UNPKG

@ngenux/ngage-whiteboarding

Version:

A collaborative whiteboard React component with real-time synchronization

123 lines 3.45 kB
export type Point = { x: number; y: number; }; export type NormalizedPoint = { x: number; y: number; }; export type ShapeType = 'rectangle' | 'ellipse' | 'line' | 'pencil' | 'eraser' | 'arrow'; export type StrokeStyle = 'solid' | 'dashed' | 'dotted'; export type ShapeProps = { id: string; userId: string; type: ShapeType; points: Point[]; normalizedPoints?: NormalizedPoint[]; fill?: string; stroke: string; strokeWidth: number; strokeStyle?: StrokeStyle; opacity: number; isDragging?: boolean; isSelected?: boolean; isEraser?: boolean; erasePaths?: Point[][]; drawingSessionId?: string; timestamp?: number; rotation?: number; scaleX?: number; scaleY?: number; x?: number; y?: number; normalizedX?: number; normalizedY?: number; normalizedErasePaths?: Point[][]; }; export type ToolType = ShapeType | 'select' | 'pan'; export type ErasePayload = { shapeId: string; erasePath: Point[]; normalizedErasePath?: Point[]; timestamp?: number; }; export type DrawingAction = { type: 'add' | 'update' | 'delete' | 'clear' | 'start_draw' | 'continue_draw' | 'end_draw' | 'undo' | 'redo' | 'deselect_all' | 'select_shape' | 'set_background_color' | 'set_opacity' | 'set_stroke_width' | 'set_color' | 'set_stroke_style' | 'request_state' | 'sync_state' | 'user_undo' | 'user_redo' | 'user_clear' | 'erase' | 'toggle_lock' | 'update_allowed_users'; payload: ShapeProps | string | Partial<ShapeProps> | ShapeProps[] | number | StrokeStyle | WhiteboardSyncState | ErasePayload | { isUnlocked: boolean; adminId: string; timestamp: number; } | { allowedUsers: string[]; userId: string; timestamp: number; }; batchId?: string; timestamp?: number; requesterId?: string; userId?: string; }; export type WhiteboardState = { shapes: ShapeProps[]; history: ShapeProps[][]; historyIndex: number; tool: ToolType; color: string; backgroundColor: string; strokeWidth: number; strokeStyle: StrokeStyle; opacity: number; userId: string; isDrawing: boolean; captureEnabled: boolean; canvasSize: { width: number; height: number; }; selectedShapeId?: string; currentDrawingShape?: ShapeProps; activeDrawings: { [shapeId: string]: ShapeProps; }; lastClearTimestamp: number; userUndoStacks: { [userId: string]: ShapeProps[]; }; }; export type TransmissionData = { userId: string; roomId: string; actions: DrawingAction[]; timestamp: number; canvasSize?: { width: number; height: number; }; }; export type CompressedData = { data: string; compressionType: 'none' | 'delta' | 'base64' | 'gzip' | 'lz4'; originalSize?: number; compressedSize?: number; }; export type CollaborationCallbacks = { sendData?: (data: CompressedData) => void; onReceiveData?: (callback: (data: CompressedData) => void) => void; }; export type PerformanceMetrics = { drawingLatency: number; transmissionLatency: number; compressionRatio: number; fps: number; }; export type WhiteboardSyncState = { shapes: ShapeProps[]; backgroundColor: string; canvasSize: { width: number; height: number; }; timestamp: number; userId: string; }; //# sourceMappingURL=index.d.ts.map