/** * The page runtime's one seam to whatever carries its traffic to the DevTools * server. Every `lit:*` message the runtime sends or receives (timeline * events, inspector data and commands, settings overrides, HMR-incompatibility * notices) goes through {@link pageChannel}, never through `import.meta.hot` * directly, so the carrier can be swapped without touching a call site. * * Carriers: Vite's HMR channel ({@link fromViteHot}), a dev server's RPC * (`rpc-transport.ts`), the extension's window relay (`window-transport.ts`). * More than one can be attached at once, when the extension's panel and the * dev server's both watch a page; each is attached with * {@link PageChannel.attach}, and listeners registered earlier bind to it. * * Vite's own lifecycle events (`vite:afterUpdate`, `vite:beforeFullReload`, * `vite:ws:*`) are not part of this channel: they describe the HMR connection * itself, so the sites that care still read `import.meta.hot` for those. */ export type { PageTransport, ViteHotLike } from './page-transport.js'; import { type PageTransport, type ViteHotLike } from './page-transport.js'; export interface PageChannel extends PageTransport { /** Whether a carrier is attached. Sends made before one is are dropped. */ readonly attached: boolean; /** The carriers in use, so a replacement can hand the channel back. */ readonly carriers: readonly PageTransport[]; /** * Add `transport` as a carrier, or announce again on one already added. * Sends go to every carrier and listeners hear each, so two peers (the * extension's panel and the dev server's) can share one runtime. Listeners * already registered are bound to it, and `onAttach` callbacks run so their * owners can announce themselves to the new peer. */ attach(transport: PageTransport): void; /** Remove a carrier `attach` added; its listeners are unbound. */ detach(transport: PageTransport): void; /** * Add Vite's HMR client as a carrier, once per page whichever module asks * first, and count the Vite-served runtime among the page's * (`runtime-registry.ts`). */ useViteHot(hot: ViteHotLike): void; /** Run `callback` on every later {@link attach}. Not run for past ones. */ onAttach(callback: () => void): void; } export declare const pageChannel: PageChannel; //# sourceMappingURL=page-channel.d.ts.map