Hiyve Components - v1.0.0
    Preparing search index...

    Interface UseWhiteboardSyncOptions

    Options for the useWhiteboardSync hook

    interface UseWhiteboardSyncOptions {
        auditLogCap?: number;
        canvas: Canvas | null;
        fileId: string;
        fileOwner?: string;
        getBackgroundSnapshotData?: () => {
            activeIndex: number;
            pages: {
                pageNumbers?: number[];
                sourceFileId: string;
                sourceFileName: string;
                type: "image"
                | "pdf-page";
            }[];
        };
        initialEvents?: WhiteboardAuditEntry[];
        isOwner: boolean;
        onError?: (error: Error) => void;
        onRemoteBackgroundPageChanged?: (index: number) => void;
        onRemoteBackgroundPagesSpec?: (
            pages: {
                pageNumbers?: number[];
                sourceFileId: string;
                sourceFileName: string;
                type: "image" | "pdf-page";
            }[],
            activeIndex: number,
        ) => void;
        onRemoteCanvasCleared?: () => void;
        onRemoteLaserUpdate?: (
            fromUserId: string,
            positions: { t: number; x: number; y: number }[],
            color: string,
            isEndBatch: boolean,
        ) => void;
        onRemoteObjectAdded?: (object: WhiteboardObject) => void;
        onRemoteObjectModified?: (object: WhiteboardObject) => void;
        onRemoteObjectRemoved?: (objectId: string) => void;
        onStateReceived?: () => void;
        sharedWith?: string[];
        styles?: Partial<WhiteboardStyles>;
        userId: string;
    }
    Index

    Properties

    auditLogCap?: number

    Cap on the audit log size. When exceeded, the oldest entries are dropped and a { userId: '__truncated__' } sentinel is inserted at the head so consumers can render "older entries omitted".

    10000
    
    canvas: Canvas | null

    Fabric.js canvas instance

    fileId: string

    File ID for this whiteboard

    fileOwner?: string

    The file owner's userId. Used together with sharedWith to filter incoming broadcast messages. Only messages from the owner or a user in sharedWith are accepted.

    getBackgroundSnapshotData?: () => {
        activeIndex: number;
        pages: {
            pageNumbers?: number[];
            sourceFileId: string;
            sourceFileName: string;
            type: "image"
            | "pdf-page";
        }[];
    }

    Called when the owner needs to attach the current background spec to a late-joiner snapshot. Returns the current pages spec (no dataUrls) and active page index. The receiver applies via onRemoteBackgroundPagesSpec after the canvas loads.

    initialEvents?: WhiteboardAuditEntry[]

    Initial audit-log entries to seed the in-memory buffer at mount (typically file.events from useWhiteboardFile). Reset whenever fileId changes. Without this the audit panel would only show events captured during the current session.

    isOwner: boolean

    Whether the current user is the owner

    onError?: (error: Error) => void

    Called when an async operation fails

    onRemoteBackgroundPageChanged?: (index: number) => void

    Called when a peer broadcasts a background-page change. Consumer applies via useBackgroundImage.applyRemoteActivePage.

    onRemoteBackgroundPagesSpec?: (
        pages: {
            pageNumbers?: number[];
            sourceFileId: string;
            sourceFileName: string;
            type: "image" | "pdf-page";
        }[],
        activeIndex: number,
    ) => void

    Called when the file owner broadcasts a full background-pages spec (add / remove / clear). Consumer rebuilds the local backgrounds from the spec — usually by re-fetching each sourceFileId and rendering. Receivers ignore this event from non-owner senders.

    onRemoteCanvasCleared?: () => void

    Called when canvas is cleared by remote

    onRemoteLaserUpdate?: (
        fromUserId: string,
        positions: { t: number; x: number; y: number }[],
        color: string,
        isEndBatch: boolean,
    ) => void

    Called when a peer broadcasts a laser-pointer position batch. Consumer typically wires this directly to useLaserPointer.handleRemoteLaserUpdate. Without this callback, remote laser pointers are dropped silently (laser is local-only).

    onRemoteObjectAdded?: (object: WhiteboardObject) => void

    Called when a remote object is added

    onRemoteObjectModified?: (object: WhiteboardObject) => void

    Called when a remote object is modified

    onRemoteObjectRemoved?: (objectId: string) => void

    Called when a remote object is removed

    onStateReceived?: () => void

    Called when full state is received

    sharedWith?: string[]

    User IDs that have access to this file. When empty or omitted, owner-only: only the file owner's broadcasts are accepted (effectively no cross-user sync for unshared files).

    styles?: Partial<WhiteboardStyles>

    Custom styles

    userId: string

    User ID