import { ChildConnectorApi, HostConnectorApi } from "@trackunit/iris-app-runtime-core-api"; import { Connection, Methods } from "penpal"; type HostConnectorMethods = HostConnectorApi & Methods; /** * Install a handler for one of the host-driven subscription methods on the * singleton `host-runtime` channel. Returns an unregister function that * restores the previously installed handler (typically the * `doNothingByDefault` no-op); call it from the effect's cleanup. * * Safe to call before the singleton's penpal handshake completes: the * singleton's child-facing methods look up the current handler at call time, * so handlers registered after `connect()` has resolved still receive events. */ export declare const registerHostChangeHandler: (name: TKey, handler: ChildConnectorApi[TKey]) => (() => void); /** * Setup using the subscribedMethods to subscribe to events from the host. * * @param subscribedMethods the methods to subscribe to. Any key omitted here * dispatches through the {@link registerHostChangeHandler} registry on the * singleton connection, so internal callers can register handlers via that * path without opening a second penpal connection. * @param channel the penpal channel to use; defaults to `undefined`. The * default singleton on the iris-app side intentionally omits the channel so * the host's matching `connect()` call (which also omits it) can accept * both native v7 SYNs and v6 SYNs translated by penpal's v6-compat shim * (`upgradeMessage` produces v7 messages with `channel: undefined`). External * callers can still pin a channel for isolated parallel connections; the * host won't auto-handshake those — they're for caller-managed transports. * @returns { Connection } the connection to the host */ export declare const setupHostConnector: (subscribedMethods: Partial & Methods, channel?: string) => Connection; /** * Gets the host connector. * * Returns penpal v7's {@link RemoteProxy} directly. The proxy is a JavaScript * `Proxy` that intercepts every method access via a `get` trap and routes the * call to the host through the underlying `MessagePort`. Attempting to spread * or `Object.assign` it produces an empty object — the proxy has no own * enumerable properties, only the `get` trap. * * The return is type-cast to `HostConnectorApi` because v7's `RemoteProxy` * is a mapped type that erases method-level generics (e.g. `exportData`'s * `` is widened to ``). At runtime the * proxy serializes whatever data the caller hands it across `postMessage`, so * the original generics are honoured by the host on the other end — the * widening is purely a TypeScript artefact at this library boundary. * * @returns { Promise } the connection to the host */ export declare const getHostConnector: () => Promise; export {};