import { MessageHandler, MessageType, MessengerOptions } from './types.ts'; /** * `Messenger` abstracts away the raw `window.postMessage` / `addEventListener` * API and enforces: * - Typed send API. */ export declare class Messenger { private readonly targetWindow; private readonly targetOrigin; private readonly allowedOrigin; /** Map of message-type → set of handlers registered via `.on()`. */ private readonly handlers; /** Bound reference kept so we can remove the exact same listener in `destroy()`. */ private readonly boundListener; constructor(options: MessengerOptions); /** * Send a typed message **to** the widget iframe. * * @param type - One of the protocol's `MessageType` values. * @param data - Arbitrary payload; typed by the caller. */ send(type: MessageType, data: T): void; /** * Subscribe to a specific message type **from** the widget. * Returns an unsubscribe function for convenience. * * @param type - The `MessageType` to listen for. * @param handler - Callback invoked with the `data` field of the payload. */ on(type: MessageType, handler: MessageHandler): () => void; /** * Remove all registered handlers and the window-level `message` listener. * Must be called during SDK teardown to prevent memory leaks. */ destroy(): void; private handleMessage; }