export interface CrossTabMessage { id: string; senderTabId: string; projectId?: string; type: string; timestamp: number; payload: T; } export interface LocalMutationPayload { path: string; action: 'set' | 'patch' | 'update' | 'delete' | string; data?: any; metadata?: { mutationId?: string; source?: 'local' | 'server' | string; state?: 'pending' | 'acknowledged' | string; hasPendingWrites?: boolean; [key: string]: any; }; } export type CrossTabMessageHandler = (payload: T, message: CrossTabMessage) => void; export type MutationSyncHandler = (path: string, action: string, data?: any, metadata?: LocalMutationPayload['metadata']) => void; /** * Serializes rich JavaScript objects (Timestamp, GeoPoint, Date) into structured JSON-safe * objects with explicit type tags so they can cross BroadcastChannel or localStorage boundaries safely. */ export declare function serializeCrossTabData(data: any, seen?: WeakSet): any; /** * Deserializes structured JSON-safe objects back into rich JavaScript types (Timestamp, GeoPoint, etc.). */ export declare function deserializeCrossTabData(data: any): any; /** * Checks if native BroadcastChannel is supported in the current environment. */ export declare function isBroadcastChannelSupported(): boolean; /** * CrossTabSyncChannel provides ultra-fast, local cross-tab state synchronization * with native BroadcastChannel support and automatic fallback to localStorage storage events. */ export declare class CrossTabSyncChannel { readonly channelName: string; readonly tabId: string; private broadcastChannel; private listeners; private wildcardListeners; private storageListener; private isClosed; constructor(channelName: string); private initTransport; private handleIncomingRawMessage; /** * Broadcasts a typed message across all other browser tabs. */ broadcast(type: string, payload: T, projectId?: string): void; /** * Broadcasts a local mutation event (write, update, delete) to keep caches across tabs in sync instantly. */ broadcastMutation(path: string, action: string, data?: any, metadata?: LocalMutationPayload['metadata'], projectId?: string): void; /** * Subscribes to a specific event type. Returns an unsubscribe callback. */ on(type: string, handler: CrossTabMessageHandler): () => void; /** * Subscribes to all incoming messages regardless of type. */ onAny(handler: CrossTabMessageHandler): () => void; /** * Helper specifically for listening to local mutations across tabs. */ onMutation(handler: MutationSyncHandler): () => void; /** * Closes the channel and removes all event listeners. */ close(): void; } /** * Returns a singleton instance of CrossTabSyncChannel for the given channel name. */ export declare function getCrossTabChannel(channelName: string): CrossTabSyncChannel; /** * Creates or gets a project-scoped cross-tab synchronization channel. */ export declare function getProjectCrossTabChannel(projectId: string): CrossTabSyncChannel;