import type { Peer } from "../sync.js"; import type { AcceptFromPortOptions, WaitForConnectionOptions, ExposeOptions, MessagePortLike, PostMessageTarget } from "./types.js"; /** * CojsonMessageChannel provides a low-level API for creating cojson peers * that communicate via the MessageChannel API (or compatible implementations * like Electron's MessageChannelMain). * * Inspired by Comlink, it handles: * - Port management (creating MessageChannels and transferring ports) * - Handshake protocol (ensuring both sides are ready) * - Peer creation (returning a standard cojson Peer) */ export declare class CojsonMessageChannel { /** * Expose a cojson connection to a target with a postMessage API. * Creates a MessageChannel, transfers port2 to the target, and waits for handshake. * * @param target - Any object with a postMessage method (Worker, Window, MessagePort, etc.) * @param opts - Configuration options * @returns A promise that resolves to a Peer once the handshake completes */ static expose(target: PostMessageTarget, opts?: ExposeOptions): Promise; /** * Wait for an incoming Jazz connection. * Listens for a port transfer message on the global scope and completes the handshake. * * @param opts - Configuration options * @returns A promise that resolves to a Peer once the handshake completes */ static waitForConnection(opts?: WaitForConnectionOptions): Promise; /** * Accept an incoming Jazz connection from a specific port. * Lower-level API useful for testing or when you already have the port. * This method has no timeout - it will wait indefinitely for the handshake. * * @param port - The MessagePort to accept the connection on * @param opts - Configuration options * @returns A promise that resolves to a Peer once the handshake completes */ static acceptFromPort(port: MessagePortLike, opts?: AcceptFromPortOptions): Promise; } //# sourceMappingURL=CojsonMessageChannel.d.ts.map