/** * Connection-layer primitive (`Connection` / `ConnectionRegistry`) described in * packages/electron-deck/docs/foundation.md §4. * * A `Connection` is one trusted webContents (keyed by the unforgeable `wc.id`). * It holds a single `DisposableRegistry` as its "lifetime segment" container. * The segment tears down deterministically (LIFO) on hard-destroy * (`wc.once('destroyed')`) or soft-reuse (`reset(id)`): * - hard destroy → dispose segment, fire 'closed' once, de-register. * - soft reset → dispose segment, swap in a fresh registry, fire 'reset', * connection stays alive & registered. * * §4.3: the terminal hook is `'destroyed'` (NOT `'render-process-gone'`), and * `DisposableRegistry.disposeAll` is async (LIFO) — so close/reset are async. */ import type { WebContents } from 'electron'; import { type Disposable } from './disposable.js'; export interface Connection { readonly id: number; readonly webContents: WebContents; readonly alive: boolean; /** Register a resource cleaned up with the current lifetime segment; the * returned Disposable releases it early. */ own(d: Disposable | (() => void)): Disposable; /** Connection-level lifecycle events; returns an unsubscribe Disposable. */ on(ev: 'reset' | 'closed', cb: () => void): Disposable; } export interface ConnectionRegistry { /** Build/fetch the connection for a (trusted) webContents; idempotent. */ acquire(wc: WebContents): Connection; get(id: number): Connection | undefined; all(): readonly Connection[]; /** Soft reuse: dispose the current segment, then swap in a fresh registry. */ reset(id: number): void; } export declare function createConnectionRegistry(): ConnectionRegistry; //# sourceMappingURL=connection.d.ts.map