/** * Render-scoped head collection and document sync. * * Loaders and render-time `head()` calls push `HeadInput` entries into a * store scoped to the current render (`withHeadStore` / `withHeadStoreSync`). * SSR serializes them with `serializeHead`; on the client the router applies * the collected entries to `document` after each mount/navigation. */ /** Attribute map contributed to html/body or head tags. */ export type HeadAttrMap = Readonly>; type HeadScriptTag = HeadAttrMap & { children?: string; }; /** * Serializable description of `` (and html/body attributes) contributed * by a loader or a render-time `head()` call. Dedup keys mirror unhead so a * later move to a runtime head manager stays a drop-in. */ export interface HeadInput { title?: string; /** Wrap the resolved title. The last template in merge order wins. */ titleTemplate?: string | ((title?: string) => string); meta?: HeadAttrMap[]; link?: HeadAttrMap[]; /** * Inline script bodies are emitted raw in SSR (`serializeHead`). Must be trusted * app code and must not contain a literal `` sequence. */ script?: HeadScriptTag[]; htmlAttrs?: HeadAttrMap; bodyAttrs?: HeadAttrMap; } /** Serialized head fragments ready to inject into a document shell. */ export interface SerializedHead { /** Markup for inside `` (title, meta, link, script). */ headTags: string; /** Attribute string for the `` tag (leading space included). */ htmlAttrs: string; /** Attribute string for the `` tag (leading space included). */ bodyAttrs: string; } export interface HeadStore { entries: HeadInput[]; } /** Test-only: force WebContainer head fallback (mirrors request-scope). */ export declare const __setHeadInWebcontainerForTests: (value: boolean | null) => void; /** Test-only: force activeHeadStore to skip ALS (simulates WebContainer ALS loss). */ export declare const __setHeadAlsBypassForTests: (value: boolean) => void; export declare const cssEscapeAttr: (value: string) => string; export declare const escapeHeadAttr: (value: T) => string; /** Escape text content for inline HTML (loader error messages etc.). */ export declare const escapeHtml: (value: T) => string; /** * Apply merged head entries on client navigations. Updates `document.title` and * managed meta/link nodes (`data-ilha-head`). Script tags from HeadInput are * SSR-only and are not re-injected here. Removes managed tags from the previous * route that are not part of this navigation's set. */ export declare const applyHeadEntriesToDocument: (entries: HeadInput[]) => void; export declare const withHeadStore: (store: HeadStore, fn: () => T | Promise) => Promise; /** * Contribute `` data from inside a page, layout, or island render. * * During SSR (or a client mount with an open browser head window), entries * collect into the active store. On the client with no store, the entry is * applied to `document` immediately. */ export declare const head: (input: HeadInput) => void; export interface BrowserHeadSession { flush: () => void; close: () => void; } /** * Open a browser head collection window for a client route mount. * Nested page/layout `head()` calls may land after `mount()` returns; keep * the window open until `close()`, and flush on a microtask (or via `flush()`). */ export declare const openBrowserHead: () => BrowserHeadSession; /** * Merge head entries in contribution order (loader first as the base, then * render-time outer→inner layouts, then the page) and serialize. Later entries * win on collision; the last `titleTemplate` wraps the resolved title. */ export declare const serializeHead: (entries: HeadInput[]) => SerializedHead; export {};