/** * The per-shell windows hub (API §10). `ViewStage` mounts once near the root while * `ViewHost`s live anywhere, so they rendezvous through a hub keyed by the shared * `Shell` instance (a `WeakMap`), not context. It owns the `WindowRegistry` * (reactive store behind `useWindows`/`useWindow`, fed by the hosts), the stage * controller (the slot layer, published by the stage), and the adopt stash. */ import type { Shell, Window } from '@astrale-os/shell'; import type { AdoptRecord } from './adopt.js'; import type { WindowState } from './lifecycle/states.js'; import type { StageController } from './placement.js'; /** A `useWindow` projection — a window's phase plus its shell `Window` (or none). */ export type WindowView = WindowState & { readonly window: Window | null; }; export interface WindowRegistry { /** Referentially stable between mutations (useSyncExternalStore contract). */ getSnapshot(): ReadonlyMap; /** Stable projection for one window id (null id → a stable "no window"). */ select(windowId: string | null): WindowView; subscribe(onChange: () => void): () => void; /** Host writes: register/transition/drop a window. */ upsert(windowId: string, window: Window, state: WindowState): void; patch(windowId: string, state: WindowState): void; remove(windowId: string): void; /** Shell writes: replace host and imperatively mounted windows from authoritative snapshots. */ sync(windows: ReadonlyMap): void; } export interface StageHub { readonly registry: WindowRegistry; getController(): StageController | null; /** Publish (stage mount) or retract (stage unmount) the slot layer. */ setController(controller: StageController | null): void; /** Await the controller — fires immediately if one is already published. */ onController(cb: (controller: StageController | null) => void): () => void; /** Stash an unmounting host's live window; disposes after one macrotask if unadopted. */ stashForAdopt(key: string, record: AdoptRecord): void; /** Reclaim a stashed window for a remount of the same source, cancelling its dispose. */ takeAdopt(key: string): AdoptRecord | null; } /** The windows hub for a shell — one per shell object, created on first touch. */ export declare function getStageHub(shell: Shell): StageHub; //# sourceMappingURL=hub.d.ts.map