openpencil/src/constants.ts
Danila Poyarkov f90e1400b7 P2P collaboration: cursors, follow mode, cleanup
- Broadcast cursor position from canvas mouse move via awareness
- Broadcast selection changes via reactive watcher on selectedIds
- Follow mode: click peer avatar to track their viewport (pan + zoom)
- Zoom broadcast via watcher on store.state.zoom, not just mouse move
- Figma-style cursor arrows: colored fill, white border, name pill
- Stale cursor cleanup: removeAwarenessStates on peer leave
- MQTT signaling (replace Nostr), STUN + TURN ICE servers
- Collab constants extracted to src/constants.ts
- crypto.getRandomValues() replaces Math.random() everywhere
- Provide/inject for collab composable (COLLAB_KEY)
- Update README (collab section, tech stack), CHANGELOG, AGENTS.md
- AGENTS.md: release process, CI workflows, documentation guidelines
2026-03-01 18:11:07 +03:00

127 lines
2.9 KiB
TypeScript

export {
IS_TAURI,
SELECTION_COLOR,
COMPONENT_COLOR,
SNAP_COLOR,
CANVAS_BG_COLOR,
ROTATION_HANDLE_OFFSET,
SNAP_THRESHOLD,
RULER_SIZE,
RULER_BG_COLOR,
RULER_TICK_COLOR,
RULER_TEXT_COLOR,
RULER_BADGE_HEIGHT,
RULER_BADGE_PADDING,
RULER_BADGE_RADIUS,
RULER_BADGE_EXCLUSION,
RULER_TEXT_BASELINE,
RULER_MAJOR_TICK,
RULER_MINOR_TICK,
RULER_HIGHLIGHT_ALPHA,
PEN_HANDLE_RADIUS,
PEN_VERTEX_RADIUS,
PEN_CLOSE_RADIUS_BOOST,
PEN_PATH_STROKE_WIDTH,
PARENT_OUTLINE_ALPHA,
PARENT_OUTLINE_DASH,
DEFAULT_FONT_SIZE,
LABEL_FONT_SIZE,
SIZE_FONT_SIZE,
ROTATION_HANDLE_RADIUS,
HANDLE_HALF_SIZE,
LABEL_OFFSET_Y,
SIZE_PILL_PADDING_X,
SIZE_PILL_PADDING_Y,
SIZE_PILL_HEIGHT,
SIZE_PILL_RADIUS,
SIZE_PILL_TEXT_OFFSET_Y,
MARQUEE_FILL_ALPHA,
SELECTION_DASH_ALPHA,
DROP_HIGHLIGHT_ALPHA,
DROP_HIGHLIGHT_STROKE,
LAYOUT_INDICATOR_STROKE,
SECTION_CORNER_RADIUS,
SECTION_TITLE_HEIGHT,
SECTION_TITLE_PADDING_X,
SECTION_TITLE_RADIUS,
SECTION_TITLE_FONT_SIZE,
SECTION_TITLE_GAP,
COMPONENT_SET_DASH,
COMPONENT_SET_DASH_GAP,
COMPONENT_SET_BORDER_WIDTH,
COMPONENT_LABEL_FONT_SIZE,
COMPONENT_LABEL_GAP,
COMPONENT_LABEL_ICON_SIZE,
COMPONENT_LABEL_ICON_GAP,
RULER_TARGET_PIXEL_SPACING,
RULER_MAJOR_TOLERANCE
} from '@open-pencil/core'
import type { Color } from '@/types'
import type { Fill, Stroke } from '@open-pencil/core'
export const TRYSTERO_APP_ID = 'openpencil'
export const ROOM_ID_LENGTH = 8
export const ROOM_ID_CHARS = 'abcdefghijklmnopqrstuvwxyz0123456789'
export const PEER_COLORS: Color[] = [
{ r: 0.96, g: 0.26, b: 0.21, a: 1 },
{ r: 0.13, g: 0.59, b: 0.95, a: 1 },
{ r: 0.3, g: 0.69, b: 0.31, a: 1 },
{ r: 1.0, g: 0.76, b: 0.03, a: 1 },
{ r: 0.61, g: 0.15, b: 0.69, a: 1 },
{ r: 1.0, g: 0.34, b: 0.13, a: 1 },
{ r: 0.0, g: 0.74, b: 0.83, a: 1 },
{ r: 0.91, g: 0.12, b: 0.39, a: 1 }
]
export const YJS_JSON_FIELDS = new Set([
'childIds',
'fills',
'strokes',
'effects',
'vectorNetwork',
'boundVariables',
'styleRuns'
])
export const DEFAULT_SHAPE_FILL: Fill = {
type: 'SOLID',
color: { r: 0.83, g: 0.83, b: 0.83, a: 1 },
opacity: 1,
visible: true
}
export const DEFAULT_FRAME_FILL: Fill = {
type: 'SOLID',
color: { r: 1, g: 1, b: 1, a: 1 },
opacity: 1,
visible: true
}
export const HANDLE_SIZE = 6
export const DRAG_DEAD_ZONE = 4
export const PEN_CLOSE_THRESHOLD = 8
export const ROTATION_SNAP_DEGREES = 15
export const ROTATION_HIT_OFFSET = 24
export const DEFAULT_TEXT_WIDTH = 200
export const DEFAULT_TEXT_HEIGHT = 24
export const AUTO_LAYOUT_BREAK_THRESHOLD = 8
export const HANDLE_HIT_RADIUS = 6
export const ROTATION_HIT_RADIUS = 8
export const ZOOM_SENSITIVITY = 0.99
export const SECTION_DEFAULT_FILL: Fill = {
type: 'SOLID',
color: { r: 0.37, g: 0.37, b: 0.37, a: 1 },
opacity: 1,
visible: true
}
export const SECTION_DEFAULT_STROKE: Stroke = {
color: { r: 0.55, g: 0.55, b: 0.55, a: 1 },
weight: 1,
opacity: 1,
visible: true,
align: 'INSIDE'
}