// Build context — the collecting core the signal DOM layer builds against. // // A `view` (or a structural primitive's row/arm) is built by running its recipe // under a live `BuildCtx`: element/text helpers build real DOM nodes and register // their reactive bindings (a `produce` accessor + absolute dependency paths) into // the active ctx's `specs`. `runBuild` runs one build with a fresh ctx (nesting // safely), so structural primitives can build rows/arms mid-reconcile. The module // owns the single `ctx` slot; every other signal-DOM module reaches it only through // `requireCtx()` / `getBuildCtx()` / `runBuild()` — never the raw variable. // // The Mountable machinery lives here too: everything LLui builds (elements, text, // and the structural primitives) is a lazy `Mountable` materialized where it is // PLACED (see `element.ts`'s `populate` and `runBuild` below), which is what makes // capture-and-reuse correct by construction. import type { SignalScope } from './runtime.js' /** The minimal node-factory surface the signal build needs from its document. * Satisfied by a real `Document` (client) AND by a server `DomEnv` (SSR) — so a * single build path renders both in-browser and on the server without casts. */ export interface SignalDoc { createElement(tag: string): Element createElementNS(ns: string, tag: string): Element createTextNode(text: string): Text createComment(text: string): Comment createDocumentFragment(): DocumentFragment /** Present on a real client `Document`; absent on a server `DomEnv` (portals * default to it, so a portal with no explicit target is client-only). */ readonly body?: HTMLElement | null /** Present on a real client `Document`; absent on a server `DomEnv`. The * head-management primitives commit here on the client (and skip when absent, * deferring to the SSR collector seeded via context). */ readonly head?: HTMLHeadElement | null /** Present on a real client `Document`; the `` root for `htmlAttr`. */ readonly documentElement?: HTMLElement | null /** Present on a server `DomEnv` (and `browserEnv`): parse an HTML string into a * fragment. Absent on a raw client `Document` (the runtime falls back to a * `