import './utils/disposable'; import type { Unsubscribe, Logger } from './types'; interface TabSyncOptions { /** Enable debug logging (default: false). */ debug?: boolean; /** Custom logger (default: console). */ logger?: Logger; } /** * Cross-tab state synchronization via BroadcastChannel. * No WebSocket needed — works standalone for sharing state between browser tabs. * * @example * const sync = new TabSync('my-app'); * sync.set('theme', 'dark'); * sync.on('theme', (theme) => applyTheme(theme)); * * @example * // With debug logging * const sync = new TabSync('my-app', { debug: true }); */ export declare class TabSync implements Disposable { private store; private listeners; private bc; private disposed; private readonly log; constructor(channel?: string, options?: TabSyncOptions); /** Set a value and broadcast to all tabs. Local listeners also fire. */ set(key: string, value: T): void; /** Get current value from local store. */ get(key: string): T | undefined; /** Delete a key and broadcast deletion to all tabs. */ delete(key: string): void; /** Check if a key exists in the local store. */ has(key: string): boolean; /** Get all keys in the local store. */ keys(): string[]; /** Get number of entries. */ get size(): number; /** * Listen for changes to a key. Fires when any tab (including this one) calls set(). * * @example * sync.on('cart', (cart) => updateBadge(cart.items.length)); */ on(key: string, fn: (value: T) => void): Unsubscribe; /** Listen for a key change once, then auto-unsubscribe. */ once(key: string, fn: (value: T) => void): Unsubscribe; /** Clear all keys and notify listeners. */ clear(): void; /** Dispose — close BroadcastChannel and clear all state. */ dispose(): void; private emit; [Symbol.dispose](): void; } export {};