@llui/dom 0.0.34 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,7 @@ function fallbackBrowserEnv() {
11
11
  import { createLifetime } from './lifetime.js';
12
12
  import { applyBinding } from './binding.js';
13
13
  import { setCurrentDirtyMask } from './primitives/memo.js';
14
+ import { enterAccessor, exitAccessor } from './render-context.js';
14
15
  export const FULL_MASK = 0xffffffff | 0;
15
16
  // Addressed effect dispatcher — set by addressed.ts when imported
16
17
  let addressedDispatcher = null;
@@ -80,7 +81,12 @@ export function _forceState(inst, newState) {
80
81
  setCurrentDirtyMask(FULL_MASK);
81
82
  const snapshot = inst.structuralBlocks.slice();
82
83
  for (const block of snapshot) {
83
- block.reconcile(newState, FULL_MASK);
84
+ try {
85
+ block.reconcile(newState, FULL_MASK);
86
+ }
87
+ catch (e) {
88
+ reportReconcileError(inst, e);
89
+ }
84
90
  }
85
91
  let phase2Len = bindingsBeforePhase1;
86
92
  if (bindings.length > bindingsBeforePhase1 || (phase2Len > 0 && bindings[0].dead)) {
@@ -93,46 +99,52 @@ export function _forceState(inst, newState) {
93
99
  phase2Len = Math.min(w, bindingsBeforePhase1);
94
100
  }
95
101
  const state = inst.state;
96
- for (let i = 0, len = phase2Len; i < len; i++) {
97
- const binding = bindings[i];
98
- if (binding.dead)
99
- continue;
100
- if (binding.kind === 'effect') {
102
+ enterAccessor('a binding accessor');
103
+ try {
104
+ for (let i = 0, len = phase2Len; i < len; i++) {
105
+ const binding = bindings[i];
106
+ if (binding.dead)
107
+ continue;
108
+ if (binding.kind === 'effect') {
109
+ try {
110
+ binding.accessor(state);
111
+ }
112
+ catch (e) {
113
+ reportBindingError(inst, binding, e);
114
+ }
115
+ continue;
116
+ }
117
+ let newValue;
101
118
  try {
102
- binding.accessor(state);
119
+ newValue = binding.accessor(state);
103
120
  }
104
121
  catch (e) {
122
+ // Accessor threw — leave the binding's `lastValue` unchanged so
123
+ // the rendered DOM stays at its previous value rather than going
124
+ // blank. Sibling bindings on the same commit continue to
125
+ // evaluate. The error surfaces via the optional hook (or
126
+ // console.warn as a fallback) so it isn't silently swallowed.
127
+ reportBindingError(inst, binding, e);
128
+ continue;
129
+ }
130
+ if (Object.is(newValue, binding.lastValue))
131
+ continue;
132
+ binding.lastValue = newValue;
133
+ try {
134
+ applyBinding(binding, newValue);
135
+ }
136
+ catch (e) {
137
+ // applyBinding writes the value to the DOM (textContent,
138
+ // setAttribute, etc.). Throws here are usually environmental
139
+ // (a node was removed mid-flight by a sibling binding). Same
140
+ // contract: report and continue.
105
141
  reportBindingError(inst, binding, e);
106
142
  }
107
- continue;
108
- }
109
- let newValue;
110
- try {
111
- newValue = binding.accessor(state);
112
- }
113
- catch (e) {
114
- // Accessor threw — leave the binding's `lastValue` unchanged so
115
- // the rendered DOM stays at its previous value rather than going
116
- // blank. Sibling bindings on the same commit continue to
117
- // evaluate. The error surfaces via the optional hook (or
118
- // console.warn as a fallback) so it isn't silently swallowed.
119
- reportBindingError(inst, binding, e);
120
- continue;
121
- }
122
- if (Object.is(newValue, binding.lastValue))
123
- continue;
124
- binding.lastValue = newValue;
125
- try {
126
- applyBinding(binding, newValue);
127
- }
128
- catch (e) {
129
- // applyBinding writes the value to the DOM (textContent,
130
- // setAttribute, etc.). Throws here are usually environmental
131
- // (a node was removed mid-flight by a sibling binding). Same
132
- // contract: report and continue.
133
- reportBindingError(inst, binding, e);
134
143
  }
135
144
  }
145
+ finally {
146
+ exitAccessor();
147
+ }
136
148
  }
137
149
  function reportBindingError(inst, binding, e) {
138
150
  const err = e instanceof Error ? e : new Error(String(e));
@@ -158,6 +170,43 @@ function reportBindingError(inst, binding, e) {
158
170
  console.warn(`[llui] binding accessor threw (kind=${info.kind}${info.key ? `, key=${info.key}` : ''}): ${info.message}`);
159
171
  }
160
172
  }
173
+ /**
174
+ * Phase 1 (structural reconcile) parallel of `reportBindingError`. A
175
+ * `block.reconcile` throw — most often a misuse like `sample()` inside an
176
+ * `each().key` accessor — would otherwise escape the update loop, kill the
177
+ * remaining structural blocks AND the entire Phase 2 binding pass on this
178
+ * commit, and (in real apps) surface as an unhandled microtask rejection
179
+ * the developer never sees. Routing it through the same `_onBindingError`
180
+ * channel that Phase 2 uses gives parity: the error is named, surfaced
181
+ * once, and the rest of the update continues.
182
+ *
183
+ * Note: a partial DOM mutation on the failing block is NOT rolled back.
184
+ * The block's reconcile is responsible for keeping the DOM in a consistent
185
+ * state on its own happy path; if it throws mid-mutation, the visible
186
+ * result may be an inconsistent block, but sibling blocks and bindings
187
+ * still update correctly.
188
+ */
189
+ function reportReconcileError(inst, e) {
190
+ const err = e instanceof Error ? e : new Error(String(e));
191
+ const stack = err.stack ? err.stack.split('\n').slice(0, 8).join('\n') : undefined;
192
+ const info = stack !== undefined
193
+ ? { kind: 'reconcile', message: `${err.name}: ${err.message}`, stack }
194
+ : { kind: 'reconcile', message: `${err.name}: ${err.message}` };
195
+ if (inst._onBindingError !== undefined) {
196
+ try {
197
+ inst._onBindingError(info);
198
+ }
199
+ catch {
200
+ // hook itself threw; fall through to console
201
+ }
202
+ }
203
+ else if (typeof console !== 'undefined' && typeof console.error === 'function') {
204
+ // Reconcile errors are programmer errors (almost always: sample-in-
205
+ // accessor or a thrown structural primitive). Surface as `error` not
206
+ // `warn` so they're not lost in noisy dev consoles.
207
+ console.error(`[llui] structural reconcile threw: ${info.message}`);
208
+ }
209
+ }
161
210
  function processMessages(inst) {
162
211
  const queue = inst.queue;
163
212
  // Single-message fast path: dispatch directly to per-message-type handler
@@ -244,7 +293,12 @@ function genericUpdate(inst, state, combinedDirty, bindings, bindingsBeforePhase
244
293
  const block = blocks[bi];
245
294
  if (!block || (block.mask & combinedDirty) === 0)
246
295
  continue;
247
- block.reconcile(state, combinedDirty);
296
+ try {
297
+ block.reconcile(state, combinedDirty);
298
+ }
299
+ catch (e) {
300
+ reportReconcileError(inst, e);
301
+ }
248
302
  }
249
303
  // Phase 2 — compact + update bindings
250
304
  _runPhase2(state, combinedDirty, bindings, bindingsBeforePhase1, inst.def.name, inst._onBindingError);
@@ -267,24 +321,30 @@ export function _handleMsg(inst, msg, dirty, method) {
267
321
  const block = bl[i];
268
322
  if (!block || !(block.mask & dirty))
269
323
  continue;
270
- switch (method) {
271
- case 0:
272
- block.reconcile(s, dirty);
273
- break;
274
- case 1:
275
- block.reconcileItems?.(s);
276
- break;
277
- case 2:
278
- block.reconcileClear?.();
279
- break;
280
- case 3:
281
- block.reconcileRemove?.(s);
282
- break;
283
- default:
284
- // method >= 10: reconcileChanged with stride = method - 10
285
- if (method >= 10)
286
- block.reconcileChanged?.(s, method - 10);
287
- break;
324
+ try {
325
+ switch (method) {
326
+ case 0:
327
+ block.reconcile(s, dirty);
328
+ break;
329
+ case 1:
330
+ block.reconcileItems?.(s);
331
+ break;
332
+ case 2:
333
+ block.reconcileClear?.();
334
+ break;
335
+ case 3:
336
+ block.reconcileRemove?.(s);
337
+ break;
338
+ default:
339
+ // method >= 10: reconcileChanged with stride = method - 10
340
+ if (method >= 10)
341
+ block.reconcileChanged?.(s, method - 10);
342
+ break;
343
+ }
344
+ }
345
+ catch (err) {
346
+ reportReconcileError(inst, err);
347
+ // continue to next block — see reportReconcileError docstring
288
348
  }
289
349
  }
290
350
  }
@@ -325,38 +385,50 @@ onBindingError) {
325
385
  // behavior of rethrowing from `flush()` made one bad binding
326
386
  // visually break the entire view — the worst-case UX.
327
387
  const isDev = import.meta.env?.DEV && componentName;
328
- for (let i = 0, len = phase2Len; i < len; i++) {
329
- const binding = bindings[i];
330
- if (binding.dead || (binding.mask & dirty) === 0)
331
- continue;
332
- if (binding.kind === 'effect') {
388
+ // Single accessor label for the entire Phase 2 loop. The binding kind is
389
+ // already part of the error message that handleBindingThrow surfaces; the
390
+ // accessor label here serves the more specific purpose of catching
391
+ // sample() calls reaching for a render context that isn't set during
392
+ // the update phase. A `binding accessor` label is generic enough to apply
393
+ // to text/attr/class/effect bindings without per-kind branching.
394
+ enterAccessor('a binding accessor');
395
+ try {
396
+ for (let i = 0, len = phase2Len; i < len; i++) {
397
+ const binding = bindings[i];
398
+ if (binding.dead || (binding.mask & dirty) === 0)
399
+ continue;
400
+ if (binding.kind === 'effect') {
401
+ try {
402
+ binding.accessor(state);
403
+ }
404
+ catch (e) {
405
+ handleBindingThrow(onBindingError, binding, e, isDev ? componentName : null);
406
+ }
407
+ continue;
408
+ }
409
+ let newValue;
333
410
  try {
334
- binding.accessor(state);
411
+ newValue = binding.accessor(state);
412
+ }
413
+ catch (e) {
414
+ handleBindingThrow(onBindingError, binding, e, isDev ? componentName : null);
415
+ continue;
416
+ }
417
+ const last = binding.lastValue;
418
+ if (newValue === last || (newValue !== newValue && last !== last))
419
+ continue;
420
+ binding.lastValue = newValue;
421
+ try {
422
+ applyBinding(binding, newValue);
335
423
  }
336
424
  catch (e) {
337
425
  handleBindingThrow(onBindingError, binding, e, isDev ? componentName : null);
338
426
  }
339
- continue;
340
- }
341
- let newValue;
342
- try {
343
- newValue = binding.accessor(state);
344
- }
345
- catch (e) {
346
- handleBindingThrow(onBindingError, binding, e, isDev ? componentName : null);
347
- continue;
348
- }
349
- const last = binding.lastValue;
350
- if (newValue === last || (newValue !== newValue && last !== last))
351
- continue;
352
- binding.lastValue = newValue;
353
- try {
354
- applyBinding(binding, newValue);
355
- }
356
- catch (e) {
357
- handleBindingThrow(onBindingError, binding, e, isDev ? componentName : null);
358
427
  }
359
428
  }
429
+ finally {
430
+ exitAccessor();
431
+ }
360
432
  }
361
433
  }
362
434
  function handleBindingThrow(onBindingError, binding, e, componentName) {
@@ -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,K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AAY,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'\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 block.reconcile(newState, FULL_MASK)\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 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}\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\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 block.reconcile(state, combinedDirty)\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 switch (method) {\n case 0:\n block.reconcile(s, dirty)\n break\n case 1:\n block.reconcileItems?.(s)\n break\n case 2:\n block.reconcileClear?.()\n break\n case 3:\n block.reconcileRemove?.(s)\n break\n default:\n // method >= 10: reconcileChanged with stride = method - 10\n if (method >= 10) block.reconcileChanged?.(s, method - 10)\n break\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 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 }\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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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 switch (method) {\n case 0:\n block.reconcile(s, dirty)\n break\n case 1:\n block.reconcileItems?.(s)\n break\n case 2:\n block.reconcileClear?.()\n break\n case 3:\n block.reconcileRemove?.(s)\n break\n default:\n // method >= 10: reconcileChanged with stride = method - 10\n if (method >= 10) block.reconcileChanged?.(s, method - 10)\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.34",
3
+ "version": "0.0.35",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {