/** Fixed BroadcastChannel name shared by all mates apps / packages. */ export declare const MATES_XTAB_CHANNEL = "mates:xtab"; export type XTabHandler = (type: string, data: unknown) => void; /** * Shared cross-tab bus for the whole mates ecosystem. * * One `BroadcastChannel` (`mates:xtab`). Libraries and apps publish with * `trigger(type, data)` and listen with `__subscribe` or * `on((type, data) => { … }, [xTabEvent])`. * * - `trigger` posts to other tabs **and** runs local handlers (same tab). * - `__subscribe` auto-unsubscribes on component unmount when a host exists. * - SSR / no `BroadcastChannel`: local handlers only. */ export type XTabEventType = { /** * Broadcast `type` + `data` to every tab, and notify local subscribers. */ trigger(type: string, data?: unknown): void; /** * Listen for every message on the shared bus. * Returns unsubscribe. Inside a component, also registers cleanup on the host. */ __subscribe(fn: XTabHandler): () => void; /** Close the BroadcastChannel and clear local handlers (tests / app teardown). */ close(): void; readonly name: typeof MATES_XTAB_CHANNEL; readonly __isEvent___: true; readonly __isXTabEvent___: true; }; /** * Singleton cross-tab event bus. Prefer this over rolling your own * `BroadcastChannel` in mates packages (e.g. mates-db). * * @example * ```ts * import { on, xTabEvent } from "mates"; * * // Listen (component — auto-unsub on unmount via registerCleanup) * xTabEvent.__subscribe((type, data) => { * if (type === "mates-db:sync") reload(data); * }); * * // Or with on(): * on((type, data) => { * if (type === "theme") document.body.dataset.theme = String(data); * }, [xTabEvent]); * * // Publish * xTabEvent.trigger("theme", "dark"); * ``` */ export declare const xTabEvent: XTabEventType; //# sourceMappingURL=xTabEvent.d.ts.map