import { d as BridgePushThemeEnvelope, c as BridgePushLocaleEnvelope, b as BridgePushDensityEnvelope, a as BridgePushA11yEnvelope, B as BridgeNavPushEnvelope, e as BridgeSessionTokenPushEnvelope } from './bridge-envelopes-DA6vxbyb.js'; /** * Plugin-side bridge client for the host ↔ plugin platform contract * (WI 4858 sub-plan 2). * * `createPortBridgeClient` wraps a MessagePort (or an in-realm shim) and * exposes typed subscription callbacks for each host push (theme, locale, * density, a11y, nav, session token) and typed fire-and-wait calls for * chrome requests and a11y live-region announcements. * * For in-realm (Tier T) plugins, use `InMemoryBridgeTransport` from the * mock-host package instead — it calls callbacks synchronously without * any serialisation. */ type ThemePayload = Omit; type LocalePayload = Omit; type DensityPayload = Omit; type A11yPayload = Omit; type NavPayload = Omit; type SessionTokenPayload = Omit; /** * Minimal port surface `createPortBridgeClient` actually uses. Matches * `PortShim` in `createPortMcpTransport` — same test-injection pattern. */ interface BridgePortShim { onmessage: ((ev: { data: unknown; }) => void) | null; postMessage(msg: unknown): void; } interface PortBridgeClient { /** Replace the theme subscriber. Only the latest subscriber is called. */ onTheme(cb: (payload: ThemePayload) => void): void; /** Replace the locale subscriber. */ onLocale(cb: (payload: LocalePayload) => void): void; /** Replace the density subscriber. */ onDensity(cb: (payload: DensityPayload) => void): void; /** Replace the a11y-preferences subscriber. */ onA11y(cb: (payload: A11yPayload) => void): void; /** Replace the nav-state subscriber. */ onNav(cb: (payload: NavPayload) => void): void; /** Replace the session-token subscriber. */ onSessionToken(cb: (payload: SessionTokenPayload) => void): void; /** * Request a host chrome action. Returns the host's result or rejects with * the host's error string. Callers should catch and surface gracefully. * * @param action "toast" | "confirm" | "openUrl" * @param payload Action-specific payload. */ requestChrome(action: string, payload: Record): Promise; /** * Ask the host to make a live-region announcement on behalf of the plugin. * Prefers this over writing directly to the DOM so the host can manage * ARIA live regions centrally. */ announceA11y(message: string, politeness: "polite" | "assertive"): void; } /** * Construct a bridge client backed by a `MessagePort` (or shim). * * Registers a single `onmessage` handler on the port that dispatches each * bridge push to the appropriate subscriber. Unknown message types are * silently ignored — the port carries MCP traffic on the same channel and * those messages must not trigger an error here. */ declare function createPortBridgeClient(port: BridgePortShim): PortBridgeClient; export { type A11yPayload as A, type BridgePortShim as B, type DensityPayload as D, type LocalePayload as L, type NavPayload as N, type PortBridgeClient as P, type SessionTokenPayload as S, type ThemePayload as T, createPortBridgeClient as c };