@llui/dom 0.0.36 → 0.0.38

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.
@@ -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;AA0BtE,uEAAuE;AACvE,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAEpD;AAED,sEAAsE;AACtE,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,GAAG,IAAI,CAEzE;AAwDD,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,CA+R1E"}
1
+ {"version":3,"file":"each.d.ts","sourceRoot":"","sources":["../../src/primitives/each.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAA0B,MAAM,aAAa,CAAA;AA0BtE,uEAAuE;AACvE,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAEpD;AAED,sEAAsE;AACtE,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,GAAG,IAAI,CAEzE;AAwDD,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,CA4S1E"}
@@ -64,6 +64,15 @@ export function each(opts) {
64
64
  const parentLifetime = ctx.rootLifetime;
65
65
  const blocks = ctx.structuralBlocks;
66
66
  const anchor = ctx.dom.createComment('each');
67
+ // End-of-territory sentinel. Bulk Range ops (reconcileClear, Fast path
68
+ // 1, Fast path 5) used to setEndAfter the last entry's last node, but
69
+ // when a nested structural primitive replaced its own entries between
70
+ // the outer render snapshot and the next outer reconcile, that captured
71
+ // node could be detached — Range#setEndAfter throws InvalidNodeTypeError
72
+ // on a parent-less node. Anchoring the range with two stable comments
73
+ // (owned by this each) makes the bulk-remove correct regardless of any
74
+ // inner-each / show / branch mutation that happened in between.
75
+ const endAnchor = ctx.dom.createComment('each-end');
67
76
  const entries = [];
68
77
  const clearCallbacks = [];
69
78
  const removeCallbacks = [];
@@ -137,7 +146,7 @@ export function each(opts) {
137
146
  lastItemsRef = newItems;
138
147
  const oldKeys = snapshotKeys();
139
148
  const report = opts.onTransition ? { entering: [], leaving: [] } : null;
140
- reconcileEntries(entries, newItems, opts, parentLifetime, parent, anchor, ctx, state, leaving, report);
149
+ reconcileEntries(entries, newItems, opts, parentLifetime, parent, anchor, endAnchor, ctx, state, leaving, report);
141
150
  if (opts.onTransition && report) {
142
151
  opts.onTransition({ entering: report.entering, leaving: report.leaving, parent });
143
152
  }
@@ -170,12 +179,12 @@ export function each(opts) {
170
179
  // BEFORE scope disposal — avoids 1000 individual Set.delete calls
171
180
  for (let i = 0; i < clearCallbacks.length; i++)
172
181
  clearCallbacks[i]();
173
- // Bulk DOM removal
182
+ // Bulk DOM removal — anchored on this each's own start/end sentinels
183
+ // so a nested primitive that replaced its own captured nodes between
184
+ // the outer snapshot and now can't make this throw.
174
185
  const range = ctx.dom.createRange();
175
186
  range.setStartAfter(anchor);
176
- const lastEntry = entries[entries.length - 1];
177
- const lastNode = lastEntry.nodes[lastEntry.nodes.length - 1];
178
- range.setEndAfter(lastNode);
187
+ range.setEndBefore(endAnchor);
179
188
  range.deleteContents();
180
189
  // Bulk scope disposal — disposers that were replaced by clearCallbacks
181
190
  // are now no-ops, making this much faster
@@ -204,7 +213,7 @@ export function each(opts) {
204
213
  const newLen = newItems.length;
205
214
  if (newLen >= oldLen) {
206
215
  // Not a removal — fallback (shouldn't happen if compiler detected correctly)
207
- reconcileEntries(entries, newItems, opts, parentLifetime, parent, anchor, ctx, state, leaving, null);
216
+ reconcileEntries(entries, newItems, opts, parentLifetime, parent, anchor, endAnchor, ctx, state, leaving, null);
208
217
  emitDiff(oldKeys);
209
218
  return;
210
219
  }
@@ -308,6 +317,8 @@ export function each(opts) {
308
317
  entries.length = 0;
309
318
  if (anchor.parentNode)
310
319
  anchor.parentNode.removeChild(anchor);
320
+ if (endAnchor.parentNode)
321
+ endAnchor.parentNode.removeChild(endAnchor);
311
322
  // Force-remove any mid-leave entries immediately
312
323
  for (const entry of leaving) {
313
324
  for (const node of entry.nodes) {
@@ -324,6 +335,7 @@ export function each(opts) {
324
335
  for (let i = 0; i < nodes.length; i++)
325
336
  result.push(nodes[i]);
326
337
  }
338
+ result.push(endAnchor);
327
339
  return result;
328
340
  }
329
341
  /**
@@ -455,7 +467,7 @@ function collectNodes(target, nodes) {
455
467
  for (const n of nodes)
456
468
  target.push(n);
457
469
  }
458
- function reconcileEntries(entries, newItems, opts, parentLifetime, parent, anchor, ctx, state, leaving, report) {
470
+ function reconcileEntries(entries, newItems, opts, parentLifetime, parent, anchor, endAnchor, ctx, state, leaving, report) {
459
471
  const oldLen = entries.length;
460
472
  const newLen = newItems.length;
461
473
  const hasLeave = !!opts.leave;
@@ -474,13 +486,12 @@ function reconcileEntries(entries, newItems, opts, parentLifetime, parent, ancho
474
486
  removeEntry(entry, opts, leaving);
475
487
  return;
476
488
  }
477
- // Remove all DOM nodes in one operation using Range
489
+ // Remove all DOM nodes in one operation using Range. Anchored on
490
+ // start + end sentinels — see endAnchor comment in each() for why.
478
491
  if (entries.length > 0) {
479
492
  const range = ctx.dom.createRange();
480
493
  range.setStartAfter(anchor);
481
- const lastEntry = entries[entries.length - 1];
482
- const lastNode = lastEntry.nodes[lastEntry.nodes.length - 1];
483
- range.setEndAfter(lastNode);
494
+ range.setEndBefore(endAnchor);
484
495
  range.deleteContents();
485
496
  }
486
497
  // Bulk dispose all entry scopes — avoids per-scope function call overhead
@@ -591,11 +602,12 @@ function reconcileEntries(entries, newItems, opts, parentLifetime, parent, ancho
591
602
  for (const entry of entries)
592
603
  collectNodes(report.leaving, entry.nodes);
593
604
  }
594
- // Bulk DOM removal using Range
605
+ // Bulk DOM removal using Range — anchored on this each's stable
606
+ // sentinels so a stale lastEntry node from a nested-primitive
607
+ // mutation can't trip setEndAfter.
595
608
  const range = ctx.dom.createRange();
596
609
  range.setStartAfter(anchor);
597
- const lastEntry = entries[entries.length - 1];
598
- range.setEndAfter(lastEntry.nodes[lastEntry.nodes.length - 1]);
610
+ range.setEndBefore(endAnchor);
599
611
  range.deleteContents();
600
612
  // Bulk dispose all old scopes
601
613
  const oldLifetimes = [];
@@ -662,8 +674,18 @@ function reconcileEntries(entries, newItems, opts, parentLifetime, parent, ancho
662
674
  removeEntry(entry, opts, leaving);
663
675
  }
664
676
  else {
665
- for (const node of entry.nodes)
666
- parent.removeChild(node);
677
+ // Defensive guard: a nested primitive (inner each / show / branch)
678
+ // may have replaced its own captured nodes between the outer
679
+ // render snapshot and now. Those replaced nodes are still in
680
+ // entry.nodes but no longer children of `parent`. Skip them —
681
+ // the inner-primitive's addDisposer cascade (run by the scope
682
+ // disposal below) cleans up the orphan replacement nodes that
683
+ // ARE attached. Without this guard, removeChild throws
684
+ // NotFoundError on the stale ones.
685
+ for (const node of entry.nodes) {
686
+ if (node.parentNode === parent)
687
+ parent.removeChild(node);
688
+ }
667
689
  entry.scope.disposalCause = 'each-remove';
668
690
  disposeLifetime(entry.scope, true);
669
691
  didBulkDetach = true;
@@ -1 +1 @@
1
- {"version":3,"file":"each.js","sourceRoot":"","sources":["../../src/primitives/each.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,YAAY,GAEb,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,cAAc,EACd,eAAe,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A;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 enterAccessor,\n exitAccessor,\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// Wrap accessor invocations so `sample()` calls inside them throw a targeted\n// error. The wrappers also localise the contract: every items/key call goes\n// through these, so a future change (e.g. instrumentation) has one site.\nfunction callItems<S, T>(opts: { items: (s: S) => T[] }, state: S): T[] {\n enterAccessor('each().items')\n try {\n return opts.items(state)\n } finally {\n exitAccessor()\n }\n}\nfunction callKey<T>(opts: { key: (t: T) => string | number }, item: T): string | number {\n enterAccessor('each().key')\n try {\n return opts.key(item)\n } finally {\n exitAccessor()\n }\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 = callItems(opts, 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 = callItems(opts, 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 = callItems(opts, 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 = callItems(opts, 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 === callKey(opts, 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 = callItems(opts, 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 = callKey(opts, 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 = callKey(opts, 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 (\n e1.key === callKey(opts, newItems[mismatch2]!) &&\n e2.key === callKey(opts, newItems[mismatch1]!)\n ) {\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 && callKey(opts, 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(callKey(opts, 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 = callKey(opts, 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 !== callKey(opts, 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,EAClB,aAAa,EACb,YAAY,GAEb,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,6EAA6E;AAC7E,4EAA4E;AAC5E,yEAAyE;AACzE,SAAS,SAAS,CAAO,IAA8B,EAAE,KAAQ;IAC/D,aAAa,CAAC,cAAc,CAAC,CAAA;IAC7B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,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C,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 enterAccessor,\n exitAccessor,\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// Wrap accessor invocations so `sample()` calls inside them throw a targeted\n// error. The wrappers also localise the contract: every items/key call goes\n// through these, so a future change (e.g. instrumentation) has one site.\nfunction callItems<S, T>(opts: { items: (s: S) => T[] }, state: S): T[] {\n enterAccessor('each().items')\n try {\n return opts.items(state)\n } finally {\n exitAccessor()\n }\n}\nfunction callKey<T>(opts: { key: (t: T) => string | number }, item: T): string | number {\n enterAccessor('each().key')\n try {\n return opts.key(item)\n } finally {\n exitAccessor()\n }\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 // End-of-territory sentinel. Bulk Range ops (reconcileClear, Fast path\n // 1, Fast path 5) used to setEndAfter the last entry's last node, but\n // when a nested structural primitive replaced its own entries between\n // the outer render snapshot and the next outer reconcile, that captured\n // node could be detached — Range#setEndAfter throws InvalidNodeTypeError\n // on a parent-less node. Anchoring the range with two stable comments\n // (owned by this each) makes the bulk-remove correct regardless of any\n // inner-each / show / branch mutation that happened in between.\n const endAnchor = ctx.dom.createComment('each-end')\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 = callItems(opts, 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 = callItems(opts, 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 endAnchor,\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 = callItems(opts, 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 — anchored on this each's own start/end sentinels\n // so a nested primitive that replaced its own captured nodes between\n // the outer snapshot and now can't make this throw.\n const range = ctx.dom.createRange()\n range.setStartAfter(anchor)\n range.setEndBefore(endAnchor)\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 = callItems(opts, 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 endAnchor,\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 === callKey(opts, 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 = callItems(opts, 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 if (endAnchor.parentNode) endAnchor.parentNode.removeChild(endAnchor)\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 result.push(endAnchor)\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 = callKey(opts, 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 endAnchor: 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. Anchored on\n // start + end sentinels — see endAnchor comment in each() for why.\n if (entries.length > 0) {\n const range = ctx.dom.createRange()\n range.setStartAfter(anchor)\n range.setEndBefore(endAnchor)\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 = callKey(opts, 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 (\n e1.key === callKey(opts, newItems[mismatch2]!) &&\n e2.key === callKey(opts, newItems[mismatch1]!)\n ) {\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 && callKey(opts, 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(callKey(opts, 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 — anchored on this each's stable\n // sentinels so a stale lastEntry node from a nested-primitive\n // mutation can't trip setEndAfter.\n const range = ctx.dom.createRange()\n range.setStartAfter(anchor)\n range.setEndBefore(endAnchor)\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 = callKey(opts, 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 // Defensive guard: a nested primitive (inner each / show / branch)\n // may have replaced its own captured nodes between the outer\n // render snapshot and now. Those replaced nodes are still in\n // entry.nodes but no longer children of `parent`. Skip them —\n // the inner-primitive's addDisposer cascade (run by the scope\n // disposal below) cleans up the orphan replacement nodes that\n // ARE attached. Without this guard, removeChild throws\n // NotFoundError on the stale ones.\n for (const node of entry.nodes) {\n if (node.parentNode === parent) parent.removeChild(node)\n }\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 !== callKey(opts, 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":"update-loop.d.ts","sourceRoot":"","sources":["../src/update-loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAItD,OAAO,EAAE,KAAK,MAAM,EAAc,MAAM,cAAc,CAAA;AAoBtD,eAAO,MAAM,SAAS,QAAiB,CAAA;AAMvC,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,CAAC,GAAG,EAAE;IAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,KAAK,IAAI,GAClE,IAAI,CAEN;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO;IACtE,GAAG,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAC1B,KAAK,EAAE,CAAC,CAAA;IACR,cAAc,EAAE,CAAC,EAAE,CAAA;IACnB,YAAY,EAAE,QAAQ,CAAA;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,OAAO,EAAE,CAAA;IACtB,gBAAgB,EAAE,eAAe,EAAE,CAAA;IACnC,KAAK,EAAE,CAAC,EAAE,CAAA;IACV,kBAAkB,EAAE,OAAO,CAAA;IAC3B,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,CAAC,EAAE,CAAA;IAChB,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,CAAA;IACtB,MAA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
317
317
  inst._onCommit?.(s);
318
+ // memo()-wrapped accessors (auto-generated by the compiler for
319
+ // multi-field structural accessors like each.items / branch.on /
320
+ // show.when) gate on `currentDirtyMask`. The generic pipeline sets
321
+ // it before Phase 1; the single-message fast path must as well, or
322
+ // memo short-circuits with the stale value left over from the
323
+ // previous cycle and structural blocks reconcile against a frozen
324
+ // input.
325
+ setCurrentDirtyMask(dirty);
318
326
  if (method >= 0) {
319
327
  const bl = inst.structuralBlocks;
320
328
  for (let i = 0; i < bl.length; i++) {
@@ -1 +1 @@
1
- {"version":3,"file":"update-loop.js","sourceRoot":"","sources":["../src/update-loop.ts"],"names":[],"mappings":"AAKA,OAAO,EAAe,UAAU,EAAE,MAAM,cAAc,CAAA;AAEtD,oEAAoE;AACpE,sEAAsE;AACtE,mEAAmE;AACnE,IAAI,YAAY,GAAkB,IAAI,CAAA;AACtC,SAAS,kBAAkB;IACzB,IAAI,YAAY,KAAK,IAAI;QAAE,YAAY,GAAG,UAAU,EAAE,CAAA;IACtD,OAAO,YAAY,CAAA;AACrB,CAAC;AAMD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEjE,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,GAAG,CAAC,CAAA;AAEvC,kEAAkE;AAClE,IAAI,mBAAmB,GACrB,IAAI,CAAA;AAEN,MAAM,UAAU,sBAAsB,CACpC,EAAmE;IAEnE,mBAAmB,GAAG,EAAE,CAAA;AAC1B,CAAC;AAoFD,MAAM,UAAU,uBAAuB,CACrC,GAA6B,EAC7B,IAAQ,EACR,iBAAkC,IAAI,EACtC,GAAY;IAEZ,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC,GAAG,GAAG,CAAC,IAAI,C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GAAG,GAAI,OAAO,CAAC,SAAqC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YACzE,uEAAuE;YACvE,yEAAyE;YACzE,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAY,CAAC,CAAC,CAAA;QACvD,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC;YACZ,QAAQ,EAAE,EAAE;YACZ,IAAI;YACJ,KAAK,EAAE,iBAAiB;YACxB,SAAS,EAAE,YAAY;YACvB,UAAU,EAAE,CAAC;SACd,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;IACb,CAAC;IAED,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAA;IACnF,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;IACzF,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,WAAW;IAClB,MAAM,SAAS,GAAI,UAAyD,CAAC,MAAM,CAAA;IACnF,IAAI,SAAS,EAAE,UAAU;QAAE,OAAO,SAAS,CAAC,UAAU,EAAE,CAAA;IACxD,OAAO,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAA;AACvE,CAAC","sourcesContent":["import type { ComponentDef, Lifetime, Binding } from './types.js'\nimport type { StructuralBlock } from './structural.js'\nimport type { RingBuffer, EachDiff } from './tracking/each-diff.js'\nimport type { DisposerEvent } from './tracking/disposer-log.js'\nimport type { CoverageTracker } from './tracking/coverage.js'\nimport { type DomEnv, browserEnv } from './dom-env.js'\n\n// Single lazily-constructed browser env shared by every client-side\n// component instance. Falls through to globalThis at call time — safe\n// to construct on a server process (the lookups never fire there).\nlet _fallbackEnv: DomEnv | null = null\nfunction fallbackBrowserEnv(): DomEnv {\n if (_fallbackEnv === null) _fallbackEnv = browserEnv()\n return _fallbackEnv\n}\nimport type {\n EffectTimelineEntry,\n PendingEffectsList,\n MockRegistry,\n} from './tracking/effect-timeline.js'\nimport { createLifetime } from './lifetime.js'\nimport { applyBinding } from './binding.js'\nimport { setCurrentDirtyMask } from './primitives/memo.js'\nimport { enterAccessor, exitAccessor } from './render-context.js'\n\nexport const FULL_MASK = 0xffffffff | 0\n\n// Addressed effect dispatcher — set by addressed.ts when imported\nlet addressedDispatcher: ((eff: { __targetKey: string | number; __msg: unknown }) => void) | null =\n null\n\nexport function setAddressedDispatcher(\n fn: (eff: { __targetKey: string | number; __msg: unknown }) => void,\n): void {\n addressedDispatcher = fn\n}\n\nexport interface ComponentInstance<S = unknown, M = unknown, E = unknown> {\n def: ComponentDef<S, M, E>\n state: S\n initialEffects: E[]\n rootLifetime: Lifetime\n dom: DomEnv\n allBindings: Binding[]\n structuralBlocks: StructuralBlock[]\n queue: M[]\n microtaskScheduled: boolean\n lastDirtyMask: number\n lastEffects: E[]\n send: (msg: M) => void\n signal: AbortSignal\n abortController: AbortController\n /** @internal dev-only — populated when `installDevTools` ran. Ring-buffered\n * per-each-site reconciliation diffs for MCP introspection tools. */\n _eachDiffLog?: RingBuffer<EachDiff>\n /** @internal dev-only — monotonically incremented by the devtools-intercepted\n * `update` before each history push. Read by `each.ts` to stamp diffs with\n * the `updateIndex` of the message that caused the reconciliation. */\n _updateCounter?: number\n /** @internal dev-only — populated when `installDevTools` ran. Ring-buffered\n * log of `disposeLifetime` firings (scope id + cause). Consumed by the\n * `llui_disposer_log` MCP tool to diagnose leaks on structural transitions. */\n _disposerLog?: RingBuffer<DisposerEvent>\n /** @internal dev-only — populated when `installDevTools` ran. Per-variant\n * Msg counter keyed by discriminant. Consumed by the `llui_coverage` MCP\n * tool to surface Msg variants that have never fired this session. */\n _coverage?: CoverageTracker\n /** @internal dev-only — populated when `installDevTools` ran. Ring-buffered\n * effect dispatch phase log (dispatched → resolved/cancelled) for USER\n * effects emitted from `update()`. Consumed by the `llui_effect_timeline`\n * MCP tool. Built-in plumbing effects (`delay`, `log`, addressed) are NOT\n * recorded here by design — they short-circuit in `dispatchEffect` before\n * `dispatchEffectDev` runs. They're runtime plumbing, not user intent,\n * and surface via other channels (message queue for `delay`, browser\n * console for `log`, addressed-target routing for addressed effects). */\n _effectTimeline?: RingBuffer<EffectTimelineEntry>\n /** @internal dev-only — populated when `installDevTools` ran. List of\n * currently-pending effects addressable by id, consumed by the\n * `llui_pending_effects` MCP tool. */\n _pendingEffects?: PendingEffectsList\n /** @internal dev-only — populated when `installDevTools` ran. Mock\n * registry consulted by the effect-dispatch wrapper to short-circuit\n * matching effects. Consumed by the `llui_mock_effect` MCP tool. */\n _effectMocks?: MockRegistry\n /**\n * @internal — set by mountApp/mountAtAnchor/hydrateApp/hydrateAtAnchor\n * to fire AppHandle.subscribe listeners after every update cycle.\n * Undefined until the first subscriber registers.\n */\n _onCommit?: (state: unknown) => void\n /**\n * @internal — optional hook invoked when a binding's accessor throws\n * during Phase 2. The runtime catches the throw, leaves the binding's\n * `lastValue` unchanged (so the rendered DOM stays at its previous\n * value rather than going blank), and notifies this hook. The agent\n * factory wires it to drain.errors so the LLM sees that some bindings\n * failed; non-agent hosts can leave it undefined for the default\n * console-warn behavior.\n *\n * Why catch + continue instead of letting the throw propagate?\n * One bad binding shouldn't abort the entire update loop — sibling\n * bindings on the same commit are independent and have no business\n * going stale because a different binding crashed. The user-visible\n * effect: when one cell's accessor throws (e.g. scoring fails on a\n * malformed criterion), every other cell still renders correctly;\n * only the broken binding shows its previous value.\n */\n _onBindingError?: (info: { kind: string; key?: string; message: string; stack?: string }) => void\n /**\n * @internal — live registry of currently-mounted Msg variants\n * dispatchable from rendered UI. Lazily allocated when the first\n * compiler-tagged event handler binds. Read by the agent layer (via\n * `AppHandle.getBindingDescriptors()`) to surface live affordances\n * to the LLM. See `binding-descriptors.ts` for the registration\n * protocol and `@llui/vite-plugin`'s tagger pass for the tag emission.\n */\n _bindingDescriptors?: import('./binding-descriptors.js').BindingDescriptorRegistry\n}\n\nexport function createComponentInstance<S, M, E, D = void>(\n def: ComponentDef<S, M, E, D>,\n data?: D,\n parentLifetime: Lifetime | null = null,\n dom?: DomEnv,\n): ComponentInstance<S, M, E> {\n const [initialState, initialEffects] = def.init(data as D)\n\n const controller = new AbortController()\n\n const inst: ComponentInstance<S, M, E> = {\n // `def` carries an arbitrary `D` for typed init data, but after init\n // has run the runtime never touches `def.init` again — update/view/\n // onEffect and HMR replacement don't depend on D. Cast to the\n // D=void instance storage shape here.\n def: def as ComponentDef<S, M, E>,\n state: initialState,\n initialEffects,\n // Caller-supplied DOM env. `mountApp` defaults this to `browserEnv()`;\n // `renderToString` passes the user's jsdom/linkedom env. Never null —\n // every primitive reads from inst.dom.\n dom: dom ?? fallbackBrowserEnv(),\n // When `parentLifetime` is provided the instance's rootLifetime becomes a\n // child of that scope. This is how persistent layouts wire pages\n // into the layout's scope tree: the page's rootLifetime is parented at\n // the layout's pageSlot() point so `useContext` lookups flow layout\n // → page, and scope disposal cascades correctly. Mount paths that\n // don't pass parentLifetime get the classic detached root.\n rootLifetime: createLifetime(parentLifetime),\n allBindings: [],\n structuralBlocks: [],\n queue: [],\n microtaskScheduled: false,\n lastDirtyMask: 0,\n lastEffects: [],\n signal: controller.signal,\n abortController: controller,\n\n send(msg: M) {\n inst.queue.push(msg)\n if (!inst.microtaskScheduled) {\n inst.microtaskScheduled = true\n queueMicrotask(() => {\n inst.microtaskScheduled = false\n processMessages(inst)\n })\n }\n },\n }\n\n inst.rootLifetime._kind = 'root'\n\n return inst\n}\n\nexport function flushInstance<S, M, E>(inst: ComponentInstance<S, M, E>): void {\n if (inst.queue.length === 0) return\n inst.microtaskScheduled = false\n processMessages(inst)\n}\n\n/**\n * Dev-only: overwrite instance state and re-run both phases with FULL_MASK\n * so every binding re-evaluates. Bypasses update() — use for devtools\n * snapshot/restore, not in app code.\n */\nexport function _forceState<S, M, E>(inst: ComponentInstance<S, M, E>, newState: S): void {\n inst.state = newState\n inst.lastDirtyMask = FULL_MASK\n\n const bindings = inst.allBindings\n const bindingsBeforePhase1 = bindings.length\n\n setCurrentDirtyMask(FULL_MASK)\n\n const snapshot = inst.structuralBlocks.slice()\n for (const block of snapshot) {\n try {\n block.reconcile(newState, FULL_MASK)\n } catch (e) {\n reportReconcileError(inst, e)\n }\n }\n\n let phase2Len = bindingsBeforePhase1\n if (bindings.length > bindingsBeforePhase1 || (phase2Len > 0 && bindings[0]!.dead)) {\n let w = 0\n for (let r = 0; r < bindings.length; r++) {\n if (!bindings[r]!.dead) bindings[w++] = bindings[r]!\n }\n bindings.length = w\n phase2Len = Math.min(w, bindingsBeforePhase1)\n }\n\n const state = inst.state\n enterAccessor('a binding accessor')\n try {\n for (let i = 0, len = phase2Len; i < len; i++) {\n const binding = bindings[i]!\n if (binding.dead) continue\n if (binding.kind === 'effect') {\n try {\n binding.accessor(state)\n } catch (e) {\n reportBindingError(inst, binding, e)\n }\n continue\n }\n let newValue: unknown\n try {\n newValue = binding.accessor(state)\n } catch (e) {\n // Accessor threw — leave the binding's `lastValue` unchanged so\n // the rendered DOM stays at its previous value rather than going\n // blank. Sibling bindings on the same commit continue to\n // evaluate. The error surfaces via the optional hook (or\n // console.warn as a fallback) so it isn't silently swallowed.\n reportBindingError(inst, binding, e)\n continue\n }\n if (Object.is(newValue, binding.lastValue)) continue\n binding.lastValue = newValue\n try {\n applyBinding(binding, newValue)\n } catch (e) {\n // applyBinding writes the value to the DOM (textContent,\n // setAttribute, etc.). Throws here are usually environmental\n // (a node was removed mid-flight by a sibling binding). Same\n // contract: report and continue.\n reportBindingError(inst, binding, e)\n }\n }\n } finally {\n exitAccessor()\n }\n}\n\nfunction reportBindingError<S, M, E>(\n inst: ComponentInstance<S, M, E>,\n binding: Binding,\n e: unknown,\n): void {\n const err = e instanceof Error ? e : new Error(String(e))\n const stack = err.stack ? err.stack.split('\\n').slice(0, 8).join('\\n') : undefined\n const info =\n stack !== undefined\n ? {\n kind: String(binding.kind),\n key: binding.key,\n message: `${err.name}: ${err.message}`,\n stack,\n }\n : { kind: String(binding.kind), key: binding.key, message: `${err.name}: ${err.message}` }\n if (inst._onBindingError !== undefined) {\n try {\n inst._onBindingError(info)\n } catch {\n // The hook itself threw — nothing to do; we're in a recovery\n // path already. Fall through to the console fallback.\n }\n } else if (typeof console !== 'undefined' && typeof console.warn === 'function') {\n console.warn(\n `[llui] binding accessor threw (kind=${info.kind}${info.key ? `, key=${info.key}` : ''}): ${info.message}`,\n )\n }\n}\n\n/**\n * Phase 1 (structural reconcile) parallel of `reportBindingError`. A\n * `block.reconcile` throw — most often a misuse like `sample()` inside an\n * `each().key` accessor — would otherwise escape the update loop, kill the\n * remaining structural blocks AND the entire Phase 2 binding pass on this\n * commit, and (in real apps) surface as an unhandled microtask rejection\n * the developer never sees. Routing it through the same `_onBindingError`\n * channel that Phase 2 uses gives parity: the error is named, surfaced\n * once, and the rest of the update continues.\n *\n * Note: a partial DOM mutation on the failing block is NOT rolled back.\n * The block's reconcile is responsible for keeping the DOM in a consistent\n * state on its own happy path; if it throws mid-mutation, the visible\n * result may be an inconsistent block, but sibling blocks and bindings\n * still update correctly.\n */\nfunction reportReconcileError<S, M, E>(inst: ComponentInstance<S, M, E>, e: unknown): void {\n const err = e instanceof Error ? e : new Error(String(e))\n const stack = err.stack ? err.stack.split('\\n').slice(0, 8).join('\\n') : undefined\n const info =\n stack !== undefined\n ? { kind: 'reconcile', message: `${err.name}: ${err.message}`, stack }\n : { kind: 'reconcile', message: `${err.name}: ${err.message}` }\n if (inst._onBindingError !== undefined) {\n try {\n inst._onBindingError(info)\n } catch {\n // hook itself threw; fall through to console\n }\n } else if (typeof console !== 'undefined' && typeof console.error === 'function') {\n // Reconcile errors are programmer errors (almost always: sample-in-\n // accessor or a thrown structural primitive). Surface as `error` not\n // `warn` so they're not lost in noisy dev consoles.\n console.error(`[llui] structural reconcile threw: ${info.message}`)\n }\n}\n\nfunction processMessages<S, M, E>(inst: ComponentInstance<S, M, E>): void {\n const queue = inst.queue\n\n // Single-message fast path: dispatch directly to per-message-type handler\n // if available. Skips dirty computation, Phase 1/2 entirely.\n if (queue.length === 1 && inst.def.__handlers) {\n const msg = queue[0]!\n const handler = inst.def.__handlers[(msg as Record<string, unknown>).type as string] as\n | ((inst: ComponentInstance, msg: unknown) => [S, E[]])\n | undefined\n if (handler) {\n queue.length = 0\n const [newState, effects] = handler(inst as ComponentInstance, msg)\n inst.state = newState\n inst._onCommit?.(newState as unknown)\n if (import.meta.env?.DEV) {\n inst.lastDirtyMask = FULL_MASK\n inst.lastEffects = effects\n }\n for (let i = 0; i < effects.length; i++) {\n dispatchEffect(inst, effects[i]!)\n }\n return\n }\n }\n\n // Generic pipeline — drain queue, accumulate dirty bits\n let state = inst.state\n let combinedDirty = 0\n const allEffects: E[] = []\n\n const defUpdate = inst.def.update\n const dirtyFn = inst.def.__dirty\n for (let qi = 0; qi < queue.length; qi++) {\n const msg = queue[qi]!\n const [newState, effects] = defUpdate(state, msg)\n const dirty = dirtyFn ? dirtyFn(state, newState) : FULL_MASK\n if (typeof dirty === 'number') {\n combinedDirty |= dirty\n } else {\n combinedDirty |= dirty[0] | dirty[1]\n }\n state = newState\n // Avoid spread — allocates an iterator per call. For typical effect\n // arrays (0-2 elements) this is a minor saving; for bursts it matters.\n for (let ei = 0; ei < effects.length; ei++) allEffects.push(effects[ei]!)\n }\n queue.length = 0\n\n inst.state = state\n inst._onCommit?.(state as unknown)\n // Dev-only bookkeeping — tests read lastDirtyMask/lastEffects, prod\n // doesn't. Gating here keeps two writes out of the prod hot path.\n if (import.meta.env?.DEV) {\n inst.lastDirtyMask = combinedDirty\n inst.lastEffects = allEffects\n }\n\n // Snapshot binding count before Phase 1 — bindings added during\n // Phase 1 already have correct initial values and skip Phase 2.\n const bindings = inst.allBindings\n const bindingsBeforePhase1 = bindings.length\n\n // Set current dirty mask BEFORE Phase 1 so memo() accessors used in\n // structural primitives (e.g. each.items) can use the bitmask fast path.\n setCurrentDirtyMask(combinedDirty)\n\n if (inst.def.__update) {\n // Compiler-generated fast path — replaces generic Phase 1 + Phase 2\n inst.def.__update(state, combinedDirty, bindings, inst.structuralBlocks, bindingsBeforePhase1)\n } else {\n // Generic Phase 1 + Phase 2 fallback (uncompiled components)\n genericUpdate(inst, state, combinedDirty, bindings, bindingsBeforePhase1)\n }\n\n // Dispatch effects after DOM updates\n for (let i = 0; i < allEffects.length; i++) {\n dispatchEffect(inst, allEffects[i]!)\n }\n}\n\nfunction genericUpdate<S, M, E>(\n inst: ComponentInstance<S, M, E>,\n state: S,\n combinedDirty: number,\n bindings: Binding[],\n bindingsBeforePhase1: number,\n): void {\n // Phase 1 — structural reconciliation. Structural primitives register\n // their blocks BEFORE running builders, so parents precede their nested\n // children in this array. That ordering matters: a parent's reconcile\n // may dispose the old arm, whose disposers splice nested child blocks\n // out of this shared array. Because children are always to the right\n // of their parent, the splice shifts entries left — which is safe for\n // a forward iterator that re-reads length each step.\n const blocks = inst.structuralBlocks\n for (let bi = 0; bi < blocks.length; bi++) {\n const block = blocks[bi]\n if (!block || (block.mask & combinedDirty) === 0) continue\n try {\n block.reconcile(state, combinedDirty)\n } catch (e) {\n reportReconcileError(inst, e)\n }\n }\n\n // Phase 2 — compact + update bindings\n _runPhase2(\n state,\n combinedDirty,\n bindings,\n bindingsBeforePhase1,\n inst.def.name,\n inst._onBindingError,\n )\n}\n\n/**\n * Run a handler for a single message: call update(), reconcile blocks\n * with the given method, run Phase 2. Used by compiler-generated __handlers\n * to avoid duplicating boilerplate per message type.\n *\n * @param method 0=reconcile, 1=reconcileItems, 2=reconcileClear, 3=reconcileRemove, -1=skip blocks\n * @public — used by compiler-generated `__handlers`\n */\nexport function _handleMsg(\n inst: ComponentInstance,\n msg: unknown,\n dirty: number,\n method: number,\n): [unknown, unknown[]] {\n const [s, e] = (inst.def.update as (s: unknown, m: unknown) => [unknown, unknown[]])(\n inst.state,\n msg,\n )\n inst.state = s\n inst._onCommit?.(s)\n\n if (method >= 0) {\n const bl = inst.structuralBlocks\n for (let i = 0; i < bl.length; i++) {\n const block = bl[i]\n if (!block || !(block.mask & dirty)) continue\n try {\n // Specialized methods (`reconcileItems`, `reconcileClear`,\n // `reconcileRemove`, `reconcileChanged`) only exist on `each`\n // blocks. Non-each blocks (`show`, `branch`, `scope`) leave\n // them undefined. The compiler-side fix in `detectArrayOp`\n // already restricts these methods to single-field cases, but\n // a show()/branch() block whose mask intersects the cleared\n // field would still be silently skipped without this fallback.\n // When the specialized method is missing, run the general\n // `reconcile` path so the block's `when`/`on` accessor still\n // re-evaluates. each blocks always have the specialized\n // methods, so they keep their fast path.\n switch (method) {\n case 0:\n block.reconcile(s, dirty)\n break\n case 1:\n if (block.reconcileItems) block.reconcileItems(s)\n else block.reconcile(s, dirty)\n break\n case 2:\n if (block.reconcileClear) block.reconcileClear()\n else block.reconcile(s, dirty)\n break\n case 3:\n if (block.reconcileRemove) block.reconcileRemove(s)\n else block.reconcile(s, dirty)\n break\n default:\n // method >= 10: reconcileChanged with stride = method - 10\n if (method >= 10) {\n if (block.reconcileChanged) block.reconcileChanged(s, method - 10)\n else block.reconcile(s, dirty)\n }\n break\n }\n } catch (err) {\n reportReconcileError(inst, err)\n // continue to next block — see reportReconcileError docstring\n }\n }\n }\n\n const b = inst.allBindings\n _runPhase2(s, dirty, b, b.length, inst.def.name, inst._onBindingError)\n return [s, e]\n}\n\n/**\n * Phase 2: compact dead bindings + update live bindings.\n * Shared between genericUpdate and compiler-generated __update.\n * @public — used by compiler-generated `__update` functions\n */\nexport function _runPhase2(\n state: unknown,\n dirty: number,\n bindings: Binding[],\n bindingsBeforePhase1: number,\n componentName?: string,\n // Optional `_onBindingError` hook. Type is duplicated here rather\n // than referenced as `ComponentInstance['_onBindingError']` because\n // the underlying field is `@internal` — stripped from the generated\n // `.d.ts` — and a public-export signature can't depend on a stripped\n // type without breaking dependent packages' typecheck.\n onBindingError?: (info: { kind: string; key?: string; message: string; stack?: string }) => void,\n): void {\n let phase2Len = bindingsBeforePhase1\n if (bindings.length > bindingsBeforePhase1 || (phase2Len > 0 && bindings[0]!.dead)) {\n let w = 0\n for (let r = 0; r < bindings.length; r++) {\n if (!bindings[r]!.dead) bindings[w++] = bindings[r]!\n }\n bindings.length = w\n phase2Len = Math.min(w, bindingsBeforePhase1)\n }\n\n if (dirty !== 0) {\n // Always catch+continue: a single accessor throw shouldn't abort\n // the rest of the bindings on the same commit. The user-visible\n // effect: a broken cell shows its previous value; sibling cells\n // stay current. In dev mode, the wrapped error (with component\n // name, kind, node descriptor, accessor source) is forwarded via\n // the `_onBindingError` hook (agent integration) or to\n // `console.error` (dev harness without an agent). The prior\n // behavior of rethrowing from `flush()` made one bad binding\n // visually break the entire view — the worst-case UX.\n const isDev = import.meta.env?.DEV && componentName\n // Single accessor label for the entire Phase 2 loop. The binding kind is\n // already part of the error message that handleBindingThrow surfaces; the\n // accessor label here serves the more specific purpose of catching\n // sample() calls reaching for a render context that isn't set during\n // the update phase. A `binding accessor` label is generic enough to apply\n // to text/attr/class/effect bindings without per-kind branching.\n enterAccessor('a binding accessor')\n try {\n for (let i = 0, len = phase2Len; i < len; i++) {\n const binding = bindings[i]!\n if (binding.dead || (binding.mask & dirty) === 0) continue\n if (binding.kind === 'effect') {\n try {\n binding.accessor(state)\n } catch (e) {\n handleBindingThrow(onBindingError, binding, e, isDev ? componentName : null)\n }\n continue\n }\n let newValue: unknown\n try {\n newValue = binding.accessor(state)\n } catch (e) {\n handleBindingThrow(onBindingError, binding, e, isDev ? componentName : null)\n continue\n }\n const last = binding.lastValue\n if (newValue === last || (newValue !== newValue && last !== last)) continue\n binding.lastValue = newValue\n try {\n applyBinding(binding, newValue)\n } catch (e) {\n handleBindingThrow(onBindingError, binding, e, isDev ? componentName : null)\n }\n }\n } finally {\n exitAccessor()\n }\n }\n}\n\nfunction handleBindingThrow(\n onBindingError: ComponentInstance['_onBindingError'] | undefined,\n binding: Binding,\n e: unknown,\n componentName: string | null,\n): void {\n // Dev mode: build the rich wrapped error (with accessor source,\n // node descriptor, undefined-hint detection). Prod skips the\n // bookkeeping. Either way the report flows through `_onBindingError`\n // when wired (agent setups), else falls back to console.error so\n // operators see the cause.\n const wrapped =\n componentName !== null && e instanceof Error\n ? enhanceBindingError(e, binding, componentName)\n : null\n const err = wrapped ?? (e instanceof Error ? e : new Error(String(e)))\n const stack = err.stack ? err.stack.split('\\n').slice(0, 8).join('\\n') : undefined\n const info =\n stack !== undefined\n ? { kind: String(binding.kind), key: binding.key, message: err.message, stack }\n : { kind: String(binding.kind), key: binding.key, message: err.message }\n\n if (onBindingError !== undefined) {\n try {\n onBindingError(info)\n } catch {\n // hook itself threw; fall through to console\n }\n } else if (typeof console !== 'undefined') {\n // Dev mode shows the wrapped (richer) message. Prod shows a brief\n // line — operators still see something but without the full source\n // hint that's only useful at development time.\n if (componentName !== null) {\n console.error(err)\n } else if (typeof console.warn === 'function') {\n console.warn(\n `[llui] binding accessor threw (kind=${info.kind}${info.key ? `, key=${info.key}` : ''}): ${info.message}`,\n )\n }\n }\n}\n\nfunction enhanceBindingError(err: unknown, binding: Binding, componentName: string): Error {\n // For text bindings, binding.node is the Text node — use its parent element.\n const node = binding.node\n const target = node.nodeType === 1 ? (node as Element) : (node.parentElement ?? null)\n let nodeDesc = '?'\n if (target) {\n const id = target.id ? `#${target.id}` : ''\n const cls =\n target.className && typeof target.className === 'string'\n ? `.${target.className.split(' ').filter(Boolean).slice(0, 2).join('.')}`\n : ''\n nodeDesc = `<${target.tagName.toLowerCase()}${id}${cls}>`\n if (node.nodeType === 3) nodeDesc += ' text-child'\n else if (node.nodeType === 8) nodeDesc += ' comment-child'\n }\n const keyPart = binding.key ? ` .${binding.key}` : ''\n const errMsg = err instanceof Error ? err.message : String(err)\n\n // Build accessor source hint if available\n let accessorHint = ''\n try {\n const src = binding.accessor.toString().slice(0, 80)\n accessorHint = `\\n accessor: ${src}${binding.accessor.toString().length > 80 ? '...' : ''}`\n } catch {\n // toString() may throw on revoked proxies, etc.\n }\n\n // Detect common undefined/null access pattern and add a helpful hint\n let undefinedHint = ''\n if (err instanceof TypeError && /Cannot read propert(ies|y).*of (undefined|null)/.test(errMsg)) {\n undefinedHint =\n '\\n hint: Check that your accessor handles undefined state fields (e.g., use optional chaining: s.user?.name)'\n }\n\n const wrapped = new Error(\n `[LLui] ${binding.kind}${keyPart} binding on ${nodeDesc} — accessor threw in <${componentName}>\\n` +\n ` ↳ ${errMsg}` +\n undefinedHint +\n accessorHint,\n err instanceof Error ? { cause: err } : undefined,\n )\n wrapped.stack = (err instanceof Error && err.stack) || wrapped.stack\n return wrapped\n}\n\nfunction dispatchEffect<S, M, E>(inst: ComponentInstance<S, M, E>, effect: E): void {\n const eff = effect as Record<string, unknown>\n\n // Addressed effects — dispatch to target component\n if (eff.__addressed === true && typeof eff.__targetKey !== 'undefined') {\n addressedDispatcher?.(eff as { __targetKey: string | number; __msg: unknown })\n return\n }\n\n // Built-in: delay\n if (eff.type === 'delay') {\n const ms = eff.ms as number\n const onDone = eff.onDone as M\n setTimeout(() => inst.send(onDone), ms)\n return\n }\n\n // Built-in: log\n if (eff.type === 'log') {\n console.log(eff.message)\n return\n }\n\n // Dev-only: record on the timeline / consult the mock registry.\n // Short-circuits real dispatch when a mock matches. Zero cost in\n // production — the guard on `_effectTimeline` is undefined unless\n // `installDevTools` populated the trackers.\n if (inst._effectTimeline !== undefined && dispatchEffectDev(inst, effect)) return\n\n // User onEffect handler\n if (inst.def.onEffect) {\n inst.def.onEffect({ effect, send: inst.send, signal: inst.signal })\n }\n}\n\n/**\n * Dev-only effect dispatch wrapper. Records the `dispatched` phase and,\n * when a mock matches, auto-delivers the mocked response through the\n * effect's own `onSuccess` callback on a microtask (same timing contract\n * as a real async resolve). Non-matched effects are tracked as pending\n * so `llui_pending_effects` / `llui_resolve_effect` can observe them.\n *\n * @returns `true` when a mock matched (caller should skip the real\n * dispatch) or `false` to proceed with the user-provided onEffect.\n */\nfunction dispatchEffectDev<S, M, E>(inst: ComponentInstance<S, M, E>, effect: E): boolean {\n const timeline = inst._effectTimeline\n if (timeline === undefined) return false\n\n const eff = effect as Record<string, unknown>\n const id = newEffectId()\n const type = typeof eff.type === 'string' ? eff.type : '<unknown>'\n const dispatchedAt = Date.now()\n\n const mock = inst._effectMocks?.match(effect)\n if (mock) {\n timeline.push({ effectId: id, type, phase: 'dispatched', timestamp: dispatchedAt })\n // Auto-deliver the mocked response via the effect's onSuccess callback (if any).\n // This mirrors what the real dispatch would do, so the component receives a Msg\n // from the mocked effect without any network/IO happening.\n const payload = effect as Record<string, unknown>\n if (typeof payload.onSuccess === 'function') {\n const msg = (payload.onSuccess as (d: unknown) => unknown)(mock.response)\n // Schedule delivery as a microtask so it runs after the current update\n // cycle completes (same timing contract as a real async effect resolve).\n Promise.resolve().then(() => inst.send(msg as never))\n }\n timeline.push({\n effectId: id,\n type,\n phase: 'resolved-mocked',\n timestamp: dispatchedAt,\n durationMs: 0,\n })\n return true\n }\n\n timeline.push({ effectId: id, type, phase: 'dispatched', timestamp: dispatchedAt })\n inst._pendingEffects?.push({ id, type, dispatchedAt, status: 'queued', payload: effect })\n return false\n}\n\nfunction newEffectId(): string {\n const cryptoObj = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto\n if (cryptoObj?.randomUUID) return cryptoObj.randomUUID()\n return `eff-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`\n}\n"]}
1
+ {"version":3,"file":"update-loop.js","sourceRoot":"","sources":["../src/update-loop.ts"],"names":[],"mappings":"AAKA,OAAO,EAAe,UAAU,EAAE,MAAM,cAAc,CAAA;AAEtD,oEAAoE;AACpE,sEAAsE;AACtE,mEAAmE;AACnE,IAAI,YAAY,GAAkB,IAAI,CAAA;AACtC,SAAS,kBAA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C;IAED,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAA;IACnF,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;IACzF,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,WAAW;IAClB,MAAM,SAAS,GAAI,UAAyD,CAAC,MAAM,CAAA;IACnF,IAAI,SAAS,EAAE,UAAU;QAAE,OAAO,SAAS,CAAC,UAAU,EAAE,CAAA;IACxD,OAAO,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAA;AACvE,CAAC","sourcesContent":["import type { ComponentDef, Lifetime, Binding } from './types.js'\nimport type { StructuralBlock } from './structural.js'\nimport type { RingBuffer, EachDiff } from './tracking/each-diff.js'\nimport type { DisposerEvent } from './tracking/disposer-log.js'\nimport type { CoverageTracker } from './tracking/coverage.js'\nimport { type DomEnv, browserEnv } from './dom-env.js'\n\n// Single lazily-constructed browser env shared by every client-side\n// component instance. Falls through to globalThis at call time — safe\n// to construct on a server process (the lookups never fire there).\nlet _fallbackEnv: DomEnv | null = null\nfunction fallbackBrowserEnv(): DomEnv {\n if (_fallbackEnv === null) _fallbackEnv = browserEnv()\n return _fallbackEnv\n}\nimport type {\n EffectTimelineEntry,\n PendingEffectsList,\n MockRegistry,\n} from './tracking/effect-timeline.js'\nimport { createLifetime } from './lifetime.js'\nimport { applyBinding } from './binding.js'\nimport { setCurrentDirtyMask } from './primitives/memo.js'\nimport { enterAccessor, exitAccessor } from './render-context.js'\n\nexport const FULL_MASK = 0xffffffff | 0\n\n// Addressed effect dispatcher — set by addressed.ts when imported\nlet addressedDispatcher: ((eff: { __targetKey: string | number; __msg: unknown }) => void) | null =\n null\n\nexport function setAddressedDispatcher(\n fn: (eff: { __targetKey: string | number; __msg: unknown }) => void,\n): void {\n addressedDispatcher = fn\n}\n\nexport interface ComponentInstance<S = unknown, M = unknown, E = unknown> {\n def: ComponentDef<S, M, E>\n state: S\n initialEffects: E[]\n rootLifetime: Lifetime\n dom: DomEnv\n allBindings: Binding[]\n structuralBlocks: StructuralBlock[]\n queue: M[]\n microtaskScheduled: boolean\n lastDirtyMask: number\n lastEffects: E[]\n send: (msg: M) => void\n signal: AbortSignal\n abortController: AbortController\n /** @internal dev-only — populated when `installDevTools` ran. Ring-buffered\n * per-each-site reconciliation diffs for MCP introspection tools. */\n _eachDiffLog?: RingBuffer<EachDiff>\n /** @internal dev-only — monotonically incremented by the devtools-intercepted\n * `update` before each history push. Read by `each.ts` to stamp diffs with\n * the `updateIndex` of the message that caused the reconciliation. */\n _updateCounter?: number\n /** @internal dev-only — populated when `installDevTools` ran. Ring-buffered\n * log of `disposeLifetime` firings (scope id + cause). Consumed by the\n * `llui_disposer_log` MCP tool to diagnose leaks on structural transitions. */\n _disposerLog?: RingBuffer<DisposerEvent>\n /** @internal dev-only — populated when `installDevTools` ran. Per-variant\n * Msg counter keyed by discriminant. Consumed by the `llui_coverage` MCP\n * tool to surface Msg variants that have never fired this session. */\n _coverage?: CoverageTracker\n /** @internal dev-only — populated when `installDevTools` ran. Ring-buffered\n * effect dispatch phase log (dispatched → resolved/cancelled) for USER\n * effects emitted from `update()`. Consumed by the `llui_effect_timeline`\n * MCP tool. Built-in plumbing effects (`delay`, `log`, addressed) are NOT\n * recorded here by design — they short-circuit in `dispatchEffect` before\n * `dispatchEffectDev` runs. They're runtime plumbing, not user intent,\n * and surface via other channels (message queue for `delay`, browser\n * console for `log`, addressed-target routing for addressed effects). */\n _effectTimeline?: RingBuffer<EffectTimelineEntry>\n /** @internal dev-only — populated when `installDevTools` ran. List of\n * currently-pending effects addressable by id, consumed by the\n * `llui_pending_effects` MCP tool. */\n _pendingEffects?: PendingEffectsList\n /** @internal dev-only — populated when `installDevTools` ran. Mock\n * registry consulted by the effect-dispatch wrapper to short-circuit\n * matching effects. Consumed by the `llui_mock_effect` MCP tool. */\n _effectMocks?: MockRegistry\n /**\n * @internal — set by mountApp/mountAtAnchor/hydrateApp/hydrateAtAnchor\n * to fire AppHandle.subscribe listeners after every update cycle.\n * Undefined until the first subscriber registers.\n */\n _onCommit?: (state: unknown) => void\n /**\n * @internal — optional hook invoked when a binding's accessor throws\n * during Phase 2. The runtime catches the throw, leaves the binding's\n * `lastValue` unchanged (so the rendered DOM stays at its previous\n * value rather than going blank), and notifies this hook. The agent\n * factory wires it to drain.errors so the LLM sees that some bindings\n * failed; non-agent hosts can leave it undefined for the default\n * console-warn behavior.\n *\n * Why catch + continue instead of letting the throw propagate?\n * One bad binding shouldn't abort the entire update loop — sibling\n * bindings on the same commit are independent and have no business\n * going stale because a different binding crashed. The user-visible\n * effect: when one cell's accessor throws (e.g. scoring fails on a\n * malformed criterion), every other cell still renders correctly;\n * only the broken binding shows its previous value.\n */\n _onBindingError?: (info: { kind: string; key?: string; message: string; stack?: string }) => void\n /**\n * @internal — live registry of currently-mounted Msg variants\n * dispatchable from rendered UI. Lazily allocated when the first\n * compiler-tagged event handler binds. Read by the agent layer (via\n * `AppHandle.getBindingDescriptors()`) to surface live affordances\n * to the LLM. See `binding-descriptors.ts` for the registration\n * protocol and `@llui/vite-plugin`'s tagger pass for the tag emission.\n */\n _bindingDescriptors?: import('./binding-descriptors.js').BindingDescriptorRegistry\n}\n\nexport function createComponentInstance<S, M, E, D = void>(\n def: ComponentDef<S, M, E, D>,\n data?: D,\n parentLifetime: Lifetime | null = null,\n dom?: DomEnv,\n): ComponentInstance<S, M, E> {\n const [initialState, initialEffects] = def.init(data as D)\n\n const controller = new AbortController()\n\n const inst: ComponentInstance<S, M, E> = {\n // `def` carries an arbitrary `D` for typed init data, but after init\n // has run the runtime never touches `def.init` again — update/view/\n // onEffect and HMR replacement don't depend on D. Cast to the\n // D=void instance storage shape here.\n def: def as ComponentDef<S, M, E>,\n state: initialState,\n initialEffects,\n // Caller-supplied DOM env. `mountApp` defaults this to `browserEnv()`;\n // `renderToString` passes the user's jsdom/linkedom env. Never null —\n // every primitive reads from inst.dom.\n dom: dom ?? fallbackBrowserEnv(),\n // When `parentLifetime` is provided the instance's rootLifetime becomes a\n // child of that scope. This is how persistent layouts wire pages\n // into the layout's scope tree: the page's rootLifetime is parented at\n // the layout's pageSlot() point so `useContext` lookups flow layout\n // → page, and scope disposal cascades correctly. Mount paths that\n // don't pass parentLifetime get the classic detached root.\n rootLifetime: createLifetime(parentLifetime),\n allBindings: [],\n structuralBlocks: [],\n queue: [],\n microtaskScheduled: false,\n lastDirtyMask: 0,\n lastEffects: [],\n signal: controller.signal,\n abortController: controller,\n\n send(msg: M) {\n inst.queue.push(msg)\n if (!inst.microtaskScheduled) {\n inst.microtaskScheduled = true\n queueMicrotask(() => {\n inst.microtaskScheduled = false\n processMessages(inst)\n })\n }\n },\n }\n\n inst.rootLifetime._kind = 'root'\n\n return inst\n}\n\nexport function flushInstance<S, M, E>(inst: ComponentInstance<S, M, E>): void {\n if (inst.queue.length === 0) return\n inst.microtaskScheduled = false\n processMessages(inst)\n}\n\n/**\n * Dev-only: overwrite instance state and re-run both phases with FULL_MASK\n * so every binding re-evaluates. Bypasses update() — use for devtools\n * snapshot/restore, not in app code.\n */\nexport function _forceState<S, M, E>(inst: ComponentInstance<S, M, E>, newState: S): void {\n inst.state = newState\n inst.lastDirtyMask = FULL_MASK\n\n const bindings = inst.allBindings\n const bindingsBeforePhase1 = bindings.length\n\n setCurrentDirtyMask(FULL_MASK)\n\n const snapshot = inst.structuralBlocks.slice()\n for (const block of snapshot) {\n try {\n block.reconcile(newState, FULL_MASK)\n } catch (e) {\n reportReconcileError(inst, e)\n }\n }\n\n let phase2Len = bindingsBeforePhase1\n if (bindings.length > bindingsBeforePhase1 || (phase2Len > 0 && bindings[0]!.dead)) {\n let w = 0\n for (let r = 0; r < bindings.length; r++) {\n if (!bindings[r]!.dead) bindings[w++] = bindings[r]!\n }\n bindings.length = w\n phase2Len = Math.min(w, bindingsBeforePhase1)\n }\n\n const state = inst.state\n enterAccessor('a binding accessor')\n try {\n for (let i = 0, len = phase2Len; i < len; i++) {\n const binding = bindings[i]!\n if (binding.dead) continue\n if (binding.kind === 'effect') {\n try {\n binding.accessor(state)\n } catch (e) {\n reportBindingError(inst, binding, e)\n }\n continue\n }\n let newValue: unknown\n try {\n newValue = binding.accessor(state)\n } catch (e) {\n // Accessor threw — leave the binding's `lastValue` unchanged so\n // the rendered DOM stays at its previous value rather than going\n // blank. Sibling bindings on the same commit continue to\n // evaluate. The error surfaces via the optional hook (or\n // console.warn as a fallback) so it isn't silently swallowed.\n reportBindingError(inst, binding, e)\n continue\n }\n if (Object.is(newValue, binding.lastValue)) continue\n binding.lastValue = newValue\n try {\n applyBinding(binding, newValue)\n } catch (e) {\n // applyBinding writes the value to the DOM (textContent,\n // setAttribute, etc.). Throws here are usually environmental\n // (a node was removed mid-flight by a sibling binding). Same\n // contract: report and continue.\n reportBindingError(inst, binding, e)\n }\n }\n } finally {\n exitAccessor()\n }\n}\n\nfunction reportBindingError<S, M, E>(\n inst: ComponentInstance<S, M, E>,\n binding: Binding,\n e: unknown,\n): void {\n const err = e instanceof Error ? e : new Error(String(e))\n const stack = err.stack ? err.stack.split('\\n').slice(0, 8).join('\\n') : undefined\n const info =\n stack !== undefined\n ? {\n kind: String(binding.kind),\n key: binding.key,\n message: `${err.name}: ${err.message}`,\n stack,\n }\n : { kind: String(binding.kind), key: binding.key, message: `${err.name}: ${err.message}` }\n if (inst._onBindingError !== undefined) {\n try {\n inst._onBindingError(info)\n } catch {\n // The hook itself threw — nothing to do; we're in a recovery\n // path already. Fall through to the console fallback.\n }\n } else if (typeof console !== 'undefined' && typeof console.warn === 'function') {\n console.warn(\n `[llui] binding accessor threw (kind=${info.kind}${info.key ? `, key=${info.key}` : ''}): ${info.message}`,\n )\n }\n}\n\n/**\n * Phase 1 (structural reconcile) parallel of `reportBindingError`. A\n * `block.reconcile` throw — most often a misuse like `sample()` inside an\n * `each().key` accessor — would otherwise escape the update loop, kill the\n * remaining structural blocks AND the entire Phase 2 binding pass on this\n * commit, and (in real apps) surface as an unhandled microtask rejection\n * the developer never sees. Routing it through the same `_onBindingError`\n * channel that Phase 2 uses gives parity: the error is named, surfaced\n * once, and the rest of the update continues.\n *\n * Note: a partial DOM mutation on the failing block is NOT rolled back.\n * The block's reconcile is responsible for keeping the DOM in a consistent\n * state on its own happy path; if it throws mid-mutation, the visible\n * result may be an inconsistent block, but sibling blocks and bindings\n * still update correctly.\n */\nfunction reportReconcileError<S, M, E>(inst: ComponentInstance<S, M, E>, e: unknown): void {\n const err = e instanceof Error ? e : new Error(String(e))\n const stack = err.stack ? err.stack.split('\\n').slice(0, 8).join('\\n') : undefined\n const info =\n stack !== undefined\n ? { kind: 'reconcile', message: `${err.name}: ${err.message}`, stack }\n : { kind: 'reconcile', message: `${err.name}: ${err.message}` }\n if (inst._onBindingError !== undefined) {\n try {\n inst._onBindingError(info)\n } catch {\n // hook itself threw; fall through to console\n }\n } else if (typeof console !== 'undefined' && typeof console.error === 'function') {\n // Reconcile errors are programmer errors (almost always: sample-in-\n // accessor or a thrown structural primitive). Surface as `error` not\n // `warn` so they're not lost in noisy dev consoles.\n console.error(`[llui] structural reconcile threw: ${info.message}`)\n }\n}\n\nfunction processMessages<S, M, E>(inst: ComponentInstance<S, M, E>): void {\n const queue = inst.queue\n\n // Single-message fast path: dispatch directly to per-message-type handler\n // if available. Skips dirty computation, Phase 1/2 entirely.\n if (queue.length === 1 && inst.def.__handlers) {\n const msg = queue[0]!\n const handler = inst.def.__handlers[(msg as Record<string, unknown>).type as string] as\n | ((inst: ComponentInstance, msg: unknown) => [S, E[]])\n | undefined\n if (handler) {\n queue.length = 0\n const [newState, effects] = handler(inst as ComponentInstance, msg)\n inst.state = newState\n inst._onCommit?.(newState as unknown)\n if (import.meta.env?.DEV) {\n inst.lastDirtyMask = FULL_MASK\n inst.lastEffects = effects\n }\n for (let i = 0; i < effects.length; i++) {\n dispatchEffect(inst, effects[i]!)\n }\n return\n }\n }\n\n // Generic pipeline — drain queue, accumulate dirty bits\n let state = inst.state\n let combinedDirty = 0\n const allEffects: E[] = []\n\n const defUpdate = inst.def.update\n const dirtyFn = inst.def.__dirty\n for (let qi = 0; qi < queue.length; qi++) {\n const msg = queue[qi]!\n const [newState, effects] = defUpdate(state, msg)\n const dirty = dirtyFn ? dirtyFn(state, newState) : FULL_MASK\n if (typeof dirty === 'number') {\n combinedDirty |= dirty\n } else {\n combinedDirty |= dirty[0] | dirty[1]\n }\n state = newState\n // Avoid spread — allocates an iterator per call. For typical effect\n // arrays (0-2 elements) this is a minor saving; for bursts it matters.\n for (let ei = 0; ei < effects.length; ei++) allEffects.push(effects[ei]!)\n }\n queue.length = 0\n\n inst.state = state\n inst._onCommit?.(state as unknown)\n // Dev-only bookkeeping — tests read lastDirtyMask/lastEffects, prod\n // doesn't. Gating here keeps two writes out of the prod hot path.\n if (import.meta.env?.DEV) {\n inst.lastDirtyMask = combinedDirty\n inst.lastEffects = allEffects\n }\n\n // Snapshot binding count before Phase 1 — bindings added during\n // Phase 1 already have correct initial values and skip Phase 2.\n const bindings = inst.allBindings\n const bindingsBeforePhase1 = bindings.length\n\n // Set current dirty mask BEFORE Phase 1 so memo() accessors used in\n // structural primitives (e.g. each.items) can use the bitmask fast path.\n setCurrentDirtyMask(combinedDirty)\n\n if (inst.def.__update) {\n // Compiler-generated fast path — replaces generic Phase 1 + Phase 2\n inst.def.__update(state, combinedDirty, bindings, inst.structuralBlocks, bindingsBeforePhase1)\n } else {\n // Generic Phase 1 + Phase 2 fallback (uncompiled components)\n genericUpdate(inst, state, combinedDirty, bindings, bindingsBeforePhase1)\n }\n\n // Dispatch effects after DOM updates\n for (let i = 0; i < allEffects.length; i++) {\n dispatchEffect(inst, allEffects[i]!)\n }\n}\n\nfunction genericUpdate<S, M, E>(\n inst: ComponentInstance<S, M, E>,\n state: S,\n combinedDirty: number,\n bindings: Binding[],\n bindingsBeforePhase1: number,\n): void {\n // Phase 1 — structural reconciliation. Structural primitives register\n // their blocks BEFORE running builders, so parents precede their nested\n // children in this array. That ordering matters: a parent's reconcile\n // may dispose the old arm, whose disposers splice nested child blocks\n // out of this shared array. Because children are always to the right\n // of their parent, the splice shifts entries left — which is safe for\n // a forward iterator that re-reads length each step.\n const blocks = inst.structuralBlocks\n for (let bi = 0; bi < blocks.length; bi++) {\n const block = blocks[bi]\n if (!block || (block.mask & combinedDirty) === 0) continue\n try {\n block.reconcile(state, combinedDirty)\n } catch (e) {\n reportReconcileError(inst, e)\n }\n }\n\n // Phase 2 — compact + update bindings\n _runPhase2(\n state,\n combinedDirty,\n bindings,\n bindingsBeforePhase1,\n inst.def.name,\n inst._onBindingError,\n )\n}\n\n/**\n * Run a handler for a single message: call update(), reconcile blocks\n * with the given method, run Phase 2. Used by compiler-generated __handlers\n * to avoid duplicating boilerplate per message type.\n *\n * @param method 0=reconcile, 1=reconcileItems, 2=reconcileClear, 3=reconcileRemove, -1=skip blocks\n * @public — used by compiler-generated `__handlers`\n */\nexport function _handleMsg(\n inst: ComponentInstance,\n msg: unknown,\n dirty: number,\n method: number,\n): [unknown, unknown[]] {\n const [s, e] = (inst.def.update as (s: unknown, m: unknown) => [unknown, unknown[]])(\n inst.state,\n msg,\n )\n inst.state = s\n inst._onCommit?.(s)\n\n // memo()-wrapped accessors (auto-generated by the compiler for\n // multi-field structural accessors like each.items / branch.on /\n // show.when) gate on `currentDirtyMask`. The generic pipeline sets\n // it before Phase 1; the single-message fast path must as well, or\n // memo short-circuits with the stale value left over from the\n // previous cycle and structural blocks reconcile against a frozen\n // input.\n setCurrentDirtyMask(dirty)\n\n if (method >= 0) {\n const bl = inst.structuralBlocks\n for (let i = 0; i < bl.length; i++) {\n const block = bl[i]\n if (!block || !(block.mask & dirty)) continue\n try {\n // Specialized methods (`reconcileItems`, `reconcileClear`,\n // `reconcileRemove`, `reconcileChanged`) only exist on `each`\n // blocks. Non-each blocks (`show`, `branch`, `scope`) leave\n // them undefined. The compiler-side fix in `detectArrayOp`\n // already restricts these methods to single-field cases, but\n // a show()/branch() block whose mask intersects the cleared\n // field would still be silently skipped without this fallback.\n // When the specialized method is missing, run the general\n // `reconcile` path so the block's `when`/`on` accessor still\n // re-evaluates. each blocks always have the specialized\n // methods, so they keep their fast path.\n switch (method) {\n case 0:\n block.reconcile(s, dirty)\n break\n case 1:\n if (block.reconcileItems) block.reconcileItems(s)\n else block.reconcile(s, dirty)\n break\n case 2:\n if (block.reconcileClear) block.reconcileClear()\n else block.reconcile(s, dirty)\n break\n case 3:\n if (block.reconcileRemove) block.reconcileRemove(s)\n else block.reconcile(s, dirty)\n break\n default:\n // method >= 10: reconcileChanged with stride = method - 10\n if (method >= 10) {\n if (block.reconcileChanged) block.reconcileChanged(s, method - 10)\n else block.reconcile(s, dirty)\n }\n break\n }\n } catch (err) {\n reportReconcileError(inst, err)\n // continue to next block — see reportReconcileError docstring\n }\n }\n }\n\n const b = inst.allBindings\n _runPhase2(s, dirty, b, b.length, inst.def.name, inst._onBindingError)\n return [s, e]\n}\n\n/**\n * Phase 2: compact dead bindings + update live bindings.\n * Shared between genericUpdate and compiler-generated __update.\n * @public — used by compiler-generated `__update` functions\n */\nexport function _runPhase2(\n state: unknown,\n dirty: number,\n bindings: Binding[],\n bindingsBeforePhase1: number,\n componentName?: string,\n // Optional `_onBindingError` hook. Type is duplicated here rather\n // than referenced as `ComponentInstance['_onBindingError']` because\n // the underlying field is `@internal` — stripped from the generated\n // `.d.ts` — and a public-export signature can't depend on a stripped\n // type without breaking dependent packages' typecheck.\n onBindingError?: (info: { kind: string; key?: string; message: string; stack?: string }) => void,\n): void {\n let phase2Len = bindingsBeforePhase1\n if (bindings.length > bindingsBeforePhase1 || (phase2Len > 0 && bindings[0]!.dead)) {\n let w = 0\n for (let r = 0; r < bindings.length; r++) {\n if (!bindings[r]!.dead) bindings[w++] = bindings[r]!\n }\n bindings.length = w\n phase2Len = Math.min(w, bindingsBeforePhase1)\n }\n\n if (dirty !== 0) {\n // Always catch+continue: a single accessor throw shouldn't abort\n // the rest of the bindings on the same commit. The user-visible\n // effect: a broken cell shows its previous value; sibling cells\n // stay current. In dev mode, the wrapped error (with component\n // name, kind, node descriptor, accessor source) is forwarded via\n // the `_onBindingError` hook (agent integration) or to\n // `console.error` (dev harness without an agent). The prior\n // behavior of rethrowing from `flush()` made one bad binding\n // visually break the entire view — the worst-case UX.\n const isDev = import.meta.env?.DEV && componentName\n // Single accessor label for the entire Phase 2 loop. The binding kind is\n // already part of the error message that handleBindingThrow surfaces; the\n // accessor label here serves the more specific purpose of catching\n // sample() calls reaching for a render context that isn't set during\n // the update phase. A `binding accessor` label is generic enough to apply\n // to text/attr/class/effect bindings without per-kind branching.\n enterAccessor('a binding accessor')\n try {\n for (let i = 0, len = phase2Len; i < len; i++) {\n const binding = bindings[i]!\n if (binding.dead || (binding.mask & dirty) === 0) continue\n if (binding.kind === 'effect') {\n try {\n binding.accessor(state)\n } catch (e) {\n handleBindingThrow(onBindingError, binding, e, isDev ? componentName : null)\n }\n continue\n }\n let newValue: unknown\n try {\n newValue = binding.accessor(state)\n } catch (e) {\n handleBindingThrow(onBindingError, binding, e, isDev ? componentName : null)\n continue\n }\n const last = binding.lastValue\n if (newValue === last || (newValue !== newValue && last !== last)) continue\n binding.lastValue = newValue\n try {\n applyBinding(binding, newValue)\n } catch (e) {\n handleBindingThrow(onBindingError, binding, e, isDev ? componentName : null)\n }\n }\n } finally {\n exitAccessor()\n }\n }\n}\n\nfunction handleBindingThrow(\n onBindingError: ComponentInstance['_onBindingError'] | undefined,\n binding: Binding,\n e: unknown,\n componentName: string | null,\n): void {\n // Dev mode: build the rich wrapped error (with accessor source,\n // node descriptor, undefined-hint detection). Prod skips the\n // bookkeeping. Either way the report flows through `_onBindingError`\n // when wired (agent setups), else falls back to console.error so\n // operators see the cause.\n const wrapped =\n componentName !== null && e instanceof Error\n ? enhanceBindingError(e, binding, componentName)\n : null\n const err = wrapped ?? (e instanceof Error ? e : new Error(String(e)))\n const stack = err.stack ? err.stack.split('\\n').slice(0, 8).join('\\n') : undefined\n const info =\n stack !== undefined\n ? { kind: String(binding.kind), key: binding.key, message: err.message, stack }\n : { kind: String(binding.kind), key: binding.key, message: err.message }\n\n if (onBindingError !== undefined) {\n try {\n onBindingError(info)\n } catch {\n // hook itself threw; fall through to console\n }\n } else if (typeof console !== 'undefined') {\n // Dev mode shows the wrapped (richer) message. Prod shows a brief\n // line — operators still see something but without the full source\n // hint that's only useful at development time.\n if (componentName !== null) {\n console.error(err)\n } else if (typeof console.warn === 'function') {\n console.warn(\n `[llui] binding accessor threw (kind=${info.kind}${info.key ? `, key=${info.key}` : ''}): ${info.message}`,\n )\n }\n }\n}\n\nfunction enhanceBindingError(err: unknown, binding: Binding, componentName: string): Error {\n // For text bindings, binding.node is the Text node — use its parent element.\n const node = binding.node\n const target = node.nodeType === 1 ? (node as Element) : (node.parentElement ?? null)\n let nodeDesc = '?'\n if (target) {\n const id = target.id ? `#${target.id}` : ''\n const cls =\n target.className && typeof target.className === 'string'\n ? `.${target.className.split(' ').filter(Boolean).slice(0, 2).join('.')}`\n : ''\n nodeDesc = `<${target.tagName.toLowerCase()}${id}${cls}>`\n if (node.nodeType === 3) nodeDesc += ' text-child'\n else if (node.nodeType === 8) nodeDesc += ' comment-child'\n }\n const keyPart = binding.key ? ` .${binding.key}` : ''\n const errMsg = err instanceof Error ? err.message : String(err)\n\n // Build accessor source hint if available\n let accessorHint = ''\n try {\n const src = binding.accessor.toString().slice(0, 80)\n accessorHint = `\\n accessor: ${src}${binding.accessor.toString().length > 80 ? '...' : ''}`\n } catch {\n // toString() may throw on revoked proxies, etc.\n }\n\n // Detect common undefined/null access pattern and add a helpful hint\n let undefinedHint = ''\n if (err instanceof TypeError && /Cannot read propert(ies|y).*of (undefined|null)/.test(errMsg)) {\n undefinedHint =\n '\\n hint: Check that your accessor handles undefined state fields (e.g., use optional chaining: s.user?.name)'\n }\n\n const wrapped = new Error(\n `[LLui] ${binding.kind}${keyPart} binding on ${nodeDesc} — accessor threw in <${componentName}>\\n` +\n ` ↳ ${errMsg}` +\n undefinedHint +\n accessorHint,\n err instanceof Error ? { cause: err } : undefined,\n )\n wrapped.stack = (err instanceof Error && err.stack) || wrapped.stack\n return wrapped\n}\n\nfunction dispatchEffect<S, M, E>(inst: ComponentInstance<S, M, E>, effect: E): void {\n const eff = effect as Record<string, unknown>\n\n // Addressed effects — dispatch to target component\n if (eff.__addressed === true && typeof eff.__targetKey !== 'undefined') {\n addressedDispatcher?.(eff as { __targetKey: string | number; __msg: unknown })\n return\n }\n\n // Built-in: delay\n if (eff.type === 'delay') {\n const ms = eff.ms as number\n const onDone = eff.onDone as M\n setTimeout(() => inst.send(onDone), ms)\n return\n }\n\n // Built-in: log\n if (eff.type === 'log') {\n console.log(eff.message)\n return\n }\n\n // Dev-only: record on the timeline / consult the mock registry.\n // Short-circuits real dispatch when a mock matches. Zero cost in\n // production — the guard on `_effectTimeline` is undefined unless\n // `installDevTools` populated the trackers.\n if (inst._effectTimeline !== undefined && dispatchEffectDev(inst, effect)) return\n\n // User onEffect handler\n if (inst.def.onEffect) {\n inst.def.onEffect({ effect, send: inst.send, signal: inst.signal })\n }\n}\n\n/**\n * Dev-only effect dispatch wrapper. Records the `dispatched` phase and,\n * when a mock matches, auto-delivers the mocked response through the\n * effect's own `onSuccess` callback on a microtask (same timing contract\n * as a real async resolve). Non-matched effects are tracked as pending\n * so `llui_pending_effects` / `llui_resolve_effect` can observe them.\n *\n * @returns `true` when a mock matched (caller should skip the real\n * dispatch) or `false` to proceed with the user-provided onEffect.\n */\nfunction dispatchEffectDev<S, M, E>(inst: ComponentInstance<S, M, E>, effect: E): boolean {\n const timeline = inst._effectTimeline\n if (timeline === undefined) return false\n\n const eff = effect as Record<string, unknown>\n const id = newEffectId()\n const type = typeof eff.type === 'string' ? eff.type : '<unknown>'\n const dispatchedAt = Date.now()\n\n const mock = inst._effectMocks?.match(effect)\n if (mock) {\n timeline.push({ effectId: id, type, phase: 'dispatched', timestamp: dispatchedAt })\n // Auto-deliver the mocked response via the effect's onSuccess callback (if any).\n // This mirrors what the real dispatch would do, so the component receives a Msg\n // from the mocked effect without any network/IO happening.\n const payload = effect as Record<string, unknown>\n if (typeof payload.onSuccess === 'function') {\n const msg = (payload.onSuccess as (d: unknown) => unknown)(mock.response)\n // Schedule delivery as a microtask so it runs after the current update\n // cycle completes (same timing contract as a real async effect resolve).\n Promise.resolve().then(() => inst.send(msg as never))\n }\n timeline.push({\n effectId: id,\n type,\n phase: 'resolved-mocked',\n timestamp: dispatchedAt,\n durationMs: 0,\n })\n return true\n }\n\n timeline.push({ effectId: id, type, phase: 'dispatched', timestamp: dispatchedAt })\n inst._pendingEffects?.push({ id, type, dispatchedAt, status: 'queued', payload: effect })\n return false\n}\n\nfunction newEffectId(): string {\n const cryptoObj = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto\n if (cryptoObj?.randomUUID) return cryptoObj.randomUUID()\n return `eff-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llui/dom",
3
- "version": "0.0.36",
3
+ "version": "0.0.38",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {