@llui/dom 0.0.33 → 0.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hmr.js +5 -0
- package/dist/hmr.js.map +1 -1
- package/dist/mount.d.ts.map +1 -1
- package/dist/mount.js +5 -0
- package/dist/mount.js.map +1 -1
- package/dist/primitives/branch.d.ts.map +1 -1
- package/dist/primitives/branch.js +18 -3
- package/dist/primitives/branch.js.map +1 -1
- package/dist/primitives/child.d.ts.map +1 -1
- package/dist/primitives/child.js +15 -3
- package/dist/primitives/child.js.map +1 -1
- package/dist/primitives/each.d.ts.map +1 -1
- package/dist/primitives/each.js +36 -14
- package/dist/primitives/each.js.map +1 -1
- package/dist/primitives/foreign.d.ts.map +1 -1
- package/dist/primitives/foreign.js +15 -3
- package/dist/primitives/foreign.js.map +1 -1
- package/dist/primitives/sample.d.ts +32 -1
- package/dist/primitives/sample.d.ts.map +1 -1
- package/dist/primitives/sample.js +52 -2
- package/dist/primitives/sample.js.map +1 -1
- package/dist/primitives/show.d.ts.map +1 -1
- package/dist/primitives/show.js +13 -1
- package/dist/primitives/show.js.map +1 -1
- package/dist/primitives/virtual-each.d.ts.map +1 -1
- package/dist/primitives/virtual-each.js +25 -5
- package/dist/primitives/virtual-each.js.map +1 -1
- package/dist/render-context.d.ts +3 -0
- package/dist/render-context.d.ts.map +1 -1
- package/dist/render-context.js +27 -1
- package/dist/render-context.js.map +1 -1
- package/dist/types.d.ts +23 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/update-loop.d.ts +6 -1
- package/dist/update-loop.d.ts.map +1 -1
- package/dist/update-loop.js +214 -59
- package/dist/update-loop.js.map +1 -1
- package/package.json +1 -1
package/dist/hmr.js
CHANGED
|
@@ -213,6 +213,11 @@ function makeReplacementHandle(name, entry, typedInst) {
|
|
|
213
213
|
const [state, effects] = typedInst.def.update(typedInst.state, msg);
|
|
214
214
|
return { state, effects: effects };
|
|
215
215
|
},
|
|
216
|
+
setOnBindingError(hook) {
|
|
217
|
+
if (disposed)
|
|
218
|
+
return;
|
|
219
|
+
typedInst._onBindingError = hook ?? undefined;
|
|
220
|
+
},
|
|
216
221
|
};
|
|
217
222
|
}
|
|
218
223
|
function captureFocus(root) {
|
package/dist/hmr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmr.js","sourceRoot":"","sources":["../src/hmr.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C;;;GAGG;AACH,MAAM,UAAU,SAAS;IACvB,aAAa,CAAC;QACZ,SAAS;QACT,cAAc;QACd,iBAAiB;QACjB,gBAAgB;QAChB,gBAAgB;KACjB,CAAC,CAAA;AACJ,CAAC;AAiBD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAsB,CAAA;AAEjD,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,IAAY,EAAE,SAAsB;IAC/E,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;IAC3C,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAyB,EAAE,SAAS,EAAE,CAAC,CAAA;IAC/E,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,O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C;gBAAE,OAAO,IAAI,CAAA;QACrE,CAAC;IACH,CAAC;IACD,IAAI,GAAG,GAAS,IAAY,CAAA;IAC5B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,KAAK,GAAG,GAAG,CAAC,UAAU,CAAA;QAC1B,IAAI,CAAC,GAAG,CAAC,CAAA;QACT,OAAO,KAAK,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;YACxB,KAAK,GAAG,KAAK,CAAC,WAAW,CAAA;YACzB,CAAC,EAAE,CAAA;QACL,CAAC;QACD,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAA;QACvB,GAAG,GAAG,KAAK,CAAA;IACb,CAAC;IACD,OAAO,GAAG,YAAY,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAA;AAC5C,CAAC","sourcesContent":["import type { ComponentDef, AppHandle } from './types.js'\nimport type { ComponentInstance } from './update-loop.js'\nimport { flushInstance } from './update-loop.js'\nimport { createLifetime, disposeLifetime } from './lifetime.js'\nimport { setRenderContext, clearRenderContext } from './render-context.js'\nimport { setFlatBindings } from './binding.js'\nimport { getBindingDescriptors } from './binding-descriptors.js'\nimport { unregisterInstance } from './runtime.js'\nimport { _setHmrModule } from './mount.js'\nimport { createView } from './view-helpers.js'\n\n/**\n * Enable HMR state preservation. Called by compiler-generated dev code.\n * Importing this module registers it with mountApp for hot-swapping.\n */\nexport function enableHmr(): void {\n _setHmrModule({\n enableHmr,\n registerForHmr,\n registerForAnchor,\n unregisterForHmr,\n replaceComponent,\n })\n}\n\n// ── HMR Registry ─────────────────────────────────────────────────\n\ntype HmrEntry =\n | {\n kind: 'container'\n inst: ComponentInstance\n container: HTMLElement\n }\n | {\n kind: 'anchor'\n inst: ComponentInstance\n anchor: Comment\n endSentinel: Comment\n }\n\nconst hmrRegistry = new Map<string, HmrEntry[]>()\n\nexport function registerForHmr(name: string, inst: object, container: HTMLElement): void {\n const entries = hmrRegistry.get(name) ?? []\n entries.push({ kind: 'container', inst: inst as ComponentInstance, container })\n hmrRegistry.set(name, entries)\n}\n\nexport function registerForAnchor(\n name: string,\n inst: object,\n anchor: Comment,\n endSentinel: Comment,\n): void {\n const entries = hmrRegistry.get(name) ?? []\n entries.push({ kind: 'anchor', inst: inst as ComponentInstance, anchor, endSentinel })\n hmrRegistry.set(name, entries)\n}\n\nexport function unregisterForHmr(name: string, inst: object): void {\n const entries = hmrRegistry.get(name)\n if (!entries) return\n const idx = entries.findIndex((e) => e.inst === inst)\n if (idx !== -1) entries.splice(idx, 1)\n if (entries.length === 0) hmrRegistry.delete(name)\n}\n\n/**\n * Hot-swap a component definition on all live instances.\n *\n * Preserves the current state. Replaces update, view, onEffect, and __dirty.\n * Disposes the old scope tree (removing old DOM and bindings),\n * re-runs view(currentState, send) to rebuild fresh DOM.\n *\n * Returns an AppHandle for the first instance (for mountApp compatibility),\n * or null if no instances are registered (first mount).\n */\nexport function replaceComponent<S, M, E, D = void>(\n name: string,\n newDef: ComponentDef<S, M, E, D>,\n): AppHandle | null {\n const entries = hmrRegistry.get(name)\n if (!entries || entries.length === 0) return null\n\n let handle: AppHandle | null = null\n\n for (const entry of entries) {\n const typedInst = entry.inst as ComponentInstance<S, M, E>\n\n typedInst.def = {\n ...typedInst.def,\n update: newDef.update,\n view: newDef.view,\n onEffect: newDef.onEffect,\n __dirty: newDef.__dirty,\n __update: newDef.__update,\n __handlers: newDef.__handlers,\n }\n\n // Snapshot focus + selection + scroll BEFORE disposal — once the\n // root lifetime tears down its DOM, the activeElement and any\n // scrollable subtree are detached and can't be queried. We\n // restore best-effort after the new view renders. The cost of\n // skipping this step is the every-edit experience: the user\n // types in an input, saves, the input rebuilds and loses focus\n // and cursor position. That kills incremental editing flow.\n const ownerRoot: ParentNode | null =\n entry.kind === 'container' ? entry.container : (entry.anchor.parentElement ?? null)\n const focusSnapshot = ownerRoot ? captureFocus(ownerRoot) : null\n const scrollSnapshot = ownerRoot ? captureScroll(ownerRoot) : null\n\n disposeLifetime(typedInst.rootLifetime)\n\n // Clear the owned region per-kind.\n if (entry.kind === 'container') {\n entry.container.textContent = ''\n } else {\n // anchor kind — wipe siblings between anchor and endSentinel, keep the\n // anchor AND the end sentinel (they bracket the fresh render).\n let sib = entry.anchor.nextSibling\n while (sib !== null && sib !== entry.endSentinel) {\n const next = sib.nextSibling\n sib.parentNode!.removeChild(sib)\n sib = next\n }\n }\n\n typedInst.rootLifetime = createLifetime(null)\n typedInst.rootLifetime._kind = 'root'\n typedInst.allBindings = []\n typedInst.structuralBlocks = []\n\n setFlatBindings(typedInst.allBindings)\n setRenderContext({\n rootLifetime: typedInst.rootLifetime,\n state: typedInst.state,\n allBindings: typedInst.allBindings,\n structuralBlocks: typedInst.structuralBlocks,\n dom: typedInst.dom,\n container:\n entry.kind === 'container' ? entry.container : (entry.anchor.parentElement ?? undefined),\n send: typedInst.send as (msg: unknown) => void,\n instance: typedInst as ComponentInstance,\n })\n const nodes = typedInst.def.view(createView<S, M>(typedInst.send))\n clearRenderContext()\n setFlatBindings(null)\n\n if (entry.kind === 'container') {\n for (const node of nodes) {\n entry.container.appendChild(node)\n }\n } else {\n for (const node of nodes) {\n entry.anchor.parentNode!.insertBefore(node, entry.endSentinel)\n }\n }\n\n // Restore focus, selection, and scroll positions in the freshly\n // rendered DOM. Best-effort: when the new view's DOM has diverged\n // structurally (different IDs, different element ordering, the\n // input that was focused no longer exists), the restorers no-op\n // silently. This is the right tradeoff — failing loudly on\n // structural divergence would just mean every meaningful view\n // edit prints an error.\n if (ownerRoot) {\n if (focusSnapshot) restoreFocus(ownerRoot, focusSnapshot)\n if (scrollSnapshot) restoreScroll(ownerRoot, scrollSnapshot)\n }\n\n if (!handle) {\n handle = makeReplacementHandle(name, entry, typedInst)\n }\n }\n\n console.log(`[LLui HMR] ${name} updated — state preserved`)\n\n return handle\n}\n\nfunction makeReplacementHandle<S, M, E>(\n name: string,\n entry: HmrEntry,\n typedInst: ComponentInstance<S, M, E>,\n): AppHandle {\n const listeners = new Set<(s: unknown) => void>()\n typedInst._onCommit = (state: unknown) => {\n for (const l of Array.from(listeners)) {\n try {\n l(state)\n } catch (err) {\n console.error('[llui] listener threw:', err)\n }\n }\n }\n let disposed = false\n return {\n dispose() {\n if (disposed) return\n disposed = true\n listeners.clear()\n typedInst._onCommit = undefined\n unregisterForHmr(name, entry.inst)\n entry.inst.abortController.abort()\n unregisterInstance(entry.inst)\n disposeLifetime(typedInst.rootLifetime)\n if (entry.kind === 'container') {\n entry.container.textContent = ''\n } else {\n let sib = entry.anchor.nextSibling\n while (sib !== null && sib !== entry.endSentinel) {\n const next = sib.nextSibling\n sib.parentNode!.removeChild(sib)\n sib = next\n }\n entry.endSentinel.parentNode?.removeChild(entry.endSentinel)\n }\n },\n flush() {\n flushInstance(entry.inst)\n },\n send(msg: unknown) {\n ;(typedInst.send as (m: unknown) => void)(msg)\n },\n getState() {\n return typedInst.state\n },\n subscribe(listener: (state: unknown) => void) {\n if (disposed) return () => {}\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n getBindingDescriptors() {\n if (disposed) return []\n return getBindingDescriptors(typedInst as ComponentInstance)\n },\n swapUpdate(newUpdate, newOnEffect) {\n if (disposed) return\n flushInstance(entry.inst)\n ;(typedInst.def as { update: typeof newUpdate }).update = newUpdate\n if (newOnEffect !== undefined) {\n ;(typedInst.def as { onEffect?: typeof newOnEffect }).onEffect = newOnEffect\n }\n },\n runReducer(msg) {\n if (disposed) return null\n const [state, effects] = (\n typedInst.def.update as (s: unknown, m: unknown) => [unknown, unknown[]]\n )(typedInst.state, msg)\n return { state, effects: effects as unknown[] }\n },\n }\n}\n\n// ── Focus / selection / scroll preservation across HMR ──────────\n\n/**\n * What we record before disposing the root DOM. The locator is a\n * structural pointer: prefer `id` (resilient to view restructuring),\n * fall back to a child-index path through the rendered subtree. If\n * the new DOM doesn't match either, the restore call no-ops.\n */\ntype FocusSnapshot = {\n /** The element's `id` if it had one, else `null`. */\n id: string | null\n /** Sibling-index path from `ownerRoot` down to the focused element. */\n path: number[]\n /** Selection range if the focused element is a text input/textarea. */\n selection: { start: number; end: number; direction: 'forward' | 'backward' | 'none' } | null\n}\n\ntype ScrollSnapshot = Array<{\n id: string | null\n path: number[]\n scrollTop: number\n scrollLeft: number\n}>\n\nfunction captureFocus(root: ParentNode): FocusSnapshot | null {\n const doc = (root as Element).ownerDocument ?? globalThis.document\n if (!doc) return null\n const active = doc.activeElement\n if (!active || active === doc.body) return null\n // Only capture focus for elements inside our owned subtree —\n // anything outside is not ours to restore.\n if (!(root as ParentNode & Node).contains(active)) return null\n\n const path = pathFromAncestor(root as Node, active)\n if (path === null) return null\n\n let selection: FocusSnapshot['selection'] = null\n if (active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement) {\n // Some input types (number, email, etc.) reject selectionStart access.\n // Wrapper try/catch keeps the snapshot resilient to those cases.\n try {\n if (active.selectionStart !== null && active.selectionEnd !== null) {\n selection = {\n start: active.selectionStart,\n end: active.selectionEnd,\n direction: (active.selectionDirection ?? 'none') as 'forward' | 'backward' | 'none',\n }\n }\n } catch {\n selection = null\n }\n }\n\n return {\n id: active.id || null,\n path,\n selection,\n }\n}\n\nfunction restoreFocus(root: ParentNode, snap: FocusSnapshot): void {\n const target = locate(root, snap.id, snap.path)\n if (!target || !(target instanceof HTMLElement)) return\n try {\n target.focus({ preventScroll: true })\n } catch {\n return\n }\n if (\n snap.selection &&\n (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement)\n ) {\n try {\n target.setSelectionRange(snap.selection.start, snap.selection.end, snap.selection.direction)\n } catch {\n // Some input types throw on setSelectionRange; ignore.\n }\n }\n}\n\nfunction captureScroll(root: ParentNode): ScrollSnapshot {\n // Walk the subtree and snapshot every element with non-zero\n // scroll. Most subtrees have at most a handful, so the per-edit\n // cost is small. Capturing all-zeroes wastes the restore work for\n // no benefit; the filter keeps things tight.\n const out: ScrollSnapshot = []\n const walk = (node: Node): void => {\n if (node instanceof HTMLElement) {\n if (node.scrollTop !== 0 || node.scrollLeft !== 0) {\n const path = pathFromAncestor(root as Node, node)\n if (path !== null) {\n out.push({\n id: node.id || null,\n path,\n scrollTop: node.scrollTop,\n scrollLeft: node.scrollLeft,\n })\n }\n }\n }\n for (let c = node.firstChild; c !== null; c = c.nextSibling) {\n walk(c)\n }\n }\n walk(root as Node)\n return out\n}\n\nfunction restoreScroll(root: ParentNode, snap: ScrollSnapshot): void {\n for (const s of snap) {\n const target = locate(root, s.id, s.path)\n if (!target || !(target instanceof HTMLElement)) continue\n target.scrollTop = s.scrollTop\n target.scrollLeft = s.scrollLeft\n }\n}\n\n/**\n * Compute the child-index path from `ancestor` down to `target`, or\n * `null` if `target` isn't in the subtree. The path is what gets\n * walked on restore — no document-wide selectors, no string-encoded\n * selectors that can break on punctuation in IDs.\n */\nfunction pathFromAncestor(ancestor: Node, target: Node): number[] | null {\n const path: number[] = []\n let cur: Node | null = target\n while (cur !== null && cur !== ancestor) {\n const parent: Node | null = cur.parentNode\n if (parent === null) return null\n let idx = 0\n let sib: Node | null = parent.firstChild\n while (sib !== null && sib !== cur) {\n idx++\n sib = sib.nextSibling\n }\n if (sib === null) return null\n path.push(idx)\n cur = parent\n }\n if (cur !== ancestor) return null\n return path.reverse()\n}\n\n/**\n * Restore lookup: try `id` first (cheap and resilient to structural\n * change), then walk the captured child-index path. Returns `null`\n * if neither lookup succeeds — the restore caller silently no-ops.\n */\nfunction locate(root: ParentNode, id: string | null, path: number[]): Element | null {\n if (id) {\n const doc = (root as Element).ownerDocument ?? globalThis.document\n if (doc) {\n const byId = doc.getElementById(id)\n if (byId && (root as ParentNode & Node).contains(byId)) return byId\n }\n }\n let cur: Node = root as Node\n for (const idx of path) {\n let child = cur.firstChild\n let i = 0\n while (child && i < idx) {\n child = child.nextSibling\n i++\n }\n if (!child) return null\n cur = child\n }\n return cur instanceof Element ? cur : null\n}\n"]}
|
|
1
|
+
{"version":3,"file":"hmr.js","sourceRoot":"","sources":["../src/hmr.ts"],"names":[],"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C,UAAU,CAAA;QAC1B,IAAI,CAAC,GAAG,CAAC,CAAA;QACT,OAAO,KAAK,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;YACxB,KAAK,GAAG,KAAK,CAAC,WAAW,CAAA;YACzB,CAAC,EAAE,CAAA;QACL,CAAC;QACD,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAA;QACvB,GAAG,GAAG,KAAK,CAAA;IACb,CAAC;IACD,OAAO,GAAG,YAAY,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAA;AAC5C,CAAC","sourcesContent":["import type { ComponentDef, AppHandle } from './types.js'\nimport type { ComponentInstance } from './update-loop.js'\nimport { flushInstance } from './update-loop.js'\nimport { createLifetime, disposeLifetime } from './lifetime.js'\nimport { setRenderContext, clearRenderContext } from './render-context.js'\nimport { setFlatBindings } from './binding.js'\nimport { getBindingDescriptors } from './binding-descriptors.js'\nimport { unregisterInstance } from './runtime.js'\nimport { _setHmrModule } from './mount.js'\nimport { createView } from './view-helpers.js'\n\n/**\n * Enable HMR state preservation. Called by compiler-generated dev code.\n * Importing this module registers it with mountApp for hot-swapping.\n */\nexport function enableHmr(): void {\n _setHmrModule({\n enableHmr,\n registerForHmr,\n registerForAnchor,\n unregisterForHmr,\n replaceComponent,\n })\n}\n\n// ── HMR Registry ─────────────────────────────────────────────────\n\ntype HmrEntry =\n | {\n kind: 'container'\n inst: ComponentInstance\n container: HTMLElement\n }\n | {\n kind: 'anchor'\n inst: ComponentInstance\n anchor: Comment\n endSentinel: Comment\n }\n\nconst hmrRegistry = new Map<string, HmrEntry[]>()\n\nexport function registerForHmr(name: string, inst: object, container: HTMLElement): void {\n const entries = hmrRegistry.get(name) ?? []\n entries.push({ kind: 'container', inst: inst as ComponentInstance, container })\n hmrRegistry.set(name, entries)\n}\n\nexport function registerForAnchor(\n name: string,\n inst: object,\n anchor: Comment,\n endSentinel: Comment,\n): void {\n const entries = hmrRegistry.get(name) ?? []\n entries.push({ kind: 'anchor', inst: inst as ComponentInstance, anchor, endSentinel })\n hmrRegistry.set(name, entries)\n}\n\nexport function unregisterForHmr(name: string, inst: object): void {\n const entries = hmrRegistry.get(name)\n if (!entries) return\n const idx = entries.findIndex((e) => e.inst === inst)\n if (idx !== -1) entries.splice(idx, 1)\n if (entries.length === 0) hmrRegistry.delete(name)\n}\n\n/**\n * Hot-swap a component definition on all live instances.\n *\n * Preserves the current state. Replaces update, view, onEffect, and __dirty.\n * Disposes the old scope tree (removing old DOM and bindings),\n * re-runs view(currentState, send) to rebuild fresh DOM.\n *\n * Returns an AppHandle for the first instance (for mountApp compatibility),\n * or null if no instances are registered (first mount).\n */\nexport function replaceComponent<S, M, E, D = void>(\n name: string,\n newDef: ComponentDef<S, M, E, D>,\n): AppHandle | null {\n const entries = hmrRegistry.get(name)\n if (!entries || entries.length === 0) return null\n\n let handle: AppHandle | null = null\n\n for (const entry of entries) {\n const typedInst = entry.inst as ComponentInstance<S, M, E>\n\n typedInst.def = {\n ...typedInst.def,\n update: newDef.update,\n view: newDef.view,\n onEffect: newDef.onEffect,\n __dirty: newDef.__dirty,\n __update: newDef.__update,\n __handlers: newDef.__handlers,\n }\n\n // Snapshot focus + selection + scroll BEFORE disposal — once the\n // root lifetime tears down its DOM, the activeElement and any\n // scrollable subtree are detached and can't be queried. We\n // restore best-effort after the new view renders. The cost of\n // skipping this step is the every-edit experience: the user\n // types in an input, saves, the input rebuilds and loses focus\n // and cursor position. That kills incremental editing flow.\n const ownerRoot: ParentNode | null =\n entry.kind === 'container' ? entry.container : (entry.anchor.parentElement ?? null)\n const focusSnapshot = ownerRoot ? captureFocus(ownerRoot) : null\n const scrollSnapshot = ownerRoot ? captureScroll(ownerRoot) : null\n\n disposeLifetime(typedInst.rootLifetime)\n\n // Clear the owned region per-kind.\n if (entry.kind === 'container') {\n entry.container.textContent = ''\n } else {\n // anchor kind — wipe siblings between anchor and endSentinel, keep the\n // anchor AND the end sentinel (they bracket the fresh render).\n let sib = entry.anchor.nextSibling\n while (sib !== null && sib !== entry.endSentinel) {\n const next = sib.nextSibling\n sib.parentNode!.removeChild(sib)\n sib = next\n }\n }\n\n typedInst.rootLifetime = createLifetime(null)\n typedInst.rootLifetime._kind = 'root'\n typedInst.allBindings = []\n typedInst.structuralBlocks = []\n\n setFlatBindings(typedInst.allBindings)\n setRenderContext({\n rootLifetime: typedInst.rootLifetime,\n state: typedInst.state,\n allBindings: typedInst.allBindings,\n structuralBlocks: typedInst.structuralBlocks,\n dom: typedInst.dom,\n container:\n entry.kind === 'container' ? entry.container : (entry.anchor.parentElement ?? undefined),\n send: typedInst.send as (msg: unknown) => void,\n instance: typedInst as ComponentInstance,\n })\n const nodes = typedInst.def.view(createView<S, M>(typedInst.send))\n clearRenderContext()\n setFlatBindings(null)\n\n if (entry.kind === 'container') {\n for (const node of nodes) {\n entry.container.appendChild(node)\n }\n } else {\n for (const node of nodes) {\n entry.anchor.parentNode!.insertBefore(node, entry.endSentinel)\n }\n }\n\n // Restore focus, selection, and scroll positions in the freshly\n // rendered DOM. Best-effort: when the new view's DOM has diverged\n // structurally (different IDs, different element ordering, the\n // input that was focused no longer exists), the restorers no-op\n // silently. This is the right tradeoff — failing loudly on\n // structural divergence would just mean every meaningful view\n // edit prints an error.\n if (ownerRoot) {\n if (focusSnapshot) restoreFocus(ownerRoot, focusSnapshot)\n if (scrollSnapshot) restoreScroll(ownerRoot, scrollSnapshot)\n }\n\n if (!handle) {\n handle = makeReplacementHandle(name, entry, typedInst)\n }\n }\n\n console.log(`[LLui HMR] ${name} updated — state preserved`)\n\n return handle\n}\n\nfunction makeReplacementHandle<S, M, E>(\n name: string,\n entry: HmrEntry,\n typedInst: ComponentInstance<S, M, E>,\n): AppHandle {\n const listeners = new Set<(s: unknown) => void>()\n typedInst._onCommit = (state: unknown) => {\n for (const l of Array.from(listeners)) {\n try {\n l(state)\n } catch (err) {\n console.error('[llui] listener threw:', err)\n }\n }\n }\n let disposed = false\n return {\n dispose() {\n if (disposed) return\n disposed = true\n listeners.clear()\n typedInst._onCommit = undefined\n unregisterForHmr(name, entry.inst)\n entry.inst.abortController.abort()\n unregisterInstance(entry.inst)\n disposeLifetime(typedInst.rootLifetime)\n if (entry.kind === 'container') {\n entry.container.textContent = ''\n } else {\n let sib = entry.anchor.nextSibling\n while (sib !== null && sib !== entry.endSentinel) {\n const next = sib.nextSibling\n sib.parentNode!.removeChild(sib)\n sib = next\n }\n entry.endSentinel.parentNode?.removeChild(entry.endSentinel)\n }\n },\n flush() {\n flushInstance(entry.inst)\n },\n send(msg: unknown) {\n ;(typedInst.send as (m: unknown) => void)(msg)\n },\n getState() {\n return typedInst.state\n },\n subscribe(listener: (state: unknown) => void) {\n if (disposed) return () => {}\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n getBindingDescriptors() {\n if (disposed) return []\n return getBindingDescriptors(typedInst as ComponentInstance)\n },\n swapUpdate(newUpdate, newOnEffect) {\n if (disposed) return\n flushInstance(entry.inst)\n ;(typedInst.def as { update: typeof newUpdate }).update = newUpdate\n if (newOnEffect !== undefined) {\n ;(typedInst.def as { onEffect?: typeof newOnEffect }).onEffect = newOnEffect\n }\n },\n runReducer(msg) {\n if (disposed) return null\n const [state, effects] = (\n typedInst.def.update as (s: unknown, m: unknown) => [unknown, unknown[]]\n )(typedInst.state, msg)\n return { state, effects: effects as unknown[] }\n },\n setOnBindingError(hook) {\n if (disposed) return\n typedInst._onBindingError = hook ?? undefined\n },\n }\n}\n\n// ── Focus / selection / scroll preservation across HMR ──────────\n\n/**\n * What we record before disposing the root DOM. The locator is a\n * structural pointer: prefer `id` (resilient to view restructuring),\n * fall back to a child-index path through the rendered subtree. If\n * the new DOM doesn't match either, the restore call no-ops.\n */\ntype FocusSnapshot = {\n /** The element's `id` if it had one, else `null`. */\n id: string | null\n /** Sibling-index path from `ownerRoot` down to the focused element. */\n path: number[]\n /** Selection range if the focused element is a text input/textarea. */\n selection: { start: number; end: number; direction: 'forward' | 'backward' | 'none' } | null\n}\n\ntype ScrollSnapshot = Array<{\n id: string | null\n path: number[]\n scrollTop: number\n scrollLeft: number\n}>\n\nfunction captureFocus(root: ParentNode): FocusSnapshot | null {\n const doc = (root as Element).ownerDocument ?? globalThis.document\n if (!doc) return null\n const active = doc.activeElement\n if (!active || active === doc.body) return null\n // Only capture focus for elements inside our owned subtree —\n // anything outside is not ours to restore.\n if (!(root as ParentNode & Node).contains(active)) return null\n\n const path = pathFromAncestor(root as Node, active)\n if (path === null) return null\n\n let selection: FocusSnapshot['selection'] = null\n if (active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement) {\n // Some input types (number, email, etc.) reject selectionStart access.\n // Wrapper try/catch keeps the snapshot resilient to those cases.\n try {\n if (active.selectionStart !== null && active.selectionEnd !== null) {\n selection = {\n start: active.selectionStart,\n end: active.selectionEnd,\n direction: (active.selectionDirection ?? 'none') as 'forward' | 'backward' | 'none',\n }\n }\n } catch {\n selection = null\n }\n }\n\n return {\n id: active.id || null,\n path,\n selection,\n }\n}\n\nfunction restoreFocus(root: ParentNode, snap: FocusSnapshot): void {\n const target = locate(root, snap.id, snap.path)\n if (!target || !(target instanceof HTMLElement)) return\n try {\n target.focus({ preventScroll: true })\n } catch {\n return\n }\n if (\n snap.selection &&\n (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement)\n ) {\n try {\n target.setSelectionRange(snap.selection.start, snap.selection.end, snap.selection.direction)\n } catch {\n // Some input types throw on setSelectionRange; ignore.\n }\n }\n}\n\nfunction captureScroll(root: ParentNode): ScrollSnapshot {\n // Walk the subtree and snapshot every element with non-zero\n // scroll. Most subtrees have at most a handful, so the per-edit\n // cost is small. Capturing all-zeroes wastes the restore work for\n // no benefit; the filter keeps things tight.\n const out: ScrollSnapshot = []\n const walk = (node: Node): void => {\n if (node instanceof HTMLElement) {\n if (node.scrollTop !== 0 || node.scrollLeft !== 0) {\n const path = pathFromAncestor(root as Node, node)\n if (path !== null) {\n out.push({\n id: node.id || null,\n path,\n scrollTop: node.scrollTop,\n scrollLeft: node.scrollLeft,\n })\n }\n }\n }\n for (let c = node.firstChild; c !== null; c = c.nextSibling) {\n walk(c)\n }\n }\n walk(root as Node)\n return out\n}\n\nfunction restoreScroll(root: ParentNode, snap: ScrollSnapshot): void {\n for (const s of snap) {\n const target = locate(root, s.id, s.path)\n if (!target || !(target instanceof HTMLElement)) continue\n target.scrollTop = s.scrollTop\n target.scrollLeft = s.scrollLeft\n }\n}\n\n/**\n * Compute the child-index path from `ancestor` down to `target`, or\n * `null` if `target` isn't in the subtree. The path is what gets\n * walked on restore — no document-wide selectors, no string-encoded\n * selectors that can break on punctuation in IDs.\n */\nfunction pathFromAncestor(ancestor: Node, target: Node): number[] | null {\n const path: number[] = []\n let cur: Node | null = target\n while (cur !== null && cur !== ancestor) {\n const parent: Node | null = cur.parentNode\n if (parent === null) return null\n let idx = 0\n let sib: Node | null = parent.firstChild\n while (sib !== null && sib !== cur) {\n idx++\n sib = sib.nextSibling\n }\n if (sib === null) return null\n path.push(idx)\n cur = parent\n }\n if (cur !== ancestor) return null\n return path.reverse()\n}\n\n/**\n * Restore lookup: try `id` first (cheap and resilient to structural\n * change), then walk the captured child-index path. Returns `null`\n * if neither lookup succeeds — the restore caller silently no-ops.\n */\nfunction locate(root: ParentNode, id: string | null, path: number[]): Element | null {\n if (id) {\n const doc = (root as Element).ownerDocument ?? globalThis.document\n if (doc) {\n const byId = doc.getElementById(id)\n if (byId && (root as ParentNode & Node).contains(byId)) return byId\n }\n }\n let cur: Node = root as Node\n for (const idx of path) {\n let child = cur.firstChild\n let i = 0\n while (child && i < idx) {\n child = child.nextSibling\n i++\n }\n if (!child) return null\n cur = child\n }\n return cur instanceof Element ? cur : null\n}\n"]}
|
package/dist/mount.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EA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CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC7B,WAAW,EAAE,CAAC,EACd,OAAO,CAAC,EAAE,YAAY,GACrB,SAAS,CA8EX"}
|
package/dist/mount.js
CHANGED
|
@@ -461,6 +461,11 @@ function buildAppHandle(inst, hmrName, domCleanup) {
|
|
|
461
461
|
const [state, effects] = inst.def.update(inst.state, msg);
|
|
462
462
|
return { state, effects: effects };
|
|
463
463
|
},
|
|
464
|
+
setOnBindingError(hook) {
|
|
465
|
+
if (disposed)
|
|
466
|
+
return;
|
|
467
|
+
inst._onBindingError = hook ?? undefined;
|
|
468
|
+
},
|
|
464
469
|
};
|
|
465
470
|
}
|
|
466
471
|
export function hydrateApp(container, def, serverState, options) {
|
package/dist/mount.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,UAAU,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAA0B,MAAM,kBAAkB,CAAA;AACjG,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAEzF,2EAA2E;AAE3E;;;;GAIG;AACH,SAAS,cAAc,CAAC,MAAe,EAAE,UAAmB;IAC1D,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAA;IACh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,aAAa,CAAC,cAAc,CAAC,CAAA;IAE7B,sEAAsE;IACtE,SAAS,CAAC,eAAe,CAAC,GAAG,KAAK,CAAC,CAAA;IAEnC,sEAAsE;IACtE,eAAe,CAAC,YAAY,CAAC,CAAA;IAE7B,sEAAsE;IACtE,kEAAkE;IAClE,qEAAqE;IACrE,qEAAqE;IACrE,mEAAmE;IACnE,mDAAmD;IACnD,IAAI,OAAO,EAAE,uBAAuB,EAAE,CAAC;QACrC,sBAAsB,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;SAAM,CAAC;QACN,sBAAsB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;IAC5C,CAAC;IAED,gBAAgB,CAAC,IAAI,CAAC,CAAA;IACtB,wDAAwD;IACxD,8DAA8D;IAC9D,+DAA+D;IAC/D,gCAAgC;IAChC,IAAI,SAAS,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;QACjC,SAAS,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;IAC5D,CAAC;IACD,OAAO,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,IAAI,EAAE,GAAG,EAAE;QACxD,SAAS,CAAC,WAAW,GAAG,EAAE,CAAA;IAC5B,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import type { ComponentDef, AppHandle, Lifetime } from './types.js'\nimport { type DomEnv, browserEnv } from './dom-env.js'\nimport { createComponentInstance, flushInstance, type ComponentInstance } from './update-loop.js'\nimport { disposeLifetime } from './lifetime.js'\nimport { setRenderContext, clearRenderContext } from './render-context.js'\nimport { setFlatBindings } from './binding.js'\nimport { getBindingDescriptors } from './binding-descriptors.js'\nimport { registerInstance, unregisterInstance } from './runtime.js'\nimport { createView } from './view-helpers.js'\nimport { pushMountQueue, popMountQueue, flushMountQueue } from './primitives/on-mount.js'\n\n// ── Sentinel-region helpers (used by anchor-based mount primitives) ─────\n\n/**\n * Remove every sibling from `anchor.nextSibling` up to but not including\n * `stopBefore`. Used by anchor-based mount primitives and their HMR\n * swap path to clear the owned DOM region between the pair.\n */\nfunction _removeBetween(anchor: Comment, stopBefore: Comment): void {\n const parent = anchor.parentNode\n if (parent === null) return\n while (anchor.nextSibling !== null && anchor.nextSibling !== stopBefore) {\n parent.removeChild(anchor.nextSibling)\n }\n}\n\n/**\n * Walk forward from `anchor.nextSibling` looking for an existing\n * `<!-- llui-mount-end -->` sentinel. Used by mount/hydrate at anchor\n * to reuse a server-emitted (or stale) sentinel rather than synthesizing\n * a duplicate. Returns null if no matching comment is found before the\n * end of the parent's children.\n */\nfunction _findEndSentinel(anchor: Comment): Comment | null {\n let node: Node | null = anchor.nextSibling\n while (node !== null) {\n if (node.nodeType === 8 && (node as Comment).nodeValue === 'llui-mount-end') {\n return node as Comment\n }\n node = node.nextSibling\n }\n return null\n}\n\n// Vite injects import.meta.env.DEV — declare the shape for TypeScript\ndeclare global {\n interface ImportMeta {\n env?: { DEV?: boolean }\n }\n}\n\n// ── HMR (dev only) ──────────────────────────────────────────────\n// Set by enableHmr() from '@llui/dom/hmr' — never imported in production.\n\nlet hmrModule: typeof import('./hmr') | null = null\n\n/**\n * @internal Called by enableHmr in the hmr module. Tests use this\n * (paired with `_getHmrModule`) to snapshot/restore prior state across\n * suite boundaries — pass `null` to clear.\n */\nexport function _setHmrModule(m: typeof import('./hmr') | null): void {\n hmrModule = m\n}\n\n/** @internal Read the currently-installed HMR module (or null). */\nexport function _getHmrModule(): typeof import('./hmr') | null {\n return hmrModule\n}\n\n// ── DevTools auto-install (dev only) ────────────────────────────\n// Set by enableDevTools() from '@llui/dom/devtools' — never imported in production.\n\nlet devToolsInstall: ((inst: object) => void) | null = null\n\n/** @internal Called by enableDevTools in the devtools module */\nexport function _setDevToolsInstall(fn: ((inst: object) => void) | null): void {\n devToolsInstall = fn\n}\n\n/** @internal Read the currently-installed devtools-install hook (or null). */\nexport function _getDevToolsInstall(): ((inst: object) => void) | null {\n return devToolsInstall\n}\n\nexport interface MountOptions {\n devTools?: boolean\n /**\n * Parent scope for the mounted component's rootLifetime. When provided,\n * the rootLifetime is created as a child of this scope — context lookups\n * from within the component walk up through the parent's scope tree,\n * and disposing the parent scope cascades into this instance's scope.\n * Used by `@llui/vike`'s persistent-layout machinery to mount a page\n * as a true scope-tree child of its enclosing layout, so layout-\n * provided contexts flow naturally into pages via `useContext`.\n *\n * When omitted (the default), the rootLifetime is detached — same as\n * every `mountApp` call before persistent layouts existed.\n */\n parentLifetime?: Lifetime\n /**\n * DOM env override. Defaults to `browserEnv()` — wraps the browser\n * globals. Specify only when mounting into a non-browser DOM (e.g.\n * a jsdom instance held by a test harness, or isolated DOM per\n * shadow root).\n */\n env?: DomEnv\n /**\n * **`hydrateApp` / `hydrateAtAnchor` only.** When `true`, fire the\n * effects that `init()` returned during hydration the same way\n * `mountApp` does on a fresh mount. Defaults to `false` because the\n * SSR render already ran `init()` on the server, and re-running its\n * effects on the client typically produces duplicate work — an\n * `httpGet` issued from `init()` would fetch on the server *and* on\n * hydration; a subscription would attach twice; etc.\n *\n * Opt in only when:\n * - `init()` returns no effects, OR\n * - all returned effects are idempotent / client-only (e.g.\n * wiring a `window` event listener, opening a `WebSocket`), AND\n * - the SSR path didn't run them (typically when `init()` checks a\n * `loaded` flag in state and returns `[]` on the server).\n *\n * Pre-0.0.31 behavior was to always run init effects on hydrate;\n * the option preserves it on demand for projects that depended on\n * it. The default-off direction matches the safer expectation that\n * \"hydration should be cheap and side-effect-free.\"\n */\n runInitEffectsOnHydrate?: boolean\n}\n\nexport function mountApp<S, M, E>(\n container: HTMLElement,\n def: ComponentDef<S, M, E>,\n data?: undefined,\n options?: MountOptions,\n): AppHandle\nexport function mountApp<S, M, E, D>(\n container: HTMLElement,\n def: ComponentDef<S, M, E, D>,\n data: D,\n options?: MountOptions,\n): AppHandle\nexport function mountApp<S, M, E, D>(\n container: HTMLElement,\n def: ComponentDef<S, M, E, D>,\n data?: D,\n options?: MountOptions,\n): AppHandle {\n // HMR: if this component is already mounted (module re-execution\n // during hot update), swap the definition instead of creating a new instance.\n // HMR swap bypasses parentLifetime — HMR re-mounts the outermost app handle,\n // which in a layout setup means the layout re-mounts at the root and the\n // rest of the chain is re-established via the normal mount path.\n if (hmrModule && def.name && !options?.parentLifetime) {\n const swapped = hmrModule.replaceComponent(def.name, def)\n if (swapped) return swapped\n }\n\n const inst = createComponentInstance(def, data, options?.parentLifetime ?? null, options?.env)\n\n // Dev-only: auto-install devtools if enabled via '@llui/dom/devtools' import\n if (devToolsInstall) devToolsInstall(inst)\n\n // Dev-only: warn if initial state contains non-serializable values.\n // Silent bug-bomb: Date/Map/Set/class instances break SSR, hydration, replay tools.\n if (import.meta.env?.DEV) {\n const offender = findNonSerializable(inst.state)\n if (offender) {\n console.warn(\n `[LLui] <${def.name}> initial state contains a non-serializable value at \"${offender.path}\":`,\n offender.value,\n '\\nState must be plain JSON (no Date/Map/Set/class instances/functions).' +\n '\\nThis will break SSR hydration, state replay, and devtools snapshots.' +\n '\\nhint: Convert to a serializable representation (e.g., Date → ISO string, Map → Record).',\n )\n }\n }\n\n // Run view() within a render context so primitives can register bindings.\n // Also collect onMount callbacks in a queue we'll flush synchronously\n // after node insertion — prevents the race where a user event fires\n // between mount and the queueMicrotask callback running.\n const { queue: onMountQueue, prev: prevMountQueue } = pushMountQueue()\n setFlatBindings(inst.allBindings)\n setRenderContext({\n ...inst,\n container,\n send: inst.send as (msg: unknown) => void,\n instance: inst as ComponentInstance,\n })\n const nodes = def.view(createView<S, M>(inst.send))\n clearRenderContext()\n setFlatBindings(null)\n popMountQueue(prevMountQueue)\n\n // Batch-insert via DocumentFragment — one layout-invalidating operation\n // instead of N individual appendChild calls on a live container element.\n if (nodes.length > 1) {\n const frag = inst.dom.createDocumentFragment()\n for (const node of nodes) frag.appendChild(node)\n container.appendChild(frag)\n } else if (nodes.length === 1) {\n container.appendChild(nodes[0]!)\n }\n\n // Flush onMount callbacks SYNCHRONOUSLY now that the DOM is in place.\n // Any listeners they attach are ready before this function returns,\n // so a synchronous dispatchEvent in the caller's next line fires\n // against a fully-wired tree.\n flushMountQueue(onMountQueue)\n\n registerInstance(inst)\n if (hmrModule && def.name) {\n hmrModule.registerForHmr(def.name, inst, container)\n }\n dispatchInitialEffects(inst)\n return buildAppHandle(inst, def.name ?? null, () => {\n container.textContent = ''\n })\n}\n\n// Walks an object graph looking for non-JSON-serializable values. Returns the\n// first offender found (depth-first), or null if everything is fine. Stops at\n// depth 6 to bound runtime cost for large states.\nfunction findNonSerializable(\n v: unknown,\n path = 'state',\n depth = 0,\n seen = new WeakSet<object>(),\n): { path: string; value: unknown } | null {\n if (depth > 6) return null\n if (v === null || v === undefined) return null\n const t = typeof v\n if (t === 'string' || t === 'number' || t === 'boolean') return null\n if (t === 'function') return { path, value: v }\n if (t === 'symbol' || t === 'bigint') return { path, value: v }\n if (t !== 'object') return null\n const obj = v as object\n if (seen.has(obj)) return null\n seen.add(obj)\n if (obj instanceof Date) return { path: `${path} (Date)`, value: v }\n if (obj instanceof Map) return { path: `${path} (Map)`, value: v }\n if (obj instanceof Set) return { path: `${path} (Set)`, value: v }\n if (obj instanceof RegExp) return { path: `${path} (RegExp)`, value: v }\n if (obj instanceof Promise) return { path: `${path} (Promise)`, value: v }\n // Plain objects/arrays have Object.prototype / Array.prototype. Class instances\n // have a different prototype.\n const proto = Object.getPrototypeOf(obj)\n if (proto !== null && proto !== Object.prototype && proto !== Array.prototype) {\n return { path: `${path} (${proto?.constructor?.name ?? 'class instance'})`, value: v }\n }\n if (Array.isArray(v)) {\n for (let i = 0; i < v.length; i++) {\n const r = findNonSerializable(v[i], `${path}[${i}]`, depth + 1, seen)\n if (r) return r\n }\n return null\n }\n for (const k of Object.keys(obj)) {\n const r = findNonSerializable(\n (obj as Record<string, unknown>)[k],\n `${path}.${k}`,\n depth + 1,\n seen,\n )\n if (r) return r\n }\n return null\n}\n\n/**\n * Mount a component relative to a comment anchor rather than inside a\n * container element. Inserts a synthesized end sentinel (`<!-- llui-mount-end -->`)\n * immediately after the anchor and places the component's nodes between\n * the pair. The anchor must already be attached to a live DOM tree.\n *\n * Unlike `mountApp`, the caller's anchor node is preserved across the\n * handle's lifetime — only the content between the pair (and the end\n * sentinel itself) is disposed. Used by `@llui/vike` persistent layouts\n * to mount chain layers without a wrapper element.\n *\n * If a pre-existing `<!-- llui-mount-end -->` is found after the anchor\n * (e.g. stale from an undisposed prior mount), the content between the\n * anchor and that sentinel is swept and the sentinel is reused. Dev mode\n * warns in that case.\n */\nexport function mountAtAnchor<S, M, E>(\n anchor: Comment,\n def: ComponentDef<S, M, E>,\n data?: undefined,\n options?: MountOptions,\n): AppHandle\nexport function mountAtAnchor<S, M, E, D>(\n anchor: Comment,\n def: ComponentDef<S, M, E, D>,\n data: D,\n options?: MountOptions,\n): AppHandle\nexport function mountAtAnchor<S, M, E, D>(\n anchor: Comment,\n def: ComponentDef<S, M, E, D>,\n data?: D,\n options?: MountOptions,\n): AppHandle {\n if (anchor.parentNode === null) {\n throw new Error(\n `[LLui] mountAtAnchor: anchor comment must be attached to a live DOM tree before mount`,\n )\n }\n\n // Locate or synthesize the end sentinel.\n const existingEnd = _findEndSentinel(anchor)\n let endSentinel: Comment\n if (existingEnd !== null) {\n if (import.meta.env?.DEV) {\n console.warn(\n `[LLui] mountAtAnchor: anchor has a pre-existing end sentinel. ` +\n `A prior mount was not disposed — sweeping stale siblings and reusing the sentinel.`,\n )\n }\n _removeBetween(anchor, existingEnd)\n endSentinel = existingEnd\n } else {\n // Use the caller-provided env if any — end-sentinel creation happens\n // before `inst` exists, so we pick the env directly from options.\n // (browserEnv() fallback matches what createComponentInstance will\n // use below when options.env is undefined.)\n endSentinel = (options?.env ?? browserEnv()).createComment('llui-mount-end')\n anchor.parentNode.insertBefore(endSentinel, anchor.nextSibling)\n }\n\n const inst = createComponentInstance(def, data, options?.parentLifetime ?? null, options?.env)\n\n if (devToolsInstall) devToolsInstall(inst)\n\n if (import.meta.env?.DEV) {\n const offender = findNonSerializable(inst.state)\n if (offender) {\n console.warn(\n `[LLui] <${def.name}> initial state contains a non-serializable value at \"${offender.path}\":`,\n offender.value,\n '\\nState must be plain JSON (no Date/Map/Set/class instances/functions).' +\n '\\nThis will break SSR hydration, state replay, and devtools snapshots.' +\n '\\nhint: Convert to a serializable representation (e.g., Date → ISO string, Map → Record).',\n )\n }\n }\n\n const { queue: onMountQueue, prev: prevMountQueue } = pushMountQueue()\n setFlatBindings(inst.allBindings)\n setRenderContext({\n ...inst,\n container: anchor.parentElement ?? undefined,\n send: inst.send as (msg: unknown) => void,\n instance: inst as ComponentInstance,\n })\n const nodes = def.view(createView<S, M>(inst.send))\n clearRenderContext()\n setFlatBindings(null)\n popMountQueue(prevMountQueue)\n\n // Batch-insert via DocumentFragment — one layout pass instead of N.\n if (nodes.length > 1) {\n const frag = inst.dom.createDocumentFragment()\n for (const node of nodes) frag.appendChild(node)\n anchor.parentNode.insertBefore(frag, endSentinel)\n } else if (nodes.length === 1) {\n anchor.parentNode.insertBefore(nodes[0]!, endSentinel)\n }\n\n flushMountQueue(onMountQueue)\n\n registerInstance(inst)\n if (hmrModule && def.name) {\n hmrModule.registerForAnchor(def.name, inst, anchor, endSentinel)\n }\n dispatchInitialEffects(inst)\n return buildAppHandle(inst, def.name ?? null, () => {\n _removeBetween(anchor, endSentinel)\n endSentinel.parentNode?.removeChild(endSentinel)\n })\n}\n\n/**\n * Hydrate a component relative to a comment anchor rather than inside a\n * container element. Analogous to `hydrateApp` — uses `serverState` as\n * the initial state (not `init()`'s output) while preserving `init()`'s\n * effects for post-mount dispatch.\n *\n * The DOM-handling path is identical to `mountAtAnchor`: reuses a\n * pre-existing end sentinel when present, synthesizes one otherwise.\n * Atomic-swaps the owned region whether or not server content is there\n * to replace. No error for a missing end sentinel — the vike chain's\n * outer `hydrateApp`'s `replaceChildren` wipes inner layers' sentinels,\n * so inner-layer `hydrateAtAnchor` calls routinely find nothing to\n * reuse, and that's normal.\n */\nexport function hydrateAtAnchor<S, M, E, D = void>(\n anchor: Comment,\n def: ComponentDef<S, M, E, D>,\n serverState: S,\n options?: MountOptions,\n): AppHandle {\n if (anchor.parentNode === null) {\n throw new Error(\n `[LLui] hydrateAtAnchor: anchor comment must be attached to a live DOM tree before hydrate`,\n )\n }\n\n const existingEnd = _findEndSentinel(anchor)\n let endSentinel: Comment\n if (existingEnd !== null) {\n _removeBetween(anchor, existingEnd)\n endSentinel = existingEnd\n } else {\n endSentinel = (options?.env ?? browserEnv()).createComment('llui-mount-end')\n anchor.parentNode.insertBefore(endSentinel, anchor.nextSibling)\n }\n\n // Run original init() to capture effects, then override state with server's.\n const [, originalEffects] = (def.init as (data: unknown) => [S, E[]])(undefined)\n const hydrateDef: ComponentDef<S, M, E> = {\n ...def,\n init: () => [serverState, originalEffects],\n }\n\n const inst = createComponentInstance(\n hydrateDef,\n undefined,\n options?.parentLifetime ?? null,\n options?.env,\n )\n\n if (devToolsInstall) devToolsInstall(inst)\n\n const { queue: onMountQueue, prev: prevMountQueue } = pushMountQueue()\n setFlatBindings(inst.allBindings)\n setRenderContext({\n ...inst,\n container: anchor.parentElement ?? undefined,\n send: inst.send as (msg: unknown) => void,\n instance: inst as ComponentInstance,\n })\n const nodes = hydrateDef.view(createView<S, M>(inst.send))\n clearRenderContext()\n setFlatBindings(null)\n popMountQueue(prevMountQueue)\n\n if (nodes.length > 1) {\n const frag = inst.dom.createDocumentFragment()\n for (const node of nodes) frag.appendChild(node)\n anchor.parentNode.insertBefore(frag, endSentinel)\n } else if (nodes.length === 1) {\n anchor.parentNode.insertBefore(nodes[0]!, endSentinel)\n }\n\n flushMountQueue(onMountQueue)\n\n registerInstance(inst)\n if (hmrModule && def.name) {\n hmrModule.registerForAnchor(def.name, inst, anchor, endSentinel)\n }\n // Hydration: skip init's effects by default. The SSR pass already ran\n // them on the server; re-running on the client typically produces\n // duplicate work (double fetches, double subscriptions). Opt back in\n // via `MountOptions.runInitEffectsOnHydrate: true`.\n if (options?.runInitEffectsOnHydrate) {\n dispatchInitialEffects(inst)\n } else {\n warnDroppedInitEffects(inst, 'hydrateAtAnchor')\n }\n return buildAppHandle(inst, def.name ?? null, () => {\n _removeBetween(anchor, endSentinel)\n endSentinel.parentNode?.removeChild(endSentinel)\n })\n}\n\nfunction dispatchInitialEffects<S, M, E>(\n inst: ReturnType<typeof createComponentInstance<S, M, E>>,\n): void {\n if (inst.initialEffects.length === 0 || !inst.def.onEffect) return\n for (const effect of inst.initialEffects) {\n inst.def.onEffect({ effect, send: inst.send, signal: inst.signal })\n }\n inst.initialEffects = []\n}\n\n/**\n * Dev-only warning when a hydrate path silently drops a non-empty\n * `initialEffects` array. The default-skip behavior is deliberate (the\n * server already ran them), but if `init()` produces effects that\n * weren't run on the server — typically client-only init pipelines —\n * silent drop is a footgun. Surface the count and the opt-in.\n */\nfunction warnDroppedInitEffects<S, M, E>(\n inst: ReturnType<typeof createComponentInstance<S, M, E>>,\n via: 'hydrateApp' | 'hydrateAtAnchor',\n): void {\n if (!import.meta.env?.DEV) return\n if (inst.initialEffects.length === 0) return\n const name = inst.def.name ?? '<anonymous>'\n console.warn(\n `[LLui] ${via}: skipped ${inst.initialEffects.length} init effect(s) for \"${name}\". ` +\n `Hydration drops init effects by default since the server already ran them. ` +\n `If these effects only fire on the client, pass \\`runInitEffectsOnHydrate: true\\` to opt in.`,\n )\n}\n\n/**\n * Build the `AppHandle` returned by every mount/hydrate path. Captures\n * the `_onCommit` listener registry, the `disposed` flag, and the\n * standard `flush` / `send` / `getState` / `subscribe` shape — all\n * code that was previously duplicated four times across `mountApp`,\n * `mountAtAnchor`, `hydrateApp`, and `hydrateAtAnchor`.\n *\n * Variation lives in the two parameters:\n * - `hmrName` — the def's name used to call `hmrModule.unregisterForHmr`\n * on dispose. Pass `null` to skip HMR unregistration (no current\n * mount path needs that, but it keeps the helper honest).\n * - `domCleanup` — final teardown step that detaches mounted nodes.\n * Container-rooted paths set `container.textContent = ''`;\n * anchor-rooted paths call `_removeBetween(anchor, endSentinel)`\n * and detach the end sentinel. Runs LAST in the dispose chain to\n * match the historical ordering exactly (lifetime is disposed\n * before nodes are detached, so binding teardown sees attached\n * DOM until the very end).\n *\n * The mount-path-parity test in `mount-path-parity.test.ts` enforces\n * that each public entry point produces structurally identical\n * AppHandle behavior — this helper is the realisation of that\n * promise.\n */\nfunction buildAppHandle<S, M, E>(\n inst: ReturnType<typeof createComponentInstance<S, M, E>>,\n hmrName: string | null,\n domCleanup: () => void,\n): AppHandle {\n let disposed = false\n const listeners = new Set<(s: unknown) => void>()\n\n inst._onCommit = (state: unknown) => {\n for (const l of Array.from(listeners)) {\n try {\n l(state)\n } catch (err) {\n console.error('[llui] listener threw:', err)\n }\n }\n }\n\n return {\n dispose() {\n if (disposed) return\n disposed = true\n listeners.clear()\n inst._onCommit = undefined\n if (hmrModule && hmrName) hmrModule.unregisterForHmr(hmrName, inst)\n inst.abortController.abort()\n unregisterInstance(inst)\n // Tag the root scope so the disposer log reports app-level\n // teardown distinct from in-tree component-unmount events.\n inst.rootLifetime.disposalCause = 'app-unmount'\n disposeLifetime(inst.rootLifetime)\n domCleanup()\n },\n flush() {\n if (disposed) return\n flushInstance(inst)\n },\n send(msg: unknown) {\n if (disposed) return\n ;(inst.send as (m: unknown) => void)(msg)\n },\n getState() {\n if (disposed) {\n throw new Error(\n '[LLui] AppHandle.getState() called after dispose — handle is dead. ' +\n 'Detach your event listener / cancel your timer when the handle ' +\n 'is disposed to avoid stale reads.',\n )\n }\n return inst.state\n },\n subscribe(listener: (state: unknown) => void) {\n if (disposed) return () => {}\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n getBindingDescriptors() {\n if (disposed) return []\n return getBindingDescriptors(inst as ComponentInstance)\n },\n swapUpdate(newUpdate, newOnEffect) {\n if (disposed) return\n // Drain pending messages with the OLD update first — anything\n // already in the queue was constructed under the old contract,\n // and re-routing it through a new reducer mid-flight could mix\n // half of one transition with half of another (e.g. a payload\n // shape the new update no longer accepts).\n flushInstance(inst)\n // Mutate the def in place so subsequent `inst.def.update`\n // reads — including the per-message read in `flushInstance`'s\n // generic loop — pick up the new function. We deliberately\n // don't replace `inst.def` itself: existing closures, the\n // `__update` fast path, and `__handlers` all stay valid; only\n // the user-visible reducer function changes.\n ;(inst.def as { update: typeof newUpdate }).update = newUpdate\n if (newOnEffect !== undefined) {\n ;(inst.def as { onEffect?: typeof newOnEffect }).onEffect = newOnEffect\n }\n },\n runReducer(msg) {\n if (disposed) return null\n // Direct invocation against current state. No subscribe, no\n // flush, no effect handler. The reducer's contract per TEA is\n // a pure function — calling it twice with the same args is a\n // no-op other than allocations. Returning the raw tuple\n // shape lets the agent inspect both halves without interpreting.\n const [state, effects] = (\n inst.def.update as (s: unknown, m: unknown) => [unknown, unknown[]]\n )(inst.state, msg)\n return { state, effects: effects as unknown[] }\n },\n }\n}\n\nexport function hydrateApp<S, M, E, D = void>(\n container: HTMLElement,\n def: ComponentDef<S, M, E, D>,\n serverState: S,\n options?: MountOptions,\n): AppHandle {\n // Run the original init once to capture its effects. The state it\n // returns is discarded — we use `serverState` (what the server\n // rendered with) instead. The effects are preserved and dispatched\n // after the DOM is in place, so components that rely on \"load data\n // or wire subscriptions on mount\" behave consistently between fresh\n // mount and SSR+hydrate. If the original init has already-loaded\n // data for the hydration case, gate the effect emission inside init\n // itself (e.g. based on a `loaded` flag in state).\n const [, originalEffects] = (def.init as (data: unknown) => [S, E[]])(undefined)\n\n const hydrateDef: ComponentDef<S, M, E> = {\n ...def,\n init: () => [serverState, originalEffects],\n }\n\n const inst = createComponentInstance(\n hydrateDef,\n undefined,\n options?.parentLifetime ?? null,\n options?.env,\n )\n\n // Dev-only: auto-install devtools if enabled via '@llui/dom/devtools'\n // import. The other three mount paths (mountApp / mountAtAnchor /\n // hydrateAtAnchor) all call this; without it, the hydrated layout\n // never appears in `window.__lluiComponents`, never sets\n // `window.__lluiDebug`, and is invisible to MCP / agent client /\n // devtools console — so a vike SSR app's outermost layout silently\n // drops out of every observability surface.\n if (devToolsInstall) devToolsInstall(inst)\n\n // Build the component DOM and swap atomically with server HTML.\n // Server HTML remains visible until JS finishes — no flash.\n // onMount callbacks are collected in a queue and flushed synchronously\n // after the swap, matching mountApp's ordering.\n const { queue: onMountQueue, prev: prevMountQueue } = pushMountQueue()\n setFlatBindings(inst.allBindings)\n setRenderContext({\n ...inst,\n container,\n send: inst.send as (msg: unknown) => void,\n instance: inst as ComponentInstance,\n })\n const nodes = hydrateDef.view(createView<S, M>(inst.send))\n clearRenderContext()\n setFlatBindings(null)\n popMountQueue(prevMountQueue)\n\n // Atomic swap — replaces server HTML with client DOM in one operation\n container.replaceChildren(...nodes)\n\n // Flush onMount callbacks synchronously now that the DOM is in place.\n flushMountQueue(onMountQueue)\n\n // Hydration: skip init's effects by default. The SSR pass already ran\n // them on the server; re-running on the client typically produces\n // duplicate work (double fetches, double subscriptions). Opt back in\n // via `MountOptions.runInitEffectsOnHydrate: true` for projects that\n // need the post-swap dispatch (typically when `init()` is gated by\n // a `loaded` flag and returns `[]` on the server).\n if (options?.runInitEffectsOnHydrate) {\n dispatchInitialEffects(inst)\n } else {\n warnDroppedInitEffects(inst, 'hydrateApp')\n }\n\n registerInstance(inst)\n // HMR registration — same as mountApp / mountAtAnchor /\n // hydrateAtAnchor. Without it, replaceComponent(name, newDef)\n // silently no-ops on the hydrated layout layer because the HMR\n // registry has no entry for it.\n if (hmrModule && hydrateDef.name) {\n hmrModule.registerForHmr(hydrateDef.name, inst, container)\n }\n return buildAppHandle(inst, hydrateDef.name ?? null, () => {\n container.textContent = ''\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,UAAU,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAA0B,MAAM,kBAAkB,CAAA;AACjG,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB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AC;IACD,OAAO,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,IAAI,EAAE,GAAG,EAAE;QACxD,SAAS,CAAC,WAAW,GAAG,EAAE,CAAA;IAC5B,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import type { ComponentDef, AppHandle, Lifetime } from './types.js'\nimport { type DomEnv, browserEnv } from './dom-env.js'\nimport { createComponentInstance, flushInstance, type ComponentInstance } from './update-loop.js'\nimport { disposeLifetime } from './lifetime.js'\nimport { setRenderContext, clearRenderContext } from './render-context.js'\nimport { setFlatBindings } from './binding.js'\nimport { getBindingDescriptors } from './binding-descriptors.js'\nimport { registerInstance, unregisterInstance } from './runtime.js'\nimport { createView } from './view-helpers.js'\nimport { pushMountQueue, popMountQueue, flushMountQueue } from './primitives/on-mount.js'\n\n// ── Sentinel-region helpers (used by anchor-based mount primitives) ─────\n\n/**\n * Remove every sibling from `anchor.nextSibling` up to but not including\n * `stopBefore`. Used by anchor-based mount primitives and their HMR\n * swap path to clear the owned DOM region between the pair.\n */\nfunction _removeBetween(anchor: Comment, stopBefore: Comment): void {\n const parent = anchor.parentNode\n if (parent === null) return\n while (anchor.nextSibling !== null && anchor.nextSibling !== stopBefore) {\n parent.removeChild(anchor.nextSibling)\n }\n}\n\n/**\n * Walk forward from `anchor.nextSibling` looking for an existing\n * `<!-- llui-mount-end -->` sentinel. Used by mount/hydrate at anchor\n * to reuse a server-emitted (or stale) sentinel rather than synthesizing\n * a duplicate. Returns null if no matching comment is found before the\n * end of the parent's children.\n */\nfunction _findEndSentinel(anchor: Comment): Comment | null {\n let node: Node | null = anchor.nextSibling\n while (node !== null) {\n if (node.nodeType === 8 && (node as Comment).nodeValue === 'llui-mount-end') {\n return node as Comment\n }\n node = node.nextSibling\n }\n return null\n}\n\n// Vite injects import.meta.env.DEV — declare the shape for TypeScript\ndeclare global {\n interface ImportMeta {\n env?: { DEV?: boolean }\n }\n}\n\n// ── HMR (dev only) ──────────────────────────────────────────────\n// Set by enableHmr() from '@llui/dom/hmr' — never imported in production.\n\nlet hmrModule: typeof import('./hmr') | null = null\n\n/**\n * @internal Called by enableHmr in the hmr module. Tests use this\n * (paired with `_getHmrModule`) to snapshot/restore prior state across\n * suite boundaries — pass `null` to clear.\n */\nexport function _setHmrModule(m: typeof import('./hmr') | null): void {\n hmrModule = m\n}\n\n/** @internal Read the currently-installed HMR module (or null). */\nexport function _getHmrModule(): typeof import('./hmr') | null {\n return hmrModule\n}\n\n// ── DevTools auto-install (dev only) ────────────────────────────\n// Set by enableDevTools() from '@llui/dom/devtools' — never imported in production.\n\nlet devToolsInstall: ((inst: object) => void) | null = null\n\n/** @internal Called by enableDevTools in the devtools module */\nexport function _setDevToolsInstall(fn: ((inst: object) => void) | null): void {\n devToolsInstall = fn\n}\n\n/** @internal Read the currently-installed devtools-install hook (or null). */\nexport function _getDevToolsInstall(): ((inst: object) => void) | null {\n return devToolsInstall\n}\n\nexport interface MountOptions {\n devTools?: boolean\n /**\n * Parent scope for the mounted component's rootLifetime. When provided,\n * the rootLifetime is created as a child of this scope — context lookups\n * from within the component walk up through the parent's scope tree,\n * and disposing the parent scope cascades into this instance's scope.\n * Used by `@llui/vike`'s persistent-layout machinery to mount a page\n * as a true scope-tree child of its enclosing layout, so layout-\n * provided contexts flow naturally into pages via `useContext`.\n *\n * When omitted (the default), the rootLifetime is detached — same as\n * every `mountApp` call before persistent layouts existed.\n */\n parentLifetime?: Lifetime\n /**\n * DOM env override. Defaults to `browserEnv()` — wraps the browser\n * globals. Specify only when mounting into a non-browser DOM (e.g.\n * a jsdom instance held by a test harness, or isolated DOM per\n * shadow root).\n */\n env?: DomEnv\n /**\n * **`hydrateApp` / `hydrateAtAnchor` only.** When `true`, fire the\n * effects that `init()` returned during hydration the same way\n * `mountApp` does on a fresh mount. Defaults to `false` because the\n * SSR render already ran `init()` on the server, and re-running its\n * effects on the client typically produces duplicate work — an\n * `httpGet` issued from `init()` would fetch on the server *and* on\n * hydration; a subscription would attach twice; etc.\n *\n * Opt in only when:\n * - `init()` returns no effects, OR\n * - all returned effects are idempotent / client-only (e.g.\n * wiring a `window` event listener, opening a `WebSocket`), AND\n * - the SSR path didn't run them (typically when `init()` checks a\n * `loaded` flag in state and returns `[]` on the server).\n *\n * Pre-0.0.31 behavior was to always run init effects on hydrate;\n * the option preserves it on demand for projects that depended on\n * it. The default-off direction matches the safer expectation that\n * \"hydration should be cheap and side-effect-free.\"\n */\n runInitEffectsOnHydrate?: boolean\n}\n\nexport function mountApp<S, M, E>(\n container: HTMLElement,\n def: ComponentDef<S, M, E>,\n data?: undefined,\n options?: MountOptions,\n): AppHandle\nexport function mountApp<S, M, E, D>(\n container: HTMLElement,\n def: ComponentDef<S, M, E, D>,\n data: D,\n options?: MountOptions,\n): AppHandle\nexport function mountApp<S, M, E, D>(\n container: HTMLElement,\n def: ComponentDef<S, M, E, D>,\n data?: D,\n options?: MountOptions,\n): AppHandle {\n // HMR: if this component is already mounted (module re-execution\n // during hot update), swap the definition instead of creating a new instance.\n // HMR swap bypasses parentLifetime — HMR re-mounts the outermost app handle,\n // which in a layout setup means the layout re-mounts at the root and the\n // rest of the chain is re-established via the normal mount path.\n if (hmrModule && def.name && !options?.parentLifetime) {\n const swapped = hmrModule.replaceComponent(def.name, def)\n if (swapped) return swapped\n }\n\n const inst = createComponentInstance(def, data, options?.parentLifetime ?? null, options?.env)\n\n // Dev-only: auto-install devtools if enabled via '@llui/dom/devtools' import\n if (devToolsInstall) devToolsInstall(inst)\n\n // Dev-only: warn if initial state contains non-serializable values.\n // Silent bug-bomb: Date/Map/Set/class instances break SSR, hydration, replay tools.\n if (import.meta.env?.DEV) {\n const offender = findNonSerializable(inst.state)\n if (offender) {\n console.warn(\n `[LLui] <${def.name}> initial state contains a non-serializable value at \"${offender.path}\":`,\n offender.value,\n '\\nState must be plain JSON (no Date/Map/Set/class instances/functions).' +\n '\\nThis will break SSR hydration, state replay, and devtools snapshots.' +\n '\\nhint: Convert to a serializable representation (e.g., Date → ISO string, Map → Record).',\n )\n }\n }\n\n // Run view() within a render context so primitives can register bindings.\n // Also collect onMount callbacks in a queue we'll flush synchronously\n // after node insertion — prevents the race where a user event fires\n // between mount and the queueMicrotask callback running.\n const { queue: onMountQueue, prev: prevMountQueue } = pushMountQueue()\n setFlatBindings(inst.allBindings)\n setRenderContext({\n ...inst,\n container,\n send: inst.send as (msg: unknown) => void,\n instance: inst as ComponentInstance,\n })\n const nodes = def.view(createView<S, M>(inst.send))\n clearRenderContext()\n setFlatBindings(null)\n popMountQueue(prevMountQueue)\n\n // Batch-insert via DocumentFragment — one layout-invalidating operation\n // instead of N individual appendChild calls on a live container element.\n if (nodes.length > 1) {\n const frag = inst.dom.createDocumentFragment()\n for (const node of nodes) frag.appendChild(node)\n container.appendChild(frag)\n } else if (nodes.length === 1) {\n container.appendChild(nodes[0]!)\n }\n\n // Flush onMount callbacks SYNCHRONOUSLY now that the DOM is in place.\n // Any listeners they attach are ready before this function returns,\n // so a synchronous dispatchEvent in the caller's next line fires\n // against a fully-wired tree.\n flushMountQueue(onMountQueue)\n\n registerInstance(inst)\n if (hmrModule && def.name) {\n hmrModule.registerForHmr(def.name, inst, container)\n }\n dispatchInitialEffects(inst)\n return buildAppHandle(inst, def.name ?? null, () => {\n container.textContent = ''\n })\n}\n\n// Walks an object graph looking for non-JSON-serializable values. Returns the\n// first offender found (depth-first), or null if everything is fine. Stops at\n// depth 6 to bound runtime cost for large states.\nfunction findNonSerializable(\n v: unknown,\n path = 'state',\n depth = 0,\n seen = new WeakSet<object>(),\n): { path: string; value: unknown } | null {\n if (depth > 6) return null\n if (v === null || v === undefined) return null\n const t = typeof v\n if (t === 'string' || t === 'number' || t === 'boolean') return null\n if (t === 'function') return { path, value: v }\n if (t === 'symbol' || t === 'bigint') return { path, value: v }\n if (t !== 'object') return null\n const obj = v as object\n if (seen.has(obj)) return null\n seen.add(obj)\n if (obj instanceof Date) return { path: `${path} (Date)`, value: v }\n if (obj instanceof Map) return { path: `${path} (Map)`, value: v }\n if (obj instanceof Set) return { path: `${path} (Set)`, value: v }\n if (obj instanceof RegExp) return { path: `${path} (RegExp)`, value: v }\n if (obj instanceof Promise) return { path: `${path} (Promise)`, value: v }\n // Plain objects/arrays have Object.prototype / Array.prototype. Class instances\n // have a different prototype.\n const proto = Object.getPrototypeOf(obj)\n if (proto !== null && proto !== Object.prototype && proto !== Array.prototype) {\n return { path: `${path} (${proto?.constructor?.name ?? 'class instance'})`, value: v }\n }\n if (Array.isArray(v)) {\n for (let i = 0; i < v.length; i++) {\n const r = findNonSerializable(v[i], `${path}[${i}]`, depth + 1, seen)\n if (r) return r\n }\n return null\n }\n for (const k of Object.keys(obj)) {\n const r = findNonSerializable(\n (obj as Record<string, unknown>)[k],\n `${path}.${k}`,\n depth + 1,\n seen,\n )\n if (r) return r\n }\n return null\n}\n\n/**\n * Mount a component relative to a comment anchor rather than inside a\n * container element. Inserts a synthesized end sentinel (`<!-- llui-mount-end -->`)\n * immediately after the anchor and places the component's nodes between\n * the pair. The anchor must already be attached to a live DOM tree.\n *\n * Unlike `mountApp`, the caller's anchor node is preserved across the\n * handle's lifetime — only the content between the pair (and the end\n * sentinel itself) is disposed. Used by `@llui/vike` persistent layouts\n * to mount chain layers without a wrapper element.\n *\n * If a pre-existing `<!-- llui-mount-end -->` is found after the anchor\n * (e.g. stale from an undisposed prior mount), the content between the\n * anchor and that sentinel is swept and the sentinel is reused. Dev mode\n * warns in that case.\n */\nexport function mountAtAnchor<S, M, E>(\n anchor: Comment,\n def: ComponentDef<S, M, E>,\n data?: undefined,\n options?: MountOptions,\n): AppHandle\nexport function mountAtAnchor<S, M, E, D>(\n anchor: Comment,\n def: ComponentDef<S, M, E, D>,\n data: D,\n options?: MountOptions,\n): AppHandle\nexport function mountAtAnchor<S, M, E, D>(\n anchor: Comment,\n def: ComponentDef<S, M, E, D>,\n data?: D,\n options?: MountOptions,\n): AppHandle {\n if (anchor.parentNode === null) {\n throw new Error(\n `[LLui] mountAtAnchor: anchor comment must be attached to a live DOM tree before mount`,\n )\n }\n\n // Locate or synthesize the end sentinel.\n const existingEnd = _findEndSentinel(anchor)\n let endSentinel: Comment\n if (existingEnd !== null) {\n if (import.meta.env?.DEV) {\n console.warn(\n `[LLui] mountAtAnchor: anchor has a pre-existing end sentinel. ` +\n `A prior mount was not disposed — sweeping stale siblings and reusing the sentinel.`,\n )\n }\n _removeBetween(anchor, existingEnd)\n endSentinel = existingEnd\n } else {\n // Use the caller-provided env if any — end-sentinel creation happens\n // before `inst` exists, so we pick the env directly from options.\n // (browserEnv() fallback matches what createComponentInstance will\n // use below when options.env is undefined.)\n endSentinel = (options?.env ?? browserEnv()).createComment('llui-mount-end')\n anchor.parentNode.insertBefore(endSentinel, anchor.nextSibling)\n }\n\n const inst = createComponentInstance(def, data, options?.parentLifetime ?? null, options?.env)\n\n if (devToolsInstall) devToolsInstall(inst)\n\n if (import.meta.env?.DEV) {\n const offender = findNonSerializable(inst.state)\n if (offender) {\n console.warn(\n `[LLui] <${def.name}> initial state contains a non-serializable value at \"${offender.path}\":`,\n offender.value,\n '\\nState must be plain JSON (no Date/Map/Set/class instances/functions).' +\n '\\nThis will break SSR hydration, state replay, and devtools snapshots.' +\n '\\nhint: Convert to a serializable representation (e.g., Date → ISO string, Map → Record).',\n )\n }\n }\n\n const { queue: onMountQueue, prev: prevMountQueue } = pushMountQueue()\n setFlatBindings(inst.allBindings)\n setRenderContext({\n ...inst,\n container: anchor.parentElement ?? undefined,\n send: inst.send as (msg: unknown) => void,\n instance: inst as ComponentInstance,\n })\n const nodes = def.view(createView<S, M>(inst.send))\n clearRenderContext()\n setFlatBindings(null)\n popMountQueue(prevMountQueue)\n\n // Batch-insert via DocumentFragment — one layout pass instead of N.\n if (nodes.length > 1) {\n const frag = inst.dom.createDocumentFragment()\n for (const node of nodes) frag.appendChild(node)\n anchor.parentNode.insertBefore(frag, endSentinel)\n } else if (nodes.length === 1) {\n anchor.parentNode.insertBefore(nodes[0]!, endSentinel)\n }\n\n flushMountQueue(onMountQueue)\n\n registerInstance(inst)\n if (hmrModule && def.name) {\n hmrModule.registerForAnchor(def.name, inst, anchor, endSentinel)\n }\n dispatchInitialEffects(inst)\n return buildAppHandle(inst, def.name ?? null, () => {\n _removeBetween(anchor, endSentinel)\n endSentinel.parentNode?.removeChild(endSentinel)\n })\n}\n\n/**\n * Hydrate a component relative to a comment anchor rather than inside a\n * container element. Analogous to `hydrateApp` — uses `serverState` as\n * the initial state (not `init()`'s output) while preserving `init()`'s\n * effects for post-mount dispatch.\n *\n * The DOM-handling path is identical to `mountAtAnchor`: reuses a\n * pre-existing end sentinel when present, synthesizes one otherwise.\n * Atomic-swaps the owned region whether or not server content is there\n * to replace. No error for a missing end sentinel — the vike chain's\n * outer `hydrateApp`'s `replaceChildren` wipes inner layers' sentinels,\n * so inner-layer `hydrateAtAnchor` calls routinely find nothing to\n * reuse, and that's normal.\n */\nexport function hydrateAtAnchor<S, M, E, D = void>(\n anchor: Comment,\n def: ComponentDef<S, M, E, D>,\n serverState: S,\n options?: MountOptions,\n): AppHandle {\n if (anchor.parentNode === null) {\n throw new Error(\n `[LLui] hydrateAtAnchor: anchor comment must be attached to a live DOM tree before hydrate`,\n )\n }\n\n const existingEnd = _findEndSentinel(anchor)\n let endSentinel: Comment\n if (existingEnd !== null) {\n _removeBetween(anchor, existingEnd)\n endSentinel = existingEnd\n } else {\n endSentinel = (options?.env ?? browserEnv()).createComment('llui-mount-end')\n anchor.parentNode.insertBefore(endSentinel, anchor.nextSibling)\n }\n\n // Run original init() to capture effects, then override state with server's.\n const [, originalEffects] = (def.init as (data: unknown) => [S, E[]])(undefined)\n const hydrateDef: ComponentDef<S, M, E> = {\n ...def,\n init: () => [serverState, originalEffects],\n }\n\n const inst = createComponentInstance(\n hydrateDef,\n undefined,\n options?.parentLifetime ?? null,\n options?.env,\n )\n\n if (devToolsInstall) devToolsInstall(inst)\n\n const { queue: onMountQueue, prev: prevMountQueue } = pushMountQueue()\n setFlatBindings(inst.allBindings)\n setRenderContext({\n ...inst,\n container: anchor.parentElement ?? undefined,\n send: inst.send as (msg: unknown) => void,\n instance: inst as ComponentInstance,\n })\n const nodes = hydrateDef.view(createView<S, M>(inst.send))\n clearRenderContext()\n setFlatBindings(null)\n popMountQueue(prevMountQueue)\n\n if (nodes.length > 1) {\n const frag = inst.dom.createDocumentFragment()\n for (const node of nodes) frag.appendChild(node)\n anchor.parentNode.insertBefore(frag, endSentinel)\n } else if (nodes.length === 1) {\n anchor.parentNode.insertBefore(nodes[0]!, endSentinel)\n }\n\n flushMountQueue(onMountQueue)\n\n registerInstance(inst)\n if (hmrModule && def.name) {\n hmrModule.registerForAnchor(def.name, inst, anchor, endSentinel)\n }\n // Hydration: skip init's effects by default. The SSR pass already ran\n // them on the server; re-running on the client typically produces\n // duplicate work (double fetches, double subscriptions). Opt back in\n // via `MountOptions.runInitEffectsOnHydrate: true`.\n if (options?.runInitEffectsOnHydrate) {\n dispatchInitialEffects(inst)\n } else {\n warnDroppedInitEffects(inst, 'hydrateAtAnchor')\n }\n return buildAppHandle(inst, def.name ?? null, () => {\n _removeBetween(anchor, endSentinel)\n endSentinel.parentNode?.removeChild(endSentinel)\n })\n}\n\nfunction dispatchInitialEffects<S, M, E>(\n inst: ReturnType<typeof createComponentInstance<S, M, E>>,\n): void {\n if (inst.initialEffects.length === 0 || !inst.def.onEffect) return\n for (const effect of inst.initialEffects) {\n inst.def.onEffect({ effect, send: inst.send, signal: inst.signal })\n }\n inst.initialEffects = []\n}\n\n/**\n * Dev-only warning when a hydrate path silently drops a non-empty\n * `initialEffects` array. The default-skip behavior is deliberate (the\n * server already ran them), but if `init()` produces effects that\n * weren't run on the server — typically client-only init pipelines —\n * silent drop is a footgun. Surface the count and the opt-in.\n */\nfunction warnDroppedInitEffects<S, M, E>(\n inst: ReturnType<typeof createComponentInstance<S, M, E>>,\n via: 'hydrateApp' | 'hydrateAtAnchor',\n): void {\n if (!import.meta.env?.DEV) return\n if (inst.initialEffects.length === 0) return\n const name = inst.def.name ?? '<anonymous>'\n console.warn(\n `[LLui] ${via}: skipped ${inst.initialEffects.length} init effect(s) for \"${name}\". ` +\n `Hydration drops init effects by default since the server already ran them. ` +\n `If these effects only fire on the client, pass \\`runInitEffectsOnHydrate: true\\` to opt in.`,\n )\n}\n\n/**\n * Build the `AppHandle` returned by every mount/hydrate path. Captures\n * the `_onCommit` listener registry, the `disposed` flag, and the\n * standard `flush` / `send` / `getState` / `subscribe` shape — all\n * code that was previously duplicated four times across `mountApp`,\n * `mountAtAnchor`, `hydrateApp`, and `hydrateAtAnchor`.\n *\n * Variation lives in the two parameters:\n * - `hmrName` — the def's name used to call `hmrModule.unregisterForHmr`\n * on dispose. Pass `null` to skip HMR unregistration (no current\n * mount path needs that, but it keeps the helper honest).\n * - `domCleanup` — final teardown step that detaches mounted nodes.\n * Container-rooted paths set `container.textContent = ''`;\n * anchor-rooted paths call `_removeBetween(anchor, endSentinel)`\n * and detach the end sentinel. Runs LAST in the dispose chain to\n * match the historical ordering exactly (lifetime is disposed\n * before nodes are detached, so binding teardown sees attached\n * DOM until the very end).\n *\n * The mount-path-parity test in `mount-path-parity.test.ts` enforces\n * that each public entry point produces structurally identical\n * AppHandle behavior — this helper is the realisation of that\n * promise.\n */\nfunction buildAppHandle<S, M, E>(\n inst: ReturnType<typeof createComponentInstance<S, M, E>>,\n hmrName: string | null,\n domCleanup: () => void,\n): AppHandle {\n let disposed = false\n const listeners = new Set<(s: unknown) => void>()\n\n inst._onCommit = (state: unknown) => {\n for (const l of Array.from(listeners)) {\n try {\n l(state)\n } catch (err) {\n console.error('[llui] listener threw:', err)\n }\n }\n }\n\n return {\n dispose() {\n if (disposed) return\n disposed = true\n listeners.clear()\n inst._onCommit = undefined\n if (hmrModule && hmrName) hmrModule.unregisterForHmr(hmrName, inst)\n inst.abortController.abort()\n unregisterInstance(inst)\n // Tag the root scope so the disposer log reports app-level\n // teardown distinct from in-tree component-unmount events.\n inst.rootLifetime.disposalCause = 'app-unmount'\n disposeLifetime(inst.rootLifetime)\n domCleanup()\n },\n flush() {\n if (disposed) return\n flushInstance(inst)\n },\n send(msg: unknown) {\n if (disposed) return\n ;(inst.send as (m: unknown) => void)(msg)\n },\n getState() {\n if (disposed) {\n throw new Error(\n '[LLui] AppHandle.getState() called after dispose — handle is dead. ' +\n 'Detach your event listener / cancel your timer when the handle ' +\n 'is disposed to avoid stale reads.',\n )\n }\n return inst.state\n },\n subscribe(listener: (state: unknown) => void) {\n if (disposed) return () => {}\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n getBindingDescriptors() {\n if (disposed) return []\n return getBindingDescriptors(inst as ComponentInstance)\n },\n swapUpdate(newUpdate, newOnEffect) {\n if (disposed) return\n // Drain pending messages with the OLD update first — anything\n // already in the queue was constructed under the old contract,\n // and re-routing it through a new reducer mid-flight could mix\n // half of one transition with half of another (e.g. a payload\n // shape the new update no longer accepts).\n flushInstance(inst)\n // Mutate the def in place so subsequent `inst.def.update`\n // reads — including the per-message read in `flushInstance`'s\n // generic loop — pick up the new function. We deliberately\n // don't replace `inst.def` itself: existing closures, the\n // `__update` fast path, and `__handlers` all stay valid; only\n // the user-visible reducer function changes.\n ;(inst.def as { update: typeof newUpdate }).update = newUpdate\n if (newOnEffect !== undefined) {\n ;(inst.def as { onEffect?: typeof newOnEffect }).onEffect = newOnEffect\n }\n },\n runReducer(msg) {\n if (disposed) return null\n // Direct invocation against current state. No subscribe, no\n // flush, no effect handler. The reducer's contract per TEA is\n // a pure function — calling it twice with the same args is a\n // no-op other than allocations. Returning the raw tuple\n // shape lets the agent inspect both halves without interpreting.\n const [state, effects] = (\n inst.def.update as (s: unknown, m: unknown) => [unknown, unknown[]]\n )(inst.state, msg)\n return { state, effects: effects as unknown[] }\n },\n setOnBindingError(hook) {\n if (disposed) return\n inst._onBindingError = hook ?? undefined\n },\n }\n}\n\nexport function hydrateApp<S, M, E, D = void>(\n container: HTMLElement,\n def: ComponentDef<S, M, E, D>,\n serverState: S,\n options?: MountOptions,\n): AppHandle {\n // Run the original init once to capture its effects. The state it\n // returns is discarded — we use `serverState` (what the server\n // rendered with) instead. The effects are preserved and dispatched\n // after the DOM is in place, so components that rely on \"load data\n // or wire subscriptions on mount\" behave consistently between fresh\n // mount and SSR+hydrate. If the original init has already-loaded\n // data for the hydration case, gate the effect emission inside init\n // itself (e.g. based on a `loaded` flag in state).\n const [, originalEffects] = (def.init as (data: unknown) => [S, E[]])(undefined)\n\n const hydrateDef: ComponentDef<S, M, E> = {\n ...def,\n init: () => [serverState, originalEffects],\n }\n\n const inst = createComponentInstance(\n hydrateDef,\n undefined,\n options?.parentLifetime ?? null,\n options?.env,\n )\n\n // Dev-only: auto-install devtools if enabled via '@llui/dom/devtools'\n // import. The other three mount paths (mountApp / mountAtAnchor /\n // hydrateAtAnchor) all call this; without it, the hydrated layout\n // never appears in `window.__lluiComponents`, never sets\n // `window.__lluiDebug`, and is invisible to MCP / agent client /\n // devtools console — so a vike SSR app's outermost layout silently\n // drops out of every observability surface.\n if (devToolsInstall) devToolsInstall(inst)\n\n // Build the component DOM and swap atomically with server HTML.\n // Server HTML remains visible until JS finishes — no flash.\n // onMount callbacks are collected in a queue and flushed synchronously\n // after the swap, matching mountApp's ordering.\n const { queue: onMountQueue, prev: prevMountQueue } = pushMountQueue()\n setFlatBindings(inst.allBindings)\n setRenderContext({\n ...inst,\n container,\n send: inst.send as (msg: unknown) => void,\n instance: inst as ComponentInstance,\n })\n const nodes = hydrateDef.view(createView<S, M>(inst.send))\n clearRenderContext()\n setFlatBindings(null)\n popMountQueue(prevMountQueue)\n\n // Atomic swap — replaces server HTML with client DOM in one operation\n container.replaceChildren(...nodes)\n\n // Flush onMount callbacks synchronously now that the DOM is in place.\n flushMountQueue(onMountQueue)\n\n // Hydration: skip init's effects by default. The SSR pass already ran\n // them on the server; re-running on the client typically produces\n // duplicate work (double fetches, double subscriptions). Opt back in\n // via `MountOptions.runInitEffectsOnHydrate: true` for projects that\n // need the post-swap dispatch (typically when `init()` is gated by\n // a `loaded` flag and returns `[]` on the server).\n if (options?.runInitEffectsOnHydrate) {\n dispatchInitialEffects(inst)\n } else {\n warnDroppedInitEffects(inst, 'hydrateApp')\n }\n\n registerInstance(inst)\n // HMR registration — same as mountApp / mountAtAnchor /\n // hydrateAtAnchor. Without it, replaceComponent(name, newDef)\n // silently no-ops on the hydrated layout layer because the HMR\n // registry has no entry for it.\n if (hmrModule && hydrateDef.name) {\n hmrModule.registerForHmr(hydrateDef.name, inst, container)\n }\n return buildAppHandle(inst, hydrateDef.name ?? null, () => {\n container.textContent = ''\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch.d.ts","sourceRoot":"","sources":["../../src/primitives/branch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"branch.d.ts","sourceRoot":"","sources":["../../src/primitives/branch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,aAAa,CAAA;AAe1D,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,EAC9D,IAAI,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAC3B,IAAI,EAAE,CAuKR"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getRenderContext, setRenderContext, clearRenderContext } from '../render-context.js';
|
|
1
|
+
import { getRenderContext, setRenderContext, clearRenderContext, enterAccessor, exitAccessor, } from '../render-context.js';
|
|
2
2
|
import { createLifetime, disposeLifetime, addDisposer } from '../lifetime.js';
|
|
3
3
|
import { setFlatBindings } from '../binding.js';
|
|
4
4
|
import { createView } from '../view-helpers.js';
|
|
@@ -10,13 +10,28 @@ export function branch(opts) {
|
|
|
10
10
|
const blocks = ctx.structuralBlocks;
|
|
11
11
|
const send = ctx.send;
|
|
12
12
|
const anchor = ctx.dom.createComment('branch');
|
|
13
|
-
|
|
13
|
+
// `on` accessor wrapped so sample()/h.sample() called from inside throws a
|
|
14
|
+
// targeted error. Both initial and reconcile paths route through callOn.
|
|
15
|
+
// `Discriminant<S, K>` is `((s: S) => K) | (() => K)` — passing `state`
|
|
16
|
+
// works for either arm at runtime (zero-arg ignores the extra), but a
|
|
17
|
+
// typed wrapper forces a union-call inference TypeScript can't unify.
|
|
18
|
+
// The runtime cast keeps the wrapper transparent.
|
|
19
|
+
const callOn = (state) => {
|
|
20
|
+
enterAccessor('branch().on');
|
|
21
|
+
try {
|
|
22
|
+
return opts.on(state);
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
exitAccessor();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
let currentKey = callOn(ctx.state);
|
|
14
29
|
let currentLifetime = null;
|
|
15
30
|
let currentNodes = [];
|
|
16
31
|
const block = {
|
|
17
32
|
mask: opts.__mask ?? FULL_MASK,
|
|
18
33
|
reconcile(state) {
|
|
19
|
-
const newKey =
|
|
34
|
+
const newKey = callOn(state);
|
|
20
35
|
if (Object.is(newKey, currentKey))
|
|
21
36
|
return;
|
|
22
37
|
const parent = anchor.parentNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch.js","sourceRoot":"","sources":["../../src/primitives/branch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAC7F,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAG9E,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CAAA;IAEF,OAAO,CAAC,MAAM,EAAE,GAAG,YAAY,CAAC,CAAA;AAClC,CAAC","sourcesContent":["import type { BranchOptions, Lifetime } from '../types.js'\nimport { getRenderContext, setRenderContext, clearRenderContext } from '../render-context.js'\nimport { createLifetime, disposeLifetime, addDisposer } from '../lifetime.js'\nimport { setFlatBindings } from '../binding.js'\nimport { createView } from '../view-helpers.js'\nimport { FULL_MASK } from '../update-loop.js'\nimport { pushMountQueue, popMountQueue, flushMountQueue } from './on-mount.js'\nimport type { StructuralBlock } from '../structural.js'\n\nexport function branch<S, M = unknown, K extends string = string>(\n opts: BranchOptions<S, M, K>,\n): Node[] {\n const ctx = getRenderContext('branch')\n const parentLifetime = ctx.rootLifetime\n const blocks = ctx.structuralBlocks\n const send = ctx.send as (msg: M) => void\n\n const anchor = ctx.dom.createComment('branch')\n\n let currentKey = opts.on(ctx.state as S)\n let currentLifetime: Lifetime | null = null\n let currentNodes: Node[] = []\n\n const block: StructuralBlock = {\n mask: (opts as { __mask?: number }).__mask ?? FULL_MASK,\n reconcile(state: unknown) {\n const newKey = opts.on(state as S)\n if (Object.is(newKey, currentKey)) return\n\n const parent = anchor.parentNode\n if (!parent) return\n\n const leavingNodes = currentNodes\n const leavingLifetime = currentLifetime\n\n // Build new arm first (before removing old — for FLIP animations)\n currentNodes = []\n currentLifetime = null\n currentKey = newKey\n\n const newCaseKey = String(newKey) as K\n const newBuilder = opts.cases?.[newCaseKey] ?? opts.default\n // Collect onMount callbacks from the new case into a local queue,\n // then flush them SYNCHRONOUSLY after the new nodes are inserted.\n // Without this, onMount inside a branch case would see stale DOM\n // (nodes not yet attached) OR fall back to queueMicrotask and\n // race with synchronous event dispatches after the reconcile.\n let onMountQueue: Array<() => void> | null = null\n if (newBuilder) {\n const mq = pushMountQueue()\n onMountQueue = mq.queue\n currentLifetime = createLifetime(parentLifetime)\n currentLifetime._kind =\n opts.__disposalCause === 'show-hide'\n ? 'show'\n : opts.__disposalCause === 'scope-rebuild'\n ? 'scope'\n : 'branch'\n setFlatBindings(ctx.allBindings)\n setRenderContext({ ...ctx, rootLifetime: currentLifetime, state })\n currentNodes = newBuilder(createView<S, M>(send))\n clearRenderContext()\n setFlatBindings(null)\n popMountQueue(mq.prev)\n\n const ref = anchor.nextSibling\n for (const node of currentNodes) {\n parent.insertBefore(node, ref)\n }\n }\n if (onMountQueue) flushMountQueue(onMountQueue)\n\n // Fire enter for new nodes\n if (opts.enter && currentNodes.length > 0) {\n opts.enter(currentNodes)\n }\n\n // Handle leave — may be deferred via Promise\n const removeOld = () => {\n for (const node of leavingNodes) {\n if (node.parentNode) node.parentNode.removeChild(node)\n }\n if (leavingLifetime) {\n // Tag BEFORE dispose so the disposer log records the cause.\n // `show()` passes `__disposalCause: 'show-hide'`; raw branch()\n // defaults to `'branch-swap'`. Tag wins over any pre-existing\n // value set by an inner primitive so the outermost cause is\n // reported (matches how humans describe the event).\n leavingLifetime.disposalCause = opts.__disposalCause ?? 'branch-swap'\n disposeLifetime(leavingLifetime)\n }\n }\n\n if (leavingNodes.length > 0 && opts.leave) {\n const result = opts.leave(leavingNodes)\n if (result && typeof (result as Promise<void>).then === 'function') {\n ;(result as Promise<void>).then(removeOld)\n } else {\n removeOld()\n }\n } else {\n removeOld()\n }\n },\n }\n\n // Register the block BEFORE running the initial builder so that parent\n // blocks always precede their nested children in the flat blocks array.\n // This guarantees correct Phase 1 iteration order: parents reconcile\n // first, so a parent that unmounts its old arm can dispose nested child\n // blocks (splicing them out of this array) without corrupting the loop\n // index — the splice only affects entries to the RIGHT of the parent.\n blocks.push(block)\n\n const caseKey = String(currentKey) as K\n const builder = opts.cases?.[caseKey] ?? opts.default\n // Initial-mount onMount callbacks are handled by the outer mountApp\n // queue — we're still inside the first view() call. branch doesn't\n // insert into the DOM at this point (the anchor + initial children\n // are returned to the parent), so we don't need to flush here.\n if (builder) {\n currentLifetime = createLifetime(parentLifetime)\n currentLifetime._kind =\n opts.__disposalCause === 'show-hide'\n ? 'show'\n : opts.__disposalCause === 'scope-rebuild'\n ? 'scope'\n : 'branch'\n setRenderContext({ ...ctx, rootLifetime: currentLifetime })\n currentNodes = builder(createView<S, M>(send))\n clearRenderContext()\n setRenderContext(ctx)\n\n // Fire enter on initial mount\n if (opts.enter && currentNodes.length > 0) {\n opts.enter(currentNodes)\n }\n }\n\n addDisposer(parentLifetime, () => {\n const idx = blocks.indexOf(block)\n if (idx !== -1) blocks.splice(idx, 1)\n // Remove arm DOM nodes + the anchor. The parent's own cleanup\n // (e.g. an outer branch's removeOld) only walks what its initial\n // render captured — nodes that THIS branch inserted into the\n // shared parent AFTER the outer's snapshot (including every\n // arm swap since initial mount) aren't in that list. Walking\n // `currentNodes` here and guarding with `parentNode` closes the\n // leak: if the parent DOM is already cascade-removed by an\n // ancestor, `node.parentNode` is null and the removeChild\n // no-ops. If the parent is still live (spread-into-arm case),\n // the removal is what cleans up the orphans.\n for (const node of currentNodes) {\n if (node.parentNode) node.parentNode.removeChild(node)\n }\n if (anchor.parentNode) anchor.parentNode.removeChild(anchor)\n if (currentLifetime) {\n disposeLifetime(currentLifetime)\n currentLifetime = null\n }\n })\n\n return [anchor, ...currentNodes]\n}\n"]}
|
|
1
|
+
{"version":3,"file":"branch.js","sourceRoot":"","sources":["../../src/primitives/branch.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,YAAY,GACb,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAG9E,MAAM,UAAU,MAA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AE,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;QACxD,CAAC;QACD,IAAI,MAAM,CAAC,UAAU;YAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;QAC5D,IAAI,eAAe,EAAE,CAAC;YACpB,eAAe,CAAC,eAAe,CAAC,CAAA;YAChC,eAAe,GAAG,IAAI,CAAA;QACxB,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,CAAC,MAAM,EAAE,GAAG,YAAY,CAAC,CAAA;AAClC,CAAC","sourcesContent":["import type { BranchOptions, Lifetime } from '../types.js'\nimport {\n getRenderContext,\n setRenderContext,\n clearRenderContext,\n enterAccessor,\n exitAccessor,\n} from '../render-context.js'\nimport { createLifetime, disposeLifetime, addDisposer } from '../lifetime.js'\nimport { setFlatBindings } from '../binding.js'\nimport { createView } from '../view-helpers.js'\nimport { FULL_MASK } from '../update-loop.js'\nimport { pushMountQueue, popMountQueue, flushMountQueue } from './on-mount.js'\nimport type { StructuralBlock } from '../structural.js'\n\nexport function branch<S, M = unknown, K extends string = string>(\n opts: BranchOptions<S, M, K>,\n): Node[] {\n const ctx = getRenderContext('branch')\n const parentLifetime = ctx.rootLifetime\n const blocks = ctx.structuralBlocks\n const send = ctx.send as (msg: M) => void\n\n const anchor = ctx.dom.createComment('branch')\n\n // `on` accessor wrapped so sample()/h.sample() called from inside throws a\n // targeted error. Both initial and reconcile paths route through callOn.\n // `Discriminant<S, K>` is `((s: S) => K) | (() => K)` — passing `state`\n // works for either arm at runtime (zero-arg ignores the extra), but a\n // typed wrapper forces a union-call inference TypeScript can't unify.\n // The runtime cast keeps the wrapper transparent.\n const callOn = (state: S) => {\n enterAccessor('branch().on')\n try {\n return (opts.on as (s: S) => K)(state)\n } finally {\n exitAccessor()\n }\n }\n\n let currentKey = callOn(ctx.state as S)\n let currentLifetime: Lifetime | null = null\n let currentNodes: Node[] = []\n\n const block: StructuralBlock = {\n mask: (opts as { __mask?: number }).__mask ?? FULL_MASK,\n reconcile(state: unknown) {\n const newKey = callOn(state as S)\n if (Object.is(newKey, currentKey)) return\n\n const parent = anchor.parentNode\n if (!parent) return\n\n const leavingNodes = currentNodes\n const leavingLifetime = currentLifetime\n\n // Build new arm first (before removing old — for FLIP animations)\n currentNodes = []\n currentLifetime = null\n currentKey = newKey\n\n const newCaseKey = String(newKey) as K\n const newBuilder = opts.cases?.[newCaseKey] ?? opts.default\n // Collect onMount callbacks from the new case into a local queue,\n // then flush them SYNCHRONOUSLY after the new nodes are inserted.\n // Without this, onMount inside a branch case would see stale DOM\n // (nodes not yet attached) OR fall back to queueMicrotask and\n // race with synchronous event dispatches after the reconcile.\n let onMountQueue: Array<() => void> | null = null\n if (newBuilder) {\n const mq = pushMountQueue()\n onMountQueue = mq.queue\n currentLifetime = createLifetime(parentLifetime)\n currentLifetime._kind =\n opts.__disposalCause === 'show-hide'\n ? 'show'\n : opts.__disposalCause === 'scope-rebuild'\n ? 'scope'\n : 'branch'\n setFlatBindings(ctx.allBindings)\n setRenderContext({ ...ctx, rootLifetime: currentLifetime, state })\n currentNodes = newBuilder(createView<S, M>(send))\n clearRenderContext()\n setFlatBindings(null)\n popMountQueue(mq.prev)\n\n const ref = anchor.nextSibling\n for (const node of currentNodes) {\n parent.insertBefore(node, ref)\n }\n }\n if (onMountQueue) flushMountQueue(onMountQueue)\n\n // Fire enter for new nodes\n if (opts.enter && currentNodes.length > 0) {\n opts.enter(currentNodes)\n }\n\n // Handle leave — may be deferred via Promise\n const removeOld = () => {\n for (const node of leavingNodes) {\n if (node.parentNode) node.parentNode.removeChild(node)\n }\n if (leavingLifetime) {\n // Tag BEFORE dispose so the disposer log records the cause.\n // `show()` passes `__disposalCause: 'show-hide'`; raw branch()\n // defaults to `'branch-swap'`. Tag wins over any pre-existing\n // value set by an inner primitive so the outermost cause is\n // reported (matches how humans describe the event).\n leavingLifetime.disposalCause = opts.__disposalCause ?? 'branch-swap'\n disposeLifetime(leavingLifetime)\n }\n }\n\n if (leavingNodes.length > 0 && opts.leave) {\n const result = opts.leave(leavingNodes)\n if (result && typeof (result as Promise<void>).then === 'function') {\n ;(result as Promise<void>).then(removeOld)\n } else {\n removeOld()\n }\n } else {\n removeOld()\n }\n },\n }\n\n // Register the block BEFORE running the initial builder so that parent\n // blocks always precede their nested children in the flat blocks array.\n // This guarantees correct Phase 1 iteration order: parents reconcile\n // first, so a parent that unmounts its old arm can dispose nested child\n // blocks (splicing them out of this array) without corrupting the loop\n // index — the splice only affects entries to the RIGHT of the parent.\n blocks.push(block)\n\n const caseKey = String(currentKey) as K\n const builder = opts.cases?.[caseKey] ?? opts.default\n // Initial-mount onMount callbacks are handled by the outer mountApp\n // queue — we're still inside the first view() call. branch doesn't\n // insert into the DOM at this point (the anchor + initial children\n // are returned to the parent), so we don't need to flush here.\n if (builder) {\n currentLifetime = createLifetime(parentLifetime)\n currentLifetime._kind =\n opts.__disposalCause === 'show-hide'\n ? 'show'\n : opts.__disposalCause === 'scope-rebuild'\n ? 'scope'\n : 'branch'\n setRenderContext({ ...ctx, rootLifetime: currentLifetime })\n currentNodes = builder(createView<S, M>(send))\n clearRenderContext()\n setRenderContext(ctx)\n\n // Fire enter on initial mount\n if (opts.enter && currentNodes.length > 0) {\n opts.enter(currentNodes)\n }\n }\n\n addDisposer(parentLifetime, () => {\n const idx = blocks.indexOf(block)\n if (idx !== -1) blocks.splice(idx, 1)\n // Remove arm DOM nodes + the anchor. The parent's own cleanup\n // (e.g. an outer branch's removeOld) only walks what its initial\n // render captured — nodes that THIS branch inserted into the\n // shared parent AFTER the outer's snapshot (including every\n // arm swap since initial mount) aren't in that list. Walking\n // `currentNodes` here and guarding with `parentNode` closes the\n // leak: if the parent DOM is already cascade-removed by an\n // ancestor, `node.parentNode` is null and the removeChild\n // no-ops. If the parent is still live (spread-into-arm case),\n // the removal is what cleans up the orphans.\n for (const node of currentNodes) {\n if (node.parentNode) node.parentNode.removeChild(node)\n }\n if (anchor.parentNode) anchor.parentNode.removeChild(anchor)\n if (currentLifetime) {\n disposeLifetime(currentLifetime)\n currentLifetime = null\n }\n })\n\n return [anchor, ...currentNodes]\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"child.d.ts","sourceRoot":"","sources":["../../src/primitives/child.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"child.d.ts","sourceRoot":"","sources":["../../src/primitives/child.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,aAAa,CAAA;AAgB7D,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,IAAI,EAAE,CAoHtE"}
|
package/dist/primitives/child.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getRenderContext, setRenderContext, clearRenderContext } from '../render-context.js';
|
|
1
|
+
import { getRenderContext, setRenderContext, clearRenderContext, enterAccessor, exitAccessor, } from '../render-context.js';
|
|
2
2
|
import { createLifetime, disposeLifetime, addDisposer } from '../lifetime.js';
|
|
3
3
|
import { createComponentInstance, flushInstance } from '../update-loop.js';
|
|
4
4
|
import { createBinding, setFlatBindings } from '../binding.js';
|
|
@@ -24,7 +24,19 @@ export function child(opts) {
|
|
|
24
24
|
childLifetime.disposalCause = 'child-unmount';
|
|
25
25
|
const parentSend = parentCtx.send;
|
|
26
26
|
const childDef = opts.def;
|
|
27
|
-
|
|
27
|
+
// `props` accessor wrapped so sample()/h.sample() inside throws a targeted
|
|
28
|
+
// error. Both initial read and the per-update binding accessor route through
|
|
29
|
+
// callProps.
|
|
30
|
+
const callProps = (parentState) => {
|
|
31
|
+
enterAccessor('child().props');
|
|
32
|
+
try {
|
|
33
|
+
return opts.props(parentState);
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
exitAccessor();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const initialProps = callProps(parentCtx.state);
|
|
28
40
|
// Child component inherits the parent's DOM env — render-context
|
|
29
41
|
// threading means the same env flows from mountApp to child() to any
|
|
30
42
|
// nested primitives inside the child's view.
|
|
@@ -53,7 +65,7 @@ export function child(opts) {
|
|
|
53
65
|
createBinding(childLifetime, {
|
|
54
66
|
mask: FULL_MASK,
|
|
55
67
|
accessor: ((parentState) => {
|
|
56
|
-
const newProps =
|
|
68
|
+
const newProps = callProps(parentState);
|
|
57
69
|
let changed = false;
|
|
58
70
|
for (const key of Object.keys(newProps)) {
|
|
59
71
|
if (!Object.is(newProps[key], prevProps[key])) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"child.js","sourceRoot":"","sources":["../../src/primitives/child.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"child.js","sourceRoot":"","sources":["../../src/primitives/child.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,YAAY,GACb,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC7E,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAA0B,MAAM,mBAAmB,CAAA;AAClG,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE/C,MAAM,SAAS,GAAG,UAAU,CAAA;AAE5B,MAAM,UAAU,KAAK,CAAY,IAA6B;IAC5D,gEAAgE;IAChE,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACb,UAAU,MAAM,CAAC,IAAI,C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EAAE,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC;QACtD,OAAO,EAAE,KAAK;KACf,CAAC,CAAA;IAEF,yDAAyD;IACzD,eAAe,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IACtC,gBAAgB,CAAC;QACf,GAAG,SAAS;QACZ,IAAI,EAAE,SAAS,CAAC,IAA8B;QAC9C,QAAQ,EAAE,SAA8B;KACzC,CAAC,CAAA;IACF,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;IACvD,kBAAkB,EAAE,CAAA;IACpB,eAAe,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IACtC,gBAAgB,CAAC,SAAS,CAAC,CAAA;IAE3B,uDAAuD;IACvD,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC,IAA8B,EAAE,CAAC,CAAA;IAE3E,6DAA6D;IAC7D,WAAW,CAAC,aAAa,EAAE,GAAG,EAAE;QAC9B,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACzB,SAAS,CAAC,YAAY,CAAC,aAAa,GAAG,eAAe,CAAA;QACtD,eAAe,CAAC,SAAS,CAAC,YAAY,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;IAEF,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import type { ChildOptions, ComponentDef } from '../types.js'\nimport {\n getRenderContext,\n setRenderContext,\n clearRenderContext,\n enterAccessor,\n exitAccessor,\n} from '../render-context.js'\nimport { createLifetime, disposeLifetime, addDisposer } from '../lifetime.js'\nimport { createComponentInstance, flushInstance, type ComponentInstance } from '../update-loop.js'\nimport { createBinding, setFlatBindings } from '../binding.js'\nimport { registerChild, unregisterChild } from '../addressed.js'\nimport { createView } from '../view-helpers.js'\n\nconst FULL_MASK = 0xffffffff\n\nexport function child<S, ChildM>(opts: ChildOptions<S, ChildM>): Node[] {\n // Dev-mode guard: props must be a function, not a static object\n if (typeof opts.props !== 'function') {\n throw new Error(\n `child(\"${String(opts.key)}\"): props must be a reactive accessor function ` +\n `(s => ({ ... })), not a static object. Static props are captured once at mount ` +\n `and never update.`,\n )\n }\n\n const parentCtx = getRenderContext('child')\n const parentLifetime = parentCtx.rootLifetime\n const childLifetime = createLifetime(parentLifetime)\n childLifetime._kind = 'child'\n // Tag eagerly: childLifetime lives as long as the child component is mounted,\n // so disposing it IS the child-unmount event. Setting the cause up front\n // (instead of inside the disposer closure below) ensures the parent's\n // _disposerLog sees it when `disposeLifetime` walks up the parent chain —\n // `childInst.rootLifetime` is an orphan (parent = null) and cannot emit.\n childLifetime.disposalCause = 'child-unmount'\n const parentSend = parentCtx.send\n\n const childDef = opts.def as ComponentDef<unknown, ChildM, unknown, Record<string, unknown>>\n // `props` accessor wrapped so sample()/h.sample() inside throws a targeted\n // error. Both initial read and the per-update binding accessor route through\n // callProps.\n const callProps = (parentState: S): Record<string, unknown> => {\n enterAccessor('child().props')\n try {\n return opts.props(parentState)\n } finally {\n exitAccessor()\n }\n }\n const initialProps = callProps(parentCtx.state as S)\n // Child component inherits the parent's DOM env — render-context\n // threading means the same env flows from mountApp to child() to any\n // nested primitives inside the child's view.\n const childInst = createComponentInstance(childDef, initialProps, null, parentCtx.dom)\n\n // Wrap child's send to intercept messages for onMsg → parent\n const originalSend = childInst.send\n childInst.send = (msg: ChildM) => {\n originalSend(msg)\n if (opts.onMsg && parentSend) {\n // Defer to after the child processes — use microtask\n queueMicrotask(() => {\n const parentMsg = opts.onMsg!(msg)\n if (parentMsg != null) {\n parentSend(parentMsg)\n }\n })\n }\n }\n\n // Track props for shallow-diff\n let prevProps: Record<string, unknown> = { ...initialProps }\n\n // Register a binding on the child scope that watches parent props changes.\n // This is a side-effect-only (`kind: 'effect'`) binding: Phase 2 runs the\n // accessor purely to fire the diff + propsMsg dispatch below. There is no\n // DOM output — the comment node is a detached anchor kept only so the\n // Binding shape stays uniform with other kinds.\n createBinding(childLifetime, {\n mask: FULL_MASK,\n accessor: ((parentState: S) => {\n const newProps = callProps(parentState)\n\n let changed = false\n for (const key of Object.keys(newProps)) {\n if (!Object.is(newProps[key], prevProps[key])) {\n changed = true\n break\n }\n }\n\n if (changed && childDef.propsMsg) {\n const msg = childDef.propsMsg(newProps)\n // Dispatch via `originalSend` so framework-synthesized propsMsg\n // traffic bypasses the `onMsg` wrapper below. Otherwise a naive\n // `onMsg: m => forward(m)` echoes props/set back to the parent,\n // which mutates parent state, re-fires this accessor, and loops\n // forever.\n originalSend(msg)\n flushInstance(childInst)\n }\n prevProps = { ...newProps }\n }) as (state: never) => unknown,\n kind: 'effect',\n node: parentCtx.dom.createComment('child:' + opts.key),\n perItem: false,\n })\n\n // Run the child's view within the child's render context\n setFlatBindings(childInst.allBindings)\n setRenderContext({\n ...childInst,\n send: childInst.send as (msg: unknown) => void,\n instance: childInst as ComponentInstance,\n })\n const nodes = childDef.view(createView(childInst.send))\n clearRenderContext()\n setFlatBindings(parentCtx.allBindings)\n setRenderContext(parentCtx)\n\n // Register in component registry for addressed effects\n registerChild(opts.key, { send: childInst.send as (msg: unknown) => void })\n\n // Cleanup: dispose child instance when parent scope disposes\n addDisposer(childLifetime, () => {\n unregisterChild(opts.key)\n childInst.rootLifetime.disposalCause = 'child-unmount'\n disposeLifetime(childInst.rootLifetime)\n })\n\n return nodes\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"each.d.ts","sourceRoot":"","sources":["../../src/primitives/each.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAA0B,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"each.d.ts","sourceRoot":"","sources":["../../src/primitives/each.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAA0B,MAAM,aAAa,CAAA;AA0BtE,uEAAuE;AACvE,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAEpD;AAED,sEAAsE;AACtE,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,GAAG,IAAI,CAEzE;AAwDD,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,CA+R1E"}
|