@llui/dom 0.0.30 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/binding-descriptors.d.ts +126 -0
- package/dist/binding-descriptors.d.ts.map +1 -0
- package/dist/binding-descriptors.js +144 -0
- package/dist/binding-descriptors.js.map +1 -0
- package/dist/devtools.d.ts +7 -3
- package/dist/devtools.d.ts.map +1 -1
- package/dist/devtools.js +52 -19
- package/dist/devtools.js.map +1 -1
- package/dist/el-split.d.ts.map +1 -1
- package/dist/el-split.js +12 -0
- package/dist/el-split.js.map +1 -1
- package/dist/elements.d.ts.map +1 -1
- package/dist/elements.js +14 -0
- package/dist/elements.js.map +1 -1
- package/dist/hmr.d.ts.map +1 -1
- package/dist/hmr.js +194 -0
- package/dist/hmr.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/mount.d.ts +22 -0
- package/dist/mount.d.ts.map +1 -1
- package/dist/mount.js +156 -173
- package/dist/mount.js.map +1 -1
- package/dist/primitives/sample.d.ts +16 -4
- package/dist/primitives/sample.d.ts.map +1 -1
- package/dist/primitives/sample.js +16 -4
- package/dist/primitives/sample.js.map +1 -1
- package/dist/primitives/unsafe-html.d.ts +1 -1
- package/dist/primitives/unsafe-html.d.ts.map +1 -1
- package/dist/primitives/unsafe-html.js.map +1 -1
- package/dist/types.d.ts +99 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/update-loop.d.ts.map +1 -1
- package/dist/update-loop.js.map +1 -1
- package/dist/view-helpers.d.ts +19 -3
- package/dist/view-helpers.d.ts.map +1 -1
- package/dist/view-helpers.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,11 +2,23 @@ import { getRenderContext } from '../render-context.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Read current state inside a render context and return the result of
|
|
4
4
|
* `selector(state)`. No binding is created, no mask is assigned — this
|
|
5
|
-
* is a one-shot imperative read.
|
|
5
|
+
* is a one-shot imperative read at view-construction time.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* **Don't use for variable-length lists.** Wrapping a list-render in
|
|
8
|
+
* `sample` looks idiomatic but silently breaks reactivity: the
|
|
9
|
+
* `.map(...)` runs once at construction, captures the row objects in
|
|
10
|
+
* closure, and never re-runs when state updates in place. The cells
|
|
11
|
+
* inside the captured rows show stale data; only a full structural
|
|
12
|
+
* rebuild (e.g. a parent `branch` swapping arms) will refresh them.
|
|
13
|
+
* Use `each` + `ItemAccessor` instead — see the "List of editable
|
|
14
|
+
* rows" recipe in the cookbook.
|
|
15
|
+
*
|
|
16
|
+
* **Use for** passing a state snapshot to an imperative renderer
|
|
17
|
+
* (foreign libraries, third-party canvas/svg builders), reading a
|
|
18
|
+
* value to compute a static piece of structure that doesn't need to
|
|
19
|
+
* react, or any case where a reactive binding would be semantically
|
|
20
|
+
* wrong (e.g. capturing a value at *this exact moment* for a
|
|
21
|
+
* one-shot side effect).
|
|
10
22
|
*
|
|
11
23
|
* Also exposed as `h.sample` on the View bag for destructure-from-`h`
|
|
12
24
|
* ergonomics. The top-level import form works everywhere a render
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sample.js","sourceRoot":"","sources":["../../src/primitives/sample.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAEvD
|
|
1
|
+
{"version":3,"file":"sample.js","sourceRoot":"","sources":["../../src/primitives/sample.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,MAAM,CAAO,QAAqB;IAChD,MAAM,GAAG,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAA;IACtC,OAAO,QAAQ,CAAC,GAAG,CAAC,KAAU,CAAC,CAAA;AACjC,CAAC","sourcesContent":["import { getRenderContext } from '../render-context.js'\n\n/**\n * Read current state inside a render context and return the result of\n * `selector(state)`. No binding is created, no mask is assigned — this\n * is a one-shot imperative read at view-construction time.\n *\n * **Don't use for variable-length lists.** Wrapping a list-render in\n * `sample` looks idiomatic but silently breaks reactivity: the\n * `.map(...)` runs once at construction, captures the row objects in\n * closure, and never re-runs when state updates in place. The cells\n * inside the captured rows show stale data; only a full structural\n * rebuild (e.g. a parent `branch` swapping arms) will refresh them.\n * Use `each` + `ItemAccessor` instead — see the \"List of editable\n * rows\" recipe in the cookbook.\n *\n * **Use for** passing a state snapshot to an imperative renderer\n * (foreign libraries, third-party canvas/svg builders), reading a\n * value to compute a static piece of structure that doesn't need to\n * react, or any case where a reactive binding would be semantically\n * wrong (e.g. capturing a value at *this exact moment* for a\n * one-shot side effect).\n *\n * Also exposed as `h.sample` on the View bag for destructure-from-`h`\n * ergonomics. The top-level import form works everywhere a render\n * context is live — including `each.render`, whose bag intentionally\n * does not carry View methods.\n *\n * Throws if called outside a render context.\n */\nexport function sample<S, R>(selector: (s: S) => R): R {\n const ctx = getRenderContext('sample')\n return selector(ctx.state as S)\n}\n"]}
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
* reads. Phase 2 / Phase 1 skip the reconcile when no interesting bit
|
|
25
25
|
* is set. Defaults to FULL_MASK for hand-written components.
|
|
26
26
|
*/
|
|
27
|
-
export declare function unsafeHtml<S>(accessor: ((s: S) => string) | string, mask?: number): Node[];
|
|
27
|
+
export declare function unsafeHtml<S>(accessor: ((s: S) => string) | (() => string) | string, mask?: number): Node[];
|
|
28
28
|
//# sourceMappingURL=unsafe-html.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsafe-html.d.ts","sourceRoot":"","sources":["../../src/primitives/unsafe-html.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,UAAU,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"unsafe-html.d.ts","sourceRoot":"","sources":["../../src/primitives/unsafe-html.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAC1B,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,MAAM,EACtD,IAAI,CAAC,EAAE,MAAM,GACZ,IAAI,EAAE,CA8CR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsafe-html.js","sourceRoot":"","sources":["../../src/primitives/unsafe-html.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,UAAU,
|
|
1
|
+
{"version":3,"file":"unsafe-html.js","sourceRoot":"","sources":["../../src/primitives/unsafe-html.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,UAAU,CACxB,QAAsD,EACtD,IAAa;IAEb,MAAM,GAAG,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAAA;IAC1C,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,gBAAgB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;IACxC,CAAC;IAED,MAAM,MAAM,GAAG,GAAG,CAAC,gBAAgB,CAAA;IACnC,MAAM,SAAS,GAAG,IAAI,IAAI,SAAS,CAAA;IAEnC,MAAM,M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IACpE,oEAAoE;IACpE,iEAAiE;IACjE,sEAAsE;IACtE,0DAA0D;IAC1D,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAA;AAC/D,CAAC","sourcesContent":["import type { StructuralBlock } from '../structural.js'\nimport { getRenderContext } from '../render-context.js'\nimport { FULL_MASK } from '../update-loop.js'\n\n/**\n * Insert raw HTML into the DOM tree.\n *\n * **Security.** The caller is responsible for sanitizing `html`. Never\n * interpolate unsanitized user input — this is the XSS escape hatch and\n * the name carries the warning deliberately.\n *\n * **Opaque to the framework.** The parsed subtree is treated as a black\n * box by LLui — no bindings, events, `each`, `show`, or `child` inside\n * it will be discovered or driven by the framework. Use element helpers\n * for anything that needs to react to state or dispatch messages.\n *\n * **Static form.** `unsafeHtml('<b>hi</b>')` parses once at view time\n * and returns the parsed nodes. Zero reactive overhead.\n *\n * **Reactive form.** `unsafeHtml((s) => s.markdownHtml)` registers a\n * structural block that re-parses when the returned string differs\n * (strict `===`) from the previous value. Unchanged strings short-\n * circuit — existing DOM identity (focus, selection, listeners\n * attached outside LLui) is preserved.\n *\n * **Mask hint.** The second parameter mirrors `text()`: the compiler\n * passes a precise mask derived from which state fields the accessor\n * reads. Phase 2 / Phase 1 skip the reconcile when no interesting bit\n * is set. Defaults to FULL_MASK for hand-written components.\n */\nexport function unsafeHtml<S>(\n accessor: ((s: S) => string) | (() => string) | string,\n mask?: number,\n): Node[] {\n const ctx = getRenderContext('unsafeHtml')\n if (typeof accessor === 'string') {\n return parseHtmlToNodes(ctx, accessor)\n }\n\n const blocks = ctx.structuralBlocks\n const blockMask = mask ?? FULL_MASK\n\n const anchor = ctx.dom.createComment('unsafeHtml')\n let currentHtml = accessor(ctx.state as S)\n let currentNodes: Node[] = parseHtmlToNodes(ctx, currentHtml)\n\n const block: StructuralBlock = {\n mask: blockMask,\n reconcile(state: unknown) {\n const newHtml = accessor(state as S)\n // Identity short-circuit — don't rebuild the subtree when the\n // author handed us the same string. Preserves focus, selection,\n // and any listeners outside LLui's view of the world.\n if (newHtml === currentHtml) return\n\n const parent = anchor.parentNode\n if (!parent) return\n\n const oldNodes = currentNodes\n currentNodes = parseHtmlToNodes(ctx, newHtml)\n currentHtml = newHtml\n\n // The anchor sits immediately before the current node range, so\n // `anchor.nextSibling` is the first old node (or whatever follows\n // when the old list is empty). Insert new nodes there, then\n // remove the old ones — matches `branch()`'s enter/leave order so\n // transitions can inspect both sets.\n const ref = anchor.nextSibling\n for (const node of currentNodes) {\n parent.insertBefore(node, ref)\n }\n for (const node of oldNodes) {\n if (node.parentNode) node.parentNode.removeChild(node)\n }\n },\n }\n blocks.push(block)\n\n return [anchor, ...currentNodes]\n}\n\nfunction parseHtmlToNodes(ctx: import('../render-context.js').RenderContext, html: string): Node[] {\n // Delegates to the env — jsdom/linkedom adapters may implement this\n // via DOMParser instead of the browser `<template>` trick, but both\n // return an inert DocumentFragment that doesn't execute scripts.\n // Snapshot — moving nodes to a parent drains fragment.childNodes, but\n // callers hold this array and we iterate it on reconcile.\n return Array.from(ctx.dom.parseHtmlFragment(html).childNodes)\n}\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -166,6 +166,78 @@ export interface AppHandle {
|
|
|
166
166
|
* unsubscribe). See agent spec §10.5 (state-update frames).
|
|
167
167
|
*/
|
|
168
168
|
subscribe(listener: (state: unknown) => void): () => void;
|
|
169
|
+
/**
|
|
170
|
+
* Snapshot the Msg variants currently dispatchable from rendered UI.
|
|
171
|
+
* Each entry corresponds to one or more event-handler bindings the
|
|
172
|
+
* compiler tagged with literal `send({type: '<variant>'})` calls;
|
|
173
|
+
* the registry tracks live mounts via lifetime refcounts so the
|
|
174
|
+
* snapshot reflects what the user can click *right now*, not the
|
|
175
|
+
* static catalogue of every variant the app could ever accept.
|
|
176
|
+
*
|
|
177
|
+
* Used by `@llui/agent` to populate `list_actions`. Apps that don't
|
|
178
|
+
* use the LLui compiler tagger pass (or whose views contain no
|
|
179
|
+
* literal sends) get an empty array — agents fall back to the Msg
|
|
180
|
+
* schema for affordance discovery.
|
|
181
|
+
*/
|
|
182
|
+
getBindingDescriptors(): Array<{
|
|
183
|
+
variant: string;
|
|
184
|
+
}>;
|
|
185
|
+
/**
|
|
186
|
+
* Hot-swap the component's `update` function (and optionally
|
|
187
|
+
* `onEffect`) without rebuilding the DOM. Pending messages are
|
|
188
|
+
* drained against the OLD `update` first so a half-applied
|
|
189
|
+
* transition can't leave the state ill-formed; subsequent
|
|
190
|
+
* dispatches go through the new function.
|
|
191
|
+
*
|
|
192
|
+
* This is the lightweight HMR escape hatch for cases where the
|
|
193
|
+
* full `replaceComponent` flow (in `@llui/dom/hmr`) is overkill —
|
|
194
|
+
* pure `update.ts` edits don't change the view, so disposing the
|
|
195
|
+
* root lifetime and re-running the view just to install a new
|
|
196
|
+
* function is wasteful and loses focus / scroll / transient DOM
|
|
197
|
+
* state. Wire it via `import.meta.hot`:
|
|
198
|
+
*
|
|
199
|
+
* ```ts
|
|
200
|
+
* // main.ts
|
|
201
|
+
* const handle = mountApp(root, App)
|
|
202
|
+
* if (import.meta.hot) {
|
|
203
|
+
* import.meta.hot.accept('./app/update', (mod) => {
|
|
204
|
+
* if (mod) handle.swapUpdate(mod.update)
|
|
205
|
+
* })
|
|
206
|
+
* }
|
|
207
|
+
* ```
|
|
208
|
+
*
|
|
209
|
+
* Caveats:
|
|
210
|
+
* - Doesn't compensate for State shape changes — if the new
|
|
211
|
+
* `update` reads a field the old state doesn't have, you'll
|
|
212
|
+
* see runtime errors. Hard-reload after structural state
|
|
213
|
+
* changes.
|
|
214
|
+
* - Doesn't swap `view` or compiler-emitted `__update`/`__dirty`
|
|
215
|
+
* — for those, prefer the auto-injected component-level HMR
|
|
216
|
+
* accept callback (which routes through `replaceComponent`).
|
|
217
|
+
*/
|
|
218
|
+
swapUpdate(newUpdate: (state: unknown, msg: unknown) => [unknown, unknown[]], newOnEffect?: unknown): void;
|
|
219
|
+
/**
|
|
220
|
+
* Run the reducer in isolation against the current state. Returns
|
|
221
|
+
* `[newState, effects]` — the reducer's literal output without any
|
|
222
|
+
* commit, flush, or effect-handler invocation. Used by the agent's
|
|
223
|
+
* `would_dispatch` tool to predict what a candidate dispatch would
|
|
224
|
+
* do before committing to it.
|
|
225
|
+
*
|
|
226
|
+
* Pure-reducer assumption: TEA mandates `update` be pure. LLui's
|
|
227
|
+
* runtime treats it that way too (no speculative re-runs for any
|
|
228
|
+
* other reason). Apps whose reducers branch on `Date.now()` or
|
|
229
|
+
* read `localStorage` will see prediction drift from real dispatch
|
|
230
|
+
* by exactly that amount of impurity — surface as documented at
|
|
231
|
+
* the agent's call site, not silently corrected here.
|
|
232
|
+
*
|
|
233
|
+
* **No effects fire.** Effect descriptors are returned for the
|
|
234
|
+
* agent to inspect; `onEffect` is not called. This is the entire
|
|
235
|
+
* point of the API.
|
|
236
|
+
*/
|
|
237
|
+
runReducer(msg: unknown): {
|
|
238
|
+
state: unknown;
|
|
239
|
+
effects: unknown[];
|
|
240
|
+
} | null;
|
|
169
241
|
}
|
|
170
242
|
export interface Lifetime {
|
|
171
243
|
id: number;
|
|
@@ -216,11 +288,19 @@ export interface TransitionOptions {
|
|
|
216
288
|
}
|
|
217
289
|
interface BranchOptionsBase extends TransitionOptions {
|
|
218
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Discriminant accessor — reads a string-keyed value either from the
|
|
293
|
+
* current state (`(s) => …`) or from a closed-over item accessor /
|
|
294
|
+
* memo (`() => item.kind()`). Both forms re-evaluate on every commit.
|
|
295
|
+
* The zero-arg form is the canonical shape for branching on per-row
|
|
296
|
+
* fields inside an `each.render` callback.
|
|
297
|
+
*/
|
|
298
|
+
type Discriminant<S, K extends string> = ((s: S) => K) | (() => K);
|
|
219
299
|
/**
|
|
220
300
|
* All cases covered by `cases` — no default allowed (would be dead code).
|
|
221
301
|
*/
|
|
222
302
|
type BranchOptionsExhaustive<S, M, K extends string> = BranchOptionsBase & {
|
|
223
|
-
on:
|
|
303
|
+
on: Discriminant<S, K>;
|
|
224
304
|
cases: {
|
|
225
305
|
[P in K]: (h: View<S, M>) => Node[];
|
|
226
306
|
};
|
|
@@ -230,7 +310,7 @@ type BranchOptionsExhaustive<S, M, K extends string> = BranchOptionsBase & {
|
|
|
230
310
|
* `cases` may cover some but not all keys; `default` handles the rest.
|
|
231
311
|
*/
|
|
232
312
|
type BranchOptionsNonExhaustive<S, M, K extends string> = BranchOptionsBase & {
|
|
233
|
-
on:
|
|
313
|
+
on: Discriminant<S, K>;
|
|
234
314
|
cases?: {
|
|
235
315
|
[P in K]?: (h: View<S, M>) => Node[];
|
|
236
316
|
};
|
|
@@ -244,7 +324,7 @@ type BranchOptionsNonExhaustive<S, M, K extends string> = BranchOptionsBase & {
|
|
|
244
324
|
* `on`'s return type to a literal union.
|
|
245
325
|
*/
|
|
246
326
|
type BranchOptionsWide<S, M> = BranchOptionsBase & {
|
|
247
|
-
on:
|
|
327
|
+
on: Discriminant<S, string>;
|
|
248
328
|
cases?: Record<string, (h: View<S, M>) => Node[]>;
|
|
249
329
|
default?: (h: View<S, M>) => Node[];
|
|
250
330
|
};
|
|
@@ -264,7 +344,15 @@ type BranchOptionsWide<S, M> = BranchOptionsBase & {
|
|
|
264
344
|
*/
|
|
265
345
|
export type BranchOptions<S, M = unknown, K extends string = string> = string extends K ? BranchOptionsWide<S, M> : BranchOptionsExhaustive<S, M, K> | BranchOptionsNonExhaustive<S, M, K>;
|
|
266
346
|
export interface ShowOptions<S, M = unknown> extends TransitionOptions {
|
|
267
|
-
|
|
347
|
+
/**
|
|
348
|
+
* Predicate evaluated on every commit. `(s) => …` reads from
|
|
349
|
+
* component state; `() => …` (zero-arg) reads from a closed-over
|
|
350
|
+
* source — typically `item.field()` inside an `each.render`
|
|
351
|
+
* callback. Both forms are reactive: the predicate runs against
|
|
352
|
+
* each new state and the rendered subtree mounts/unmounts on the
|
|
353
|
+
* boolean transition.
|
|
354
|
+
*/
|
|
355
|
+
when: ((s: S) => boolean) | (() => boolean);
|
|
268
356
|
render: (h: View<S, M>) => Node[];
|
|
269
357
|
fallback?: (h: View<S, M>) => Node[];
|
|
270
358
|
}
|
|
@@ -278,7 +366,13 @@ export interface ShowOptions<S, M = unknown> extends TransitionOptions {
|
|
|
278
366
|
* one-shot current-state read.
|
|
279
367
|
*/
|
|
280
368
|
export interface ScopeOptions<S, M = unknown> extends TransitionOptions {
|
|
281
|
-
|
|
369
|
+
/**
|
|
370
|
+
* Key accessor evaluated on every commit. `(s) => …` reads from
|
|
371
|
+
* component state; `() => …` (zero-arg) reads from a closed-over
|
|
372
|
+
* source. The render callback rebuilds whenever the returned key
|
|
373
|
+
* changes — fresh lifetime, fresh bindings.
|
|
374
|
+
*/
|
|
375
|
+
on: ((s: S) => string) | (() => string);
|
|
282
376
|
render: (h: View<S, M>) => Node[];
|
|
283
377
|
}
|
|
284
378
|
/**
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAK7C,MAAM,WAAW,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,IAAI;IACrD,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;IAC3B,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;IACtC,IAAI,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,CAAA;IAC/B,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE;QAAE,MAAM,EA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K,IAAI;KAC5F,CAAA;IACL,OAAO,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAA;IACrC,SAAS,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAA;CAC7D;AAED,MAAM,WAAW,YAAY,CAAC,CAAC,EAAE,MAAM;IAMrC,GAAG,EAAE,eAAe,CAAA;IACpB,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACxC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,CAAA;CACxC"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,qEAAqE","sourcesContent":["// ── Component Definition ──────────────────────────────────────────\n\nimport type { View } from './view-helpers.js'\nimport type { StructuralBlock } from './structural.js'\nimport type { ComponentInstance } from './update-loop.js'\nimport type { DisposerEvent } from './tracking/disposer-log.js'\n\nexport interface ComponentDef<S, M, E = never, D = void> {\n name: string\n init: (data: D) => [S, E[]]\n update: (state: S, msg: M) => [S, E[]]\n view: (h: View<S, M>) => Node[]\n onEffect?: (ctx: { effect: E; send: Send<M>; signal: AbortSignal }) => void\n\n // Level 2 composition\n propsMsg?: (props: Record<string, unknown>) => M\n receives?: Record<string, (params: unknown) => M>\n\n /** @internal Compiler-injected */\n __dirty?: (oldState: S, newState: S) => number | [number, number]\n /** @internal Compiler-injected */\n __renderToString?: (state: S) => string\n /** @internal Compiler-injected */\n __msgSchema?: object\n /** @internal Compiler-injected; keyed by Msg discriminant → annotations. See agent spec §5.1. */\n __msgAnnotations?: Record<\n string,\n {\n intent: string | null\n alwaysAffordable: boolean\n requiresConfirm: boolean\n humanOnly: boolean\n }\n >\n /** @internal Compiler-emitted; one entry per send() call site in view(). See agent spec §5.2. */\n __bindingDescriptors?: Array<{ variant: string }>\n /** @internal Compiler-injected; 32-char hex SHA-256 of schemas + annotations. See agent spec §12.3. */\n __schemaHash?: string\n /** @internal Compiler-injected — maps top-level state field → dirty-mask bit(s) */\n __maskLegend?: Record<string, number>\n /** @internal Compiler-injected — source-file location of the component() call */\n __componentMeta?: { file: string; line: number }\n /** @internal Compiler-injected — shape of the State type (for introspection) */\n __stateSchema?: object\n /** @internal Compiler-injected — Effect union schema (for introspection) */\n __effectSchema?: object\n /** @internal Compiler-injected — replaces generic Phase 1 + Phase 2 loop */\n __update?: (\n state: S,\n dirty: number,\n bindings: Binding[],\n blocks: StructuralBlock[],\n bindingsBeforePhase1: number,\n ) => void\n /** @internal Compiler-injected — per-message-type specialized handlers.\n * Bypass the entire processMessages pipeline for single-message updates. */\n __handlers?: Record<string, (inst: object, msg: unknown) => [S, E[]]>\n}\n\nexport type Send<M> = (msg: M) => void\n\n/**\n * Type-erased component definition for use at module boundaries where\n * the consumer's `S`, `M`, `E` are internal and invisible to the caller.\n *\n * Why this exists: `ComponentDef<S, M, E, D>` uses property syntax for\n * its callable fields (`init: (data: D) => ...`), and TypeScript\n * checks property syntax with strict (contravariant) variance. That's\n * the right call for user-facing type safety when authoring a\n * component (a narrower `Msg` type can't accidentally satisfy the\n * `update`'s param), but it means `ComponentDef<MyState, MyMsg, MyEffect, MyData>`\n * is NOT structurally assignable to `ComponentDef<unknown, unknown, unknown, unknown>`\n * — the `init: (data: MyData) => ...` field is contravariant in `MyData`,\n * so widening to `unknown` is rejected.\n *\n * `AnyComponentDef` (and `LazyDef<D>` below) declare the same fields\n * using **method syntax** (`init(data: D): ...`), which TypeScript\n * checks bivariantly. Concrete `ComponentDef<S, M, E, D>` assigns into\n * these structurally without any `widenDef` helper at the callsite.\n *\n * Used by every API that accepts an opaque component definition at a\n * module boundary:\n *\n * - `child({ def })`\n * - `lazy({ loader })` — returns `LazyDef<D>` so the loader's `D` survives\n * - `createOnRenderClient({ Layout })` (from `@llui/vike`)\n * - `createOnRenderHtml({ Layout })` (from `@llui/vike`)\n *\n * The `D` parameter is `unknown` here — `child()` doesn't pass init\n * data through, and `Layout` callers pass route-supplied data whose\n * shape is unknown at the type-erased boundary. Use `LazyDef<D>` when\n * you need to preserve the init data shape (the lazy loader case).\n */\nexport interface AnyComponentDef {\n name: string\n init(data: unknown): [unknown, unknown[]]\n update(state: unknown, msg: unknown): [unknown, unknown[]]\n view(h: unknown): Node[]\n onEffect?: unknown\n propsMsg?: unknown\n receives?: unknown\n __dirty?: unknown\n __renderToString?: unknown\n __msgSchema?: unknown\n __msgAnnotations?: unknown\n __bindingDescriptors?: unknown\n __schemaHash?: unknown\n __maskLegend?: unknown\n __componentMeta?: unknown\n __stateSchema?: unknown\n __effectSchema?: unknown\n __update?: unknown\n __handlers?: unknown\n}\n\n/**\n * Type-erased component definition for use at module boundaries where the\n * loaded component's S, M, E are internal and invisible to the caller.\n * Only `D` (init data) survives because the caller provides it.\n *\n * `ComponentDef<S, M, E, D>` is structurally assignable to `LazyDef<D>`\n * for any S, M, E — `view: (h: unknown) => Node[]` accepts any View via\n * contravariance, and all other fields widen to `unknown` return types.\n *\n * Used by `lazy()` as the loader's return type. Use `AnyComponentDef`\n * (above) when D is also opaque — most other adapter-layer APIs.\n */\nexport interface LazyDef<D = void> {\n name: string\n // Method syntax — TypeScript checks methods bivariantly, so\n // ComponentDef<S, M, E, D>'s concrete (state: S, msg: M) => ...\n // assigns here even though S/M ≠ unknown. Property syntax would\n // be contravariant and reject the assignment.\n init(data: D): [unknown, unknown[]]\n update(state: unknown, msg: unknown): [unknown, unknown[]]\n view(h: unknown): Node[]\n onEffect?: unknown\n propsMsg?: unknown\n receives?: unknown\n __dirty?: unknown\n __renderToString?: unknown\n __msgSchema?: unknown\n __msgAnnotations?: unknown\n __bindingDescriptors?: unknown\n __schemaHash?: unknown\n __maskLegend?: unknown\n __componentMeta?: unknown\n __stateSchema?: unknown\n __effectSchema?: unknown\n __update?: unknown\n __handlers?: unknown\n}\n\n/**\n * Maps a value shape to a reactive-props shape: every field becomes an accessor\n * `(s: S) => V`. Use for Level-1 view function signatures.\n *\n * ```ts\n * type ToolbarData = { tools: Tool[]; theme: 'light' | 'dark' }\n *\n * export function toolbar<S>(props: Props<ToolbarData, S>, send: Send<Msg>) {\n * return [div({ class: props.theme }, [each({ items: props.tools, ... })])]\n * }\n *\n * // Caller — TypeScript enforces per-field accessors; passing a raw value errors:\n * toolbar({ tools: (s: State) => s.tools, theme: (s) => s.theme }, send)\n * ```\n */\nexport type Props<T, S> = {\n [K in keyof T]: (s: S) => T[K]\n}\n\n// ── App Handle ────────────────────────────────────────────────────\n\nexport interface AppHandle {\n dispose(): void\n flush(): void\n /**\n * Dispatch a message into the mounted instance from outside its\n * normal view-bound `send` channel. Useful for adapter layers that\n * need to push updates into a long-lived instance — e.g.\n * `@llui/vike`'s persistent-layout chain pushes layout-data updates\n * into surviving layer instances on client navigation when their\n * `propsMsg` translates the new data into a state-update message.\n *\n * Messages are queued through the same path as `view`-side `send`\n * calls — they batch into the next microtask and process via the\n * normal update loop. Calling `send` after `dispose` is a no-op.\n */\n send(msg: unknown): void\n /**\n * Read the current state snapshot. Safe to call from anywhere —\n * event handlers, async callbacks, adapter `send` wrappers, or any\n * imperative context where the render context is not live.\n *\n * Unlike `sample()` (a view primitive that requires an active\n * render context and throws outside of `view()`), `getState` is\n * the sanctioned escape hatch for \"I need to know the current\n * state to decide what to dispatch.\" Typical shape:\n *\n * ```ts\n * const handle = mountApp(root, MyApp)\n * container.addEventListener('drop', () => {\n * const { mode } = handle.getState() as AppState\n * if (mode === 'drag') handle.send({ type: 'commit' })\n * })\n * ```\n *\n * Throws after `dispose()` — stale reads are silent bugs; a thrown\n * error pinpoints the callsite that forgot to detach.\n *\n * The return type is `unknown` because `AppHandle` is state-type\n * erased at this boundary; cast to your app's state type at the\n * call site.\n */\n getState(): unknown\n /**\n * Register a listener called synchronously after every update cycle\n * completes. The listener receives the new state. Returns an\n * unsubscribe function. Safe after dispose (no-op; returns a no-op\n * unsubscribe). See agent spec §10.5 (state-update frames).\n */\n subscribe(listener: (state: unknown) => void): () => void\n}\n\n// ── Lifetime ─────────────────────────────────────────────────────────\n\nexport interface Lifetime {\n id: number\n parent: Lifetime | null\n children: Lifetime[]\n disposers: Array<() => void>\n bindings: Binding[]\n /** Per-item updaters — called directly by each() when item changes, bypassing Phase 2 */\n itemUpdaters: Array<() => void>\n /**\n * @internal dev-only back-reference to the owning ComponentInstance.\n * Populated on the root scope by `installDevTools` so `disposeLifetime`\n * can walk up the scope chain and emit DisposerEvents into the\n * instance's `_disposerLog`. Undefined in production.\n */\n instance?: ComponentInstance\n /**\n * @internal dev-only cause hint. Structural primitives (branch, each,\n * child, mountApp teardown) set this field immediately before calling\n * `disposeLifetime`; the dispose path reads it once to stamp the emitted\n * DisposerEvent. Left undefined, `disposeLifetime` falls back to\n * `'component-unmount'`. Undefined in production.\n */\n disposalCause?: DisposerEvent['cause']\n /** @internal dev-only — populated by structural primitives for scope-tree classification */\n _kind?: 'root' | 'show' | 'each' | 'branch' | 'scope' | 'child' | 'portal' | 'foreign'\n}\n\nexport interface LifetimeNode {\n scopeId: string\n kind: 'root' | 'show' | 'each' | 'branch' | 'scope' | 'child' | 'portal' | 'foreign'\n active: boolean\n children: LifetimeNode[]\n}\n\n// ── Binding ───────────────────────────────────────────────────────\n\n/**\n * Binding output kinds.\n *\n * `'text' | 'prop' | 'attr' | 'class' | 'style'` write their accessor's\n * return value to the DOM. `'effect'` is a side-effect-only watcher:\n * the accessor is invoked every Phase 2 tick its mask is hit, but its\n * return value is discarded and `applyBinding` is a no-op. Used by\n * `child()` to fire the prop-diff/propsMsg cascade on parent updates\n * without the cost of stringifying the returned props bag onto a\n * detached anchor node every render.\n */\nexport type BindingKind = 'text' | 'prop' | 'attr' | 'class' | 'style' | 'effect'\n\nexport interface Binding {\n mask: number\n accessor: (state: unknown) => unknown\n lastValue: unknown\n kind: BindingKind\n node: Node\n key?: string\n ownerLifetime: Lifetime\n perItem: boolean\n dead: boolean\n}\n\n// ── Structural Primitives ─────────────────────────────────────────\n\nexport interface TransitionOptions {\n enter?: (nodes: Node[]) => void | Promise<void>\n leave?: (nodes: Node[]) => void | Promise<void>\n onTransition?: (ctx: { entering: Node[]; leaving: Node[]; parent: Node }) => void | Promise<void>\n}\n\ninterface BranchOptionsBase extends TransitionOptions {\n /**\n * @internal Set by `show()` / `scope()` sugar when delegating to\n * `branch()`, so the dev-only disposer log can report `'show-hide'` /\n * `'scope-rebuild'` instead of the default `'branch-swap'` for the\n * leaving arm. User code should not set this directly.\n */\n __disposalCause?: DisposerEvent['cause']\n /** @internal Compiler-injected mask of paths read by `on`. */\n __mask?: number\n}\n\n/**\n * All cases covered by `cases` — no default allowed (would be dead code).\n */\ntype BranchOptionsExhaustive<S, M, K extends string> = BranchOptionsBase & {\n on: (s: S) => K\n cases: { [P in K]: (h: View<S, M>) => Node[] }\n default?: never\n}\n\n/**\n * `cases` may cover some but not all keys; `default` handles the rest.\n */\ntype BranchOptionsNonExhaustive<S, M, K extends string> = BranchOptionsBase & {\n on: (s: S) => K\n cases?: { [P in K]?: (h: View<S, M>) => Node[] }\n default: (h: View<S, M>) => Node[]\n}\n\n/**\n * `on` returns a wide `string` — exhaustiveness cannot be verified at\n * compile time (the key domain is infinite). Lenient: `default` is\n * optional so existing call sites that predate exhaustiveness typing\n * continue to compile. Authors who want the gate opt in by narrowing\n * `on`'s return type to a literal union.\n */\ntype BranchOptionsWide<S, M> = BranchOptionsBase & {\n on: (s: S) => string\n cases?: Record<string, (h: View<S, M>) => Node[]>\n default?: (h: View<S, M>) => Node[]\n}\n\n/**\n * Options for `branch()`.\n *\n * When `on` returns a literal string union (e.g. `'idle' | 'loading'\n * | 'done'`), TypeScript enforces exhaustiveness: either every union\n * member has a case (and `default` is disallowed as unreachable), or\n * `default` is required to cover the remainder. When `on` returns a\n * wide `string`, `default` stays optional — exhaustiveness isn't\n * meaningful for an unbounded domain.\n *\n * `cases` is optional when `default` is present; `branch({ on, default })`\n * is the canonical dynamic-rebuild shape — `scope()` sugar wraps\n * exactly this form.\n */\nexport type BranchOptions<S, M = unknown, K extends string = string> = string extends K\n ? BranchOptionsWide<S, M>\n : BranchOptionsExhaustive<S, M, K> | BranchOptionsNonExhaustive<S, M, K>\n\nexport interface ShowOptions<S, M = unknown> extends TransitionOptions {\n when: (s: S) => boolean\n render: (h: View<S, M>) => Node[]\n fallback?: (h: View<S, M>) => Node[]\n}\n\n/**\n * Options for `scope()` — rebuilds a subtree when `on(state)` changes.\n *\n * Sugar over `branch({ on, cases: {}, default: render, __disposalCause: 'scope-rebuild' })`.\n * Use when the key is dynamic (e.g. an epoch counter bumped from the\n * outside) and you want a fresh arm — fresh lifetime, fresh bindings —\n * each time it changes. Combine with `sample()` inside `render` for a\n * one-shot current-state read.\n */\nexport interface ScopeOptions<S, M = unknown> extends TransitionOptions {\n on: (s: S) => string\n render: (h: View<S, M>) => Node[]\n /** @internal Compiler-injected mask of paths read by `on`. */\n __mask?: number\n}\n\n/**\n * Options for `each()`. The inherited `enter` / `leave` callbacks fire **per item**:\n * `enter(nodes)` runs after an item's DOM is inserted (including initial mount);\n * `leave(nodes)` runs before an item's DOM is removed and may return a Promise\n * to hold the DOM until the animation resolves. Setting `leave` disables the\n * bulk-clear / full-replace fast paths.\n */\n/**\n * Per-item accessor. Two access forms:\n * - `item.field` — shorthand, returns accessor for `item.current[field]`\n * - `item(t => t.expr)` — computed expressions\n *\n * In both cases the returned value is a `() => V` accessor.\n * Invoke it (`item.field()`) to read the current value imperatively.\n */\nexport type ItemAccessor<T> = {\n <R>(selector: (t: T) => R): () => R\n} & {\n [K in keyof T]-?: () => T[K]\n} & {\n /**\n * Read the whole current item. Needed when T is a primitive (where the\n * field-map branch collapses to method names like `toString`) or when\n * you want to sample the entire record rather than a single field.\n *\n * Shadows any literal `current` field on T — if T has such a field,\n * use `item(r => r.current)` to disambiguate.\n */\n current(): T\n}\n\nexport interface EachOptions<S, T, M = unknown> extends TransitionOptions {\n items: (s: S) => T[]\n key: (item: T) => string | number\n render: (opts: {\n send: Send<M>\n item: ItemAccessor<T>\n /**\n * Plain (non-Proxy) accessor factory. Compiler-output path; avoid in user code\n * (use `item.field` / `item(fn)` — more ergonomic and bypasses Proxy when compiled).\n */\n acc: <R>(selector: (t: T) => R) => () => R\n index: () => number\n /**\n * The component's View bag (`h.text`, `h.show`, `h.branch`,\n * `h.scope`, `h.sample`, …). Each-render callers used to reach\n * for the top-level imports; the bag form is symmetric with how\n * `branch.cases[k]`, `show.render`, and `scope.render` receive it.\n * Both still work — destructure whichever is more convenient.\n */\n h: View<S, M>\n /** @internal Compiler-injected — entry reference for row factory */\n entry?: Record<string, unknown>\n }) => Node[]\n}\n\nexport interface PortalOptions {\n target: HTMLElement | string\n render: () => Node[]\n}\n\nexport interface ForeignOptions<S, M, T extends Record<string, unknown>, Instance> {\n /**\n * Construct the imperative instance. Can be async — return a\n * `Promise<Instance>` to defer construction until e.g. a dynamic\n * `import()` resolves. While the promise is pending:\n *\n * - The container element is in the DOM immediately (so layout\n * doesn't shift when the instance arrives).\n * - `sync` is NOT called. State changes are tracked by the\n * primitive and the latest props are applied as the initial\n * sync right after the promise resolves.\n * - If the owning scope disposes before the promise resolves,\n * `destroy(instance)` runs on resolution — no matter how long\n * the promise takes.\n */\n mount: (ctx: { container: HTMLElement; send: Send<M> }) => Instance | Promise<Instance>\n props: (s: S) => T\n sync:\n | ((ctx: { instance: Instance; props: T; prev: T | undefined }) => void)\n | {\n [K in keyof T]?: (ctx: { instance: Instance; value: T[K]; prev: T[K] | undefined }) => void\n }\n destroy: (instance: Instance) => void\n container?: { tag?: string; attrs?: Record<string, string> }\n}\n\nexport interface ChildOptions<S, ChildM> {\n // Type-erased via AnyComponentDef so callers can pass any concrete\n // ComponentDef<S, M, E, D> without a widening helper. The runtime\n // narrows the message shape via the user-supplied `onMsg` callback,\n // which keeps `ChildM` typed at this boundary even though the def\n // itself is opaque.\n def: AnyComponentDef\n key: string | number\n props: (s: S) => Record<string, unknown>\n onMsg?: (msg: ChildM) => unknown | null\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,qEAAqE","sourcesContent":["// ── Component Definition ──────────────────────────────────────────\n\nimport type { View } from './view-helpers.js'\nimport type { StructuralBlock } from './structural.js'\nimport type { ComponentInstance } from './update-loop.js'\nimport type { DisposerEvent } from './tracking/disposer-log.js'\n\nexport interface ComponentDef<S, M, E = never, D = void> {\n name: string\n init: (data: D) => [S, E[]]\n update: (state: S, msg: M) => [S, E[]]\n view: (h: View<S, M>) => Node[]\n onEffect?: (ctx: { effect: E; send: Send<M>; signal: AbortSignal }) => void\n\n // Level 2 composition\n propsMsg?: (props: Record<string, unknown>) => M\n receives?: Record<string, (params: unknown) => M>\n\n /** @internal Compiler-injected */\n __dirty?: (oldState: S, newState: S) => number | [number, number]\n /** @internal Compiler-injected */\n __renderToString?: (state: S) => string\n /** @internal Compiler-injected */\n __msgSchema?: object\n /** @internal Compiler-injected; keyed by Msg discriminant → annotations. See agent spec §5.1. */\n __msgAnnotations?: Record<\n string,\n {\n intent: string | null\n alwaysAffordable: boolean\n requiresConfirm: boolean\n humanOnly: boolean\n }\n >\n /** @internal Compiler-emitted; one entry per send() call site in view(). See agent spec §5.2. */\n __bindingDescriptors?: Array<{ variant: string }>\n /** @internal Compiler-injected; 32-char hex SHA-256 of schemas + annotations. See agent spec §12.3. */\n __schemaHash?: string\n /** @internal Compiler-injected — maps top-level state field → dirty-mask bit(s) */\n __maskLegend?: Record<string, number>\n /** @internal Compiler-injected — source-file location of the component() call */\n __componentMeta?: { file: string; line: number }\n /** @internal Compiler-injected — shape of the State type (for introspection) */\n __stateSchema?: object\n /** @internal Compiler-injected — Effect union schema (for introspection) */\n __effectSchema?: object\n /** @internal Compiler-injected — replaces generic Phase 1 + Phase 2 loop */\n __update?: (\n state: S,\n dirty: number,\n bindings: Binding[],\n blocks: StructuralBlock[],\n bindingsBeforePhase1: number,\n ) => void\n /** @internal Compiler-injected — per-message-type specialized handlers.\n * Bypass the entire processMessages pipeline for single-message updates. */\n __handlers?: Record<string, (inst: object, msg: unknown) => [S, E[]]>\n}\n\nexport type Send<M> = (msg: M) => void\n\n/**\n * Type-erased component definition for use at module boundaries where\n * the consumer's `S`, `M`, `E` are internal and invisible to the caller.\n *\n * Why this exists: `ComponentDef<S, M, E, D>` uses property syntax for\n * its callable fields (`init: (data: D) => ...`), and TypeScript\n * checks property syntax with strict (contravariant) variance. That's\n * the right call for user-facing type safety when authoring a\n * component (a narrower `Msg` type can't accidentally satisfy the\n * `update`'s param), but it means `ComponentDef<MyState, MyMsg, MyEffect, MyData>`\n * is NOT structurally assignable to `ComponentDef<unknown, unknown, unknown, unknown>`\n * — the `init: (data: MyData) => ...` field is contravariant in `MyData`,\n * so widening to `unknown` is rejected.\n *\n * `AnyComponentDef` (and `LazyDef<D>` below) declare the same fields\n * using **method syntax** (`init(data: D): ...`), which TypeScript\n * checks bivariantly. Concrete `ComponentDef<S, M, E, D>` assigns into\n * these structurally without any `widenDef` helper at the callsite.\n *\n * Used by every API that accepts an opaque component definition at a\n * module boundary:\n *\n * - `child({ def })`\n * - `lazy({ loader })` — returns `LazyDef<D>` so the loader's `D` survives\n * - `createOnRenderClient({ Layout })` (from `@llui/vike`)\n * - `createOnRenderHtml({ Layout })` (from `@llui/vike`)\n *\n * The `D` parameter is `unknown` here — `child()` doesn't pass init\n * data through, and `Layout` callers pass route-supplied data whose\n * shape is unknown at the type-erased boundary. Use `LazyDef<D>` when\n * you need to preserve the init data shape (the lazy loader case).\n */\nexport interface AnyComponentDef {\n name: string\n init(data: unknown): [unknown, unknown[]]\n update(state: unknown, msg: unknown): [unknown, unknown[]]\n view(h: unknown): Node[]\n onEffect?: unknown\n propsMsg?: unknown\n receives?: unknown\n __dirty?: unknown\n __renderToString?: unknown\n __msgSchema?: unknown\n __msgAnnotations?: unknown\n __bindingDescriptors?: unknown\n __schemaHash?: unknown\n __maskLegend?: unknown\n __componentMeta?: unknown\n __stateSchema?: unknown\n __effectSchema?: unknown\n __update?: unknown\n __handlers?: unknown\n}\n\n/**\n * Type-erased component definition for use at module boundaries where the\n * loaded component's S, M, E are internal and invisible to the caller.\n * Only `D` (init data) survives because the caller provides it.\n *\n * `ComponentDef<S, M, E, D>` is structurally assignable to `LazyDef<D>`\n * for any S, M, E — `view: (h: unknown) => Node[]` accepts any View via\n * contravariance, and all other fields widen to `unknown` return types.\n *\n * Used by `lazy()` as the loader's return type. Use `AnyComponentDef`\n * (above) when D is also opaque — most other adapter-layer APIs.\n */\nexport interface LazyDef<D = void> {\n name: string\n // Method syntax — TypeScript checks methods bivariantly, so\n // ComponentDef<S, M, E, D>'s concrete (state: S, msg: M) => ...\n // assigns here even though S/M ≠ unknown. Property syntax would\n // be contravariant and reject the assignment.\n init(data: D): [unknown, unknown[]]\n update(state: unknown, msg: unknown): [unknown, unknown[]]\n view(h: unknown): Node[]\n onEffect?: unknown\n propsMsg?: unknown\n receives?: unknown\n __dirty?: unknown\n __renderToString?: unknown\n __msgSchema?: unknown\n __msgAnnotations?: unknown\n __bindingDescriptors?: unknown\n __schemaHash?: unknown\n __maskLegend?: unknown\n __componentMeta?: unknown\n __stateSchema?: unknown\n __effectSchema?: unknown\n __update?: unknown\n __handlers?: unknown\n}\n\n/**\n * Maps a value shape to a reactive-props shape: every field becomes an accessor\n * `(s: S) => V`. Use for Level-1 view function signatures.\n *\n * ```ts\n * type ToolbarData = { tools: Tool[]; theme: 'light' | 'dark' }\n *\n * export function toolbar<S>(props: Props<ToolbarData, S>, send: Send<Msg>) {\n * return [div({ class: props.theme }, [each({ items: props.tools, ... })])]\n * }\n *\n * // Caller — TypeScript enforces per-field accessors; passing a raw value errors:\n * toolbar({ tools: (s: State) => s.tools, theme: (s) => s.theme }, send)\n * ```\n */\nexport type Props<T, S> = {\n [K in keyof T]: (s: S) => T[K]\n}\n\n// ── App Handle ────────────────────────────────────────────────────\n\nexport interface AppHandle {\n dispose(): void\n flush(): void\n /**\n * Dispatch a message into the mounted instance from outside its\n * normal view-bound `send` channel. Useful for adapter layers that\n * need to push updates into a long-lived instance — e.g.\n * `@llui/vike`'s persistent-layout chain pushes layout-data updates\n * into surviving layer instances on client navigation when their\n * `propsMsg` translates the new data into a state-update message.\n *\n * Messages are queued through the same path as `view`-side `send`\n * calls — they batch into the next microtask and process via the\n * normal update loop. Calling `send` after `dispose` is a no-op.\n */\n send(msg: unknown): void\n /**\n * Read the current state snapshot. Safe to call from anywhere —\n * event handlers, async callbacks, adapter `send` wrappers, or any\n * imperative context where the render context is not live.\n *\n * Unlike `sample()` (a view primitive that requires an active\n * render context and throws outside of `view()`), `getState` is\n * the sanctioned escape hatch for \"I need to know the current\n * state to decide what to dispatch.\" Typical shape:\n *\n * ```ts\n * const handle = mountApp(root, MyApp)\n * container.addEventListener('drop', () => {\n * const { mode } = handle.getState() as AppState\n * if (mode === 'drag') handle.send({ type: 'commit' })\n * })\n * ```\n *\n * Throws after `dispose()` — stale reads are silent bugs; a thrown\n * error pinpoints the callsite that forgot to detach.\n *\n * The return type is `unknown` because `AppHandle` is state-type\n * erased at this boundary; cast to your app's state type at the\n * call site.\n */\n getState(): unknown\n /**\n * Register a listener called synchronously after every update cycle\n * completes. The listener receives the new state. Returns an\n * unsubscribe function. Safe after dispose (no-op; returns a no-op\n * unsubscribe). See agent spec §10.5 (state-update frames).\n */\n subscribe(listener: (state: unknown) => void): () => void\n /**\n * Snapshot the Msg variants currently dispatchable from rendered UI.\n * Each entry corresponds to one or more event-handler bindings the\n * compiler tagged with literal `send({type: '<variant>'})` calls;\n * the registry tracks live mounts via lifetime refcounts so the\n * snapshot reflects what the user can click *right now*, not the\n * static catalogue of every variant the app could ever accept.\n *\n * Used by `@llui/agent` to populate `list_actions`. Apps that don't\n * use the LLui compiler tagger pass (or whose views contain no\n * literal sends) get an empty array — agents fall back to the Msg\n * schema for affordance discovery.\n */\n getBindingDescriptors(): Array<{ variant: string }>\n /**\n * Hot-swap the component's `update` function (and optionally\n * `onEffect`) without rebuilding the DOM. Pending messages are\n * drained against the OLD `update` first so a half-applied\n * transition can't leave the state ill-formed; subsequent\n * dispatches go through the new function.\n *\n * This is the lightweight HMR escape hatch for cases where the\n * full `replaceComponent` flow (in `@llui/dom/hmr`) is overkill —\n * pure `update.ts` edits don't change the view, so disposing the\n * root lifetime and re-running the view just to install a new\n * function is wasteful and loses focus / scroll / transient DOM\n * state. Wire it via `import.meta.hot`:\n *\n * ```ts\n * // main.ts\n * const handle = mountApp(root, App)\n * if (import.meta.hot) {\n * import.meta.hot.accept('./app/update', (mod) => {\n * if (mod) handle.swapUpdate(mod.update)\n * })\n * }\n * ```\n *\n * Caveats:\n * - Doesn't compensate for State shape changes — if the new\n * `update` reads a field the old state doesn't have, you'll\n * see runtime errors. Hard-reload after structural state\n * changes.\n * - Doesn't swap `view` or compiler-emitted `__update`/`__dirty`\n * — for those, prefer the auto-injected component-level HMR\n * accept callback (which routes through `replaceComponent`).\n */\n swapUpdate(\n newUpdate: (state: unknown, msg: unknown) => [unknown, unknown[]],\n newOnEffect?: unknown,\n ): void\n /**\n * Run the reducer in isolation against the current state. Returns\n * `[newState, effects]` — the reducer's literal output without any\n * commit, flush, or effect-handler invocation. Used by the agent's\n * `would_dispatch` tool to predict what a candidate dispatch would\n * do before committing to it.\n *\n * Pure-reducer assumption: TEA mandates `update` be pure. LLui's\n * runtime treats it that way too (no speculative re-runs for any\n * other reason). Apps whose reducers branch on `Date.now()` or\n * read `localStorage` will see prediction drift from real dispatch\n * by exactly that amount of impurity — surface as documented at\n * the agent's call site, not silently corrected here.\n *\n * **No effects fire.** Effect descriptors are returned for the\n * agent to inspect; `onEffect` is not called. This is the entire\n * point of the API.\n */\n runReducer(msg: unknown): { state: unknown; effects: unknown[] } | null\n}\n\n// ── Lifetime ─────────────────────────────────────────────────────────\n\nexport interface Lifetime {\n id: number\n parent: Lifetime | null\n children: Lifetime[]\n disposers: Array<() => void>\n bindings: Binding[]\n /** Per-item updaters — called directly by each() when item changes, bypassing Phase 2 */\n itemUpdaters: Array<() => void>\n /**\n * @internal dev-only back-reference to the owning ComponentInstance.\n * Populated on the root scope by `installDevTools` so `disposeLifetime`\n * can walk up the scope chain and emit DisposerEvents into the\n * instance's `_disposerLog`. Undefined in production.\n */\n instance?: ComponentInstance\n /**\n * @internal dev-only cause hint. Structural primitives (branch, each,\n * child, mountApp teardown) set this field immediately before calling\n * `disposeLifetime`; the dispose path reads it once to stamp the emitted\n * DisposerEvent. Left undefined, `disposeLifetime` falls back to\n * `'component-unmount'`. Undefined in production.\n */\n disposalCause?: DisposerEvent['cause']\n /** @internal dev-only — populated by structural primitives for scope-tree classification */\n _kind?: 'root' | 'show' | 'each' | 'branch' | 'scope' | 'child' | 'portal' | 'foreign'\n}\n\nexport interface LifetimeNode {\n scopeId: string\n kind: 'root' | 'show' | 'each' | 'branch' | 'scope' | 'child' | 'portal' | 'foreign'\n active: boolean\n children: LifetimeNode[]\n}\n\n// ── Binding ───────────────────────────────────────────────────────\n\n/**\n * Binding output kinds.\n *\n * `'text' | 'prop' | 'attr' | 'class' | 'style'` write their accessor's\n * return value to the DOM. `'effect'` is a side-effect-only watcher:\n * the accessor is invoked every Phase 2 tick its mask is hit, but its\n * return value is discarded and `applyBinding` is a no-op. Used by\n * `child()` to fire the prop-diff/propsMsg cascade on parent updates\n * without the cost of stringifying the returned props bag onto a\n * detached anchor node every render.\n */\nexport type BindingKind = 'text' | 'prop' | 'attr' | 'class' | 'style' | 'effect'\n\nexport interface Binding {\n mask: number\n accessor: (state: unknown) => unknown\n lastValue: unknown\n kind: BindingKind\n node: Node\n key?: string\n ownerLifetime: Lifetime\n perItem: boolean\n dead: boolean\n}\n\n// ── Structural Primitives ─────────────────────────────────────────\n\nexport interface TransitionOptions {\n enter?: (nodes: Node[]) => void | Promise<void>\n leave?: (nodes: Node[]) => void | Promise<void>\n onTransition?: (ctx: { entering: Node[]; leaving: Node[]; parent: Node }) => void | Promise<void>\n}\n\ninterface BranchOptionsBase extends TransitionOptions {\n /**\n * @internal Set by `show()` / `scope()` sugar when delegating to\n * `branch()`, so the dev-only disposer log can report `'show-hide'` /\n * `'scope-rebuild'` instead of the default `'branch-swap'` for the\n * leaving arm. User code should not set this directly.\n */\n __disposalCause?: DisposerEvent['cause']\n /** @internal Compiler-injected mask of paths read by `on`. */\n __mask?: number\n}\n\n/**\n * Discriminant accessor — reads a string-keyed value either from the\n * current state (`(s) => …`) or from a closed-over item accessor /\n * memo (`() => item.kind()`). Both forms re-evaluate on every commit.\n * The zero-arg form is the canonical shape for branching on per-row\n * fields inside an `each.render` callback.\n */\ntype Discriminant<S, K extends string> = ((s: S) => K) | (() => K)\n\n/**\n * All cases covered by `cases` — no default allowed (would be dead code).\n */\ntype BranchOptionsExhaustive<S, M, K extends string> = BranchOptionsBase & {\n on: Discriminant<S, K>\n cases: { [P in K]: (h: View<S, M>) => Node[] }\n default?: never\n}\n\n/**\n * `cases` may cover some but not all keys; `default` handles the rest.\n */\ntype BranchOptionsNonExhaustive<S, M, K extends string> = BranchOptionsBase & {\n on: Discriminant<S, K>\n cases?: { [P in K]?: (h: View<S, M>) => Node[] }\n default: (h: View<S, M>) => Node[]\n}\n\n/**\n * `on` returns a wide `string` — exhaustiveness cannot be verified at\n * compile time (the key domain is infinite). Lenient: `default` is\n * optional so existing call sites that predate exhaustiveness typing\n * continue to compile. Authors who want the gate opt in by narrowing\n * `on`'s return type to a literal union.\n */\ntype BranchOptionsWide<S, M> = BranchOptionsBase & {\n on: Discriminant<S, string>\n cases?: Record<string, (h: View<S, M>) => Node[]>\n default?: (h: View<S, M>) => Node[]\n}\n\n/**\n * Options for `branch()`.\n *\n * When `on` returns a literal string union (e.g. `'idle' | 'loading'\n * | 'done'`), TypeScript enforces exhaustiveness: either every union\n * member has a case (and `default` is disallowed as unreachable), or\n * `default` is required to cover the remainder. When `on` returns a\n * wide `string`, `default` stays optional — exhaustiveness isn't\n * meaningful for an unbounded domain.\n *\n * `cases` is optional when `default` is present; `branch({ on, default })`\n * is the canonical dynamic-rebuild shape — `scope()` sugar wraps\n * exactly this form.\n */\nexport type BranchOptions<S, M = unknown, K extends string = string> = string extends K\n ? BranchOptionsWide<S, M>\n : BranchOptionsExhaustive<S, M, K> | BranchOptionsNonExhaustive<S, M, K>\n\nexport interface ShowOptions<S, M = unknown> extends TransitionOptions {\n /**\n * Predicate evaluated on every commit. `(s) => …` reads from\n * component state; `() => …` (zero-arg) reads from a closed-over\n * source — typically `item.field()` inside an `each.render`\n * callback. Both forms are reactive: the predicate runs against\n * each new state and the rendered subtree mounts/unmounts on the\n * boolean transition.\n */\n when: ((s: S) => boolean) | (() => boolean)\n render: (h: View<S, M>) => Node[]\n fallback?: (h: View<S, M>) => Node[]\n}\n\n/**\n * Options for `scope()` — rebuilds a subtree when `on(state)` changes.\n *\n * Sugar over `branch({ on, cases: {}, default: render, __disposalCause: 'scope-rebuild' })`.\n * Use when the key is dynamic (e.g. an epoch counter bumped from the\n * outside) and you want a fresh arm — fresh lifetime, fresh bindings —\n * each time it changes. Combine with `sample()` inside `render` for a\n * one-shot current-state read.\n */\nexport interface ScopeOptions<S, M = unknown> extends TransitionOptions {\n /**\n * Key accessor evaluated on every commit. `(s) => …` reads from\n * component state; `() => …` (zero-arg) reads from a closed-over\n * source. The render callback rebuilds whenever the returned key\n * changes — fresh lifetime, fresh bindings.\n */\n on: ((s: S) => string) | (() => string)\n render: (h: View<S, M>) => Node[]\n /** @internal Compiler-injected mask of paths read by `on`. */\n __mask?: number\n}\n\n/**\n * Options for `each()`. The inherited `enter` / `leave` callbacks fire **per item**:\n * `enter(nodes)` runs after an item's DOM is inserted (including initial mount);\n * `leave(nodes)` runs before an item's DOM is removed and may return a Promise\n * to hold the DOM until the animation resolves. Setting `leave` disables the\n * bulk-clear / full-replace fast paths.\n */\n/**\n * Per-item accessor. Two access forms:\n * - `item.field` — shorthand, returns accessor for `item.current[field]`\n * - `item(t => t.expr)` — computed expressions\n *\n * In both cases the returned value is a `() => V` accessor.\n * Invoke it (`item.field()`) to read the current value imperatively.\n */\nexport type ItemAccessor<T> = {\n <R>(selector: (t: T) => R): () => R\n} & {\n [K in keyof T]-?: () => T[K]\n} & {\n /**\n * Read the whole current item. Needed when T is a primitive (where the\n * field-map branch collapses to method names like `toString`) or when\n * you want to sample the entire record rather than a single field.\n *\n * Shadows any literal `current` field on T — if T has such a field,\n * use `item(r => r.current)` to disambiguate.\n */\n current(): T\n}\n\nexport interface EachOptions<S, T, M = unknown> extends TransitionOptions {\n items: (s: S) => T[]\n key: (item: T) => string | number\n render: (opts: {\n send: Send<M>\n item: ItemAccessor<T>\n /**\n * Plain (non-Proxy) accessor factory. Compiler-output path; avoid in user code\n * (use `item.field` / `item(fn)` — more ergonomic and bypasses Proxy when compiled).\n */\n acc: <R>(selector: (t: T) => R) => () => R\n index: () => number\n /**\n * The component's View bag (`h.text`, `h.show`, `h.branch`,\n * `h.scope`, `h.sample`, …). Each-render callers used to reach\n * for the top-level imports; the bag form is symmetric with how\n * `branch.cases[k]`, `show.render`, and `scope.render` receive it.\n * Both still work — destructure whichever is more convenient.\n */\n h: View<S, M>\n /** @internal Compiler-injected — entry reference for row factory */\n entry?: Record<string, unknown>\n }) => Node[]\n}\n\nexport interface PortalOptions {\n target: HTMLElement | string\n render: () => Node[]\n}\n\nexport interface ForeignOptions<S, M, T extends Record<string, unknown>, Instance> {\n /**\n * Construct the imperative instance. Can be async — return a\n * `Promise<Instance>` to defer construction until e.g. a dynamic\n * `import()` resolves. While the promise is pending:\n *\n * - The container element is in the DOM immediately (so layout\n * doesn't shift when the instance arrives).\n * - `sync` is NOT called. State changes are tracked by the\n * primitive and the latest props are applied as the initial\n * sync right after the promise resolves.\n * - If the owning scope disposes before the promise resolves,\n * `destroy(instance)` runs on resolution — no matter how long\n * the promise takes.\n */\n mount: (ctx: { container: HTMLElement; send: Send<M> }) => Instance | Promise<Instance>\n props: (s: S) => T\n sync:\n | ((ctx: { instance: Instance; props: T; prev: T | undefined }) => void)\n | {\n [K in keyof T]?: (ctx: { instance: Instance; value: T[K]; prev: T[K] | undefined }) => void\n }\n destroy: (instance: Instance) => void\n container?: { tag?: string; attrs?: Record<string, string> }\n}\n\nexport interface ChildOptions<S, ChildM> {\n // Type-erased via AnyComponentDef so callers can pass any concrete\n // ComponentDef<S, M, E, D> without a widening helper. The runtime\n // narrows the message shape via the user-supplied `onMsg` callback,\n // which keeps `ChildM` typed at this boundary even though the def\n // itself is opaque.\n def: AnyComponentDef\n key: string | number\n props: (s: S) => Record<string, unknown>\n onMsg?: (msg: ChildM) => unknown | null\n}\n"]}
|
|
@@ -1 +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;AAmBtD,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,CA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AAA;QACjD,IAAI,OAAO,OAAO,CAAC,SAAS,KAAK,UAAU,EAAE,CAAC;YAC5C,MAAM,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'\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\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 binding.accessor(state)\n continue\n }\n const newValue = binding.accessor(state)\n if (Object.is(newValue, binding.lastValue)) continue\n binding.lastValue = newValue\n applyBinding(binding, newValue)\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(state, combinedDirty, bindings, bindingsBeforePhase1, inst.def.name)\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)\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): 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 if (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 // Side-effect-only: run accessor, discard return, skip the\n // Object.is diff and `applyBinding` entirely. Used by child()'s\n // prop-watch binding so fresh-object props accessors don't\n // stringify onto a detached anchor every update.\n try {\n binding.accessor(state)\n } catch (e) {\n throw enhanceBindingError(e, binding, componentName)\n }\n continue\n }\n let newValue: unknown\n try {\n newValue = binding.accessor(state)\n } catch (e) {\n throw enhanceBindingError(e, binding, componentName)\n }\n const last = binding.lastValue\n if (newValue === last || (newValue !== newValue && last !== last)) continue\n binding.lastValue = newValue\n applyBinding(binding, newValue)\n }\n } else {\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 binding.accessor(state)\n continue\n }\n const newValue = binding.accessor(state)\n const last = binding.lastValue\n if (newValue === last || (newValue !== newValue && last !== last)) continue\n binding.lastValue = newValue\n applyBinding(binding, newValue)\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,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;AAE1D,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;AAkED,MAAM,UAAU,uBAAuB,CACrC,G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,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 — 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 binding.accessor(state)\n continue\n }\n const newValue = binding.accessor(state)\n if (Object.is(newValue, binding.lastValue)) continue\n binding.lastValue = newValue\n applyBinding(binding, newValue)\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(state, combinedDirty, bindings, bindingsBeforePhase1, inst.def.name)\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)\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): 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 if (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 // Side-effect-only: run accessor, discard return, skip the\n // Object.is diff and `applyBinding` entirely. Used by child()'s\n // prop-watch binding so fresh-object props accessors don't\n // stringify onto a detached anchor every update.\n try {\n binding.accessor(state)\n } catch (e) {\n throw enhanceBindingError(e, binding, componentName)\n }\n continue\n }\n let newValue: unknown\n try {\n newValue = binding.accessor(state)\n } catch (e) {\n throw enhanceBindingError(e, binding, componentName)\n }\n const last = binding.lastValue\n if (newValue === last || (newValue !== newValue && last !== last)) continue\n binding.lastValue = newValue\n applyBinding(binding, newValue)\n }\n } else {\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 binding.accessor(state)\n continue\n }\n const newValue = binding.accessor(state)\n const last = binding.lastValue\n if (newValue === last || (newValue !== newValue && last !== last)) continue\n binding.lastValue = newValue\n applyBinding(binding, newValue)\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/dist/view-helpers.d.ts
CHANGED
|
@@ -33,13 +33,29 @@ export interface View<S, M> {
|
|
|
33
33
|
branch<K extends string = string>(opts: BranchOptions<S, M, K>): Node[];
|
|
34
34
|
scope(opts: ScopeOptions<S, M>): Node[];
|
|
35
35
|
each<T>(opts: EachOptions<S, T, M>): Node[];
|
|
36
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Reactive text node. Three accepted forms, all reactive at the
|
|
38
|
+
* binding layer:
|
|
39
|
+
* - **Static** — `text('hello')` for a fixed string.
|
|
40
|
+
* - **State accessor** — `text((s) => s.title)` reads from the
|
|
41
|
+
* component's state on every commit.
|
|
42
|
+
* - **Item accessor (zero-arg)** — `text(item.title)` inside an
|
|
43
|
+
* `each.render` callback reads the current item's value. The
|
|
44
|
+
* runtime detects the zero-arg form and registers it as a
|
|
45
|
+
* per-item updater — same reactivity, no full state-mask scan.
|
|
46
|
+
*
|
|
47
|
+
* Eager invocation (`text(item.title())`) is **static** — it reads
|
|
48
|
+
* once at view-construction and the resulting Text node never
|
|
49
|
+
* updates. The `agent-no-eager-item-accessor` lint rule flags this.
|
|
50
|
+
*/
|
|
51
|
+
text(accessor: ((s: S) => string) | (() => string) | string, mask?: number): Text;
|
|
37
52
|
/**
|
|
38
53
|
* Insert raw HTML into the tree. Caller is responsible for sanitizing.
|
|
39
54
|
* The parsed subtree is opaque to LLui — no nested bindings, events,
|
|
40
|
-
* or primitives inside it will be tracked.
|
|
55
|
+
* or primitives inside it will be tracked. Same accessor forms as
|
|
56
|
+
* `text` — state-keyed, item-keyed (zero-arg), or static string.
|
|
41
57
|
*/
|
|
42
|
-
unsafeHtml(accessor: ((s: S) => string) | string, mask?: number): Node[];
|
|
58
|
+
unsafeHtml(accessor: ((s: S) => string) | (() => string) | string, mask?: number): Node[];
|
|
43
59
|
memo<T>(accessor: (s: S) => T): (s: S) => T;
|
|
44
60
|
selector<V>(field: (s: S) => V): SelectorInstance<V>;
|
|
45
61
|
ctx<T>(c: Context<T>): (s: S) => T;
|