@llui/dom 0.0.27 → 0.0.28

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 CHANGED
@@ -142,6 +142,9 @@ function makeReplacementHandle(name, entry, typedInst) {
142
142
  ;
143
143
  typedInst.send(msg);
144
144
  },
145
+ getState() {
146
+ return typedInst.state;
147
+ },
145
148
  };
146
149
  }
147
150
  //# sourceMappingURL=hmr.js.map
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,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/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IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAA;YAClC,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YAC9B,eAAe,CAAC,SAAS,CAAC,YAAY,CAAC,CAAA;YACvC,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBAC/B,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,EAAE,CAAA;YAClC,CAAC;iBAAM,CAAC;gBACN,IAAI,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,CAAA;gBAClC,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC;oBACjD,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,CAAA;oBAC5B,GAAG,CAAC,UAAW,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;oBAChC,GAAG,GAAG,IAAI,CAAA;gBACZ,CAAC;gBACD,KAAK,CAAC,WAAW,CAAC,UAAU,EAAE,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;YAC9D,CAAC;QACH,CAAC;QACD,KAAK;YACH,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC3B,CAAC;QACD,IAAI,CAAC,GAAY;YACf,CAAC;YAAC,SAAS,CAAC,IAA6B,CAAC,GAAG,CAAC,CAAA;QAChD,CAAC;KACF,CAAA;AACH,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 { 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 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 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 return {\n dispose() {\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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A;YAClC,CAAC;iBAAM,CAAC;gBACN,IAAI,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,CAAA;gBAClC,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC;oBACjD,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,CAAA;oBAC5B,GAAG,CAAC,UAAW,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;oBAChC,GAAG,GAAG,IAAI,CAAA;gBACZ,CAAC;gBACD,KAAK,CAAC,WAAW,CAAC,UAAU,EAAE,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;YAC9D,CAAC;QACH,CAAC;QACD,KAAK;YACH,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC3B,CAAC;QACD,IAAI,CAAC,GAAY;YACf,CAAC;YAAC,SAAS,CAAC,IAA6B,CAAC,GAAG,CAAC,CAAA;QAChD,CAAC;QACD,QAAQ;YACN,OAAO,SAAS,CAAC,KAAK,CAAA;QACxB,CAAC;KACF,CAAA;AACH,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 { 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 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 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 return {\n dispose() {\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 }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AAAA,OAAO,K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B,SAAS,CA0FX;AAYD,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,EAC1C,SAAS,EAAE,WAAW,EACtB,GAAG,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC7B,WAAW,EAAE,CAAC,EACd,OAAO,CAAC,EAAE,YAAY,GACrB,SAAS,CAgFX"}
package/dist/mount.js CHANGED
@@ -139,6 +139,14 @@ export function mountApp(container, def, data, options) {
139
139
  return;
140
140
  inst.send(msg);
141
141
  },
142
+ getState() {
143
+ if (disposed) {
144
+ throw new Error('[LLui] AppHandle.getState() called after dispose — handle is dead. ' +
145
+ 'Detach your event listener / cancel your timer when the handle ' +
146
+ 'is disposed to avoid stale reads.');
147
+ }
148
+ return inst.state;
149
+ },
142
150
  };
143
151
  }
144
152
  // Walks an object graph looking for non-JSON-serializable values. Returns the
@@ -280,6 +288,12 @@ export function mountAtAnchor(anchor, def, data, options) {
280
288
  return;
281
289
  inst.send(msg);
282
290
  },
291
+ getState() {
292
+ if (disposed) {
293
+ throw new Error('[LLui] AppHandle.getState() called after dispose — handle is dead.');
294
+ }
295
+ return inst.state;
296
+ },
283
297
  };
284
298
  }
285
299
  /**
@@ -371,6 +385,12 @@ export function hydrateAtAnchor(anchor, def, serverState, options) {
371
385
  return;
372
386
  inst.send(msg);
373
387
  },
388
+ getState() {
389
+ if (disposed) {
390
+ throw new Error('[LLui] AppHandle.getState() called after dispose — handle is dead.');
391
+ }
392
+ return inst.state;
393
+ },
374
394
  };
375
395
  }
376
396
  function dispatchInitialEffects(inst) {
@@ -444,6 +464,12 @@ export function hydrateApp(container, def, serverState, options) {
444
464
  return;
445
465
  inst.send(msg);
446
466
  },
467
+ getState() {
468
+ if (disposed) {
469
+ throw new Error('[LLui] AppHandle.getState() called after dispose — handle is dead.');
470
+ }
471
+ return inst.state;
472
+ },
447
473
  };
448
474
  }
449
475
  //# sourceMappingURL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AAQ,EAAE,IAAyB;KACpC,CAAC,CAAA;IACF,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAC1D,kBAAkB,EAAE,CAAA;IACpB,eAAe,CAAC,IAAI,CAAC,CAAA;IACrB,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,kEAAkE;IAClE,qDAAqD;IACrD,sBAAsB,CAAC,IAAI,CAAC,CAAA;IAE5B,gBAAgB,CAAC,IAAI,CAAC,CAAA;IACtB,IAAI,QAAQ,GAAG,KAAK,CAAA;IAEpB,OAAO;QACL,OAAO;YACL,IAAI,QAAQ;gBAAE,OAAM;YACpB,QAAQ,GAAG,IAAI,CAAA;YACf,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAA;YAC5B,kBAAkB,CAAC,IAAI,CAAC,CAAA;YACxB,2DAA2D;YAC3D,2DAA2D;YAC3D,IAAI,CAAC,YAAY,CAAC,aAAa,GAAG,aAAa,CAAA;YAC/C,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;YAClC,SAAS,CAAC,WAAW,GAAG,EAAE,CAAA;QAC5B,CAAC;QACD,KAAK;YACH,IAAI,QAAQ;gBAAE,OAAM;YACpB,aAAa,CAAC,IAAI,CAAC,CAAA;QACrB,CAAC;QACD,IAAI,CAAC,GAAY;YACf,IAAI,QAAQ;gBAAE,OACb;YAAC,IAAI,CAAC,IAA6B,CAAC,GAAG,CAAC,CAAA;QAC3C,CAAC;KACF,CAAA;AACH,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 { 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/** @internal Called by enableHmr in the hmr module */\nexport function _setHmrModule(m: typeof import('./hmr')): void {\n hmrModule = m\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\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\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 let disposed = false\n\n return {\n dispose() {\n if (disposed) return\n disposed = true\n if (hmrModule && def.name) hmrModule.unregisterForHmr(def.name, 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 container.textContent = ''\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 }\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 let disposed = false\n\n return {\n dispose() {\n if (disposed) return\n disposed = true\n if (hmrModule && def.name) hmrModule.unregisterForHmr(def.name, inst)\n inst.abortController.abort()\n unregisterInstance(inst)\n inst.rootLifetime.disposalCause = 'app-unmount'\n disposeLifetime(inst.rootLifetime)\n _removeBetween(anchor, endSentinel)\n endSentinel.parentNode?.removeChild(endSentinel)\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 }\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 dispatchInitialEffects(inst)\n let disposed = false\n\n return {\n dispose() {\n if (disposed) return\n disposed = true\n if (hmrModule && def.name) hmrModule.unregisterForHmr(def.name, inst)\n inst.abortController.abort()\n unregisterInstance(inst)\n inst.rootLifetime.disposalCause = 'app-unmount'\n disposeLifetime(inst.rootLifetime)\n _removeBetween(anchor, endSentinel)\n endSentinel.parentNode?.removeChild(endSentinel)\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 }\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\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 // 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 // Fire the original init's effects post-swap, matching mountApp's\n // lifecycle. Previously these were silently dropped.\n dispatchInitialEffects(inst)\n\n registerInstance(inst)\n let disposed = false\n\n return {\n dispose() {\n if (disposed) return\n disposed = true\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 container.textContent = ''\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 }\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,EAAE,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,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;IAChC,IAAI,MAAM,KAAK,IAAI;QAAE,OAAM;IAC3B,OAAO,MAAM,CAAC,W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K,CAAC,CAAA;IAEnC,sEAAsE;IACtE,eAAe,CAAC,YAAY,CAAC,CAAA;IAE7B,kEAAkE;IAClE,qDAAqD;IACrD,sBAAsB,CAAC,IAAI,CAAC,CAAA;IAE5B,gBAAgB,CAAC,IAAI,CAAC,CAAA;IACtB,IAAI,QAAQ,GAAG,KAAK,CAAA;IAEpB,OAAO;QACL,OAAO;YACL,IAAI,QAAQ;gBAAE,OAAM;YACpB,QAAQ,GAAG,IAAI,CAAA;YACf,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAA;YAC5B,kBAAkB,CAAC,IAAI,CAAC,CAAA;YACxB,2DAA2D;YAC3D,2DAA2D;YAC3D,IAAI,CAAC,YAAY,CAAC,aAAa,GAAG,aAAa,CAAA;YAC/C,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;YAClC,SAAS,CAAC,WAAW,GAAG,EAAE,CAAA;QAC5B,CAAC;QACD,KAAK;YACH,IAAI,QAAQ;gBAAE,OAAM;YACpB,aAAa,CAAC,IAAI,CAAC,CAAA;QACrB,CAAC;QACD,IAAI,CAAC,GAAY;YACf,IAAI,QAAQ;gBAAE,OACb;YAAC,IAAI,CAAC,IAA6B,CAAC,GAAG,CAAC,CAAA;QAC3C,CAAC;QACD,QAAQ;YACN,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAA;YACvF,CAAC;YACD,OAAO,IAAI,CAAC,KAAK,CAAA;QACnB,CAAC;KACF,CAAA;AACH,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 { 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/** @internal Called by enableHmr in the hmr module */\nexport function _setHmrModule(m: typeof import('./hmr')): void {\n hmrModule = m\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\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\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 let disposed = false\n\n return {\n dispose() {\n if (disposed) return\n disposed = true\n if (hmrModule && def.name) hmrModule.unregisterForHmr(def.name, 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 container.textContent = ''\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 }\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 let disposed = false\n\n return {\n dispose() {\n if (disposed) return\n disposed = true\n if (hmrModule && def.name) hmrModule.unregisterForHmr(def.name, inst)\n inst.abortController.abort()\n unregisterInstance(inst)\n inst.rootLifetime.disposalCause = 'app-unmount'\n disposeLifetime(inst.rootLifetime)\n _removeBetween(anchor, endSentinel)\n endSentinel.parentNode?.removeChild(endSentinel)\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('[LLui] AppHandle.getState() called after dispose — handle is dead.')\n }\n return inst.state\n },\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 dispatchInitialEffects(inst)\n let disposed = false\n\n return {\n dispose() {\n if (disposed) return\n disposed = true\n if (hmrModule && def.name) hmrModule.unregisterForHmr(def.name, inst)\n inst.abortController.abort()\n unregisterInstance(inst)\n inst.rootLifetime.disposalCause = 'app-unmount'\n disposeLifetime(inst.rootLifetime)\n _removeBetween(anchor, endSentinel)\n endSentinel.parentNode?.removeChild(endSentinel)\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('[LLui] AppHandle.getState() called after dispose — handle is dead.')\n }\n return inst.state\n },\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\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 // 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 // Fire the original init's effects post-swap, matching mountApp's\n // lifecycle. Previously these were silently dropped.\n dispatchInitialEffects(inst)\n\n registerInstance(inst)\n let disposed = false\n\n return {\n dispose() {\n if (disposed) return\n disposed = true\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 container.textContent = ''\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('[LLui] AppHandle.getState() called after dispose — handle is dead.')\n }\n return inst.state\n },\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;AAS1D,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,CA0IR"}
1
+ {"version":3,"file":"branch.d.ts","sourceRoot":"","sources":["../../src/primitives/branch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,aAAa,CAAA;AAS1D,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,CAwJR"}
@@ -128,6 +128,22 @@ export function branch(opts) {
128
128
  const idx = blocks.indexOf(block);
129
129
  if (idx !== -1)
130
130
  blocks.splice(idx, 1);
131
+ // Remove arm DOM nodes + the anchor. The parent's own cleanup
132
+ // (e.g. an outer branch's removeOld) only walks what its initial
133
+ // render captured — nodes that THIS branch inserted into the
134
+ // shared parent AFTER the outer's snapshot (including every
135
+ // arm swap since initial mount) aren't in that list. Walking
136
+ // `currentNodes` here and guarding with `parentNode` closes the
137
+ // leak: if the parent DOM is already cascade-removed by an
138
+ // ancestor, `node.parentNode` is null and the removeChild
139
+ // no-ops. If the parent is still live (spread-into-arm case),
140
+ // the removal is what cleans up the orphans.
141
+ for (const node of currentNodes) {
142
+ if (node.parentNode)
143
+ node.parentNode.removeChild(node);
144
+ }
145
+ if (anchor.parentNode)
146
+ anchor.parentNode.removeChild(anchor);
131
147
  if (currentLifetime) {
132
148
  disposeLifetime(currentLifetime);
133
149
  currentLifetime = null;
@@ -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,MAAM,UAAU,MAAM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AM;gBACR,CAAC,CAAC,IAAI,CAAC,eAAe,KAAK,eAAe;oBACxC,CAAC,CAAC,OAAO;oBACT,CAAC,CAAC,QAAQ,CAAA;QAChB,gBAAgB,CAAC,EAAE,GAAG,GAAG,EAAE,YAAY,EAAE,eAAe,EAAE,CAAC,CAAA;QAC3D,YAAY,GAAG,OAAO,CAAC,UAAU,CAAO,IAAI,CAAC,CAAC,CAAA;QAC9C,kBAAkB,EAAE,CAAA;QACpB,gBAAgB,CAAC,GAAG,CAAC,CAAA;QAErB,8BAA8B;QAC9B,IAAI,IAAI,CAAC,KAAK,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1C,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;QAC1B,CAAC;IACH,CAAC;IAED,WAAW,CAAC,cAAc,EAAE,GAAG,EAAE;QAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACjC,IAAI,GAAG,KAAK,CAAC,CAAC;YAAE,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;QACrC,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 { 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 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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AA0D;QAC1D,8DAA8D;QAC9D,6CAA6C;QAC7C,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;YAChC,IAAI,IAAI,CAAC,UAAU;gBAAE,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 { 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 +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;AAwBtE,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;AAoCD,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,CAmR1E"}
1
+ {"version":3,"file":"each.d.ts","sourceRoot":"","sources":["../../src/primitives/each.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAA0B,MAAM,aAAa,CAAA;AAwBtE,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;AAoCD,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"}
@@ -269,10 +269,24 @@ export function each(opts) {
269
269
  // parentLifetime is being disposed — its children array is about to be
270
270
  // cleared by the recursive dispose pass, so skip per-entry parent
271
271
  // removal (avoids O(N²) indexOf+splice).
272
+ //
273
+ // Rows created AFTER the parent's initial render (each reconciled
274
+ // with a new item list) are siblings of the anchor inside the
275
+ // parent's DOM container, but aren't tracked by the parent's
276
+ // snapshot (e.g. an outer branch's currentNodes). Walking entries
277
+ // here and removing their DOM — guarded by parentNode — closes
278
+ // the leak: cascade-removed subtrees no-op, live-parent cases get
279
+ // the orphans cleaned up.
272
280
  for (const entry of entries) {
281
+ for (const node of entry.nodes) {
282
+ if (node.parentNode)
283
+ node.parentNode.removeChild(node);
284
+ }
273
285
  disposeLifetime(entry.scope, true);
274
286
  }
275
287
  entries.length = 0;
288
+ if (anchor.parentNode)
289
+ anchor.parentNode.removeChild(anchor);
276
290
  // Force-remove any mid-leave entries immediately
277
291
  for (const entry of leaving) {
278
292
  for (const node of entry.nodes) {
@@ -1 +1 @@
1
- {"version":3,"file":"each.js","sourceRoot":"","sources":["../../src/primitives/each.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,GAEnB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,sBAAsB,GACvB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE/C,6FAA6F;AAC7F,kFAAkF;AAClF,IAAI,oBAAoB,GAA6B,IAAI,CAAA;AACzD,IAAI,qBAAqB,GAAiD,IAAI,CAAA;AAE9E,uEAAuE;AACvE,MAAM,UAAU,eAAe,CAAC,EAAc;IAC5C,IAAI,oBAAoB;QAAE,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACzD,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,gBAAgB,CAAC,EAAkC;IACjE,IAAI,qBAAqB;QAAE,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAC3D,CAAC;AAED,+EAA+E;AAC/E,sFAAsF;AACtF,4EAA4E;AAC5E,oEAAoE;AACpE,MAAM,QAAQ,GAAkB;IAC9B,YAAY,EAAE,IAA2B;IACzC,KAAK,EAAE,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AAQ,CAAC,CAAC,CAAE,CAAC;YAAE,OAAO,KAAK,CAAA;IAC9D,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,gBAAgB,CACvB,UAAsB,EACtB,UAAsB,EACtB,QAA8B;IAE9B,oCAAoC;IACpC,MAAM,WAAW,GAAG,IAAI,GAAG,EAA2B,CAAA;IACtD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,IAAI,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAE,CAAC,GAAG,CAAC,EAAE,CAAC;YACrC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;QACxC,CAAC;IACH,CAAC;IACD,0EAA0E;IAC1E,IAAI,WAAW,GAAG,CAAC,CAAC,CAAA;IACpB,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;QAC/B,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACzC,IAAI,MAAM,KAAK,SAAS;YAAE,SAAQ,CAAC,kBAAkB;QACrD,IAAI,MAAM,GAAG,WAAW;YAAE,OAAO,KAAK,CAAA;QACtC,WAAW,GAAG,MAAM,CAAA;IACtB,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import type { EachOptions, ItemAccessor, Lifetime } from '../types.js'\nimport {\n getRenderContext,\n setRenderContext,\n clearRenderContext,\n type RenderContext,\n} from '../render-context.js'\nimport {\n createLifetime,\n disposeLifetime,\n disposeLifetimesBulk,\n addDisposer,\n removeOrphanedChildren,\n} from '../lifetime.js'\nimport { getFlatBindings, setFlatBindings } from '../binding.js'\nimport { FULL_MASK } from '../update-loop.js'\nimport type { StructuralBlock } from '../structural.js'\nimport { createView } from '../view-helpers.js'\n\n// Clear callbacks — registered by selector.bind() during render, called by reconcileClear().\n// Eliminates per-row disposers (1000 Set.delete calls → 1 registry.clear() call).\nlet activeClearCallbacks: Array<() => void> | null = null\nlet activeRemoveCallbacks: Array<(key: string | number) => void> | null = null\n\n/** Register a callback to run when the current each() block clears. */\nexport function registerOnClear(cb: () => void): void {\n if (activeClearCallbacks) activeClearCallbacks.push(cb)\n}\n\n/** Register a callback to run when a single row is removed by key. */\nexport function registerOnRemove(cb: (key: string | number) => void): void {\n if (activeRemoveCallbacks) activeRemoveCallbacks.push(cb)\n}\n\n// Reusable render context for buildEntry — avoids object allocation per entry.\n// All fields except `rootLifetime`, `state`, `allBindings`, `structuralBlocks`, `dom`\n// are copied from the surrounding render context per reconcile call, so the\n// initial shape's null/empty values are never observed in practice.\nconst buildCtx: RenderContext = {\n rootLifetime: null as unknown as Lifetime,\n state: null,\n allBindings: [],\n structuralBlocks: [],\n dom: null as unknown as import('../dom-env.js').DomEnv,\n}\n\n// Reusable render bag — mutated per entry instead of allocating new objects\nconst buildBag: Record<string, unknown> = {\n send: null,\n get item() {\n return (buildBag._getItemProxy as () => unknown)()\n },\n acc: null,\n index: null,\n _getItemProxy: null,\n}\n\ninterface Entry<T> {\n key: string | number\n item: T\n current: T\n index: number\n scope: Lifetime\n nodes: Node[]\n /** Per-item updaters — stored on entry directly to avoid scope overhead for leaf rows */\n updaters: Array<() => void>\n}\n\nexport function each<S, T, M = unknown>(opts: EachOptions<S, T, M>): Node[] {\n const ctx = getRenderContext('each')\n const parentLifetime = ctx.rootLifetime\n const blocks = ctx.structuralBlocks\n\n const anchor = ctx.dom.createComment('each')\n const entries: Entry<T>[] = []\n const clearCallbacks: Array<() => void> = []\n const removeCallbacks: Array<(key: string | number) => void> = []\n // Entries whose leave animation is still in progress. Their DOM nodes\n // remain in the parent until the leave Promise resolves.\n const leaving: Entry<T>[] = []\n\n const initialItems = opts.items(ctx.state as S)\n let lastItemsRef = initialItems\n\n // Dev-only diff tracking: if the owning component has an _eachDiffLog\n // (installed by devtools), we capture key sets before/after each\n // key-mutating reconcile call and emit an EachDiff entry. The siteId\n // is derived from this each() block's position in the flat block\n // array at registration time — stable for the lifetime of the block.\n const inst = ctx.instance\n const eachSiteId = inst?._eachDiffLog !== undefined ? `each#${blocks.length}` : ''\n const snapshotKeys = (): string[] | null => {\n if (inst?._eachDiffLog === undefined) return null\n const keys: string[] = []\n for (let i = 0; i < entries.length; i++) keys.push(String(entries[i]!.key))\n return keys\n }\n const emitDiff = (oldKeys: string[] | null): void => {\n if (oldKeys === null || inst?._eachDiffLog === undefined) return\n const newKeys: string[] = []\n for (let i = 0; i < entries.length; i++) newKeys.push(String(entries[i]!.key))\n const oldKeySet = new Set(oldKeys)\n const newKeySet = new Set(newKeys)\n const added: string[] = []\n const removed: string[] = []\n const moved: Array<{ key: string; from: number; to: number }> = []\n const reused: string[] = []\n for (const k of newKeys) if (!oldKeySet.has(k)) added.push(k)\n for (const k of oldKeys) if (!newKeySet.has(k)) removed.push(k)\n for (let i = 0; i < newKeys.length; i++) {\n const k = newKeys[i]!\n if (!oldKeySet.has(k)) continue\n const from = oldKeys.indexOf(k)\n if (from !== i) moved.push({ key: k, from, to: i })\n else reused.push(k)\n }\n inst._eachDiffLog.push({\n updateIndex: inst._updateCounter ?? 0,\n eachSiteId,\n added,\n removed,\n moved,\n reused,\n })\n }\n\n const block: StructuralBlock = {\n mask: (opts as { __mask?: number }).__mask ?? FULL_MASK,\n reconcile(state: unknown) {\n const parent = anchor.parentNode\n if (!parent) return\n\n const newItems = opts.items(state as S)\n\n // Fast path: same array reference → skip entirely.\n if (newItems === lastItemsRef) return\n lastItemsRef = newItems\n\n const oldKeys = snapshotKeys()\n const report = opts.onTransition ? { entering: [] as Node[], leaving: [] as Node[] } : null\n reconcileEntries(\n entries,\n newItems,\n opts,\n parentLifetime,\n parent,\n anchor,\n ctx,\n state,\n leaving,\n report,\n )\n if (opts.onTransition && report) {\n opts.onTransition({ entering: report.entering, leaving: report.leaving, parent })\n }\n emitDiff(oldKeys)\n },\n\n /** Same keys, only item data changed — skip mismatch/swap detection.\n * Compiler calls this when it knows the array structure is unchanged. */\n reconcileItems(state: unknown) {\n const newItems = opts.items(state as S)\n lastItemsRef = newItems\n const len = Math.min(entries.length, newItems.length)\n for (let i = 0; i < len; i++) {\n const entry = entries[i]!\n const newItem = newItems[i]!\n if (entry.item !== newItem) {\n updateEntry(entry, newItem, i)\n }\n }\n },\n\n /** Remove all items — skip items accessor, go straight to clear path. */\n reconcileClear() {\n lastItemsRef = [] as unknown as T[]\n const parent = anchor.parentNode\n if (!parent) return\n if (entries.length === 0) return\n\n const oldKeys = snapshotKeys()\n\n // Call registered clear callbacks (e.g., selector registry.clear())\n // BEFORE scope disposal — avoids 1000 individual Set.delete calls\n for (let i = 0; i < clearCallbacks.length; i++) clearCallbacks[i]!()\n\n // Bulk DOM removal\n const range = ctx.dom.createRange()\n range.setStartAfter(anchor)\n const lastEntry = entries[entries.length - 1]!\n const lastNode = lastEntry.nodes[lastEntry.nodes.length - 1]!\n range.setEndAfter(lastNode)\n range.deleteContents()\n\n // Bulk scope disposal — disposers that were replaced by clearCallbacks\n // are now no-ops, making this much faster\n const scopes: Lifetime[] = []\n for (let i = 0; i < entries.length; i++) {\n const s = entries[i]!.scope\n s.disposalCause = 'each-remove'\n scopes.push(s)\n }\n disposeLifetimesBulk(scopes)\n removeOrphanedChildren(parentLifetime)\n entries.length = 0\n\n emitDiff(oldKeys)\n },\n\n /** Remove entries not present in the new items. Optimized for filter()\n * patterns where items are removed but order is preserved. Walks old\n * and new arrays in parallel — O(n) with no Map/Set allocation. */\n reconcileRemove(state: unknown) {\n const newItems = opts.items(state as S)\n lastItemsRef = newItems\n const parent = anchor.parentNode\n if (!parent) return\n\n const oldKeys = snapshotKeys()\n const oldLen = entries.length\n const newLen = newItems.length\n if (newLen >= oldLen) {\n // Not a removal — fallback (shouldn't happen if compiler detected correctly)\n reconcileEntries(\n entries,\n newItems,\n opts,\n parentLifetime,\n parent,\n anchor,\n ctx,\n state,\n leaving,\n null,\n )\n emitDiff(oldKeys)\n return\n }\n\n // Parallel walk: new items are a subsequence of old items (same order, some removed)\n let ni = 0\n let didRemove = false\n for (let oi = 0; oi < oldLen; oi++) {\n const entry = entries[oi]!\n if (ni < newLen && entry.key === opts.key(newItems[ni]!)) {\n // Entry survives — update if item ref changed\n if (entry.item !== newItems[ni]) {\n updateEntry(entry, newItems[ni]!, ni)\n }\n ni++\n } else {\n // Entry removed — notify selectors before scope disposal\n for (let ci = 0; ci < removeCallbacks.length; ci++) removeCallbacks[ci]!(entry.key)\n for (const node of entry.nodes) parent.removeChild(node)\n entry.scope.disposalCause = 'each-remove'\n disposeLifetime(entry.scope, true)\n entries[oi] = null!\n didRemove = true\n }\n }\n\n // Compact entries array\n if (didRemove) {\n let w = 0\n for (let r = 0; r < oldLen; r++) {\n if (entries[r]) entries[w++] = entries[r]!\n }\n entries.length = w\n removeOrphanedChildren(parentLifetime)\n }\n\n // Update indices for remaining entries\n for (let i = 0; i < entries.length; i++) {\n entries[i]!.index = i\n }\n\n emitDiff(oldKeys)\n },\n\n /** Update only entries at stride intervals — O(k) where k = n/stride.\n * The compiler passes the stride from the detected for-loop pattern. */\n reconcileChanged(state: unknown, stride: number) {\n const newItems = opts.items(state as S)\n lastItemsRef = newItems\n for (let i = 0; i < entries.length && i < newItems.length; i += stride) {\n const entry = entries[i]!\n const newItem = newItems[i]!\n if (entry.item !== newItem) {\n updateEntry(entry, newItem, i)\n }\n }\n },\n }\n\n // Register the block BEFORE building initial row entries so that this\n // each() block precedes any nested structural blocks its rows register.\n // Parents must come first in the flat blocks array — see branch.ts for\n // the full rationale (Phase 1 iteration safety when disposing nested).\n blocks.push(block)\n\n activeClearCallbacks = clearCallbacks\n activeRemoveCallbacks = removeCallbacks\n for (let i = 0; i < initialItems.length; i++) {\n const item = initialItems[i]!\n const entry = buildEntry(item, i, opts, parentLifetime, ctx)\n entries.push(entry)\n }\n activeClearCallbacks = null\n activeRemoveCallbacks = null\n\n // Fire initial enter for mount-time items\n if (opts.enter) {\n for (const entry of entries) {\n if (entry.nodes.length > 0) opts.enter(entry.nodes)\n }\n }\n\n addDisposer(parentLifetime, () => {\n const idx = blocks.indexOf(block)\n if (idx !== -1) blocks.splice(idx, 1)\n // parentLifetime is being disposed — its children array is about to be\n // cleared by the recursive dispose pass, so skip per-entry parent\n // removal (avoids O(N²) indexOf+splice).\n for (const entry of entries) {\n disposeLifetime(entry.scope, true)\n }\n entries.length = 0\n // Force-remove any mid-leave entries immediately\n for (const entry of leaving) {\n for (const node of entry.nodes) {\n if (node.parentNode) node.parentNode.removeChild(node)\n }\n disposeLifetime(entry.scope, true)\n }\n leaving.length = 0\n })\n\n const result: Node[] = [anchor]\n for (const entry of entries) {\n const nodes = entry.nodes\n for (let i = 0; i < nodes.length; i++) result.push(nodes[i]!)\n }\n return result\n}\n\n/**\n * Remove an entry's DOM + dispose its scope, running opts.leave first if\n * provided. When leave returns a Promise, the DOM removal is deferred until\n * resolution (entry is tracked in `leaving`).\n */\nfunction removeEntry<T>(\n entry: Entry<T>,\n opts: { leave?: (nodes: Node[]) => void | Promise<void> },\n leaving: Entry<T>[],\n): void {\n const removeNow = (): void => {\n for (const node of entry.nodes) {\n if (node.parentNode) node.parentNode.removeChild(node)\n }\n entry.scope.disposalCause = 'each-remove'\n disposeLifetime(entry.scope)\n const idx = leaving.indexOf(entry)\n if (idx !== -1) leaving.splice(idx, 1)\n }\n if (opts.leave && entry.nodes.length > 0) {\n const result = opts.leave(entry.nodes)\n if (result && typeof (result as Promise<void>).then === 'function') {\n leaving.push(entry)\n ;(result as Promise<void>).then(removeNow)\n return\n }\n }\n removeNow()\n}\n\nfunction fireEnter<T>(\n entry: Entry<T>,\n opts: { enter?: (nodes: Node[]) => void | Promise<void> },\n): void {\n if (opts.enter && entry.nodes.length > 0) {\n void opts.enter(entry.nodes)\n }\n}\n\nfunction buildEntry<S, T, M>(\n item: T,\n index: number,\n opts: EachOptions<S, T, M>,\n parentLifetime: Lifetime,\n ctx: ReturnType<typeof getRenderContext>,\n state?: unknown,\n): Entry<T> {\n const key = opts.key(item)\n // Use a lightweight scope — just needs itemUpdaters for per-item bindings.\n // Full scope features (disposers, bindings, children) are only needed when\n // the render callback uses structural primitives or selector.bind().\n const scope = createLifetime(parentLifetime)\n scope._kind = 'each'\n const currentState = (state ?? ctx.state) as S\n const send = ctx.send as (msg: M) => void\n\n // Create entry before render so itemAccessor closures can capture it\n const entry: Entry<T> = { key, item, current: item, index, scope, nodes: null!, updaters: [] }\n\n // Base callable: item(selector) for computed expressions\n const itemFn = <R>(selector: (t: T) => R): (() => R) => {\n const accessor = () => selector(entry.current)\n accessor.__perItem = true as const\n return accessor\n }\n\n // Proxy for item.field shorthand: LAZILY created. Compiled code uses\n // `acc(fn)` instead (the compiler rewrites item.x → acc(r => r.x)),\n // so the Proxy is never constructed in the common case. This saves\n // ~300ns × N Proxy allocations per create cycle.\n let itemProxy: ItemAccessor<T> | null = null\n const getItemProxy = (): ItemAccessor<T> => {\n if (itemProxy) return itemProxy\n let fieldCache: Map<string, () => unknown> | null = null\n itemProxy = new Proxy(itemFn as object, {\n get(target, prop) {\n if (typeof prop === 'symbol' || prop === 'then' || prop === 'prototype') {\n return Reflect.get(target, prop)\n }\n const key = prop as string\n if (fieldCache) {\n const cached = fieldCache.get(key)\n if (cached) return cached\n } else {\n fieldCache = new Map()\n }\n // `current` returns the whole item — essential for primitive T\n // (where the field map is useless) and for whole-record sampling.\n // Caller must call it like a method: `item.current()`.\n const accessor =\n key === 'current'\n ? () => entry.current\n : () => (entry.current as Record<string, unknown>)[key]\n ;(accessor as unknown as { __perItem: true }).__perItem = true\n fieldCache.set(key, accessor)\n return accessor\n },\n }) as ItemAccessor<T>\n return itemProxy\n }\n\n const indexAccessor = (): number => entry.index\n\n // Reuse a single context object to avoid allocation per entry\n buildCtx.rootLifetime = scope\n buildCtx.state = currentState\n buildCtx.allBindings = ctx.allBindings\n buildCtx.structuralBlocks = ctx.structuralBlocks\n buildCtx.dom = ctx.dom\n buildCtx.instance = ctx.instance\n const prevFlatBindings = getFlatBindings()\n setFlatBindings(ctx.allBindings)\n setRenderContext(buildCtx)\n\n // Reuse a single render bag object across entries — mutate `acc` and\n // `index` per entry to avoid per-entry object allocation.\n buildBag.send = send\n buildBag.acc = itemFn\n buildBag.index = indexAccessor\n buildBag._getItemProxy = getItemProxy\n buildBag.entry = entry\n // The View bag — lets each.render use `h.text`, `h.scope`, `h.sample`,\n // etc. without reaching for the top-level imports. Each entry gets a\n // fresh View so its `send` is bound to this row's dispatch path.\n buildBag.h = createView<S, M>(send)\n // Row factory: pass compiler-injected template + update function through to render\n const rfOpts = opts as unknown as Record<string, unknown>\n if (rfOpts.__tpl) buildBag.__tpl = rfOpts.__tpl\n if (rfOpts.__rowUpd) buildBag.__rowUpd = rfOpts.__rowUpd\n entry.nodes = opts.render(buildBag as Parameters<typeof opts.render>[0])\n\n // Move itemUpdaters from scope to entry for direct access during updateEntry.\n // This avoids scope.itemUpdaters lookup overhead on every item update.\n if (scope.itemUpdaters.length > 0) {\n entry.updaters = scope.itemUpdaters\n scope.itemUpdaters = []\n }\n\n clearRenderContext()\n setFlatBindings(prevFlatBindings)\n setRenderContext(ctx)\n\n return entry\n}\n\ninterface TransitionReport {\n entering: Node[]\n leaving: Node[]\n}\n\nfunction collectNodes(target: Node[], nodes: Node[]): void {\n for (const n of nodes) target.push(n)\n}\n\nfunction reconcileEntries<S, T>(\n entries: Entry<T>[],\n newItems: T[],\n opts: EachOptions<S, T>,\n parentLifetime: Lifetime,\n parent: Node,\n anchor: Node,\n ctx: ReturnType<typeof getRenderContext>,\n state: unknown,\n leaving: Entry<T>[],\n report: TransitionReport | null,\n): void {\n const oldLen = entries.length\n const newLen = newItems.length\n const hasLeave = !!opts.leave\n\n // Fast path 1: clear all — bulk DOM removal.\n // When opts.leave is set, each item needs its own leave animation, so\n // fall through to per-item removal instead of Range.deleteContents().\n if (newLen === 0) {\n if (report) {\n for (const entry of entries) collectNodes(report.leaving, entry.nodes)\n }\n if (hasLeave) {\n const toRemove = entries.slice()\n entries.length = 0\n for (const entry of toRemove) removeEntry(entry, opts, leaving)\n return\n }\n // Remove all DOM nodes in one operation using Range\n if (entries.length > 0) {\n const range = ctx.dom.createRange()\n range.setStartAfter(anchor)\n const lastEntry = entries[entries.length - 1]!\n const lastNode = lastEntry.nodes[lastEntry.nodes.length - 1]!\n range.setEndAfter(lastNode)\n range.deleteContents()\n }\n // Bulk dispose all entry scopes — avoids per-scope function call overhead\n const scopes: Lifetime[] = []\n for (let i = 0; i < entries.length; i++) {\n const s = entries[i]!.scope\n s.disposalCause = 'each-remove'\n scopes.push(s)\n }\n disposeLifetimesBulk(scopes)\n removeOrphanedChildren(parentLifetime)\n entries.length = 0\n return\n }\n\n // Fast path 2: append-only — old keys are a prefix of new keys\n if (newLen > oldLen && isAppendOnly(entries, newItems, opts)) {\n for (let i = 0; i < oldLen; i++) {\n updateEntry(entries[i]!, newItems[i]!, i)\n }\n // Find insertion point: after last existing entry's last node, or after anchor\n const lastEntry = oldLen > 0 ? entries[oldLen - 1]! : null\n const ref = lastEntry\n ? lastEntry.nodes[lastEntry.nodes.length - 1]!.nextSibling\n : anchor.nextSibling\n const frag = ctx.dom.createDocumentFragment()\n const newlyAdded: Entry<T>[] = []\n for (let i = oldLen; i < newLen; i++) {\n const entry = buildEntry(newItems[i]!, i, opts, parentLifetime, ctx, state)\n entries.push(entry)\n newlyAdded.push(entry)\n for (const node of entry.nodes) frag.appendChild(node)\n }\n parent.insertBefore(frag, ref)\n if (report) {\n for (const entry of newlyAdded) collectNodes(report.entering, entry.nodes)\n }\n for (const entry of newlyAdded) fireEnter(entry, opts)\n return\n }\n\n // Fast path 3: same length — single pass handles both same-keys update\n // and two-element swap detection. Avoids a second O(n) pass.\n if (newLen === oldLen) {\n let mismatch1 = -1\n let mismatch2 = -1\n let mismatchCount = 0\n\n for (let i = 0; i < newLen; i++) {\n const entry = entries[i]!\n const newItem = newItems[i]!\n if (entry.item === newItem) continue\n const newKey = opts.key(newItem)\n if (entry.key === newKey) {\n updateEntry(entry, newItem, i)\n continue\n }\n // Key mismatch — track for swap detection\n mismatchCount++\n if (mismatchCount === 1) mismatch1 = i\n else if (mismatchCount === 2) mismatch2 = i\n else break // 3+ mismatches → fall through to general path\n }\n\n // All keys matched (with possible item updates) → done\n if (mismatchCount === 0) return\n\n // Exactly 2 key mismatches — check if it's a swap\n if (mismatchCount === 2) {\n const e1 = entries[mismatch1]!\n const e2 = entries[mismatch2]!\n if (e1.key === opts.key(newItems[mismatch2]!) && e2.key === opts.key(newItems[mismatch1]!)) {\n // DOM swap\n const refI = e1.nodes[0]!\n const refAfterJ = e2.nodes[e2.nodes.length - 1]!.nextSibling\n for (const node of e2.nodes) parent.insertBefore(node, refI)\n for (const node of e1.nodes) parent.insertBefore(node, refAfterJ)\n entries[mismatch1] = e2\n entries[mismatch2] = e1\n updateEntry(e2, newItems[mismatch1]!, mismatch1)\n updateEntry(e1, newItems[mismatch2]!, mismatch2)\n return\n }\n }\n // Fall through to general path for 3+ mismatches or non-swap\n }\n\n // Fast path 5: full replace — no shared keys between old and new.\n // Skipped when opts.leave is set so departing items can animate individually.\n if (!hasLeave && oldLen > 0 && opts.key(newItems[0]!) !== entries[0]!.key) {\n const oldKeys = new Set<string | number>()\n for (const entry of entries) oldKeys.add(entry.key)\n let anyShared = false\n for (let i = 0; i < newLen; i++) {\n if (oldKeys.has(opts.key(newItems[i]!))) {\n anyShared = true\n break\n }\n }\n if (!anyShared) {\n if (report) {\n for (const entry of entries) collectNodes(report.leaving, entry.nodes)\n }\n // Bulk DOM removal using Range\n const range = ctx.dom.createRange()\n range.setStartAfter(anchor)\n const lastEntry = entries[entries.length - 1]!\n range.setEndAfter(lastEntry.nodes[lastEntry.nodes.length - 1]!)\n range.deleteContents()\n // Bulk dispose all old scopes\n const oldLifetimes: Lifetime[] = []\n for (let i = 0; i < entries.length; i++) {\n const s = entries[i]!.scope\n s.disposalCause = 'each-remove'\n oldLifetimes.push(s)\n }\n disposeLifetimesBulk(oldLifetimes)\n removeOrphanedChildren(parentLifetime)\n entries.length = 0\n // Build all new entries into a fragment\n const frag = ctx.dom.createDocumentFragment()\n const newlyAdded: Entry<T>[] = []\n for (let i = 0; i < newLen; i++) {\n const entry = buildEntry(newItems[i]!, i, opts, parentLifetime, ctx, state)\n entries.push(entry)\n newlyAdded.push(entry)\n for (const node of entry.nodes) frag.appendChild(node)\n }\n parent.insertBefore(frag, anchor.nextSibling)\n if (report) {\n for (const entry of newlyAdded) collectNodes(report.entering, entry.nodes)\n }\n for (const entry of newlyAdded) fireEnter(entry, opts)\n return\n }\n }\n\n // General path: keyed reconciliation\n const oldByKey = new Map<string | number, Entry<T>>()\n for (const entry of entries) {\n oldByKey.set(entry.key, entry)\n }\n\n const newEntries: Entry<T>[] = []\n const usedKeys = new Set<string | number>()\n const newlyAdded: Entry<T>[] = []\n\n for (let i = 0; i < newLen; i++) {\n const item = newItems[i]!\n const key = opts.key(item)\n usedKeys.add(key)\n\n const existing = oldByKey.get(key)\n if (existing) {\n updateEntry(existing, item, i)\n newEntries.push(existing)\n } else {\n const entry = buildEntry(item, i, opts, parentLifetime, ctx, state)\n newEntries.push(entry)\n newlyAdded.push(entry)\n }\n }\n\n // Remove entries not in the new list. Use bulk-detach pattern so\n // disposing K removals costs O(K+P) rather than O(K*P) where P is\n // parentLifetime.children.length (avoids K * indexOf+splice).\n let didBulkDetach = false\n for (const entry of entries) {\n if (!usedKeys.has(entry.key)) {\n if (report) collectNodes(report.leaving, entry.nodes)\n if (hasLeave) {\n removeEntry(entry, opts, leaving)\n } else {\n for (const node of entry.nodes) parent.removeChild(node)\n entry.scope.disposalCause = 'each-remove'\n disposeLifetime(entry.scope, true)\n didBulkDetach = true\n }\n }\n }\n if (didBulkDetach) removeOrphanedChildren(parentLifetime)\n\n // Reorder DOM\n const hasSurvivors = newEntries.some((e) => oldByKey.has(e.key))\n\n if (!hasSurvivors || !survivorsInOrder(entries, newEntries, usedKeys)) {\n // Full fragment rebuild — one reflow\n const frag = ctx.dom.createDocumentFragment()\n for (const entry of newEntries) {\n for (const node of entry.nodes) frag.appendChild(node)\n }\n parent.insertBefore(frag, anchor.nextSibling)\n } else {\n // Survivors in order — batch-insert new entries between survivors\n let frag: DocumentFragment | null = null\n let insertRef: ChildNode | null = anchor.nextSibling\n for (const entry of newEntries) {\n if (oldByKey.has(entry.key)) {\n // Flush any pending fragment before this survivor\n if (frag) {\n parent.insertBefore(frag, insertRef)\n frag = null\n }\n // Skip past survivor's nodes\n const lastNode = entry.nodes[entry.nodes.length - 1]\n insertRef = lastNode ? lastNode.nextSibling : insertRef\n } else {\n // Batch new entries into a fragment\n if (!frag) frag = ctx.dom.createDocumentFragment()\n for (const node of entry.nodes) frag.appendChild(node)\n }\n }\n if (frag) parent.insertBefore(frag, insertRef)\n }\n\n entries.length = newEntries.length\n for (let i = 0; i < newEntries.length; i++) entries[i] = newEntries[i]!\n\n if (report) {\n for (const entry of newlyAdded) collectNodes(report.entering, entry.nodes)\n }\n\n // Fire enter for newly-added entries (after DOM insertion)\n if (opts.enter) {\n for (const entry of newlyAdded) fireEnter(entry, opts)\n }\n}\n\nfunction updateEntry<T>(entry: Entry<T>, item: T, index: number): void {\n const changed = !Object.is(entry.item, item)\n entry.item = item\n entry.current = item\n entry.index = index\n // eachItemStable removed — unused\n // Directly run per-item updaters when item changed — bypasses Phase 2\n if (changed) {\n // Row factory fast path: shared update function, zero closures\n const rowUpd = (entry as unknown as Record<string, unknown>).__rowUpdate as\n | ((e: Entry<T>) => void)\n | undefined\n if (rowUpd) {\n rowUpd(entry)\n } else {\n // Closure-based fallback\n const updaters = entry.updaters.length > 0 ? entry.updaters : entry.scope.itemUpdaters\n for (let i = 0; i < updaters.length; i++) {\n updaters[i]!()\n }\n }\n }\n}\n\nfunction isAppendOnly<S, T>(entries: Entry<T>[], newItems: T[], opts: EachOptions<S, T>): boolean {\n for (let i = 0; i < entries.length; i++) {\n if (entries[i]!.key !== opts.key(newItems[i]!)) return false\n }\n return true\n}\n\nfunction survivorsInOrder<T>(\n oldEntries: Entry<T>[],\n newEntries: Entry<T>[],\n usedKeys: Set<string | number>,\n): boolean {\n // Build old-index map for survivors\n const oldIndexMap = new Map<string | number, number>()\n for (let i = 0; i < oldEntries.length; i++) {\n if (usedKeys.has(oldEntries[i]!.key)) {\n oldIndexMap.set(oldEntries[i]!.key, i)\n }\n }\n // Check that survivors appear in increasing old-index order in newEntries\n let maxOldIndex = -1\n for (const entry of newEntries) {\n const oldIdx = oldIndexMap.get(entry.key)\n if (oldIdx === undefined) continue // new entry, skip\n if (oldIdx < maxOldIndex) return false\n maxOldIndex = oldIdx\n }\n return true\n}\n"]}
1
+ {"version":3,"file":"each.js","sourceRoot":"","sources":["../../src/primitives/each.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,GAEnB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,sBAAsB,GACvB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE/C,6FAA6F;AAC7F,kFAAkF;AAClF,IAAI,oBAAoB,GAA6B,IAAI,CAAA;AACzD,IAAI,qBAAqB,GAAiD,IAAI,CAAA;AAE9E,uEAAuE;AACvE,MAAM,UAAU,eAAe,CAAC,EAAc;IAC5C,IAAI,oBAAoB;QAAE,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACzD,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,gBAAgB,CAAC,EAAkC;IACjE,IAAI,qBAAqB;QAAE,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAC3D,C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AAI,MAAM,KAAK,SAAS;YAAE,SAAQ,CAAC,kBAAkB;QACrD,IAAI,MAAM,GAAG,WAAW;YAAE,OAAO,KAAK,CAAA;QACtC,WAAW,GAAG,MAAM,CAAA;IACtB,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import type { EachOptions, ItemAccessor, Lifetime } from '../types.js'\nimport {\n getRenderContext,\n setRenderContext,\n clearRenderContext,\n type RenderContext,\n} from '../render-context.js'\nimport {\n createLifetime,\n disposeLifetime,\n disposeLifetimesBulk,\n addDisposer,\n removeOrphanedChildren,\n} from '../lifetime.js'\nimport { getFlatBindings, setFlatBindings } from '../binding.js'\nimport { FULL_MASK } from '../update-loop.js'\nimport type { StructuralBlock } from '../structural.js'\nimport { createView } from '../view-helpers.js'\n\n// Clear callbacks — registered by selector.bind() during render, called by reconcileClear().\n// Eliminates per-row disposers (1000 Set.delete calls → 1 registry.clear() call).\nlet activeClearCallbacks: Array<() => void> | null = null\nlet activeRemoveCallbacks: Array<(key: string | number) => void> | null = null\n\n/** Register a callback to run when the current each() block clears. */\nexport function registerOnClear(cb: () => void): void {\n if (activeClearCallbacks) activeClearCallbacks.push(cb)\n}\n\n/** Register a callback to run when a single row is removed by key. */\nexport function registerOnRemove(cb: (key: string | number) => void): void {\n if (activeRemoveCallbacks) activeRemoveCallbacks.push(cb)\n}\n\n// Reusable render context for buildEntry — avoids object allocation per entry.\n// All fields except `rootLifetime`, `state`, `allBindings`, `structuralBlocks`, `dom`\n// are copied from the surrounding render context per reconcile call, so the\n// initial shape's null/empty values are never observed in practice.\nconst buildCtx: RenderContext = {\n rootLifetime: null as unknown as Lifetime,\n state: null,\n allBindings: [],\n structuralBlocks: [],\n dom: null as unknown as import('../dom-env.js').DomEnv,\n}\n\n// Reusable render bag — mutated per entry instead of allocating new objects\nconst buildBag: Record<string, unknown> = {\n send: null,\n get item() {\n return (buildBag._getItemProxy as () => unknown)()\n },\n acc: null,\n index: null,\n _getItemProxy: null,\n}\n\ninterface Entry<T> {\n key: string | number\n item: T\n current: T\n index: number\n scope: Lifetime\n nodes: Node[]\n /** Per-item updaters — stored on entry directly to avoid scope overhead for leaf rows */\n updaters: Array<() => void>\n}\n\nexport function each<S, T, M = unknown>(opts: EachOptions<S, T, M>): Node[] {\n const ctx = getRenderContext('each')\n const parentLifetime = ctx.rootLifetime\n const blocks = ctx.structuralBlocks\n\n const anchor = ctx.dom.createComment('each')\n const entries: Entry<T>[] = []\n const clearCallbacks: Array<() => void> = []\n const removeCallbacks: Array<(key: string | number) => void> = []\n // Entries whose leave animation is still in progress. Their DOM nodes\n // remain in the parent until the leave Promise resolves.\n const leaving: Entry<T>[] = []\n\n const initialItems = opts.items(ctx.state as S)\n let lastItemsRef = initialItems\n\n // Dev-only diff tracking: if the owning component has an _eachDiffLog\n // (installed by devtools), we capture key sets before/after each\n // key-mutating reconcile call and emit an EachDiff entry. The siteId\n // is derived from this each() block's position in the flat block\n // array at registration time — stable for the lifetime of the block.\n const inst = ctx.instance\n const eachSiteId = inst?._eachDiffLog !== undefined ? `each#${blocks.length}` : ''\n const snapshotKeys = (): string[] | null => {\n if (inst?._eachDiffLog === undefined) return null\n const keys: string[] = []\n for (let i = 0; i < entries.length; i++) keys.push(String(entries[i]!.key))\n return keys\n }\n const emitDiff = (oldKeys: string[] | null): void => {\n if (oldKeys === null || inst?._eachDiffLog === undefined) return\n const newKeys: string[] = []\n for (let i = 0; i < entries.length; i++) newKeys.push(String(entries[i]!.key))\n const oldKeySet = new Set(oldKeys)\n const newKeySet = new Set(newKeys)\n const added: string[] = []\n const removed: string[] = []\n const moved: Array<{ key: string; from: number; to: number }> = []\n const reused: string[] = []\n for (const k of newKeys) if (!oldKeySet.has(k)) added.push(k)\n for (const k of oldKeys) if (!newKeySet.has(k)) removed.push(k)\n for (let i = 0; i < newKeys.length; i++) {\n const k = newKeys[i]!\n if (!oldKeySet.has(k)) continue\n const from = oldKeys.indexOf(k)\n if (from !== i) moved.push({ key: k, from, to: i })\n else reused.push(k)\n }\n inst._eachDiffLog.push({\n updateIndex: inst._updateCounter ?? 0,\n eachSiteId,\n added,\n removed,\n moved,\n reused,\n })\n }\n\n const block: StructuralBlock = {\n mask: (opts as { __mask?: number }).__mask ?? FULL_MASK,\n reconcile(state: unknown) {\n const parent = anchor.parentNode\n if (!parent) return\n\n const newItems = opts.items(state as S)\n\n // Fast path: same array reference → skip entirely.\n if (newItems === lastItemsRef) return\n lastItemsRef = newItems\n\n const oldKeys = snapshotKeys()\n const report = opts.onTransition ? { entering: [] as Node[], leaving: [] as Node[] } : null\n reconcileEntries(\n entries,\n newItems,\n opts,\n parentLifetime,\n parent,\n anchor,\n ctx,\n state,\n leaving,\n report,\n )\n if (opts.onTransition && report) {\n opts.onTransition({ entering: report.entering, leaving: report.leaving, parent })\n }\n emitDiff(oldKeys)\n },\n\n /** Same keys, only item data changed — skip mismatch/swap detection.\n * Compiler calls this when it knows the array structure is unchanged. */\n reconcileItems(state: unknown) {\n const newItems = opts.items(state as S)\n lastItemsRef = newItems\n const len = Math.min(entries.length, newItems.length)\n for (let i = 0; i < len; i++) {\n const entry = entries[i]!\n const newItem = newItems[i]!\n if (entry.item !== newItem) {\n updateEntry(entry, newItem, i)\n }\n }\n },\n\n /** Remove all items — skip items accessor, go straight to clear path. */\n reconcileClear() {\n lastItemsRef = [] as unknown as T[]\n const parent = anchor.parentNode\n if (!parent) return\n if (entries.length === 0) return\n\n const oldKeys = snapshotKeys()\n\n // Call registered clear callbacks (e.g., selector registry.clear())\n // BEFORE scope disposal — avoids 1000 individual Set.delete calls\n for (let i = 0; i < clearCallbacks.length; i++) clearCallbacks[i]!()\n\n // Bulk DOM removal\n const range = ctx.dom.createRange()\n range.setStartAfter(anchor)\n const lastEntry = entries[entries.length - 1]!\n const lastNode = lastEntry.nodes[lastEntry.nodes.length - 1]!\n range.setEndAfter(lastNode)\n range.deleteContents()\n\n // Bulk scope disposal — disposers that were replaced by clearCallbacks\n // are now no-ops, making this much faster\n const scopes: Lifetime[] = []\n for (let i = 0; i < entries.length; i++) {\n const s = entries[i]!.scope\n s.disposalCause = 'each-remove'\n scopes.push(s)\n }\n disposeLifetimesBulk(scopes)\n removeOrphanedChildren(parentLifetime)\n entries.length = 0\n\n emitDiff(oldKeys)\n },\n\n /** Remove entries not present in the new items. Optimized for filter()\n * patterns where items are removed but order is preserved. Walks old\n * and new arrays in parallel — O(n) with no Map/Set allocation. */\n reconcileRemove(state: unknown) {\n const newItems = opts.items(state as S)\n lastItemsRef = newItems\n const parent = anchor.parentNode\n if (!parent) return\n\n const oldKeys = snapshotKeys()\n const oldLen = entries.length\n const newLen = newItems.length\n if (newLen >= oldLen) {\n // Not a removal — fallback (shouldn't happen if compiler detected correctly)\n reconcileEntries(\n entries,\n newItems,\n opts,\n parentLifetime,\n parent,\n anchor,\n ctx,\n state,\n leaving,\n null,\n )\n emitDiff(oldKeys)\n return\n }\n\n // Parallel walk: new items are a subsequence of old items (same order, some removed)\n let ni = 0\n let didRemove = false\n for (let oi = 0; oi < oldLen; oi++) {\n const entry = entries[oi]!\n if (ni < newLen && entry.key === opts.key(newItems[ni]!)) {\n // Entry survives — update if item ref changed\n if (entry.item !== newItems[ni]) {\n updateEntry(entry, newItems[ni]!, ni)\n }\n ni++\n } else {\n // Entry removed — notify selectors before scope disposal\n for (let ci = 0; ci < removeCallbacks.length; ci++) removeCallbacks[ci]!(entry.key)\n for (const node of entry.nodes) parent.removeChild(node)\n entry.scope.disposalCause = 'each-remove'\n disposeLifetime(entry.scope, true)\n entries[oi] = null!\n didRemove = true\n }\n }\n\n // Compact entries array\n if (didRemove) {\n let w = 0\n for (let r = 0; r < oldLen; r++) {\n if (entries[r]) entries[w++] = entries[r]!\n }\n entries.length = w\n removeOrphanedChildren(parentLifetime)\n }\n\n // Update indices for remaining entries\n for (let i = 0; i < entries.length; i++) {\n entries[i]!.index = i\n }\n\n emitDiff(oldKeys)\n },\n\n /** Update only entries at stride intervals — O(k) where k = n/stride.\n * The compiler passes the stride from the detected for-loop pattern. */\n reconcileChanged(state: unknown, stride: number) {\n const newItems = opts.items(state as S)\n lastItemsRef = newItems\n for (let i = 0; i < entries.length && i < newItems.length; i += stride) {\n const entry = entries[i]!\n const newItem = newItems[i]!\n if (entry.item !== newItem) {\n updateEntry(entry, newItem, i)\n }\n }\n },\n }\n\n // Register the block BEFORE building initial row entries so that this\n // each() block precedes any nested structural blocks its rows register.\n // Parents must come first in the flat blocks array — see branch.ts for\n // the full rationale (Phase 1 iteration safety when disposing nested).\n blocks.push(block)\n\n activeClearCallbacks = clearCallbacks\n activeRemoveCallbacks = removeCallbacks\n for (let i = 0; i < initialItems.length; i++) {\n const item = initialItems[i]!\n const entry = buildEntry(item, i, opts, parentLifetime, ctx)\n entries.push(entry)\n }\n activeClearCallbacks = null\n activeRemoveCallbacks = null\n\n // Fire initial enter for mount-time items\n if (opts.enter) {\n for (const entry of entries) {\n if (entry.nodes.length > 0) opts.enter(entry.nodes)\n }\n }\n\n addDisposer(parentLifetime, () => {\n const idx = blocks.indexOf(block)\n if (idx !== -1) blocks.splice(idx, 1)\n // parentLifetime is being disposed — its children array is about to be\n // cleared by the recursive dispose pass, so skip per-entry parent\n // removal (avoids O(N²) indexOf+splice).\n //\n // Rows created AFTER the parent's initial render (each reconciled\n // with a new item list) are siblings of the anchor inside the\n // parent's DOM container, but aren't tracked by the parent's\n // snapshot (e.g. an outer branch's currentNodes). Walking entries\n // here and removing their DOM — guarded by parentNode — closes\n // the leak: cascade-removed subtrees no-op, live-parent cases get\n // the orphans cleaned up.\n for (const entry of entries) {\n for (const node of entry.nodes) {\n if (node.parentNode) node.parentNode.removeChild(node)\n }\n disposeLifetime(entry.scope, true)\n }\n entries.length = 0\n if (anchor.parentNode) anchor.parentNode.removeChild(anchor)\n // Force-remove any mid-leave entries immediately\n for (const entry of leaving) {\n for (const node of entry.nodes) {\n if (node.parentNode) node.parentNode.removeChild(node)\n }\n disposeLifetime(entry.scope, true)\n }\n leaving.length = 0\n })\n\n const result: Node[] = [anchor]\n for (const entry of entries) {\n const nodes = entry.nodes\n for (let i = 0; i < nodes.length; i++) result.push(nodes[i]!)\n }\n return result\n}\n\n/**\n * Remove an entry's DOM + dispose its scope, running opts.leave first if\n * provided. When leave returns a Promise, the DOM removal is deferred until\n * resolution (entry is tracked in `leaving`).\n */\nfunction removeEntry<T>(\n entry: Entry<T>,\n opts: { leave?: (nodes: Node[]) => void | Promise<void> },\n leaving: Entry<T>[],\n): void {\n const removeNow = (): void => {\n for (const node of entry.nodes) {\n if (node.parentNode) node.parentNode.removeChild(node)\n }\n entry.scope.disposalCause = 'each-remove'\n disposeLifetime(entry.scope)\n const idx = leaving.indexOf(entry)\n if (idx !== -1) leaving.splice(idx, 1)\n }\n if (opts.leave && entry.nodes.length > 0) {\n const result = opts.leave(entry.nodes)\n if (result && typeof (result as Promise<void>).then === 'function') {\n leaving.push(entry)\n ;(result as Promise<void>).then(removeNow)\n return\n }\n }\n removeNow()\n}\n\nfunction fireEnter<T>(\n entry: Entry<T>,\n opts: { enter?: (nodes: Node[]) => void | Promise<void> },\n): void {\n if (opts.enter && entry.nodes.length > 0) {\n void opts.enter(entry.nodes)\n }\n}\n\nfunction buildEntry<S, T, M>(\n item: T,\n index: number,\n opts: EachOptions<S, T, M>,\n parentLifetime: Lifetime,\n ctx: ReturnType<typeof getRenderContext>,\n state?: unknown,\n): Entry<T> {\n const key = opts.key(item)\n // Use a lightweight scope — just needs itemUpdaters for per-item bindings.\n // Full scope features (disposers, bindings, children) are only needed when\n // the render callback uses structural primitives or selector.bind().\n const scope = createLifetime(parentLifetime)\n scope._kind = 'each'\n const currentState = (state ?? ctx.state) as S\n const send = ctx.send as (msg: M) => void\n\n // Create entry before render so itemAccessor closures can capture it\n const entry: Entry<T> = { key, item, current: item, index, scope, nodes: null!, updaters: [] }\n\n // Base callable: item(selector) for computed expressions\n const itemFn = <R>(selector: (t: T) => R): (() => R) => {\n const accessor = () => selector(entry.current)\n accessor.__perItem = true as const\n return accessor\n }\n\n // Proxy for item.field shorthand: LAZILY created. Compiled code uses\n // `acc(fn)` instead (the compiler rewrites item.x → acc(r => r.x)),\n // so the Proxy is never constructed in the common case. This saves\n // ~300ns × N Proxy allocations per create cycle.\n let itemProxy: ItemAccessor<T> | null = null\n const getItemProxy = (): ItemAccessor<T> => {\n if (itemProxy) return itemProxy\n let fieldCache: Map<string, () => unknown> | null = null\n itemProxy = new Proxy(itemFn as object, {\n get(target, prop) {\n if (typeof prop === 'symbol' || prop === 'then' || prop === 'prototype') {\n return Reflect.get(target, prop)\n }\n const key = prop as string\n if (fieldCache) {\n const cached = fieldCache.get(key)\n if (cached) return cached\n } else {\n fieldCache = new Map()\n }\n // `current` returns the whole item — essential for primitive T\n // (where the field map is useless) and for whole-record sampling.\n // Caller must call it like a method: `item.current()`.\n const accessor =\n key === 'current'\n ? () => entry.current\n : () => (entry.current as Record<string, unknown>)[key]\n ;(accessor as unknown as { __perItem: true }).__perItem = true\n fieldCache.set(key, accessor)\n return accessor\n },\n }) as ItemAccessor<T>\n return itemProxy\n }\n\n const indexAccessor = (): number => entry.index\n\n // Reuse a single context object to avoid allocation per entry\n buildCtx.rootLifetime = scope\n buildCtx.state = currentState\n buildCtx.allBindings = ctx.allBindings\n buildCtx.structuralBlocks = ctx.structuralBlocks\n buildCtx.dom = ctx.dom\n buildCtx.instance = ctx.instance\n const prevFlatBindings = getFlatBindings()\n setFlatBindings(ctx.allBindings)\n setRenderContext(buildCtx)\n\n // Reuse a single render bag object across entries — mutate `acc` and\n // `index` per entry to avoid per-entry object allocation.\n buildBag.send = send\n buildBag.acc = itemFn\n buildBag.index = indexAccessor\n buildBag._getItemProxy = getItemProxy\n buildBag.entry = entry\n // The View bag — lets each.render use `h.text`, `h.scope`, `h.sample`,\n // etc. without reaching for the top-level imports. Each entry gets a\n // fresh View so its `send` is bound to this row's dispatch path.\n buildBag.h = createView<S, M>(send)\n // Row factory: pass compiler-injected template + update function through to render\n const rfOpts = opts as unknown as Record<string, unknown>\n if (rfOpts.__tpl) buildBag.__tpl = rfOpts.__tpl\n if (rfOpts.__rowUpd) buildBag.__rowUpd = rfOpts.__rowUpd\n entry.nodes = opts.render(buildBag as Parameters<typeof opts.render>[0])\n\n // Move itemUpdaters from scope to entry for direct access during updateEntry.\n // This avoids scope.itemUpdaters lookup overhead on every item update.\n if (scope.itemUpdaters.length > 0) {\n entry.updaters = scope.itemUpdaters\n scope.itemUpdaters = []\n }\n\n clearRenderContext()\n setFlatBindings(prevFlatBindings)\n setRenderContext(ctx)\n\n return entry\n}\n\ninterface TransitionReport {\n entering: Node[]\n leaving: Node[]\n}\n\nfunction collectNodes(target: Node[], nodes: Node[]): void {\n for (const n of nodes) target.push(n)\n}\n\nfunction reconcileEntries<S, T>(\n entries: Entry<T>[],\n newItems: T[],\n opts: EachOptions<S, T>,\n parentLifetime: Lifetime,\n parent: Node,\n anchor: Node,\n ctx: ReturnType<typeof getRenderContext>,\n state: unknown,\n leaving: Entry<T>[],\n report: TransitionReport | null,\n): void {\n const oldLen = entries.length\n const newLen = newItems.length\n const hasLeave = !!opts.leave\n\n // Fast path 1: clear all — bulk DOM removal.\n // When opts.leave is set, each item needs its own leave animation, so\n // fall through to per-item removal instead of Range.deleteContents().\n if (newLen === 0) {\n if (report) {\n for (const entry of entries) collectNodes(report.leaving, entry.nodes)\n }\n if (hasLeave) {\n const toRemove = entries.slice()\n entries.length = 0\n for (const entry of toRemove) removeEntry(entry, opts, leaving)\n return\n }\n // Remove all DOM nodes in one operation using Range\n if (entries.length > 0) {\n const range = ctx.dom.createRange()\n range.setStartAfter(anchor)\n const lastEntry = entries[entries.length - 1]!\n const lastNode = lastEntry.nodes[lastEntry.nodes.length - 1]!\n range.setEndAfter(lastNode)\n range.deleteContents()\n }\n // Bulk dispose all entry scopes — avoids per-scope function call overhead\n const scopes: Lifetime[] = []\n for (let i = 0; i < entries.length; i++) {\n const s = entries[i]!.scope\n s.disposalCause = 'each-remove'\n scopes.push(s)\n }\n disposeLifetimesBulk(scopes)\n removeOrphanedChildren(parentLifetime)\n entries.length = 0\n return\n }\n\n // Fast path 2: append-only — old keys are a prefix of new keys\n if (newLen > oldLen && isAppendOnly(entries, newItems, opts)) {\n for (let i = 0; i < oldLen; i++) {\n updateEntry(entries[i]!, newItems[i]!, i)\n }\n // Find insertion point: after last existing entry's last node, or after anchor\n const lastEntry = oldLen > 0 ? entries[oldLen - 1]! : null\n const ref = lastEntry\n ? lastEntry.nodes[lastEntry.nodes.length - 1]!.nextSibling\n : anchor.nextSibling\n const frag = ctx.dom.createDocumentFragment()\n const newlyAdded: Entry<T>[] = []\n for (let i = oldLen; i < newLen; i++) {\n const entry = buildEntry(newItems[i]!, i, opts, parentLifetime, ctx, state)\n entries.push(entry)\n newlyAdded.push(entry)\n for (const node of entry.nodes) frag.appendChild(node)\n }\n parent.insertBefore(frag, ref)\n if (report) {\n for (const entry of newlyAdded) collectNodes(report.entering, entry.nodes)\n }\n for (const entry of newlyAdded) fireEnter(entry, opts)\n return\n }\n\n // Fast path 3: same length — single pass handles both same-keys update\n // and two-element swap detection. Avoids a second O(n) pass.\n if (newLen === oldLen) {\n let mismatch1 = -1\n let mismatch2 = -1\n let mismatchCount = 0\n\n for (let i = 0; i < newLen; i++) {\n const entry = entries[i]!\n const newItem = newItems[i]!\n if (entry.item === newItem) continue\n const newKey = opts.key(newItem)\n if (entry.key === newKey) {\n updateEntry(entry, newItem, i)\n continue\n }\n // Key mismatch — track for swap detection\n mismatchCount++\n if (mismatchCount === 1) mismatch1 = i\n else if (mismatchCount === 2) mismatch2 = i\n else break // 3+ mismatches → fall through to general path\n }\n\n // All keys matched (with possible item updates) → done\n if (mismatchCount === 0) return\n\n // Exactly 2 key mismatches — check if it's a swap\n if (mismatchCount === 2) {\n const e1 = entries[mismatch1]!\n const e2 = entries[mismatch2]!\n if (e1.key === opts.key(newItems[mismatch2]!) && e2.key === opts.key(newItems[mismatch1]!)) {\n // DOM swap\n const refI = e1.nodes[0]!\n const refAfterJ = e2.nodes[e2.nodes.length - 1]!.nextSibling\n for (const node of e2.nodes) parent.insertBefore(node, refI)\n for (const node of e1.nodes) parent.insertBefore(node, refAfterJ)\n entries[mismatch1] = e2\n entries[mismatch2] = e1\n updateEntry(e2, newItems[mismatch1]!, mismatch1)\n updateEntry(e1, newItems[mismatch2]!, mismatch2)\n return\n }\n }\n // Fall through to general path for 3+ mismatches or non-swap\n }\n\n // Fast path 5: full replace — no shared keys between old and new.\n // Skipped when opts.leave is set so departing items can animate individually.\n if (!hasLeave && oldLen > 0 && opts.key(newItems[0]!) !== entries[0]!.key) {\n const oldKeys = new Set<string | number>()\n for (const entry of entries) oldKeys.add(entry.key)\n let anyShared = false\n for (let i = 0; i < newLen; i++) {\n if (oldKeys.has(opts.key(newItems[i]!))) {\n anyShared = true\n break\n }\n }\n if (!anyShared) {\n if (report) {\n for (const entry of entries) collectNodes(report.leaving, entry.nodes)\n }\n // Bulk DOM removal using Range\n const range = ctx.dom.createRange()\n range.setStartAfter(anchor)\n const lastEntry = entries[entries.length - 1]!\n range.setEndAfter(lastEntry.nodes[lastEntry.nodes.length - 1]!)\n range.deleteContents()\n // Bulk dispose all old scopes\n const oldLifetimes: Lifetime[] = []\n for (let i = 0; i < entries.length; i++) {\n const s = entries[i]!.scope\n s.disposalCause = 'each-remove'\n oldLifetimes.push(s)\n }\n disposeLifetimesBulk(oldLifetimes)\n removeOrphanedChildren(parentLifetime)\n entries.length = 0\n // Build all new entries into a fragment\n const frag = ctx.dom.createDocumentFragment()\n const newlyAdded: Entry<T>[] = []\n for (let i = 0; i < newLen; i++) {\n const entry = buildEntry(newItems[i]!, i, opts, parentLifetime, ctx, state)\n entries.push(entry)\n newlyAdded.push(entry)\n for (const node of entry.nodes) frag.appendChild(node)\n }\n parent.insertBefore(frag, anchor.nextSibling)\n if (report) {\n for (const entry of newlyAdded) collectNodes(report.entering, entry.nodes)\n }\n for (const entry of newlyAdded) fireEnter(entry, opts)\n return\n }\n }\n\n // General path: keyed reconciliation\n const oldByKey = new Map<string | number, Entry<T>>()\n for (const entry of entries) {\n oldByKey.set(entry.key, entry)\n }\n\n const newEntries: Entry<T>[] = []\n const usedKeys = new Set<string | number>()\n const newlyAdded: Entry<T>[] = []\n\n for (let i = 0; i < newLen; i++) {\n const item = newItems[i]!\n const key = opts.key(item)\n usedKeys.add(key)\n\n const existing = oldByKey.get(key)\n if (existing) {\n updateEntry(existing, item, i)\n newEntries.push(existing)\n } else {\n const entry = buildEntry(item, i, opts, parentLifetime, ctx, state)\n newEntries.push(entry)\n newlyAdded.push(entry)\n }\n }\n\n // Remove entries not in the new list. Use bulk-detach pattern so\n // disposing K removals costs O(K+P) rather than O(K*P) where P is\n // parentLifetime.children.length (avoids K * indexOf+splice).\n let didBulkDetach = false\n for (const entry of entries) {\n if (!usedKeys.has(entry.key)) {\n if (report) collectNodes(report.leaving, entry.nodes)\n if (hasLeave) {\n removeEntry(entry, opts, leaving)\n } else {\n for (const node of entry.nodes) parent.removeChild(node)\n entry.scope.disposalCause = 'each-remove'\n disposeLifetime(entry.scope, true)\n didBulkDetach = true\n }\n }\n }\n if (didBulkDetach) removeOrphanedChildren(parentLifetime)\n\n // Reorder DOM\n const hasSurvivors = newEntries.some((e) => oldByKey.has(e.key))\n\n if (!hasSurvivors || !survivorsInOrder(entries, newEntries, usedKeys)) {\n // Full fragment rebuild — one reflow\n const frag = ctx.dom.createDocumentFragment()\n for (const entry of newEntries) {\n for (const node of entry.nodes) frag.appendChild(node)\n }\n parent.insertBefore(frag, anchor.nextSibling)\n } else {\n // Survivors in order — batch-insert new entries between survivors\n let frag: DocumentFragment | null = null\n let insertRef: ChildNode | null = anchor.nextSibling\n for (const entry of newEntries) {\n if (oldByKey.has(entry.key)) {\n // Flush any pending fragment before this survivor\n if (frag) {\n parent.insertBefore(frag, insertRef)\n frag = null\n }\n // Skip past survivor's nodes\n const lastNode = entry.nodes[entry.nodes.length - 1]\n insertRef = lastNode ? lastNode.nextSibling : insertRef\n } else {\n // Batch new entries into a fragment\n if (!frag) frag = ctx.dom.createDocumentFragment()\n for (const node of entry.nodes) frag.appendChild(node)\n }\n }\n if (frag) parent.insertBefore(frag, insertRef)\n }\n\n entries.length = newEntries.length\n for (let i = 0; i < newEntries.length; i++) entries[i] = newEntries[i]!\n\n if (report) {\n for (const entry of newlyAdded) collectNodes(report.entering, entry.nodes)\n }\n\n // Fire enter for newly-added entries (after DOM insertion)\n if (opts.enter) {\n for (const entry of newlyAdded) fireEnter(entry, opts)\n }\n}\n\nfunction updateEntry<T>(entry: Entry<T>, item: T, index: number): void {\n const changed = !Object.is(entry.item, item)\n entry.item = item\n entry.current = item\n entry.index = index\n // eachItemStable removed — unused\n // Directly run per-item updaters when item changed — bypasses Phase 2\n if (changed) {\n // Row factory fast path: shared update function, zero closures\n const rowUpd = (entry as unknown as Record<string, unknown>).__rowUpdate as\n | ((e: Entry<T>) => void)\n | undefined\n if (rowUpd) {\n rowUpd(entry)\n } else {\n // Closure-based fallback\n const updaters = entry.updaters.length > 0 ? entry.updaters : entry.scope.itemUpdaters\n for (let i = 0; i < updaters.length; i++) {\n updaters[i]!()\n }\n }\n }\n}\n\nfunction isAppendOnly<S, T>(entries: Entry<T>[], newItems: T[], opts: EachOptions<S, T>): boolean {\n for (let i = 0; i < entries.length; i++) {\n if (entries[i]!.key !== opts.key(newItems[i]!)) return false\n }\n return true\n}\n\nfunction survivorsInOrder<T>(\n oldEntries: Entry<T>[],\n newEntries: Entry<T>[],\n usedKeys: Set<string | number>,\n): boolean {\n // Build old-index map for survivors\n const oldIndexMap = new Map<string | number, number>()\n for (let i = 0; i < oldEntries.length; i++) {\n if (usedKeys.has(oldEntries[i]!.key)) {\n oldIndexMap.set(oldEntries[i]!.key, i)\n }\n }\n // Check that survivors appear in increasing old-index order in newEntries\n let maxOldIndex = -1\n for (const entry of newEntries) {\n const oldIdx = oldIndexMap.get(entry.key)\n if (oldIdx === undefined) continue // new entry, skip\n if (oldIdx < maxOldIndex) return false\n maxOldIndex = oldIdx\n }\n return true\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"render-context.d.ts","sourceRoot":"","sources":["../src/render-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,QAAQ,CAAA;IACtB,KAAK,EAAE,OAAO,CAAA;IACd,WAAW,EAAE,OAAO,EAAE,CAAA;IACtB,gBAAgB,EAAE,eAAe,EAAE,CAAA;IACnC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;IAC7B;;;;;;OAMG;IACH,GAAG,EAAE,MAAM,CAAA;CAMZ;AAID,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAEzD;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED,wBAAgB,gBAAgB,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,aAAa,CAgBtE"}
1
+ {"version":3,"file":"render-context.d.ts","sourceRoot":"","sources":["../src/render-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,QAAQ,CAAA;IACtB,KAAK,EAAE,OAAO,CAAA;IACd,WAAW,EAAE,OAAO,EAAE,CAAA;IACtB,gBAAgB,EAAE,eAAe,EAAE,CAAA;IACnC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;IAC7B;;;;;;OAMG;IACH,GAAG,EAAE,MAAM,CAAA;CAMZ;AAID,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAEzD;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED,wBAAgB,gBAAgB,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,aAAa,CAmCtE"}
@@ -8,6 +8,23 @@ export function clearRenderContext() {
8
8
  export function getRenderContext(primitiveName) {
9
9
  if (!currentContext) {
10
10
  const name = primitiveName ? `${primitiveName}()` : 'primitives';
11
+ // `sample()` is specifically the one users reach for from adapter
12
+ // send wrappers / event handlers / async callbacks expecting it to
13
+ // be "imperative and safe." It isn't — it's a view-primitive that
14
+ // reads the render-time state snapshot, and the context is cleared
15
+ // as soon as view() returns. Point at the sanctioned escape hatch
16
+ // in the thrown message so the caller doesn't have to dig.
17
+ const sampleGuidance = primitiveName === 'sample'
18
+ ? '\n\nFor the "read state inside a callback / handler" case: use ' +
19
+ 'AppHandle.getState() instead. It is safe to call from anywhere ' +
20
+ '(event handlers, adapter send wrappers, async callbacks, timers).\n' +
21
+ 'Example:\n' +
22
+ ' const handle = mountApp(root, App)\n' +
23
+ " el.addEventListener('click', () => {\n" +
24
+ ' const { count } = handle.getState() as AppState\n' +
25
+ " if (count > 0) handle.send({ type: 'tick' })\n" +
26
+ ' })'
27
+ : '';
11
28
  throw new Error(`[LLui] ${name} can only be called inside a component's view() function. ` +
12
29
  `It was called outside a render context. Common causes:\n` +
13
30
  ` 1. Calling a primitive at module scope instead of inside view().\n` +
@@ -16,7 +33,8 @@ export function getRenderContext(primitiveName) {
16
33
  `from inside the component's view callback so their result can be spread ` +
17
34
  `into the returned node tree.\n` +
18
35
  ` 3. Calling a primitive from a setTimeout / Promise / event handler — ` +
19
- `the render context only persists during the synchronous view() call.`);
36
+ `the render context only persists during the synchronous view() call.` +
37
+ sampleGuidance);
20
38
  }
21
39
  return currentContext;
22
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"render-context.js","sourceRoot":"","sources":["../src/render-context.ts"],"names":[],"mappings":"AA2BA,IAAI,cAAc,GAAyB,IAAI,CAAA;AAE/C,MAAM,UAAU,gBAAgB,CAAC,GAAkB;IACjD,cAAc,GAAG,GAAG,CAAA;AACtB,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,cAAc,GAAG,IAAI,CAAA;AACvB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,aAAsB;IACrD,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,IAAI,CAAC,CAAC,CAAC,YAAY,CAAA;QAChE,MAAM,IAAI,KAAK,CACb,UAAU,IAAI,4DAA4D;YACxE,0DAA0D;YAC1D,sEAAsE;YACtE,yEAAyE;YACzE,0EAA0E;YAC1E,0EAA0E;YAC1E,gCAAgC;YAChC,yEAAyE;YACzE,sEAAsE,CACzE,CAAA;IACH,CAAC;IACD,OAAO,cAAc,CAAA;AACvB,CAAC","sourcesContent":["import type { Lifetime, Binding } from './types.js'\nimport type { StructuralBlock } from './structural.js'\nimport type { ComponentInstance } from './update-loop.js'\nimport type { DomEnv } from './dom-env.js'\n\nexport interface RenderContext {\n rootLifetime: Lifetime\n state: unknown\n allBindings: Binding[]\n structuralBlocks: StructuralBlock[]\n container?: Element\n send?: (msg: unknown) => void\n /**\n * The DOM implementation backing this render pass. Seeded by\n * `mountApp` / `hydrateApp` / `renderToString` and threaded through\n * every nested primitive via context spread. Primitives construct\n * DOM through `ctx.dom.createElement(...)` etc. instead of reaching\n * for `globalThis.document`.\n */\n dom: DomEnv\n /** @internal dev-only — the owning ComponentInstance. Set by mount /\n * hydrate / child to let primitives (currently `each`) emit tracker\n * data to `inst._eachDiffLog`. Nested contexts pass through via\n * spread (e.g. `{ ...ctx, rootLifetime }`). Undefined outside dev. */\n instance?: ComponentInstance\n}\n\nlet currentContext: RenderContext | null = null\n\nexport function setRenderContext(ctx: RenderContext): void {\n currentContext = ctx\n}\n\nexport function clearRenderContext(): void {\n currentContext = null\n}\n\nexport function getRenderContext(primitiveName?: string): RenderContext {\n if (!currentContext) {\n const name = primitiveName ? `${primitiveName}()` : 'primitives'\n throw new Error(\n `[LLui] ${name} can only be called inside a component's view() function. ` +\n `It was called outside a render context. Common causes:\\n` +\n ` 1. Calling a primitive at module scope instead of inside view().\\n` +\n ` 2. Calling an overlay helper (dialog.overlay, popover.overlay, …) at ` +\n `module scope — these internally use show()/branch() and must be invoked ` +\n `from inside the component's view callback so their result can be spread ` +\n `into the returned node tree.\\n` +\n ` 3. Calling a primitive from a setTimeout / Promise / event handler — ` +\n `the render context only persists during the synchronous view() call.`,\n )\n }\n return currentContext\n}\n"]}
1
+ {"version":3,"file":"render-context.js","sourceRoot":"","sources":["../src/render-context.ts"],"names":[],"mappings":"AA2BA,IAAI,cAAc,GAAyB,IAAI,CAAA;AAE/C,MAAM,UAAU,gBAAgB,CAAC,GAAkB;IACjD,cAAc,GAAG,GAAG,CAAA;AACtB,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,cAAc,GAAG,IAAI,CAAA;AACvB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,aAAsB;IACrD,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,IAAI,CAAC,CAAC,CAAC,YAAY,CAAA;QAChE,kEAAkE;QAClE,mEAAmE;QACnE,kEAAkE;QAClE,mEAAmE;QACnE,kEAAkE;QAClE,2DAA2D;QAC3D,MAAM,cAAc,GAClB,aAAa,KAAK,QAAQ;YACxB,CAAC,CAAC,iEAAiE;gBACjE,iEAAiE;gBACjE,qEAAqE;gBACrE,YAAY;gBACZ,wCAAwC;gBACxC,0CAA0C;gBAC1C,uDAAuD;gBACvD,oDAAoD;gBACpD,MAAM;YACR,CAAC,CAAC,EAAE,CAAA;QACR,MAAM,IAAI,KAAK,CACb,UAAU,IAAI,4DAA4D;YACxE,0DAA0D;YAC1D,sEAAsE;YACtE,yEAAyE;YACzE,0EAA0E;YAC1E,0EAA0E;YAC1E,gCAAgC;YAChC,yEAAyE;YACzE,sEAAsE;YACtE,cAAc,CACjB,CAAA;IACH,CAAC;IACD,OAAO,cAAc,CAAA;AACvB,CAAC","sourcesContent":["import type { Lifetime, Binding } from './types.js'\nimport type { StructuralBlock } from './structural.js'\nimport type { ComponentInstance } from './update-loop.js'\nimport type { DomEnv } from './dom-env.js'\n\nexport interface RenderContext {\n rootLifetime: Lifetime\n state: unknown\n allBindings: Binding[]\n structuralBlocks: StructuralBlock[]\n container?: Element\n send?: (msg: unknown) => void\n /**\n * The DOM implementation backing this render pass. Seeded by\n * `mountApp` / `hydrateApp` / `renderToString` and threaded through\n * every nested primitive via context spread. Primitives construct\n * DOM through `ctx.dom.createElement(...)` etc. instead of reaching\n * for `globalThis.document`.\n */\n dom: DomEnv\n /** @internal dev-only — the owning ComponentInstance. Set by mount /\n * hydrate / child to let primitives (currently `each`) emit tracker\n * data to `inst._eachDiffLog`. Nested contexts pass through via\n * spread (e.g. `{ ...ctx, rootLifetime }`). Undefined outside dev. */\n instance?: ComponentInstance\n}\n\nlet currentContext: RenderContext | null = null\n\nexport function setRenderContext(ctx: RenderContext): void {\n currentContext = ctx\n}\n\nexport function clearRenderContext(): void {\n currentContext = null\n}\n\nexport function getRenderContext(primitiveName?: string): RenderContext {\n if (!currentContext) {\n const name = primitiveName ? `${primitiveName}()` : 'primitives'\n // `sample()` is specifically the one users reach for from adapter\n // send wrappers / event handlers / async callbacks expecting it to\n // be \"imperative and safe.\" It isn't — it's a view-primitive that\n // reads the render-time state snapshot, and the context is cleared\n // as soon as view() returns. Point at the sanctioned escape hatch\n // in the thrown message so the caller doesn't have to dig.\n const sampleGuidance =\n primitiveName === 'sample'\n ? '\\n\\nFor the \"read state inside a callback / handler\" case: use ' +\n 'AppHandle.getState() instead. It is safe to call from anywhere ' +\n '(event handlers, adapter send wrappers, async callbacks, timers).\\n' +\n 'Example:\\n' +\n ' const handle = mountApp(root, App)\\n' +\n \" el.addEventListener('click', () => {\\n\" +\n ' const { count } = handle.getState() as AppState\\n' +\n \" if (count > 0) handle.send({ type: 'tick' })\\n\" +\n ' })'\n : ''\n throw new Error(\n `[LLui] ${name} can only be called inside a component's view() function. ` +\n `It was called outside a render context. Common causes:\\n` +\n ` 1. Calling a primitive at module scope instead of inside view().\\n` +\n ` 2. Calling an overlay helper (dialog.overlay, popover.overlay, …) at ` +\n `module scope — these internally use show()/branch() and must be invoked ` +\n `from inside the component's view callback so their result can be spread ` +\n `into the returned node tree.\\n` +\n ` 3. Calling a primitive from a setTimeout / Promise / event handler — ` +\n `the render context only persists during the synchronous view() call.` +\n sampleGuidance,\n )\n }\n return currentContext\n}\n"]}
package/dist/types.d.ts CHANGED
@@ -127,6 +127,32 @@ export interface AppHandle {
127
127
  * normal update loop. Calling `send` after `dispose` is a no-op.
128
128
  */
129
129
  send(msg: unknown): void;
130
+ /**
131
+ * Read the current state snapshot. Safe to call from anywhere —
132
+ * event handlers, async callbacks, adapter `send` wrappers, or any
133
+ * imperative context where the render context is not live.
134
+ *
135
+ * Unlike `sample()` (a view primitive that requires an active
136
+ * render context and throws outside of `view()`), `getState` is
137
+ * the sanctioned escape hatch for "I need to know the current
138
+ * state to decide what to dispatch." Typical shape:
139
+ *
140
+ * ```ts
141
+ * const handle = mountApp(root, MyApp)
142
+ * container.addEventListener('drop', () => {
143
+ * const { mode } = handle.getState() as AppState
144
+ * if (mode === 'drag') handle.send({ type: 'commit' })
145
+ * })
146
+ * ```
147
+ *
148
+ * Throws after `dispose()` — stale reads are silent bugs; a thrown
149
+ * error pinpoints the callsite that forgot to detach.
150
+ *
151
+ * The return type is `unknown` because `AppHandle` is state-type
152
+ * erased at this boundary; cast to your app's state type at the
153
+ * call site.
154
+ */
155
+ getState(): unknown;
130
156
  }
131
157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E,QAAQ,CAAC;YAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAA;SAAE,KAAK,IAAI;KAC5F,CAAA;IACL,OAAO,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAA;IACrC,SAAS,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAA;CAC7D;AAED,MAAM,WAAW,YAAY,CAAC,CAAC,EAAE,MAAM;IAMrC,GAAG,EAAE,eAAe,CAAA;IACpB,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACxC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,CAAA;CACxC"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,qEAAqE","sourcesContent":["// ── Component Definition ──────────────────────────────────────────\n\nimport type { View } from './view-helpers.js'\nimport type { StructuralBlock } from './structural.js'\nimport type { ComponentInstance } from './update-loop.js'\nimport type { DisposerEvent } from './tracking/disposer-log.js'\n\nexport interface ComponentDef<S, M, E = never, D = void> {\n name: string\n init: (data: D) => [S, E[]]\n update: (state: S, msg: M) => [S, E[]]\n view: (h: View<S, M>) => Node[]\n onEffect?: (ctx: { effect: E; send: Send<M>; signal: AbortSignal }) => void\n\n // Level 2 composition\n propsMsg?: (props: Record<string, unknown>) => M\n receives?: Record<string, (params: unknown) => M>\n\n /** @internal Compiler-injected */\n __dirty?: (oldState: S, newState: S) => number | [number, number]\n /** @internal Compiler-injected */\n __renderToString?: (state: S) => string\n /** @internal Compiler-injected */\n __msgSchema?: object\n /** @internal Compiler-injected — maps top-level state field → dirty-mask bit(s) */\n __maskLegend?: Record<string, number>\n /** @internal Compiler-injected — source-file location of the component() call */\n __componentMeta?: { file: string; line: number }\n /** @internal Compiler-injected — shape of the State type (for introspection) */\n __stateSchema?: object\n /** @internal Compiler-injected — Effect union schema (for introspection) */\n __effectSchema?: object\n /** @internal Compiler-injected — replaces generic Phase 1 + Phase 2 loop */\n __update?: (\n state: S,\n dirty: number,\n bindings: Binding[],\n blocks: StructuralBlock[],\n bindingsBeforePhase1: number,\n ) => void\n /** @internal Compiler-injected — per-message-type specialized handlers.\n * Bypass the entire processMessages pipeline for single-message updates. */\n __handlers?: Record<string, (inst: object, msg: unknown) => [S, E[]]>\n}\n\nexport type Send<M> = (msg: M) => void\n\n/**\n * Type-erased component definition for use at module boundaries where\n * the consumer's `S`, `M`, `E` are internal and invisible to the caller.\n *\n * Why this exists: `ComponentDef<S, M, E, D>` uses property syntax for\n * its callable fields (`init: (data: D) => ...`), and TypeScript\n * checks property syntax with strict (contravariant) variance. That's\n * the right call for user-facing type safety when authoring a\n * component (a narrower `Msg` type can't accidentally satisfy the\n * `update`'s param), but it means `ComponentDef<MyState, MyMsg, MyEffect, MyData>`\n * is NOT structurally assignable to `ComponentDef<unknown, unknown, unknown, unknown>`\n * — the `init: (data: MyData) => ...` field is contravariant in `MyData`,\n * so widening to `unknown` is rejected.\n *\n * `AnyComponentDef` (and `LazyDef<D>` below) declare the same fields\n * using **method syntax** (`init(data: D): ...`), which TypeScript\n * checks bivariantly. Concrete `ComponentDef<S, M, E, D>` assigns into\n * these structurally without any `widenDef` helper at the callsite.\n *\n * Used by every API that accepts an opaque component definition at a\n * module boundary:\n *\n * - `child({ def })`\n * - `lazy({ loader })` — returns `LazyDef<D>` so the loader's `D` survives\n * - `createOnRenderClient({ Layout })` (from `@llui/vike`)\n * - `createOnRenderHtml({ Layout })` (from `@llui/vike`)\n *\n * The `D` parameter is `unknown` here — `child()` doesn't pass init\n * data through, and `Layout` callers pass route-supplied data whose\n * shape is unknown at the type-erased boundary. Use `LazyDef<D>` when\n * you need to preserve the init data shape (the lazy loader case).\n */\nexport interface AnyComponentDef {\n name: string\n init(data: unknown): [unknown, unknown[]]\n update(state: unknown, msg: unknown): [unknown, unknown[]]\n view(h: unknown): Node[]\n onEffect?: unknown\n propsMsg?: unknown\n receives?: unknown\n __dirty?: unknown\n __renderToString?: unknown\n __msgSchema?: unknown\n __maskLegend?: unknown\n __componentMeta?: unknown\n __stateSchema?: unknown\n __effectSchema?: unknown\n __update?: unknown\n __handlers?: unknown\n}\n\n/**\n * Type-erased component definition for use at module boundaries where the\n * loaded component's S, M, E are internal and invisible to the caller.\n * Only `D` (init data) survives because the caller provides it.\n *\n * `ComponentDef<S, M, E, D>` is structurally assignable to `LazyDef<D>`\n * for any S, M, E — `view: (h: unknown) => Node[]` accepts any View via\n * contravariance, and all other fields widen to `unknown` return types.\n *\n * Used by `lazy()` as the loader's return type. Use `AnyComponentDef`\n * (above) when D is also opaque — most other adapter-layer APIs.\n */\nexport interface LazyDef<D = void> {\n name: string\n // Method syntax — TypeScript checks methods bivariantly, so\n // ComponentDef<S, M, E, D>'s concrete (state: S, msg: M) => ...\n // assigns here even though S/M ≠ unknown. Property syntax would\n // be contravariant and reject the assignment.\n init(data: D): [unknown, unknown[]]\n update(state: unknown, msg: unknown): [unknown, unknown[]]\n view(h: unknown): Node[]\n onEffect?: unknown\n propsMsg?: unknown\n receives?: unknown\n __dirty?: unknown\n __renderToString?: unknown\n __msgSchema?: unknown\n __maskLegend?: unknown\n __componentMeta?: unknown\n __stateSchema?: unknown\n __effectSchema?: unknown\n __update?: unknown\n __handlers?: unknown\n}\n\n/**\n * Maps a value shape to a reactive-props shape: every field becomes an accessor\n * `(s: S) => V`. Use for Level-1 view function signatures.\n *\n * ```ts\n * type ToolbarData = { tools: Tool[]; theme: 'light' | 'dark' }\n *\n * export function toolbar<S>(props: Props<ToolbarData, S>, send: Send<Msg>) {\n * return [div({ class: props.theme }, [each({ items: props.tools, ... })])]\n * }\n *\n * // Caller — TypeScript enforces per-field accessors; passing a raw value errors:\n * toolbar({ tools: (s: State) => s.tools, theme: (s) => s.theme }, send)\n * ```\n */\nexport type Props<T, S> = {\n [K in keyof T]: (s: S) => T[K]\n}\n\n// ── App Handle ────────────────────────────────────────────────────\n\nexport interface AppHandle {\n dispose(): void\n flush(): void\n /**\n * Dispatch a message into the mounted instance from outside its\n * normal view-bound `send` channel. Useful for adapter layers that\n * need to push updates into a long-lived instance — e.g.\n * `@llui/vike`'s persistent-layout chain pushes layout-data updates\n * into surviving layer instances on client navigation when their\n * `propsMsg` translates the new data into a state-update message.\n *\n * Messages are queued through the same path as `view`-side `send`\n * calls — they batch into the next microtask and process via the\n * normal update loop. Calling `send` after `dispose` is a no-op.\n */\n send(msg: unknown): void\n}\n\n// ── Lifetime ─────────────────────────────────────────────────────────\n\nexport interface Lifetime {\n id: number\n parent: Lifetime | null\n children: Lifetime[]\n disposers: Array<() => void>\n bindings: Binding[]\n /** Per-item updaters — called directly by each() when item changes, bypassing Phase 2 */\n itemUpdaters: Array<() => void>\n /**\n * @internal dev-only back-reference to the owning ComponentInstance.\n * Populated on the root scope by `installDevTools` so `disposeLifetime`\n * can walk up the scope chain and emit DisposerEvents into the\n * instance's `_disposerLog`. Undefined in production.\n */\n instance?: ComponentInstance\n /**\n * @internal dev-only cause hint. Structural primitives (branch, each,\n * child, mountApp teardown) set this field immediately before calling\n * `disposeLifetime`; the dispose path reads it once to stamp the emitted\n * DisposerEvent. Left undefined, `disposeLifetime` falls back to\n * `'component-unmount'`. Undefined in production.\n */\n disposalCause?: DisposerEvent['cause']\n /** @internal dev-only — populated by structural primitives for scope-tree classification */\n _kind?: 'root' | 'show' | 'each' | 'branch' | 'scope' | 'child' | 'portal' | 'foreign'\n}\n\nexport interface LifetimeNode {\n scopeId: string\n kind: 'root' | 'show' | 'each' | 'branch' | 'scope' | 'child' | 'portal' | 'foreign'\n active: boolean\n children: LifetimeNode[]\n}\n\n// ── Binding ───────────────────────────────────────────────────────\n\n/**\n * Binding output kinds.\n *\n * `'text' | 'prop' | 'attr' | 'class' | 'style'` write their accessor's\n * return value to the DOM. `'effect'` is a side-effect-only watcher:\n * the accessor is invoked every Phase 2 tick its mask is hit, but its\n * return value is discarded and `applyBinding` is a no-op. Used by\n * `child()` to fire the prop-diff/propsMsg cascade on parent updates\n * without the cost of stringifying the returned props bag onto a\n * detached anchor node every render.\n */\nexport type BindingKind = 'text' | 'prop' | 'attr' | 'class' | 'style' | 'effect'\n\nexport interface Binding {\n mask: number\n accessor: (state: unknown) => unknown\n lastValue: unknown\n kind: BindingKind\n node: Node\n key?: string\n ownerLifetime: Lifetime\n perItem: boolean\n dead: boolean\n}\n\n// ── Structural Primitives ─────────────────────────────────────────\n\nexport interface TransitionOptions {\n enter?: (nodes: Node[]) => void | Promise<void>\n leave?: (nodes: Node[]) => void | Promise<void>\n onTransition?: (ctx: { entering: Node[]; leaving: Node[]; parent: Node }) => void | Promise<void>\n}\n\ninterface BranchOptionsBase extends TransitionOptions {\n /**\n * @internal Set by `show()` / `scope()` sugar when delegating to\n * `branch()`, so the dev-only disposer log can report `'show-hide'` /\n * `'scope-rebuild'` instead of the default `'branch-swap'` for the\n * leaving arm. User code should not set this directly.\n */\n __disposalCause?: DisposerEvent['cause']\n /** @internal Compiler-injected mask of paths read by `on`. */\n __mask?: number\n}\n\n/**\n * All cases covered by `cases` — no default allowed (would be dead code).\n */\ntype BranchOptionsExhaustive<S, M, K extends string> = BranchOptionsBase & {\n on: (s: S) => K\n cases: { [P in K]: (h: View<S, M>) => Node[] }\n default?: never\n}\n\n/**\n * `cases` may cover some but not all keys; `default` handles the rest.\n */\ntype BranchOptionsNonExhaustive<S, M, K extends string> = BranchOptionsBase & {\n on: (s: S) => K\n cases?: { [P in K]?: (h: View<S, M>) => Node[] }\n default: (h: View<S, M>) => Node[]\n}\n\n/**\n * `on` returns a wide `string` — exhaustiveness cannot be verified at\n * compile time (the key domain is infinite). Lenient: `default` is\n * optional so existing call sites that predate exhaustiveness typing\n * continue to compile. Authors who want the gate opt in by narrowing\n * `on`'s return type to a literal union.\n */\ntype BranchOptionsWide<S, M> = BranchOptionsBase & {\n on: (s: S) => string\n cases?: Record<string, (h: View<S, M>) => Node[]>\n default?: (h: View<S, M>) => Node[]\n}\n\n/**\n * Options for `branch()`.\n *\n * When `on` returns a literal string union (e.g. `'idle' | 'loading'\n * | 'done'`), TypeScript enforces exhaustiveness: either every union\n * member has a case (and `default` is disallowed as unreachable), or\n * `default` is required to cover the remainder. When `on` returns a\n * wide `string`, `default` stays optional — exhaustiveness isn't\n * meaningful for an unbounded domain.\n *\n * `cases` is optional when `default` is present; `branch({ on, default })`\n * is the canonical dynamic-rebuild shape — `scope()` sugar wraps\n * exactly this form.\n */\nexport type BranchOptions<S, M = unknown, K extends string = string> = string extends K\n ? BranchOptionsWide<S, M>\n : BranchOptionsExhaustive<S, M, K> | BranchOptionsNonExhaustive<S, M, K>\n\nexport interface ShowOptions<S, M = unknown> extends TransitionOptions {\n when: (s: S) => boolean\n render: (h: View<S, M>) => Node[]\n fallback?: (h: View<S, M>) => Node[]\n}\n\n/**\n * Options for `scope()` — rebuilds a subtree when `on(state)` changes.\n *\n * Sugar over `branch({ on, cases: {}, default: render, __disposalCause: 'scope-rebuild' })`.\n * Use when the key is dynamic (e.g. an epoch counter bumped from the\n * outside) and you want a fresh arm — fresh lifetime, fresh bindings —\n * each time it changes. Combine with `sample()` inside `render` for a\n * one-shot current-state read.\n */\nexport interface ScopeOptions<S, M = unknown> extends TransitionOptions {\n on: (s: S) => string\n render: (h: View<S, M>) => Node[]\n /** @internal Compiler-injected mask of paths read by `on`. */\n __mask?: number\n}\n\n/**\n * Options for `each()`. The inherited `enter` / `leave` callbacks fire **per item**:\n * `enter(nodes)` runs after an item's DOM is inserted (including initial mount);\n * `leave(nodes)` runs before an item's DOM is removed and may return a Promise\n * to hold the DOM until the animation resolves. Setting `leave` disables the\n * bulk-clear / full-replace fast paths.\n */\n/**\n * Per-item accessor. Two access forms:\n * - `item.field` — shorthand, returns accessor for `item.current[field]`\n * - `item(t => t.expr)` — computed expressions\n *\n * In both cases the returned value is a `() => V` accessor.\n * Invoke it (`item.field()`) to read the current value imperatively.\n */\nexport type ItemAccessor<T> = {\n <R>(selector: (t: T) => R): () => R\n} & {\n [K in keyof T]-?: () => T[K]\n} & {\n /**\n * Read the whole current item. Needed when T is a primitive (where the\n * field-map branch collapses to method names like `toString`) or when\n * you want to sample the entire record rather than a single field.\n *\n * Shadows any literal `current` field on T — if T has such a field,\n * use `item(r => r.current)` to disambiguate.\n */\n current(): T\n}\n\nexport interface EachOptions<S, T, M = unknown> extends TransitionOptions {\n items: (s: S) => T[]\n key: (item: T) => string | number\n render: (opts: {\n send: Send<M>\n item: ItemAccessor<T>\n /**\n * Plain (non-Proxy) accessor factory. Compiler-output path; avoid in user code\n * (use `item.field` / `item(fn)` — more ergonomic and bypasses Proxy when compiled).\n */\n acc: <R>(selector: (t: T) => R) => () => R\n index: () => number\n /**\n * The component's View bag (`h.text`, `h.show`, `h.branch`,\n * `h.scope`, `h.sample`, …). Each-render callers used to reach\n * for the top-level imports; the bag form is symmetric with how\n * `branch.cases[k]`, `show.render`, and `scope.render` receive it.\n * Both still work — destructure whichever is more convenient.\n */\n h: View<S, M>\n /** @internal Compiler-injected — entry reference for row factory */\n entry?: Record<string, unknown>\n }) => Node[]\n}\n\nexport interface PortalOptions {\n target: HTMLElement | string\n render: () => Node[]\n}\n\nexport interface ForeignOptions<S, M, T extends Record<string, unknown>, Instance> {\n /**\n * Construct the imperative instance. Can be async — return a\n * `Promise<Instance>` to defer construction until e.g. a dynamic\n * `import()` resolves. While the promise is pending:\n *\n * - The container element is in the DOM immediately (so layout\n * doesn't shift when the instance arrives).\n * - `sync` is NOT called. State changes are tracked by the\n * primitive and the latest props are applied as the initial\n * sync right after the promise resolves.\n * - If the owning scope disposes before the promise resolves,\n * `destroy(instance)` runs on resolution — no matter how long\n * the promise takes.\n */\n mount: (ctx: { container: HTMLElement; send: Send<M> }) => Instance | Promise<Instance>\n props: (s: S) => T\n sync:\n | ((ctx: { instance: Instance; props: T; prev: T | undefined }) => void)\n | {\n [K in keyof T]?: (ctx: { instance: Instance; value: T[K]; prev: T[K] | undefined }) => void\n }\n destroy: (instance: Instance) => void\n container?: { tag?: string; attrs?: Record<string, string> }\n}\n\nexport interface ChildOptions<S, ChildM> {\n // Type-erased via AnyComponentDef so callers can pass any concrete\n // ComponentDef<S, M, E, D> without a widening helper. The runtime\n // narrows the message shape via the user-supplied `onMsg` callback,\n // which keeps `ChildM` typed at this boundary even though the def\n // itself is opaque.\n def: AnyComponentDef\n key: string | number\n props: (s: S) => Record<string, unknown>\n onMsg?: (msg: ChildM) => unknown | null\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,qEAAqE","sourcesContent":["// ── Component Definition ──────────────────────────────────────────\n\nimport type { View } from './view-helpers.js'\nimport type { StructuralBlock } from './structural.js'\nimport type { ComponentInstance } from './update-loop.js'\nimport type { DisposerEvent } from './tracking/disposer-log.js'\n\nexport interface ComponentDef<S, M, E = never, D = void> {\n name: string\n init: (data: D) => [S, E[]]\n update: (state: S, msg: M) => [S, E[]]\n view: (h: View<S, M>) => Node[]\n onEffect?: (ctx: { effect: E; send: Send<M>; signal: AbortSignal }) => void\n\n // Level 2 composition\n propsMsg?: (props: Record<string, unknown>) => M\n receives?: Record<string, (params: unknown) => M>\n\n /** @internal Compiler-injected */\n __dirty?: (oldState: S, newState: S) => number | [number, number]\n /** @internal Compiler-injected */\n __renderToString?: (state: S) => string\n /** @internal Compiler-injected */\n __msgSchema?: object\n /** @internal Compiler-injected — maps top-level state field → dirty-mask bit(s) */\n __maskLegend?: Record<string, number>\n /** @internal Compiler-injected — source-file location of the component() call */\n __componentMeta?: { file: string; line: number }\n /** @internal Compiler-injected — shape of the State type (for introspection) */\n __stateSchema?: object\n /** @internal Compiler-injected — Effect union schema (for introspection) */\n __effectSchema?: object\n /** @internal Compiler-injected — replaces generic Phase 1 + Phase 2 loop */\n __update?: (\n state: S,\n dirty: number,\n bindings: Binding[],\n blocks: StructuralBlock[],\n bindingsBeforePhase1: number,\n ) => void\n /** @internal Compiler-injected — per-message-type specialized handlers.\n * Bypass the entire processMessages pipeline for single-message updates. */\n __handlers?: Record<string, (inst: object, msg: unknown) => [S, E[]]>\n}\n\nexport type Send<M> = (msg: M) => void\n\n/**\n * Type-erased component definition for use at module boundaries where\n * the consumer's `S`, `M`, `E` are internal and invisible to the caller.\n *\n * Why this exists: `ComponentDef<S, M, E, D>` uses property syntax for\n * its callable fields (`init: (data: D) => ...`), and TypeScript\n * checks property syntax with strict (contravariant) variance. That's\n * the right call for user-facing type safety when authoring a\n * component (a narrower `Msg` type can't accidentally satisfy the\n * `update`'s param), but it means `ComponentDef<MyState, MyMsg, MyEffect, MyData>`\n * is NOT structurally assignable to `ComponentDef<unknown, unknown, unknown, unknown>`\n * — the `init: (data: MyData) => ...` field is contravariant in `MyData`,\n * so widening to `unknown` is rejected.\n *\n * `AnyComponentDef` (and `LazyDef<D>` below) declare the same fields\n * using **method syntax** (`init(data: D): ...`), which TypeScript\n * checks bivariantly. Concrete `ComponentDef<S, M, E, D>` assigns into\n * these structurally without any `widenDef` helper at the callsite.\n *\n * Used by every API that accepts an opaque component definition at a\n * module boundary:\n *\n * - `child({ def })`\n * - `lazy({ loader })` — returns `LazyDef<D>` so the loader's `D` survives\n * - `createOnRenderClient({ Layout })` (from `@llui/vike`)\n * - `createOnRenderHtml({ Layout })` (from `@llui/vike`)\n *\n * The `D` parameter is `unknown` here — `child()` doesn't pass init\n * data through, and `Layout` callers pass route-supplied data whose\n * shape is unknown at the type-erased boundary. Use `LazyDef<D>` when\n * you need to preserve the init data shape (the lazy loader case).\n */\nexport interface AnyComponentDef {\n name: string\n init(data: unknown): [unknown, unknown[]]\n update(state: unknown, msg: unknown): [unknown, unknown[]]\n view(h: unknown): Node[]\n onEffect?: unknown\n propsMsg?: unknown\n receives?: unknown\n __dirty?: unknown\n __renderToString?: unknown\n __msgSchema?: unknown\n __maskLegend?: unknown\n __componentMeta?: unknown\n __stateSchema?: unknown\n __effectSchema?: unknown\n __update?: unknown\n __handlers?: unknown\n}\n\n/**\n * Type-erased component definition for use at module boundaries where the\n * loaded component's S, M, E are internal and invisible to the caller.\n * Only `D` (init data) survives because the caller provides it.\n *\n * `ComponentDef<S, M, E, D>` is structurally assignable to `LazyDef<D>`\n * for any S, M, E — `view: (h: unknown) => Node[]` accepts any View via\n * contravariance, and all other fields widen to `unknown` return types.\n *\n * Used by `lazy()` as the loader's return type. Use `AnyComponentDef`\n * (above) when D is also opaque — most other adapter-layer APIs.\n */\nexport interface LazyDef<D = void> {\n name: string\n // Method syntax — TypeScript checks methods bivariantly, so\n // ComponentDef<S, M, E, D>'s concrete (state: S, msg: M) => ...\n // assigns here even though S/M ≠ unknown. Property syntax would\n // be contravariant and reject the assignment.\n init(data: D): [unknown, unknown[]]\n update(state: unknown, msg: unknown): [unknown, unknown[]]\n view(h: unknown): Node[]\n onEffect?: unknown\n propsMsg?: unknown\n receives?: unknown\n __dirty?: unknown\n __renderToString?: unknown\n __msgSchema?: unknown\n __maskLegend?: unknown\n __componentMeta?: unknown\n __stateSchema?: unknown\n __effectSchema?: unknown\n __update?: unknown\n __handlers?: unknown\n}\n\n/**\n * Maps a value shape to a reactive-props shape: every field becomes an accessor\n * `(s: S) => V`. Use for Level-1 view function signatures.\n *\n * ```ts\n * type ToolbarData = { tools: Tool[]; theme: 'light' | 'dark' }\n *\n * export function toolbar<S>(props: Props<ToolbarData, S>, send: Send<Msg>) {\n * return [div({ class: props.theme }, [each({ items: props.tools, ... })])]\n * }\n *\n * // Caller — TypeScript enforces per-field accessors; passing a raw value errors:\n * toolbar({ tools: (s: State) => s.tools, theme: (s) => s.theme }, send)\n * ```\n */\nexport type Props<T, S> = {\n [K in keyof T]: (s: S) => T[K]\n}\n\n// ── App Handle ────────────────────────────────────────────────────\n\nexport interface AppHandle {\n dispose(): void\n flush(): void\n /**\n * Dispatch a message into the mounted instance from outside its\n * normal view-bound `send` channel. Useful for adapter layers that\n * need to push updates into a long-lived instance — e.g.\n * `@llui/vike`'s persistent-layout chain pushes layout-data updates\n * into surviving layer instances on client navigation when their\n * `propsMsg` translates the new data into a state-update message.\n *\n * Messages are queued through the same path as `view`-side `send`\n * calls — they batch into the next microtask and process via the\n * normal update loop. Calling `send` after `dispose` is a no-op.\n */\n send(msg: unknown): void\n /**\n * Read the current state snapshot. Safe to call from anywhere —\n * event handlers, async callbacks, adapter `send` wrappers, or any\n * imperative context where the render context is not live.\n *\n * Unlike `sample()` (a view primitive that requires an active\n * render context and throws outside of `view()`), `getState` is\n * the sanctioned escape hatch for \"I need to know the current\n * state to decide what to dispatch.\" Typical shape:\n *\n * ```ts\n * const handle = mountApp(root, MyApp)\n * container.addEventListener('drop', () => {\n * const { mode } = handle.getState() as AppState\n * if (mode === 'drag') handle.send({ type: 'commit' })\n * })\n * ```\n *\n * Throws after `dispose()` — stale reads are silent bugs; a thrown\n * error pinpoints the callsite that forgot to detach.\n *\n * The return type is `unknown` because `AppHandle` is state-type\n * erased at this boundary; cast to your app's state type at the\n * call site.\n */\n getState(): unknown\n}\n\n// ── Lifetime ─────────────────────────────────────────────────────────\n\nexport interface Lifetime {\n id: number\n parent: Lifetime | null\n children: Lifetime[]\n disposers: Array<() => void>\n bindings: Binding[]\n /** Per-item updaters — called directly by each() when item changes, bypassing Phase 2 */\n itemUpdaters: Array<() => void>\n /**\n * @internal dev-only back-reference to the owning ComponentInstance.\n * Populated on the root scope by `installDevTools` so `disposeLifetime`\n * can walk up the scope chain and emit DisposerEvents into the\n * instance's `_disposerLog`. Undefined in production.\n */\n instance?: ComponentInstance\n /**\n * @internal dev-only cause hint. Structural primitives (branch, each,\n * child, mountApp teardown) set this field immediately before calling\n * `disposeLifetime`; the dispose path reads it once to stamp the emitted\n * DisposerEvent. Left undefined, `disposeLifetime` falls back to\n * `'component-unmount'`. Undefined in production.\n */\n disposalCause?: DisposerEvent['cause']\n /** @internal dev-only — populated by structural primitives for scope-tree classification */\n _kind?: 'root' | 'show' | 'each' | 'branch' | 'scope' | 'child' | 'portal' | 'foreign'\n}\n\nexport interface LifetimeNode {\n scopeId: string\n kind: 'root' | 'show' | 'each' | 'branch' | 'scope' | 'child' | 'portal' | 'foreign'\n active: boolean\n children: LifetimeNode[]\n}\n\n// ── Binding ───────────────────────────────────────────────────────\n\n/**\n * Binding output kinds.\n *\n * `'text' | 'prop' | 'attr' | 'class' | 'style'` write their accessor's\n * return value to the DOM. `'effect'` is a side-effect-only watcher:\n * the accessor is invoked every Phase 2 tick its mask is hit, but its\n * return value is discarded and `applyBinding` is a no-op. Used by\n * `child()` to fire the prop-diff/propsMsg cascade on parent updates\n * without the cost of stringifying the returned props bag onto a\n * detached anchor node every render.\n */\nexport type BindingKind = 'text' | 'prop' | 'attr' | 'class' | 'style' | 'effect'\n\nexport interface Binding {\n mask: number\n accessor: (state: unknown) => unknown\n lastValue: unknown\n kind: BindingKind\n node: Node\n key?: string\n ownerLifetime: Lifetime\n perItem: boolean\n dead: boolean\n}\n\n// ── Structural Primitives ─────────────────────────────────────────\n\nexport interface TransitionOptions {\n enter?: (nodes: Node[]) => void | Promise<void>\n leave?: (nodes: Node[]) => void | Promise<void>\n onTransition?: (ctx: { entering: Node[]; leaving: Node[]; parent: Node }) => void | Promise<void>\n}\n\ninterface BranchOptionsBase extends TransitionOptions {\n /**\n * @internal Set by `show()` / `scope()` sugar when delegating to\n * `branch()`, so the dev-only disposer log can report `'show-hide'` /\n * `'scope-rebuild'` instead of the default `'branch-swap'` for the\n * leaving arm. User code should not set this directly.\n */\n __disposalCause?: DisposerEvent['cause']\n /** @internal Compiler-injected mask of paths read by `on`. */\n __mask?: number\n}\n\n/**\n * All cases covered by `cases` — no default allowed (would be dead code).\n */\ntype BranchOptionsExhaustive<S, M, K extends string> = BranchOptionsBase & {\n on: (s: S) => K\n cases: { [P in K]: (h: View<S, M>) => Node[] }\n default?: never\n}\n\n/**\n * `cases` may cover some but not all keys; `default` handles the rest.\n */\ntype BranchOptionsNonExhaustive<S, M, K extends string> = BranchOptionsBase & {\n on: (s: S) => K\n cases?: { [P in K]?: (h: View<S, M>) => Node[] }\n default: (h: View<S, M>) => Node[]\n}\n\n/**\n * `on` returns a wide `string` — exhaustiveness cannot be verified at\n * compile time (the key domain is infinite). Lenient: `default` is\n * optional so existing call sites that predate exhaustiveness typing\n * continue to compile. Authors who want the gate opt in by narrowing\n * `on`'s return type to a literal union.\n */\ntype BranchOptionsWide<S, M> = BranchOptionsBase & {\n on: (s: S) => string\n cases?: Record<string, (h: View<S, M>) => Node[]>\n default?: (h: View<S, M>) => Node[]\n}\n\n/**\n * Options for `branch()`.\n *\n * When `on` returns a literal string union (e.g. `'idle' | 'loading'\n * | 'done'`), TypeScript enforces exhaustiveness: either every union\n * member has a case (and `default` is disallowed as unreachable), or\n * `default` is required to cover the remainder. When `on` returns a\n * wide `string`, `default` stays optional — exhaustiveness isn't\n * meaningful for an unbounded domain.\n *\n * `cases` is optional when `default` is present; `branch({ on, default })`\n * is the canonical dynamic-rebuild shape — `scope()` sugar wraps\n * exactly this form.\n */\nexport type BranchOptions<S, M = unknown, K extends string = string> = string extends K\n ? BranchOptionsWide<S, M>\n : BranchOptionsExhaustive<S, M, K> | BranchOptionsNonExhaustive<S, M, K>\n\nexport interface ShowOptions<S, M = unknown> extends TransitionOptions {\n when: (s: S) => boolean\n render: (h: View<S, M>) => Node[]\n fallback?: (h: View<S, M>) => Node[]\n}\n\n/**\n * Options for `scope()` — rebuilds a subtree when `on(state)` changes.\n *\n * Sugar over `branch({ on, cases: {}, default: render, __disposalCause: 'scope-rebuild' })`.\n * Use when the key is dynamic (e.g. an epoch counter bumped from the\n * outside) and you want a fresh arm — fresh lifetime, fresh bindings —\n * each time it changes. Combine with `sample()` inside `render` for a\n * one-shot current-state read.\n */\nexport interface ScopeOptions<S, M = unknown> extends TransitionOptions {\n on: (s: S) => string\n render: (h: View<S, M>) => Node[]\n /** @internal Compiler-injected mask of paths read by `on`. */\n __mask?: number\n}\n\n/**\n * Options for `each()`. The inherited `enter` / `leave` callbacks fire **per item**:\n * `enter(nodes)` runs after an item's DOM is inserted (including initial mount);\n * `leave(nodes)` runs before an item's DOM is removed and may return a Promise\n * to hold the DOM until the animation resolves. Setting `leave` disables the\n * bulk-clear / full-replace fast paths.\n */\n/**\n * Per-item accessor. Two access forms:\n * - `item.field` — shorthand, returns accessor for `item.current[field]`\n * - `item(t => t.expr)` — computed expressions\n *\n * In both cases the returned value is a `() => V` accessor.\n * Invoke it (`item.field()`) to read the current value imperatively.\n */\nexport type ItemAccessor<T> = {\n <R>(selector: (t: T) => R): () => R\n} & {\n [K in keyof T]-?: () => T[K]\n} & {\n /**\n * Read the whole current item. Needed when T is a primitive (where the\n * field-map branch collapses to method names like `toString`) or when\n * you want to sample the entire record rather than a single field.\n *\n * Shadows any literal `current` field on T — if T has such a field,\n * use `item(r => r.current)` to disambiguate.\n */\n current(): T\n}\n\nexport interface EachOptions<S, T, M = unknown> extends TransitionOptions {\n items: (s: S) => T[]\n key: (item: T) => string | number\n render: (opts: {\n send: Send<M>\n item: ItemAccessor<T>\n /**\n * Plain (non-Proxy) accessor factory. Compiler-output path; avoid in user code\n * (use `item.field` / `item(fn)` — more ergonomic and bypasses Proxy when compiled).\n */\n acc: <R>(selector: (t: T) => R) => () => R\n index: () => number\n /**\n * The component's View bag (`h.text`, `h.show`, `h.branch`,\n * `h.scope`, `h.sample`, …). Each-render callers used to reach\n * for the top-level imports; the bag form is symmetric with how\n * `branch.cases[k]`, `show.render`, and `scope.render` receive it.\n * Both still work — destructure whichever is more convenient.\n */\n h: View<S, M>\n /** @internal Compiler-injected — entry reference for row factory */\n entry?: Record<string, unknown>\n }) => Node[]\n}\n\nexport interface PortalOptions {\n target: HTMLElement | string\n render: () => Node[]\n}\n\nexport interface ForeignOptions<S, M, T extends Record<string, unknown>, Instance> {\n /**\n * Construct the imperative instance. Can be async — return a\n * `Promise<Instance>` to defer construction until e.g. a dynamic\n * `import()` resolves. While the promise is pending:\n *\n * - The container element is in the DOM immediately (so layout\n * doesn't shift when the instance arrives).\n * - `sync` is NOT called. State changes are tracked by the\n * primitive and the latest props are applied as the initial\n * sync right after the promise resolves.\n * - If the owning scope disposes before the promise resolves,\n * `destroy(instance)` runs on resolution — no matter how long\n * the promise takes.\n */\n mount: (ctx: { container: HTMLElement; send: Send<M> }) => Instance | Promise<Instance>\n props: (s: S) => T\n sync:\n | ((ctx: { instance: Instance; props: T; prev: T | undefined }) => void)\n | {\n [K in keyof T]?: (ctx: { instance: Instance; value: T[K]; prev: T[K] | undefined }) => void\n }\n destroy: (instance: Instance) => void\n container?: { tag?: string; attrs?: Record<string, string> }\n}\n\nexport interface ChildOptions<S, ChildM> {\n // Type-erased via AnyComponentDef so callers can pass any concrete\n // ComponentDef<S, M, E, D> without a widening helper. The runtime\n // narrows the message shape via the user-supplied `onMsg` callback,\n // which keeps `ChildM` typed at this boundary even though the def\n // itself is opaque.\n def: AnyComponentDef\n key: string | number\n props: (s: S) => Record<string, unknown>\n onMsg?: (msg: ChildM) => unknown | null\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llui/dom",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {