import type { InitMsg } from "../transport/protocol"; import type { WorkerRenderer } from "./renderer.worker"; /** * Adapter that satisfies the `MessagePort` shape `WorkerRenderer` * expects (it only ever calls `.postMessage` on it). Outgoing posts * get session-tagged on the way out so the host can route them to * the right `RendererTransport` instance. * * The receive direction is handled exclusively by the worker-scope * `self.addEventListener("message", …)` installed by `installSessionHost`; * this adapter does not own a real port pair. */ export declare function makeSessionPort(sessionId: number): MessagePort; /** * Install the shared message handler on the worker scope. One worker * process hosts many `WorkerRenderer` instances, one per `sessionId` * allocated by the host's `RendererTransport`; this listener * demultiplexes incoming `ControlEnvelope`s and routes them to the * matching renderer. * * The `bootstrap` callback constructs a `WorkerRenderer` from an * `InitMsg` and a session-tagged port. It's injected so this module * doesn't need to import `renderer.worker` for runtime bindings (avoids * a runtime cycle — `renderer.worker` imports this module). */ export declare function installSessionHost(bootstrap: (msg: InitMsg, port: MessagePort) => Promise): void;