@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.
- package/README.md +711 -225
- package/dist/development/vera-renderer-elements.d.ts +39 -0
- package/dist/development/vera-renderer-elements.d.ts.map +1 -0
- package/dist/development/vera-renderer-elements.js +193 -0
- package/dist/development/vera-renderer-elements.js.map +1 -0
- package/dist/development/vera-renderer-hydrate-slots.d.ts +94 -0
- package/dist/development/vera-renderer-hydrate-slots.d.ts.map +1 -0
- package/dist/development/vera-renderer-hydrate-slots.js +325 -0
- package/dist/development/vera-renderer-hydrate-slots.js.map +1 -0
- package/dist/development/vera-renderer-hydration.d.ts +332 -0
- package/dist/development/vera-renderer-hydration.d.ts.map +1 -0
- package/dist/development/vera-renderer-hydration.js +864 -0
- package/dist/development/vera-renderer-hydration.js.map +1 -0
- package/dist/development/vera-renderer-keyed.d.ts +25 -8
- package/dist/development/vera-renderer-keyed.d.ts.map +1 -1
- package/dist/development/vera-renderer-keyed.js +843 -268
- package/dist/development/vera-renderer-keyed.js.map +1 -1
- package/dist/development/vera-renderer-multi-window.d.ts +5 -0
- package/dist/development/vera-renderer-multi-window.d.ts.map +1 -0
- package/dist/development/vera-renderer-multi-window.js +40 -0
- package/dist/development/vera-renderer-multi-window.js.map +1 -0
- package/dist/development/vera-renderer-namespaces.d.ts +64 -0
- package/dist/development/vera-renderer-namespaces.d.ts.map +1 -0
- package/dist/development/vera-renderer-namespaces.js +94 -0
- package/dist/development/vera-renderer-namespaces.js.map +1 -0
- package/dist/development/vera-renderer-native-elements.d.ts +13 -0
- package/dist/development/vera-renderer-native-elements.d.ts.map +1 -0
- package/dist/development/vera-renderer-native-elements.js +231 -0
- package/dist/development/vera-renderer-native-elements.js.map +1 -0
- package/dist/development/vera-renderer-portal.d.ts +29 -0
- package/dist/development/vera-renderer-portal.d.ts.map +1 -0
- package/dist/development/vera-renderer-portal.js +167 -0
- package/dist/development/vera-renderer-portal.js.map +1 -0
- package/dist/development/vera-renderer-profiler.d.ts +48 -96
- package/dist/development/vera-renderer-profiler.d.ts.map +1 -1
- package/dist/development/vera-renderer-profiler.js +2423 -2140
- package/dist/development/vera-renderer-profiler.js.map +1 -1
- package/dist/development/vera-renderer-slots.d.ts +88 -92
- package/dist/development/vera-renderer-slots.d.ts.map +1 -1
- package/dist/development/vera-renderer-slots.js +1834 -1237
- package/dist/development/vera-renderer-slots.js.map +1 -1
- package/dist/development/vera-renderer-spread.d.ts +7 -41
- package/dist/development/vera-renderer-spread.d.ts.map +1 -1
- package/dist/development/vera-renderer-spread.js +539 -477
- package/dist/development/vera-renderer-spread.js.map +1 -1
- package/dist/development/vera-renderer-tag.d.ts +12 -3
- package/dist/development/vera-renderer-tag.d.ts.map +1 -1
- package/dist/development/vera-renderer-tag.js +671 -513
- package/dist/development/vera-renderer-tag.js.map +1 -1
- package/dist/development/vera-renderer-until.d.ts +24 -0
- package/dist/development/vera-renderer-until.d.ts.map +1 -0
- package/dist/development/vera-renderer-until.js +83 -0
- package/dist/development/vera-renderer-until.js.map +1 -0
- package/dist/development/vera-renderer.d.ts +48 -96
- package/dist/development/vera-renderer.d.ts.map +1 -1
- package/dist/development/vera-renderer.js +2400 -2104
- package/dist/development/vera-renderer.js.map +1 -1
- package/dist/vera-renderer-elements.min.js +2 -0
- package/dist/vera-renderer-elements.min.js.map +1 -0
- package/dist/vera-renderer-hydrate-slots.min.js +2 -0
- package/dist/vera-renderer-hydrate-slots.min.js.map +1 -0
- package/dist/vera-renderer-hydration.min.js +3 -0
- package/dist/vera-renderer-hydration.min.js.map +1 -0
- package/dist/vera-renderer-keyed.min.js +1 -1
- package/dist/vera-renderer-keyed.min.js.map +1 -1
- package/dist/vera-renderer-multi-window.min.js +2 -0
- package/dist/vera-renderer-multi-window.min.js.map +1 -0
- package/dist/vera-renderer-namespaces.min.js +2 -0
- package/dist/vera-renderer-namespaces.min.js.map +1 -0
- package/dist/vera-renderer-native-elements.min.js +2 -0
- package/dist/vera-renderer-native-elements.min.js.map +1 -0
- package/dist/vera-renderer-portal.min.js +2 -0
- package/dist/vera-renderer-portal.min.js.map +1 -0
- package/dist/vera-renderer-slots.min.js +1 -1
- package/dist/vera-renderer-slots.min.js.map +1 -1
- package/dist/vera-renderer-spread.min.js +1 -1
- package/dist/vera-renderer-spread.min.js.map +1 -1
- package/dist/vera-renderer-tag.min.js +1 -1
- package/dist/vera-renderer-tag.min.js.map +1 -1
- package/dist/vera-renderer-until.min.js +2 -0
- package/dist/vera-renderer-until.min.js.map +1 -0
- package/dist/vera-renderer.min.js +1 -1
- package/dist/vera-renderer.min.js.map +1 -1
- package/package.json +52 -9
- package/dist/development/vera-renderer-hydrate.d.ts +0 -147
- package/dist/development/vera-renderer-hydrate.d.ts.map +0 -1
- package/dist/development/vera-renderer-hydrate.js +0 -3136
- package/dist/development/vera-renderer-hydrate.js.map +0 -1
- package/dist/vera-renderer-hydrate.min.js +0 -2
- package/dist/vera-renderer-hydrate.min.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vera-renderer-keyed.min.js","sources":["../src/keyed.ts"],"sourcesContent":["import type { Item, KeyedResult, ListStrategy } from './renderer.js';\n\n/**\n * Keyed list reconciliation, as its own entry.\n *\n * **This module imports nothing.** Every other renderer entry inlines `./renderer.js` and carries\n * its own template cache, so a module that imported one of them would be wrong for the others —\n * `hydrate` in particular. Like `spread`, this one talks to whatever renderer is present through a\n * mangling-exempt protocol, which is what makes it additive rather than a substitute.\n *\n * It also does not register. `keyed()` stamps `$r` onto the result it marks, so the algorithm\n * travels with the values that need it: importing the marker is the whole installation, and a list\n * always names the strategy that understands it. Two strategies therefore cannot disagree — there\n * is nothing to disagree about, because the decision is per value rather than per registry.\n */\n\n/**\n * The standard head/tail algorithm (as in lit's `repeat` and Vue): skip matching prefixes and\n * suffixes, detect the two swap shapes directly, and fall back to key maps for arbitrary moves,\n * removals and insertions.\n *\n * Everything before reconciliation — the mode switch, the empty list, the initial fill — has\n * already happened in the renderer and is passed in, so this function only ever runs against a\n * non-empty list that is already keyed.\n */\n/**\n * **Reconciliation for a list whose nodes no longer live where its markers do.**\n *\n * `@verajs/renderer/slots` distributes a light-DOM host's children by MOVING them into the\n * component's tree. A keyed list that renders those children therefore ends up split: the items are\n * inside the component, the part's own markers stay behind in the host. The two-ended diff below\n * positions against those markers and against `end`, so every move it makes asks the host to insert\n * before a reference that is somewhere else — `NotFoundError`, in both builds. Shadow DOM never hits\n * this because the platform PROJECTS rather than moves: the nodes stay children of the host.\n *\n * The way out is to stop looking for an anchor. Walking the new order in REVERSE, each item is\n * placed immediately before its successor **in its own container**, and the last item in each\n * container is left exactly where it is. That needs no end marker, no part boundary, and no\n * knowledge of slots — and it is what makes a list SPLIT ACROSS SLOTS come out right for free,\n * since items in different containers simply have different successors. Native does the same thing\n * for the same input: order within each slot follows the logical order.\n *\n * Items created here go into the host, not into a container, because distribution is the observer's\n * job and has not run yet. They are skipped by the placement pass for that render and land in slot\n * order when it does.\n */\nconst reconcileRelocated: ListStrategy = (part, newValues, items, parent, end) => {\n const count = newValues.length;\n const byKey = new Map<unknown, Item>();\n for (const item of items) if (item !== null) byKey.set(item.$k, item);\n\n const newItems: Item[] = new Array(count);\n for (let i = 0; i < count; i++) {\n const existing = byKey.get((newValues[i] as KeyedResult).key);\n if (existing !== undefined) {\n part.$u(existing, newValues[i]);\n newItems[i] = existing;\n byKey.delete((newValues[i] as KeyedResult).key);\n }\n }\n /** Whatever kept no key is gone. `$d` moves into a scratch fragment, so its parent is irrelevant. */\n for (const dropped of byKey.values()) part.$d(dropped);\n\n /**\n * **One reverse pass that both places and creates**, so an item's successor is already final when\n * it is needed — and it is needed twice. Placing reads it as the reference; CREATING reads the\n * container it lives in, which is the only way a new item can land among its logical neighbours.\n *\n * Creating in the host instead would be simpler and is wrong: the observer distributes it later\n * and appends it, so an insertion in the middle of a list arrives at the end. Creating it in the\n * successor's container puts it where native would — and if it names a DIFFERENT slot than its\n * neighbour, it is in the host's subtree with a `slot` attribute, which is exactly what the\n * observer is watching for, so that case corrects itself.\n *\n * `$m` short-circuits an item already in position, which is what keeps this from re-attaching a\n * whole list; re-attaching is not free, it blurs focus and restarts transitions.\n */\n const successorIn = new Map<Node, Node>();\n for (let i = count - 1; i >= 0; i--) {\n const item = newItems[i];\n if (item === undefined) continue; // created below, in forward order, once neighbours are final\n const container = part.$f(item).parentNode;\n if (container === null) continue;\n const successor = successorIn.get(container);\n if (successor !== undefined) part.$m(item, successor, container);\n successorIn.set(container, part.$f(item));\n }\n /**\n * **Creations run FORWARD, after every surviving item is in its final place.** Two reasons.\n * A new item belongs beside its logical successor, and the successor's position is only final\n * once the reverse pass above has run. And consecutive new rows must land in logical order:\n * created back-to-front they arrive in the host reversed, the observer captures them in\n * arrival order, and the list renders permuted.\n *\n * Created under the HOST, before `end` — the part's own boundary. Created straight into the\n * component's tree they would read as the component's own output and never be captured;\n * appended to the host's tail they would sit in the component's region, which is the same\n * mistake. Between the part's markers they are unambiguously the host's content, which the\n * observer captures with native semantics. A new item whose logical successor lives inside\n * the component is then moved beside it — a move, which the observer already reads correctly.\n */\n for (let i = 0; i < count; i++) {\n if (newItems[i] !== undefined) continue;\n const created = part.$c(newValues[i], parent, end);\n const following = i + 1 < count ? newItems[i + 1] : undefined;\n if (following !== undefined) {\n const first = part.$f(following);\n if (first.parentNode !== null && first.parentNode !== parent) part.$m(created, first, first.parentNode);\n }\n newItems[i] = created;\n }\n return newItems;\n};\n\nconst reconcile: ListStrategy = (part, newValues, items, parent, end) => {\n const count = newValues.length;\n\n /**\n * Zero-allocation fast path for the dominant case: same length, same key order — a pure in-place\n * update (a selection change, a field edit). No key array, no output array, no null checks. Falls\n * through to the full algorithm on the first mismatch; the items already updated re-verify there\n * as cheap no-op compares.\n */\n if (items.length === count) {\n let i = 0;\n while (i < count && items[i].$k === (newValues[i] as KeyedResult).key) {\n part.$u(items[i], newValues[i]);\n i++;\n }\n if (i === count) return items;\n }\n\n /**\n * **Has anything moved this list's nodes out from under its markers?**\n *\n * Only `@verajs/renderer/slots` does today, but the question is asked of the DOM rather than of\n * that module — keyed imports nothing, and a list does not need to know what moved its nodes to\n * know that they moved.\n *\n * Placed after the no-change fast path, so the dominant case (same keys, same order) never\n * reaches it. What remains is one `parentNode` read per item against a diff that already does far\n * more per item, and it breaks on the first mismatch, so the case it exists for costs exactly one.\n */\n for (let i = 0; i < items.length; i++)\n if (part.$f(items[i]).parentNode !== parent)\n return reconcileRelocated(part, newValues, items, parent, end);\n\n const oldItems: (Item | null)[] = items;\n const newKeys: unknown[] = new Array(count);\n for (let i = 0; i < count; i++) newKeys[i] = (newValues[i] as KeyedResult).key;\n /**\n * Said once, where it is nearly free: the general algorithm already walks every key, and a list\n * whose keys never move never reaches here at all. A duplicate key is a mistake that behaves\n * *correctly* in the common case and arbitrarily in the rest, which is the shape of bug that\n * survives a test suite.\n */\n if (__DEV__ && new Set(newKeys).size !== count) {\n const seen = new Set<unknown>();\n const repeated = newKeys.filter((key) => (seen.has(key) ? true : (seen.add(key), false)));\n console.warn(\n `[vera] keyed: the key ${String(repeated[0])} is used by more than one item in this list. ` +\n `A key identifies one item, so which of them keeps the existing DOM is not defined — ` +\n `the list still renders, but nothing about which node ends up where can be relied on.`\n );\n }\n const newItems: Item[] = new Array(count);\n let oldHead = 0;\n let oldTail = oldItems.length - 1;\n let newHead = 0;\n let newTail = count - 1;\n let newKeyToIndex: Map<unknown, number> | undefined;\n let oldKeyToIndex: Map<unknown, number> | undefined;\n const refAt = (i: number): Node | null =>\n i < count && newItems[i] !== undefined ? part.$f(newItems[i]) : end;\n\n while (oldHead <= oldTail && newHead <= newTail) {\n if (oldItems[oldHead] === null) oldHead++;\n else if (oldItems[oldTail] === null) oldTail--;\n else if (oldItems[oldHead]!.$k === newKeys[newHead]) {\n part.$u((newItems[newHead] = oldItems[oldHead]!), newValues[newHead]);\n oldHead++;\n newHead++;\n } else if (oldItems[oldTail]!.$k === newKeys[newTail]) {\n part.$u((newItems[newTail] = oldItems[oldTail]!), newValues[newTail]);\n oldTail--;\n newTail--;\n } else if (oldItems[oldHead]!.$k === newKeys[newTail]) {\n const item = oldItems[oldHead]!;\n part.$m(item, refAt(newTail + 1), parent);\n part.$u(item, newValues[newTail]);\n newItems[newTail] = item;\n oldHead++;\n newTail--;\n } else if (oldItems[oldTail]!.$k === newKeys[newHead]) {\n const item = oldItems[oldTail]!;\n part.$m(item, part.$f(oldItems[oldHead]!), parent);\n part.$u(item, newValues[newHead]);\n newItems[newHead] = item;\n oldTail--;\n newHead++;\n } else {\n if (newKeyToIndex === undefined) {\n newKeyToIndex = new Map();\n for (let i = newHead; i <= newTail; i++) newKeyToIndex.set(newKeys[i], i);\n oldKeyToIndex = new Map();\n for (let i = oldHead; i <= oldTail; i++) {\n if (oldItems[i] !== null) oldKeyToIndex.set(oldItems[i]!.$k, i);\n }\n }\n if (!newKeyToIndex.has(oldItems[oldHead]!.$k)) {\n part.$d(oldItems[oldHead]!);\n oldHead++;\n } else if (!newKeyToIndex.has(oldItems[oldTail]!.$k)) {\n part.$d(oldItems[oldTail]!);\n oldTail--;\n } else {\n const oldIndex = oldKeyToIndex!.get(newKeys[newHead]);\n /**\n * **`oldItems[oldIndex]` can be null, and reading it crashed the render.** The map holds one\n * index per key, so a list where a key appears twice finds, for the second one, the slot the\n * first already consumed and nulled. `part.$m(null, …)` then read `_element` of null and took\n * the whole render down with a `TypeError` naming the renderer's internals rather than\n * anything the caller wrote.\n *\n * Duplicate keys are documented as undefined behaviour and stay that way — which of the two\n * keeps the existing node is not specified. Undefined must still mean *a list*, though, not\n * an exception from three frames inside a private algorithm: the shapes that crash are\n * particular (a duplicate **and** a reorder **and** a new key, found by fuzzing over a\n * four-key alphabet), so this passes in development and takes the page down later.\n *\n * Two ways a slot can already be spoken for, and both have to be checked. The map nulls what\n * it consumes, so `oldItems[oldIndex] === null` catches one. The other is invisible: the map\n * is built once, and the head/tail branches above consume items by *moving the pointers*\n * without nulling anything — so an index that was live when the map was built can now sit\n * outside `[oldHead, oldTail]`. With unique keys that is unreachable, because a key is looked\n * up at most once; with a repeated key it hands the same item to two positions, and the list\n * then renders one item short of what it holds. Checking only for null fixed the crash and\n * left that, which is the worse of the two — nothing throws and the page is quietly wrong.\n *\n * Treating either as \"not found\" gives the second occurrence a fresh item, which is what the\n * branch below already does for a key that never existed.\n */\n const reusable =\n oldIndex === undefined || oldIndex < oldHead || oldIndex > oldTail\n ? null\n : oldItems[oldIndex];\n if (reusable === null) {\n newItems[newHead] = part.$c(newValues[newHead], parent, part.$f(oldItems[oldHead]!));\n } else {\n const item = reusable;\n part.$m(item, part.$f(oldItems[oldHead]!), parent);\n part.$u(item, newValues[newHead]);\n newItems[newHead] = item;\n oldItems[oldIndex!] = null;\n }\n newHead++;\n }\n }\n }\n /**\n * The trailing fill inserts every remaining item before the same reference — `refAt(newTail + 1)`\n * cannot move while the loop runs, because the loop itself only fills slots *below* it. Built\n * into a fragment and landed with one `insertBefore`, an append of 1 000 rows costs one live-DOM\n * insertion instead of 1 000 — the same batching the renderer's index-mode grow path has always\n * had, which this path silently lacked. A single item skips the fragment: one insert either way.\n */\n if (newHead < newTail) {\n const ref = refAt(newTail + 1);\n const fragment = parent.ownerDocument!.createDocumentFragment();\n while (newHead <= newTail) {\n newItems[newHead] = part.$c(newValues[newHead], fragment, null);\n newHead++;\n }\n parent.insertBefore(fragment, ref);\n } else if (newHead === newTail) {\n newItems[newHead] = part.$c(newValues[newHead], parent, refAt(newTail + 1));\n newHead++;\n }\n while (oldHead <= oldTail) {\n const item = oldItems[oldHead++];\n if (item !== null) part.$d(item);\n }\n return newItems;\n};\n\n/**\n * Marks a template result with a stable key so list reconciliation moves it instead of rewriting\n * it. Key all items in a list or none — mixing is undefined behaviour, as are duplicate keys.\n *\n * **Undefined means the list is arbitrary, not that the render fails.** With a repeated key, which\n * item keeps the existing node is unspecified; the render still completes and the DOM still holds\n * what the list holds. Development warns, once per render.\n *\n * ```js\n * import { keyed } from '@verajs/renderer/keyed';\n * rows.map((r) => keyed(r.id, html`<tr>...</tr>`))\n * ```\n */\nexport const keyed = <T>(key: unknown, result: T): T => {\n /**\n * Two arguments, and the second is the one that goes missing — `keyed(row.id)` instead of\n * `keyed(row.id, html\\`…\\`)`. It failed with `Cannot set properties of undefined (setting 'key')`,\n * which names this function's internals and not the call.\n */\n if (__DEV__ && (result === null || typeof result !== 'object'))\n throw new TypeError(\n `keyed: expected a template as the second argument and received ${String(result)}. ` +\n `It marks a template with a key — \\`keyed(row.id, html\\`<li>…</li>\\`)\\`.`\n );\n (result as KeyedResult).key = key;\n (result as KeyedResult).$r = reconcile;\n return result;\n};\n"],"names":["reconcileRelocated","part","newValues","items","parent","end","count","length","byKey","Map","item","set","$k","newItems","Array","i","existing","get","key","undefined","$u","delete","dropped","values","$d","successorIn","container","$f","parentNode","successor","$m","created","$c","following","first","reconcile","oldItems","newKeys","newKeyToIndex","oldKeyToIndex","oldHead","oldTail","newHead","newTail","refAt","has","oldIndex","reusable","ref","fragment","ownerDocument","createDocumentFragment","insertBefore","keyed","result","$r"],"mappings":"AA8CA,MAAMA,EAAmC,CAACC,EAAMC,EAAWC,EAAOC,EAAQC,KACxE,MAAMC,EAAQJ,EAAUK,OAClBC,EAAQ,IAAIC,IAClB,IAAK,MAAMC,KAAQP,EAAoB,OAATO,GAAeF,EAAMG,IAAID,EAAKE,GAAIF,GAEhE,MAAMG,EAAmB,IAAIC,MAAMR,GACnC,IAAK,IAAIS,EAAI,EAAGA,EAAIT,EAAOS,IAAK,CAC9B,MAAMC,EAAWR,EAAMS,IAAKf,EAAUa,GAAmBG,UACxCC,IAAbH,IACFf,EAAKmB,GAAGJ,EAAUd,EAAUa,IAC5BF,EAASE,GAAKC,EACdR,EAAMa,OAAQnB,EAAUa,GAAmBG,KAE/C,CAEA,IAAK,MAAMI,KAAWd,EAAMe,SAAUtB,EAAKuB,GAAGF,GAgB9C,MAAMG,EAAc,IAAIhB,IACxB,IAAK,IAAIM,EAAIT,E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AAQ,CAAInC,EAAcoC,KAWpCA,EAAuBpC,IAAMA,EAC7BoC,EAAuBC,GAAKpB,EACtBmB"}
|
|
1
|
+
{"version":3,"file":"vera-renderer-keyed.min.js","sources":["../../shared-utils/src/diagnostic.ts","../src/keyed.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 { misuse, warnOnce } from '@verajs/shared-utils';\nimport { PROSE } from './keyed-diagnostics.js';\n/**\n * @verajs/renderer/keyed — key-based list reconciliation, loaded by the values that need it.\n *\n * `keyed()` stamps a result with its key and with the strategy that reconciles it (`$r`), so importing\n * the marker is what loads the algorithm: nothing registers, and a list names its own strategy. It\n * imports nothing at runtime and reaches the renderer only through the `$`-named list protocol on the\n * part (`$c` create, `$u` update, `$f` first node, `$m` move, `$d` remove) and each item's `$k`, which\n * is what lets it sit beside any renderer entry, hydrate included.\n */\nimport type { Item, KeyedResult, ListStrategy } from './renderer.js';\nimport type { CrossBundleHook } from '@verajs/core';\n\nconst reconcile: ListStrategy = (part, values, items, parent, end) => {\n const count = values.length;\n /** A `null` item is unkeyed, as the renderer's `$c` already treats it — never a throw on the second render. */\n const key = (i: number) => (values[i] as KeyedResult | null)?.key;\n let start = 0;\n let oldEnd = items.length - 1;\n let newEnd = count - 1;\n\n /**\n * The unchanged run at each end, matched without allocating. When what remains between them is only\n * removals (a row deleted) or only insertions (rows appended, prepended, inserted), it is settled here;\n * a same-order update is the case where nothing remains at all.\n */\n /** A row whose value is the result committed last time (a list row that did not re-render) is not even asked. */\n while (start <= oldEnd && start <= newEnd && items[start].$k === key(start)) {\n const value = values[start];\n if (value === undefined || value !== (items[start] as { $j?: unknown }).$j) items[start] = part.$u(items[start], value);\n start++;\n }\n while (start <= oldEnd && start <= newEnd && items[oldEnd].$k === key(newEnd)) {\n const value = values[newEnd];\n if (value === undefined || value !== (items[oldEnd] as { $j?: unknown }).$j) items[oldEnd] = part.$u(items[oldEnd], value);\n oldEnd--;\n newEnd--;\n }\n /**\n * A repeated key, said where it can have arisen: only when the new list has items between the end scans (inserted\n * or moved) — a same-order update and a pure removal cannot create one, and never pay for the check. It behaves\n * correctly in the common case and arbitrarily in the rest — the shape of bug that survives a test suite.\n * Development only; the keys are gathered only here.\n */\n if (__DEV__ && start <= newEnd) {\n const seen = new Set<unknown>();\n for (let i = 0; i < count; i++) {\n const k = key(i);\n if (seen.has(k)) {\n /** Once per (list, key): the same duplicate on every reconcile is noise; a NEW duplicate key is news. */\n warnOnce('keyed', 'a keyed list', 'keyed-duplicate-key', __DEV__ && (() => PROSE['keyed-duplicate-key'](String(k))), [part, k]);\n break;\n }\n seen.add(k);\n }\n }\n if (start > newEnd) {\n for (let i = start; i <= oldEnd; i++) part.$d(items[i]);\n items.splice(start, oldEnd - start + 1);\n return items;\n }\n /** Joined with `concat`, never spread into `splice`: an engine caps a call's arguments (JavaScriptCore at 65 536). */\n const ref = start < items.length ? part.$f(items[start]) : end;\n const added: Item[] = [];\n if (start > oldEnd) {\n for (let i = start; i <= newEnd; i++) added.push(part.$c(values[i], parent, ref));\n return items.slice(0, start).concat(added, items.slice(start));\n }\n\n /**\n * A genuine reorder: two-ended from where the scans stopped, with a key map of the old middle built only\n * when both ends miss. An old item the new list no longer holds stays until the final sweep removes it.\n */\n const old: (Item | null)[] = items;\n const next: Item[] = items.slice(0, start).concat(new Array(newEnd - start + 1), items.slice(oldEnd + 1));\n const before = (i: number): Node | null => (i < count ? part.$f(next[i]) : end);\n let map: Map<unknown, number> | undefined;\n /** The new middle's keys, built with `map`: what tells a removed old end from a moved one. */\n let fresh: Set<unknown> | undefined;\n let oldHead = start;\n let newHead = start;\n while (oldHead <= oldEnd && newHead <= newEnd) {\n const head = old[oldHead];\n const tail = old[oldEnd];\n if (head === null) oldHead++;\n else if (tail === null) oldEnd--;\n else if (head.$k === key(newHead)) {\n next[newHead] = part.$u(head, values[newHead]);\n oldHead++;\n newHead++;\n } else if (tail.$k === key(newEnd)) {\n next[newEnd] = part.$u(tail, values[newEnd]);\n oldEnd--;\n newEnd--;\n } else if (head.$k === key(newEnd)) {\n part.$m(head, before(newEnd + 1), parent);\n next[newEnd] = part.$u(head, values[newEnd]);\n oldHead++;\n newEnd--;\n } else if (tail.$k === key(newHead)) {\n part.$m(tail, part.$f(head), parent);\n next[newHead] = part.$u(tail, values[newHead]);\n oldEnd--;\n newHead++;\n } else {\n if (map === undefined) {\n map = new Map();\n for (let i = oldHead; i <= oldEnd; i++) if (old[i] !== null) map.set(old[i]!.$k, i);\n fresh = new Set();\n for (let i = newHead; i <= newEnd; i++) fresh.add(key(i));\n }\n /**\n * **An old end the new list no longer holds is REMOVED, not worked around** (2026-10-20): a push and a middle\n * splice in one flush left no unchanged run at either end, and the walk moved every row past the removed one —\n * 999 `insertBefore` on 1000 rows, where 2 DOM operations are right (`auto-moves.mjs`).\n */\n if (!fresh!.has(head.$k)) {\n part.$d(head);\n old[oldHead++] = null;\n continue;\n }\n if (!fresh!.has(tail.$k)) {\n part.$d(tail);\n old[oldEnd--] = null;\n continue;\n }\n /**\n * A slot the map points at may already be spoken for when a key repeats: nulled by an earlier reuse,\n * or consumed by the two-ended branches (which move pointers without nulling). Either is treated as\n * \"not found\" and gets a fresh item — duplicate keys are undefined behavior, but undefined must still\n * mean a list, never a throw or a row rendered twice.\n */\n const at = map.get(key(newHead));\n const reusable = at === undefined || at < oldHead || at > oldEnd ? null : old[at];\n if (reusable === null) next[newHead] = part.$c(values[newHead], parent, part.$f(head));\n else {\n part.$m(reusable, part.$f(head), parent);\n next[newHead] = part.$u(reusable, values[newHead]);\n old[at!] = null;\n }\n newHead++;\n }\n }\n const fill = before(newEnd + 1);\n for (; newHead <= newEnd; newHead++) next[newHead] = part.$c(values[newHead], parent, fill);\n for (; oldHead <= oldEnd; oldHead++) if (old[oldHead] !== null) part.$d(old[oldHead]!);\n return next;\n};\n\n/**\n * Marks a template result with a stable key, so list reconciliation moves it instead of rewriting it.\n * Key all items in a list or none. A repeated key is undefined behavior: which item keeps the existing\n * node is unspecified, but the render completes and the DOM holds what the list holds.\n *\n * ```js\n * import { keyed } from '@verajs/renderer/keyed';\n * rows.map((r) => keyed(r.id, html`<tr>…</tr>`))\n * ```\n */\nexport const keyed = <T>(key: unknown, result: T): T => {\n /**\n * The second argument is the one that goes missing — `keyed(row.id)`. It failed with `Cannot set properties of\n * undefined (setting 'key')`, which names this function's internals and not the call.\n */\n if (__DEV__ && (result === null || typeof result !== 'object'))\n throw new TypeError(misuse('keyed', 'keyed-not-template', __DEV__ && PROSE['keyed-not-template'](String(result))));\n (result as KeyedResult).key = key;\n (result as KeyedResult).$r = reconcile;\n return result;\n};\n\n/**\n * **Rows that track themselves** (PROBE P1, 2026-10-18; its `each(items, key, row)` API RETIRED 2026-10-21, Brian: the\n * automatic `.map` below replaced it, nothing documented or used it, and it carried its own reconcile and key cache):\n * core's hook machinery gives each row its own subscriber, and the renderer's list part does the walk and the moves. A\n * write a row read wakes exactly that row, which re-commits itself in place through `part.$u`.\n */\ntype Owner = { _$g$: number; _$x$: boolean; _$h$?: unknown[]; localName: string; readonly isConnected: boolean; readonly ownerDocument: Document };\n/** The row's hook, as core's `$q` hands it back: the record itself, run through its `$n` (a `$`-name: survives mangling). */\ntype RowHook = { $n(signal?: unknown, init?: boolean): void };\ntype EachPart = { $p(value: unknown): void; $u(item: Item, value: unknown): Item; $i?: Item[] };\n\n/** Core's queued-hook factory (`$q`) and retire (`$z`), handed over by `lists` when it is wired: a row's subscriber. */\nlet hook: ((owner: Owner, callback: (signal?: unknown, init?: boolean) => void) => RowHook) | undefined;\n/** Core's bare row hook (`$qb`), its direct retire (`$zh`) and the hook → owner read (`$ow`): one object fewer and no closure per row. */\nlet bareHook: ((owner: Owner, callback: (this: RowHook, signal?: unknown, init?: boolean) => void) => RowHook) | undefined;\nlet retireHook: ((hook: RowHook) => void) | undefined;\nlet ownerOf: ((hook: RowHook) => Owner) | undefined;\n/** Core's run ownership (`$own`). */\nlet own: ((hook: unknown, item: List) => void) | undefined;\n/** Core's settle (`$so`): a row that owns lists settles them where its run ends, or disposes them as it drops. */\nlet settle: ((hook: unknown, all?: boolean) => void) | undefined;\n/**\n * **How many live lists a ROW owns** (a `.map` inside a row's render), page-wide: while it is 0 — every page without\n * nested lists — a row's run and its drop pay one module read for ownership, and no lookup (what (e′) paid per row).\n */\nlet nested = 0;\n/** Every row's callback, ONE function: core calls it as a method of the row's hook, which leads back to the row. */\nfunction rowCb(this: RowHook, signal?: unknown, init?: boolean) {\n rowRun.call(ownerOf!(this) as Row, signal, init);\n}\n/** Core's retire (`$z`): what releases a row's subscriptions. */\nlet retire: ((owner: Owner) => void) | undefined;\n/** Core's raw walk of a store array (`$w`), when core is wired; otherwise the list walks itself. */\nlet walk: ((list: unknown, visit: (raw: unknown, item: unknown) => void, from?: number, to?: number) => boolean) | undefined;\n/** Core's raw read of a store array WITHOUT subscribing (`$wr`): what the list compares its unchanged ends on. */\nlet rawOf: ((list: unknown) => unknown[] | undefined) | undefined;\n/** The render counter: a row stamped with this render's `t` was met in it; one not met is swept (`eachValue`). */\nlet tick = 0;\n\n/**\n * A row's template result, ready for the list part: its `key` (what reconcile matches on), `$r` (the keyed strategy, so\n * the part reconciles by key) and `_$same$` (opts the result into the identity skip: the renderer may do nothing when\n * the SAME result object comes back, which a list row returns when it did not re-render).\n */\nconst stamp = (rec: Row) => {\n const r = rec.row(rec.item) as KeyedResult & { _$same$?: number };\n /** An automatic `.map` row may return a string or a number (`.map((t) => t.name).join(', ')`): nothing to stamp. */\n if (r === null || typeof r !== 'object') return r;\n r.key = rec.key;\n r.$r = reconcile;\n r._$same$ = 1;\n return r;\n};\n/**\n * **A row: its record AND its hook's OWNER, one object; the hook is core's BARE row hook (`$qb`: never in the owner's hook list, retired directly), held in `h`, run through the one shared `rowCb`.** (An earlier version made the row\n * its own hook, a subclass of core's hook class across the bundle boundary: one object per row instead of two. It bought\n * nothing — a Chrome profile of create10k showed the two identical, and two races put it 4–6% SLOWER at Chrome 10k\n * creation — and the cross-bundle subclass cost two mangling bugs; REVERTED, Brian 2026-10-20.) As the owner it carries\n * what core's hooks read of an owner: `_$g$` its generation (bumped by `drop`, which retires the hook), `_$x$` /\n * `localName`, `_$h$` the hook list core keeps on it (declared, so its first write is no shape change), `isConnected` (core\n * skips a disconnected owner's writes; the row is connected while its rendered node is) and `ownerDocument` (the\n * scheduler uses the element's own window). As the record: `part` its list part, `list` its automatic list, `key`,\n * `item` / `row` what it renders from, `result` its last template result, `inst` the instance that result was committed\n * into, `seen` the render that last met it.\n */\nclass Row {\n /**\n * `declare`d and ASSIGNED in the constructor, in one order — as core's `HookState` is — never class-field initializers\n * (a define-semantics field is a property DEFINITION per instance).\n */\n declare _$g$: number;\n declare _$x$: boolean;\n declare _$h$: unknown[] | undefined;\n declare localName: string;\n declare h: RowHook;\n declare part: EachPart | undefined;\n /** The automatic `.map` list this row belongs to (the only kind of row since `each` was retired, 2026-10-21). */\n declare list: List | undefined;\n declare result: KeyedResult | null;\n declare inst: Item | undefined;\n declare key: unknown;\n declare item: unknown;\n /** The RAW slot value the row was last met as: the list's cheap \"same row, same place\" test compares it. */\n declare src: unknown;\n declare row: (item: unknown) => unknown;\n declare seen: number;\n constructor(p: EachPart | undefined, k: unknown, item: unknown, row: (item: unknown) => unknown, t: number, list: List | undefined, src: unknown) {\n this._$g$ = 1;\n this._$x$ = false;\n this._$h$ = undefined;\n this.localName = 'each-row';\n this.h = undefined as unknown as RowHook;\n this.part = p;\n this.list = list;\n this.result = null;\n this.inst = undefined;\n this.key = k;\n this.item = item;\n this.src = src;\n this.row = row;\n this.seen = t;\n }\n get isConnected() {\n const node = (this.inst as { $R?: Node } | undefined)?.$R;\n return node === undefined || node.isConnected;\n }\n get ownerDocument() {\n return (this.inst as { $R?: Node } | undefined)?.$R?.ownerDocument ?? document;\n }\n}\n/**\n * The row's run: a write the row's render read wakes exactly this row. It re-stamps and commits its new result into its\n * OWN instance in place (`part.$u`); if the instance had to be replaced (the row's shape changed), the list part's item\n * array is patched to point at the new one.\n */\nfunction rowRun(this: Row, _signal?: unknown, init?: boolean) {\n const list = this.list;\n /** An automatic list the parent's latest run no longer reached: its rows go with it. */\n if (!init && list !== undefined && list.mapped !== list.parent.$runs) return orphan(list);\n const r = stamp(this);\n this.result = r;\n /** The row's render returned: a nested list it hid this time goes now (core's ownership, settled here — (e″)). */\n if (nested !== 0) settle!(this.h);\n /**\n * A run its LIST asked for (`init`: created, or re-run in the list's walk) only records its result — the list hands it\n * to the renderer. Only a write the row heard commits or wakes anything: a walk-time run that woke the parent made the\n * parent re-run its rows, which woke it again (a loop, measured 2026-10-20).\n */\n if (init) return;\n /**\n * An automatic list's row commits in place only while the page shows what the parent's LATEST run mapped (`committed`);\n * otherwise the map's result was used as a value (summed, joined, chained), so the parent re-renders with it.\n */\n if (list !== undefined && list.committed !== list.parent.$runs) return list.parent.$n();\n if (this.inst !== undefined) {\n const part = this.part!;\n const out = part.$u(this.inst, r);\n if (out !== this.inst) {\n const items = part.$i!;\n items[items.indexOf(this.inst)] = out;\n this.inst = out;\n }\n }\n}\nconst makeRow = (part: EachPart | undefined, k: unknown, item: unknown, row: (item: unknown) => unknown, list: List | undefined, src: unknown): Row => {\n const rec = new Row(part, k, item, row, tick, list, src);\n rec.h = bareHook!(rec, rowCb);\n /** `init`: a hook's first run is immediate (a queued hook's write-time run would only enqueue it). */\n rec.h.$n(undefined, true);\n return rec;\n};\n/** A row that left the list: its generation moves on (it goes inert) and core retires it (a self-owned hook: directly). */\nconst drop = (rec: Row) => {\n rec._$g$++;\n retireHook!(rec.h);\n if (nested !== 0) settle!(rec.h, true);\n /** A row owns exactly one hook today; if anything ever registers another on it, the full retire still runs. */\n if (rec._$h$ !== undefined) retire!(rec);\n};\n/**\n * **Automatic `.map`** (Brian 2026-10-20: every `.map` on a store array inside a render is\n * a keyed list, with no rule and nothing to learn). Core's array handler hands `state.todos.map(fn)` here when it runs in\n * a render (`$M`). The result is a REAL array of the row results — `.map(i => i.name).join(', ')` still works — and each\n * `fn(item)` runs once, under its ROW's hook, so the parent never subscribes to row fields: a write to\n * one item re-renders that row. A LIST (below) owns the rows and, as its own hook, the array's shape (`ITEMS`): a push\n * or a splice re-runs the list, not the parent.\n *\n * **The stale-value rule, decided by WHICH hook ran** (signals-readiness constraint 4: no change information is read):\n * the parent's run called `.map` → every row re-runs with the new `fn` (fresh parent values, exactly as a plain map); the\n * list's own hook ran alone → only the shape changed, so unchanged rows are skipped.\n *\n * **Keys:** an item's own `id`, else the item itself — what lets a refetch (`state.todos = await …`) keep the rows of\n * unchanged ids, and their DOM. A repeated `id` turns the list to identity keys for good (development warns,\n * `keyed-duplicate-key`); the same object twice gets a fresh row per occurrence. **A plain map instead** when `fn`\n * declares an index (`(t, i) => …`: a row would show a stale position after a reorder) or the array holds primitives.\n *\n * **Lists are matched to calls by ORDER within the parent's run**, as hooks are: the parent's k-th `.map` is the k-th\n * list. A list the parent's latest run did not reach is an orphan; its next wake retires it with its rows.\n */\nclass List {\n declare _$g$: number;\n declare _$x$: boolean;\n declare _$h$: unknown[] | undefined;\n declare localName: string;\n declare h: RowHook;\n /** Its parent hook, read across the bundle boundary (`CrossBundleHook`). */\n declare parent: CrossBundleHook;\n declare owner: Node & { readonly isConnected: boolean };\n declare fn: (item: unknown) => unknown;\n declare items: ArrayLike<unknown>;\n declare cache: Map<unknown, Row>;\n declare recs: Row[];\n declare values: unknown[];\n declare part: EachPart | undefined;\n declare mapped: number;\n declare committed: number;\n declare all: boolean;\n declare ident: boolean;\n declare dead: boolean;\n /** The array this list last mapped (a list is found by its array first: see the matching below). */\n declare raw: unknown[] | undefined;\n /** The ownership contract core reads (`$`-named): the parent run that last claimed it, its owning hook. */\n declare $r: number;\n declare $h: unknown;\n constructor(parent: List['parent'], owner: List['owner']) {\n this._$g$ = 1;\n this._$x$ = false;\n this._$h$ = undefined;\n this.localName = 'each-list';\n this.h = undefined as unknown as RowHook;\n this.parent = parent;\n this.owner = owner;\n this.fn = undefined as unknown as List['fn'];\n this.items = [];\n this.cache = new Map();\n this.recs = [];\n this.values = [];\n this.part = undefined;\n this.mapped = 0;\n this.committed = -1;\n this.all = true;\n this.ident = false;\n this.dead = false;\n this.raw = undefined;\n this.$r = -1;\n this.$h = undefined;\n }\n /** Disposed by core when the parent's run ends without claiming it, or the parent hook retires. */\n $d() {\n orphan(this);\n }\n /** Connected while the component that mapped it is. */\n get isConnected() {\n return this.owner.isConnected !== false;\n }\n get ownerDocument() {\n return this.owner.ownerDocument ?? document;\n }\n}\n/** The mark on a map's result: the list that made it. A Symbol private to this module copy. */\nconst AUTO = Symbol();\n/**\n * The marked array this module is committing right now, so the renderer's own list path takes THAT array — and only\n * it: a row built during the commit carries its own nested list, which must still reach `commitList` (a plain flag\n * turned every nested list away, so every inner write re-ran its outer row — measured 2026-10-20).\n */\nlet committing: unknown[] | undefined;\n/**\n * **Only a map whose rows are TEMPLATES becomes a list** (option C, Brian 2026-10-20 — measured first without the rule:\n * a `map → reduce` over 10k items in a render cost +29% Chrome / +30% Firefox on its first render and twice the heap,\n * 5.63 vs 2.85 MB, for rows nothing renders). A call site's first item decides, ONCE: its row run untracked; a result\n * that is not an object marks the call site `PLAIN` for good, and it maps natively from then on.\n */\nconst PLAIN = 0;\n/** Per parent hook: the run its lists were last counted in, how many it has reached this run, and the lists. */\ntype ListsState = {\n v: number;\n n: number;\n lists: (List | typeof PLAIN)[];\n /** This run's count of maps per array, and each array's slots by occurrence. */\n occ: Map<unknown, number>;\n byRaw: WeakMap<object, (List | typeof PLAIN | undefined)[]>;\n};\nconst listsOf = new WeakMap<object, ListsState>();\n/** Core's `untracked` (`$t`): the deciding run of a call site's first item subscribes nothing. */\nlet untracked: (<R>(fn: () => R) => R) | undefined;\n/** A list the parent no longer reaches: its rows and its own hook retire. */\nconst orphan = (list: List) => {\n /**\n * ONCE: a second orphan would count a row-owned list out of `nested` twice, and a count driven to 0 while nested\n * lists live turns their settling off — the leak (e″) closes, silently. Unreachable today (an orphaned list's hooks and\n * rows move generation, so nothing queued runs them again), kept as the invariant.\n */\n if (list.dead) return;\n list.dead = true;\n if (ownerOf!(list.parent as unknown as RowHook) instanceof Row) nested--;\n for (let i = 0; i < list.recs.length; i++) drop(list.recs[i]);\n list.recs = [];\n list.cache.clear();\n /**\n * A disposed list may stay RECORDED (in the per-array history), so it lets go of everything else: its last\n * results (a hidden 10k list's 10 000 template results), its render's callback, its array and its part (Brian 2026-10-20:\n * \"is there any risk with references getting held with the tables?\").\n */\n list.values = [];\n list.fn = undefined as unknown as List['fn'];\n list.items = [];\n list.part = undefined;\n list._$g$++;\n retire!(list);\n};\n/** The list's result committed into `part` by the renderer's own list path; then each row learns its instance and part. */\nconst commitList = (list: List, part: EachPart) => {\n const outer = committing;\n committing = list.values;\n try {\n part.$p(list.values);\n } finally {\n committing = outer;\n }\n /**\n * Marked committed only once the commit SUCCEEDED: a commit that threw left the list \"committed\" with its\n * rows' instances stale, and the next row write patched an instance the part no longer held (`items[-1]`). Unmarked,\n * a row write wakes the parent instead, which re-renders and commits again.\n */\n list.part = part;\n list.committed = list.parent.$runs;\n const its = part.$i;\n const recs = list.recs;\n if (its !== undefined)\n for (let i = 0; i < recs.length; i++) {\n recs[i].inst = its[i];\n recs[i].part = part;\n }\n};\n/**\n * The row last met as raw slot `value` is met again unchanged: the same raw object AND the same key (`id` written in\n * place re-keys the row, as a full walk would; a row keyed by identity has `key === src`).\n */\nconst same = (rec: Row, value: unknown) =>\n rec.src === value && (rec.key === value || (value !== null && typeof value === 'object' && (value as { id?: unknown }).id === rec.key));\n/** The list's run: walk the array (subscribing the list to its shape), reuse / create / sweep rows, mark the result. */\nfunction listRun(this: List): void {\n const all = this.all;\n this.all = false;\n if (!all && this.mapped !== this.parent.$runs) return orphan(this);\n const t = ++tick;\n const fn = this.fn;\n const cache = this.cache;\n const prev = this.recs;\n const n = this.items.length;\n const recs: Row[] = new Array(n);\n const values: unknown[] = new Array(n);\n let i = 0;\n let restart = false;\n /**\n * **The unchanged ends, settled on RAW slots before any key is resolved** (the reconcile's two-ends idea, one level\n * up). A swap or a splice changes a few slots and re-ran this whole walk — a Map lookup, an `hasOwn`, a proxy read per\n * row, 63% of a Chrome swap (2026-10-23). Off when every row must re-run (`all`), and off unless core can hand the raw\n * slots (`rawOf`: a plain store array) — the fallback below reads through the proxy, whose per-index reads are links.\n * Every row kept here is stamped `seen` BEFORE the middle runs, so a middle item repeating its key is still a duplicate.\n */\n let front = 0;\n let back = 0;\n const raw = all ? undefined : rawOf?.(this.items);\n if (raw !== undefined) {\n const m = prev.length;\n const lim = n < m ? n : m;\n while (front < lim && same(prev[front], raw[front])) front++;\n while (back < lim - front && same(prev[m - 1 - back], raw[n - 1 - back])) back++;\n for (let j = 0; j < front; j++) {\n const rec = prev[j];\n rec.seen = t;\n recs[j] = rec;\n values[j] = rec.result;\n }\n for (let j = 1; j <= back; j++) {\n const rec = prev[m - j];\n rec.seen = t;\n recs[n - j] = rec;\n values[n - j] = rec.result;\n }\n i = front;\n }\n const visit = (source: unknown, item: unknown) => {\n if (restart) return;\n /** The row last run at this position, met again as the same raw slot: no key to resolve (a swap's untouched middle). */\n const at = raw === undefined ? undefined : prev[i];\n let rec: Row | undefined;\n let k: unknown;\n if (at !== undefined && at.seen !== t && same(at, source)) {\n rec = at;\n k = at.key;\n } else {\n k = this.ident || !Object.hasOwn(source as object, 'id') ? source : (source as { id: unknown }).id;\n rec = cache.get(k);\n }\n if (rec !== undefined && rec.seen === t) {\n if (!this.ident) {\n /** A repeated id: identity keys from now on, and this run again from the start. Said once per list. */\n if (__DEV__) warnOnce('keyed', 'an automatic .map list', 'keyed-duplicate-key', __DEV__ && (() => PROSE['keyed-duplicate-key'](String(k))), this);\n this.ident = true;\n restart = true;\n return;\n }\n /** The same object twice under identity keys: a row of its own, never cached. */\n rec = makeRow(undefined, {}, item, fn, this, source);\n } else if (rec === undefined) {\n rec = makeRow(undefined, k, item, fn, this, source);\n cache.set(k, rec);\n } else if (all || rec.item !== item) {\n /** Through the row's OWN hook: what it reads subscribes the row, never the list or the parent. */\n rec.item = item;\n rec.row = fn;\n rec.h.$n(undefined, true);\n }\n rec.seen = t;\n rec.src = source;\n recs[i] = rec;\n values[i++] = rec.result;\n };\n if (!walk!(this.items, visit, front, n - back))\n for (let j = 0; j < n; j++) {\n const item = this.items[j];\n visit(item, item);\n }\n if (restart) {\n /** Identity keys now: every row is made again by a full walk, then this run's commit decision still applies. */\n for (const rec of cache.values()) drop(rec);\n cache.clear();\n this.recs = [];\n this.all = true;\n listRun.call(this);\n if (all) return;\n if (this.committed === this.parent.$runs && this.part !== undefined) commitList(this, this.part);\n else this.parent.$n();\n return;\n }\n /** Last run's rows this run did not meet: swept (each drops its own subscriptions). The kept ends were all met. */\n for (let j = front; j < prev.length - back; j++) {\n const rec = prev[j];\n if (rec.seen !== t) {\n if (cache.get(rec.key) === rec) cache.delete(rec.key);\n drop(rec);\n }\n }\n this.recs = recs;\n (values as unknown as Record<symbol, List>)[AUTO] = this;\n this.values = values;\n if (all) return;\n /** The shape changed alone: commit where the page shows the parent's latest result, or re-render the parent. */\n if (this.committed === this.parent.$runs && this.part !== undefined) commitList(this, this.part);\n else this.parent.$n();\n}\n/** Core's `$M`: `state.todos.map(fn)` inside a render. `raw` is the array behind `proxy`; `method` the native `map`. */\nconst automap = (\n proxy: ArrayLike<unknown>,\n raw: unknown[],\n fn: (item: unknown) => unknown,\n parent: List['parent'],\n owner: List['owner'],\n method: (this: unknown, fn: unknown) => unknown[],\n) => {\n let state = listsOf.get(parent);\n if (state === undefined) listsOf.set(parent, (state = { v: parent.$runs, n: 0, lists: [], occ: new Map(), byRaw: new WeakMap() }));\n else if (state.v !== parent.$runs) {\n state.v = parent.$runs;\n state.n = 0;\n state.occ.clear();\n }\n /**\n * EVERY `.map` call in a render takes its place in the order, whatever path it takes (one rule). An index or\n * non-function callback needs no memory — its arity is known at every call — so it takes the place WITHOUT writing\n * PLAIN: writing it could overwrite a live list unretired, and turn a list that slid onto this place into a plain map.\n */\n if (typeof fn !== 'function' || fn.length > 1) {\n state.n++;\n return method.call(proxy, fn);\n }\n /**\n * **A list is found by (ARRAY, its occurrence in this run) first** (2026-10-20): a conditional `.map` before\n * another no longer slides the later one onto its list — a hidden map shifts only other maps over the SAME array. A new\n * array (a refetch) falls back to the list at this call's place in order, but only one whose own array is not mapped in\n * this run, so it never takes another site's list. A PLAIN decision is found only by its exact array (a refetched plain\n * site decides again: one untracked call).\n */\n const k = state.occ.get(raw) ?? 0;\n state.occ.set(raw, k + 1);\n const slots = state.byRaw.get(raw);\n let list: List | typeof PLAIN | undefined = slots?.[k];\n /** Dead, or already claimed by another call this run (a list serves ONE call per run): not this call's. */\n if (list !== undefined && list !== PLAIN && (list.dead || list.mapped === parent.$runs)) list = undefined;\n /**\n * The order fallback is for a REFETCH only — a brand-new array, with no history of its own. An array that has history is\n * a RETURNING one (a list shown again): falling back would hand it another array's list, and that array's own call would\n * then share it (measured: auto-cond, both lists rendered from one).\n */\n if (list === undefined && slots === undefined) {\n const at = state.lists[state.n];\n if (at !== undefined && at !== PLAIN && !at.dead && at.mapped !== parent.$runs && !state.occ.has(at.raw)) list = at;\n }\n const st = state;\n const put = (v: List | typeof PLAIN) => {\n st.lists[st.n] = v;\n let mine = st.byRaw.get(raw);\n if (mine === undefined) st.byRaw.set(raw, (mine = []));\n mine[k] = v;\n if (v !== PLAIN) v.raw = raw;\n };\n if (list === PLAIN) {\n state.n++;\n return method.call(proxy, fn);\n }\n /**\n * **A call site with a live list ALWAYS runs it — an empty array included** (2026-10-20): the empty case took the plain\n * path, so clearing a list never swept its rows — 10 000 rows stayed alive and subscribed after `state.rows = []`\n * (Chrome: 12.22 MB retained after a clear vs the earlier idiom's 4.50, `perrow.mjs`), each create ran beside the last one's\n * rows (twice the live heap: Firefox's extra major GC), and the empty call did not count its place in the parent's\n * order, so a later `.map` slid into this one's list. With no list yet, an empty or primitive array maps natively, and\n * still takes its place (an empty one stays undecided; a primitive one is PLAIN for good).\n */\n if (list === undefined || list.dead) {\n if (raw.length === 0) {\n state.n++;\n return method.call(proxy, fn);\n }\n if (raw[0] === null || typeof raw[0] !== 'object') {\n put(PLAIN);\n state.n++;\n return method.call(proxy, fn);\n }\n }\n if (list === undefined) {\n const first = untracked!(() => fn(proxy[0]));\n /**\n * A list only when the first row is a TEMPLATE result — the renderer's OWN definition, `strings !== undefined`\n * (`isTemplateResult`, renderer.ts; a DELIBERATE twin, since this module imports nothing at runtime: change both\n * together), so a hand-built `{ strings, values }` the renderer accepts is a list here too —\n * not any object: a computational map returning plain objects (`items.map((i) => ({ ...i, label }))`, a directives\n * query) became a tracked list and broke `directives-query` (2026-10-20).\n */\n if (first === null || typeof first !== 'object' || (first as { strings?: unknown }).strings === undefined) {\n put(PLAIN);\n state.n++;\n return method.call(proxy, fn);\n }\n }\n if (list === undefined || list.dead) {\n const made = new List(parent, owner);\n made.h = hook!(made, () => listRun.call(made));\n if (ownerOf!(parent as unknown as RowHook) instanceof Row) nested++;\n list = made;\n }\n put(list);\n state.n++;\n /**\n * **Owned by the parent's run** (core's `$own`): when a parent run ENDS without claiming this list — its\n * render hid it, or no longer reaches it — core disposes it (`$d`, an orphan's retirement) at once, `.map` call or not.\n */\n own!(parent, list);\n list.fn = fn;\n list.items = proxy;\n list.mapped = parent.$runs;\n list.all = true;\n list.h.$n(undefined, true);\n return list.values;\n};\nconst eachValue = (part: object, value: unknown, adopted?: object) => {\n if (value === null || typeof value !== 'object') return false;\n /** An automatic `.map` result: committed by its list, which then knows the part its rows live in. */\n if (Array.isArray(value)) {\n const list = (value as unknown as Record<symbol, List | undefined>)[AUTO];\n if (list === undefined || value === committing) return false;\n /**\n * **Hydrating: the list ADOPTS the server's rows** (2026-10-22). The base adopted one instance per row FROM THESE\n * ROWS' OWN results — same count, same templates, same keys, by construction — so the list only takes ownership\n * (`ADOPTED`, 2) and the base's queued commits patch any stale value in place, as for every adopted instance. It used\n * to claim, which rebuilt every row. Any other shape (no adopted items, a count that differs) builds, as before.\n */\n const items = (adopted as EachPart | undefined)?.$i;\n if (items !== undefined && items.length === list.recs.length) {\n list.part = part as EachPart;\n list.committed = list.parent.$runs;\n for (let i = 0; i < items.length; i++) {\n list.recs[i].inst = items[i];\n list.recs[i].part = part as EachPart;\n }\n return 2;\n }\n commitList(list, part as EachPart);\n return true;\n }\n return false;\n};\n/**\n * **`createSelector(source)` → `isSelected(key)`** (2026-10-20): selection that wakes\n * exactly the rows whose answer changed. `isSelected(key)` subscribes the running hook to ONE cell per key (core's store\n * kit, `$k`, on a private target), and a hook watching `source` wakes only the previous and the new key's cells when it\n * changes — so a select re-renders 2 rows, not every row that compared against `state.selected`.\n *\n * ```js\n * const isSelected = createSelector(() => state.selected);\n * state.rows.map((r) => html`<tr class=${isSelected(r.id) ? 'selected' : ''}>…</tr>`)\n * ```\n *\n * Made in a component's setup, it is that component's (its watcher retires with it); with no component being set up it\n * THROWS, as every hook does. Its watcher runs inside the write (an immediate hook), so the woken rows render in the same flush.\n * Its keys are bounded: cells no row reads any more are pruned on an amortized budget (below).\n */\nlet kit: { track(obj: object, key: unknown): void; trigger(obj: object, key: unknown, value: unknown, prev: unknown): void } | undefined;\nlet makeHook: ((hook: { callback: () => void; priority: number }) => ((signal?: unknown, init?: boolean) => void) | undefined) | undefined;\nexport const createSelector = <K>(source: () => K): ((key: K) => boolean) => {\n if (kit === undefined || makeHook === undefined) throw new Error(misuse('createSelector', 'selector-not-wired', __DEV__ && PROSE['selector-not-wired']()));\n const target = {};\n const k = kit;\n let current: K | typeof target = target;\n const run = makeHook({\n callback: () => {\n const next = source();\n if (next === current) return;\n const prev = current;\n current = next;\n if (prev !== target) k.trigger(target, prev, false, true);\n k.trigger(target, next, true, false);\n },\n priority: 0,\n });\n run?.(undefined, true);\n /**\n * **Keys are bounded by core**: every big key map is swept as it grows (createProxy's `sweepIfDue`) — the cells no\n * row reads any more go, so a list whose ids only increase (a feed, a log) keeps only about twice its live keys. (This\n * selector had its own budgeted prune until core generalized it, 2026-10-23.)\n */\n return (key: K) => {\n k.track(target, key);\n return current === key;\n };\n};\n\n/**\n * Wire it: `wire([renderer, lists])`. A CONNECTOR (a function `wire` hands the registry): core's registry carries the\n * hook machinery (`$q`, `$z`) and the raw walk (`$w`); automatic `.map` results are recognized on the renderer's `'value'` insert.\n */\nexport const lists = (registry: { $q?: unknown; $qb?: unknown; $zh?: unknown; $ow?: unknown; $own?: unknown; $so?: unknown; $z?: unknown; $w?: unknown; $wr?: unknown; $M?: unknown; $t?: unknown; $k?: unknown; $s?: unknown }, w: (item: unknown) => void) => {\n hook = registry.$q as typeof hook;\n bareHook = registry.$qb as typeof bareHook;\n retireHook = registry.$zh as typeof retireHook;\n ownerOf = registry.$ow as typeof ownerOf;\n own = registry.$own as typeof own;\n settle = registry.$so as typeof settle;\n /** Core's array handler asks `$M` for a store array's `.map` inside a render: automatic lists. */\n (registry as { $M?: unknown }).$M = automap;\n retire = registry.$z as typeof retire;\n untracked = registry.$t as typeof untracked;\n kit = registry.$k as typeof kit;\n makeHook = (registry.$s as unknown[] | undefined)?.[2] as typeof makeHook;\n walk = registry.$w as typeof walk;\n rawOf = registry.$wr as typeof rawOf;\n w({ on: 'value', fn: eachValue, priority: 50 });\n};\n"],"names":["reconcile","part","values","items","parent","end","count","length","key","i","start","oldEnd","newEnd","$k","value","undefined","$j","$u","$d","splice","ref","$f","added","push","$c","slice","concat","old","next","Array","before","map","fresh","oldHead","newHead","head","tail","$m","Map","set","Set","add","has","at","get","reusable","fill","keyed","result","$r","hook","bareHook","retireHook","ownerOf","own","settle","retire","walk","rawOf","nested","rowCb","signal","init","rowRun","call","this","tick","stamp","rec","r","row","item","_$same$","Row","constructor","p","k","t","list","src","_$g$","_$x$","_$h$","localName","h","inst","seen","isConnected","node","$R","ownerDocument","document","_signal","mapped","$runs","orphan","committed","$n","out","$i","indexOf","makeRow","drop","List","owner","fn","cache","recs","all","ident","dead","raw","$h","AUTO","Symbol","committing","listsOf","WeakMap","untracked","clear","commitList","outer","$p","its","same","id","listRun","prev","n","restart","front","back","m","lim","j","visit","source","Object","hasOwn","delete","automap","proxy","method","state","v","lists","occ","byRaw","slots","st","put","mine","first","strings","made","eachValue","adopted","isArray","kit","makeHook","createSelector","Error","target","current","run","callback","trigger","priority","track","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ChB3H,EAAQ+G,EAASa,IACjBZ,EAAE,CAAEa,GAAI,QAAS9E,GAAIkD,EAAWY,SAAU,IAAK"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const n=(n,o)=>{const e=n,r=new WeakSet,t=globalThis,i=n=>{const o=n.ownerDocument.defaultView;null===o||o===t||r.has(o)||(r.add(o),o.addEventListener("pagehide",(n=>{if(n.persisted)return;const r=o.document;t.setTimeout((()=>(n=>{const o=e.$td,r=e.$m;if(void 0===o||void 0===r)return;const t=e=>{for(const i of e.querySelectorAll("*")){const e=i.shadowRoot??i._$r$;e&&t(e),void 0!==i[r]&&i.ownerDocument===n&&o(i)}};t(n)})(r)),0)})))};o([{name:"@verajs/renderer/multi-window",on:"adopted",fn:i,priority:60},{name:"@verajs/renderer/multi-window",on:"init",fn:n=>{i(n)},priority:60}])};export{n as multiWindow};
|
|
2
|
+
//# sourceMappingURL=vera-renderer-multi-window.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vera-renderer-multi-window.min.js","sources":["../src/multi-window.ts"],"sourcesContent":["/**\n * **`multiWindow` — components in the windows your page opens or embeds** (`@verajs/renderer/multi-window`; Brian\n * 2026-10-26). `wire([renderer, multiWindow])`. A component moved into a pop-out (`window.open`, an auxiliary browsing\n * context) or an iframe (a child navigable) is KEPT by core already; this module releases the ones LEFT there when\n * that window goes away for good. Without it, a component left behind stays subscribed to this window's stores, alive and\n * running, for the life of the page.\n *\n * - **Which windows.** One a component of this core is ADOPTED into (core's `'adopted'` insert: moved there, or resumed\n * there) or first CONNECTED in (an `'init'` insert: appended there directly). Each is watched once, in a WeakSet, so a\n * dead window is never held.\n * - **When.** At that window's final `pagehide` (not `persisted`: a back/forward cached page comes back), on THIS realm's\n * next task, so the app's own `pagehide` handlers run first, and moving a panel back home is what they do.\n * - **What.** The dead document is walked, shadow roots included (`_$r$` holds the closed ones core made), and every\n * component of THIS core still in it is retired through core's own teardown (`$td`). Recognized by core's per-copy mark\n * (`$m`), so two copies of core on one page never retire each other's components — in PRODUCTION, where each copy has\n * its own registry. In development two copies share one registry (core keeps `@verajs/inserts` external there), so `$m`\n * is whichever copy loaded last: two cores in development is the known mis-resolution trap, not a supported setup, and\n * the two-copies row runs in production only. A component moved back before the release is no longer there,\n * and survives.\n * - **A connector**, as `@verajs/hot` is: each core it is wired into gets its own watch and release, against its own\n * teardown and mark. It imports nothing.\n */\ntype Registry = { $td?: (element: Element) => void; $m?: symbol };\ntype Wire = (item: never) => void;\n\nexport const multiWindow = (registry: object, w: Wire) => {\n const core = registry as Registry;\n const watched = new WeakSet<object>();\n /** This realm's window: its timers run; a dead window's never fire. */\n const home = globalThis;\n const release = (dead: Document) => {\n const teardown = core.$td, mine = core.$m;\n if (teardown === undefined || mine === undefined) return;\n const walk = (root: ParentNode) => {\n for (const el of root.querySelectorAll('*')) {\n const inner = el.shadowRoot ?? (el as { _$r$?: ShadowRoot })._$r$;\n if (inner) walk(inner);\n if ((el as unknown as Record<symbol, unknown>)[mine] !== undefined && el.ownerDocument === dead) teardown(el);\n }\n };\n walk(dead);\n };\n const watch = (element: Element) => {\n const view = element.ownerDocument.defaultView;\n if (view === null || view === (home as unknown) || watched.has(view)) return;\n watched.add(view);\n view.addEventListener('pagehide', (event) => {\n if ((event as PageTransitionEvent).persisted) return;\n const dead = view.document;\n home.setTimeout(() => release(dead), 0);\n });\n };\n w([\n { name: '@verajs/renderer/multi-window', on: 'adopted', fn: watch, priority: 60 },\n { name: '@verajs/renderer/multi-window', on: 'init', fn: (element: Element) => { watch(element); }, priority: 60 },\n ] as never);\n};\n"],"names":["multiWindow","registry","w","core","watched","WeakSet","home","globalThis","watch","element","view","ownerDocument","defaultView","has","add","addEventListener","event","persisted","dead","document","setTimeout","teardown","$td","mine","$m","undefined","walk","root","el","querySelectorAll","inner","shadowRoot","_$r$","release","name","on","fn","priority"],"mappings":"MAyBaA,EAAc,CAACC,EAAkBC,KAC5C,MAAMC,EAAOF,EACPG,EAAU,IAAIC,QAEdC,EAAOC,WAaPC,EAASC,IACb,MAAMC,EAAOD,EAAQE,cAAcC,YACtB,OAATF,GAAiBA,IAAUJ,GAAoBF,EAAQS,IAAIH,KAC/DN,EAAQU,IAAIJ,GACZA,EAAKK,iBAAiB,YAAaC,IACjC,GAAKA,EAA8BC,UAAW,OAC9C,MAAMC,EAAOR,EAAKS,SAClBb,EAAKc,YAAW,IAnBJ,CAACF,IACf,MAAMG,EAAWlB,EAAKmB,IAAKC,EAAOpB,EAAKqB,GACvC,QAAiBC,IAAbJ,QAAmCI,IAATF,EAAoB,OAClD,MAAMG,EAAQC,IACZ,IAAK,MAAMC,KAAMD,EAAKE,iBAAiB,KAAM,CAC3C,MAAMC,EAAQF,EAAGG,YAAeH,EAA6BI,KACzDF,GAAOJ,EAAKI,QACyCL,IAApDG,EAA0CL,IAAuBK,EAAGjB,gBAAkBO,GAAMG,EAASO,EAC5G,GAEFF,EAAKR,EAAK,EASce,CAAQf,IAAO,EAAE,IACvC,EAEJhB,EAAE,CACA,CAAEgC,KAAM,gCAAiCC,GAAI,UAAWC,GAAI5B,EAAO6B,SAAU,IAC7E,CAAEH,KAAM,gCAAiCC,GAAI,OAAQC,GAAK3B,IAAuBD,EAAMC,EAAQ,EAAK4B,SAAU,KACrG"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const t="http://www.w3.org/1999/xhtml",n="http://www.w3.org/2000/svg",l="http://www.w3.org/1998/Math/MathML",e={},r=(n,l)=>{if(n.namespaceURI===t)return null;if("annotation-xml"===n.localName){const t=n.getAttribute("encoding")?.toLowerCase();if("text/html"===t||"application/xhtml+xml"===t)return null}const r=(e[n.namespaceURI]??={})[n.localName]??={};let o=r[l];if(void 0===o){const e=n.cloneNode(!1);e.innerHTML=`<${l}></${l}>`;const i=e.firstChild?.namespaceURI??null;r[l]=o=i===t?null:i}return o},o=Symbol(),i={name:"@verajs/renderer/namespaces",on:"template",priority:50,fn:(t,e,i)=>{const s=t,w=e._$litType$??1;if(1!==w)return void(s._$ns$=2===w?n:l);const a=/<([a-zA-Z][^\s/>]*)/.exec(e.strings.join("").replace(/<!--(?:-?>|[\s\S]*?--!?>)/g,""))?.[1]??"x";let c,p;s._$at$=t=>{const w=t[o];return null===(u=void 0!==w?w:1!==t.nodeType?i()?._$ns$??null:t.namespaceURI===l?r(t,a):t[o]=r(t,"x"))?s:u===n?c??=new s.constructor({_$litType$:2,strings:e.strings}):p??=new s.constructor({_$litType$:3,strings:e.strings});var u}}};export{i as namespaces};
|
|
2
|
+
//# sourceMappingURL=vera-renderer-namespaces.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vera-renderer-namespaces.min.js","sources":["../src/namespaces.ts"],"sourcesContent":["/**\n * **`@verajs/renderer/namespaces` — a template is parsed in the namespace of the position it lands in.**\n *\n * `wire([renderer, namespaces])`, and `` html`<path/>` `` committed inside an `<svg>` is built as SVG — as the\n * platform's fragment parser treats markup given a context element — so a component's children cross a function\n * boundary without anyone choosing `svg\\`…\\`` for them. `@verajs/jsx` wires it for every module it compiles, because\n * JSX cannot write `svg\\`…\\``. An app that does not wire it pays nothing.\n *\n * It imports nothing: the renderer reaches it through the `'template'` insert, and it answers through the\n * sigil-named `_$at$` (which template to build at a position) and `_$ns$` (a template's own namespace), which\n * mangling leaves alone. **The child namespace is asked of the PARSER**, not written down — integration points\n * (`<foreignObject>`, `<annotation-xml>`, MathML's text elements) answer as the engine answers — with one exception\n * the engines disagree about.\n */\nimport type { TemplateResult } from './types.js';\n\n/** The three namespaces — fixed by the specifications, so written rather than read off a probe element. */\nconst HTML = 'http://www.w3.org/1999/xhtml';\nconst SVG = 'http://www.w3.org/2000/svg';\nconst MATHML = 'http://www.w3.org/1998/Math/MathML';\n\n/** The renderer's template, as this module sees it: two sigil-named members and a way to build a variant. */\ntype Template = {\n _$at$?: (parent: Node) => Template;\n _$ns$?: string | null;\n constructor: new (result: { _$litType$: number; strings: TemplateStringsArray }) => Template;\n};\n\n/**\n * **The namespace a `tag` takes as a child of `parent`** (`null` for HTML), asked of the parser: a shallow clone of\n * the parent is handed that child through `innerHTML`, which runs the fragment parser with it as the context. Cached\n * by the parent's KIND — namespace and name — and the tag, because nothing else decides it: one probe per kind of\n * parent for the life of the page, and no DOM node held. Nested objects rather than a joined key: building the key\n * cost more than the lookup, on a path walked once per instance.\n *\n * **The tag decides only under a MathML parent**: `<svg>` in `<annotation-xml>` is SVG where any other child is\n * MathML, and `<mglyph>`/`<malignmark>` stay MathML inside `<mi>`/`<mo>`/`<mn>`/`<ms>`/`<mtext>` where any other child\n * is HTML. Every other parent is asked with a stand-in tag, since its answer is the same for all.\n */\nconst answers: Record<string, Record<string, Record<string, string | null>>> = {};\nconst childOf = (parent: Element, tag: string): string | null => {\n if (parent.namespaceURI === HTML) return null;\n /**\n * The one context the probe cannot answer: the engines DISAGREE about `<annotation-xml>` as a fragment parser's\n * context — Chromium reads its `encoding`, Firefox does not — while all agree in full markup, where the `encoding`\n * on its start tag decides. So the attribute is read, and the answer is not cached (a binding can change it).\n */\n if (parent.localName === 'annotation-xml') {\n const encoding = parent.getAttribute('encoding')?.toLowerCase();\n if (encoding === 'text/html' || encoding === 'application/xhtml+xml') return null;\n }\n const byTag = ((answers[parent.namespaceURI!] ??= {})[parent.localName] ??= {});\n let answer = byTag[tag];\n if (answer === undefined) {\n const probe = parent.cloneNode(false) as Element;\n probe.innerHTML = `<${tag}></${tag}>`;\n const ns = (probe.firstChild as Element | null)?.namespaceURI ?? null;\n byTag[tag] = answer = ns === HTML ? null : ns;\n }\n return answer;\n};\n\n/**\n * **A parent element's answer, cached ON it** under a Symbol — the fast path: every row of a list shares one parent,\n * and once this is wired EVERY `html` instance asks, so the common case must be one property read, not the\n * `namespaceURI`/`localName` reads the kind cache needs. A string stored on the element holds nothing and dies with\n * it (measured alternatives: a `WeakRef` to the last parent cost Firefox 8.7% on plain creation; a strong reference\n * would keep a removed subtree alive). Invisible to `Object.keys` and `for…in`. Not used under a MathML parent, whose\n * answer depends on the tag.\n */\nconst ANSWER = Symbol();\ntype Cached = Element & { [ANSWER]?: string | null };\n\nexport const namespaces = {\n name: '@verajs/renderer/namespaces',\n on: 'template' as const,\n priority: 50,\n /**\n * Typed as the `'template'` insert declares it — the renderer hands its template as an `object` — so\n * `wire([renderer, namespaces])` type-checks for a consumer; the sigil-named members are this module's view of it.\n */\n fn: (built: object, result: Pick<TemplateResult, '_$litType$' | 'strings'>, readScope: () => unknown): void => {\n const template = built as Template;\n const type = result._$litType$ ?? 1;\n /** An `svg\\`…\\``/`mathml\\`…\\`` template — or a variant this module built — is in its namespace already. */\n if (type !== 1) {\n template._$ns$ = type === 2 ? SVG : MATHML;\n return;\n }\n /**\n * The template's first ELEMENT's tag — past leading text, comments and expressions (`<!--c--><svg>`, `label <svg>`,\n * `${x}<svg>`), `x` when it has none — which is what a MathML parent's answer depends on.\n */\n const tag = /<([a-zA-Z][^\\s/>]*)/.exec(result.strings.join('').replace(/<!--(?:-?>|[\\s\\S]*?--!?>)/g, ''))?.[1] ?? 'x';\n /** Its SVG and MathML builds, made the first time one is needed — the renderer's own constructor, so every\n * construction-time decision (every refusal) is made again there, never copied. */\n let svg: Template | undefined;\n let mathml: Template | undefined;\n const pick = (ns: string | null): Template =>\n ns === null\n ? template\n : ns === SVG\n ? (svg ??= new template.constructor({ _$litType$: 2, strings: result.strings }))\n : (mathml ??= new template.constructor({ _$litType$: 3, strings: result.strings }));\n template._$at$ = (parent) => {\n const cached = (parent as Cached)[ANSWER];\n if (cached !== undefined) return pick(cached);\n /** Still inside an instance's detached clone: the template being built answers, with its own namespace. */\n if (parent.nodeType !== 1) return pick((readScope() as Template | null)?._$ns$ ?? null);\n if ((parent as Element).namespaceURI === MATHML) return pick(childOf(parent as Element, tag));\n return pick(((parent as Cached)[ANSWER] = childOf(parent as Element, 'x')));\n };\n },\n};\n"],"names":["HTML","SVG","MATHML","answers","childOf","parent","tag","namespaceURI","localName","encoding","getAttribute","toLowerCase","byTag","answer","undefined","probe","cloneNode","innerHTML","ns","firstChild","ANSWER","Symbol","namespaces","name","on","priority","fn","built","result","readScope","template","type","_$litType$","_$ns$","exec","strings","join","replace","svg","mathml","_$at$","cached","nodeType","constructor"],"mappings":"AAiBA,MAAMA,EAAO,+BACPC,EAAM,6BACNC,EAAS,qCAoBTC,EAAyE,CAAA,EACzEC,EAAU,CAACC,EAAiBC,KAChC,GAAID,EAAOE,eAAiBP,EAAM,OAAO,KAMzC,GAAyB,mBAArBK,EAAOG,UAAgC,CACzC,MAAMC,EAAWJ,EAAOK,aAAa,aAAaC,cAClD,GAAiB,cAAbF,GAAyC,0BAAbA,EAAsC,OAAO,IAC/E,CACA,MAAMG,GAAUT,EAAQE,EAAOE,gBAAmB,CAAA,GAAIF,EAAOG,aAAe,GAC5E,IAAIK,EAASD,EAAMN,GACnB,QAAeQ,IAAXD,EAAsB,CACxB,MAAME,EAAQV,EAAOW,WAAU,GAC/BD,EAAME,UAAY,IAAIX,OAASA,KAC/B,MAAMY,EAAMH,EAAMI,YAA+BZ,cAAgB,KACjEK,EAAMN,GAAOO,EAASK,IAAOlB,EAAO,KAAOkB,CAC7C,CACA,OAAOL,CAAM,EAWTO,EAASC,SAGFC,EAAa,CACxBC,KAAM,8BACNC,GAAI,WACJC,SAAU,GAKVC,GAAI,CAACC,EAAeC,EAAwDC,KAC1E,MAAMC,EAAWH,EACXI,EAAOH,EAAOI,YAAc,EAElC,GAAa,IAATD,EAEF,YADAD,EAASG,MAAiB,IAATF,EAAa9B,EAAMC,GAOtC,MAAMI,EAAM,sBAAsB4B,KAAKN,EAAOO,QAAQC,KAAK,IAAIC,QAAQ,6BAA8B,OAAO,IAAM,IAGlH,IAAIC,EACAC,EAOJT,EAASU,MAASnC,IAChB,MAAMoC,EAAUpC,EAAkBe,GAClC,OAPO,QADKF,OAQGJ,IAAX2B,EAAkCA,EAEd,IAApBpC,EAAOqC,SAA6Bb,KAAiCI,OAAS,KAC7E5B,EAAmBE,eAAiBL,EAAoBE,EAAQC,EAAmBC,GAC1ED,EAAkBe,GAAUhB,EAAQC,EAAmB,MAVjEyB,EACAZ,IAAOjB,EACJqC,IAAQ,IAAIR,EAASa,YAAY,CAAEX,WAAY,EAAGG,QAASP,EAAOO,UAClEI,IAAW,IAAIT,EAASa,YAAY,CAAEX,WAAY,EAAGG,QAASP,EAAOO,UALjE,IAACjB,CAY+D,CAC5E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const t=Symbol(),o=Symbol(),n=new WeakMap;let e;const i=t=>t.getRootNode().host,c=c=>{const l=c.customElements;let s=n.get(l);if(void 0===s){let r=0;for(;void 0!==l.get(s=`vera-s-${r}`);)r++;l.define(s,class extends c.HTMLElement{connectedCallback(){const n=i(this);!0===n._$x$||n[o]?(n[o]=void 0,(o=>{const n=o[t];void 0!==n&&null!==o.ownerDocument.defaultView&&e.$in(o,n[0],n[1])})(n)):void 0!==n._$d$&&n.ownerDocument!==n._$d$&&e.$rh(n)}disconnectedCallback(){const t=i(this);t.isConnected||!0===t._$x$||e.$td(t)}}),n.set(l,s)}return s},l=(n,e,i)=>{if(n.localName.indexOf("-")>=0)return;if(n.ownerDocument._$srv$)return;const l=n.ownerDocument.defaultView;if(null!==l&&!l.customElements.getName?.(n.constructor)){if(void 0===n[t]){let t;try{t=n.attachShadow({mode:"closed"})}catch{return}const o=n.ownerDocument,e=o.createElement(c(l));e.hidden=!0,t.append(o.createElement("slot"),e)}if(n[t]=[e,i],!n.isConnected)return n[o]=!0,!1}},s=(t,o)=>{e=t,o({on:"init",fn:l,priority:0})};export{s as nativeElements};
|
|
2
|
+
//# sourceMappingURL=vera-renderer-native-elements.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vera-renderer-native-elements.min.js","sources":["../../shared-utils/src/diagnostic.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","/**\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":["SETUP","Symbol","PENDING","names","WeakMap","core","hostOf","sentinel","getRootNode","host","sentinelFor","win","registry","customElements","name","get","undefined","n","define","HTMLElement","connectedCallback","this","_$x$","given","ownerDocument","defaultView","$in","setUp","_$d$","$rh","disconnectedCallback","isConnected","$td","set","onInit","element","options","setup","localName","indexOf","_$srv$","getName","constructor","root","attachShadow","mode","doc","createElement","hidden","append","nativeElements","w","on","fn","priority"],"mappings":"AAMO,MCqBDA,EAAQC,SAERC,EAAUD,SAEVE,EAAQ,IAAIC,QAClB,IAAIC,EAEJ,MAAMC,EAAUC,GAAuBA,EAASC,cAA6BC,KAQvEC,EAAeC,IACnB,MAAMC,EAAWD,EAAIE,eACrB,IAAIC,EAAOX,EAAMY,IAAIH,GACrB,QAAaI,IAATF,EAAoB,CACtB,IAAIG,EAAI,EACR,UAAgDD,IAAzCJ,EAASG,IAAKD,EAAO,UAAUG,MAAqBA,IAC3DL,EAASM,OACPJ,EACA,cAAcH,EAAIQ,YAChB,iBAAAC,GAKE,MAAMX,EAAOH,EAAOe,OACF,IAAdZ,EAAKa,MAAiBb,EAAKP,IAC7BO,EAAKP,QAAWc,EArBd,CAACP,IACb,MAAMc,EAAQd,EAAKT,QACLgB,IAAVO,GAA0D,OAAnCd,EAAKe,cAAcC,aAAsBpB,EAAMqB,IAAIjB,EAAMc,EAAM,GAAIA,EAAM,GAAG,EAoB7FI,CAAMlB,SACiBO,IAAdP,EAAKmB,MAAsBnB,EAAKe,gBAAkBf,EAAKmB,MAAMvB,EAAMwB,IAAIpB,EACpF,CACA,oBAAAqB,GACE,MAAMrB,EAAOH,EAAOe,MAEfZ,EAAKsB,cAA6B,IAAdtB,EAAKa,MAAejB,EAAM2B,IAAIvB,EACzD,IAGJN,EAAM8B,IAAIrB,EAAUE,EACtB,CACA,OAAOA,CAAI,EAWPoB,EAAS,CAACC,EAAkDC,EAAkBC,KAMlF,GAAIF,EAAQG,UAAUC,QAAQ,MAAQ,EAAG,OAEzC,GAAKJ,EAAQX,cAAkDgB,OAAQ,OACvE,MAAM7B,EAAMwB,EAAQX,cAAcC,YAClC,GAAY,OAARd,IAECA,EAAIE,eAA+D4B,UAAUN,EAAQO,aAA1F,CACA,QAAuB1B,IAAnBmB,EAAQnC,GAAsB,CAChC,IAAI2C,EACJ,IACEA,EAAOR,EAAQS,aAAa,CAAEC,KAAM,UACtC,CAAE,MAIA,MACF,CACA,MAAMC,EAAMX,EAAQX,cACdjB,EAAWuC,EAAIC,cAAcrC,EAAYC,IAK/CJ,EAASyC,QAAS,EAClBL,EAAKM,OAAOH,EAAIC,cAAc,QAASxC,EAMzC,CAQA,GAPA4B,EAAQnC,GAAS,CAACoC,EAASC,IAOvBF,EAAQJ,YAEZ,OADCI,EAAwCjC,IAAW,GAC7C,CAlCiH,CAkC5G,EAUDgD,EAAiB,CAACtC,EAAoBuC,KAEjD9C,EAAOO,EAIPuC,EAAE,CAAEC,GAAI,OAAQC,GAAInB,EAAQoB,SAAU,GAAa"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{untrack as o,effect as n,inserts as t}from"@verajs/core";let r=!1;const e=!0===globalThis.__veraSsrShimmed,i=o=>{const n=o?.ownerDocument?.defaultView;return null!=n&&!n.closed},l=(l,c)=>{if(e)return;let f,s,u;if("function"==typeof l){const n=o(l);s=i(n)?n:document.createDocumentFragment()}else s=l;const d=t,v=()=>void 0!==f&&null!==f.$s.parentNode&&f.$s.parentNode===f.$e.parentNode&&i(f.$s.parentNode),p=(o,n,t)=>{const r=n.ownerDocument;f=new o[3](r.createComment(""),r.createComment("")),n.append(f.$s,f.$e),o[9](n,f,t)},y=n((o=>{const n=d.$H;if(void 0===n||1!==n[0])return void(r||(r=!0,console.warn("[vera] portal-no-renderer")));const t=u="function"==typeof c?c(o):c;v()?n[9](s,f,t):p(n,s,t),d.$so?.(y)}),{priority:50});n((()=>()=>{void 0!==f&&(v()&&d.$H[9](s,f,null),f.$s.remove(),f.$e.remove(),f=void 0)}),{priority:50}),"function"==typeof l&&n((()=>{const o=l();if(!i(o)||o===s)return;const n=s;if(s=o,void 0===f)return;if(!v())return p(d.$H,o,u);const t=[];for(let o=f.$s;null!==o&&(t.push(o),o!==f.$e);o=o.nextSibling);const r=o.moveBefore;if(void 0!==r&&n.isConnected&&o.isConnected&&f.$s.getRootNode()===o.getRootNode())for(const n of t)r.call(o,n,null);else o.append(...t)}))};export{l as portal};
|
|
2
|
+
//# sourceMappingURL=vera-renderer-portal.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vera-renderer-portal.min.js","sources":["../src/portal.ts","../src/kinds.ts"],"sourcesContent":["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","/**\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"],"names":["printedPortal","onServer","globalThis","__veraSsrShimmed","usable","t","view","ownerDocument","defaultView","closed","portal","target","template","part","current","last","first","untrack","document","createDocumentFragment","registry","inserts","intact","undefined","$s","parentNode","$e","fresh","handoff","into","value","doc","createComment","append","hook","effect","change","$H","console","warn","$so","priority","remove","next","from","nodes","n","push","nextSibling","move","moveBefore","isConnected","getRootNode","call"],"mappings":"gEAOA,IAAIA,GAAgB,EAepB,MAAMC,GAA+E,IAAnEC,WAA8CC,iBAiC1DC,EAAUC,IACd,MAAMC,EAAOD,GAAGE,eAAeC,YAC/B,OAAe,MAARF,IAAiBA,EAAKG,MAAM,EAExBC,EAAS,CAACC,EAAoDC,KACzE,GAAIX,EAAU,OACd,IAAIY,EAEAC,EAOAC,EANJ,GAAsB,mBAAXJ,EAAuB,CAChC,MAAMK,EAAQC,EAAQN,GAEtBG,EAAUV,EAAOY,GAASA,EAAQE,SAASC,wBAC7C,MAAOL,EAAUH,EAGjB,MAAMS,EAAWC,EAQXC,EAAS,SAAeC,IAATV,GAA8C,OAAxBA,EAAKW,GAAIC,YAAuBZ,EAAKW,GAAIC,aAAeZ,EAAKa,GAAID,YAAcrB,EAAOS,EAAKW,GAAIC,YAEpIE,EAAQ,CAACC,EAAoBC,EAAcC,KAC/C,MAAMC,EAAMF,EAAKtB,cACjBM,EAAO,IAAKe,ECtBkB,GDsBmBG,EAAIC,cAAc,IAAKD,EAAIC,cAAc,KAC1FH,EAAKI,OAAOpB,EAAKW,GAAKX,EAAKa,IAC1BE,ECl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:!0,attributeFilter:["slot"]},s=n=>3===n.nodeType?"":1===n.nodeType?n.getAttribute("slot")??"":null,r=(n,t)=>{let o=n.t.get(t);return void 0===o&&n.t.set(t,o=[]),o},f=(n,t,l=!1,f=!1)=>{const i=s(t);if(null===i)return null;const c=r(n,i),u=a(n,i),d=void 0!==u&&t.parentNode===u.o.parentNode,v=t._$own$;let _=c.length,b=!1;if(l);else if(d){for(let n=0;n<c.length;n++)if(4&t.compareDocumentPosition(c[n])){_=n;break}}else if(void 0!==v){for(let n=c.length-1;n>=0;n--)if(c[n]._$own$===v){_=n+1;break}}else{const o=t.parentNode,l=c[c.length-1],s=n.l;if(b=!f&&s.parentNode===o&&!!(4&t.compareDocumentPosition(s)),!f&&s.parentNode===o&&4&t.compareDocumentPosition(s)&&void 0!==l&&!(l.parentNode===o&&4&l.compareDocumentPosition(t))){let n=!1;for(let o=t.nextSibling;null!==o&&o!==s;o=o.nextSibling){const t=8===o.nodeType?e.get(o):void 0;if(void 0!==t){const o=c.indexOf(t);if(-1!==o){_=o,b=!1,n=!0;break}}}if(!n)for(let o=t.previousSibling;null!==o;o=o.previousSibling){const t=8===o.nodeType?e.get(o):void 0;if(void 0!==t){const o=c.indexOf(t);if(-1!==o){_=o+1,b=!1,n=!0;break}}}if(!n)for(let n=0;n<c.length;n++){const e=c[n];if(e.parentNode!==o||4&t.compareDocumentPosition(e)){_=n;break}}}}if(!n.i.has(t)){const o=_>0?n.i.get(c[_-1]):void 0,e=_<c.length?n.i.get(c[_]):void 0;n.i.set(t,b?--n.u:void 0===e?n.v++:void 0===o?e-1:(o+e)/2)}return c.splice(_,0,t),n._.set(t,i),o.set(t,n.l),d||n.p.appendChild(t),i},i=(n,t,o)=>{const e=n.t.get(o);if(void 0===e)return;const l=e.indexOf(t);-1!==l&&e.splice(l,1)},c=n=>{n.k.takeRecords()},u=n=>{if(n.m)return;const t=n.k.takeRecords();if(0!==t.length){n.m=!0;try{w(n.M,n,t)}finally{n.m=!1}}},a=(n,t)=>{const o=n.h;for(let n=0;n<o.length;n++)if(o[n].W===t)return o[n]},d=[],v=(n,t)=>{const o=t.$;void 0===o||t.S||(t.S=!0,queueMicrotask((()=>{t.S=!1,o.dispatchEvent(new n.q("slotchange",{bubbles:!0,composed:!1}))})))},_=(n,t)=>{u(n);const o=t.o.parentNode;if(null===o)return;const e=new Map;let l=t.o.nextSibling;for(;null!==l&&l!==t.j;){const o=l.nextSibling;e.set(l,e.size),t.F?n.p.appendChild(l):t.N.appendChild(l),l=o}const s=a(n,t.W)===t?r(n,t.W):d;if(e.size>0&&s!==d){const n=new Map;let t=-1;for(const o of s){const l=e.get(o);void 0!==l&&(t=l),n.set(o,l??t+.5)}s.sort(((t,o)=>n.get(t)-n.get(o)))}const f=[];for(let e=0;e<s.length;e++){const l=s[e],r=l.parentNode;r===n.p||null===r||r===o||n.O.has(r)||m(n,l)?(o.insertBefore(l,t.j),f.push(l)):(s.splice(e--,1),n._.delete(l))}t.F=f.length>0,0===f.length&&o.insertBefore(t.N,t.j),((n,t)=>{if(n.length!==t.length)return!1;for(let o=0;o<n.length;o++)if(n[o]!==t[o])return!1;return!0})(t.T,f)||(t.T=f,v(n,t))},b=(n,t)=>{const o=a(n,t);void 0!==o&&_(n,o)},p=(n,t)=>{n.h.push(t);const o=t.$;return void 0!==o&&(n.L.set(o,t),k(n,t),n.k.observe(o,{attributes:!0,attributeFilter:["name"]})),{_$park$:()=>{if(u(n),t.F){let o=t.o.nextSibling;for(;null!==o&&o!==t.j;){const t=o.nextSibling;n.p.appendChild(o),o=t}}const o=a(n,t.W)===t,e=n.h.indexOf(t);-1!==e&&n.h.splice(e,1),o&&b(n,t.W),c(n)}}},k=(n,t)=>{const o=t.$,e=o=>{const e=a(n,t.W)===t?n.t.get(t.W)??d:d;if(e.length>0)return[...e];if(!0!==o)return[];const l=[];for(let n=t.o.nextSibling;null!==n&&n!==t.j;n=n.nextSibling)l.push(n);return l.filter((n=>null!==s(n)))};o.assignedNodes=n=>e(n?.flatten),o.assignedElements=n=>e(n?.flatten).filter((n=>1===n.nodeType))},m=(new Set,(n,t)=>{for(const o of n.h){const n=o.o.parentNode;if(null!==n&&n===t.parentNode&&4&o.o.compareDocumentPosition(t)&&4&t.compareDocumentPosition(o.j))return!0}return!1}),w=(n,t,o)=>{const e=new Set,l=[];for(const c of o)if("attributes"!==c.type){for(const o of c.addedNodes)if(c.target!==n&&o.parentNode!==n||!0===o._$own$||t._.has(o)){if(!t._.has(o)&&!0!==o._$own$)for(const n of t.h)if(n.F&&n.o.parentNode===c.target&&4&n.o.compareDocumentPosition(o)&&4&o.compareDocumentPosition(n.j)&&s(o)===n.W){f(t,o),e.add(n.W);break}}else{const n=f(t,o,!1,null===c.nextSibling);null!==n&&e.add(n)}for(const o of c.removedNodes){const l=t._.get(o);void 0===l||o.parentNode===t.p||n.contains(o)||m(t,o)||(i(t,o,l),t._.delete(o),e.add(l))}}else{const n=c.target,o=t.L.get(n);if(void 0!==o){const t=n.getAttribute("name")??"";t!==o.W&&(e.add(o.W),o.W=t,e.add(t),l.push(o));continue}const f=t._.get(n);if(void 0!==f){const o=s(n);if(o!==f){i(t,n,f);const l=r(t,o),s=t.i.get(n);let c=l.length;for(let n=0;n<l.length;n++){const o=t.i.get(l[n]);if(void 0!==o&&o>s){c=n;break}}l.splice(c,0,n),t._.set(n,o),e.add(f),e.add(o)}}}for(const n of e)b(t,n);for(const n of l)_(t,n)},M=(o,s=!1,r)=>{let i=n.get(o);if(void 0!==i)return i;const u=o.ownerDocument,a=i={M:o,m:!1,t:new Map,h:[],p:u.createDocumentFragment(),O:new WeakSet,i:new WeakMap,v:0,u:0,_:new WeakMap,L:new WeakMap,q:u.defaultView?.Event??Event,k:new MutationObserver((t=>((t,o)=>{const e=n.get(t);w(t,e,o),c(e)})(o,t))),l:r??u.createComment("")};n.set(o,a),Object.defineProperty(o,"_$hosted$",t),void 0===r&&o.appendChild(a.l);for(const n of[...o.children])if("template"===n.localName&&n.hasAttribute($)){const t=n.content;for(const n of[...t.childNodes])f(a,n,!0);o.removeChild(n)}if(!s){let n=null;for(const t of[...o.childNodes])if(8===t.nodeType)(n??=[]).push(t);else if(null!==f(a,t,!0)&&null!==n){for(const o of n)e.set(o,t);n=null}}return a.k.observe(o,l),a.k.observe(a.p,l),a},g=(n,t,o)=>{if(globalThis.__veraSsrShimmed)return null;if(1!==t.nodeType)return null;if(null===n.parentNode)return null;const e=[],s=M(t),r=n.ownerDocument,f=n.parentNode,i=r.createComment(""),u=r.createComment("");f.insertBefore(i,n),f.insertBefore(u,n);const a=[...n.querySelectorAll("slot")].reverse();for(const n of a){const o=g(n,t,n.getAttribute("name")??"");null!==o&&e.push(o)}const d=r.createDocumentFragment();for(s.O.add(d),s.k.observe(d,l);null!==n.firstChild;)d.appendChild(n.firstChild);f.removeChild(n);const v={o:i,j:u,W:o,N:d,F:!1,$:n,T:[],S:!1},b=p(s,v);if(_(s,v),c(s),e.length>0){const n=b._$park$,t=e;b._$park$=()=>{for(const n of t)n._$park$();n()}}return b},h=(t,o="")=>{const e=n.get(t);if(void 0!==e)return(n=>{if(void 0===n||n.length<2)return void 0===n?[]:[...n];const t=n[0].parentNode;let o=null!==t;for(let e=1;o&&e<n.length;e++)n[e].parentNode!==t&&(o=!1);if(!o)return[...n].sort(((n,t)=>n===t?0:4&n.compareDocumentPosition(t)?-1:1));const e=new Set(n),l=[];for(let n=t.firstChild;null!==n;n=n.nextSibling)e.has(n)&&l.push(n);return l})(e.t.get(o));const l=t._root??t.shadowRoot;if(null!=l)for(const n of l.querySelectorAll("slot"))if((n.getAttribute("name")??"")===o)return n.assignedNodes();return[]},W="data-vm-slotted",$="data-vm-unassigned";g._$capture$=(t,o)=>{globalThis.__veraSsrShimmed||(M(t,!1,o),c(n.get(t)))},g._$home$=n=>{const t=o.get(n);return void 0!==t&&null!==t.parentNode?t:null},g._$server$=(n,t)=>{const o=new Map;for(const n of t){const t=s(n);if(null===t)continue;let e=o.get(t);void 0===e&&o.set(t,e=[]),e.push(n),null!==n.parentNode&&n.parentNode.removeChild(n)}const e=new Set,l=[],r=[...n.querySelectorAll("slot")];for(const n of r){const t=n.parentNode;if(null===t)continue;const s=n.getAttribute("name")??"",r=e.has(s)?void 0:o.get(s);if(void 0!==r&&r.length>0){e.add(s);for(const o of r)t.insertBefore(o,n);""===s&&l.push({parent:t,first:r[0],last:r[r.length-1],count:r.length})}else{let o=n.firstChild;for(;null!==o;){const e=o.nextSibling;t.insertBefore(o,n),o=e}}t.removeChild(n)}for(const{first:t,last:o}of l){const e=n.ownerDocument,l=t.previousSibling;null!==l&&3===l.nodeType&&3===t.nodeType&&t.parentNode.insertBefore(e.createComment(""),t);const s=o.nextSibling;null!==s&&3===s.nodeType&&3===o.nodeType&&o.parentNode.insertBefore(e.createComment(""),s)}let f=null;for(const[t,l]of o)if(!e.has(t)&&0!==l.length){null===f&&(f=n.ownerDocument.createElement("template"),f.setAttribute($,""));for(const n of l)f.appendChild(n)}null!==f&&n.appendChild(f);for(const{parent:n,first:t,count:o}of l){let e=0;for(let o=n.firstChild;null!==o&&o!==t;o=o.nextSibling)e++;n.setAttribute(W,`${e},${o}`)}},g._$adopt$=(n,t,o,e,s,f,i)=>{const u=M(n,!0),a=n.ownerDocument,d=a.createComment(""),_=a.createComment("");s.insertBefore(d,(o&&o.length>0?o[0]:e[0])??f??f),s.insertBefore(_,f);const b=null!==o&&o.length>0,k=a.createDocumentFragment();if(u.O.add(k),u.k.observe(k,l),b)for(const n of e)k.appendChild(n);if(b)for(const n of o)r(u,t).push(n),u._.set(n,t),u.i.set(n,u.v++);const m={o:d,j:_,W:t,N:k,F:b,$:i,T:[],S:!1},w=p(u,m);return b&&(m.T=o.slice(),v(u,m)),c(u),w},g._$rescue$=n=>{const t=[],o=n=>{const e=n.getAttribute(W);let l=-1,s=-1;if(null!==e){const n=e.indexOf(",");l=Number(e.slice(0,n)),s=l+Number(e.slice(n+1))}let r=0;for(let e=n.firstChild;null!==e;e=e.nextSibling,r++){if(r>=l&&r<s){t.push(e);continue}if(1!==e.nodeType)continue;const n=e;if("template"===n.localName&&n.hasAttribute($))for(let o=n.content.firstChild;null!==o;o=o.nextSibling)t.push(o);else n.hasAttribute("slot")?t.push(n):-1===n.localName.indexOf("-")&&o(n)}};o(n);for(const n of t)n.parentNode?.removeChild(n);return t.length>0?t:null};const S={name:"@verajs/renderer/slots",on:"slot",fn:g,priority:50};export{S as slots,h as slotted};
|
|
1
|
+
const o=new Set(["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"]),n=n=>n.includes("-")&&!o.has(n.toLowerCase());let t=null;const e=(o,n,e)=>((o,n,t,e)=>{if(o?.length)for(const e of o)e(n,t);else((o,n)=>{"function"!=typeof reportError?console.error(n,o):reportError(o)})(n,e)})(t?.get("error"),o,(o=>null==o?void 0:11===o.nodeType?o.host:o)(n),e),l=o=>1===o.nodeType?o:o.firstElementChild,r=(o,n)=>{if(null!==o.firstElementChild)return o.firstElementChild;for(let t=o;null!==t&&t!==n;t=t.parentElement)if(null!==t.nextElementSibling)return t.nextElementSibling;return null},i=[o=>{t=o},{name:"@verajs/renderer/elements",on:"template",fn:(o,n,i,s)=>{const f=t?.get("element");if(void 0===f||0===f.length)return;const c=o,u=[],d=[];let a=0;for(let o=l(s);null!==o;o=r(o,s),a++)for(let n=0;n<f.length;n++){const t=f[n](o);void 0!==t&&(u.push(a),d.push(t))}u.length>0&&(c._$inst$=((o,n)=>({$c:(t,i,s)=>{const f=[],c=Array.isArray(t);let u=c?null:l(t),d=0;for(let l=0;l<o.length;l++){if(c)u=t[o[l]];else for(;d<o[l];d++)u=r(u,t);try{n[l].create?.(u,s)}catch(o){e(o,i,"[vera] claim-threw");continue}f.push(u,n[l])}return{f:f,r:i,a:s,k:void 0,d:!1}},$m:o=>{const n=o;if(n.d)return;const t=n.f,l={root:n.r,adopted:n.a};n.f=null;for(let o=0;o<t.length;o+=2){const r=t[o+1];let i;try{i=r.mount?.(t[o],l)}catch(o){e(o,n.r,"[vera] claim-threw");continue}void 0!==i&&void 0!==r.unmount&&(n.k??=[]).push(t[o],r,i)}},$q:o=>{const n=o;n.d=!0;const t=n.k;if(void 0!==t)for(let o=0;o<t.length;o+=3)try{t[o+1].unmount(t[o+2],t[o])}catch(o){e(o,n.r,"[vera] claim-threw")}}}))(u,d))},priority:10}],s=o=>3===o.nodeType?"":1===o.nodeType?o.getAttribute("slot")??"":null,f=o=>{const n=ko(o);return n.parentNode!==o.host&&o.host.insertBefore(n,o.host.firstChild),wo(o),n},c=Symbol(),u=o=>o[c],d=o=>void 0!==o[c],a=new WeakMap,v=new WeakMap,h=new WeakMap,m=new WeakMap,w={},p=o=>{const n=[];for(const t of o.units)if(t.a===t.z)n.push(t.a);else for(let o=t.a.nextSibling;null!==o&&o!==t.z;o=o.nextSibling)n.push(h.get(o)??o);return n},b=o=>{const n=v.get(o);void 0!==n&&(v.delete(o),h.delete(n),n.remove())},y=o=>o.$rec?.rs??o,g=o=>o.$rec?.re??o,k=(o,n,t)=>{const e=g(n);for(let l=y(n);null!==l;){const n=l===e?null:l.nextSibling;o.insertBefore(l,t),l=n}},S=(o,n,t)=>{const e=o.ownerDocument.createComment("");n.insertBefore(e,t),v.set(o,e),h.set(e,o)},M=(o,n)=>{const t=v.get(n);void 0!==t?(k(f(o),n,t),b(n),m.delete(n)):(k(f(o),n,o.holding.lastChild),m.set(n,null))},W=o=>{const n=[];let t=o.rs??o.slot;for(;;){if(n.unshift(t),o.light.host.contains(t))return n;let e=t;for(;null!==e.parentNode;)e=e.parentNode;const l=e.$rec;if(void 0===l||null===l.rs)return null;t=l.rs}},j=(o,n)=>!!(4&o.compareDocumentPosition(n)),q=o=>{if(null!==o.rs)return;const n=o.slot.ownerDocument,t=o.slot.parentNode;o.rs=n.createComment("["),o.re=n.createComment("]"),t.insertBefore(o.rs,o.slot),t.insertBefore(o.re,o.slot),t.removeChild(o.slot),ro(t,o.light)},z=o=>{null!==o.rs&&(o.rs.parentNode?.insertBefore(o.slot,o.rs),o.rs.remove(),o.re.remove(),o.rs=o.re=null)},L=o=>{for(const n of p(o.light))m.get(n)===o&&M(o.light,n);z(o)},E=o=>o.light.recs.splice(o.light.recs.indexOf(o),1),x=o=>{o.queued||(o.queued=!0,queueMicrotask((()=>{o.queued=!1,o.slot.dispatchEvent(new o.slot.ownerDocument.defaultView.Event("slotchange",{bubbles:!0,composed:!1}))})))},F=(o,n)=>{if(m.get(o)===w)return!0;const t=o.parentNode;if(null===t)return!1;if(t===n.holding)return!0;for(const o of n.recs)if(null!==o.re&&o.re.parentNode===t)return!0;return!1};let $=!1;const N=o=>{if($)eo(o);else{$=!0;try{do{O(o)}while(o.dirty)}finally{$=!1}}},O=o=>{o.dirty=!1;const n=o.fresh;G&&(o.fresh=!1);const t=o.host,e=e=>y(e).parentNode===o.holding||n&&y(e).parentNode===t;o.units=o.units.filter((l=>l.a===l.z?((o,n)=>{const t=m.get(o);if(t===w)return!0;const e=y(o).parentNode;return null==t?e===n.holding:t.light===n&&null!==e&&e===t.re?.parentNode})(l.a,o)||n&&y(l.a).parentNode===t:e(l.a)&&e(l.z)));for(const n of o.units)if(n.a!==n.z)for(let t=n.a.nextSibling;null!==t&&t!==n.z;t=t.nextSibling){const n=h.get(t);void 0===n||F(n,o)||(m.delete(n),b(n))}const l=[],r=new Set;for(const n of o.recs){const o=W(n);null!==o?l.push({rec:n,at:o}):r.add(n)}l.sort(((o,n)=>((o,n)=>{for(let t=0;t<o.length&&t<n.length;t++)if(o[t]!==n[t])return j(o[t],n[t]);return o.length<n.length})(o.at,n.at)?-1:1));const i=new Map;for(const{rec:o}of l){const n=o.slot.getAttribute("name")??"";i.has(n)||i.set(n,o)}const c=p(o),u=new Set;for(const n of o.units)n.a===n.z&&u.add(n.a);const d=new Map,a=new Set;for(const o of c){const n=s(o),t=null===n?void 0:i.get(n);if(void 0===t)continue;let e=d.get(t);void 0===e&&d.set(t,e=[]),e.push(o),a.add(o)}for(const{rec:o}of l){const n=d.get(o)??[];if(n.length>0){q(o);const t=o.re.parentNode;let l=o.rs;for(const r of n){const n=y(r);n.parentNode!==t||n.previousSibling!==l?(u.has(r)||!e(r)||v.has(r)||S(r,n.parentNode,n),k(t,r,l.nextSibling),r._$slotted$=!0,m.set(r,o),l=g(r)):l=g(r)}}(n.length!==o.shown.length||n.some(((n,t)=>n!==o.shown[t])))&&(o.shown=n,x(o))}for(const n of c){if(a.has(n))continue;const e=m.get(n);null!=e&&r.has(e)||(e!==w||G)&&(v.has(n)||null!=e||G&&u.has(n)&&n.parentNode===t)&&M(o,n)}if(n&&G)for(const n of o.units)if(n.a!==n.z&&n.a.parentNode===t){const t=[];for(let o=n.a;null!==o&&(t.push(o),o!==n.z);o=o.nextSibling);const e=ko(o);for(const n of t)(8===n.nodeType?e:f(o)).insertBefore(n,e.lastChild);wo(o)}for(const{rec:o}of l)d.has(o)||z(o);(o=>{const n=o.holding;if(void 0!==n){for(let t=n.firstChild;null!==t;t=t.nextSibling)if(8!==t.nodeType)return void f(o);n.remove()}})(o)},T=o=>{const n=globalThis.MutationObserver??o.host.ownerDocument.defaultView.MutationObserver;return o.obs??=new n((n=>{oo(o,n),lo()}))};let A;const R=new WeakMap,B=o=>{no(o),lo()},C=(o,n=!0)=>void 0===o.obs||!n&&!0!==o.ho&&!0!==o.cw?[]:o.obs.takeRecords(),D=o=>{if(void 0!==o.obs&&(!0===o.ho||!0===o.cw))for(const n of o.obs.takeRecords())"attributes"===n.type&&(eo(n.target.$rec?.light??o),queueMicrotask(lo))};let G=!1,H=new WeakMap;const I=(o,n)=>n===o.holding||n===o.host&&!0===o.hw||n.$rec?.light===o||o.recs.some((o=>null!==o.re&&o.re.parentNode===n)),J=o=>{let n=o;for(;;){const o=n.$rec,t=void 0!==o&&null!==o.rs&&o.slot===n?o.rs:n.parentNode;if(null===t)return n;n=t}},K=(o,n)=>{for(let t=o;null!==t;){if(t===n)return!0;const o=t.$rec;t=void 0!==o&&null!==o.rs&&o.slot===t?o.rs:t.parentNode}return!1},P=o=>{E(o),L(o),eo(o.light)};function Q(){const o=this.$rec;void 0!==o&&null!==o.rs&&L(o),this.ownerDocument.defaultView.Element.prototype.remove.call(this)}function U(...o){const n=this.$rec;void 0!==n&&null!==n.rs&&L(n),this.ownerDocument.defaultView.Element.prototype.replaceWith.apply(this,o)}let V=[],X=!1;const Y=(o,n)=>{if(1!==n.nodeType)return;const t=n;if("slot"===t.localName)return void(void 0===t.$rec&&V.push([t,o]));if(null===t.firstElementChild)return;const e=t.getElementsByTagName("slot");for(let n=0;n<e.length;n++)void 0===e[n].$rec&&V.push([e[n],o])},Z=(o,n)=>{for(let t=o.parentNode;null!==t;t=t.parentNode){if(t===n.host)return!0;if(t===n.holding||m.has(t))return!1}return!1},_=()=>{X=!1;const o=V;V=[];for(const[n,t]of o)void 0===n.$rec&&u(t.host)===t&&Z(n,t)&&Eo.mount(n,{root:t.host})},oo=(o,n)=>{!0===o.ex&&((o,n)=>{for(const t of n){if("childList"!==t.type)continue;const n=t.addedNodes;for(let t=0,e=n.length;t<e;t++)Y(o,n[t])}})(o,n),H=new WeakMap;let t=!1;for(const e of n){const n=e.target;if(e.removedNodes.length>0&&(t=!0),"attributes"!==e.type){if((n===o.host?!0===o.hw:I(o,n))&&(eo(o),ho(o,e)),n===o.host){o.fresh&&vo(o,e);for(const n of e.addedNodes)co(o,n)}}else{const t=n.$rec;if(void 0!==t){eo(t.light);continue}(F(n,o)||n.parentNode===o.host)&&eo(o)}}if(t)for(let n=o.recs.length-1;n>=0;n--){const t=o.recs[n],e=t.rs??t.slot;K(e,o.host)||R.has(J(e))||P(t)}},no=o=>{for(const n of o)if("childList"!==n.type)for(let o=n.target;null!==o;o=o.parentNode){const n=o.$rec??m.get(o);if(n){eo(n.light);break}const t=u(o);if(void 0!==t){eo(t);break}}else{let o=n.target;for(;null!==o.parentNode;)o=o.parentNode;const t=R.get(o),e=void 0===t?void 0:u(t);void 0!==e&&!e.host.contains(n.target)&&I(e,n.target)&&(eo(e),ho(e,n))}},to=new Set,eo=o=>{o.dirty=!0,o.wait||to.add(o)},lo=(o,n)=>{if($)return;const t=[];void 0!==o&&t.push(o);const e=void 0===n?void 0:qo.get(n);if(void 0!==e){const o=[],l=n.isConnected;for(let n=0;n<e.length;n++){const r=e[n].deref();if(void 0===r)continue;if(!r.isConnected&&l)continue;o.push(e[n]);const i=u(r);void 0!==i&&t.push(i)}qo.set(n,o)}for(const o of t)oo(o,C(o));for(const o of to)oo(o,C(o,!1));void 0!==A&&no(A.takeRecords());for(const o of to)(o.dirty||G&&o.fresh)&&(N(o),D(o)),o.dirty||o.fresh&&o.host.isConnected||to.delete(o);for(const o of t)D(o);V.length>0&&!X&&(X=!0,queueMicrotask(_))},ro=(o,n)=>{if(o===n.host)return void(n.hw=!0);const t=T(n);void 0===o.$rec?(o===n.holding||((o,n)=>{for(let t=o;t!==n;t=t.parentNode)if(null===t||void 0!==t.$rec)return!0;return!1})(o,n.host))&&(n.cw=!0,t.observe(o,{childList:!0})):t.observe(o,{attributes:!0,attributeFilter:so(o)?["slot","name"]:["name"]})},io=Symbol(),so=o=>!0===o[io],fo=(o,n)=>{1===n.nodeType&&!0===o.ho&&(n[io]=!0,T(o).observe(n,{attributes:!0,attributeFilter:void 0!==n.$rec?["slot","name"]:["slot"]}))},co=(o,n)=>{if(8===n.nodeType||n.parentNode!==o.host||n===o.holding)return;const t=new Set;for(const n of o.units)t.add(n.a).add(n.z);if(t.has(n))return;let e=null,l=null;for(const n of o.host.childNodes)8!==n.nodeType||t.has(n)||(e??=n,l=n);if(null!==e&&e!==l&&j(e,n)&&j(n,l))return;const r=null!==e&&j(n,e);if(f(o).insertBefore(n,o.holding.lastChild),m.set(n,null),fo(o,n),r){const t=H.get(o)??0;o.units.splice(t,0,{a:n,z:n}),H.set(o,t+1)}else o.units.push({a:n,z:n});eo(o)},uo=(o,n)=>{const t=v.get(n);return o.units.findIndex(void 0===t?o=>o.a===n:o=>o.a!==o.z&&j(o.a,t)&&j(t,o.z))},ao=(o,n)=>{const t=n.parentNode;if(null!==t&&8!==n.nodeType)for(const e of o.recs){if(null===e.re||e.re.parentNode!==t)continue;if(!j(e.rs,n)||!j(n,e.re))continue;let l=-1;for(let t=n.nextSibling;null!==t&&t!==e.re&&l<0;t=t.nextSibling)l=uo(o,t);return l<0?o.units.push({a:n,z:n}):o.units.splice(l,0,{a:n,z:n}),m.set(n,e),void fo(o,n)}},vo=(o,n)=>{const t=o.holding;for(const o of n.removedNodes){const n=h.get(o);if(void 0!==n){const e=o.parentNode;if(e===t||null!==e&&11!==e.nodeType)continue;null===e?n.parentNode?.removeChild(n):e.insertBefore(n,o),m.delete(n),b(n)}else v.has(o)&&null===o.parentNode&&(m.delete(o),b(o))}},ho=(o,n)=>{const t=ko(o);vo(o,n);for(const e of n.addedNodes){if(e.parentNode!==n.target)continue;if(n.target===t){v.has(e)&&(m.delete(e),b(e)),fo(o,e);continue}if(void 0!==m.get(e)&&!v.has(e))continue;const l=n.nextSibling,r=n.previousSibling,i=n=>n.parentNode===t||o.fresh&&n.parentNode===o.host,s=null===l?void 0:v.get(l)??(i(l)?l:void 0),c=null===r?void 0:v.get(r)??(i(r)?r:void 0);if(void 0===s&&void 0===c){ao(o,e);continue}const u=s??c.nextSibling,d=v.get(e),a=null===u?t:u.parentNode;(a===t&&void 0===d?f(o):a).insertBefore(d??e,u),fo(o,e)}},mo=o=>{if(!0!==o.ho){o.ho=!0,T(o).observe(o.host,{childList:!0,subtree:!0});for(const n of p(o))fo(o,n);(void 0!==Ro?._$hydrateSlots$||o.units.some((o=>o.a!==o.z))||(o.holding?.childNodes.length??0)>2)&&wo(o)}},wo=o=>{!0===o.ho&&!0!==o.hh&&(o.hh=!0,ro(ko(o),o))},po=o=>{for(const n of o.recs)for(const o of[...n.shown]){const n=v.get(o);if(void 0===n)continue;if(null===o.parentNode){m.delete(o),b(o);continue}const t=n.parentNode;if(null===t)o.parentNode.removeChild(o);else{if(11!==t.nodeType)continue;t.insertBefore(o,n)}m.delete(o),b(o)}for(const n of o.recs)if(null!==n.rs&&null!==n.re)for(let t=n.rs.nextSibling;null!==t&&t!==n.re;){const e=t.nextSibling;m.has(t)||8===t.nodeType||ho(o,{target:n.re.parentNode,addedNodes:[t],removedNodes:[],previousSibling:t.previousSibling,nextSibling:t.nextSibling}),t=e}const n=o.host,t=new Set;for(const n of o.units)t.add(n.a).add(n.z);let e=null,l=null;for(let o=n.firstChild;null!==o;o=o.nextSibling)8!==o.nodeType||t.has(o)||(e??=o,l=o);const r=null!==e&&e!==l;for(const i of[...n.childNodes])8===i.nodeType||i===o.holding||t.has(i)||m.has(i)||r&&j(e,i)&&j(i,l)||o.units.some((o=>o.a!==o.z&&j(o.a,i)&&j(i,o.z)))||co(o,i)},bo=Symbol(),yo=o=>{if(!0!==o[bo]){o[bo]=!0;for(const n of[o.Element?.prototype,o.Text?.prototype]){const o=void 0===n?void 0:Object.getOwnPropertyDescriptor(n,"assignedSlot"),t=o?.get;void 0!==t&&Object.defineProperty(n,"assignedSlot",{configurable:!0,enumerable:o.enumerable,get(){const o=m.get(this);return null!=o&&o!==w?o.slot:t.call(this)}})}}},go=o=>{const n=o.ownerDocument;return o.setAttribute("hidden",""),o.setAttribute("data-vm-unassigned",""),o.style.setProperty("display","none","important"),o.insertBefore(n.createComment(""),o.firstChild),o.append(n.createComment("")),o},ko=o=>o.holding??=go(o.host.ownerDocument.createElement("ins")),So={get:o=>{const n=u(o);return void 0!==n&&ko(n),n},has:o=>d(o)},Mo=(...o)=>{const n=jo(...o);return ko(n),n},Wo=(o,n,t=null)=>{const e=o.ownerDocument.defaultView;null!==e&&yo(e),$o();const l={host:o,units:[],holding:null===t?void 0:go(t),recs:[],dirty:!1,fresh:!1,late:n,wait:!1};return((o,n)=>{o[c]=n})(o,l),l},jo=(o,n=null,t=[...o.childNodes],e=null,l=!1)=>{let r=u(o);if(void 0!==r&&!r.late)return r;const i=o.ownerDocument;r??=Wo(o,!1,e),r.late=!1;const s=a.get(o);let f=null;const c=()=>{if(null===f)return;const n=i.createComment(""),t=i.createComment("");o.insertBefore(n,f[0]),o.insertBefore(t,f[f.length-1].nextSibling),r.units.push({a:n,z:t}),f=null};for(const e of t){if(e===n)break;const t=e.parentNode;t!==o&&m.set(e,t===r.holding?null:w),fo(r,e),void 0===s||s.has(e)?(c(),r.units.push({a:e,z:e})):(f??=[]).push(e)}return c(),l?r.wait=!0:(r.fresh=!0,eo(r)),r},qo=new WeakMap,zo={mount:(o,{root:n})=>{if(null===n)return;let t=qo.get(n);void 0===t&&($o(),qo.set(n,t=[])),t.push(new WeakRef(o))},create:(o,n)=>{if(n)return;const t=new Set;let e=!1;for(const n of[...o.childNodes]){const l=3===n.nodeType&&""===n.data;if(l&&e){const e=o.ownerDocument.createComment("");o.insertBefore(e,n),t.add(e)}l||t.add(n),e=l}a.set(o,t)}},Lo=(o,n,t=!1)=>{lo(o.light);const e=o.shown.filter((o=>!n||1===o.nodeType));if(o.shown.length>0||!t)return e;for(const t of o.slot.childNodes){const o=t.$rec;if(void 0!==o)e.push(...Lo(o,n,!0));else{if(1===t.nodeType&&"slot"===t.localName)continue;(1===t.nodeType||!n&&3===t.nodeType)&&e.push(t)}}return e},Eo={mount:(o,t)=>{const e=t.root;if(null!==e&&11===e.nodeType){const o=u(e.host);void 0!==o&&0===o.recs.length&&(o=>{for(const n of o.units)if(n.a!==n.z)for(let t=n.a.nextSibling;null!==t&&t!==n.z;){const n=t.nextSibling;o.host.appendChild(h.get(t)??t),t=n}else k(o.host,n.a,null);o.holding?.remove(),o.host[c]=void 0,to.delete(o),o.obs?.disconnect(),o.obs=void 0})(o)}if(null===e||1!==e.nodeType)return;lo(u(e));const l=u(e)??Wo(e,n(e.localName)),r=o,i={slot:r,light:l,rs:null,re:null,shown:[],queued:!1};r.$rec=i;const s=r._$region$;if(void 0!==s){r._$region$=void 0,[i.rs,i.re]=s;for(let o=i.rs.nextSibling;o!==i.re;o=o.nextSibling)m.set(o,i),o._$slotted$=!0;ro(i.re.parentNode,l)}return r.assignedNodes=o=>Lo(i,!1,o?.flatten),r.remove=Q,r.replaceWith=U,r.assignedElements=o=>Lo(i,!0,o?.flatten),l.recs.push(i),l.wait=!1,ro(r,l),N(l),D(l),l.fresh||!0===l.ho||queueMicrotask((()=>{!0!==l.ho&&u(l.host)===l&&(po(l),lo(l),mo(l))})),i},unmount:o=>{lo(o.light),E(o),L(o),N(o.light),D(o.light)}};let xo,Fo;const $o=()=>{void 0!==Fo&&Fo._$done$!==xo&&(Fo._$done$=xo)},No=o=>{1===o.nodeType&&n(o.localName)&&$o();const t=1===o.nodeType?o.getAttribute(Ao):null;if(null!==t){if(!t.endsWith(":"))throw new Error("[vera] hydration-unwired");for(let n=o.firstChild;null!==n;){const t=n.nextSibling;1===n.nodeType&&n.hasAttribute("data-vm-sheet")||o.removeChild(n),n=t}o.removeAttribute(Ao)}},Oo=o=>{const n=u(o);return void 0===n?null:(lo(n),p(n))},To=(o,n="")=>{const t=u(o);if(void 0!==t){lo(t);for(const o of t.recs)if((o.slot.getAttribute("name")??"")===n&&o.shown.length>0)return[...o.shown];return p(t).filter((o=>s(o)===n))}const e=o._$r$??o.shadowRoot,l=[...e?.querySelectorAll("slot")??[]].find((o=>(o.getAttribute("name")??"")===n));return void 0===l?[]:l.assignedNodes()},Ao="data-vm-light";let Ro=null;const Bo=[i,{name:"@verajs/renderer/slots-capture",on:"init",fn:(o,t)=>{const e=t?.observeSlots,l="eager"===(void 0!==e?e:Ro?._$observeSlots$);if((null!==o.firstChild||l)&&null==o._$r$&&null===o.shadowRoot&&n(o.localName)&&!d(o)&&(!0!==Ro?._$hydrating$||!o.hasAttribute(Ao))){const n=jo(o);l&&(n.ex=!0)}},priority:10},{name:"@verajs/renderer/slot-discovery",on:"element",fn:o=>"slot"===o.localName?Eo:null!==o.firstChild&&n(o.localName)?zo:void 0,priority:10},o=>{Ro=o,o._$capture$=[1,Mo,Oo,So,S,m,w],o._$unadopted$=No,o._$parked$=(o,n)=>{$o(),null!==n&&R.set(o,n),(A??=new(globalThis.MutationObserver??o.ownerDocument.defaultView.MutationObserver)(B)).observe(o,{attributes:!0,attributeFilter:["slot"],childList:!0,subtree:!0})},Fo=o,xo=(o,t)=>{let e=u(o);if(1===o.nodeType&&(e?.late??o.firstChild!==t)&&null===o.shadowRoot&&n(o.localName)&&(jo(o,t),e=u(o)),void 0===e&&0===to.size&&void 0===A&&void 0===qo.get(o))return;e?.fresh&&!e.wait&&to.add(e);const l=void 0!==e&&e.recs.length>0;void 0!==e&&!0!==e.ho&&(e.fresh||l)&&po(e),G=!0;try{lo(e,o)}finally{G=!1}void 0===e||!0===e.ho||!l&&!0!==e.ex||mo(e)}}],Co=[Bo,{name:"@verajs/renderer/slots",on:"slot",fn:()=>null,priority:50}],Do=()=>{throw new Error("[vera] slots-wire-too-old")},Go=(o,n)=>{if("function"==typeof o?.get)return"function"!=typeof n&&Do(),void n(Co);const t=o,e=t?.observeSlots;return(o,n)=>{"function"!=typeof n&&Do(),n(Co),void 0!==e&&(o._$observeSlots$=e)}};export{Bo as slotDiscovery,Go as slots,To as slotted};
|
|
2
2
|
//# sourceMappingURL=vera-renderer-slots.min.js.map
|