import { Envelope, HostEnvelope, HostOp, PluginEnvelope, PluginOp } from '../protocol/envelope.js'; export type EnvelopeHandler = (env: E) => void; /** Subset of the DOM `Window` we depend on. Tests pass a stub. */ export interface MessageWindow { addEventListener(type: 'message', listener: (event: MessageEvent) => void, options?: { signal?: AbortSignal; }): void; removeEventListener(type: 'message', listener: (event: MessageEvent) => void): void; } export interface MessageTarget { postMessage(message: unknown, targetOrigin: string): void; } export interface BusOptions { /** Identity check on every receive. Tightens the trust boundary. */ allowedOrigins: string[]; /** Optional handle to a specific `MessageEventSource` we expect. */ expectedSource?: MessageEventSource | null; /** Stub-friendly window. Defaults to the platform `window` at runtime. */ window?: MessageWindow; } declare abstract class BaseMessageBus { protected readonly options: BusOptions; protected handlers: Set>; protected disposed: boolean; private readonly listener; private readonly hostWindow; constructor(options: BusOptions); on(handler: EnvelopeHandler): () => void; dispose(): void; protected abstract get target(): MessageTarget; protected abstract get targetOrigin(): string; protected abstract isExpectedDirection(env: Envelope): env is TRecv; send(envelope: TSend): void; private handleMessage; } export interface IframeBusOptions extends BusOptions { /** The parent we postMessage UP to. Defaults to `window.parent`. */ parent?: MessageTarget; } /** * The bus a plugin instance uses to talk to its host shell. Send a * `PluginEnvelope` UP, receive `HostEnvelope`s DOWN. */ export declare class IframeMessageBus extends BaseMessageBus { private readonly parentTarget; private readonly origin; constructor(opts: IframeBusOptions); protected get target(): MessageTarget; protected get targetOrigin(): string; protected isExpectedDirection(env: Envelope): env is HostEnvelope; } export interface ParentBusOptions extends BusOptions { /** The iframe element we postMessage DOWN to. */ iframe: HTMLIFrameElement; } /** * The bus a host page uses to talk to one iframe-mounted plugin instance. * Send a `HostEnvelope` DOWN, receive `PluginEnvelope`s UP. */ export declare class ParentMessageBus extends BaseMessageBus { private readonly iframe; private readonly origin; constructor(opts: ParentBusOptions); protected get target(): MessageTarget; protected get targetOrigin(): string; protected isExpectedDirection(env: Envelope): env is PluginEnvelope; } export declare function buildHostEnvelope

(kind: HostOp, payload: P, requestId?: string): HostEnvelope

; export declare function buildPluginEnvelope

(kind: PluginOp, payload: P, requestId?: string): PluginEnvelope

; export {}; //# sourceMappingURL=message-bus.d.ts.map