@verajs/renderer 0.2.2 → 0.3.0

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.
Files changed (90) hide show
  1. package/README.md +711 -225
  2. package/dist/development/vera-renderer-elements.d.ts +39 -0
  3. package/dist/development/vera-renderer-elements.d.ts.map +1 -0
  4. package/dist/development/vera-renderer-elements.js +193 -0
  5. package/dist/development/vera-renderer-elements.js.map +1 -0
  6. package/dist/development/vera-renderer-hydrate-slots.d.ts +94 -0
  7. package/dist/development/vera-renderer-hydrate-slots.d.ts.map +1 -0
  8. package/dist/development/vera-renderer-hydrate-slots.js +325 -0
  9. package/dist/development/vera-renderer-hydrate-slots.js.map +1 -0
  10. package/dist/development/vera-renderer-hydration.d.ts +332 -0
  11. package/dist/development/vera-renderer-hydration.d.ts.map +1 -0
  12. package/dist/development/vera-renderer-hydration.js +864 -0
  13. package/dist/development/vera-renderer-hydration.js.map +1 -0
  14. package/dist/development/vera-renderer-keyed.d.ts +25 -8
  15. package/dist/development/vera-renderer-keyed.d.ts.map +1 -1
  16. package/dist/development/vera-renderer-keyed.js +843 -268
  17. package/dist/development/vera-renderer-keyed.js.map +1 -1
  18. package/dist/development/vera-renderer-multi-window.d.ts +5 -0
  19. package/dist/development/vera-renderer-multi-window.d.ts.map +1 -0
  20. package/dist/development/vera-renderer-multi-window.js +40 -0
  21. package/dist/development/vera-renderer-multi-window.js.map +1 -0
  22. package/dist/development/vera-renderer-namespaces.d.ts +64 -0
  23. package/dist/development/vera-renderer-namespaces.d.ts.map +1 -0
  24. package/dist/development/vera-renderer-namespaces.js +94 -0
  25. package/dist/development/vera-renderer-namespaces.js.map +1 -0
  26. package/dist/development/vera-renderer-native-elements.d.ts +13 -0
  27. package/dist/development/vera-renderer-native-elements.d.ts.map +1 -0
  28. package/dist/development/vera-renderer-native-elements.js +231 -0
  29. package/dist/development/vera-renderer-native-elements.js.map +1 -0
  30. package/dist/development/vera-renderer-portal.d.ts +29 -0
  31. package/dist/development/vera-renderer-portal.d.ts.map +1 -0
  32. package/dist/development/vera-renderer-portal.js +167 -0
  33. package/dist/development/vera-renderer-portal.js.map +1 -0
  34. package/dist/development/vera-renderer-profiler.d.ts +48 -96
  35. package/dist/development/vera-renderer-profiler.d.ts.map +1 -1
  36. package/dist/development/vera-renderer-profiler.js +2423 -2140
  37. package/dist/development/vera-renderer-profiler.js.map +1 -1
  38. package/dist/development/vera-renderer-slots.d.ts +88 -92
  39. package/dist/development/vera-renderer-slots.d.ts.map +1 -1
  40. package/dist/development/vera-renderer-slots.js +1834 -1237
  41. package/dist/development/vera-renderer-slots.js.map +1 -1
  42. package/dist/development/vera-renderer-spread.d.ts +7 -41
  43. package/dist/development/vera-renderer-spread.d.ts.map +1 -1
  44. package/dist/development/vera-renderer-spread.js +539 -477
  45. package/dist/development/vera-renderer-spread.js.map +1 -1
  46. package/dist/development/vera-renderer-tag.d.ts +12 -3
  47. package/dist/development/vera-renderer-tag.d.ts.map +1 -1
  48. package/dist/development/vera-renderer-tag.js +671 -513
  49. package/dist/development/vera-renderer-tag.js.map +1 -1
  50. package/dist/development/vera-renderer-until.d.ts +24 -0
  51. package/dist/development/vera-renderer-until.d.ts.map +1 -0
  52. package/dist/development/vera-renderer-until.js +83 -0
  53. package/dist/development/vera-renderer-until.js.map +1 -0
  54. package/dist/development/vera-renderer.d.ts +48 -96
  55. package/dist/development/vera-renderer.d.ts.map +1 -1
  56. package/dist/development/vera-renderer.js +2400 -2104
  57. package/dist/development/vera-renderer.js.map +1 -1
  58. package/dist/vera-renderer-elements.min.js +2 -0
  59. package/dist/vera-renderer-elements.min.js.map +1 -0
  60. package/dist/vera-renderer-hydrate-slots.min.js +2 -0
  61. package/dist/vera-renderer-hydrate-slots.min.js.map +1 -0
  62. package/dist/vera-renderer-hydration.min.js +3 -0
  63. package/dist/vera-renderer-hydration.min.js.map +1 -0
  64. package/dist/vera-renderer-keyed.min.js +1 -1
  65. package/dist/vera-renderer-keyed.min.js.map +1 -1
  66. package/dist/vera-renderer-multi-window.min.js +2 -0
  67. package/dist/vera-renderer-multi-window.min.js.map +1 -0
  68. package/dist/vera-renderer-namespaces.min.js +2 -0
  69. package/dist/vera-renderer-namespaces.min.js.map +1 -0
  70. package/dist/vera-renderer-native-elements.min.js +2 -0
  71. package/dist/vera-renderer-native-elements.min.js.map +1 -0
  72. package/dist/vera-renderer-portal.min.js +2 -0
  73. package/dist/vera-renderer-portal.min.js.map +1 -0
  74. package/dist/vera-renderer-slots.min.js +1 -1
  75. package/dist/vera-renderer-slots.min.js.map +1 -1
  76. package/dist/vera-renderer-spread.min.js +1 -1
  77. package/dist/vera-renderer-spread.min.js.map +1 -1
  78. package/dist/vera-renderer-tag.min.js +1 -1
  79. package/dist/vera-renderer-tag.min.js.map +1 -1
  80. package/dist/vera-renderer-until.min.js +2 -0
  81. package/dist/vera-renderer-until.min.js.map +1 -0
  82. package/dist/vera-renderer.min.js +1 -1
  83. package/dist/vera-renderer.min.js.map +1 -1
  84. package/package.json +52 -9
  85. package/dist/development/vera-renderer-hydrate.d.ts +0 -147
  86. package/dist/development/vera-renderer-hydrate.d.ts.map +0 -1
  87. package/dist/development/vera-renderer-hydrate.js +0 -3136
  88. package/dist/development/vera-renderer-hydrate.js.map +0 -1
  89. package/dist/vera-renderer-hydrate.min.js +0 -2
  90. package/dist/vera-renderer-hydrate.min.js.map +0 -1
@@ -0,0 +1,39 @@
1
+ /**
2
+ * **What a claimant attaches to an element it claimed** — `@verajs/renderer/elements`. One shared
3
+ * object for every claimed element of every instance of a template; plain method names, which
4
+ * mangling leaves alone, so it crosses the bundle boundary. The `'element'` insert in
5
+ * `@verajs/inserts` is declared with this same shape. **A throw from any of the three is reported, never raised** —
6
+ * the ref rule: to the `'error'` chain with the component, else as uncaught; the render, the other claims and the
7
+ * teardown carry on. A claim whose `create` threw is dropped for that instance (never mounted or unmounted).
8
+ */
9
+ type ElementBehavior = {
10
+ /**
11
+ * Once per instance, at its creation: before its first update (the clone is inert — a binding position is still its
12
+ * empty placeholder) and before it is connected. `adopted` is true when hydration adopted the server's element.
13
+ */
14
+ create?(element: Element, adopted: boolean): void;
15
+ /**
16
+ * Once per instance, after its first update — bindings committed, the element possibly not yet
17
+ * connected (a host rendered off-page, a row in its batching fragment). `root` is the render root
18
+ * the instance was committed into, `null` outside any render; `adopted` is true when hydration
19
+ * adopted the server's element rather than creating one. Whatever it returns is kept for `unmount`.
20
+ */
21
+ mount?(element: Element, context: {
22
+ root: Node | null;
23
+ adopted: boolean;
24
+ }): unknown;
25
+ /** Once, at the instance's teardown, with what `mount` returned — only when that was not undefined. */
26
+ unmount?(kept: unknown, element: Element): void;
27
+ };
28
+
29
+ /** Wire it as `wire([renderer, elements, …claims])`. A bare module: it has no options. */
30
+ declare const elements: (((registry: Map<string, unknown[]>) => void) | {
31
+ name: string;
32
+ on: "template";
33
+ fn: (built: object, _result: unknown, _readScope: unknown, root: Node) => void;
34
+ priority: number;
35
+ })[];
36
+
37
+ export { elements };
38
+ export type { ElementBehavior };
39
+ //# sourceMappingURL=vera-renderer-elements.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vera-renderer-elements.d.ts","sources":["../../src/elements.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA;AACA,cAAc,QAAQ;AAItB;AAEA;;;;;;;","names":[]}
@@ -0,0 +1,193 @@
1
+ /**
2
+ * **Where every diagnostic code is explained.** The URL is permanent: a released bundle is immutable, so every version
3
+ * published points here for ever — the domain cannot lapse and `/e/` cannot be reorganized without breaking links in
4
+ * code nobody can edit; the docs site redirects instead. `scripts/sync-diagnostics.mjs` imports this constant, so the
5
+ * pages and the bundles can never disagree about where they are.
6
+ */
7
+ const DOCS = 'https://verajs.dev/e/';
8
+ const diagnostic = (inArea, bySubject, withCode, andProse) =>
9
+ /** `true ` HERE as well as at the call: production folds this to the one-line form, branch and all. */
10
+ true && andProse
11
+ ? `[vera] ${inArea}: ${bySubject} — ${andProse[0]}${andProse[1] ? ` ${andProse[1]}` : ''} (${withCode})`
12
+ : `[vera] ${inArea}: ${bySubject} — ${DOCS}${withCode}`;
13
+
14
+ /**
15
+ * **Reports an error nothing else handled, the way the platform reports one.** `reportError` fires
16
+ * the window's `error` event — what `window.onerror`, error trackers and test runners listen for —
17
+ * without unwinding the caller, so one failing hook or ref never stops its siblings. A bare
18
+ * `console.error` reached none of those: a component could stop updating while every page-error
19
+ * listener stayed silent. Off-browser (Node has no `reportError`) the console is all there is.
20
+ * `line` is the framework's own line, printed beside the error — a CODED one (2026-10-09):
21
+ * each caller passes `'[vera] <code>'` in production and its table's `diagnostic()` sentence in development, both
22
+ * literal codes at the call site, so the static checks read them. The subject is fixed wording too (`a hook`, `an
23
+ * element ref`), never a tag name: this line is the console's FORMAT (no `'%s'`, which measured +2–3 B on the renderer
24
+ * bundles), so nothing from outside may reach it — the element goes to the `'error'` handlers instead. Production prints it only where the platform has no
25
+ * `reportError` (Node); in a browser, `reportError` alone reports.
26
+ *
27
+ * Shared by core (a hook threw) and the renderer (a ref threw) so the fallback is one rule.
28
+ */
29
+ const reportUncaught = (error, line) => {
30
+ if (typeof reportError !== 'function')
31
+ console.error(line, error);
32
+ else {
33
+ if (true )
34
+ console.error(line, error);
35
+ reportError(error);
36
+ }
37
+ };
38
+ /**
39
+ * **Reports what user code a render called threw — to the app's `'error'` chain, else as uncaught.** One rule for
40
+ * every callback the framework runs on the user's behalf and survives: a hook (core), an element ref, and an element
41
+ * claim's `create`/`mount`/`unmount` (the renderer). The caller catches at the call site and carries on, so one
42
+ * failing callback never stops its siblings or leaves a commit half applied. `element` is the component the error
43
+ * belongs to, handed to each handler. Every throw is reported — nothing is deduped, as a hook's never was.
44
+ * **Core keeps a deliberate twin** (`reportHookError`, the same rule as a `forEach`): routed through here it measured
45
+ * +11 B gzip on `vera.min.js` (2026-10-09). A change to the rule changes both.
46
+ */
47
+ const reportTo = (handlers, error, element, line) => {
48
+ if (handlers?.length)
49
+ for (const handler of handlers)
50
+ handler(error, element);
51
+ else
52
+ reportUncaught(error, line);
53
+ };
54
+ /** The component a render root belongs to: a shadow root's host, or a light root itself. */
55
+ const hostOf = (root) => root == null ? undefined : root.nodeType === 11 ? root.host : root;
56
+
57
+ const PROSE = {
58
+ 'claim-threw': (phase, outcome) => [
59
+ `threw in ${phase}; its error is printed beside this line, and ${outcome}.`,
60
+ "Fix the claim's callback, or wire an 'error' insert to handle what claims throw.",
61
+ ],
62
+ 'elements-hook-replaced': () => [
63
+ "a 'template' hook set an instance hook before `elements` (priority 10) and is replaced.",
64
+ 'Claim elements through the `element` insert instead of a second instance hook.',
65
+ ],
66
+ };
67
+
68
+ let registered = null;
69
+ /**
70
+ * **A claim's callbacks follow the ref rule** (Brian, 2026-10-09): user code a render calls is caught AT ITS CALL SITE
71
+ * — so a template with no claims runs exactly the path it did — reported to the app's `'error'` chain with the
72
+ * component it belongs to (else as uncaught), and the render, the other claims and the teardown carry on. A mid-commit
73
+ * throw once left a component's root empty for good; `mount` propagating aborted every later claim's mount.
74
+ */
75
+ const report = (error, root, line) => reportTo(registered?.get('error'), error, hostOf(root), line);
76
+ /**
77
+ * **The next element of an instance in document pre-order, never leaving it.** A root is a fragment, or — for a
78
+ * single-root template — its one element, which is then position 0. Bounded by the root rather than by the tree it
79
+ * sits in, because a hydrated instance is already in the page.
80
+ */
81
+ const firstIn = (root) => (root.nodeType === 1 ? root : root.firstElementChild);
82
+ const nextIn = (node, root) => {
83
+ if (node.firstElementChild !== null)
84
+ return node.firstElementChild;
85
+ for (let at = node; at !== null && at !== root; at = at.parentElement)
86
+ if (at.nextElementSibling !== null)
87
+ return at.nextElementSibling;
88
+ return null;
89
+ };
90
+ /** The instance hook for one template, from the positions and behaviors its claimants answered. */
91
+ const hookFor = (positions, behaviors) => ({
92
+ $c: (instance, root, adopted) => {
93
+ const found = [];
94
+ /**
95
+ * ADOPTED, the instance arrives as its elements in template order (hydration pairs them): its live root already
96
+ * holds what its nested parts rendered, so counting there would land on the wrong element.
97
+ */
98
+ const listed = Array.isArray(instance);
99
+ let node = listed ? null : firstIn(instance);
100
+ let at = 0;
101
+ for (let k = 0; k < positions.length; k++) {
102
+ if (listed)
103
+ node = instance[positions[k]];
104
+ else
105
+ for (; at < positions[k]; at++)
106
+ node = nextIn(node, instance);
107
+ /**
108
+ * At creation — before the first update, and before the instance is connected anywhere. A claim whose `create`
109
+ * throws is reported and DROPPED for this instance (it never mounts or unmounts, being half made); the element
110
+ * stays as the template built it — a claim inserts nothing — and every other claim carries on. The ref rule.
111
+ */
112
+ try {
113
+ behaviors[k].create?.(node, adopted);
114
+ }
115
+ catch (error) {
116
+ report(error, root, true ? diagnostic('elements', 'an element claim', 'claim-threw', true && PROSE['claim-threw']('create', 'the render continued without it')) : '[vera] claim-threw');
117
+ continue;
118
+ }
119
+ found.push(node, behaviors[k]);
120
+ }
121
+ return { f: found, r: root, a: adopted, k: undefined, d: false };
122
+ },
123
+ $m: (given) => {
124
+ const state = given;
125
+ /** Torn down before its render finished: it never mounts. */
126
+ if (state.d)
127
+ return;
128
+ const found = state.f;
129
+ const context = { root: state.r, adopted: state.a };
130
+ state.f = null;
131
+ for (let i = 0; i < found.length; i += 2) {
132
+ const behavior = found[i + 1];
133
+ let value;
134
+ try {
135
+ value = behavior.mount?.(found[i], context);
136
+ }
137
+ catch (error) {
138
+ report(error, state.r, true ? diagnostic('elements', 'an element claim', 'claim-threw', true && PROSE['claim-threw']('mount', 'the others still mounted')) : '[vera] claim-threw');
139
+ continue;
140
+ }
141
+ if (value !== undefined && behavior.unmount !== undefined)
142
+ (state.k ??= []).push(found[i], behavior, value);
143
+ }
144
+ },
145
+ $q: (given) => {
146
+ const state = given;
147
+ state.d = true;
148
+ const kept = state.k;
149
+ if (kept !== undefined)
150
+ for (let i = 0; i < kept.length; i += 3)
151
+ try {
152
+ kept[i + 1].unmount(kept[i + 2], kept[i]);
153
+ }
154
+ catch (error) {
155
+ report(error, state.r, true ? diagnostic('elements', 'an element claim', 'claim-threw', true && PROSE['claim-threw']('unmount', 'the rest of the teardown ran')) : '[vera] claim-threw');
156
+ }
157
+ },
158
+ });
159
+ /**
160
+ * Asks the claimants about the template's canonical content, once, as it is built — and gives it an instance hook
161
+ * only if something was claimed. The content is READ, never changed (see the `'template'` insert's contract).
162
+ */
163
+ const claimTemplate = (built, _result, _readScope, root) => {
164
+ const claims = registered?.get('element');
165
+ if (claims === undefined || claims.length === 0)
166
+ return;
167
+ const template = built;
168
+ if (true && template._$inst$ !== undefined)
169
+ console.warn(diagnostic('elements', 'template', 'elements-hook-replaced', true && PROSE['elements-hook-replaced']()));
170
+ const positions = [];
171
+ const behaviors = [];
172
+ let at = 0;
173
+ for (let node = firstIn(root); node !== null; node = nextIn(node, root), at++)
174
+ for (let i = 0; i < claims.length; i++) {
175
+ const behavior = claims[i](node);
176
+ if (behavior !== undefined) {
177
+ positions.push(at);
178
+ behaviors.push(behavior);
179
+ }
180
+ }
181
+ if (positions.length > 0)
182
+ template._$inst$ = hookFor(positions, behaviors);
183
+ };
184
+ /** Wire it as `wire([renderer, elements, …claims])`. A bare module: it has no options. */
185
+ const elements = [
186
+ (registry) => {
187
+ registered = registry;
188
+ },
189
+ { name: '@verajs/renderer/elements', on: 'template', fn: claimTemplate, priority: 10 },
190
+ ];
191
+
192
+ export { elements };
193
+ //# sourceMappingURL=vera-renderer-elements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vera-renderer-elements.js","sources":["../../../shared-utils/src/diagnostic.ts","../../../shared-utils/src/utils.ts","../../src/elements-diagnostics.ts","../../src/elements.ts"],"sourcesContent":["/**\n * **Where every diagnostic code is explained.** The URL is permanent: a released bundle is immutable, so every version\n * published points here for ever — the domain cannot lapse and `/e/` cannot be reorganized without breaking links in\n * code nobody can edit; the docs site redirects instead. `scripts/sync-diagnostics.mjs` imports this constant, so the\n * pages and the bundles can never disagree about where they are.\n */\nexport const DOCS = 'https://verajs.dev/e/';\n\n/**\n * **What this copy of the framework has already said** (Brian's ruling, 2026-11-12): the ONE memory behind `warnOnce`, `errorOnce`\n * and `hasWarned`, for DEVELOPMENT-ONLY warnings. It replaced the hand-written once-flags every package kept\n * (`saidLists`, `warnedDrop`, per-element WeakSets, per-key Sets: two naming styles, Brian: no names). **A warning that\n * ships to production keeps its memory at its site** (bytes, measured 2026-11-12: the shared memory costs +80–145 B gz\n * per bundle); development-only warnings use warnOnce. Module state by necessity, since \"once\" spans every call on the\n * page. One per BUNDLE COPY, exactly the scope each flag had, because this package is inlined into every bundle.\n * A code, or `code key` for a string key, in a Set. An object key (an element, a setup function) in a WeakMap, so its\n * entry goes with the object. Marked pure, so a bundle that never prints once drops both.\n */\nconst printed = /* @__PURE__ */ new Set<string>();\nconst printedOn = /* @__PURE__ */ new WeakMap<object, Map<string, Set<unknown>>>();\n/**\n * A once's KEY: none (once per page), a string (once per that string), an object (once per that object: an element, a\n * class, a setup function), or the PAIR `[object, value]`, a value key on that object (a store write: the object and its\n * property; a keyed list: the list and the duplicate key, compared as the list compares them, by value, so `1` and `'1'`\n * stay apart). A pair is the only array a key may be.\n */\ntype OnceKey = string | object | readonly [object, unknown];\n/** Where an object key's (code, value) lives: the value set for that code on that object, made on demand. */\nconst valuesOn = (on: object, code: string, make: boolean): Set<unknown> | undefined => {\n let codes = printedOn.get(on);\n if (codes === undefined) {\n if (!make) return undefined;\n printedOn.set(on, (codes = new Map()));\n }\n let values = codes.get(code);\n if (values === undefined && make) codes.set(code, (values = new Set()));\n return values;\n};\n/** The object and value of an object or pair key. */\nconst split = (key: object): readonly [object, unknown] => (Array.isArray(key) ? (key as unknown as readonly [object, unknown]) : [key, undefined]);\n/** Whether (code, key) is new, recording it if so. */\nconst firstTime = (code: string, key?: OnceKey): boolean => {\n if (key === undefined || typeof key === 'string') {\n const entry = key === undefined ? code : `${code} ${key}`;\n if (printed.has(entry)) return false;\n printed.add(entry);\n return true;\n }\n const [on, sub] = split(key);\n const values = valuesOn(on, code, true)!;\n if (values.has(sub)) return false;\n values.add(sub);\n return true;\n};\n\n/**\n * **One shape for every diagnostic the framework prints** — the short line production keeps, the whole sentence\n * development adds — so a package converting its messages writes a table and a call, never its own format.\n *\n * production `[vera] hydration: element: found <i> — https://verajs.dev/e/hydration-fallback`\n * development `[vera] hydration: element: found <i> — fell back to a client render: … (hydration-fallback)`\n *\n * `subject` is the free information — what the code already has at hand, naming the problem area — the same in both\n * builds. `prose` is development only: the package's table entry (`Prose`), called behind `__DEV__` at the call site so\n * the table goes unreferenced in production and rollup drops it whole. Production prints the code inside the link, so\n * the reader is one click from the explanation, which `scripts/sync-diagnostics.mjs` publishes from the same tables.\n *\n * **Every production message is coded** (Brian, 2026-11-11; this supersedes \"convert where smaller\", 2026-10-02):\n * consistency over a few bytes, so no package keeps a hand-written production line beside its table.\n */\n/*\n * The parameter names are deliberately unlike anything a caller holds: terser will not inline a function whose\n * parameter shadows a name at the call site (measured 2026-10-02 — directives passes its own `code`, and a parameter\n * called `code` left `((e,t,n)=>`…`)(0,t,n)` in its bundle, +8 B; renamed, the call folds to the bare template).\n */\n/**\n * **A misused API, named by its function** — the thrown-error twin of `diagnostic()`: `untrack: expected a function …\n * (untrack-not-function)`, function-first because a stack already names the source and the sweep reads that shape. The\n * prose comes from a package's table, behind `__DEV__`, so a development-only guard costs production nothing.\n */\nexport const misuse = (forName: string, withCode: string, andProse?: false | readonly [string, string?]) =>\n __DEV__ && andProse\n ? `${forName}: ${andProse[0]}${andProse[1] ? ` ${andProse[1]}` : ''} (${withCode})`\n : `${forName}: ${DOCS}${withCode}`;\n\n/**\n * **A misused API and what it was misused ABOUT** — `misuse()` with a subject, in `diagnostic()`'s ` — ` separator:\n * `parseFrontmatter: line 3 — https://verajs.dev/e/cms-frontmatter-unsupported`. The subject is the free information\n * (a line, a URL and its status) and prints in both builds. A sibling rather than an optional parameter on `misuse()`,\n * because `misuse()` is inlined into every bundle that throws and a conditional subject would tax all of them for a\n * shape few need; a sibling is tree-shaken where unused.\n */\nexport const misuseAbout = (forName: string, aboutSubject: string, withCode: string, andProse?: false | readonly [string, string?]) =>\n __DEV__ && andProse\n ? `${forName}: ${aboutSubject} — ${andProse[0]}${andProse[1] ? ` ${andProse[1]}` : ''} (${withCode})`\n : `${forName}: ${aboutSubject} — ${DOCS}${withCode}`;\n\nexport const diagnostic = (\n inArea: string,\n bySubject: string,\n withCode: string,\n andProse?: false | readonly [string, string?]\n) =>\n /** `__DEV__` HERE as well as at the call: production folds this to the one-line form, branch and all. */\n __DEV__ && andProse\n ? `[vera] ${inArea}: ${bySubject} — ${andProse[0]}${andProse[1] ? ` ${andProse[1]}` : ''} (${withCode})`\n : `[vera] ${inArea}: ${bySubject} — ${DOCS}${withCode}`;\n\n/**\n * **Text from outside — a file path, a YAML key, a URL, an error's message — quoted before it reaches a line.** A log is a\n * pipeline, and such text can be shaped by an author or a request: a newline in it forges a line, an ESC sequence hides\n * one (log injection). `JSON.stringify` escapes both; cut to 80 characters so one value cannot fill the log. @verajs/ssr\n * keeps a twin (it cannot import this), held equal by tests/ssr-coded-diagnostics.\n */\n/**\n * `max` caps the length (80 by default); `Infinity` keeps the whole text for a value worth reading in full — a site\n * owner's own path — which is still ESCAPED: truncation and escaping are separate jobs, and a path is not free of control\n * characters just because its owner wrote it (2026-10-09).\n */\nexport const quoted = (text: string, max = 80): string => JSON.stringify(text.length > max ? `${text.slice(0, max)}…` : text);\n\n/**\n * **The errors a package constructs, marked as its own** — so a wrapper that reports an inner refusal (cms's\n * `generateManifest` around a frontmatter line) carries it as it is: already formatted, its outside text already\n * quoted. Anything else is foreign, and quoted. Identity, never a shape test: a message can imitate ours, an identity\n * cannot. @verajs/ssr keeps a twin (it cannot import this).\n */\nconst ours = /* @__PURE__ */ new WeakSet<object>();\nexport const own = <E extends Error>(error: E): E => {\n ours.add(error);\n return error;\n};\nexport const isOwn = (error: unknown): boolean => typeof error === 'object' && error !== null && ours.has(error);\n\n/**\n * **Whether this copy has already said `code` (for `key`)**: for a GUARD only, where deciding to warn costs work worth\n * skipping once the warning is out (development's whole-tree walk for unwired directive attributes, an event-name\n * guess over every property of an element). A site that only prints calls `warnOnce`. Asks, never records.\n */\nexport const hasWarned = (code: string, key?: OnceKey): boolean => {\n if (key === undefined || typeof key === 'string') return printed.has(key === undefined ? code : `${code} ${key}`);\n const [on, sub] = split(key);\n return valuesOn(on, code, false)?.has(sub) === true;\n};\n\ntype Detail = false | readonly [string, string?] | (() => readonly [string, string?] | undefined);\n/**\n * The printer behind both, on one level. `andDetail` is `diagnostic()`'s prose, or a function returning it where building\n * the sentence costs something: it is called only the first time. `...andMore` rides beside the line behind '%s' (an\n * element, a thrown error), never inside it, so text from outside cannot forge a line. The console method is read at the\n * call, so a test that replaces `console.warn` sees it.\n */\nconst sayOnce =\n (level: 'warn' | 'error') =>\n (inArea: string, bySubject: string, withCode: string, andDetail?: Detail, forKey?: OnceKey, ...andMore: unknown[]): void => {\n if (!firstTime(withCode, forKey)) return;\n const line = diagnostic(inArea, bySubject, withCode, typeof andDetail === 'function' ? andDetail() : andDetail);\n if (andMore.length) console[level]('%s', line, ...andMore);\n else console[level](line);\n };\n/**\n * **A diagnostic said once per page** (per key, where one is given: a string, or an object such as the element it is\n * about): `diagnostic()`'s arguments, then the key, then what rides beside the line. Coded in production exactly as\n * `diagnostic()` is, because it IS `diagnostic()`. `errorOnce` is its twin on `console.error`, for a refusal a page should\n * not miss.\n */\nexport const warnOnce = /* @__PURE__ */ sayOnce('warn');\nexport const errorOnce = /* @__PURE__ */ sayOnce('error');\n","import type { HandlerHolder, Untracked } from './types.js';\nimport { diagnostic } from './diagnostic.js';\nimport * as SHARED from './diagnostics.js';\n\n/**\n * Get an object's type.\n *\n * @param obj The object\n * @return The type\n */\nexport const getType = (obj: unknown) => Object.prototype.toString.call(obj).slice(8, -1).toLowerCase();\n\n/**\n * Weak collections need their per-key dependencies stored weakly, or tracking `weakMap.get(obj)`\n * holds `obj` and defeats the whole point of the type. Checked by type string rather than\n * `instanceof`, which fails across realms (iframes, `vm`).\n */\n/**\n * A WeakMap or WeakSet (or WeakRef) — read from `Symbol.toStringTag`, the tag `Object.prototype.toString` itself reads, so\n * the answer is the same (another realm's collections included) without building and lower-casing a string on every first\n * tracked read of every object.\n */\nexport const isWeakCollection = (item: unknown) => {\n const tag = (item as { [Symbol.toStringTag]?: unknown } | null)?.[Symbol.toStringTag];\n return typeof tag === 'string' && (tag[0] === 'W' || tag[0] === 'w');\n};\n\n/**\n * Remove a trailing slash from an url if its not root url (`/`).\n *\n * @param str String to remove trailing slash from\n */\nexport const stripTrailingSlash = (str: string) => (str !== '/' && str.endsWith('/') ? str.slice(0, -1) : str);\n\n/**\n * **Reports an error nothing else handled, the way the platform reports one.** `reportError` fires\n * the window's `error` event — what `window.onerror`, error trackers and test runners listen for —\n * without unwinding the caller, so one failing hook or ref never stops its siblings. A bare\n * `console.error` reached none of those: a component could stop updating while every page-error\n * listener stayed silent. Off-browser (Node has no `reportError`) the console is all there is.\n * `line` is the framework's own line, printed beside the error — a CODED one (2026-10-09):\n * each caller passes `'[vera] <code>'` in production and its table's `diagnostic()` sentence in development, both\n * literal codes at the call site, so the static checks read them. The subject is fixed wording too (`a hook`, `an\n * element ref`), never a tag name: this line is the console's FORMAT (no `'%s'`, which measured +2–3 B on the renderer\n * bundles), so nothing from outside may reach it — the element goes to the `'error'` handlers instead. Production prints it only where the platform has no\n * `reportError` (Node); in a browser, `reportError` alone reports.\n *\n * Shared by core (a hook threw) and the renderer (a ref threw) so the fallback is one rule.\n */\nexport const reportUncaught = (error: unknown, line: string) => {\n if (typeof reportError !== 'function') console.error(line, error);\n else {\n if (__DEV__) console.error(line, error);\n reportError(error);\n }\n};\n\n/**\n * **Reports what user code a render called threw — to the app's `'error'` chain, else as uncaught.** One rule for\n * every callback the framework runs on the user's behalf and survives: a hook (core), an element ref, and an element\n * claim's `create`/`mount`/`unmount` (the renderer). The caller catches at the call site and carries on, so one\n * failing callback never stops its siblings or leaves a commit half applied. `element` is the component the error\n * belongs to, handed to each handler. Every throw is reported — nothing is deduped, as a hook's never was.\n * **Core keeps a deliberate twin** (`reportHookError`, the same rule as a `forEach`): routed through here it measured\n * +11 B gzip on `vera.min.js` (2026-10-09). A change to the rule changes both.\n */\nexport const reportTo = (handlers: readonly unknown[] | undefined, error: unknown, element: Element | undefined, line: string) => {\n if (handlers?.length) for (const handler of handlers) (handler as (error: unknown, element?: Element) => void)(error, element);\n else reportUncaught(error, line);\n};\n\n/** The component a render root belongs to: a shadow root's host, or a light root itself. */\nexport const hostOf = (root: Node | null | undefined): Element | undefined =>\n root == null ? undefined : root.nodeType === 11 ? (root as ShadowRoot).host : (root as Element);\n\n/** `fn(a, b, c)`, tracked as the caller is — the stand-in for core's `untracked` when no core was wired. */\nexport const call: Untracked = (fn, a, b, c) => fn(a!, b!, c!);\n\n/**\n * **Runs a bound handler, and its callers run it UNTRACKED**: the renderer's template `@event` and spread's event key,\n * each through `untracked(dispatch, holder, event)` (2026-10-09). An effect that fires an event synchronously\n * (`el.click()`, `focus()`, `dispatchEvent`) runs the handler INSIDE itself, and the handler's reads subscribed the\n * effect: a handler doing `state.n++` made the effect re-run on every click, a self-feeding loop held to one round per\n * frame, forever (measured). A handler's reads are event-time decisions, never a hook's inputs. The directives engine's\n * delegated `listen` makes the same choice its own way. A function is called with the element as `this`; an object\n * through its `handleEvent`. One function for both callers (Brian's size-audit ruling, 2026-11-13): it was two\n * identical copies, so a fix had two addresses; each bundle still inlines its own.\n */\nexport const dispatch = (holder: HandlerHolder, event: Event) => {\n const handler = holder._handler as EventListener | EventListenerObject | null;\n if (typeof handler === 'function') handler.call(holder._element as never, event);\n else if (typeof handler?.handleEvent === 'function') handler.handleEvent(event);\n};\n\n/**\n * **Whether a property binding is a `<select>`'s SELECTION** — `value` or `selectedIndex` — which the renderer and\n * `spread` both treat as live: re-asserted every render and compared against the live value (as `!value` is), because\n * a select's options can be replaced under an unchanged value, which drops the selection. One rule, asked once per\n * binding by both, so a template and a spread key cannot disagree about it.\n *\n * In development it names the one shape it cannot serve: on a `<select multiple>` both properties read and set a\n * SINGLE selection, so a selection the user adds is kept rather than controlled. Always writing there was measured\n * 2–3% slower on every table with a select per row, to serve an API that does not fit — hence a warning, not a cost.\n */\nexport const isSelection = (element: Element, name: unknown) => {\n if ((name !== 'value' && name !== 'selectedIndex') || element.localName !== 'select') return false;\n return true;\n};\n\n/**\n * Development: the one shape a selection binding cannot serve, named by the module the user wired (`side`). Called only\n * behind `__DEV__` at each call site, so production keeps `isSelection` exactly as small as it was (a `side` argument on\n * it measured +1 B, a default +9 B on vera-renderer.min.js — 2026-10-09).\n */\nexport const saySelectMultiple = (element: Element, name: unknown, side: string) => {\n if (element.hasAttribute('multiple'))\n console.warn(diagnostic(side, '<select multiple>', 'select-multiple', __DEV__ && SHARED.selectMultiple(String(name))));\n};\n\n/**\n * `target[key]`, as a function — how a component's GETTER is read through `untracked`. Not `Reflect.get`: `untracked`\n * passes three arguments, and `Reflect.get`'s third is the RECEIVER — `undefined` there runs the getter with no `this`.\n */\nexport const read = (target: object, key: string) => (target as Record<string, unknown>)[key];\n\n/**\n * **What a thrown value says, whatever was thrown — and it never throws itself.** A caught value comes from author\n * code (a `resolve` option, a motion tick or vocabulary function), and JavaScript can throw anything: `null`, an object\n * with no prototype (`String()` finds no `toString`), one whose `toString` or `message` getter throws, a Proxy whose\n * traps throw. Formatting it naively replaced the real failure with an unrelated TypeError from inside the framework.\n * Anything unreadable becomes a fixed phrase; `Object.prototype.toString` is no fallback, since it reads\n * `Symbol.toStringTag` through a Proxy's trap too.\n *\n * **A deliberate duplicate of `thrownMessage` in `packages/ssr/src/vera/escaping.ts` — fix both copies.** `@verajs/ssr`\n * is compiled per file with no bundling, so it cannot import this private, unpublished package at run time;\n * `tests/thrown-message-copies.test.mjs` runs one table of thrown values against both, so they cannot drift.\n */\nexport const thrownMessage = (error: unknown): string => {\n try {\n if (error instanceof Error) return String(error.message);\n const message = (error as { message?: unknown } | null)?.message;\n return typeof message === 'string' ? message : String(error);\n } catch {\n return '[unprintable value thrown]';\n }\n};\n","/** **`@verajs/renderer/elements`'s diagnostics — DEVELOPMENT ONLY.** Its bundle's own table, merged into the renderer's json. */\nimport type { Prose } from '@verajs/shared-utils';\n\nexport const PROSE: Record<string, Prose> = {\n 'claim-threw': (phase, outcome) => [\n `threw in ${phase}; its error is printed beside this line, and ${outcome}.`,\n \"Fix the claim's callback, or wire an 'error' insert to handle what claims throw.\",\n ],\n 'elements-hook-replaced': () => [\n \"a 'template' hook set an instance hook before `elements` (priority 10) and is replaced.\",\n 'Claim elements through the `element` insert instead of a second instance hook.',\n ],\n};\n","/**\n * **`@verajs/renderer/elements` — attach behavior to elements in templates.**\n *\n * ```js\n * const autofocus = { mount: (element) => element.focus() };\n * wire([renderer, elements, { on: 'element', fn: (el) => (el.hasAttribute('autofocus') ? autofocus : undefined) }]);\n * ```\n *\n * Every `'element'` claimant is asked about each element of a template ONCE, as the template is BUILT — on its\n * canonical content, so a tag and its static attributes are real and no binding is ever applied (a hydrated first\n * instance, whose elements are the server's with bound values in them, changes nothing). The answers are two flat\n * lists shared by every instance: element positions in document pre-order, and their behaviors. A template nobody\n * claimed anything in gets no instance hook at all. Each instance finds its claimed elements with one short walk to\n * those positions; once the render that created it has finished, each behavior's `mount` runs, and what it returns is\n * handed to `unmount` at teardown. Nothing runs per update.\n *\n * Built on the renderer's `'template'` insert and instance hook (`InstanceHook`); it imports nothing — the registry\n * arrives through its connector. An app that does not wire it pays nothing.\n */\nimport type { ElementBehavior, InstanceHook } from './types.js';\nimport { diagnostic, hostOf, reportTo } from '@verajs/shared-utils';\nimport { PROSE } from './elements-diagnostics.js';\n\ntype Claim = (element: Element) => ElementBehavior | undefined;\n\nlet registered: Map<string, unknown[]> | null = null;\n\n/**\n * **A claim's callbacks follow the ref rule** (Brian, 2026-10-09): user code a render calls is caught AT ITS CALL SITE\n * — so a template with no claims runs exactly the path it did — reported to the app's `'error'` chain with the\n * component it belongs to (else as uncaught), and the render, the other claims and the teardown carry on. A mid-commit\n * throw once left a component's root empty for good; `mount` propagating aborted every later claim's mount.\n */\nconst report = (error: unknown, root: Node | null, line: string) => reportTo(registered?.get('error'), error, hostOf(root), line);\n\n/**\n * **The next element of an instance in document pre-order, never leaving it.** A root is a fragment, or — for a\n * single-root template — its one element, which is then position 0. Bounded by the root rather than by the tree it\n * sits in, because a hydrated instance is already in the page.\n */\nconst firstIn = (root: Node): Element | null => (root.nodeType === 1 ? (root as Element) : (root as ParentNode).firstElementChild);\nconst nextIn = (node: Element, root: Node): Element | null => {\n if (node.firstElementChild !== null) return node.firstElementChild;\n for (let at: Element | null = node; at !== null && at !== root; at = at.parentElement)\n if (at.nextElementSibling !== null) return at.nextElementSibling;\n return null;\n};\n\n/**\n * One instance's claims until it mounts — its claimed elements and their behaviors, interleaved, where it rendered,\n * whether it was adopted — and then only what `unmount` needs. **The elements are released at mount**: per-instance\n * state that keeps DOM references past the moment it needs them costs every operation on the page (measured: ~7% on\n * select and swap of a table whose every row was claimed, operations that never touch it).\n */\ntype State = { f: (Element | ElementBehavior)[] | null; r: Node | null; a: boolean; k: unknown[] | undefined; d: boolean };\n\n/** The instance hook for one template, from the positions and behaviors its claimants answered. */\nconst hookFor = (positions: number[], behaviors: ElementBehavior[]): InstanceHook => ({\n $c: (instance, root, adopted) => {\n const found: (Element | ElementBehavior)[] = [];\n /**\n * ADOPTED, the instance arrives as its elements in template order (hydration pairs them): its live root already\n * holds what its nested parts rendered, so counting there would land on the wrong element.\n */\n const listed = Array.isArray(instance);\n let node = listed ? null : firstIn(instance as Node);\n let at = 0;\n for (let k = 0; k < positions.length; k++) {\n if (listed) node = (instance as readonly Element[])[positions[k]];\n else for (; at < positions[k]; at++) node = nextIn(node!, instance as Node);\n /**\n * At creation — before the first update, and before the instance is connected anywhere. A claim whose `create`\n * throws is reported and DROPPED for this instance (it never mounts or unmounts, being half made); the element\n * stays as the template built it — a claim inserts nothing — and every other claim carries on. The ref rule.\n */\n try {\n behaviors[k].create?.(node!, adopted);\n } catch (error) {\n report(error, root, __DEV__ ? diagnostic('elements', 'an element claim', 'claim-threw', __DEV__ && PROSE['claim-threw']('create', 'the render continued without it')) : '[vera] claim-threw');\n continue;\n }\n found.push(node!, behaviors[k]);\n }\n return { f: found, r: root, a: adopted, k: undefined, d: false } as State;\n },\n $m: (given) => {\n const state = given as State;\n /** Torn down before its render finished: it never mounts. */\n if (state.d) return;\n const found = state.f!;\n const context = { root: state.r, adopted: state.a };\n state.f = null;\n for (let i = 0; i < found.length; i += 2) {\n const behavior = found[i + 1] as ElementBehavior;\n let value;\n try {\n value = behavior.mount?.(found[i] as Element, context);\n } catch (error) {\n report(error, state.r, __DEV__ ? diagnostic('elements', 'an element claim', 'claim-threw', __DEV__ && PROSE['claim-threw']('mount', 'the others still mounted')) : '[vera] claim-threw');\n continue;\n }\n if (value !== undefined && behavior.unmount !== undefined) (state.k ??= []).push(found[i], behavior, value);\n }\n },\n $q: (given) => {\n const state = given as State;\n state.d = true;\n const kept = state.k;\n if (kept !== undefined)\n for (let i = 0; i < kept.length; i += 3)\n try {\n (kept[i + 1] as ElementBehavior).unmount!(kept[i + 2], kept[i] as Element);\n } catch (error) {\n report(error, state.r, __DEV__ ? diagnostic('elements', 'an element claim', 'claim-threw', __DEV__ && PROSE['claim-threw']('unmount', 'the rest of the teardown ran')) : '[vera] claim-threw');\n }\n },\n});\n\n/**\n * Asks the claimants about the template's canonical content, once, as it is built — and gives it an instance hook\n * only if something was claimed. The content is READ, never changed (see the `'template'` insert's contract).\n */\nconst claimTemplate = (built: object, _result: unknown, _readScope: unknown, root: Node) => {\n const claims = registered?.get('element') as Claim[] | undefined;\n if (claims === undefined || claims.length === 0) return;\n const template = built as { _$inst$?: InstanceHook };\n if (__DEV__ && template._$inst$ !== undefined)\n console.warn(diagnostic('elements', 'template', 'elements-hook-replaced', __DEV__ && PROSE['elements-hook-replaced']()));\n const positions: number[] = [];\n const behaviors: ElementBehavior[] = [];\n let at = 0;\n for (let node = firstIn(root); node !== null; node = nextIn(node, root), at++)\n for (let i = 0; i < claims.length; i++) {\n const behavior = claims[i](node);\n if (behavior !== undefined) {\n positions.push(at);\n behaviors.push(behavior);\n }\n }\n if (positions.length > 0) template._$inst$ = hookFor(positions, behaviors);\n};\n\n/** Wire it as `wire([renderer, elements, …claims])`. A bare module: it has no options. */\nexport const elements = [\n (registry: Map<string, unknown[]>) => {\n registered = registry;\n },\n { name: '@verajs/renderer/elements', on: 'template' as const, fn: claimTemplate, priority: 10 },\n];\n\nexport type { ElementBehavior } from './types.js';\n"],"names":[],"mappings":"AAAA;;;;;AAKG;AACI,MAAM,IAAI,GAAG,uBAAuB;AA2FpC,MAAM,UAAU,GAAG,CACxB,MAAc,EACd,SAAiB,EACjB,QAAgB,EAChB,QAA6C;AAE7C;AACA,OAAO,IAAI;AACT,MAAE,CAAA,OAAA,EAAU,MAAM,CAAA,EAAA,EAAK,SAAS,CAAA,GAAA,EAAM,QAAQ,CAAC,CAAC,CAAC,CAAA,EAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAA,CAAA,EAAI,QAAQ,CAAC,CAAC,CAAC,CAAA,CAAE,GAAG,EAAE,CAAA,EAAA,EAAK,QAAQ,CAAA,CAAA;MACnG,CAAA,OAAA,EAAU,MAAM,CAAA,EAAA,EAAK,SAAS,MAAM,IAAI,CAAA,EAAG,QAAQ,CAAA,CAAE;;ACxE3D;;;;;;;;;;;;;;AAcG;AACI,MAAM,cAAc,GAAG,CAAC,KAAc,EAAE,IAAY,KAAI;IAC7D,IAAI,OAAO,WAAW,KAAK,UAAU;AAAE,QAAA,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC;SAC5D;AACH,QAAA,IAAI,OAAO;AAAE,YAAA,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC;QACvC,WAAW,CAAC,KAAK,CAAC;IACpB;AACF,CAAC;AAED;;;;;;;;AAQG;AACI,MAAM,QAAQ,GAAG,CAAC,QAAwC,EAAE,KAAc,EAAE,OAA4B,EAAE,IAAY,KAAI;IAC/H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E,GAAG,CAAC;IACV,KAAK,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,KAAK,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE;AAC3E,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACtC,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAChC,YAAA,IAAI,QAAQ,KAAK,SAAS,EAAE;AAC1B,gBAAA,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;AAClB,gBAAA,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC1B;QACF;AACF,IAAA,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;QAAE,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC;AAC5E,CAAC;AAED;AACO,MAAM,QAAQ,GAAG;IACtB,CAAC,QAAgC,KAAI;QACnC,UAAU,GAAG,QAAQ;IACvB,CAAC;AACD,IAAA,EAAE,IAAI,EAAE,2BAA2B,EAAE,EAAE,EAAE,UAAmB,EAAE,EAAE,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE,EAAE;;;;;"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Where hydration's walk stands among a live parent's children: a node, and an offset into it when it is text — server
3
+ * text runs arrive MERGED (`a${x}b` is one text node), so a static and a value share a node until the walk splits them.
4
+ * `hydrate-slots` moves it past a filled slot's range. Plain names, so property mangling leaves them alone.
5
+ */
6
+ type HydrationCursor = {
7
+ parent: Node;
8
+ node: Node | null;
9
+ offset: number;
10
+ /**
11
+ * Walking a LIGHT host's children in light order (`hydrate-slots`): the list, `node`'s index in it, and how many of
12
+ * them the template must account for — all of a list read from the server's statement, none of a live record's (a
13
+ * node the page added since is the host's, not the template's). ABSENT on every other walk, so a page without light
14
+ * hosts walks one three-field shape: carrying them on every cursor cost Chrome's hydrate 14% (measured 2026-10-07).
15
+ */
16
+ light?: Node[];
17
+ at?: number;
18
+ end?: number;
19
+ /**
20
+ * On a light walk, how many RUNS the template writes among those children, and each anchor the walk set for them with
21
+ * the node it stands before (`null`: the end) — `hydrate-slots`' own, so `_`-named: the minifier shortens them.
22
+ */
23
+ _runs?: number;
24
+ _marks?: (Node | null)[];
25
+ };
26
+ /** Hydration's mismatch: records the cause and the first node that disagreed, and stops the adoption by throwing. */
27
+ type HydrationFail = (cause: string, at: Node | null, reason: false | (() => string)) => never;
28
+ /** A served light host as hydration sees it: only its carrier (`<ins data-vm-unassigned>`), which the walk passes over. */
29
+ type ServedHost = {
30
+ readonly carrier: Node | null;
31
+ };
32
+ /**
33
+ * Slots' `capture` (`_$capture$`): a light host's light children, in light order, captured wherever they stand — the
34
+ * server's carrier, when given, becoming the holding.
35
+ */
36
+ type LightCapture = (host: Element, before: Node | null, nodes?: Node[], carrier?: HTMLElement | null, wait?: boolean) => unknown;
37
+ /**
38
+ * Slots' seam (`_$capture$`), stamped with the package's seam protocol: its `capture` (light children, or runs, in light
39
+ * order), a host's light children as its record holds them (`null` without one), and `runOf`: a run turned into one unit
40
+ * of a record that holds its nodes as statics already — nothing moves.
41
+ */
42
+ type CaptureSeam = [
43
+ protocol: number,
44
+ capture: LightCapture,
45
+ lightNodes: (host: Element) => Node[] | null,
46
+ records: WeakMap<Element, LightRecord>,
47
+ standIn: (node: Node, parent: Node, ref: Node | null) => void,
48
+ placed: WeakMap<Node, unknown>,
49
+ adopted: unknown
50
+ ];
51
+ /** The parts of slots' light record `hydrate-slots` builds runs into (placement (ii) measurement). */
52
+ type LightRecord = {
53
+ host: Element;
54
+ units: {
55
+ a: Node;
56
+ z: Node;
57
+ }[];
58
+ holding: Element;
59
+ dirty: boolean;
60
+ };
61
+ /**
62
+ * **Hydrating light slots is its own piece** (`@verajs/renderer/hydrate-slots`): hydration calls it through these
63
+ * positions (`_$hydrateSlots$`), stamped with the package's seam protocol — open a served host, take a filled slot's
64
+ * range at a canonical `<slot>` (its detached copy, or `null`), close a matched walk, rescue a mismatched one.
65
+ */
66
+ type HydrateSlots = [
67
+ protocol: number,
68
+ open: (host: Element, fail: HydrationFail) => ServedHost,
69
+ slot: (canonical: Element, cursor: HydrationCursor, served: ServedHost) => Element | null,
70
+ close: (served: ServedHost | null) => void,
71
+ rescue: (served: ServedHost | null) => void,
72
+ /**
73
+ * The cursor that walks a light host's children in light order, for a template placing content into it — over the
74
+ * live record's list, else the statement's (strict) — or `null`: walked as its DOM stands. Given the canonical
75
+ * element, its adoption's plan and values, so a RUN written among those children (a value that is not text) can decline.
76
+ */
77
+ light: (host: Element, canonical: Element, plan: ReadonlyMap<Node, readonly number[]>, values: readonly unknown[]) => HydrationCursor | null,
78
+ /** The walk's step, light-aware: the next light child on a light cursor, else the next sibling. Hydration adopts it once the piece is wired. */
79
+ next: (cursor: HydrationCursor, node: Node) => Node | null,
80
+ /** An insert on a light walk: an anchor of a RUN is held for the unit the piece builds, text put in place. */
81
+ insert: (cursor: HydrationCursor, node: Node) => void
82
+ ];
83
+
84
+ /** The registry as this module uses it — `get` named so `wire`'s registry is assignable (a type of optional members alone is "weak"). */
85
+ type Registry = {
86
+ get(name: string): unknown[] | undefined;
87
+ _$capture$?: CaptureSeam;
88
+ _$hydrateSlots$?: HydrateSlots;
89
+ };
90
+ /** `wire([renderer, hydration, slots, hydrateSlots])`. */
91
+ declare const hydrateSlots: (given: Registry) => void;
92
+
93
+ export { hydrateSlots };
94
+ //# sourceMappingURL=vera-renderer-hydrate-slots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vera-renderer-hydrate-slots.d.ts","sources":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[]}