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

    Interface UseWhiteboardSyncResult

    Sync hook return type

    interface UseWhiteboardSyncResult {
        activeUsers: Record<string, ActiveUser>;
        broadcastUpdate: (
            payload: Omit<WhiteboardPayload, "fileId" | "userId">,
        ) => void;
        connected: boolean;
        events: WhiteboardAuditEntry[];
        getEvents: () => WhiteboardAuditEntry[];
        getIsApplyingRemoteState: () => boolean;
        getLastRemoteApplyAt: () => number;
        isOwner: boolean;
        ownerPresent: boolean;
        readOnly: boolean;
        requestState: () => void;
        sendState: (targetUserId: string) => void;
        setEvents: (entries: WhiteboardAuditEntry[]) => void;
        setIsLoading: (loading: boolean) => void;
        setSuppressBroadcast: (suppress: boolean) => void;
        throttledBroadcastUpdate: (
            payload: Omit<WhiteboardPayload, "fileId" | "userId">,
        ) => void & { cancel: () => void };
    }
    Index

    Properties

    activeUsers: Record<string, ActiveUser>

    Active users in the whiteboard

    broadcastUpdate: (payload: Omit<WhiteboardPayload, "fileId" | "userId">) => void

    Broadcast a whiteboard update

    connected: boolean

    Whether connected to room

    Persistent audit-log buffer. Append-only across the hook's lifetime; capped to auditLogCap (default 10K) with a truncation sentinel. Reset on fileId change and on the initial mount of a freshly-loaded file (via initialEvents).

    getEvents: () => WhiteboardAuditEntry[]

    Read the current audit log without subscribing to state updates. Used by useWhiteboardFile.saveFile to roll the latest events into the persisted file without depending on a stale closure.

    getIsApplyingRemoteState: () => boolean

    Returns true while a snapshot or STATE_REPLACED payload is being applied to the canvas. The Whiteboard component reads this to skip debounced undo-stack pushes during snapshot enliven — Fabric's per-object object:added events fire from inside the load and would otherwise capture partial-snapshot states as undo entries. Stable identity (does not change between renders).

    getLastRemoteApplyAt: () => number

    Returns the ms timestamp of the most recent remote message applied to the canvas, or 0 if none. Consumed by useWhiteboardFile's autosave guard so a save can't snapshot a canvas that's mid-application of a peer's update.

    isOwner: boolean

    Whether the current user is the owner

    ownerPresent: boolean

    Whether owner is present (for non-owners)

    readOnly: boolean

    Whether in read-only mode

    requestState: () => void

    Request full state from owner

    sendState: (targetUserId: string) => void

    Send full state to a specific user

    setEvents: (entries: WhiteboardAuditEntry[]) => void

    Seed the audit log from a loaded / snapshot-received source. Replaces the current log atomically. Used by the file-load path and the late-joiner snapshot-apply path.

    setIsLoading: (loading: boolean) => void

    Mark a load in progress. Mirrors setSuppressBroadcast and is read by broadcastUpdate to drop any in-flight events while the canvas is being torn down + rebuilt.

    setSuppressBroadcast: (suppress: boolean) => void

    Pause local broadcasts. Used by the file-load and snapshot-apply paths so canvas mutations from the load don't get re-broadcast.

    throttledBroadcastUpdate: (
        payload: Omit<WhiteboardPayload, "fileId" | "userId">,
    ) => void & { cancel: () => void }

    Throttled version of broadcastUpdate for high-frequency events. Limits broadcasts to once per broadcastThrottleInterval (default 50ms = 20 updates/sec). Includes a cancel() method to cancel pending broadcasts.