import { ReactiveControllerHost } from 'lit'; import { BaseController } from './base.controller.js'; export type MessageHandler = (payload: unknown) => void; export type WildcardMessageHandler = (type: string, payload: unknown) => void; /** * Controller for postMessage communication with iframes or other windows. * * @example * ```ts * class MyIframeHost extends LitElement { * private messageBus = new MessageBusController(this); * * connectedCallback() { * super.connectedCallback(); * this.messageBus.onMessage('READY', (payload) => { * console.log('Iframe is ready', payload); * }); * } * * sendToIframe() { * this.messageBus.send('COMMAND', { action: 'do-something' }); * } * } * ``` */ export declare class MessageBusController extends BaseController { private handlers; private wildcardHandlers; private targetOrigin; /** * @param host - The reactive controller host * @param targetOrigin - The origin to accept messages from and send messages to. * SECURITY NOTE: Using '*' accepts messages from any origin which can be dangerous. * Always specify an explicit origin in production environments. */ constructor(host: ReactiveControllerHost, targetOrigin?: string); send(type: string, payload: unknown, targetWindow?: Window): void; sendToFrame(iframe: HTMLIFrameElement, type: string, payload: unknown): void; onMessage(type: string, handler: MessageHandler): () => void; onMessage(type: '*', handler: WildcardMessageHandler): () => void; private handleMessage; hostConnected(): void; hostDisconnected(): void; } //# sourceMappingURL=message-bus.controller.d.ts.map