/** * Runs a devframe definition in the same JavaScript realm as its client, with * no server and no wire in between: the host for the Chrome DevTools * extension, which shows the Lit panel for pages no dev server is watching. * * devframe has no hook for this. Its client (`connectDevframe()`) only speaks * WebSocket, SSE or a static dump, and its host (`createHostContext()`) is * built on `node:` modules, so neither half runs in an extension page. What * runs fine is the definition itself (see `definition.ts`), and its `setup()` * touches a small slice of the node context. {@link createLocalHost} * implements exactly that slice and hands back a client whose calls go * straight to the registered handlers. * * Where devframe ships browser-safe pieces they are reused rather than * re-implemented: shared state (`devframe/utils/shared-state`), stream sinks * and readers (`devframe/utils/streaming-channel`) and the client's own * `lit:` scoping and settings stores (`createScopedClientContext()`), so the * panel sees the namespacing and settings semantics it gets from a real * connection. The remaining differences are deliberate: * * - Shared states are one object on both sides, not two mirrors. A mutation * is visible to the other side at once, with no patch round trip. * - Call arguments, results, broadcasts and stream chunks are * `structuredClone`d, so neither side can mutate (or be handed a frozen * copy of) the other's objects. A wire would have copied them too. * - `settings` live in a {@link KeyValueStorage} the embedder supplies (the * extension passes `chrome.storage`), not a JSON file. * - No services: `services.get()` answers `undefined`, which is how * `open-source` learns there is no editor to open. */ import type { DevframeRpcClient } from 'devframe/client'; import type { DevframeDefinition } from 'devframe'; /** * Durable storage for the settings stores. Each store is one entry, keyed by * its devframe shared-state key (`devframe:settings:global:lit`) and holding * the whole settings object, which maps directly onto `chrome.storage.local`. */ export interface KeyValueStorage { /** The stored value, or `undefined` when there is none. */ get(key: string): Promise; set(key: string, value: unknown): Promise; } /** A {@link KeyValueStorage} that forgets everything with the page. */ export declare const createMemoryStorage: () => KeyValueStorage; export interface LocalHostOptions { /** Where settings persist. Defaults to {@link createMemoryStorage}. */ storage?: KeyValueStorage; } /** * The slice of devframe's {@link DevframeRpcClient} the local host provides: * what `createScopedClientContext()` and the panel reach for. The rest * (trust handshakes, the RPC cache, wire services) has nothing behind it. */ export type LocalDevframeClient = Pick; /** * Run `definition.setup()` against an in-process context and return a client * wired straight to it. Resolves once setup has finished, so the client's * first call already finds every function registered. */ export declare function createLocalHost(definition: DevframeDefinition, options?: LocalHostOptions): Promise; //# sourceMappingURL=local-host.d.ts.map