@verajs/renderer 0.2.1 → 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 +729 -226
  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 +113 -138
  35. package/dist/development/vera-renderer-profiler.d.ts.map +1 -1
  36. package/dist/development/vera-renderer-profiler.js +2428 -2101
  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 +8 -29
  43. package/dist/development/vera-renderer-spread.d.ts.map +1 -1
  44. package/dist/development/vera-renderer-spread.js +542 -461
  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 -494
  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 +77 -96
  55. package/dist/development/vera-renderer.d.ts.map +1 -1
  56. package/dist/development/vera-renderer.js +2401 -2061
  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 -118
  86. package/dist/development/vera-renderer-hydrate.d.ts.map +0 -1
  87. package/dist/development/vera-renderer-hydrate.js +0 -3092
  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,231 @@
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
+ /**
9
+ * **What this copy of the framework has already said** (Brian's ruling, 2026-11-12): the ONE memory behind `warnOnce`, `errorOnce`
10
+ * and `hasWarned`, for DEVELOPMENT-ONLY warnings. It replaced the hand-written once-flags every package kept
11
+ * (`saidLists`, `warnedDrop`, per-element WeakSets, per-key Sets: two naming styles, Brian: no names). **A warning that
12
+ * ships to production keeps its memory at its site** (bytes, measured 2026-11-12: the shared memory costs +80–145 B gz
13
+ * per bundle); development-only warnings use warnOnce. Module state by necessity, since "once" spans every call on the
14
+ * page. One per BUNDLE COPY, exactly the scope each flag had, because this package is inlined into every bundle.
15
+ * 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
16
+ * entry goes with the object. Marked pure, so a bundle that never prints once drops both.
17
+ */
18
+ const printed = /* @__PURE__ */ new Set();
19
+ const printedOn = /* @__PURE__ */ new WeakMap();
20
+ /** Where an object key's (code, value) lives: the value set for that code on that object, made on demand. */
21
+ const valuesOn = (on, code, make) => {
22
+ let codes = printedOn.get(on);
23
+ if (codes === undefined) {
24
+ printedOn.set(on, (codes = new Map()));
25
+ }
26
+ let values = codes.get(code);
27
+ if (values === undefined && make)
28
+ codes.set(code, (values = new Set()));
29
+ return values;
30
+ };
31
+ /** The object and value of an object or pair key. */
32
+ const split = (key) => (Array.isArray(key) ? key : [key, undefined]);
33
+ /** Whether (code, key) is new, recording it if so. */
34
+ const firstTime = (code, key) => {
35
+ if (key === undefined || typeof key === 'string') {
36
+ const entry = key === undefined ? code : `${code} ${key}`;
37
+ if (printed.has(entry))
38
+ return false;
39
+ printed.add(entry);
40
+ return true;
41
+ }
42
+ const [on, sub] = split(key);
43
+ const values = valuesOn(on, code, true);
44
+ if (values.has(sub))
45
+ return false;
46
+ values.add(sub);
47
+ return true;
48
+ };
49
+ const diagnostic = (inArea, bySubject, withCode, andProse) =>
50
+ /** `true ` HERE as well as at the call: production folds this to the one-line form, branch and all. */
51
+ true && andProse
52
+ ? `[vera] ${inArea}: ${bySubject} — ${andProse[0]}${andProse[1] ? ` ${andProse[1]}` : ''} (${withCode})`
53
+ : `[vera] ${inArea}: ${bySubject} — ${DOCS}${withCode}`;
54
+ /**
55
+ * The printer behind both, on one level. `andDetail` is `diagnostic()`'s prose, or a function returning it where building
56
+ * the sentence costs something: it is called only the first time. `...andMore` rides beside the line behind '%s' (an
57
+ * element, a thrown error), never inside it, so text from outside cannot forge a line. The console method is read at the
58
+ * call, so a test that replaces `console.warn` sees it.
59
+ */
60
+ const sayOnce = (level) => (inArea, bySubject, withCode, andDetail, forKey, ...andMore) => {
61
+ if (!firstTime(withCode, forKey))
62
+ return;
63
+ const line = diagnostic(inArea, bySubject, withCode, typeof andDetail === 'function' ? andDetail() : andDetail);
64
+ if (andMore.length)
65
+ console[level]('%s', line, ...andMore);
66
+ else
67
+ console[level](line);
68
+ };
69
+ /**
70
+ * **A diagnostic said once per page** (per key, where one is given: a string, or an object such as the element it is
71
+ * about): `diagnostic()`'s arguments, then the key, then what rides beside the line. Coded in production exactly as
72
+ * `diagnostic()` is, because it IS `diagnostic()`. `errorOnce` is its twin on `console.error`, for a refusal a page should
73
+ * not miss.
74
+ */
75
+ const warnOnce = /* @__PURE__ */ sayOnce('warn');
76
+
77
+ const PROSE = {
78
+ 'native-host-unsupported': (tag) => [
79
+ `<${tag}> cannot carry the lifecycle native-elements gives a built-in host: it is an element core did not define (a custom element defined before core loaded, or a built-in tag that cannot hold a shadow root — ul, li, table, button…), or one that already has a shadow root — including one core attached from a shadow option or the app's renderer({ shadow }) default. It still renders; it is never released when removed.`,
80
+ 'Give init() a div, section, article, aside, header, footer, main, nav, p, span, blockquote or h1–h6 — or a custom element, which calls init(this) in its connectedCallback.',
81
+ ],
82
+ 'native-host-slot-attribute': (tag) => [
83
+ `a direct child of this built-in host carries a slot attribute (<${tag} slot=…>), so it renders NOWHERE: the root that gives the host its lifecycle has only a default <slot>, and a child that names a slot is assigned to none.`,
84
+ 'Drop the slot attribute, wrap the child in another element (a deeper descendant is not affected), or make the host a custom element.',
85
+ ],
86
+ 'native-host-shadow': () => [
87
+ 'this element carries native-elements’ own closed shadow root (how its lifecycle is heard), so it cannot be given another.',
88
+ 'Use a custom element for a host that needs its own shadow root — init(this, …) with { shadow } — or attach the shadow root to an element inside this one.',
89
+ ],
90
+ };
91
+
92
+ /**
93
+ * **`@verajs/renderer/native-elements` — `init` on a BUILT-IN host element, with a custom element's lifecycle.**
94
+ *
95
+ * ```js
96
+ * wire([renderer, nativeElements]);
97
+ * init(document.querySelector('#panel'), () => () => html`…`);
98
+ * ```
99
+ *
100
+ * A custom element tells core when it leaves and comes back (its callbacks); a `div` given to `init` tells nobody, so
101
+ * with strong links it was never released (2026-10-21: 30 of 30 removed hosts retained). This module gives each
102
+ * built-in host a CLOSED shadow root holding a default `<slot>` (its light content renders exactly as before; the root is
103
+ * invisible to code and selectors) and a tiny SENTINEL custom element — which hears its host attached, moved, removed
104
+ * and re-attached, identically in Chromium, Firefox and WebKit (BROWSER-LEDGER). Removed: core's own teardown (`$td`).
105
+ * Re-attached: set up fresh (`$in`), as a custom element is. Moved — in one operation, or into another window's document
106
+ * (a popped-out panel) — kept, with its state.
107
+ *
108
+ * Built on core's `'init'` insert, which hands it every element `init` sets up; it imports nothing (the registry
109
+ * arrives through its connector), and an app that does not wire it pays nothing. Never on a server (ssr marks the
110
+ * registry, `$srv`). Unsupported, said in development: a tag that cannot hold a shadow root, and a host with one already.
111
+ */
112
+ /** The setup each host was given, to set it up again on its return; per module COPY (two copies never share one). */
113
+ const SETUP = Symbol();
114
+ /** A host whose setup waits for its first connect (it was given `init` off the page). */
115
+ const PENDING = Symbol();
116
+ /** Each realm's sentinel name, per copy: `vera-s-` + the first number free in that realm's registry (deterministic). */
117
+ const names = new WeakMap();
118
+ let core;
119
+ const hostOf = (sentinel) => sentinel.getRootNode().host;
120
+ /** Sets a host up (again) from what it was given — never in a document with no window (it could never be released). */
121
+ const setUp = (host) => {
122
+ const given = host[SETUP];
123
+ if (given !== undefined && host.ownerDocument.defaultView !== null)
124
+ core.$in(host, given[0], given[1]);
125
+ };
126
+ const sentinelFor = (win) => {
127
+ const registry = win.customElements;
128
+ let name = names.get(registry);
129
+ if (name === undefined) {
130
+ let n = 0;
131
+ while (registry.get((name = `vera-s-${n}`)) !== undefined)
132
+ n++;
133
+ registry.define(name, class extends win.HTMLElement {
134
+ connectedCallback() {
135
+ /**
136
+ * Back after a removal: set up fresh. A move (the host still connected at its disconnect) kept it — and a move
137
+ * into ANOTHER document re-homes it, as core does a component.
138
+ */
139
+ const host = hostOf(this);
140
+ if (host._$x$ === true || host[PENDING]) {
141
+ host[PENDING] = undefined;
142
+ setUp(host);
143
+ }
144
+ else if (host._$d$ !== undefined && host.ownerDocument !== host._$d$)
145
+ core.$rh(host);
146
+ }
147
+ disconnectedCallback() {
148
+ const host = hostOf(this);
149
+ /** Still connected: a MOVE in one operation (the platform runs reactions after it) — kept, as a component is. */
150
+ if (!host.isConnected && host._$x$ !== true)
151
+ core.$td(host);
152
+ }
153
+ });
154
+ names.set(registry, name);
155
+ }
156
+ return name;
157
+ };
158
+ const slotAttributeCheck = (host) => {
159
+ const children = host.children;
160
+ for (let i = 0; i < children.length; i++)
161
+ /** Once per host. */
162
+ if (children[i].hasAttribute('slot'))
163
+ warnOnce('native-elements', `<${host.localName}>`, 'native-host-slot-attribute', true && (() => PROSE['native-host-slot-attribute'](children[i].localName)), host);
164
+ };
165
+ const onInit = (element, options, setup) => {
166
+ /**
167
+ * A custom element has its own callbacks — tested FIRST, on the name alone: this insert runs for EVERY `init`, and on
168
+ * Firefox a page of custom elements paid +1.7% creation and +3.7% churn (11 of 12 sessions each, 2026-10-21) when the
169
+ * document and window reads below came before it; with this order it is level with the module unwired.
170
+ */
171
+ if (element.localName.indexOf('-') >= 0)
172
+ return undefined;
173
+ /** A server's document (ssr marks it): its elements are read once, never given a lifecycle. */
174
+ if (element.ownerDocument._$srv$)
175
+ return undefined;
176
+ const win = element.ownerDocument.defaultView;
177
+ if (win === null)
178
+ return undefined;
179
+ /** A customized built-in (`is=`) is a custom element too: `getName` knows its class. */
180
+ if (win.customElements.getName?.(element.constructor))
181
+ return undefined;
182
+ if (element[SETUP] === undefined) {
183
+ let root;
184
+ try {
185
+ root = element.attachShadow({ mode: 'closed' });
186
+ }
187
+ catch {
188
+ /** Once per tag. */
189
+ if (true )
190
+ warnOnce('native-elements', `<${element.localName}>`, 'native-host-unsupported', true && (() => PROSE['native-host-unsupported'](element.localName)), element.localName);
191
+ return undefined;
192
+ }
193
+ const doc = element.ownerDocument;
194
+ const sentinel = doc.createElement(sentinelFor(win));
195
+ /**
196
+ * No box (`hidden`): an element in the host's shadow tree is one of its layout children — a flex host laid its items
197
+ * out around it (each 4 px narrower, the gap shifted; tests/browser/native-elements). Its callbacks need no box.
198
+ */
199
+ sentinel.hidden = true;
200
+ root.append(doc.createElement('slot'), sentinel);
201
+ /** Development: a later attachShadow on this host says why it cannot, by name. */
202
+ if (true )
203
+ element.attachShadow = () => {
204
+ throw new Error(diagnostic('native-elements', `<${element.localName}>`, 'native-host-shadow', true && PROSE['native-host-shadow']()));
205
+ };
206
+ }
207
+ element[SETUP] = [options, setup];
208
+ /**
209
+ * Development: a DIRECT child with a `slot` attribute renders nowhere under the default-slot root (BROWSER-LEDGER) —
210
+ * a silent disappearance, so it is said, once per host, after the render this setup is about to run.
211
+ */
212
+ if (true )
213
+ queueMicrotask(() => slotAttributeCheck(element));
214
+ /** Off the page: its setup waits for its first connect (core stops on `false`), so a host never attached links nothing. */
215
+ if (element.isConnected)
216
+ return undefined;
217
+ element[PENDING] = true;
218
+ return false;
219
+ };
220
+ const nativeElements = (registry, w) => {
221
+ /** Core's seams, typed loosely on the registry (as the keyed module's are): a connector is handed core's `Inserts`. */
222
+ core = registry;
223
+ /** Read only by core's development check, so written only in development (2026-10-22). */
224
+ if (true )
225
+ registry.$ne = true;
226
+ /** FIRST of the `'init'` inserts (priority 0): a deferral stops every insert after it, so none runs on a detached host twice. */
227
+ w({ on: 'init', fn: onInit, priority: 0 });
228
+ };
229
+
230
+ export { nativeElements };
231
+ //# sourceMappingURL=vera-renderer-native-elements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vera-renderer-native-elements.js","sources":["../../../shared-utils/src/diagnostic.ts","../../src/native-elements-diagnostics.ts","../../src/native-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","/** **`@verajs/renderer/native-elements`' 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 'native-host-unsupported': (tag) => [\n `<${tag}> cannot carry the lifecycle native-elements gives a built-in host: it is an element core did not define (a custom element defined before core loaded, or a built-in tag that cannot hold a shadow root — ul, li, table, button…), or one that already has a shadow root — including one core attached from a shadow option or the app's renderer({ shadow }) default. It still renders; it is never released when removed.`,\n 'Give init() a div, section, article, aside, header, footer, main, nav, p, span, blockquote or h1–h6 — or a custom element, which calls init(this) in its connectedCallback.',\n ],\n 'native-host-slot-attribute': (tag) => [\n `a direct child of this built-in host carries a slot attribute (<${tag} slot=…>), so it renders NOWHERE: the root that gives the host its lifecycle has only a default <slot>, and a child that names a slot is assigned to none.`,\n 'Drop the slot attribute, wrap the child in another element (a deeper descendant is not affected), or make the host a custom element.',\n ],\n 'native-host-shadow': () => [\n 'this element carries native-elements’ own closed shadow root (how its lifecycle is heard), so it cannot be given another.',\n 'Use a custom element for a host that needs its own shadow root — init(this, …) with { shadow } — or attach the shadow root to an element inside this one.',\n ],\n};\n","/**\n * **`@verajs/renderer/native-elements` — `init` on a BUILT-IN host element, with a custom element's lifecycle.**\n *\n * ```js\n * wire([renderer, nativeElements]);\n * init(document.querySelector('#panel'), () => () => html`…`);\n * ```\n *\n * A custom element tells core when it leaves and comes back (its callbacks); a `div` given to `init` tells nobody, so\n * with strong links it was never released (2026-10-21: 30 of 30 removed hosts retained). This module gives each\n * built-in host a CLOSED shadow root holding a default `<slot>` (its light content renders exactly as before; the root is\n * invisible to code and selectors) and a tiny SENTINEL custom element — which hears its host attached, moved, removed\n * and re-attached, identically in Chromium, Firefox and WebKit (BROWSER-LEDGER). Removed: core's own teardown (`$td`).\n * Re-attached: set up fresh (`$in`), as a custom element is. Moved — in one operation, or into another window's document\n * (a popped-out panel) — kept, with its state.\n *\n * Built on core's `'init'` insert, which hands it every element `init` sets up; it imports nothing (the registry\n * arrives through its connector), and an app that does not wire it pays nothing. Never on a server (ssr marks the\n * registry, `$srv`). Unsupported, said in development: a tag that cannot hold a shadow root, and a host with one already.\n */\nimport { diagnostic, warnOnce } from '@verajs/shared-utils';\nimport { PROSE } from './native-elements-diagnostics.js';\n\ntype Host = HTMLElement & { _$x$?: boolean };\ntype Core = { $in(element: Host, options: unknown, setup: unknown): void; $td(element: Host): void; $rh(element: Host): void };\n\n/** The setup each host was given, to set it up again on its return; per module COPY (two copies never share one). */\nconst SETUP = Symbol();\n/** A host whose setup waits for its first connect (it was given `init` off the page). */\nconst PENDING = Symbol();\n/** Each realm's sentinel name, per copy: `vera-s-` + the first number free in that realm's registry (deterministic). */\nconst names = new WeakMap<CustomElementRegistry, string>();\nlet core: Core | undefined;\n\nconst hostOf = (sentinel: Element) => (sentinel.getRootNode() as ShadowRoot).host as Host & { [SETUP]?: [unknown, unknown] };\n\n/** Sets a host up (again) from what it was given — never in a document with no window (it could never be released). */\nconst setUp = (host: Host & { [SETUP]?: [unknown, unknown] }) => {\n const given = host[SETUP];\n if (given !== undefined && host.ownerDocument.defaultView !== null) core!.$in(host, given[0], given[1]);\n};\n\nconst sentinelFor = (win: Window & typeof globalThis) => {\n const registry = win.customElements;\n let name = names.get(registry);\n if (name === undefined) {\n let n = 0;\n while (registry.get((name = `vera-s-${n}`)) !== undefined) n++;\n registry.define(\n name,\n class extends win.HTMLElement {\n connectedCallback() {\n /**\n * Back after a removal: set up fresh. A move (the host still connected at its disconnect) kept it — and a move\n * into ANOTHER document re-homes it, as core does a component.\n */\n const host = hostOf(this) as Host & { [PENDING]?: true; _$d$?: Document };\n if (host._$x$ === true || host[PENDING]) {\n host[PENDING] = undefined;\n setUp(host);\n } else if (host._$d$ !== undefined && host.ownerDocument !== host._$d$) core!.$rh(host);\n }\n disconnectedCallback() {\n const host = hostOf(this);\n /** Still connected: a MOVE in one operation (the platform runs reactions after it) — kept, as a component is. */\n if (!host.isConnected && host._$x$ !== true) core!.$td(host);\n }\n }\n );\n names.set(registry, name);\n }\n return name;\n};\n\nconst slotAttributeCheck = (host: Element) => {\n const children = host.children;\n for (let i = 0; i < children.length; i++)\n /** Once per host. */\n if (children[i]!.hasAttribute('slot'))\n warnOnce('native-elements', `<${host.localName}>`, 'native-host-slot-attribute', __DEV__ && (() => PROSE['native-host-slot-attribute'](children[i]!.localName)), host);\n};\n\nconst onInit = (element: Host & { [SETUP]?: [unknown, unknown] }, options: unknown, setup: unknown): false | undefined => {\n /**\n * A custom element has its own callbacks — tested FIRST, on the name alone: this insert runs for EVERY `init`, and on\n * Firefox a page of custom elements paid +1.7% creation and +3.7% churn (11 of 12 sessions each, 2026-10-21) when the\n * document and window reads below came before it; with this order it is level with the module unwired.\n */\n if (element.localName.indexOf('-') >= 0) return undefined;\n /** A server's document (ssr marks it): its elements are read once, never given a lifecycle. */\n if ((element.ownerDocument as Document & { _$srv$?: boolean })._$srv$) return undefined;\n const win = element.ownerDocument.defaultView as (Window & typeof globalThis) | null;\n if (win === null) return undefined;\n /** A customized built-in (`is=`) is a custom element too: `getName` knows its class. */\n if ((win.customElements as { getName?: (c: unknown) => string | null }).getName?.(element.constructor)) return undefined;\n if (element[SETUP] === undefined) {\n let root: ShadowRoot;\n try {\n root = element.attachShadow({ mode: 'closed' });\n } catch {\n /** Once per tag. */\n if (__DEV__)\n warnOnce('native-elements', `<${element.localName}>`, 'native-host-unsupported', __DEV__ && (() => PROSE['native-host-unsupported'](element.localName)), element.localName);\n return undefined;\n }\n const doc = element.ownerDocument;\n const sentinel = doc.createElement(sentinelFor(win));\n /**\n * No box (`hidden`): an element in the host's shadow tree is one of its layout children — a flex host laid its items\n * out around it (each 4 px narrower, the gap shifted; tests/browser/native-elements). Its callbacks need no box.\n */\n sentinel.hidden = true;\n root.append(doc.createElement('slot'), sentinel);\n /** Development: a later attachShadow on this host says why it cannot, by name. */\n if (__DEV__)\n element.attachShadow = () => {\n throw new Error(diagnostic('native-elements', `<${element.localName}>`, 'native-host-shadow', __DEV__ && PROSE['native-host-shadow']()));\n };\n }\n element[SETUP] = [options, setup];\n /**\n * Development: a DIRECT child with a `slot` attribute renders nowhere under the default-slot root (BROWSER-LEDGER) —\n * a silent disappearance, so it is said, once per host, after the render this setup is about to run.\n */\n if (__DEV__) queueMicrotask(() => slotAttributeCheck(element));\n /** Off the page: its setup waits for its first connect (core stops on `false`), so a host never attached links nothing. */\n if (element.isConnected) return undefined;\n (element as Host & { [PENDING]?: true })[PENDING] = true;\n return false;\n};\n\n/**\n * Wire it: `wire([renderer, nativeElements])`. A CONNECTOR (`wire` hands it the registry): core's setup (`$in`) and\n * teardown (`$td`) come off it, and `$ne` tells core's development check this module is wired.\n */\n/** The registry and `wire` as a connector is handed them — typed as slots' are, so a strict consumer's `wire([…])` takes it. */\ntype Registry = { get(name: never): unknown };\ntype Wire = (item: never) => void;\nexport const nativeElements = (registry: Registry, w: Wire) => {\n /** Core's seams, typed loosely on the registry (as the keyed module's are): a connector is handed core's `Inserts`. */\n core = registry as unknown as Core;\n /** Read only by core's development check, so written only in development (2026-10-22). */\n if (__DEV__) (registry as unknown as { $ne?: unknown }).$ne = true;\n /** FIRST of the `'init'` inserts (priority 0): a deferral stops every insert after it, so none runs on a detached host twice. */\n w({ on: 'init', fn: onInit, priority: 0 } as never);\n};\n"],"names":[],"mappings":"AAAA;;;;;AAKG;AACI,MAAM,IAAI,GAAG,uBAAuB;AAE3C;;;;;;;;;AASG;AACH,MAAM,OAAO,mBAAmB,IAAI,GAAG,EAAU;AACjD,MAAM,SAAS,mBAAmB,IAAI,OAAO,EAAqC;AAQlF;AACA,MAAM,QAAQ,GAAG,CAAC,EAAU,EAAE,IAAY,EAAE,IAAa,KAA8B;IACrF,IAAI,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;AAC7B,IAAA,IAAI,KAAK,KAAK,SAAS,EAAE;AAEvB,QAAA,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG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CAAA,CAAA,CAAG,EAAE,oBAAoB,EAAE,OAAO,IAAI,KAAK,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC;AAC1I,YAAA,CAAC;IACL;IACA,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC;AACjC;;;AAGG;AACH,IAAA,IAAI,OAAO;QAAE,cAAc,CAAC,MAAM,kBAAkB,CAAC,OAAO,CAAC,CAAC;;IAE9D,IAAI,OAAO,CAAC,WAAW;AAAE,QAAA,OAAO,SAAS;AACxC,IAAA,OAAuC,CAAC,OAAO,CAAC,GAAG,IAAI;AACxD,IAAA,OAAO,KAAK;AACd,CAAC;MASY,cAAc,GAAG,CAAC,QAAkB,EAAE,CAAO,KAAI;;IAE5D,IAAI,GAAG,QAA2B;;AAElC,IAAA,IAAI,OAAO;AAAG,QAAA,QAAyC,CAAC,GAAG,GAAG,IAAI;;AAElE,IAAA,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAW,CAAC;AACrD;;;;"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * **`portal(target, template)` — draws into ANOTHER element, from a component's setup** (2026-10-22, the API
3
+ * distillation: it replaced `useRender`'s one job no returned render can do). A modal on `document.body`, a tooltip
4
+ * in an overlay layer, a row in another component's light DOM.
5
+ *
6
+ * - **Its own range.** Two comments, appended to `target`, bound what it draws, so any number share one target (two
7
+ * components drawing into `document.body` with `renderInto` — one root per container — replaced each other).
8
+ * - **The render's slot.** It runs at the render's priority (50): a keyed `.map` keeps its rows with their items, it is
9
+ * drawn before the component's layout effects, and what its draw made and no longer reaches (an automatic list, a
10
+ * computed) is freed after each draw, as the component's own render frees it.
11
+ * - **Owned by the component being set up**, whose removal takes its content and markers out of `target`; a paused
12
+ * component (`persist`) takes them out too, and draws afresh when it is back. A cross-window MOVE of the component
13
+ * leaves it where it is: `target` is where it was asked to draw.
14
+ * - **Light DOM.** `target` itself, never its shadow root: into a shadow host it is the host's light content, slotted
15
+ * where the host's template says.
16
+ * - **The client only.** A server renders a component's own template; a portal registers nothing there, so hydration
17
+ * finds no range to adopt and the client draws it once.
18
+ * - **A target FUNCTION follows** (Brian, 2026-10-25): `portal(() => host.ownerDocument.body, …)` is evaluated at setup
19
+ * and again whenever what it reads changes or its component moves into another window (a cross-window move re-runs effect
20
+ * priority), and a different answer MOVES the drawn range into the new target — never a redraw, so components inside
21
+ * keep their state. A popped-out panel's modal then opens in the pop-out. A plain element target never moves.
22
+ *
23
+ * Additive, like `hydration`: it imports no renderer and reaches the one wired through its hand-off (`$H`).
24
+ */
25
+ type Target = Element | DocumentFragment;
26
+ declare const portal: (target: Target | (() => Target | null | undefined), template: unknown) => void;
27
+
28
+ export { portal };
29
+ //# sourceMappingURL=vera-renderer-portal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vera-renderer-portal.d.ts","sources":["../../src/portal.ts"],"mappings":"AAAA;AACA;AACA;AACA;AAGA;AACA;AAUA;;;;AAIG;AACH;AA2BA;;;;;AAKG;AACH;AACE;;AAEF;AACA;AACE;WAAc,GAAA,OAAO,GAAA,gBAAA;AACrB,cAAgC,MAAA,WAAA,MAAA,UAAA,MAAA;;;;","names":[]}
@@ -0,0 +1,167 @@
1
+ import { untrack, effect, inserts } from '@verajs/core';
2
+
3
+ /**
4
+ * **Where every diagnostic code is explained.** The URL is permanent: a released bundle is immutable, so every version
5
+ * published points here for ever — the domain cannot lapse and `/e/` cannot be reorganized without breaking links in
6
+ * code nobody can edit; the docs site redirects instead. `scripts/sync-diagnostics.mjs` imports this constant, so the
7
+ * pages and the bundles can never disagree about where they are.
8
+ */
9
+ const DOCS = 'https://verajs.dev/e/';
10
+ const diagnostic = (inArea, bySubject, withCode, andProse) =>
11
+ /** `true ` HERE as well as at the call: production folds this to the one-line form, branch and all. */
12
+ true && andProse
13
+ ? `[vera] ${inArea}: ${bySubject} — ${andProse[0]}${andProse[1] ? ` ${andProse[1]}` : ''} (${withCode})`
14
+ : `[vera] ${inArea}: ${bySubject} — ${DOCS}${withCode}`;
15
+
16
+ /**
17
+ * **The renderer's binding kinds and child-part modes** — numbers both `renderer.ts` and the separately bundled
18
+ * `hydration.ts` read, from ONE source (each bundle inlines them; they are literals in the output). A change here
19
+ * changes the hand-off's protocol: bump `$V` in `renderer.ts`.
20
+ */
21
+ /** A binding's kind, resolved once per template. */
22
+ /**
23
+ * **The hydration hand-off's positions** — the renderer sets `$H` to an array at `connect`, and `hydration.ts` reads
24
+ * it by these. An array, not an object of named fields: the names cost every app bytes (−35 B gzipped measured,
25
+ * 2026-10-02), and these constants inline to literals in both bundles. The first two are FROZEN across protocols — a
26
+ * hydration from another release reads the protocol at 0 and, on a mismatch, can still install its clearing hook at 1.
27
+ * Any other change here is a protocol change: bump `PROTOCOL`.
28
+ */
29
+ /**
30
+ * **The protocol of this package's first-party seams** — the renderer's hand-off (`$H`, at `HANDOFF_PROTOCOL`) and slots'
31
+ * capture (`_$capture$`), both read by hydration. One number for both: the three ship in one package, and a change to
32
+ * either seam bumps it. A hydration that meets another number declines (the page renders fresh) and says so.
33
+ */
34
+ const PROTOCOL = 1;
35
+ /** The protocol number — FROZEN at 0. */
36
+ const HANDOFF_PROTOCOL = 0;
37
+ const HANDOFF_CHILD_PART = 3;
38
+ const HANDOFF_COMMIT_AS = 9;
39
+
40
+ const PROSE = {
41
+ 'portal-no-renderer': () => [
42
+ 'a portal has no renderer of this release to draw with, so it drew nothing.',
43
+ 'Wire the renderer once at your entry — `wire([renderer])` — from the same release as `@verajs/renderer/portal`.',
44
+ ],
45
+ };
46
+
47
+ /** Whether `portal-no-renderer` has been printed: once per page, in every build (a warning that ships to production keeps its memory at its site: the shared memory costs +80–145 B gz per bundle, measured 2026-11-12). */
48
+ let printedPortal = false;
49
+ /**
50
+ * **A server registers nothing** — `@verajs/ssr` sets this public flag at import, before anything renders (the renderer
51
+ * reads it the same way). A server turn runs a setup's effects, and with no client renderer there every request said
52
+ * `portal-no-renderer` (measured 2026-10-22); a portal has nothing to draw there, and hydration nothing to adopt.
53
+ */
54
+ const onServer = globalThis.__veraSsrShimmed === true;
55
+ /**
56
+ * **No target, or a dead one, leaves the range WHERE IT IS** (2026-10-25): a falsy answer, or a target whose window is gone
57
+ * (a closed pop-out: no live `defaultView`), moves nothing — so nothing is removed and the components inside keep their
58
+ * state (holding the range in a detached fragment would be a REMOVAL, which tears them down) — and the next real target
59
+ * gets it. Nothing throws.
60
+ */
61
+ const usable = (t) => {
62
+ const view = t?.ownerDocument?.defaultView;
63
+ return view != null && !view.closed;
64
+ };
65
+ const portal = (target, template) => {
66
+ if (onServer)
67
+ return;
68
+ let part;
69
+ /** Where it draws now: a function target is read once here, untracked, so the draw does not subscribe to it. */
70
+ let current;
71
+ if (typeof target === 'function') {
72
+ const first = untrack(target);
73
+ /** No usable target yet: drawn into a fragment of THIS realm's document until one exists — portal is handed no element to take one from. */
74
+ current = usable(first) ? first : document.createDocumentFragment();
75
+ }
76
+ else
77
+ current = target;
78
+ /** The last value drawn, for a redraw when the range was destroyed (below). */
79
+ let last;
80
+ const registry = inserts;
81
+ /**
82
+ * **The range is INTACT while both markers sit in one parent** (2026-10-25). User code clearing the target —
83
+ * `container.innerHTML = ''`, a router swapping a container's children, an overlay library emptying its root — or a dead
84
+ * window taking its document's nodes (jsdom) removes them, and a draw into detached markers would be invisible (and a
85
+ * cleanup into them threw). The ONE check every path asks: the first draw, every draw, a target change, the removal.
86
+ */
87
+ /** …and a range in a document whose WINDOW is gone is not intact either: core's release retired its components. */
88
+ const intact = () => part !== undefined && part.$s.parentNode !== null && part.$s.parentNode === part.$e.parentNode && usable(part.$s.parentNode);
89
+ /** A fresh range at the end of `into`, drawn with `value` — the first draw, and the redraw of a destroyed range. */
90
+ const fresh = (handoff, into, value) => {
91
+ const doc = into.ownerDocument;
92
+ part = new handoff[HANDOFF_CHILD_PART](doc.createComment(''), doc.createComment(''));
93
+ into.append(part.$s, part.$e);
94
+ handoff[HANDOFF_COMMIT_AS](into, part, value);
95
+ };
96
+ const hook = effect((change) => {
97
+ const handoff = registry.$H;
98
+ if (handoff === undefined || handoff[HANDOFF_PROTOCOL] !== PROTOCOL) {
99
+ /**
100
+ * Once per page, in every build: a portal with no renderer of this release wired draws nothing (core's own
101
+ * `no-renderer` covers a component's render, not this).
102
+ */
103
+ if (!printedPortal) {
104
+ printedPortal = true;
105
+ console.warn(true ? diagnostic('renderer', 'portal', 'portal-no-renderer', true && PROSE['portal-no-renderer']()) : '[vera] portal-no-renderer');
106
+ }
107
+ return;
108
+ }
109
+ const value = (last = typeof template === 'function' ? template(change) : template);
110
+ if (intact())
111
+ handoff[HANDOFF_COMMIT_AS](current, part, value);
112
+ else
113
+ fresh(handoff, current, value);
114
+ registry.$so?.(hook);
115
+ }, { priority: 50 });
116
+ /**
117
+ * The removal: a second hook, reading nothing, whose cleanup runs only when the owner retires or pauses. At 50 too —
118
+ * a cross-window move re-runs the layout (60) and effect (75) priorities, and this must not run then.
119
+ */
120
+ effect(() => () => {
121
+ if (part === undefined)
122
+ return;
123
+ if (intact())
124
+ registry.$H[HANDOFF_COMMIT_AS](current, part, null);
125
+ part.$s.remove();
126
+ part.$e.remove();
127
+ part = undefined;
128
+ }, { priority: 50 });
129
+ /**
130
+ * **A function target follows** — only then: a third hook, at EFFECT priority (75) so a cross-window move re-runs it,
131
+ * re-reads the target (tracked, so a store it reads moves it too) and, when the answer changed, moves the range — the
132
+ * markers and what lies between them — into it. Moving keeps every node, components included.
133
+ */
134
+ if (typeof target === 'function')
135
+ effect(() => {
136
+ const next = target();
137
+ if (!usable(next) || next === current)
138
+ return;
139
+ const from = current;
140
+ current = next;
141
+ if (part === undefined)
142
+ return;
143
+ /** A destroyed range is drawn afresh into the new target from the last value (its components set up again). */
144
+ if (!intact())
145
+ return fresh(registry.$H, next, last);
146
+ const nodes = [];
147
+ for (let n = part.$s; n !== null; n = n.nextSibling) {
148
+ nodes.push(n);
149
+ if (n === part.$e)
150
+ break;
151
+ }
152
+ /**
153
+ * Within ONE document, `moveBefore` (Chromium, Firefox) keeps what an insertion would reset — focus, a playing media
154
+ * element, an iframe — so a reactive target switching containers loses none of it. Across documents, or where it is
155
+ * absent (WebKit), `append`: a cross-document insertion adopts.
156
+ */
157
+ const move = next.moveBefore;
158
+ if (move !== undefined && from.isConnected && next.isConnected && part.$s.getRootNode() === next.getRootNode())
159
+ for (const n of nodes)
160
+ move.call(next, n, null);
161
+ else
162
+ next.append(...nodes);
163
+ });
164
+ };
165
+
166
+ export { portal };
167
+ //# sourceMappingURL=vera-renderer-portal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vera-renderer-portal.js","sources":["../../../shared-utils/src/diagnostic.ts","../../src/kinds.ts","../../src/portal-diagnostics.ts","../../src/portal.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","/**\n * **The renderer's binding kinds and child-part modes** — numbers both `renderer.ts` and the separately bundled\n * `hydration.ts` read, from ONE source (each bundle inlines them; they are literals in the output). A change here\n * changes the hand-off's protocol: bump `$V` in `renderer.ts`.\n */\n/** A binding's kind, resolved once per template. */\nexport const IGNORED = 0; // consumed, nothing rendered: inside a comment, the later values of a multi-part attribute\nexport const CHILD = 1; // anchored on a primed empty text node the template carries\nexport const SOLE = 2; // its element's only content: no anchor in the template, the first commit writes `textContent`\nexport const ATTR = 3;\nexport const PROPERTY = 4;\nexport const BOOLEAN = 5;\n/** `EVENT` through `ADOPT` hold a `Slot` record in their node slot — one range test, in `instantiate` and `commit`. */\nexport const EVENT = 6;\n/** An element-position expression: a ref, or a value that applies itself (`_$apply$`). */\nexport const REF = 7;\n/** An element-position expression ON a `<select>`: a value applying itself there (a spread) waits for `flush`. */\nexport const SELECT_REF = 8;\n/** `.name` on a custom element — see `adoptProperty` in shared-utils. */\nexport const ADOPT = 9;\n/**\n * Kinds from here on re-assert on EVERY render, so the update loop never skips them as unchanged:\n * `!name` writes from the live DOM's point of view (a sibling radio's click unchecks this one with no\n * event on it), and a `<select>`'s selection is re-applied after its options exist — see `flush`.\n */\nexport const LIVE = 10;\n/** A `<select>`'s selection — `value` or `selectedIndex` (`isSelection`) — written when the pass ends: see `flush`. */\nexport const SELECT = 11;\n/** `!name` on a custom element: compared against the LIVE value — read through `untracked`, it is the component's getter. */\nexport const LIVE_CUSTOM = 12;\n/** A binding that must never write — and, from here on, the kinds `commit` handles before anything is computed. */\nexport const REFUSED = 13;\n/** A `<select>`'s `selectedIndex` — the rare spelling of its selection, queued as `SELECT` is (see `flush`). */\nexport const SELECT_INDEX = 14;\n\n\n/** A child part's mode: what its range currently holds. */\nexport const EMPTY = 0;\nexport const TEXT = 1;\nexport const TEMPLATE = 2;\nexport const LIST = 3;\nexport const NODE = 4;\n\n/**\n * **The hydration hand-off's positions** — the renderer sets `$H` to an array at `connect`, and `hydration.ts` reads\n * it by these. An array, not an object of named fields: the names cost every app bytes (−35 B gzipped measured,\n * 2026-10-02), and these constants inline to literals in both bundles. The first two are FROZEN across protocols — a\n * hydration from another release reads the protocol at 0 and, on a mismatch, can still install its clearing hook at 1.\n * Any other change here is a protocol change: bump `PROTOCOL`.\n */\n/**\n * **The protocol of this package's first-party seams** — the renderer's hand-off (`$H`, at `HANDOFF_PROTOCOL`) and slots'\n * capture (`_$capture$`), both read by hydration. One number for both: the three ship in one package, and a change to\n * either seam bumps it. A hydration that meets another number declines (the page renders fresh) and says so.\n */\nexport const PROTOCOL = 1;\n/** The protocol number — FROZEN at 0. */\nexport const HANDOFF_PROTOCOL = 0;\n/** The first-render hook's setter — FROZEN at 1. */\nexport const HANDOFF_ADOPTER = 1;\nexport const HANDOFF_GET_TEMPLATE = 2;\nexport const HANDOFF_CHILD_PART = 3;\nexport const HANDOFF_INSTANCE = 4;\nexport const HANDOFF_SLOT = 5;\nexport const HANDOFF_UNSET = 6;\nexport const HANDOFF_UPGRADED = 7;\nexport const HANDOFF_COMMIT = 8;\nexport const HANDOFF_COMMIT_AS = 9;\nexport const HANDOFF_HOOK_UP = 10;\nexport const HANDOFF_RESOLVE = 11;\nexport const HANDOFF_ROOTS = 12;\nexport const HANDOFF_TO_TEXT = 13;\nexport const HANDOFF_REMOVAL_WORK = 14;\n","/** **`@verajs/renderer/portal`'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 'portal-no-renderer': () => [\n 'a portal has no renderer of this release to draw with, so it drew nothing.',\n 'Wire the renderer once at your entry — `wire([renderer])` — from the same release as `@verajs/renderer/portal`.',\n ],\n};\n","import { effect, inserts, untrack } from '@verajs/core';\nimport { diagnostic } from '@verajs/shared-utils';\nimport { HANDOFF_CHILD_PART, HANDOFF_COMMIT_AS, HANDOFF_PROTOCOL, PROTOCOL } from './kinds.js';\nimport { PROSE } from './portal-diagnostics.js';\nimport type { ChildPart } from './renderer.js';\n\n/** Whether `portal-no-renderer` has been printed: once per page, in every build (a warning that ships to production keeps its memory at its site: the shared memory costs +80–145 B gz per bundle, measured 2026-11-12). */\nlet printedPortal = false;\n\n/** What this entry reads off core's registry: the renderer's hand-off and core's settle. `$`-named — never mangled. */\ntype Registry = {\n $H?: unknown[];\n $so?: (hook: unknown, all?: boolean) => void;\n};\ntype Part = new (start: Comment, end: Comment) => ChildPart;\ntype CommitAs = (root: Node, part: ChildPart, value: unknown) => void;\n\n/**\n * **A server registers nothing** — `@verajs/ssr` sets this public flag at import, before anything renders (the renderer\n * reads it the same way). A server turn runs a setup's effects, and with no client renderer there every request said\n * `portal-no-renderer` (measured 2026-10-22); a portal has nothing to draw there, and hydration nothing to adopt.\n */\nconst onServer = (globalThis as { __veraSsrShimmed?: boolean }).__veraSsrShimmed === true;\n\n/**\n * **`portal(target, template)` — draws into ANOTHER element, from a component's setup** (2026-10-22, the API\n * distillation: it replaced `useRender`'s one job no returned render can do). A modal on `document.body`, a tooltip\n * in an overlay layer, a row in another component's light DOM.\n *\n * - **Its own range.** Two comments, appended to `target`, bound what it draws, so any number share one target (two\n * components drawing into `document.body` with `renderInto` — one root per container — replaced each other).\n * - **The render's slot.** It runs at the render's priority (50): a keyed `.map` keeps its rows with their items, it is\n * drawn before the component's layout effects, and what its draw made and no longer reaches (an automatic list, a\n * computed) is freed after each draw, as the component's own render frees it.\n * - **Owned by the component being set up**, whose removal takes its content and markers out of `target`; a paused\n * component (`persist`) takes them out too, and draws afresh when it is back. A cross-window MOVE of the component\n * leaves it where it is: `target` is where it was asked to draw.\n * - **Light DOM.** `target` itself, never its shadow root: into a shadow host it is the host's light content, slotted\n * where the host's template says.\n * - **The client only.** A server renders a component's own template; a portal registers nothing there, so hydration\n * finds no range to adopt and the client draws it once.\n * - **A target FUNCTION follows** (Brian, 2026-10-25): `portal(() => host.ownerDocument.body, …)` is evaluated at setup\n * and again whenever what it reads changes or its component moves into another window (a cross-window move re-runs effect\n * priority), and a different answer MOVES the drawn range into the new target — never a redraw, so components inside\n * keep their state. A popped-out panel's modal then opens in the pop-out. A plain element target never moves.\n *\n * Additive, like `hydration`: it imports no renderer and reaches the one wired through its hand-off (`$H`).\n */\ntype Target = Element | DocumentFragment;\n/**\n * **No target, or a dead one, leaves the range WHERE IT IS** (2026-10-25): a falsy answer, or a target whose window is gone\n * (a closed pop-out: no live `defaultView`), moves nothing — so nothing is removed and the components inside keep their\n * state (holding the range in a detached fragment would be a REMOVAL, which tears them down) — and the next real target\n * gets it. Nothing throws.\n */\nconst usable = (t: Target | null | undefined): t is Target => {\n const view = t?.ownerDocument?.defaultView;\n return view != null && !view.closed;\n};\nexport const portal = (target: Target | (() => Target | null | undefined), template: unknown): void => {\n if (onServer) return;\n let part: ChildPart | undefined;\n /** Where it draws now: a function target is read once here, untracked, so the draw does not subscribe to it. */\n let current: Target;\n if (typeof target === 'function') {\n const first = untrack(target);\n /** No usable target yet: drawn into a fragment of THIS realm's document until one exists — portal is handed no element to take one from. */\n current = usable(first) ? first : document.createDocumentFragment();\n } else current = target;\n /** The last value drawn, for a redraw when the range was destroyed (below). */\n let last: unknown;\n const registry = inserts as unknown as Registry;\n /**\n * **The range is INTACT while both markers sit in one parent** (2026-10-25). User code clearing the target —\n * `container.innerHTML = ''`, a router swapping a container's children, an overlay library emptying its root — or a dead\n * window taking its document's nodes (jsdom) removes them, and a draw into detached markers would be invisible (and a\n * cleanup into them threw). The ONE check every path asks: the first draw, every draw, a target change, the removal.\n */\n /** …and a range in a document whose WINDOW is gone is not intact either: core's release retired its components. */\n const intact = () => part !== undefined && part.$s!.parentNode !== null && part.$s!.parentNode === part.$e!.parentNode && usable(part.$s!.parentNode as Target);\n /** A fresh range at the end of `into`, drawn with `value` — the first draw, and the redraw of a destroyed range. */\n const fresh = (handoff: unknown[], into: Target, value: unknown) => {\n const doc = into.ownerDocument!;\n part = new (handoff[HANDOFF_CHILD_PART] as Part)(doc.createComment(''), doc.createComment(''));\n into.append(part.$s!, part.$e!);\n (handoff[HANDOFF_COMMIT_AS] as CommitAs)(into, part, value);\n };\n const hook = effect(\n (change) => {\n const handoff = registry.$H;\n if (handoff === undefined || handoff[HANDOFF_PROTOCOL] !== PROTOCOL) {\n /**\n * Once per page, in every build: a portal with no renderer of this release wired draws nothing (core's own\n * `no-renderer` covers a component's render, not this).\n */\n if (!printedPortal) {\n printedPortal = true;\n console.warn(__DEV__ ? diagnostic('renderer', 'portal', 'portal-no-renderer', __DEV__ && PROSE['portal-no-renderer']()) : '[vera] portal-no-renderer');\n }\n return;\n }\n const value = (last = typeof template === 'function' ? (template as (change: unknown) => unknown)(change) : template);\n if (intact()) (handoff[HANDOFF_COMMIT_AS] as CommitAs)(current, part!, value);\n else fresh(handoff, current, value);\n registry.$so?.(hook);\n },\n { priority: 50 }\n );\n /**\n * The removal: a second hook, reading nothing, whose cleanup runs only when the owner retires or pauses. At 50 too —\n * a cross-window move re-runs the layout (60) and effect (75) priorities, and this must not run then.\n */\n effect(\n () => () => {\n if (part === undefined) return;\n if (intact()) (registry.$H![HANDOFF_COMMIT_AS] as CommitAs)(current, part, null);\n part.$s!.remove();\n (part.$e as ChildNode).remove();\n part = undefined;\n },\n { priority: 50 }\n );\n /**\n * **A function target follows** — only then: a third hook, at EFFECT priority (75) so a cross-window move re-runs it,\n * re-reads the target (tracked, so a store it reads moves it too) and, when the answer changed, moves the range — the\n * markers and what lies between them — into it. Moving keeps every node, components included.\n */\n if (typeof target === 'function')\n effect(() => {\n const next = target();\n if (!usable(next) || next === current) return;\n const from = current;\n current = next;\n if (part === undefined) return;\n /** A destroyed range is drawn afresh into the new target from the last value (its components set up again). */\n if (!intact()) return fresh(registry.$H!, next, last);\n const nodes: Node[] = [];\n for (let n: Node | null = part.$s!; n !== null; n = n.nextSibling) {\n nodes.push(n);\n if (n === part.$e) break;\n }\n /**\n * Within ONE document, `moveBefore` (Chromium, Firefox) keeps what an insertion would reset — focus, a playing media\n * element, an iframe — so a reactive target switching containers loses none of it. Across documents, or where it is\n * absent (WebKit), `append`: a cross-document insertion adopts.\n */\n const move = (next as Partial<{ moveBefore: (n: Node, c: Node | null) => void }>).moveBefore;\n if (move !== undefined && from.isConnected && next.isConnected && part.$s!.getRootNode() === next.getRootNode())\n for (const n of nodes) move.call(next, n, null);\n else next.append(...nodes);\n });\n};\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;;AC1G3D;;;;AAIG;AACH;AAsCA;;;;;;AAMG;AACH;;;;AAIG;AACI,MA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