/** * Cross-Tab Communication Manager * Handles communication between main page (with voice agent) and navigation tab * Uses BroadcastChannel API for reliable cross-tab messaging */ /** * Message types for cross-tab communication */ export type CrossTabMessageType = 'addToCart' | 'removeFromCart' | 'updateQuantity' | 'navigate' | 'getContext' | 'contextResponse' | 'searchElements' | 'searchElementsResponse' | 'getPageSnapshot' | 'pageSnapshotResponse' | 'clickElement' | 'typeIntoElement' | 'pressKey' | 'focusElement' | 'scrollToElement' | 'domActionResponse'; /** * Cross-tab message structure */ export interface CrossTabMessage { type: CrossTabMessageType; payload: any; timestamp: number; messageId: string; } /** * Cross-tab communication manager * Manages BroadcastChannel for communication between main tab and navigation tab * * @example * ```ts * // On main page (with voice agent) * const manager = CrossTabManager.getInstance(); * manager.sendMessage('addToCart', { productId: '123', quantity: 1 }); * * // On navigation tab * const manager = CrossTabManager.getInstance(); * manager.onMessage((message) => { * if (message.type === 'addToCart') { * // Add item to cart * } * }); * ``` */ export declare class CrossTabManager { private static instance; private channel; private messageHandlers; private readonly channelName; private constructor(); /** * Get singleton instance */ static getInstance(): CrossTabManager; /** * Initialize BroadcastChannel */ private initChannel; /** * Send a message to all tabs */ sendMessage(type: CrossTabMessageType, payload: any): void; /** * Register a message handler for a specific message type * * @param type - Message type to listen for * @param handler - Callback function * @returns Unsubscribe function */ onMessage(type: CrossTabMessageType, handler: (payload: any) => void): () => void; /** * Register a global message handler (receives all messages) * * @param handler - Callback function that receives the full message * @returns Unsubscribe function */ onAnyMessage(handler: (message: CrossTabMessage) => void): () => void; /** * Send a request and wait for a response * Useful for getting data from the navigation tab * * @param type - Request message type * @param payload - Request payload * @param responseType - Expected response message type * @param timeout - Timeout in milliseconds (default: 5000) * @returns Promise that resolves with response payload */ request(type: CrossTabMessageType, payload: any, responseType: CrossTabMessageType, timeout?: number): Promise; /** * Close the channel (cleanup) */ close(): void; /** * Check if BroadcastChannel is supported */ static isSupported(): boolean; } //# sourceMappingURL=CrossTabManager.d.ts.map