@verajs/renderer 0.3.0 → 0.3.1
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 +52 -6
- package/dist/development/vera-renderer-elements.js.map +1 -1
- package/dist/development/vera-renderer-hydrate-slots.js +1 -1
- package/dist/development/vera-renderer-hydrate-slots.js.map +1 -1
- package/dist/development/vera-renderer-hydration.d.ts.map +1 -1
- package/dist/development/vera-renderer-hydration.js +42 -4
- package/dist/development/vera-renderer-hydration.js.map +1 -1
- package/dist/development/vera-renderer-portal.js +1 -1
- package/dist/development/vera-renderer-portal.js.map +1 -1
- package/dist/development/vera-renderer-profiler.d.ts.map +1 -1
- package/dist/development/vera-renderer-profiler.js +304 -97
- package/dist/development/vera-renderer-profiler.js.map +1 -1
- package/dist/development/vera-renderer-slots.js +1 -1
- package/dist/development/vera-renderer-slots.js.map +1 -1
- package/dist/development/vera-renderer-spread.js.map +1 -1
- package/dist/development/vera-renderer-tag.js.map +1 -1
- package/dist/development/vera-renderer.d.ts.map +1 -1
- package/dist/development/vera-renderer.js +304 -97
- package/dist/development/vera-renderer.js.map +1 -1
- package/dist/vera-renderer-elements.min.js.map +1 -1
- package/dist/vera-renderer-hydrate-slots.min.js +1 -1
- package/dist/vera-renderer-hydrate-slots.min.js.map +1 -1
- package/dist/vera-renderer-hydration.min.js +1 -1
- package/dist/vera-renderer-hydration.min.js.map +1 -1
- package/dist/vera-renderer-portal.min.js +1 -1
- package/dist/vera-renderer-portal.min.js.map +1 -1
- 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.map +1 -1
- package/dist/vera-renderer-tag.min.js.map +1 -1
- package/dist/vera-renderer.min.js +1 -1
- package/dist/vera-renderer.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vera-renderer-spread.min.js","sources":["../../shared-utils/src/adopt-property.ts","../../shared-utils/src/markup-grammar.ts","../../shared-utils/src/utils.ts","../src/spread.ts"],"sourcesContent":["import type { PropertyHost } from './types.js';\nimport { diagnostic } from './diagnostic.js';\nimport * as SHARED from './diagnostics.js';\n\n/**\n * **Delivering a bound property to a custom element that may not receive it yet** — the one home of the\n * rule `@verajs/renderer` (a `.prop` template binding) and `@verajs/renderer/spread` (a `.prop` bag key)\n * both apply. They ship as separate bundles that cannot import each other, so this package, inlined into\n * each, is where the rule lives once; before, each carried a full copy and a fix had to visit both.\n *\n * Returns where the binding stands after this write:\n * - `0` — still adopting: nothing received the value, so it was recorded in the element-carried\n * `_$props$`, which core's `init()` drains over whatever the class's field initializers wrote at\n * upgrade. Call again on the next write.\n * - `1` — received (a setter anywhere on the chain, an initialized component's `_$adopt$`, or an element\n * that is already upgraded): later writes are plain property writes.\n * - `2` — refused: a getter with no setter, where the plain write would throw. Later writes do nothing.\n *\n * `_$props$` and `_$adopt$` are `$`-named because they cross bundle boundaries (renderer, spread, core)\n * and must survive property mangling.\n *\n * **`_$adopt$` is a BRAND, not just a slot:** present means \"core has initialized this component\", which is what routes\n * a delivery to the live accessor (`1`) instead of the `_$props$` record. Do not move it to a class's PROTOTYPE\n * (2026-10-10): every instance would carry it BEFORE `init`, and a delivery to an upgraded-but-uninitialized element\n * would be adopted into a store that does not exist yet. It is ONE shared function written onto each element at `init`,\n * called with the element as `this` (`adopt.call(element, …)`) — 2026-10-11: the closure it replaced was free in\n * optimized code (measured) but cost Chrome's interpreted first render one allocation per component.\n */\n\n/** Development only: getter-only names already reported, per element — a `!name` re-asserts on every render. */\nlet refused: WeakMap<PropertyHost, Set<string>> | undefined;\n\nexport const adoptProperty = (element: PropertyHost, name: string, value: unknown): 0 | 1 | 2 => {\n /**\n * **`__proto__` is refused HERE, at the receiver** (2026-11-10): `element.__proto__ = v` replaces the element's\n * prototype, and an own `__proto__` key reaches a bag through `JSON.parse`. This is the choke point every delivery\n * passes; the renderer's template binding and spread's bag key refuse it first, with a development warning naming\n * where it was written (their second addresses: renderer.ts `proto-binding`, spread.ts refusal 3).\n */\n if (name === '__proto__') return 2;\n const adopt = element._$adopt$ as ((key: string, value: unknown) => void) | undefined;\n /** The walk comes first: what it finds decides whether writing is even legal. */\n for (let carrier: object | null = element; carrier !== null; carrier = Object.getPrototypeOf(carrier)) {\n const desc = Object.getOwnPropertyDescriptor(carrier, name);\n if (desc === undefined) continue;\n if (desc.set !== undefined) {\n element[name] = value;\n return 1;\n }\n if (desc.get !== undefined) {\n if (adopt !== undefined) adopt.call(element, name, value);\n else if (__DEV__) {\n const names = (refused ??= new WeakMap()).get(element) ?? new Set<string>();\n refused.set(element, names);\n if (!names.has(name)) {\n names.add(name);\n console.warn(diagnostic('renderer', `<${element.localName}>`, 'getter-only-prop', __DEV__ && SHARED.getterOnlyProp(name)));\n }\n }\n return 2;\n }\n break; // a data property: an own field, or an inherited default — nothing receives it\n }\n element[name] = value;\n if (adopt !== undefined) {\n adopt.call(element, name, value);\n return 1;\n }\n const record = (element._$props$ ??= {}) as Record<string, unknown>;\n const first = __DEV__ && !Object.hasOwn(record, name);\n record[name] = value;\n /** Upgrade is read off the PROTOTYPE — a bag key named `constructor` can shadow `el.constructor`. The realm is the element's. */\n const view = element.ownerDocument.defaultView as unknown as {\n HTMLElement: { prototype: object };\n customElements: CustomElementRegistry;\n } | null;\n const upgraded = view === null || Object.getPrototypeOf(element) !== view.HTMLElement.prototype;\n /** Development only: an element that never drains still loses the value at upgrade — told apart by ownership. */\n if (__DEV__ && view !== null && !upgraded && first) {\n const tag = element.localName;\n view.customElements.whenDefined(tag).then(() => {\n let owned = false;\n for (let carrier: object | null = element; carrier !== null; carrier = Object.getPrototypeOf(carrier)) {\n const desc = Object.getOwnPropertyDescriptor(carrier, name);\n if (desc === undefined) continue;\n owned = desc.get !== undefined || desc.set !== undefined;\n break;\n }\n if (!owned && element[name] !== record[name])\n console.warn(diagnostic('renderer', `<${tag}>`, 'upgrade-clobber', __DEV__ && SHARED.upgradeClobber(name)));\n });\n }\n return upgraded ? 1 : 0;\n};\n","import { misuse } from './diagnostic.js';\nimport * as SHARED from './diagnostics.js';\n/**\n * HTML's own element grammar — the facts about tags that every package emitting or reading markup\n * has to agree on.\n *\n * These are not this framework's rules; they are the parser's, and a package that guesses at them\n * produces markup whose *parse* differs from what its author wrote. That failure is silent by\n * nature: nothing throws, the page renders, and the DOM simply has a different shape than the\n * source said. See `VOID_ELEMENTS` below for the two measured instances.\n *\n * **Why here.** These sets had grown copies in `@verajs/ssr`, `@verajs/cms` and (as a regex) the\n * renderer, all agreeing by luck rather than by construction. This file is the one source for\n * every package that can take a build-time import — `@verajs/shared-utils` is private and inlined,\n * so importing it costs a consumer nothing at runtime and adds no published dependency.\n *\n * **`@verajs/ssr` cannot import it** and keeps its own copies: that package publishes its `src`\n * with no dependencies at all, so an import of a package that is never published would break the\n * published tarball. The same constraint already forced a twin of `escapeStyleText` there. A copy\n * is acceptable; a copy nothing checks is not, so `tests/markup-grammar-homes.test.mjs` drives\n * every copy against this file source-to-source rather than trusting they get edited together.\n *\n * **A consumer may keep a different SHAPE for the same fact** where a hot path needs one — the\n * renderer matches raw-text tags with a case-insensitive regex rather than lowercasing a string to\n * probe a `Set`. The rule is agreement, not representation, and the homes test asserts agreement\n * across whatever shape each home uses.\n */\n\n/**\n * Elements with no end tag, and therefore no children.\n *\n * Both directions of getting this wrong are silent, and both were live in this repo until the\n * audit of 2026-09-12 measured them:\n *\n * - **A non-void element written self-closing swallows what follows it.** HTML has no\n * self-closing syntax outside foreign content, so `<div/><span>after</span>` parses as\n * `<div><span>after</span></div>` — the sibling becomes a child. Every JSX toolchain treats\n * `<div/>` as an empty element, which is exactly why authors write it.\n * - **A void element written with an end tag is duplicated.** A parser reads `</br>` as *another*\n * `<br>`, so `<br></br>` renders two line breaks where the author wrote one.\n *\n * Inside `<svg>` and `<math>` the parser switches to foreign content, where XML self-closing *is*\n * honored — so neither rule applies there, and a consumer that checks must know where it is.\n */\nexport const VOID_ELEMENTS = new Set([\n 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',\n 'link', 'meta', 'param', 'source', 'track', 'wbr',\n]);\n\n/**\n * Elements a parser reads the children of as text rather than as markup.\n *\n * Two pieces of measured lore travel with this list and are the reason it is not read off a spec:\n *\n * - `iframe` and `noscript` were once absent from the SSR copy, which built a tree no browser\n * builds — `<noscript><img src=\"x\"></noscript>` produced an element, so\n * `querySelectorAll('noscript img')` answered 1 where every engine answers 0.\n * - `noscript` is raw text only when scripting is ENABLED. Fragment parsing disables it, and\n * Chromium and WebKit then parse the content as markup while Firefox parses it as text — so a\n * binding inside `<noscript>` worked in two engines and painted the renderer's internal marker\n * onto the page in the third. Listing it is safe in both parses.\n *\n * jsdom is not the oracle for either: it parses with scripting disabled and agrees with the old,\n * wrong list.\n */\nexport const RAW_TEXT_ELEMENTS = new Set(['style', 'script', 'textarea', 'title', 'iframe', 'noscript']);\n\n/**\n * The hyphenated names SVG and MathML already define, which the custom-elements spec reserves — so a\n * dash in one of these does NOT make it a custom element.\n *\n * Measured, the one that matters: JSX treats a dash-named tag as a custom element and compiles its\n * attributes to PROPERTIES, which turned `<annotation-xml encoding=\"text/html\">` into\n * `.encoding=${…}`. The HTML parser decides that element is an integration point from the\n * ATTRIBUTE on its start tag, so HTML content inside was moved out of the `<math>` entirely, and a\n * custom element there was built MathML-namespaced and never upgraded — silent on the server and\n * the client alike. That is also the exact spelling the renderer's own warning recommends.\n */\nexport const RESERVED_ELEMENT_NAMES = new Set([\n 'annotation-xml', 'color-profile', 'font-face', 'font-face-src',\n 'font-face-uri', 'font-face-format', 'font-face-name', 'missing-glyph',\n]);\n\n/**\n * **A custom element, by its name:** a dash, except the eight names SVG and MathML already own (above). One\n * definition for every package that asks — `@verajs/jsx` compiles such a tag's attributes to properties, and\n * `@verajs/renderer/slots` captures such a host's children. (The renderer's own property paths ask a narrower\n * question, the bare dash, on its hot path; a reserved name never carries a property binding.)\n */\nexport const isCustomElementName = (tag: string): boolean =>\n tag.includes('-') && !RESERVED_ELEMENT_NAMES.has(tag.toLowerCase());\n\n/**\n * A URL whose scheme a browser reads as `javascript:` — navigating to one runs it, so a BOUND value\n * that parses this way is code arriving as data, never a link.\n *\n * Matched the way the URL Standard's parser reads a scheme, because that is the only reading that\n * matters: leading C0 controls and spaces are stripped, ASCII tab, LF and CR are removed anywhere, and\n * the scheme is case-insensitive. A check that only lowercases is bypassed by `\" jAvA\\tscript:\"`,\n * which every engine navigates to. React's blocking pattern is the same rule.\n *\n * `@verajs/ssr` keeps a twin (it cannot import this package), held to this one by\n * `tests/url-sinks.test.mjs`, so a server never emits a link the client refuses.\n */\n// eslint-disable-next-line no-control-regex\nexport const SCRIPT_URL = /^[\\u0000- ]*j[\\t\\n\\r]*a[\\t\\n\\r]*v[\\t\\n\\r]*a[\\t\\n\\r]*s[\\t\\n\\r]*c[\\t\\n\\r]*r[\\t\\n\\r]*i[\\t\\n\\r]*p[\\t\\n\\r]*t[\\t\\n\\r]*:/i;\n\n/**\n * **Every bound name whose value is checked for a `javascript:` URL — and how.** One test answers both.\n *\n * Captured, checked from the start: the attributes (and their reflecting properties) whose value a browser\n * NAVIGATES to or loads as a document — links and areas (`href`, SVG's `xlink:href`), forms (`action`,\n * `formaction`), frames (`src`), and `<object data>`. `src` is matched on every element — refusing one on an `<img>`\n * costs nothing, since an image never runs it. Resource-only attributes (`poster`, `srcset`) are fetched, never run,\n * so they are not listed.\n *\n * Not captured, checked ITEM BY ITEM (`SCRIPT_URL_ITEM`): an SVG animation's values — `to`, `from`, `by`, `values`.\n * `<animate attributeName=\"href\" to=\"javascript:…\">` (or `<set>`, or `values`) writes its value onto the link it\n * animates, and clicking the link then RUNS it: measured 2026-09-30 in Chromium, Firefox and WebKit, through `href`\n * and `xlink:href` alike. Refused on EVERY element and whatever `attributeName` says, because `attributeName` can\n * itself be bound or spread, a server spread has no element to ask, and no legitimate value of any attribute by these\n * names starts with `javascript:` (a component's `to`, a router link's, is a URL too). **Only these names are checked\n * item by item**: an unanchored test scans the whole value for `;`, which on a bound `src` holding a data URI costs\n * ~0.45 ms per MB per update in Chromium and Firefox (measured 2026-09-30), where the anchored `SCRIPT_URL` stops at\n * the first character.\n *\n * Case-insensitive, because property spellings (`formAction`) and attribute spellings meet here. `@verajs/ssr` keeps\n * a twin, held to this one by `tests/url-sinks.test.mjs`.\n */\nexport const URL_SINK = /^(?:(href|src|action|formaction|xlink:href|data)|to|from|by|values)$/i;\n\n/**\n * `SCRIPT_URL` at the start of the value OR of any `;`-separated item of it — an animation's `values` list\n * (`\"#a;javascript:…\"`) applies every item in turn. Only for an animation's values (`URL_SINK`'s uncaptured names): a `;` inside an `href` is a path\n * character, and `/p;javascript:x` is a working link, never a script. Written out rather than derived from\n * `SCRIPT_URL`: the repeated text costs less gzipped than the code that would build it.\n */\n// eslint-disable-next-line no-control-regex\nexport const SCRIPT_URL_ITEM = /(?:^|;)[\\u0000- ]*j[\\t\\n\\r]*a[\\t\\n\\r]*v[\\t\\n\\r]*a[\\t\\n\\r]*s[\\t\\n\\r]*c[\\t\\n\\r]*r[\\t\\n\\r]*i[\\t\\n\\r]*p[\\t\\n\\r]*t[\\t\\n\\r]*:/i;\n\n/**\n * **An inline event-handler attribute** — `on` and a letter, any case (`onclick`, `onLoad`, `onbeforeinput`): its\n * value is run as CODE, so a BOUND one is code arriving as data, refused by the template scanner, `spread` and the\n * server alike (a static `onclick=\"save()\"` is the author's own and untouched). Broad on purpose — it also refuses a\n * bound `once=`/`online=` attribute; the precise rule would need the platform's list of handler names. `@verajs/ssr`\n * keeps a twin, held to this one by `tests/inline-handlers.test.mjs`.\n */\nexport const INLINE_HANDLER = /^on./i;\n\n/**\n * **The properties that replace an element's whole content** — a binding to one owns the element's children, so it\n * cannot share the element with content of its own (markup, or a child binding the write would strand: a later commit\n * into it then throws on a missing parent). Development refuses the pair in the template scanner and in `spread` alike.\n */\nexport const CONTENT_PROPERTY = /^(?:textContent|innerHTML|innerText|outerHTML|outerText)$/;\n/**\n * Whether an element has content of its own that a content-replacing write would strand or lose: a child that is not\n * whitespace-only text (formatting whitespace loses nothing), or — `$content`, set in development by the renderer — a\n * child binding that owns the element whole and leaves no node behind until it commits. The element-specific `.text`\n * setters (`<a>`, `<option>`, `<title>`, `<script>`) are deliberately not in the list: a custom element's own `text`\n * prop is common, and would be refused for nothing.\n */\nexport const ownsContent = (element: Element): boolean => {\n if ((element as Element & { $content?: boolean }).$content === true) return true;\n for (let node = element.firstChild; node !== null; node = node.nextSibling)\n /**\n * An EMPTY text node is a child binding's anchor, not formatting: formatting whitespace is never empty. And\n * formatting is HTML's whitespace, `[ \\t\\n\\f\\r]` — not JS's `trim()`, which would let an ` ` be overwritten.\n */\n if (node.nodeType !== 3 || (node as Text).data === '' || /[^ \\t\\n\\f\\r]/.test((node as Text).data)) return true;\n return false;\n};\n/** `side` is the module the user wired — `renderer` for a template, `spread` for a spread. */\nexport const contentClash = (side: string, tag: string, name: string): never => {\n throw new Error(misuse(side, 'content-clash', __DEV__ && SHARED.contentClash(tag, name, side === 'spread' ? `<${tag} \\${spread({ '.${name}': … })}></${tag}>` : `<${tag} .${name}=\\${…}></${tag}>`)));\n};\n\n/**\n * **An expression in TAG-name position** (`<${x}>`, `</${x}>`, `<my-${x}>`) without `@verajs/renderer/tag`: no\n * element can be made from it — the parser reads a tag name before any value exists. Refused by the client in\n * development and by the server in every build, with one message. The tag entry splices a tag VALUE into the\n * statics before the renderer sees it, so only a non-tag ever reaches here.\n */\nexport const TAG_NAME_HOLE = /<\\/?[^\\s>]*$/;\nexport const tagHole = (side: string): never => {\n throw new Error(misuse(side, 'tag-hole', __DEV__ && SHARED.tagHole()));\n};\n","import type { HandlerHolder, Untracked } from './types.js';\nimport { diagnostic } from './diagnostic.js';\nimport * as SHARED from './diagnostics.js';\n\n/**\n * Get an object's type.\n *\n * @param obj The object\n * @return The type\n */\nexport const getType = (obj: unknown) => Object.prototype.toString.call(obj).slice(8, -1).toLowerCase();\n\n/**\n * Weak collections need their per-key dependencies stored weakly, or tracking `weakMap.get(obj)`\n * holds `obj` and defeats the whole point of the type. Checked by type string rather than\n * `instanceof`, which fails across realms (iframes, `vm`).\n */\n/**\n * A WeakMap or WeakSet (or WeakRef) — read from `Symbol.toStringTag`, the tag `Object.prototype.toString` itself reads, so\n * the answer is the same (another realm's collections included) without building and lower-casing a string on every first\n * tracked read of every object.\n */\nexport const isWeakCollection = (item: unknown) => {\n const tag = (item as { [Symbol.toStringTag]?: unknown } | null)?.[Symbol.toStringTag];\n return typeof tag === 'string' && (tag[0] === 'W' || tag[0] === 'w');\n};\n\n/**\n * Remove a trailing slash from an url if its not root url (`/`).\n *\n * @param str String to remove trailing slash from\n */\nexport const stripTrailingSlash = (str: string) => (str !== '/' && str.endsWith('/') ? str.slice(0, -1) : str);\n\n/**\n * **Reports an error nothing else handled, the way the platform reports one.** `reportError` fires\n * the window's `error` event — what `window.onerror`, error trackers and test runners listen for —\n * without unwinding the caller, so one failing hook or ref never stops its siblings. A bare\n * `console.error` reached none of those: a component could stop updating while every page-error\n * listener stayed silent. Off-browser (Node has no `reportError`) the console is all there is.\n * `line` is the framework's own line, printed beside the error — a CODED one (2026-10-09):\n * each caller passes `'[vera] <code>'` in production and its table's `diagnostic()` sentence in development, both\n * literal codes at the call site, so the static checks read them. The subject is fixed wording too (`a hook`, `an\n * element ref`), never a tag name: this line is the console's FORMAT (no `'%s'`, which measured +2–3 B on the renderer\n * bundles), so nothing from outside may reach it — the element goes to the `'error'` handlers instead. Production prints it only where the platform has no\n * `reportError` (Node); in a browser, `reportError` alone reports.\n *\n * Shared by core (a hook threw) and the renderer (a ref threw) so the fallback is one rule.\n */\nexport const reportUncaught = (error: unknown, line: string) => {\n if (typeof reportError !== 'function') console.error(line, error);\n else {\n if (__DEV__) console.error(line, error);\n reportError(error);\n }\n};\n\n/**\n * **Reports what user code a render called threw — to the app's `'error'` chain, else as uncaught.** One rule for\n * every callback the framework runs on the user's behalf and survives: a hook (core), an element ref, and an element\n * claim's `create`/`mount`/`unmount` (the renderer). The caller catches at the call site and carries on, so one\n * failing callback never stops its siblings or leaves a commit half applied. `element` is the component the error\n * belongs to, handed to each handler. Every throw is reported — nothing is deduped, as a hook's never was.\n * **Core keeps a deliberate twin** (`reportHookError`, the same rule as a `forEach`): routed through here it measured\n * +11 B gzip on `vera.min.js` (2026-10-09). A change to the rule changes both.\n */\nexport const reportTo = (handlers: readonly unknown[] | undefined, error: unknown, element: Element | undefined, line: string) => {\n if (handlers?.length) for (const handler of handlers) (handler as (error: unknown, element?: Element) => void)(error, element);\n else reportUncaught(error, line);\n};\n\n/** The component a render root belongs to: a shadow root's host, or a light root itself. */\nexport const hostOf = (root: Node | null | undefined): Element | undefined =>\n root == null ? undefined : root.nodeType === 11 ? (root as ShadowRoot).host : (root as Element);\n\n/** `fn(a, b, c)`, tracked as the caller is — the stand-in for core's `untracked` when no core was wired. */\nexport const call: Untracked = (fn, a, b, c) => fn(a!, b!, c!);\n\n/**\n * **Runs a bound handler, and its callers run it UNTRACKED**: the renderer's template `@event` and spread's event key,\n * each through `untracked(dispatch, holder, event)` (2026-10-09). An effect that fires an event synchronously\n * (`el.click()`, `focus()`, `dispatchEvent`) runs the handler INSIDE itself, and the handler's reads subscribed the\n * effect: a handler doing `state.n++` made the effect re-run on every click, a self-feeding loop held to one round per\n * frame, forever (measured). A handler's reads are event-time decisions, never a hook's inputs. The directives engine's\n * delegated `listen` makes the same choice its own way. A function is called with the element as `this`; an object\n * through its `handleEvent`. One function for both callers (Brian's size-audit ruling, 2026-11-13): it was two\n * identical copies, so a fix had two addresses; each bundle still inlines its own.\n */\nexport const dispatch = (holder: HandlerHolder, event: Event) => {\n const handler = holder._handler as EventListener | EventListenerObject | null;\n if (typeof handler === 'function') handler.call(holder._element as never, event);\n else if (typeof handler?.handleEvent === 'function') handler.handleEvent(event);\n};\n\n/**\n * **Whether a property binding is a `<select>`'s SELECTION** — `value` or `selectedIndex` — which the renderer and\n * `spread` both treat as live: re-asserted every render and compared against the live value (as `!value` is), because\n * a select's options can be replaced under an unchanged value, which drops the selection. One rule, asked once per\n * binding by both, so a template and a spread key cannot disagree about it.\n *\n * In development it names the one shape it cannot serve: on a `<select multiple>` both properties read and set a\n * SINGLE selection, so a selection the user adds is kept rather than controlled. Always writing there was measured\n * 2–3% slower on every table with a select per row, to serve an API that does not fit — hence a warning, not a cost.\n */\nexport const isSelection = (element: Element, name: unknown) => {\n if ((name !== 'value' && name !== 'selectedIndex') || element.localName !== 'select') return false;\n return true;\n};\n\n/**\n * Development: the one shape a selection binding cannot serve, named by the module the user wired (`side`). Called only\n * behind `__DEV__` at each call site, so production keeps `isSelection` exactly as small as it was (a `side` argument on\n * it measured +1 B, a default +9 B on vera-renderer.min.js — 2026-10-09).\n */\nexport const saySelectMultiple = (element: Element, name: unknown, side: string) => {\n if (element.hasAttribute('multiple'))\n console.warn(diagnostic(side, '<select multiple>', 'select-multiple', __DEV__ && SHARED.selectMultiple(String(name))));\n};\n\n/**\n * `target[key]`, as a function — how a component's GETTER is read through `untracked`. Not `Reflect.get`: `untracked`\n * passes three arguments, and `Reflect.get`'s third is the RECEIVER — `undefined` there runs the getter with no `this`.\n */\nexport const read = (target: object, key: string) => (target as Record<string, unknown>)[key];\n\n/**\n * **What a thrown value says, whatever was thrown — and it never throws itself.** A caught value comes from author\n * code (a `resolve` option, a motion tick or vocabulary function), and JavaScript can throw anything: `null`, an object\n * with no prototype (`String()` finds no `toString`), one whose `toString` or `message` getter throws, a Proxy whose\n * traps throw. Formatting it naively replaced the real failure with an unrelated TypeError from inside the framework.\n * Anything unreadable becomes a fixed phrase; `Object.prototype.toString` is no fallback, since it reads\n * `Symbol.toStringTag` through a Proxy's trap too.\n *\n * **A deliberate duplicate of `thrownMessage` in `packages/ssr/src/vera/escaping.ts` — fix both copies.** `@verajs/ssr`\n * is compiled per file with no bundling, so it cannot import this private, unpublished package at run time;\n * `tests/thrown-message-copies.test.mjs` runs one table of thrown values against both, so they cannot drift.\n */\nexport const thrownMessage = (error: unknown): string => {\n try {\n if (error instanceof Error) return String(error.message);\n const message = (error as { message?: unknown } | null)?.message;\n return typeof message === 'string' ? message : String(error);\n } catch {\n return '[unprintable value thrown]';\n }\n};\n","/**\n * `<div ${spread(props)}>` — bindings whose NAMES are not known when the template is parsed.\n *\n * Ships separately: the renderer holds one property read (a value at element position carrying\n * `_$apply$` applies itself), so an app that never spreads pays only that. This entry imports nothing\n * from the renderer and reaches it only through that protocol, so it works beside any renderer entry.\n *\n * **One key, one rule, decided once.** A key's kind and name follow the renderer's template sigils\n * exactly (`.prop`, `?bool`, `@event`, `&ref`, `!live`, `onClick`), and its verdict — including every\n * refusal — is decided when its binding is first created, never again per render. The rules are\n * repeated rather than imported from the renderer (the bundles cannot share state);\n * `tests/spread-written-parity.test.mjs` drives both spellings against each other.\n *\n * **Security: spread is where the template security model would break**, because its names arrive at\n * runtime, often from data, and are neither greppable nor reviewable. So it refuses, on the client and\n * in the server half (`_$attrs$`) alike: `.innerHTML`/`.outerHTML` (and `!`), `.__proto__`, the `srcdoc`\n * attribute, inline-handler attributes (`onclick` in any casing — `on` + Capital is the event spelling\n * and still works), names that cannot survive markup, and — as the renderer does — a `javascript:` URL\n * where a browser navigates.\n */\nimport { adoptProperty, call, CONTENT_PROPERTY, dispatch, contentClash, INLINE_HANDLER, ownsContent, isSelection, read, saySelectMultiple, SCRIPT_URL, SCRIPT_URL_ITEM, URL_SINK, diagnostic, SHARED } from '@verajs/shared-utils';\nimport type { Untracked } from '@verajs/shared-utils';\nimport { attributeValueKind } from './dev-values.js';\nimport { PROSE } from './spread-diagnostics.js';\n\nconst ATTR = 0;\nconst PROPERTY = 1;\nconst BOOLEAN = 2;\n/** `!name` — a property compared against the live DOM rather than against what this last wrote. */\nconst LIVE = 3;\nconst EVENT = 4;\nconst REF = 5;\nconst REFUSED = 6;\n\n/**\n * A name that cannot be written into a tag: the HTML attribute-name restriction (control characters,\n * whitespace, `\"`, `'`, `>`, `/`, `=`) plus `<` and a backtick — refused identically on both sides, so a\n * key cannot work here and vanish server-side. Skipped, never thrown: one bad key must not cost a render.\n */\n// eslint-disable-next-line no-control-regex\nconst UNSAFE_NAME = /^$|[\\s\"'>/=<`]|[\\u0000-\\u001f\\u007f]/;\n\n/** Development only: why a key was refused, by refusal code. */\n\n/**\n * A key's kind and name, and — for a refused key — why (`[REFUSED, code]`). The twin of the renderer's\n * template construction; a refused key's verdict never changes, so it is decided once per binding.\n */\nconst resolve = (key: string): [number, string | number] => {\n const first = key[0];\n let kind = first === '.' ? PROPERTY : first === '?' ? BOOLEAN : first === '@' ? EVENT : first === '&' ? REF : first === '!' ? LIVE : ATTR;\n let name = kind === ATTR ? key : key.slice(1);\n if (kind === ATTR && /^on[A-Z]/.test(key)) {\n kind = EVENT;\n name = key.slice(2).toLowerCase();\n }\n const property = kind === PROPERTY || kind === LIVE;\n const refusal = UNSAFE_NAME.test(name)\n ? 1\n : property && (name === 'innerHTML' || name === 'outerHTML')\n ? 2\n : property && name === '__proto__'\n ? 3\n : kind === ATTR && name.toLowerCase() === 'srcdoc'\n ? 4\n : kind === ATTR && INLINE_HANDLER.test(name)\n ? 5\n : 0;\n return refusal ? [REFUSED, refusal] : [kind, name];\n};\n\n/**\n * How a key names a URL a browser navigates to — the renderer's rule, by the same numbers: 0 not one; 1 a custom\n * element's property — often an object (`.data=${rows}`), so only a string is checked and nothing is converted; 2\n * converted ONCE, and that string checked and written (so a `toString` that answers differently each time cannot pass\n * the check as one URL and be written as another); 3 an animation's value (`to`, `values`…), converted once and\n * checked item by item. A refused key needs no case: its name is a refusal code, which no URL\n * attribute name matches.\n */\nconst urlRule = (kind: number, name: string, custom: boolean) => {\n const sink = URL_SINK.exec(name);\n return kind === BOOLEAN || kind === EVENT || kind === REF || sink === null ? 0 : kind !== ATTR && custom ? 1 : sink[1] ? 2 : 3;\n};\n\n/** What `checked` answers for a `javascript:` URL where the rule looks. */\nconst REFUSE = {};\n\n/** `value` as it is checked AND written under `rule` — converted once, or left as it is — or `REFUSE`. */\nconst checked = (rule: number, value: unknown) => {\n if (rule > 1 && value != null && typeof value !== 'string') value = `${value}`;\n return rule !== 0 && typeof value === 'string' && (rule === 3 ? SCRIPT_URL_ITEM : SCRIPT_URL).test(value) ? REFUSE : value;\n};\n\nconst UNSET = {};\n\n/** One key's binding on one element. It is also the `@event` listener — a stable object, so the platform dedupes re-adds. */\nclass Binding {\n _kind: number;\n _name: string;\n _element: Element;\n /** What the element held before the bag first wrote this key — restored when the key leaves the bag. */\n _initial: unknown = null;\n _committed: unknown = UNSET;\n _handler: unknown = null;\n /** For `.prop`: where adoption stands (`adoptProperty`: 0 still adopting, 1 received, 2 refused). */\n _state = 1;\n /** How this key is checked as a URL (`urlRule`) — decided once, with the element in hand. */\n _url: number;\n /**\n * On a custom element, a property read is the component's GETTER, so it goes through the `untracked` this binding was\n * created with; `null` on a built-in element, whose getters read no state. Decided once.\n */\n _read: Untracked | null;\n constructor(element: Element, key: string, untracked: Untracked) {\n const [resolved, name] = resolve(key);\n /** A `<select>`'s selection is live, as in a template — the same rule, asked of the same function. */\n const kind = (resolved === PROPERTY || resolved === LIVE) && isSelection(element, name) ? LIVE : resolved;\n if (__DEV__ && (resolved === PROPERTY || resolved === LIVE) && isSelection(element, name)) saySelectMultiple(element, name, 'spread');\n this._kind = kind;\n this._name = name as string;\n this._element = element;\n const custom = element.localName.includes('-');\n /** Core's `untracked` for a custom element's getter reads, and for an event key's handler (`dispatch`). */\n this._read = custom || kind === EVENT ? untracked : null;\n this._url = urlRule(kind, name as string, custom);\n /** A content-replacing property beside content of the element's own: development refuses it, as a template does. */\n if (__DEV__ && (kind === PROPERTY || kind === LIVE) && CONTENT_PROPERTY.test(name as string) && ownsContent(element))\n contentClash('spread', element.localName, name as string);\n if (kind === REFUSED) {\n if (__DEV__) {\n /** Each refusal written out, so the manifest (`diagnostics-tables`) reads every raise from the source. */\n const at = `<${element.localName}>`;\n const written = JSON.stringify(key);\n const why = name as number;\n if (why === 1) console.warn(diagnostic('spread', at, 'spread-unsafe-name', __DEV__ && PROSE['spread-unsafe-name'](written)));\n else if (why === 2) console.warn(diagnostic('spread', at, 'spread-inner-html', __DEV__ && PROSE['spread-inner-html'](written)));\n else if (why === 3) console.warn(diagnostic('spread', at, 'proto-binding', __DEV__ && SHARED.protoBinding(written)));\n else if (why === 4) console.warn(diagnostic('spread', at, 'srcdoc-attribute', __DEV__ && SHARED.srcdocAttribute(\"'.srcdoc': trusted\")));\n else\n console.warn(\n diagnostic('spread', at, 'handler-attribute',\n __DEV__ && SHARED.handlerAttribute(key, `\\`'@${key.slice(2).toLowerCase()}': fn\\` (or \\`on${key.slice(2, 3).toUpperCase()}${key.slice(3)}\\`)`))\n );\n }\n return;\n }\n if (kind === ATTR) this._initial = element.getAttribute(name as string);\n else if (kind === BOOLEAN) this._initial = element.hasAttribute(name as string);\n /** On a custom element this is the component's getter, run on the parent's behalf: read through `untracked`. */\n else if (kind === PROPERTY || kind === LIVE)\n this._initial = custom ? untracked(read, element, name as string) : (element as unknown as Record<string, unknown>)[name as string];\n if (kind === PROPERTY && custom) this._state = 0;\n }\n /** Runs the handler UNTRACKED (shared-utils' `dispatch`): `_read` holds core's `untracked` for an event key too. */\n handleEvent(event: Event) {\n (this._read ?? call)(dispatch, this, event);\n }\n}\n\nconst write = (binding: Binding, given: unknown, adopting?: boolean) => {\n const kind = binding._kind;\n const value = checked(binding._url, given);\n const name = binding._name;\n /** One variable, typed for both uses: a cast alias survives minification as a second variable. */\n const element = binding._element as Element & Record<string, unknown>;\n if (kind === REFUSED) return;\n /**\n * **Adopting server markup** (hydration hands this in): a built-in control's state — `value`, `checked`, `selected`,\n * `open`, by `.name` or `!name` — is RECORDED, not written: the server's default, and anything the user changed before\n * the script arrived, stand, exactly as for a written binding (hydration's `FORM_STATE`, the same list — keep them\n * equal). Any other name is written, and a component's property is always delivered.\n */\n if (adopting && binding._read === null && (kind === LIVE || kind === PROPERTY) && /^(?:value|checked|selected|open)$/.test(name as string)) {\n binding._committed = value;\n return;\n }\n if (value === REFUSE) {\n if (__DEV__ && given !== binding._committed)\n console.warn(diagnostic('spread', `<${element.localName}>`, 'script-url', __DEV__ && SHARED.scriptUrl(name)));\n binding._committed = given;\n element.removeAttribute(name);\n return;\n }\n if (kind === LIVE) {\n binding._committed = value;\n /**\n * A built-in is compared against its live property. A COMPONENT is compared against its current value — the raw one\n * its store holds (`_$raw$`) for a name it received, else read through `untracked` — and receives a difference\n * through `adoptProperty`. Inline, as the renderer's `commit` reads a template's `!name`: keep the two equal.\n */\n if (binding._read === null) {\n if (element[name] !== value) element[name] = value;\n } else {\n const raw = element._$raw$ as Record<string, unknown> | undefined;\n if ((raw !== undefined && name in raw ? raw[name] : binding._read(read, element, name)) !== value) adoptProperty(element, name, value);\n }\n return;\n }\n if (value === binding._committed) return;\n binding._committed = value;\n if (kind === ATTR) {\n if (value == null) element.removeAttribute(name);\n else {\n if (__DEV__) {\n const kind = attributeValueKind(element.localName, name, value);\n if (kind !== null) console.warn(diagnostic('spread', `<${element.localName}>`, 'attribute-value', __DEV__ && SHARED.attributeValue(name, kind, `'.${name}': value`)));\n }\n element.setAttribute(name, `${value}`);\n }\n } else if (kind === PROPERTY) {\n if (binding._state === 1) element[name] = value;\n else if (binding._state === 0) binding._state = adoptProperty(element, name, value);\n } else if (kind === BOOLEAN) element.toggleAttribute(name, !!value);\n else if (kind === REF) {\n if (typeof value === 'function') (value as (element: Element) => void)(element);\n else if (value !== null && typeof value === 'object') (value as { value: unknown }).value = element;\n } else {\n if (__DEV__ && value != null && value !== false && typeof value !== 'function' &&\n typeof (value as EventListenerObject)?.handleEvent !== 'function')\n console.warn(diagnostic('spread', `<${element.localName}>`, 'not-a-listener', __DEV__ && SHARED.notAListener(name, typeof value)));\n if (binding._handler === null && value != null) element.addEventListener(name, binding);\n binding._handler = value ?? null;\n }\n};\n\n/**\n * Each binding is owned by the renderer's binding record it arrived through (the `key`), so one element can\n * carry several spreads. A key that leaves the bag is written back to what the element held before.\n */\nconst owned = new WeakMap<object, Map<string, Binding>>();\n/**\n * `untracked` is `_$apply$`'s third argument — core's, through the renderer; `call` when a renderer leaves it out.\n * Each binding keeps the one it was CREATED with, so nothing about it is paid per render, and an apply nested inside\n * another (a component setter rendering a spread) can never change what the outer's bindings use.\n */\nfunction apply(this: SpreadResult, element: Element, key: object, untracked: Untracked = call, adopting = false) {\n const props = this._props;\n let bindings = owned.get(key);\n if (bindings === undefined) owned.set(key, (bindings = new Map()));\n let count = 0;\n for (const name in props) {\n count++;\n let binding = bindings.get(name);\n if (binding === undefined) bindings.set(name, (binding = new Binding(element, name, untracked)));\n write(binding, props[name], adopting);\n }\n if (bindings.size !== count)\n for (const [name, binding] of bindings)\n if (!(name in props)) {\n bindings.delete(name);\n write(binding, binding._initial);\n }\n}\n\n/**\n * The server half of the protocol: `[kind, name, value]` for each key `@verajs/ssr` should serialize —\n * `a`ttribute, `b`oolean, `p`roperty, `e`vent, `r`ef — with every refusal and every refused URL already\n * applied, by the same `resolve` the client uses, so the two cannot disagree.\n */\nfunction attributes(this: SpreadResult): [string, string, unknown][] {\n const out: [string, string, unknown][] = [];\n for (const key in this._props) {\n const [kind, name] = resolve(key);\n /** No element here: a property key is judged as a custom element's — the server only ever delivers one to a component. */\n const rule = urlRule(kind, name as string, true);\n const value = checked(rule, this._props[key]);\n if (kind === REFUSED || value === REFUSE) continue;\n out.push([kind === ATTR ? 'a' : kind === BOOLEAN ? 'b' : kind === EVENT ? 'e' : kind === REF ? 'r' : 'p', name as string, value]);\n }\n return out;\n}\n\n/** The branded, self-applying result — what the renderer's element position recognizes. */\ntype SpreadResult = {\n _props: Record<string, unknown>;\n _$apply$: unknown;\n _$attrs$: unknown;\n};\n\n/**\n * Binds every key of `props` to the element it is placed on. Keys follow the template sigils — `.prop`,\n * `?bool`, `@event` (or `onClick`), `&ref`, `!live` — and a plain key is an attribute.\n *\n * Already-branded input is returned as-is (JSX compiles `{...spread(x)}` to a spread of a spread). A\n * value that is not a plain object is refused in BOTH builds — a string would otherwise be iterated by\n * character index into attributes named `0`, `1`, `2` — and development says so.\n */\nexport const spread = (props: object | null | undefined): SpreadResult => {\n if (props !== null && typeof props === 'object' && typeof (props as SpreadResult)._$apply$ === 'function')\n return props as SpreadResult;\n if (props === null || typeof props !== 'object' || Array.isArray(props)) {\n if (__DEV__)\n console.warn(\n diagnostic('spread', 'spread()', 'spread-not-object',\n __DEV__ && PROSE['spread-not-object'](Array.isArray(props) ? 'an array' : typeof props === 'object' ? 'null' : `a ${typeof props}`))\n );\n props = {};\n }\n return { _props: props as Record<string, unknown>, _$apply$: apply, _$attrs$: attributes };\n};\n\n/** Every key as a property: `props({ items })` is `spread({ '.items': items })` — how a component receives data. */\nexport const props = <T extends object = Record<string, unknown>>(values: Partial<T>): SpreadResult => {\n const sigiled: Record<string, unknown> = {};\n for (const key of Object.keys(values)) sigiled[`.${key}`] = (values as Record<string, unknown>)[key];\n return spread(sigiled);\n};\n"],"names":["adoptProperty","element","name","value","adopt","_$adopt$","carrier","Object","getPrototypeOf","desc","getOwnPropertyDescriptor","undefined","set","get","call","_$props$","view","ownerDocument","defaultView","HTMLElement","prototype","SCRIPT_URL","URL_SINK","SCRIPT_URL_ITEM","INLINE_HANDLER","fn","a","b","c","dispatch","holder","event","handler","_handler","_element","handleEvent","read","target","key","UNSAFE_NAME","resolve","first","kind","slice","test","toLowerCase","property","refusal","urlRule","custom","sink","exec","REFUSE","checked","rule","UNSET","Binding","_kind","_name","_initial","_committed","_state","_url","_read","constructor","untracked","resolved","localName","isSelection","this","includes","getAttribute","hasAttribute","write","binding","given","adopting","removeAttribute","setAttribute","toggleAttribute","addEventListener","raw","_$raw$","owned","WeakMap","apply","props","_props","bindings","Map","count","size","delete","attributes","out","push","spread","_$apply$","Array","isArray","_$attrs$","values","sigiled","keys"],"mappings":"AAgCO,MAAMA,EAAgB,CAACC,EAAuBC,EAAcC,KAOjE,GAAa,cAATD,EAAsB,OAAO,EACjC,MAAME,EAAQH,EAAQI,SAEtB,IAAK,IAAIC,EAAyBL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AzO5B,IA0ORI,GAAoBvC,IAAUiD,GAClC0C,EAAIC,KAAK,CAlPA,IAkPCrD,EAAgB,IAhPd,IAgPoBA,EAAmB,IA7OzC,IA6O+CA,EAAiB,IA5OlE,IA4OwEA,EAAe,IAAM,IAAKxC,EAAgBC,GAC5H,CACA,OAAO2F,CACT,CAiBO,MAAME,EAAUV,GACP,OAAVA,GAAmC,iBAAVA,GAAkE,mBAApCA,EAAuBW,SACzEX,IACK,OAAVA,GAAmC,iBAAVA,GAAsBY,MAAMC,QAAQb,MAM/DA,EAAQ,CAAA,GAEH,CAAEC,EAAQD,EAAkCW,SAAUZ,EAAOe,SAAUP,IAInEP,EAAqDe,IAChE,MAAMC,EAAmC,CAAA,EACzC,IAAK,MAAMhE,KAAO/B,OAAOgG,KAAKF,GAASC,EAAQ,IAAIhE,KAAU+D,EAAmC/D,GAChG,OAAO0D,EAAOM,EAAQ"}
|
|
1
|
+
{"version":3,"file":"vera-renderer-spread.min.js","sources":["../../shared-utils/src/adopt-property.ts","../../shared-utils/src/markup-grammar.ts","../../shared-utils/src/utils.ts","../src/spread.ts"],"sourcesContent":["import type { PropertyHost } from './types.js';\nimport { diagnostic } from './diagnostic.js';\nimport * as SHARED from './diagnostics.js';\n\n/**\n * **Delivering a bound property to a custom element that may not receive it yet** — the one home of the\n * rule `@verajs/renderer` (a `.prop` template binding) and `@verajs/renderer/spread` (a `.prop` bag key)\n * both apply. They ship as separate bundles that cannot import each other, so this package, inlined into\n * each, is where the rule lives once; before, each carried a full copy and a fix had to visit both.\n *\n * Returns where the binding stands after this write:\n * - `0` — still adopting: nothing received the value, so it was recorded in the element-carried\n * `_$props$`, which core's `init()` drains over whatever the class's field initializers wrote at\n * upgrade. Call again on the next write.\n * - `1` — received (a setter anywhere on the chain, an initialized component's `_$adopt$`, or an element\n * that is already upgraded): later writes are plain property writes.\n * - `2` — refused: a getter with no setter, where the plain write would throw. Later writes do nothing.\n *\n * `_$props$` and `_$adopt$` are `$`-named because they cross bundle boundaries (renderer, spread, core)\n * and must survive property mangling.\n *\n * **`_$adopt$` is a BRAND, not just a slot:** present means \"core has initialized this component\", which is what routes\n * a delivery to the live accessor (`1`) instead of the `_$props$` record. Do not move it to a class's PROTOTYPE\n * (2026-10-10): every instance would carry it BEFORE `init`, and a delivery to an upgraded-but-uninitialized element\n * would be adopted into a store that does not exist yet. It is ONE shared function written onto each element at `init`,\n * called with the element as `this` (`adopt.call(element, …)`) — 2026-10-11: the closure it replaced was free in\n * optimized code (measured) but cost Chrome's interpreted first render one allocation per component.\n */\n\n/** Development only: getter-only names already reported, per element — a `!name` re-asserts on every render. */\nlet refused: WeakMap<PropertyHost, Set<string>> | undefined;\n\nexport const adoptProperty = (element: PropertyHost, name: string, value: unknown): 0 | 1 | 2 => {\n /**\n * **`__proto__` is refused HERE, at the receiver** (2026-11-10): `element.__proto__ = v` replaces the element's\n * prototype, and an own `__proto__` key reaches a bag through `JSON.parse`. This is the choke point every delivery\n * passes; the renderer's template binding and spread's bag key refuse it first, with a development warning naming\n * where it was written (their second addresses: renderer.ts `proto-binding`, spread.ts refusal 3).\n */\n if (name === '__proto__') return 2;\n const adopt = element._$adopt$ as ((key: string, value: unknown) => void) | undefined;\n /** The walk comes first: what it finds decides whether writing is even legal. */\n for (let carrier: object | null = element; carrier !== null; carrier = Object.getPrototypeOf(carrier)) {\n const desc = Object.getOwnPropertyDescriptor(carrier, name);\n if (desc === undefined) continue;\n if (desc.set !== undefined) {\n element[name] = value;\n return 1;\n }\n if (desc.get !== undefined) {\n if (adopt !== undefined) adopt.call(element, name, value);\n else if (__DEV__) {\n const names = (refused ??= new WeakMap()).get(element) ?? new Set<string>();\n refused.set(element, names);\n if (!names.has(name)) {\n names.add(name);\n console.warn(diagnostic('renderer', `<${element.localName}>`, 'getter-only-prop', __DEV__ && SHARED.getterOnlyProp(name)));\n }\n }\n return 2;\n }\n break; // a data property: an own field, or an inherited default — nothing receives it\n }\n element[name] = value;\n if (adopt !== undefined) {\n adopt.call(element, name, value);\n return 1;\n }\n const record = (element._$props$ ??= {}) as Record<string, unknown>;\n const first = __DEV__ && !Object.hasOwn(record, name);\n record[name] = value;\n /** Upgrade is read off the PROTOTYPE — a bag key named `constructor` can shadow `el.constructor`. The realm is the element's. */\n const view = element.ownerDocument.defaultView as unknown as {\n HTMLElement: { prototype: object };\n customElements: CustomElementRegistry;\n } | null;\n const upgraded = view === null || Object.getPrototypeOf(element) !== view.HTMLElement.prototype;\n /** Development only: an element that never drains still loses the value at upgrade — told apart by ownership. */\n if (__DEV__ && view !== null && !upgraded && first) {\n const tag = element.localName;\n view.customElements.whenDefined(tag).then(() => {\n let owned = false;\n for (let carrier: object | null = element; carrier !== null; carrier = Object.getPrototypeOf(carrier)) {\n const desc = Object.getOwnPropertyDescriptor(carrier, name);\n if (desc === undefined) continue;\n owned = desc.get !== undefined || desc.set !== undefined;\n break;\n }\n if (!owned && element[name] !== record[name])\n console.warn(diagnostic('renderer', `<${tag}>`, 'upgrade-clobber', __DEV__ && SHARED.upgradeClobber(name)));\n });\n }\n return upgraded ? 1 : 0;\n};\n","import { misuse } from './diagnostic.js';\nimport * as SHARED from './diagnostics.js';\n/**\n * HTML's own element grammar — the facts about tags that every package emitting or reading markup\n * has to agree on.\n *\n * These are not this framework's rules; they are the parser's, and a package that guesses at them\n * produces markup whose *parse* differs from what its author wrote. That failure is silent by\n * nature: nothing throws, the page renders, and the DOM simply has a different shape than the\n * source said. See `VOID_ELEMENTS` below for the two measured instances.\n *\n * **Never `exec` a shared `/g` regex in a loop whose body can re-enter it** (a nested render, a recursive compose or\n * serialize, a callback): the inner use resets `lastIndex`, and the outer loop restarts or skips. Setting `lastIndex`\n * before every `exec` is not enough. Measured 2026-11-17: the static tier's composer re-entered its marker regex through\n * a nested template and composed forever; split once, or use a fresh regex per walk.\n *\n * **Why here.** These sets had grown copies in `@verajs/ssr`, `@verajs/cms` and (as a regex) the\n * renderer, all agreeing by luck rather than by construction. This file is the one source for\n * every package that can take a build-time import — `@verajs/shared-utils` is private and inlined,\n * so importing it costs a consumer nothing at runtime and adds no published dependency.\n *\n * **`@verajs/ssr` cannot import it** and keeps its own copies: that package publishes its `src`\n * with no dependencies at all, so an import of a package that is never published would break the\n * published tarball. The same constraint already forced a twin of `escapeStyleText` there. A copy\n * is acceptable; a copy nothing checks is not, so `tests/markup-grammar-homes.test.mjs` drives\n * every copy against this file source-to-source rather than trusting they get edited together.\n *\n * **A consumer may keep a different SHAPE for the same fact** where a hot path needs one — the\n * renderer matches raw-text tags with a case-insensitive regex rather than lowercasing a string to\n * probe a `Set`. The rule is agreement, not representation, and the homes test asserts agreement\n * across whatever shape each home uses.\n */\n\n/**\n * Elements with no end tag, and therefore no children.\n *\n * Both directions of getting this wrong are silent, and both were live in this repo until the\n * audit of 2026-09-12 measured them:\n *\n * - **A non-void element written self-closing swallows what follows it.** HTML has no\n * self-closing syntax outside foreign content, so `<div/><span>after</span>` parses as\n * `<div><span>after</span></div>` — the sibling becomes a child. Every JSX toolchain treats\n * `<div/>` as an empty element, which is exactly why authors write it.\n * - **A void element written with an end tag is duplicated.** A parser reads `</br>` as *another*\n * `<br>`, so `<br></br>` renders two line breaks where the author wrote one.\n *\n * Inside `<svg>` and `<math>` the parser switches to foreign content, where XML self-closing *is*\n * honored — so neither rule applies there, and a consumer that checks must know where it is.\n */\nexport const VOID_ELEMENTS = new Set([\n 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',\n 'link', 'meta', 'param', 'source', 'track', 'wbr',\n]);\n\n/**\n * Elements a parser reads the children of as text rather than as markup.\n *\n * Two pieces of measured lore travel with this list and are the reason it is not read off a spec:\n *\n * - `iframe` and `noscript` were once absent from the SSR copy, which built a tree no browser\n * builds — `<noscript><img src=\"x\"></noscript>` produced an element, so\n * `querySelectorAll('noscript img')` answered 1 where every engine answers 0.\n * - `noscript` is raw text only when scripting is ENABLED. Fragment parsing disables it, and\n * Chromium and WebKit then parse the content as markup while Firefox parses it as text — so a\n * binding inside `<noscript>` worked in two engines and painted the renderer's internal marker\n * onto the page in the third. Listing it is safe in both parses.\n *\n * jsdom is not the oracle for either: it parses with scripting disabled and agrees with the old,\n * wrong list.\n */\nexport const RAW_TEXT_ELEMENTS = new Set(['style', 'script', 'textarea', 'title', 'iframe', 'noscript']);\n\n/**\n * The hyphenated names SVG and MathML already define, which the custom-elements spec reserves — so a\n * dash in one of these does NOT make it a custom element.\n *\n * Measured, the one that matters: JSX treats a dash-named tag as a custom element and compiles its\n * attributes to PROPERTIES, which turned `<annotation-xml encoding=\"text/html\">` into\n * `.encoding=${…}`. The HTML parser decides that element is an integration point from the\n * ATTRIBUTE on its start tag, so HTML content inside was moved out of the `<math>` entirely, and a\n * custom element there was built MathML-namespaced and never upgraded — silent on the server and\n * the client alike. That is also the exact spelling the renderer's own warning recommends.\n */\nexport const RESERVED_ELEMENT_NAMES = new Set([\n 'annotation-xml', 'color-profile', 'font-face', 'font-face-src',\n 'font-face-uri', 'font-face-format', 'font-face-name', 'missing-glyph',\n]);\n\n/**\n * **A custom element, by its name:** a dash, except the eight names SVG and MathML already own (above). One\n * definition for every package that asks — `@verajs/jsx` compiles such a tag's attributes to properties, and\n * `@verajs/renderer/slots` captures such a host's children. (The renderer's own property paths ask a narrower\n * question, the bare dash, on its hot path; a reserved name never carries a property binding.)\n */\nexport const isCustomElementName = (tag: string): boolean =>\n tag.includes('-') && !RESERVED_ELEMENT_NAMES.has(tag.toLowerCase());\n\n/**\n * A URL whose scheme a browser reads as `javascript:` — navigating to one runs it, so a BOUND value\n * that parses this way is code arriving as data, never a link.\n *\n * Matched the way the URL Standard's parser reads a scheme, because that is the only reading that\n * matters: leading C0 controls and spaces are stripped, ASCII tab, LF and CR are removed anywhere, and\n * the scheme is case-insensitive. A check that only lowercases is bypassed by `\" jAvA\\tscript:\"`,\n * which every engine navigates to. React's blocking pattern is the same rule.\n *\n * `@verajs/ssr` keeps a twin (it cannot import this package), held to this one by\n * `tests/url-sinks.test.mjs`, so a server never emits a link the client refuses.\n */\n// eslint-disable-next-line no-control-regex\nexport const SCRIPT_URL = /^[\\u0000- ]*j[\\t\\n\\r]*a[\\t\\n\\r]*v[\\t\\n\\r]*a[\\t\\n\\r]*s[\\t\\n\\r]*c[\\t\\n\\r]*r[\\t\\n\\r]*i[\\t\\n\\r]*p[\\t\\n\\r]*t[\\t\\n\\r]*:/i;\n\n/**\n * **Every bound name whose value is checked for a `javascript:` URL — and how.** One test answers both.\n *\n * Captured, checked from the start: the attributes (and their reflecting properties) whose value a browser\n * NAVIGATES to or loads as a document — links and areas (`href`, SVG's `xlink:href`), forms (`action`,\n * `formaction`), frames (`src`), and `<object data>`. `src` is matched on every element — refusing one on an `<img>`\n * costs nothing, since an image never runs it. Resource-only attributes (`poster`, `srcset`) are fetched, never run,\n * so they are not listed.\n *\n * Not captured, checked ITEM BY ITEM (`SCRIPT_URL_ITEM`): an SVG animation's values — `to`, `from`, `by`, `values`.\n * `<animate attributeName=\"href\" to=\"javascript:…\">` (or `<set>`, or `values`) writes its value onto the link it\n * animates, and clicking the link then RUNS it: measured 2026-09-30 in Chromium, Firefox and WebKit, through `href`\n * and `xlink:href` alike. Refused on EVERY element and whatever `attributeName` says, because `attributeName` can\n * itself be bound or spread, a server spread has no element to ask, and no legitimate value of any attribute by these\n * names starts with `javascript:` (a component's `to`, a router link's, is a URL too). **Only these names are checked\n * item by item**: an unanchored test scans the whole value for `;`, which on a bound `src` holding a data URI costs\n * ~0.45 ms per MB per update in Chromium and Firefox (measured 2026-09-30), where the anchored `SCRIPT_URL` stops at\n * the first character.\n *\n * Case-insensitive, because property spellings (`formAction`) and attribute spellings meet here. `@verajs/ssr` keeps\n * a twin, held to this one by `tests/url-sinks.test.mjs`.\n */\nexport const URL_SINK = /^(?:(href|src|action|formaction|xlink:href|data)|to|from|by|values)$/i;\n\n/**\n * `SCRIPT_URL` at the start of the value OR of any `;`-separated item of it — an animation's `values` list\n * (`\"#a;javascript:…\"`) applies every item in turn. Only for an animation's values (`URL_SINK`'s uncaptured names): a `;` inside an `href` is a path\n * character, and `/p;javascript:x` is a working link, never a script. Written out rather than derived from\n * `SCRIPT_URL`: the repeated text costs less gzipped than the code that would build it.\n */\n// eslint-disable-next-line no-control-regex\nexport const SCRIPT_URL_ITEM = /(?:^|;)[\\u0000- ]*j[\\t\\n\\r]*a[\\t\\n\\r]*v[\\t\\n\\r]*a[\\t\\n\\r]*s[\\t\\n\\r]*c[\\t\\n\\r]*r[\\t\\n\\r]*i[\\t\\n\\r]*p[\\t\\n\\r]*t[\\t\\n\\r]*:/i;\n\n/**\n * **An inline event-handler attribute** — `on` and a letter, any case (`onclick`, `onLoad`, `onbeforeinput`): its\n * value is run as CODE, so a BOUND one is code arriving as data, refused by the template scanner, `spread` and the\n * server alike (a static `onclick=\"save()\"` is the author's own and untouched). Broad on purpose — it also refuses a\n * bound `once=`/`online=` attribute; the precise rule would need the platform's list of handler names. `@verajs/ssr`\n * keeps a twin, held to this one by `tests/inline-handlers.test.mjs`.\n */\nexport const INLINE_HANDLER = /^on./i;\n\n/**\n * **A `<script>` that is a JSON data block, by its `type`** (Brian, 2026-11-17): the only script a value may enter (state\n * handoff, JSON-LD); every other script hole is refused (`script-hole`), since a value there is code — run on a page the\n * server rendered. \"The type ends in `json`\" never names a script that runs — measured on Chromium, Firefox and WebKit,\n * parameters included (`text/javascript; x=json` is inert), as the spec reads a type (a JavaScript MIME essence match on\n * the whole string); `type=\"\"` and a `language` attribute alone do run, and end in no `json`.\n */\nexport const JSON_BLOCK = /json\\s*$/i;\n\n/**\n * Whether a script START TAG, as written, opens a JSON data block: its attributes read IN ORDER (so a `type=` inside\n * another attribute's quoted value is never taken for the type), the first `type` as the parser keeps it, and that value\n * holding no `&` (a character reference is refused rather than decoded — a decoder slightly off would make the server\n * and the client disagree) and ending in `json` (`JSON_BLOCK`). Every side applies it to the start tag that OPENED the\n * script a hole sits in — recorded where the scanner enters raw text, never found by searching back (a `<script…>`\n * inside a script's own text is no start tag). `@verajs/ssr` holds a twin, held equal by a test.\n */\nexport const dataBlock = (openTag: string) => {\n for (const [, name, double, single, bare] of openTag.slice(7).matchAll(/[\\s/]*([^\\s\"'>/=]+)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s>]*)))?/g))\n if (name!.toLowerCase() === 'type') {\n const type = double ?? single ?? bare ?? '';\n return !type.includes('&') && JSON_BLOCK.test(type);\n }\n return false;\n};\n\n/**\n * **A raw-text element's composed text, unable to end its element** — the rule every side writes, byte for byte (the\n * server's `styleHole` and JSON rule, the renderer, hydration's comparison, lite, static): in a style each `</style`\n * (any case) as `<\\/style` (the same CSS), in a JSON data block every `<` as `\\u003c` (the same JSON). A style's or a\n * JSON block's text is serialized VERBATIM (BROWSER-LEDGER), so written as composed, a value became markup once the page\n * was saved from the DOM and parsed again. Applied to the COMPOSED text: a closer can form across a hole. Idempotent —\n * neither form leaves what it replaces.\n */\nexport const closedRawText = (text: string, json: boolean) =>\n json ? text.replace(/</g, '\\\\u003c') : text.replace(/<\\/(style)/gi, '<\\\\/$1');\n\n/**\n * **A value as inert text in ANY position** — every ASCII non-word character as a character reference (`<` `<`,\n * a space ` `, `=` `=`), everything else as it is: the encoding `@verajs/static` writes every value with, and the\n * renderer writes a never-shown element's values with. Read as raw text it holds no `<`; read as markup it decodes to\n * the same characters and cannot end a tag, a quoted or unquoted attribute value, or the element.\n */\nexport const encodeText = (text: string) => text.replace(/[^\\w\\u0080-\\uffff]/g, (c) => `&#${c.charCodeAt(0)};`);\n\n/**\n * **The properties that replace an element's whole content** — a binding to one owns the element's children, so it\n * cannot share the element with content of its own (markup, or a child binding the write would strand: a later commit\n * into it then throws on a missing parent). Development refuses the pair in the template scanner and in `spread` alike.\n */\nexport const CONTENT_PROPERTY = /^(?:textContent|innerHTML|innerText|outerHTML|outerText)$/;\n/**\n * Whether an element has content of its own that a content-replacing write would strand or lose: a child that is not\n * whitespace-only text (formatting whitespace loses nothing), or — `$content`, set in development by the renderer — a\n * child binding that owns the element whole and leaves no node behind until it commits. The element-specific `.text`\n * setters (`<a>`, `<option>`, `<title>`, `<script>`) are deliberately not in the list: a custom element's own `text`\n * prop is common, and would be refused for nothing.\n */\nexport const ownsContent = (element: Element): boolean => {\n if ((element as Element & { $content?: boolean }).$content === true) return true;\n for (let node = element.firstChild; node !== null; node = node.nextSibling)\n /**\n * An EMPTY text node is a child binding's anchor, not formatting: formatting whitespace is never empty. And\n * formatting is HTML's whitespace, `[ \\t\\n\\f\\r]` — not JS's `trim()`, which would let an ` ` be overwritten.\n */\n if (node.nodeType !== 3 || (node as Text).data === '' || /[^ \\t\\n\\f\\r]/.test((node as Text).data)) return true;\n return false;\n};\n/** `side` is the module the user wired — `renderer` for a template, `spread` for a spread. */\nexport const contentClash = (side: string, tag: string, name: string): never => {\n throw new Error(misuse(side, 'content-clash', __DEV__ && SHARED.contentClash(tag, name, side === 'spread' ? `<${tag} \\${spread({ '.${name}': … })}></${tag}>` : `<${tag} .${name}=\\${…}></${tag}>`)));\n};\n\n/**\n * **An expression in TAG-name position** (`<${x}>`, `</${x}>`, `<my-${x}>`) without `@verajs/renderer/tag`: no\n * element can be made from it — the parser reads a tag name before any value exists. Refused by the client in\n * development and by the server in every build, with one message. The tag entry splices a tag VALUE into the\n * statics before the renderer sees it, so only a non-tag ever reaches here.\n */\nexport const TAG_NAME_HOLE = /<\\/?[^\\s>]*$/;\nexport const tagHole = (side: string): never => {\n throw new Error(misuse(side, 'tag-hole', __DEV__ && SHARED.tagHole()));\n};\n","import type { HandlerHolder, Untracked } from './types.js';\nimport { diagnostic } from './diagnostic.js';\nimport * as SHARED from './diagnostics.js';\n\n/**\n * Get an object's type.\n *\n * @param obj The object\n * @return The type\n */\nexport const getType = (obj: unknown) => Object.prototype.toString.call(obj).slice(8, -1).toLowerCase();\n\n/**\n * Weak collections need their per-key dependencies stored weakly, or tracking `weakMap.get(obj)`\n * holds `obj` and defeats the whole point of the type. Checked by type string rather than\n * `instanceof`, which fails across realms (iframes, `vm`).\n */\n/**\n * A WeakMap or WeakSet (or WeakRef) — read from `Symbol.toStringTag`, the tag `Object.prototype.toString` itself reads, so\n * the answer is the same (another realm's collections included) without building and lower-casing a string on every first\n * tracked read of every object.\n */\nexport const isWeakCollection = (item: unknown) => {\n const tag = (item as { [Symbol.toStringTag]?: unknown } | null)?.[Symbol.toStringTag];\n return typeof tag === 'string' && (tag[0] === 'W' || tag[0] === 'w');\n};\n\n/**\n * Remove a trailing slash from an url if its not root url (`/`).\n *\n * @param str String to remove trailing slash from\n */\nexport const stripTrailingSlash = (str: string) => (str !== '/' && str.endsWith('/') ? str.slice(0, -1) : str);\n\n/**\n * **Reports an error nothing else handled, the way the platform reports one.** `reportError` fires\n * the window's `error` event — what `window.onerror`, error trackers and test runners listen for —\n * without unwinding the caller, so one failing hook or ref never stops its siblings. A bare\n * `console.error` reached none of those: a component could stop updating while every page-error\n * listener stayed silent. Off-browser (Node has no `reportError`) the console is all there is.\n * `line` is the framework's own line, printed beside the error — a CODED one (2026-10-09):\n * each caller passes `'[vera] <code>'` in production and its table's `diagnostic()` sentence in development, both\n * literal codes at the call site, so the static checks read them. The subject is fixed wording too (`a hook`, `an\n * element ref`), never a tag name: this line is the console's FORMAT (no `'%s'`, which measured +2–3 B on the renderer\n * bundles), so nothing from outside may reach it — the element goes to the `'error'` handlers instead. Production prints it only where the platform has no\n * `reportError` (Node); in a browser, `reportError` alone reports.\n *\n * Shared by core (a hook threw) and the renderer (a ref threw) so the fallback is one rule.\n */\nexport const reportUncaught = (error: unknown, line: string) => {\n if (typeof reportError !== 'function') console.error(line, error);\n else {\n if (__DEV__) console.error(line, error);\n reportError(error);\n }\n};\n\n/**\n * **Reports what user code a render called threw — to the app's `'error'` chain, else as uncaught.** One rule for\n * every callback the framework runs on the user's behalf and survives: a hook (core), an element ref, and an element\n * claim's `create`/`mount`/`unmount` (the renderer). The caller catches at the call site and carries on, so one\n * failing callback never stops its siblings or leaves a commit half applied. `element` is the component the error\n * belongs to, handed to each handler. Every throw is reported — nothing is deduped, as a hook's never was.\n * **Core keeps a deliberate twin** (`reportHookError`, the same rule as a `forEach`): routed through here it measured\n * +11 B gzip on `vera.min.js` (2026-10-09). A change to the rule changes both.\n */\nexport const reportTo = (handlers: readonly unknown[] | undefined, error: unknown, element: Element | undefined, line: string) => {\n if (handlers?.length) for (const handler of handlers) (handler as (error: unknown, element?: Element) => void)(error, element);\n else reportUncaught(error, line);\n};\n\n/** The component a render root belongs to: a shadow root's host, or a light root itself. */\nexport const hostOf = (root: Node | null | undefined): Element | undefined =>\n root == null ? undefined : root.nodeType === 11 ? (root as ShadowRoot).host : (root as Element);\n\n/** `fn(a, b, c)`, tracked as the caller is — the stand-in for core's `untracked` when no core was wired. */\nexport const call: Untracked = (fn, a, b, c) => fn(a!, b!, c!);\n\n/**\n * **Runs a bound handler, and its callers run it UNTRACKED**: the renderer's template `@event` and spread's event key,\n * each through `untracked(dispatch, holder, event)` (2026-10-09). An effect that fires an event synchronously\n * (`el.click()`, `focus()`, `dispatchEvent`) runs the handler INSIDE itself, and the handler's reads subscribed the\n * effect: a handler doing `state.n++` made the effect re-run on every click, a self-feeding loop held to one round per\n * frame, forever (measured). A handler's reads are event-time decisions, never a hook's inputs. The directives engine's\n * delegated `listen` makes the same choice its own way. A function is called with the element as `this`; an object\n * through its `handleEvent`. One function for both callers (Brian's size-audit ruling, 2026-11-13): it was two\n * identical copies, so a fix had two addresses; each bundle still inlines its own.\n */\nexport const dispatch = (holder: HandlerHolder, event: Event) => {\n const handler = holder._handler as EventListener | EventListenerObject | null;\n if (typeof handler === 'function') handler.call(holder._element as never, event);\n else if (typeof handler?.handleEvent === 'function') handler.handleEvent(event);\n};\n\n/**\n * **Whether a property binding is a `<select>`'s SELECTION** — `value` or `selectedIndex` — which the renderer and\n * `spread` both treat as live: re-asserted every render and compared against the live value (as `!value` is), because\n * a select's options can be replaced under an unchanged value, which drops the selection. One rule, asked once per\n * binding by both, so a template and a spread key cannot disagree about it.\n *\n * In development it names the one shape it cannot serve: on a `<select multiple>` both properties read and set a\n * SINGLE selection, so a selection the user adds is kept rather than controlled. Always writing there was measured\n * 2–3% slower on every table with a select per row, to serve an API that does not fit — hence a warning, not a cost.\n */\nexport const isSelection = (element: Element, name: unknown) => {\n if ((name !== 'value' && name !== 'selectedIndex') || element.localName !== 'select') return false;\n return true;\n};\n\n/**\n * Development: the one shape a selection binding cannot serve, named by the module the user wired (`side`). Called only\n * behind `__DEV__` at each call site, so production keeps `isSelection` exactly as small as it was (a `side` argument on\n * it measured +1 B, a default +9 B on vera-renderer.min.js — 2026-10-09).\n */\nexport const saySelectMultiple = (element: Element, name: unknown, side: string) => {\n if (element.hasAttribute('multiple'))\n console.warn(diagnostic(side, '<select multiple>', 'select-multiple', __DEV__ && SHARED.selectMultiple(String(name))));\n};\n\n/**\n * `target[key]`, as a function — how a component's GETTER is read through `untracked`. Not `Reflect.get`: `untracked`\n * passes three arguments, and `Reflect.get`'s third is the RECEIVER — `undefined` there runs the getter with no `this`.\n */\nexport const read = (target: object, key: string) => (target as Record<string, unknown>)[key];\n\n/**\n * **What a thrown value says, whatever was thrown — and it never throws itself.** A caught value comes from author\n * code (a `resolve` option, a motion tick or vocabulary function), and JavaScript can throw anything: `null`, an object\n * with no prototype (`String()` finds no `toString`), one whose `toString` or `message` getter throws, a Proxy whose\n * traps throw. Formatting it naively replaced the real failure with an unrelated TypeError from inside the framework.\n * Anything unreadable becomes a fixed phrase; `Object.prototype.toString` is no fallback, since it reads\n * `Symbol.toStringTag` through a Proxy's trap too.\n *\n * **A deliberate duplicate of `thrownMessage` in `packages/ssr/src/vera/escaping.ts` — fix both copies.** `@verajs/ssr`\n * is compiled per file with no bundling, so it cannot import this private, unpublished package at run time;\n * `tests/thrown-message-copies.test.mjs` runs one table of thrown values against both, so they cannot drift.\n */\nexport const thrownMessage = (error: unknown): string => {\n try {\n if (error instanceof Error) return String(error.message);\n const message = (error as { message?: unknown } | null)?.message;\n return typeof message === 'string' ? message : String(error);\n } catch {\n return '[unprintable value thrown]';\n }\n};\n\n/** `data-tone` → `dataTone`: the prop an observed attribute arrives as, in every package that defines components (`@verajs/core`'s `define`, its checks, `@verajs/lite`). */\nexport const camel = (name: string) => name.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase());\n","/**\n * `<div ${spread(props)}>` — bindings whose NAMES are not known when the template is parsed.\n *\n * Ships separately: the renderer holds one property read (a value at element position carrying\n * `_$apply$` applies itself), so an app that never spreads pays only that. This entry imports nothing\n * from the renderer and reaches it only through that protocol, so it works beside any renderer entry.\n *\n * **One key, one rule, decided once.** A key's kind and name follow the renderer's template sigils\n * exactly (`.prop`, `?bool`, `@event`, `&ref`, `!live`, `onClick`), and its verdict — including every\n * refusal — is decided when its binding is first created, never again per render. The rules are\n * repeated rather than imported from the renderer (the bundles cannot share state);\n * `tests/spread-written-parity.test.mjs` drives both spellings against each other.\n *\n * **Security: spread is where the template security model would break**, because its names arrive at\n * runtime, often from data, and are neither greppable nor reviewable. So it refuses, on the client and\n * in the server half (`_$attrs$`) alike: `.innerHTML`/`.outerHTML` (and `!`), `.__proto__`, the `srcdoc`\n * attribute, inline-handler attributes (`onclick` in any casing — `on` + Capital is the event spelling\n * and still works), names that cannot survive markup, and — as the renderer does — a `javascript:` URL\n * where a browser navigates.\n */\nimport { adoptProperty, call, CONTENT_PROPERTY, dispatch, contentClash, INLINE_HANDLER, ownsContent, isSelection, read, saySelectMultiple, SCRIPT_URL, SCRIPT_URL_ITEM, URL_SINK, diagnostic, SHARED } from '@verajs/shared-utils';\nimport type { Untracked } from '@verajs/shared-utils';\nimport { attributeValueKind } from './dev-values.js';\nimport { PROSE } from './spread-diagnostics.js';\n\nconst ATTR = 0;\nconst PROPERTY = 1;\nconst BOOLEAN = 2;\n/** `!name` — a property compared against the live DOM rather than against what this last wrote. */\nconst LIVE = 3;\nconst EVENT = 4;\nconst REF = 5;\nconst REFUSED = 6;\n\n/**\n * A name that cannot be written into a tag: the HTML attribute-name restriction (control characters,\n * whitespace, `\"`, `'`, `>`, `/`, `=`) plus `<` and a backtick — refused identically on both sides, so a\n * key cannot work here and vanish server-side. Skipped, never thrown: one bad key must not cost a render.\n */\n// eslint-disable-next-line no-control-regex\nconst UNSAFE_NAME = /^$|[\\s\"'>/=<`]|[\\u0000-\\u001f\\u007f]/;\n\n/** Development only: why a key was refused, by refusal code. */\n\n/**\n * A key's kind and name, and — for a refused key — why (`[REFUSED, code]`). The twin of the renderer's\n * template construction; a refused key's verdict never changes, so it is decided once per binding.\n */\nconst resolve = (key: string): [number, string | number] => {\n const first = key[0];\n let kind = first === '.' ? PROPERTY : first === '?' ? BOOLEAN : first === '@' ? EVENT : first === '&' ? REF : first === '!' ? LIVE : ATTR;\n let name = kind === ATTR ? key : key.slice(1);\n if (kind === ATTR && /^on[A-Z]/.test(key)) {\n kind = EVENT;\n name = key.slice(2).toLowerCase();\n }\n const property = kind === PROPERTY || kind === LIVE;\n const refusal = UNSAFE_NAME.test(name)\n ? 1\n : property && (name === 'innerHTML' || name === 'outerHTML')\n ? 2\n : property && name === '__proto__'\n ? 3\n : kind === ATTR && name.toLowerCase() === 'srcdoc'\n ? 4\n : kind === ATTR && INLINE_HANDLER.test(name)\n ? 5\n : 0;\n return refusal ? [REFUSED, refusal] : [kind, name];\n};\n\n/**\n * How a key names a URL a browser navigates to — the renderer's rule, by the same numbers: 0 not one; 1 a custom\n * element's property — often an object (`.data=${rows}`), so only a string is checked and nothing is converted; 2\n * converted ONCE, and that string checked and written (so a `toString` that answers differently each time cannot pass\n * the check as one URL and be written as another); 3 an animation's value (`to`, `values`…), converted once and\n * checked item by item. A refused key needs no case: its name is a refusal code, which no URL\n * attribute name matches.\n */\nconst urlRule = (kind: number, name: string, custom: boolean) => {\n const sink = URL_SINK.exec(name);\n return kind === BOOLEAN || kind === EVENT || kind === REF || sink === null ? 0 : kind !== ATTR && custom ? 1 : sink[1] ? 2 : 3;\n};\n\n/** What `checked` answers for a `javascript:` URL where the rule looks. */\nconst REFUSE = {};\n\n/** `value` as it is checked AND written under `rule` — converted once, or left as it is — or `REFUSE`. */\nconst checked = (rule: number, value: unknown) => {\n if (rule > 1 && value != null && typeof value !== 'string') value = `${value}`;\n return rule !== 0 && typeof value === 'string' && (rule === 3 ? SCRIPT_URL_ITEM : SCRIPT_URL).test(value) ? REFUSE : value;\n};\n\nconst UNSET = {};\n\n/** One key's binding on one element. It is also the `@event` listener — a stable object, so the platform dedupes re-adds. */\nclass Binding {\n _kind: number;\n _name: string;\n _element: Element;\n /** What the element held before the bag first wrote this key — restored when the key leaves the bag. */\n _initial: unknown = null;\n _committed: unknown = UNSET;\n _handler: unknown = null;\n /** For `.prop`: where adoption stands (`adoptProperty`: 0 still adopting, 1 received, 2 refused). */\n _state = 1;\n /** How this key is checked as a URL (`urlRule`) — decided once, with the element in hand. */\n _url: number;\n /**\n * On a custom element, a property read is the component's GETTER, so it goes through the `untracked` this binding was\n * created with; `null` on a built-in element, whose getters read no state. Decided once.\n */\n _read: Untracked | null;\n constructor(element: Element, key: string, untracked: Untracked) {\n const [resolved, name] = resolve(key);\n /** A `<select>`'s selection is live, as in a template — the same rule, asked of the same function. */\n const kind = (resolved === PROPERTY || resolved === LIVE) && isSelection(element, name) ? LIVE : resolved;\n if (__DEV__ && (resolved === PROPERTY || resolved === LIVE) && isSelection(element, name)) saySelectMultiple(element, name, 'spread');\n this._kind = kind;\n this._name = name as string;\n this._element = element;\n const custom = element.localName.includes('-');\n /** Core's `untracked` for a custom element's getter reads, and for an event key's handler (`dispatch`). */\n this._read = custom || kind === EVENT ? untracked : null;\n this._url = urlRule(kind, name as string, custom);\n /** A content-replacing property beside content of the element's own: development refuses it, as a template does. */\n if (__DEV__ && (kind === PROPERTY || kind === LIVE) && CONTENT_PROPERTY.test(name as string) && ownsContent(element))\n contentClash('spread', element.localName, name as string);\n if (kind === REFUSED) {\n if (__DEV__) {\n /** Each refusal written out, so the manifest (`diagnostics-tables`) reads every raise from the source. */\n const at = `<${element.localName}>`;\n const written = JSON.stringify(key);\n const why = name as number;\n if (why === 1) console.warn(diagnostic('spread', at, 'spread-unsafe-name', __DEV__ && PROSE['spread-unsafe-name'](written)));\n else if (why === 2) console.warn(diagnostic('spread', at, 'spread-inner-html', __DEV__ && PROSE['spread-inner-html'](written)));\n else if (why === 3) console.warn(diagnostic('spread', at, 'proto-binding', __DEV__ && SHARED.protoBinding(written)));\n else if (why === 4) console.warn(diagnostic('spread', at, 'srcdoc-attribute', __DEV__ && SHARED.srcdocAttribute(\"'.srcdoc': trusted\")));\n else\n console.warn(\n diagnostic('spread', at, 'handler-attribute',\n __DEV__ && SHARED.handlerAttribute(key, `\\`'@${key.slice(2).toLowerCase()}': fn\\` (or \\`on${key.slice(2, 3).toUpperCase()}${key.slice(3)}\\`)`))\n );\n }\n return;\n }\n if (kind === ATTR) this._initial = element.getAttribute(name as string);\n else if (kind === BOOLEAN) this._initial = element.hasAttribute(name as string);\n /** On a custom element this is the component's getter, run on the parent's behalf: read through `untracked`. */\n else if (kind === PROPERTY || kind === LIVE)\n this._initial = custom ? untracked(read, element, name as string) : (element as unknown as Record<string, unknown>)[name as string];\n if (kind === PROPERTY && custom) this._state = 0;\n }\n /** Runs the handler UNTRACKED (shared-utils' `dispatch`): `_read` holds core's `untracked` for an event key too. */\n handleEvent(event: Event) {\n (this._read ?? call)(dispatch, this, event);\n }\n}\n\nconst write = (binding: Binding, given: unknown, adopting?: boolean) => {\n const kind = binding._kind;\n const value = checked(binding._url, given);\n const name = binding._name;\n /** One variable, typed for both uses: a cast alias survives minification as a second variable. */\n const element = binding._element as Element & Record<string, unknown>;\n if (kind === REFUSED) return;\n /**\n * **Adopting server markup** (hydration hands this in): a built-in control's state — `value`, `checked`, `selected`,\n * `open`, by `.name` or `!name` — is RECORDED, not written: the server's default, and anything the user changed before\n * the script arrived, stand, exactly as for a written binding (hydration's `FORM_STATE`, the same list — keep them\n * equal). Any other name is written, and a component's property is always delivered.\n */\n if (adopting && binding._read === null && (kind === LIVE || kind === PROPERTY) && /^(?:value|checked|selected|open)$/.test(name as string)) {\n binding._committed = value;\n return;\n }\n if (value === REFUSE) {\n if (__DEV__ && given !== binding._committed)\n console.warn(diagnostic('spread', `<${element.localName}>`, 'script-url', __DEV__ && SHARED.scriptUrl(name)));\n binding._committed = given;\n element.removeAttribute(name);\n return;\n }\n if (kind === LIVE) {\n binding._committed = value;\n /**\n * A built-in is compared against its live property. A COMPONENT is compared against its current value — the raw one\n * its store holds (`_$raw$`) for a name it received, else read through `untracked` — and receives a difference\n * through `adoptProperty`. Inline, as the renderer's `commit` reads a template's `!name`: keep the two equal.\n */\n if (binding._read === null) {\n if (element[name] !== value) element[name] = value;\n } else {\n const raw = element._$raw$ as Record<string, unknown> | undefined;\n if ((raw !== undefined && name in raw ? raw[name] : binding._read(read, element, name)) !== value) adoptProperty(element, name, value);\n }\n return;\n }\n if (value === binding._committed) return;\n binding._committed = value;\n if (kind === ATTR) {\n if (value == null) element.removeAttribute(name);\n else {\n if (__DEV__) {\n const kind = attributeValueKind(element.localName, name, value);\n if (kind !== null) console.warn(diagnostic('spread', `<${element.localName}>`, 'attribute-value', __DEV__ && SHARED.attributeValue(name, kind, `'.${name}': value`)));\n }\n element.setAttribute(name, `${value}`);\n }\n } else if (kind === PROPERTY) {\n if (binding._state === 1) element[name] = value;\n else if (binding._state === 0) binding._state = adoptProperty(element, name, value);\n } else if (kind === BOOLEAN) element.toggleAttribute(name, !!value);\n else if (kind === REF) {\n if (typeof value === 'function') (value as (element: Element) => void)(element);\n else if (value !== null && typeof value === 'object') (value as { value: unknown }).value = element;\n } else {\n if (__DEV__ && value != null && value !== false && typeof value !== 'function' &&\n typeof (value as EventListenerObject)?.handleEvent !== 'function')\n console.warn(diagnostic('spread', `<${element.localName}>`, 'not-a-listener', __DEV__ && SHARED.notAListener(name, typeof value)));\n if (binding._handler === null && value != null) element.addEventListener(name, binding);\n binding._handler = value ?? null;\n }\n};\n\n/**\n * Each binding is owned by the renderer's binding record it arrived through (the `key`), so one element can\n * carry several spreads. A key that leaves the bag is written back to what the element held before.\n */\nconst owned = new WeakMap<object, Map<string, Binding>>();\n/**\n * `untracked` is `_$apply$`'s third argument — core's, through the renderer; `call` when a renderer leaves it out.\n * Each binding keeps the one it was CREATED with, so nothing about it is paid per render, and an apply nested inside\n * another (a component setter rendering a spread) can never change what the outer's bindings use.\n */\nfunction apply(this: SpreadResult, element: Element, key: object, untracked: Untracked = call, adopting = false) {\n const props = this._props;\n let bindings = owned.get(key);\n if (bindings === undefined) owned.set(key, (bindings = new Map()));\n let count = 0;\n for (const name in props) {\n count++;\n let binding = bindings.get(name);\n if (binding === undefined) bindings.set(name, (binding = new Binding(element, name, untracked)));\n write(binding, props[name], adopting);\n }\n if (bindings.size !== count)\n for (const [name, binding] of bindings)\n if (!(name in props)) {\n bindings.delete(name);\n write(binding, binding._initial);\n }\n}\n\n/**\n * The server half of the protocol: `[kind, name, value]` for each key `@verajs/ssr` should serialize —\n * `a`ttribute, `b`oolean, `p`roperty, `e`vent, `r`ef — with every refusal and every refused URL already\n * applied, by the same `resolve` the client uses, so the two cannot disagree.\n */\nfunction attributes(this: SpreadResult): [string, string, unknown][] {\n const out: [string, string, unknown][] = [];\n for (const key in this._props) {\n const [kind, name] = resolve(key);\n /** No element here: a property key is judged as a custom element's — the server only ever delivers one to a component. */\n const rule = urlRule(kind, name as string, true);\n const value = checked(rule, this._props[key]);\n if (kind === REFUSED || value === REFUSE) continue;\n out.push([kind === ATTR ? 'a' : kind === BOOLEAN ? 'b' : kind === EVENT ? 'e' : kind === REF ? 'r' : 'p', name as string, value]);\n }\n return out;\n}\n\n/** The branded, self-applying result — what the renderer's element position recognizes. */\ntype SpreadResult = {\n _props: Record<string, unknown>;\n _$apply$: unknown;\n _$attrs$: unknown;\n};\n\n/**\n * Binds every key of `props` to the element it is placed on. Keys follow the template sigils — `.prop`,\n * `?bool`, `@event` (or `onClick`), `&ref`, `!live` — and a plain key is an attribute.\n *\n * Already-branded input is returned as-is (JSX compiles `{...spread(x)}` to a spread of a spread). A\n * value that is not a plain object is refused in BOTH builds — a string would otherwise be iterated by\n * character index into attributes named `0`, `1`, `2` — and development says so.\n */\nexport const spread = (props: object | null | undefined): SpreadResult => {\n if (props !== null && typeof props === 'object' && typeof (props as SpreadResult)._$apply$ === 'function')\n return props as SpreadResult;\n if (props === null || typeof props !== 'object' || Array.isArray(props)) {\n if (__DEV__)\n console.warn(\n diagnostic('spread', 'spread()', 'spread-not-object',\n __DEV__ && PROSE['spread-not-object'](Array.isArray(props) ? 'an array' : typeof props === 'object' ? 'null' : `a ${typeof props}`))\n );\n props = {};\n }\n return { _props: props as Record<string, unknown>, _$apply$: apply, _$attrs$: attributes };\n};\n\n/** Every key as a property: `props({ items })` is `spread({ '.items': items })` — how a component receives data. */\nexport const props = <T extends object = Record<string, unknown>>(values: Partial<T>): SpreadResult => {\n const sigiled: Record<string, unknown> = {};\n for (const key of Object.keys(values)) sigiled[`.${key}`] = (values as Record<string, unknown>)[key];\n return spread(sigiled);\n};\n"],"names":["adoptProperty","element","name","value","adopt","_$adopt$","carrier","Object","getPrototypeOf","desc","getOwnPropertyDescriptor","undefined","set","get","call","_$props$","view","ownerDocument","defaultView","HTMLElement","prototype","SCRIPT_URL","URL_SINK","SCRIPT_URL_ITEM","INLINE_HANDLER","fn","a","b","c","dispatch","holder","event","handler","_handler","_element","handleEvent","read","target","key","UNSAFE_NAME","resolve","first","kind","slice","test","toLowerCase","property","refusal","urlRule","custom","sink","exec","REFUSE","checked","rule","UNSET","Binding","_kind","_name","_initial","_committed","_state","_url","_read","constructor","untracked","resolved","localName","isSelection","this","includes","getAttribute","hasAttribute","write","binding","given","adopting","removeAttribute","setAttribute","toggleAttribute","addEventListener","raw","_$raw$","owned","WeakMap","apply","props","_props","bindings","Map","count","size","delete","attributes","out","push","spread","_$apply$","Array","isArray","_$attrs$","values","sigiled","keys"],"mappings":"AAgCO,MAAMA,EAAgB,CAACC,EAAuBC,EAAcC,KAOjE,GAAa,cAATD,EAAsB,OAAO,EACjC,MAAME,EAAQH,EAAQI,SAEtB,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