@verajs/lite 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1746 @@
1
+ /**
2
+ * **Where every diagnostic code is explained.** The URL is permanent: a released bundle is immutable, so every version
3
+ * published points here for ever — the domain cannot lapse and `/e/` cannot be reorganized without breaking links in
4
+ * code nobody can edit; the docs site redirects instead. `scripts/sync-diagnostics.mjs` imports this constant, so the
5
+ * pages and the bundles can never disagree about where they are.
6
+ */
7
+ const DOCS = 'https://verajs.dev/e/';
8
+ /**
9
+ * **What this copy of the framework has already said** (Brian's ruling, 2026-11-12): the ONE memory behind `warnOnce`, `errorOnce`
10
+ * and `hasWarned`, for DEVELOPMENT-ONLY warnings. It replaced the hand-written once-flags every package kept
11
+ * (`saidLists`, `warnedDrop`, per-element WeakSets, per-key Sets: two naming styles, Brian: no names). **A warning that
12
+ * ships to production keeps its memory at its site** (bytes, measured 2026-11-12: the shared memory costs +80–145 B gz
13
+ * per bundle); development-only warnings use warnOnce. Module state by necessity, since "once" spans every call on the
14
+ * page. One per BUNDLE COPY, exactly the scope each flag had, because this package is inlined into every bundle.
15
+ * A code, or `code key` for a string key, in a Set. An object key (an element, a setup function) in a WeakMap, so its
16
+ * entry goes with the object. Marked pure, so a bundle that never prints once drops both.
17
+ */
18
+ const printed = /* @__PURE__ */ new Set();
19
+ const printedOn = /* @__PURE__ */ new WeakMap();
20
+ /** Where an object key's (code, value) lives: the value set for that code on that object, made on demand. */
21
+ const valuesOn = (on, code, make) => {
22
+ let codes = printedOn.get(on);
23
+ if (codes === undefined) {
24
+ if (!make)
25
+ return undefined;
26
+ printedOn.set(on, (codes = new Map()));
27
+ }
28
+ let values = codes.get(code);
29
+ if (values === undefined && make)
30
+ codes.set(code, (values = new Set()));
31
+ return values;
32
+ };
33
+ /** The object and value of an object or pair key. */
34
+ const split = (key) => (Array.isArray(key) ? key : [key, undefined]);
35
+ /** Whether (code, key) is new, recording it if so. */
36
+ const firstTime = (code, key) => {
37
+ if (key === undefined || typeof key === 'string') {
38
+ const entry = key === undefined ? code : `${code} ${key}`;
39
+ if (printed.has(entry))
40
+ return false;
41
+ printed.add(entry);
42
+ return true;
43
+ }
44
+ const [on, sub] = split(key);
45
+ const values = valuesOn(on, code, true);
46
+ if (values.has(sub))
47
+ return false;
48
+ values.add(sub);
49
+ return true;
50
+ };
51
+ /**
52
+ * **One shape for every diagnostic the framework prints** — the short line production keeps, the whole sentence
53
+ * development adds — so a package converting its messages writes a table and a call, never its own format.
54
+ *
55
+ * production `[vera] hydration: element: found <i> — https://verajs.dev/e/hydration-fallback`
56
+ * development `[vera] hydration: element: found <i> — fell back to a client render: … (hydration-fallback)`
57
+ *
58
+ * `subject` is the free information — what the code already has at hand, naming the problem area — the same in both
59
+ * builds. `prose` is development only: the package's table entry (`Prose`), called behind `true ` at the call site so
60
+ * the table goes unreferenced in production and rollup drops it whole. Production prints the code inside the link, so
61
+ * the reader is one click from the explanation, which `scripts/sync-diagnostics.mjs` publishes from the same tables.
62
+ *
63
+ * **Every production message is coded** (Brian, 2026-11-11; this supersedes "convert where smaller", 2026-10-02):
64
+ * consistency over a few bytes, so no package keeps a hand-written production line beside its table.
65
+ */
66
+ /*
67
+ * The parameter names are deliberately unlike anything a caller holds: terser will not inline a function whose
68
+ * parameter shadows a name at the call site (measured 2026-10-02 — directives passes its own `code`, and a parameter
69
+ * called `code` left `((e,t,n)=>`…`)(0,t,n)` in its bundle, +8 B; renamed, the call folds to the bare template).
70
+ */
71
+ /**
72
+ * **A misused API, named by its function** — the thrown-error twin of `diagnostic()`: `untrack: expected a function …
73
+ * (untrack-not-function)`, function-first because a stack already names the source and the sweep reads that shape. The
74
+ * prose comes from a package's table, behind `true `, so a development-only guard costs production nothing.
75
+ */
76
+ const misuse = (forName, withCode, andProse) => true && andProse
77
+ ? `${forName}: ${andProse[0]}${andProse[1] ? ` ${andProse[1]}` : ''} (${withCode})`
78
+ : `${forName}: ${DOCS}${withCode}`;
79
+ const diagnostic = (inArea, bySubject, withCode, andProse) =>
80
+ /** `true ` HERE as well as at the call: production folds this to the one-line form, branch and all. */
81
+ true && andProse
82
+ ? `[vera] ${inArea}: ${bySubject} — ${andProse[0]}${andProse[1] ? ` ${andProse[1]}` : ''} (${withCode})`
83
+ : `[vera] ${inArea}: ${bySubject} — ${DOCS}${withCode}`;
84
+ /**
85
+ * **Whether this copy has already said `code` (for `key`)**: for a GUARD only, where deciding to warn costs work worth
86
+ * skipping once the warning is out (development's whole-tree walk for unwired directive attributes, an event-name
87
+ * guess over every property of an element). A site that only prints calls `warnOnce`. Asks, never records.
88
+ */
89
+ const hasWarned = (code, key) => {
90
+ if (key === undefined || typeof key === 'string')
91
+ return printed.has(key === undefined ? code : `${code} ${key}`);
92
+ const [on, sub] = split(key);
93
+ return valuesOn(on, code, false)?.has(sub) === true;
94
+ };
95
+ /**
96
+ * The printer behind both, on one level. `andDetail` is `diagnostic()`'s prose, or a function returning it where building
97
+ * the sentence costs something: it is called only the first time. `...andMore` rides beside the line behind '%s' (an
98
+ * element, a thrown error), never inside it, so text from outside cannot forge a line. The console method is read at the
99
+ * call, so a test that replaces `console.warn` sees it.
100
+ */
101
+ const sayOnce = (level) => (inArea, bySubject, withCode, andDetail, forKey, ...andMore) => {
102
+ if (!firstTime(withCode, forKey))
103
+ return;
104
+ const line = diagnostic(inArea, bySubject, withCode, typeof andDetail === 'function' ? andDetail() : andDetail);
105
+ if (andMore.length)
106
+ console[level]('%s', line, ...andMore);
107
+ else
108
+ console[level](line);
109
+ };
110
+ /**
111
+ * **A diagnostic said once per page** (per key, where one is given: a string, or an object such as the element it is
112
+ * about): `diagnostic()`'s arguments, then the key, then what rides beside the line. Coded in production exactly as
113
+ * `diagnostic()` is, because it IS `diagnostic()`. `errorOnce` is its twin on `console.error`, for a refusal a page should
114
+ * not miss.
115
+ */
116
+ const warnOnce = /* @__PURE__ */ sayOnce('warn');
117
+ const errorOnce = /* @__PURE__ */ sayOnce('error');
118
+
119
+ /**
120
+ * core's `html`/`svg`/`mathml` and the renderer's `tag` — a tagged template called as a function. The FACT is shared;
121
+ * the EXAMPLE is each emitter's: `html` writes markup, `tag` an element name — so the emitter passes it.
122
+ */
123
+ const tagCalled$1 = (tag, received, example) => [
124
+ `expected a template literal and received ${received}.`,
125
+ `It is a tagged template — write ${tag}\`${example}\`, not ${tag}('${example}').`,
126
+ ];
127
+ /**
128
+ * A template in a text-only element (`<style>`, a JSON data block, `<title>`, `<textarea>`): its content is text. Lite
129
+ * refuses it, and so does the renderer in a style or JSON block (the server: `ssr-template-in-text`); in a `<title>` or
130
+ * `<textarea>` the renderer places it, as it always has, and says so in development only. A list there is joined.
131
+ */
132
+ const templateInText = () => [
133
+ 'a template inside a text-only element (`<style>`, a JSON `<script>`, `<title>`, `<textarea>`, or never-shown content: `<noscript>`, `<iframe>`) is never shown as markup — its content is text.',
134
+ 'Render a string there; a list of strings is joined.',
135
+ ];
136
+ /** A template that ends inside a tag: the renderer refuses it in development, the lite tier in every build. */
137
+ const unfinishedTag = () => [
138
+ 'a template cannot end inside a tag — the parser drops an unfinished tag.',
139
+ 'Close the tag inside the template.',
140
+ ];
141
+ /** The renderer and spread (two bundles); @verajs/ssr refuses the same URLs silently today. */
142
+ const scriptUrl = (name) => [
143
+ `\`${name}\` was given a javascript: URL — refused, and the attribute removed.`,
144
+ 'A bound URL is data, and data must never become code.',
145
+ ];
146
+ /**
147
+ * The renderer and spread: `kind` is what the value was (dev-values' `attributeValueKind`); `property` is the
148
+ * emitter's own spelling of a property binding — a template's `.name=${value}`, a spread's `'.name': value`.
149
+ */
150
+ const attributeValue = (name, kind, property) => [
151
+ `the attribute \`${name}\` was given ${kind}. An attribute value is a string and nothing else.`,
152
+ `If the element is meant to RECEIVE this value, bind a property instead — \`${property}\` — which is how a custom element takes anything that is not text. If it is meant to be read as text, convert it where you know what it means: \`date.toISOString()\`, \`list.join(' ')\`. A Date in particular serializes with the SERVER's timezone on one side and the browser's on the other, so it will not survive hydration.`,
153
+ ];
154
+ /** The renderer and spread: `type` is the value's `typeof`. */
155
+ const notAListener = (name, type) => [
156
+ `@${name} was given ${type === 'object' ? 'an object with no handleEvent method' : `a ${type}`}, which cannot listen — the event will do nothing.`,
157
+ 'Pass a function, or an object with a handleEvent method. A missing handler is `undefined` or `false`, both of which are fine; this is neither.',
158
+ ];
159
+ /** The renderer and lite (`namespaces.ts`): an element placed where its namespace does not render. `advice` is built there. */
160
+ const wrongNamespace = (tag, built, host, advice) => [
161
+ `<${tag}> was built as ${built} and placed inside <${host}>, where it will not render.`,
162
+ advice,
163
+ ];
164
+ /** The renderer (and, ruled 2026-10-09, @verajs/ssr): data shaped like a template, not made by `html`. */
165
+ const forgedTemplate = () => [
166
+ 'is shaped like a template but was not made by html`` — rendered as text.',
167
+ 'A template from data (JSON, or html([markup])) is never markup; for trusted markup, bind it: <div .innerHTML=${markup}>.',
168
+ ];
169
+ /** The renderer and spread (two bundles; @verajs/ssr refuses the same): binding `__proto__`. */
170
+ const protoBinding = (written) => [
171
+ `binds \`${written}\`, which would replace the element's own prototype and destroy it — no property write does this, and no use of it is legitimate.`,
172
+ 'The binding is ignored.',
173
+ ];
174
+ /** The renderer and spread: a bound `srcdoc` ATTRIBUTE. `property` is the emitter's spelling of the property binding. */
175
+ const srcdocAttribute = (property) => [
176
+ 'binds the `srcdoc` attribute, which renders its value as an HTML document — refused.',
177
+ `If the markup is trusted and sanitized, bind the property: \`${property}\`.`,
178
+ ];
179
+ /** The renderer and spread: a bound inline-handler attribute (`onclick`). `event` is the emitter's event spelling(s). */
180
+ const handlerAttribute = (name, event) => [
181
+ `binds the \`${name}\` attribute, which runs its value as code — refused.`,
182
+ `Bind a function as an event instead: ${event}.`,
183
+ ];
184
+ /* ── `define`'s checks (define-checks.ts) and the setup's result: said by `@verajs/core` and `@verajs/lite` (moved from core's table, 2026-11-17) ── */
185
+ const defineAttributeReflected = (prop) => [
186
+ `observes an attribute whose prop, \`${prop}\`, is one the platform's element already REFLECTS — this tag's accessor replaces it, so setting \`el.${prop}\` no longer does what the platform's does (it no longer writes the attribute).`,
187
+ 'Observe it only if the component owns that attribute; otherwise read it in the render with `host.getAttribute(…)`.',
188
+ ];
189
+ const defineAttributeType = (prop, type) => [
190
+ `shares the prop \`${prop}\`, whose default is a ${type} — and the attribute arrives as a STRING, so the prop changes type the moment it appears.`,
191
+ 'Give the prop a string (or null) default, and convert in the render; or keep the attribute and the prop under different names.',
192
+ ];
193
+ const defineAttributes = (received) => [
194
+ `expected an array of attribute names and received ${received}.`,
195
+ "List them: `attributes: ['label', 'data-count']` — each arrives as a prop (`label`, `dataCount`).",
196
+ ];
197
+ const defineMethodAdopted = () => [
198
+ 'an `adoptedCallback` costs every element of this tag its creation (measured +7.4% on create10k), and it is installed.',
199
+ 'Keep it only if moving elements between documents needs it.',
200
+ ];
201
+ const defineMethodIgnored = (name) => [
202
+ `\`${name}\` is core's own on a define-made class, so this one is never installed (in any build).`,
203
+ name === 'constructor'
204
+ ? 'A setup is where per-instance work goes: `define(tag, (host) => { … })`.'
205
+ : 'Put connect-time work in the setup; for work on removal, a `disconnectedCallback` in methods runs as the teardown hook.',
206
+ ];
207
+ const defineMethodNotFunction = () => [
208
+ 'is not a function, so it is installed as a plain value shared by every instance — and a getter ran ONCE, here.',
209
+ 'Methods are functions; a value that changes per element is a prop (`props: { name: default }`).',
210
+ ];
211
+ const defineMethodUnobserved = () => [
212
+ 'never fires: the class observes no attributes, and it is installed anyway.',
213
+ "Declare them: `define({ tag, attributes: ['label'] }, …)` — each then arrives as a prop.",
214
+ ];
215
+ const definePropMethod = (name) => [
216
+ `\`${name}\` is also a method, and the prop wins (it is installed after the methods), in every build.`,
217
+ 'Give the method or the prop another name.',
218
+ ];
219
+ const definePropSharedDefault = () => [
220
+ 'this default is an object that cannot be copied per element (a Set, a Map, a class instance), so EVERY element of the tag shares this one — a change through one shows in all.',
221
+ 'Declare it `null` and create it in the setup (`props: { selected: null }`, then `host.selected = new Set()`), or pass it in; arrays and plain objects are copied per element.',
222
+ ];
223
+ const definePropsNotObject = (received) => [
224
+ `expected an object of names and their defaults and received ${received}, so no prop is declared.`,
225
+ "Name each prop with its default: `props: { heading: '', items: [] }`.",
226
+ ];
227
+ const defineProtoKey = (kind) => [
228
+ `is skipped, in every build: written onto the ${kind === 'prop' ? 'props record' : 'class prototype'} it would replace a prototype instead of adding a ${kind}.`,
229
+ 'Rename the key. An own `__proto__` comes from `JSON.parse` or `Object.defineProperty`, never from an object literal.',
230
+ ];
231
+ const defineSetup = (received) => [
232
+ `the second argument is the SETUP, a function, and received ${received}.`,
233
+ 'Pass the setup after the tag or the options: `define(\'x-card\', (host) => () => html`…`)`.',
234
+ ];
235
+ const defineShadows = (name) => [
236
+ `replaces the platform's \`${name}\` for every user of these elements — scripts, libraries and the browser's own callers — and it is installed.`,
237
+ 'Give it a name of its own, unless replacing the platform member is the point.',
238
+ ];
239
+ const defineTag = (received) => [
240
+ `expected a custom element name — a string with a hyphen, not at the start — and received ${received}.`,
241
+ "Name it the way the platform requires: `define('x-card', setup)` or `define({ tag: 'x-card' }, setup)`.",
242
+ ];
243
+ const defineTwice = (tag) => [
244
+ `<${tag}> is already defined; the platform refuses a second definition of a tag and throws next.`,
245
+ 'Define each tag once, at module level. A live swap of a component while developing needs the development swap module, wired before the first define.',
246
+ ];
247
+ const setupReturnedValue = (kind) => [
248
+ `its setup returned ${kind}, not a render function, so it rendered once and will never update.`,
249
+ 'Return a render function — `return () => html`…`;` — the setup runs once, the render on every change.',
250
+ ];
251
+ /**
252
+ * **A boolean at a child position renders as the WORD** — said in development by `@verajs/renderer` and `@verajs/lite`
253
+ * (moved from the renderer's table, 2026-11-19: lite says core's development diagnostics too).
254
+ */
255
+ const booleanChild = (value) => [
256
+ `a child position was given \`${value}\`, which renders as the word "${value}" — the usual cause is \`\${cond && …}\` with a false \`cond\`.`,
257
+ 'Write `${cond ? … : null}`, or `${(cond && …) || null}`; `null` and `undefined` are the values that render nothing. If you meant to display the boolean, say so with `${String(value)}` and this goes quiet.',
258
+ ];
259
+ /** **A misspelled event name** (`@clik`) — said in development by `@verajs/renderer` and `@verajs/lite` (moved 2026-11-19). */
260
+ const eventNameTypo = (name, tag, best) => [
261
+ `@${name} is not an event <${tag}> fires — did you mean @${best}? (In JSX, on${name.slice(0, 1).toUpperCase()}${name.slice(1)} compiles to @${name}.)`,
262
+ 'A custom event by this name is fine, and this is said only in development.',
263
+ ];
264
+ /**
265
+ * **A wrapper around a real template literal's strings is no template in the small tiers** — `{ strings, values }` without
266
+ * `_$litType$`, which only `@verajs/core`'s `hold` or `tag` build: a template to core, the text `[object Object]` in
267
+ * `@verajs/lite` and `@verajs/static` (Brian, 2026-11-19: a recorded difference, said in development by both).
268
+ */
269
+ const templateWrapper = () => [
270
+ "an object holding a real template literal's `strings` but no `_$litType$` — a wrapper only `@verajs/core`'s `hold` or `tag` builds — is no template here: it renders as the text any object renders as, `[object Object]`.",
271
+ 'Render the `html` result itself; `@verajs/core` renders such a wrapper as its template.',
272
+ ];
273
+
274
+ /**
275
+ * A URL whose scheme a browser reads as `javascript:` — navigating to one runs it, so a BOUND value
276
+ * that parses this way is code arriving as data, never a link.
277
+ *
278
+ * Matched the way the URL Standard's parser reads a scheme, because that is the only reading that
279
+ * matters: leading C0 controls and spaces are stripped, ASCII tab, LF and CR are removed anywhere, and
280
+ * the scheme is case-insensitive. A check that only lowercases is bypassed by `" jAvA\tscript:"`,
281
+ * which every engine navigates to. React's blocking pattern is the same rule.
282
+ *
283
+ * `@verajs/ssr` keeps a twin (it cannot import this package), held to this one by
284
+ * `tests/url-sinks.test.mjs`, so a server never emits a link the client refuses.
285
+ */
286
+
287
+ 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;
288
+ /**
289
+ * **Every bound name whose value is checked for a `javascript:` URL — and how.** One test answers both.
290
+ *
291
+ * Captured, checked from the start: the attributes (and their reflecting properties) whose value a browser
292
+ * NAVIGATES to or loads as a document — links and areas (`href`, SVG's `xlink:href`), forms (`action`,
293
+ * `formaction`), frames (`src`), and `<object data>`. `src` is matched on every element — refusing one on an `<img>`
294
+ * costs nothing, since an image never runs it. Resource-only attributes (`poster`, `srcset`) are fetched, never run,
295
+ * so they are not listed.
296
+ *
297
+ * Not captured, checked ITEM BY ITEM (`SCRIPT_URL_ITEM`): an SVG animation's values — `to`, `from`, `by`, `values`.
298
+ * `<animate attributeName="href" to="javascript:…">` (or `<set>`, or `values`) writes its value onto the link it
299
+ * animates, and clicking the link then RUNS it: measured 2026-09-30 in Chromium, Firefox and WebKit, through `href`
300
+ * and `xlink:href` alike. Refused on EVERY element and whatever `attributeName` says, because `attributeName` can
301
+ * itself be bound or spread, a server spread has no element to ask, and no legitimate value of any attribute by these
302
+ * names starts with `javascript:` (a component's `to`, a router link's, is a URL too). **Only these names are checked
303
+ * item by item**: an unanchored test scans the whole value for `;`, which on a bound `src` holding a data URI costs
304
+ * ~0.45 ms per MB per update in Chromium and Firefox (measured 2026-09-30), where the anchored `SCRIPT_URL` stops at
305
+ * the first character.
306
+ *
307
+ * Case-insensitive, because property spellings (`formAction`) and attribute spellings meet here. `@verajs/ssr` keeps
308
+ * a twin, held to this one by `tests/url-sinks.test.mjs`.
309
+ */
310
+ const URL_SINK = /^(?:(href|src|action|formaction|xlink:href|data)|to|from|by|values)$/i;
311
+ /**
312
+ * `SCRIPT_URL` at the start of the value OR of any `;`-separated item of it — an animation's `values` list
313
+ * (`"#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
314
+ * character, and `/p;javascript:x` is a working link, never a script. Written out rather than derived from
315
+ * `SCRIPT_URL`: the repeated text costs less gzipped than the code that would build it.
316
+ */
317
+
318
+ 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;
319
+ /**
320
+ * **An inline event-handler attribute** — `on` and a letter, any case (`onclick`, `onLoad`, `onbeforeinput`): its
321
+ * value is run as CODE, so a BOUND one is code arriving as data, refused by the template scanner, `spread` and the
322
+ * server alike (a static `onclick="save()"` is the author's own and untouched). Broad on purpose — it also refuses a
323
+ * bound `once=`/`online=` attribute; the precise rule would need the platform's list of handler names. `@verajs/ssr`
324
+ * keeps a twin, held to this one by `tests/inline-handlers.test.mjs`.
325
+ */
326
+ const INLINE_HANDLER = /^on./i;
327
+ /**
328
+ * **A `<script>` that is a JSON data block, by its `type`** (Brian, 2026-11-17): the only script a value may enter (state
329
+ * handoff, JSON-LD); every other script hole is refused (`script-hole`), since a value there is code — run on a page the
330
+ * server rendered. "The type ends in `json`" never names a script that runs — measured on Chromium, Firefox and WebKit,
331
+ * parameters included (`text/javascript; x=json` is inert), as the spec reads a type (a JavaScript MIME essence match on
332
+ * the whole string); `type=""` and a `language` attribute alone do run, and end in no `json`.
333
+ */
334
+ const JSON_BLOCK = /json\s*$/i;
335
+ /**
336
+ * **A raw-text element's composed text, unable to end its element** — the rule every side writes, byte for byte (the
337
+ * server's `styleHole` and JSON rule, the renderer, hydration's comparison, lite, static): in a style each `</style`
338
+ * (any case) as `<\/style` (the same CSS), in a JSON data block every `<` as `\u003c` (the same JSON). A style's or a
339
+ * JSON block's text is serialized VERBATIM (BROWSER-LEDGER), so written as composed, a value became markup once the page
340
+ * was saved from the DOM and parsed again. Applied to the COMPOSED text: a closer can form across a hole. Idempotent —
341
+ * neither form leaves what it replaces.
342
+ */
343
+ const closedRawText = (text, json) => json ? text.replace(/</g, '\\u003c') : text.replace(/<\/(style)/gi, '<\\/$1');
344
+
345
+ /**
346
+ * **Content in the wrong namespace does not render — DEVELOPMENT ONLY, said by two renderers** (2026-11-18):
347
+ * `` html`<path/>` `` handed into an `<svg>` builds an HTML `<path>`, which draws nothing and says nothing.
348
+ * `@verajs/renderer` and `@verajs/lite` both say it, so the decision and its words live here, once (the shared-emitter
349
+ * rule, `diagnostics.ts`); each renderer passes its own area and the one sentence that differs between them (`retag`:
350
+ * how else a template could get the right namespace). Every call site is behind `true `, so production drops it whole.
351
+ *
352
+ * The host is read from where the content LANDS, and a mismatch is named once per host and content (a toggled subtree
353
+ * would otherwise warn every frame). Silent where HTML is correct — integration points (`<foreignObject>`, `<desc>`,
354
+ * `<title>`, MathML's token elements, an HTML-encoded `<annotation-xml>`) and `<style>`/`<script>`, which never draw.
355
+ */
356
+ const SVG_NS = 'http://www.w3.org/2000/svg';
357
+ const MATHML_NS = 'http://www.w3.org/1998/Math/MathML';
358
+ /** The name of a foreign host where HTML does not render, or `null` (not SVG/MathML, or an integration point). */
359
+ const foreignHost = (parent) => {
360
+ const element = parent;
361
+ const namespace = element.namespaceURI;
362
+ const svg = namespace === SVG_NS;
363
+ if (!svg && namespace !== MATHML_NS)
364
+ return null;
365
+ const name = element.localName;
366
+ if (svg)
367
+ return name === 'foreignObject' || name === 'desc' || name === 'title' ? null : name;
368
+ if (name === 'mi' || name === 'mo' || name === 'mn' || name === 'ms' || name === 'mtext')
369
+ return null;
370
+ if (name === 'annotation-xml') {
371
+ /** The ATTRIBUTE — what the parser reads; `image/svg+xml` is MathML's own spelling for an SVG annotation. */
372
+ const encoding = element.getAttribute('encoding')?.toLowerCase();
373
+ return encoding === 'text/html' || encoding === 'application/xhtml+xml' || encoding === 'image/svg+xml' ? null : name;
374
+ }
375
+ return name;
376
+ };
377
+ /** The nodes an insert is about to place — a fragment empties as it is inserted, so they are read first. */
378
+ const landing = (node) => (node.nodeType === 11 ? [...node.childNodes] : [node]);
379
+ /**
380
+ * **Development: each element of `nodes`, placed in `parent`, that will not render there, named once.** `area` is the
381
+ * emitter's label; `retag` is its sentence on another way to the right namespace, read only for HTML content, between
382
+ * "needs the svg`…` or mathml`…` tag at the call site" and the advice for content that is genuinely HTML.
383
+ */
384
+ const checkForeign = (area, parent, nodes, retag) => {
385
+ const host = foreignHost(parent);
386
+ if (host === null)
387
+ return;
388
+ const hostNamespace = parent.namespaceURI;
389
+ for (const node of nodes) {
390
+ if (node.nodeType !== 1)
391
+ continue;
392
+ const element = node;
393
+ if (element.namespaceURI === hostNamespace)
394
+ continue;
395
+ const tag = element.localName;
396
+ if (tag === 'style' || tag === 'script')
397
+ continue;
398
+ /** The parser itself opens SVG content for an `<svg>` inside `<annotation-xml>`, whatever the encoding. */
399
+ if (host === 'annotation-xml' && tag === 'svg' && element.namespaceURI === SVG_NS)
400
+ continue;
401
+ const built = element.namespaceURI === MATHML_NS ? 'MathML' : element.namespaceURI === SVG_NS ? 'SVG' : 'HTML';
402
+ /** The island and its placement are chosen by the HOST's namespace; the encoding follows the CONTENT. */
403
+ const island = hostNamespace === MATHML_NS
404
+ ? `<mtext>, or <annotation-xml encoding="${built === 'SVG' ? 'image/svg+xml' : 'text/html'}">, ` +
405
+ 'inside a MathML container such as <mrow> or <math> rather than inside a token element'
406
+ : 'a <foreignObject>, which has to sit in an element whose content model accepts one — a container such as ' +
407
+ '<g> or <svg>, not a text, clipping, gradient or filter element';
408
+ /** Keyed by host namespace AND content namespace: `<a>` is a real element in all three. */
409
+ const seen = `${hostNamespace}${host}>${element.namespaceURI}${tag}`;
410
+ /** `hasWarned` first: the advice below is built only for a case not yet said. */
411
+ if (hasWarned('wrong-namespace', seen))
412
+ continue;
413
+ const advice = built === 'HTML'
414
+ ? `If it is meant to be an SVG or MathML element, the template holding it needs the svg\`…\` or mathml\`…\` tag ` +
415
+ `at the call site${retag}. If it is ` +
416
+ `genuinely HTML (a <div>, a custom element), it belongs in ${island}: tagging it will not help, and a custom ` +
417
+ `element only upgrades in the HTML namespace.`
418
+ : `The template's tag is already right — these two namespaces cannot nest directly. Put the ` +
419
+ `${built === 'SVG' ? '<svg>' : '<math>'} root inside ${island}.`;
420
+ warnOnce(area, `<${tag}>`, 'wrong-namespace', true && (() => wrongNamespace(tag, built, host, advice)), seen);
421
+ }
422
+ };
423
+
424
+ /** `data-tone` → `dataTone`: the prop an observed attribute arrives as, in every package that defines components (`@verajs/core`'s `define`, its checks, `@verajs/lite`). */
425
+ const camel = (name) => name.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
426
+
427
+ /**
428
+ * **What a misused `define` is told, in every package that defines components — DEVELOPMENT ONLY** (`@verajs/core`'s `define`
429
+ * and `@verajs/lite`'s both call it behind `true `, so production carries none of it; `area` is the caller's label). One module, so both tiers check a definition
430
+ * identically and say so in the same words. It reads no registry: `swapping` (a development swap module is wired, so a
431
+ * redefine is a swap) is the caller's to say — core reads its registry, a small tier has none.
432
+ */
433
+ /**
434
+ * Development: the declared attributes, said by code. Not an array of names → refused, by code (production throws the
435
+ * platform's own error further on, so both builds refuse). A shared prop whose default is not a string or `null` FLIPS
436
+ * type when the attribute arrives (the platform hands strings); a camel name the platform's element already has
437
+ * (`hidden`, `title`, `ariaLabel`) replaces that REFLECTING property — `el.hidden = true` no longer hides it.
438
+ */
439
+ const checkAttributes = (area, tag, attributes, props) => {
440
+ if (!Array.isArray(attributes) || attributes.some((name) => typeof name !== 'string'))
441
+ throw new TypeError(misuse('define', 'define-attributes', true && defineAttributes(String(attributes))));
442
+ for (const name of attributes) {
443
+ const prop = camel(name);
444
+ const subject = `define('${tag}') attributes '${name}'`;
445
+ const shared = props && Object.hasOwn(props, prop) ? props[prop] : null;
446
+ if (shared !== null && typeof shared !== 'string')
447
+ console.warn(diagnostic(area, subject, 'define-attribute-type', true && defineAttributeType(prop, typeof shared)));
448
+ if (prop in HTMLElement.prototype)
449
+ console.warn(diagnostic(area, subject, 'define-attribute-reflected', true && defineAttributeReflected(prop)));
450
+ }
451
+ };
452
+ /**
453
+ * Development: an own `__proto__` key of `props` or `methods` (`JSON.parse` makes one; an object literal never does),
454
+ * which both builds skip, said by code. True when `name` is that key, so the caller moves on to the next.
455
+ */
456
+ const protoKey = (area, subject, name, kind) => {
457
+ if (name !== '__proto__')
458
+ return false;
459
+ console.error(diagnostic(area, subject, 'define-proto-key', true && defineProtoKey(kind)));
460
+ return true;
461
+ };
462
+ /**
463
+ * Development: the declared props, said by code — installed identically in both builds. A name a method also has (the
464
+ * prop wins), a platform member's name, an object default that cannot be copied per element (a `Set`, a `Map`, a class
465
+ * instance: SHARED by every instance — set it in the setup, or pass it in).
466
+ */
467
+ const checkProps = (area, tag, props, methods) => {
468
+ if (props === null || typeof props !== 'object') {
469
+ console.warn(diagnostic(area, `define('${tag}') props`, 'define-props-not-object', true && definePropsNotObject(String(props))));
470
+ return;
471
+ }
472
+ for (const name of Object.keys(props)) {
473
+ const subject = `define('${tag}') props.${name}`;
474
+ if (protoKey(area, subject, name, 'prop'))
475
+ continue;
476
+ const value = props[name];
477
+ if (methods && Object.hasOwn(methods, name))
478
+ console.warn(diagnostic(area, subject, 'define-prop-method', true && definePropMethod(name)));
479
+ else if (name in HTMLElement.prototype)
480
+ console.warn(diagnostic(area, subject, 'define-shadows', true && defineShadows(name)));
481
+ if (value !== null && typeof value === 'object' && !Array.isArray(value) && value.constructor !== Object)
482
+ console.warn(diagnostic(area, subject, 'define-prop-shared-default', true && definePropSharedDefault()));
483
+ }
484
+ };
485
+ /**
486
+ * Development: each key of `methods`, said by code — never refused, so both builds INSTALL the same thing (Brian's rule:
487
+ * one behavior, the words in development only). Read by descriptor, so a getter is reported, not run.
488
+ */
489
+ const checkMethods = (area, tag, methods, attributes) => {
490
+ for (const name of Object.keys(methods)) {
491
+ const subject = `define('${tag}') methods.${name}`;
492
+ if (protoKey(area, subject, name, 'method'))
493
+ continue;
494
+ const value = Object.getOwnPropertyDescriptor(methods, name)?.value;
495
+ /** The two names core re-asserts. A comparison, not a module-level `Set`: a top-level `new Set` SURVIVES production
496
+ * (terser cannot prove the call free of effects — it cost +33 B gz here, 2026-10-21). */
497
+ if (name === 'constructor' || name === 'connectedCallback' || (name === 'attributeChangedCallback' && attributes?.length))
498
+ console.warn(diagnostic(area, subject, 'define-method-ignored', true && defineMethodIgnored(name)));
499
+ else if (typeof value !== 'function')
500
+ console.warn(diagnostic(area, subject, 'define-method-not-function', true && defineMethodNotFunction()));
501
+ else if (name === 'adoptedCallback')
502
+ console.warn(diagnostic(area, subject, 'define-method-adopted', true && defineMethodAdopted()));
503
+ else if (name === 'attributeChangedCallback')
504
+ console.warn(diagnostic(area, subject, 'define-method-unobserved', true && defineMethodUnobserved()));
505
+ else if (name in HTMLElement.prototype)
506
+ console.warn(diagnostic(area, subject, 'define-shadows', true && defineShadows(name)));
507
+ }
508
+ };
509
+ /** Development: what a misused `define` received, by code, before the platform's own refusal (which throws in both builds). */
510
+ const checkDefine = (area, tag, setup, swapping) => {
511
+ if (typeof tag !== 'string' || tag.indexOf('-') < 1)
512
+ throw new TypeError(misuse('define', 'define-tag', true && defineTag(typeof tag === 'string' ? `'${tag}'` : String(tag))));
513
+ if (typeof setup !== 'function')
514
+ throw new TypeError(misuse('define', 'define-setup', true && defineSetup(String(setup))));
515
+ /** Silent while `@verajs/hot` is wired (`swapping`: it sets `$hot` on core's registry): a redefine is then a swap. */
516
+ if (customElements.get(tag) !== undefined && true)
517
+ console.warn(diagnostic(area, `define('${tag}')`, 'define-twice', true && defineTwice(tag)));
518
+ };
519
+ /** Development: every check of one `define` call, in order — the tag and setup first, as the platform would throw next. */
520
+ const checkDefinition = (area, tag, setup, methods, props, attributes, swapping) => {
521
+ checkDefine(area, tag, setup);
522
+ if (methods)
523
+ checkMethods(area, tag, methods, attributes);
524
+ if (props !== undefined)
525
+ checkProps(area, tag, props, methods);
526
+ if (attributes !== undefined)
527
+ checkAttributes(area, tag, attributes, props);
528
+ };
529
+
530
+ /**
531
+ * `true ` only: the one home for *"is this value something an attribute can carry?"*
532
+ *
533
+ * **Why it is a closed vocabulary and not a predicate.** The first design asked whether a value
534
+ * stringifies meaningfully — `String(v) === '[object Object]'` means it lost its data. Driven
535
+ * through 16 value shapes rather than reasoned about, that broke four ways, and the first is
536
+ * disqualifying: `String()` THROWS on `Object.create(null)`, on `{ toString: null }`, and on any
537
+ * object whose `toString` throws — so a diagnostic would have killed the page for an author using
538
+ * the recommended dictionary idiom. It also passed `["a","b"]` as `"a,b"` (one junk class, if that
539
+ * was a `class` binding) and `new Date()` as a timezone-bearing string, which is an SSR/CSR
540
+ * divergence manufactured out of correct-looking code. And it passed `Symbol('s')` while
541
+ * `` `${sym}` `` throws — a guard and its sink disagreeing about a single expression.
542
+ *
543
+ * "Does it stringify meaningfully" is an OPEN predicate over an unbounded, environment-dependent
544
+ * space, and open predicates cannot be audited. So the test is inverted and closed: **primitives
545
+ * pass; everything else is reported; anything else that should pass is a named row added on
546
+ * evidence.** The list has exactly one member so far.
547
+ *
548
+ * Credit where it is due: the four breaks were found by the omni engine's session, which drove the
549
+ * shapes rather than arguing about them, and the closed-vocabulary form is theirs.
550
+ */
551
+ /**
552
+ * Blessed non-primitives — types whose `toString` IS the value the author means.
553
+ *
554
+ * Tested by brand rather than `instanceof`, which is false across realms: a `URL` built in an
555
+ * iframe is not `instanceof` the parent's `URL`, and a diagnostic that fires on a correct value in
556
+ * one frame and not another is worse than none.
557
+ */
558
+ const brand = (value) => Object.prototype.toString.call(value);
559
+ /** One message per element+name+kind, so a value rebuilt every render does not flood the console. */
560
+ let reported;
561
+ /**
562
+ * Returns the complaint, or `null` when the value is fine. Never throws — the shapes that break a
563
+ * naive guard are exactly the ones worth reporting, so they reach the `object` arm and are named.
564
+ */
565
+ const attributeValueKind = (tag, name, value) => {
566
+ const type = typeof value;
567
+ if (type === 'string' || type === 'number' || type === 'boolean' || type === 'bigint')
568
+ return null;
569
+ if (type === 'object' && brand(value) === '[object URL]')
570
+ return null;
571
+ /**
572
+ * Keyed by BRAND, not by `typeof` — `Date`, `Array` and a plain object are all `'object'`, so a
573
+ * coarser key reported whichever arrived first and silently swallowed the rest. An author who
574
+ * fixed the Date would never have been told about the array.
575
+ */
576
+ const key = `${tag}|${name}|${type === 'object' ? brand(value) : type}`;
577
+ reported ??= new Set();
578
+ if (reported.has(key))
579
+ return null;
580
+ reported.add(key);
581
+ /**
582
+ * A function into an attribute is never what the author meant, but the REASON matters: on a
583
+ * custom element the Lit-era convention is that complex values are set as properties, so
584
+ * `<my-chart formatter={fn}>` is a coherent intention that this sink simply cannot express. The
585
+ * message names the binding that can, rather than blaming the author.
586
+ */
587
+ const kind = type === 'function'
588
+ ? `a function, which becomes its own SOURCE TEXT`
589
+ : type === 'symbol'
590
+ ? `a symbol, which every DOM conversion refuses`
591
+ : Array.isArray(value)
592
+ ? `an array, which becomes its members joined by commas`
593
+ : brand(value) === '[object Date]'
594
+ ? `a Date, whose text carries the TIMEZONE of whichever side rendered it`
595
+ : `an ${type}, which cannot survive as text`;
596
+ /** The KIND only: the sentence is the shared `attribute-value` entry, printed by each call site with its area. */
597
+ return kind;
598
+ };
599
+ /**
600
+ * `true ` only: **an event name one or two keystrokes from a real one** — `@clik`, or `onClik` in
601
+ * JSX, which compiles to it — is almost certainly a typo, and a listener for an event that never
602
+ * fires is a button that silently does nothing. TypeScript cannot catch it beside a permissive prop
603
+ * surface (an index signature cannot exclude names), and nothing at runtime ever fails.
604
+ *
605
+ * Deliberately narrow, because custom events are legitimate on every element: a name the element
606
+ * knows (`'on' + name in element`) is never questioned; one that EXTENDS a real event (`changed`,
607
+ * `loaded`, `closed`) is a custom event by its shape and is left alone; and only a name within two
608
+ * edits of an event this element really has — transpositions counting as one — is named. Each
609
+ * `(tag, name)` pair is said once: the caller's `warnOnce(…, 'event-name-typo', …, key)`, keyed by `eventKey`, and
610
+ * the scan below is skipped for a pair already said (`hasWarned`).
611
+ */
612
+ const eventKey = (element, name) => element.localName + ' ' + name;
613
+ const eventNameGuess = (element, name) => {
614
+ if ('on' + name in element)
615
+ return null;
616
+ if (hasWarned('event-name-typo', eventKey(element, name)))
617
+ return null;
618
+ let best = null;
619
+ let bestDistance = 3;
620
+ for (const key in element) {
621
+ if (!key.startsWith('on'))
622
+ continue;
623
+ const known = key.slice(2);
624
+ if (name.startsWith(known))
625
+ return null;
626
+ const distance = editDistance(name, known, bestDistance);
627
+ if (distance < bestDistance) {
628
+ bestDistance = distance;
629
+ best = known;
630
+ }
631
+ }
632
+ if (best === null)
633
+ return null;
634
+ /** The GUESS only: the sentence is the renderer table's `event-name-typo`. */
635
+ return best;
636
+ };
637
+ /** Optimal-string-alignment distance, stopping early once it cannot come in under `limit`. */
638
+ const editDistance = (a, b, limit) => {
639
+ if (Math.abs(a.length - b.length) >= limit)
640
+ return limit;
641
+ let before = [];
642
+ let previous = Array.from({ length: b.length + 1 }, (_, j) => j);
643
+ for (let i = 1; i <= a.length; i++) {
644
+ const current = [i];
645
+ let rowBest = i;
646
+ for (let j = 1; j <= b.length; j++) {
647
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
648
+ let value = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + cost);
649
+ if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1])
650
+ value = Math.min(value, before[j - 2] + 1);
651
+ current.push(value);
652
+ if (value < rowBest)
653
+ rowBest = value;
654
+ }
655
+ if (rowBest >= limit)
656
+ return limit;
657
+ before = previous;
658
+ previous = current;
659
+ }
660
+ return previous[b.length];
661
+ };
662
+
663
+ /** Lite's own codes and their development sentences, keyed by code (`misuse` / `warnOnce` raise them). */
664
+ const PROSE = {
665
+ 'tier-needs-core': (what) => [
666
+ `${what} needs \`@verajs/core\`: \`@verajs/lite\` does not have it, so it does not work here (development says so; production is silent).`,
667
+ 'Import from `@verajs/core` and wire a renderer to use it: every component written for `@verajs/lite` runs there unchanged.',
668
+ ],
669
+ 'tier-hole-position': () => [
670
+ 'a hole sits where the HTML parser does not keep it as a value (inside a comment, a `<script>` that is not a JSON data block, an element that is never shown such as `<noscript>`, `<iframe>` or `<template>`, a tag position such as `<p ${…}>`, a duplicate attribute, a binding name with a non-ASCII capital letter (the parser lowercases only ASCII), an element its parent cannot hold such as `<div>` in `<select>`), or a value is bound under an element whose content `.innerHTML` or `.textContent` replaces: a value would land where the template does not show it, so the template is refused, in every build. ON THE SERVER, one more cause: an HTML element written inside SVG or MathML content (`<div>` in an `<svg>`), which a browser moves out of it and `@verajs/ssr`\'s DOM does not reproduce, so a hole in that subtree is never found there.',
671
+ "Keep holes in text, attribute values and the text of `<title>`, `<textarea>`, `<style>` or a JSON data block; a binding in a tag position (a ref, a spread) is core's. Put HTML inside SVG in a `<foreignObject>`, and inside MathML in an `<mtext>`. An `<iframe>` is set through its attributes (`src`, `title`, `allow`): its content is fallback no browser shows. A `<noscript>` shows only with scripting off, when this tier never runs, so write it in the served page or render it with `@verajs/ssr`; one with no value inside renders here. (`@verajs/core` writes a value there as text.)",
672
+ ],
673
+ };
674
+
675
+ /**
676
+ * **What the lite tier reads in a template's static text, and what it refuses to write.** Where a hole is, the HTML
677
+ * PARSER says: a rough scan only picks each hole's MARKER form (a comment in text, a value mark inside a start tag), the
678
+ * template is parsed once in a `<template>`, and each hole must land EXACTLY ONCE where its form can be filled
679
+ * (`patch.ts`'s `prepare`). A marker the rough scan misplaces lands in raw text, a comment, a name, a template's content
680
+ * or nowhere — missing — and the template is refused: a scan error can only refuse, never misplace a value. (This
681
+ * replaced a verbatim twin of core's scanner grammar and a separate parser check, 2026-11-17: the static sketch's design,
682
+ * when static was retired into lite.) The refusals are the full tier's (`@verajs/core` with its renderer), from
683
+ * shared-utils' one grammar: a bound inline handler or `srcdoc` is never written, and a script URL on a URL-bearing name
684
+ * is removed.
685
+ */
686
+ /**
687
+ * The rough scan: a hole is in a tag when the source before it ends inside a start tag — a `<` and a letter, then no
688
+ * `>` outside quotes (so `<a title="Next >" href=${url}>` stays in the tag). Wrong only toward a marker that is then
689
+ * missing, so the template is refused, never misrendered. Its group is the open quote's text when the hole is inside
690
+ * a quoted value (`undefined` when it is not).
691
+ */
692
+ const IN_TAG = /<[a-zA-Z](?:[^>"']|"[^"]*"|'[^']*')*("[^"]*|'[^']*)?$/;
693
+ /** The name of the attribute a hole's value starts in, AS WRITTEN (case kept: the parser lowercases), from the source before it. */
694
+ const WRITTEN_NAME = /([^\s"'>/=]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s"'>]*)$/;
695
+ /** A text hole's marker is a comment holding `\u0001` and its index; a value hole's is its index between two `\u0002`s. */
696
+
697
+ const TEXT_MARK = /^\u0001(\d+)$/;
698
+ /** A value hole's marker, inside an attribute value: its index between two `\u0002`s. */
699
+
700
+ const VALUE_MARK = /\u0002(\d+)\u0002/g;
701
+ /** A text marker as it reads inside HTML's RCDATA or raw text, where the parser leaves the comment as text. */
702
+
703
+ const TEXT_MARKS = /<!--\u0001(\d+)-->/g;
704
+ /**
705
+ * Elements a value never enters, by name in ANY namespace (Brian, 2026-11-17): `script` (its text is code, unless a JSON
706
+ * data block), and those whose content is never shown — `iframe`, `noscript`, a `template`'s inert content, the obsolete
707
+ * raw-text four. Never walked, so a hole anywhere inside one is missing, and refused. Their own attributes bind.
708
+ */
709
+ const RAW = /^(?:script|iframe|noscript|xmp|noembed|noframes|plaintext|template)$/i;
710
+ /**
711
+ * Elements whose content is TEXT, in any namespace (Brian, 2026-11-17): `title` (HTML's and SVG's accessible name),
712
+ * `textarea`, and `style` — an author writing `<style>:host{--accent:${c}}</style>` means CSS. Their holes fill the
713
+ * element's text, composed with its statics, never parsed.
714
+ */
715
+ const TEXT_ONLY = /^(?:title|textarea|style)$/i;
716
+ /** A script start tag, whole and quote-aware (a `>` inside a quoted value does not end it). */
717
+ const SCRIPT_START = /<script\b(?:[^>"']|"[^"]*"|'[^']*')*>?/gi;
718
+ /**
719
+ * The strings every FORGED template renders as: the text any object renders as (`[object Object]`), one shared literal.
720
+ * Module state, immutable: shared so every forgery reuses one preparation. A REAL tagged literal, so it is frozen and
721
+ * owns `raw` by the language's own rule — the forged-template rule holds for it by construction (and it is 31 B gz
722
+ * smaller than building that shape by hand, 2026-11-17).
723
+ */
724
+ const FORGED$1 = ((strings) => strings) `[object Object]`;
725
+ /** A tagged template literal's strings: an array owning `raw` (core's check, identical). */
726
+ const literal = (strings) => Array.isArray(strings) && Object.hasOwn(strings, 'raw');
727
+ /**
728
+ * **Only a tagged template literal is a template** — core's rule, identical (`@verajs/renderer`'s `getTemplate`, the check
729
+ * Lit makes): its strings array OWNS `raw`, which `JSON.parse` cannot give an array. A value from JSON shaped like a
730
+ * template result (an API field an attacker can turn into an object) otherwise rendered as MARKUP in the small tiers
731
+ * (found 2026-11-17; unreleased). Asked on a call site's cache MISS, which a forged array always is, so a cached
732
+ * template pays nothing. A forgery renders as `FORGED`'s text, never a throw (the value is attacker-controlled);
733
+ * development says so (`forged-template`, core's words).
734
+ */
735
+ const genuine = (strings) => {
736
+ if (literal(strings))
737
+ return strings;
738
+ if (true )
739
+ console.warn(diagnostic('lite', 'a child value', 'forged-template', true && forgedTemplate()));
740
+ return FORGED$1;
741
+ };
742
+ /**
743
+ * **Development: a binding refused, said as core's renderer says it** (its codes and `SHARED`'s words; lite's own label,
744
+ * as its other diagnostics) — a refusal nobody is told about reads as a bug (CODE-PRINCIPLES §11: `onclick=${fn}` doing
745
+ * nothing). Said at preparation, once per call site and name, as core decides it when it prepares a template: `bound`
746
+ * is the binding as `check` reads it (a sigil name as written, else the parser's attribute name).
747
+ */
748
+ const sayRefused = (element, bound) => {
749
+ const where = `<${element.localName}>`;
750
+ if (/^[.!]__proto__$/.test(bound))
751
+ console.warn(diagnostic('lite', where, 'proto-binding', true && protoBinding(bound)));
752
+ else if (/^[@.!?]/.test(bound))
753
+ return;
754
+ else if (bound === 'srcdoc')
755
+ console.warn(diagnostic('lite', where, 'srcdoc-attribute', true && srcdocAttribute('.srcdoc=${…}')));
756
+ else if (INLINE_HANDLER.test(bound))
757
+ console.warn(diagnostic('lite', where, 'handler-attribute', true && handlerAttribute(bound, `\`@${bound.slice(2)}=\${…}\` (or \`on${bound[2].toUpperCase()}${bound.slice(3)}=\${…}\`)`)));
758
+ };
759
+ /** Development: a script URL refused at commit, said as core's renderer says it (`script-url`), each time the refused value changes. */
760
+ const sayScriptUrl = (element, name) => console.warn(diagnostic('lite', `<${element.localName}>`, 'script-url', true && scriptUrl(name)));
761
+ /** A name whose bound value would run or render as code, never written (an inline handler, `srcdoc`), as core refuses it. */
762
+ const refusedName = (name) => INLINE_HANDLER.test(name) || name.toLowerCase() === 'srcdoc';
763
+ /**
764
+ * The pattern a URL-bearing name's value is checked against, or `null` for any other name: a whole URL (`href`, `src`,
765
+ * `action`, `formaction`, `xlink:href`, `data`) is checked whole, an animation value list (`to`, `from`, `by`,
766
+ * `values`) item by item.
767
+ */
768
+ const urlCheck = (name) => {
769
+ const sink = URL_SINK.exec(name);
770
+ return sink === null ? null : sink[1] ? SCRIPT_URL : SCRIPT_URL_ITEM;
771
+ };
772
+ /**
773
+ * **Development: core's value diagnostics, in core's words** (Brian, 2026-11-19: lite says them too — the same checks
774
+ * and prose, shared from `@verajs/shared-utils`; production carries none of it). A boolean at a child position renders
775
+ * as the word, said on each change to one (core's rule).
776
+ */
777
+ const sayBooleanChild = (value) => {
778
+ if (typeof value === 'boolean')
779
+ console.warn(diagnostic('lite', 'a child position', 'boolean-child', true && booleanChild(String(value))));
780
+ };
781
+ /** Development: a whole attribute value that is not text (a function, an array, a Date…), once per element, name and kind. */
782
+ const sayAttributeValue = (element, name, value) => {
783
+ const kind = value == null ? null : attributeValueKind(element.localName, name, value);
784
+ if (kind !== null)
785
+ console.warn(diagnostic('lite', `<${element.localName}>`, 'attribute-value', true && attributeValue(name, kind, `.${name}=\${value}`)));
786
+ };
787
+ /**
788
+ * Development: a handler that cannot listen (`@click=${'alert(1)'}` — `false`/`undefined` are the deliberate "none"), and
789
+ * at a binding's FIRST handler a misspelled event name (`@clik`), once per tag and name — core's two checks.
790
+ */
791
+ const sayListener = (element, name, value, first) => {
792
+ if (value == null || value === false)
793
+ return;
794
+ if (typeof value !== 'function' && typeof value.handleEvent !== 'function')
795
+ console.warn(diagnostic('lite', `<${element.localName}>`, 'not-a-listener', true && notAListener(name, typeof value)));
796
+ const best = first ? eventNameGuess(element, name) : null;
797
+ if (best !== null)
798
+ warnOnce('lite', `<${element.localName}>`, 'event-name-typo', true && (() => eventNameTypo(name, element.localName, best)), eventKey(element, name));
799
+ };
800
+ /**
801
+ * Development: a value only core renders, in a text position — an object that is not a template or a list (a `keyed` or
802
+ * `spread` result, a DOM node: rendered as its text here). Said once.
803
+ */
804
+ const onlyCore = (value) => {
805
+ if (value === null || typeof value !== 'object' || Array.isArray(value))
806
+ return;
807
+ /**
808
+ * Template-SHAPED (it holds `strings`) but no template: a forgery (`JSON.parse`), said in core's words
809
+ * (`forged-template`), or a wrapper around a real literal's strings, which only core's `hold`/`tag` build — a template
810
+ * to core, text here (2026-11-19, Brian: a recorded difference, said in development).
811
+ */
812
+ const strings = value.strings;
813
+ if (strings !== undefined) {
814
+ if (Array.isArray(strings) && Object.hasOwn(strings, 'raw'))
815
+ warnOnce('lite', 'html', 'template-wrapper', true && (() => templateWrapper()), 'template-wrapper');
816
+ else
817
+ warnOnce('lite', 'html', 'forged-template', true && (() => forgedTemplate()), 'forged-template');
818
+ return;
819
+ }
820
+ const what = 'an object value (a `keyed` or `spread` result, a DOM node)';
821
+ warnOnce('lite', 'html', 'tier-needs-core', true && (() => PROSE['tier-needs-core'](what)), what);
822
+ };
823
+
824
+ /**
825
+ * **The lite tier's renderer: values patched in place.** A template is prepared once per call site (its `strings`
826
+ * array): its HTML with a marker per hole, parsed into a `<template>`, walked once for where each hole is. Each instance
827
+ * clones it and binds one part per hole; a render writes only what changed. Holes: text, attribute (whole or partial),
828
+ * `?bool`, `.prop`, `!live`, `@event`, a nested template, an array (unkeyed, reused by index). The full tier's (`@verajs/core` + `@verajs/renderer`) template semantics,
829
+ * with core's refusals (`markup.ts`); keyed lists, spread, refs and hydration are core's alone.
830
+ */
831
+ /**
832
+ * Development: lite's sentence in the wrong-namespace advice (`checkForeign`), on another way to the right namespace —
833
+ * there is none here but the tag (core's renderer can parse a template where it lands).
834
+ */
835
+ const RETAG = ' (lite parses a template by its tag alone)';
836
+ /** A hole's name for a hole that is its element's only child (`solePart`). */
837
+ const SOLE = '';
838
+ /** A hole's name for a text-only element's content (`textPart`): `title`, `textarea`, `style`, a JSON data block. */
839
+ const TEXT = '\u0003';
840
+ /**
841
+ * Module state: each call site's prepared template, by its `strings` array, built once. Shared because every component
842
+ * rendering a call site reuses its preparation; weak, so a call site's module unloading frees it.
843
+ */
844
+ const prepared = new WeakMap();
845
+ /** The path from `root` to `node`: per level down, the hops from the parent's first child. */
846
+ const pathTo = (node, root) => {
847
+ const path = [];
848
+ for (; node !== root; node = node.parentNode) {
849
+ let hops = 0;
850
+ for (let sibling = node.previousSibling; sibling !== null; sibling = sibling.previousSibling)
851
+ hops++;
852
+ path.unshift(hops);
853
+ }
854
+ return path;
855
+ };
856
+ const refuse = () => {
857
+ throw new TypeError(misuse('html', 'tier-hole-position', true && PROSE['tier-hole-position']()));
858
+ };
859
+ /**
860
+ * Lands hole `at`: once, and of its kind (`text`, a text hole's marker; else a value hole's), or the template is refused —
861
+ * an author's marker-shaped text standing in for a hole the parser lost is a duplicate, out of range, or the wrong kind.
862
+ * `written[at]` is `null` exactly for a text hole (`prepare`).
863
+ */
864
+ const land = (at, seen, written, text) => {
865
+ if (seen[at] !== false || (written[at] === null) !== text)
866
+ refuse();
867
+ seen[at] = true;
868
+ return at;
869
+ };
870
+ /**
871
+ * `data` split by its markers (`marks` captures each hole's index), in one pass: every hole landed (`land`), and the
872
+ * statics around them with the first hole's index (-1: none).
873
+ */
874
+ const mark = (data, marks, seen, written) => {
875
+ const pieces = data.split(marks);
876
+ const statics = [];
877
+ let first = -1;
878
+ for (let i = 0; i < pieces.length; i++)
879
+ if (i % 2 === 0)
880
+ statics.push(pieces[i]);
881
+ else {
882
+ const at = land(+pieces[i], seen, written, marks === TEXT_MARKS);
883
+ if (first === -1)
884
+ first = at;
885
+ }
886
+ return [statics, first];
887
+ };
888
+ /**
889
+ * **Checks every hole under `parent`, the template's first parse only** — each must land EXACTLY ONCE where it can be
890
+ * filled (a comment holding exactly its marker; an attribute's value; a text-only element's text), or it is left unseen
891
+ * and the template refused. A sigil binding (`@`, `.`, `!`, `?`) keeps its name AS WRITTEN (the parser lowercases), and
892
+ * that name, lowercased, must be the parser's: a rough-scan naming error refuses the template rather than binding the
893
+ * wrong property or event (the name backstop). Answers whether it met a custom element (a template holding one is
894
+ * imported, not cloned: `instantiate`).
895
+ */
896
+ const check = (parent, seen, found, written, data) => {
897
+ let custom = false;
898
+ for (let node = parent.firstChild; node !== null; node = node.nextSibling) {
899
+ if (node.nodeType === 1) {
900
+ const element = node;
901
+ if (element.localName.includes('-') || element.hasAttribute('is'))
902
+ custom = true;
903
+ /** False once `.innerHTML` or `.textContent` makes the content the author's value: a hole inside would be lost. */
904
+ let walk = true;
905
+ /** A script's type as the parser read it — the element that OPENED it, never a search of the text. */
906
+ const type = element.localName === 'script' ? (element.getAttribute('type') ?? '') : '';
907
+ /** Whether a value is bound on this element itself (a JSON block carrying one is refused, below). */
908
+ let carries = false;
909
+ for (const { name, value } of [...element.attributes]) {
910
+ const [statics, at] = mark(value, VALUE_MARK, seen, written);
911
+ if (at === -1)
912
+ continue;
913
+ carries = true;
914
+ let bound = name;
915
+ /**
916
+ * A sigil binding, or `on` + a capital (`onClick=${fn}`, React muscle memory): core's rule, the renderer's own test
917
+ * on the WRITTEN name, an event named by the rest, lowercased (Brian, 2026-11-17; parity rows in tests/lite.test.mjs).
918
+ */
919
+ if (/^[@.!?]/.test(name) || /^on[A-Z]/.test(written[at])) {
920
+ bound = written[at];
921
+ if (bound.toLowerCase() !== name)
922
+ refuse();
923
+ if (bound[0] === 'o')
924
+ bound = `@${name.slice(2)}`;
925
+ if (bound === '.innerHTML' || bound === '.textContent')
926
+ walk = false;
927
+ }
928
+ element.removeAttribute(name);
929
+ if (true )
930
+ sayRefused(element, bound);
931
+ found.push([node, bound, statics, at]);
932
+ }
933
+ if (!walk)
934
+ continue;
935
+ /**
936
+ * A JSON block carrying a binding of its own is refused (2026-11-18): `?type=${false}`, `.type`, `!type` change the
937
+ * type after it was judged here, and a page saved from the DOM then runs the value. Left unseen, so refused.
938
+ */
939
+ if (TEXT_ONLY.test(element.localName) || (element.localName === 'script' && data && !carries && JSON_BLOCK.test(type))) {
940
+ /**
941
+ * Its content as one string (in HTML RCDATA a marker is literal text, in SVG a comment); an element child stops it,
942
+ * and so does the END marker (the template ends with the element open: a `<style/>` slip): left unseen.
943
+ */
944
+ let content = '';
945
+ let textual = true;
946
+ for (let child = element.firstChild; child !== null; child = child.nextSibling)
947
+ if (child.nodeType === 3)
948
+ content += child.data;
949
+ else if (child.nodeType === 8)
950
+ content += TEXT_MARK.test(child.data) ? `<!--${child.data}-->` : '';
951
+ else
952
+ textual = false;
953
+ if (textual && !content.includes(`<!--\u0001${seen.length - 1}-->`)) {
954
+ const [statics, at] = mark(content, TEXT_MARKS, seen, written);
955
+ if (at !== -1) {
956
+ element.textContent = '';
957
+ found.push([node, TEXT, statics, at]);
958
+ }
959
+ }
960
+ }
961
+ else if (!RAW.test(element.localName) && check(node, seen, found, written, data))
962
+ custom = true;
963
+ }
964
+ else if (node.nodeType === 8) {
965
+ const hole = TEXT_MARK.exec(node.data);
966
+ if (hole !== null)
967
+ found.push([node, null, null, land(+hole[1], seen, written, true)]);
968
+ }
969
+ }
970
+ return custom;
971
+ };
972
+ /**
973
+ * **A call site prepared, once:** its static text written with a marker per hole (the rough scan, `IN_TAG`, picks each
974
+ * marker's form), one more after the end, parsed in a `<template>` (the server's DOM parses into the template itself) —
975
+ * inside an `<svg>` or `<math>` root for an `svg` or `mathml` template (`type`) — every hole checked (`check`), then the
976
+ * shape every instance clones.
977
+ */
978
+ const prepare = (strings, doc, type) => {
979
+ let source = strings[0];
980
+ /** Per hole, its attribute name as written (`''` in a tag where none reads), or `null` for a text hole; the end marker's too. */
981
+ const written = [];
982
+ for (let i = 1; i < strings.length; i++) {
983
+ const tag = IN_TAG.exec(source);
984
+ written.push(tag ? (WRITTEN_NAME.exec(source)?.[1] ?? '') : null);
985
+ /**
986
+ * An unquoted value followed by `/>` would absorb the slash (`<circle r=${r}/>` gives `r="5/"` to the parser): a
987
+ * space keeps it out, as core's renderer writes one — for every such hole (core's own scan, for an attribute's first).
988
+ */
989
+ source += (tag ? `\u0002${i - 1}\u0002${tag[1] || !strings[i].startsWith('/>') ? '' : ' '}` : `<!--\u0001${i - 1}-->`) + strings[i];
990
+ }
991
+ written.push(null);
992
+ const template = doc.createElement('template');
993
+ /**
994
+ * An `svg` or `mathml` template parses inside its root element, as core's renderer parses it; one more marker after
995
+ * the end (inside that root): a template ending inside a tag, a comment or raw text swallows it.
996
+ */
997
+ const wrap = ['', '', 'svg', 'math'][type];
998
+ const endMark = `<!--\u0001${strings.length - 1}-->`;
999
+ template.innerHTML = wrap ? `<${wrap}>${source}${endMark}</${wrap}>` : source + endMark;
1000
+ /** The server's DOM has no template content: its parse lands in the template itself (`instantiate` unwraps it). */
1001
+ const content = template.content ?? template;
1002
+ /**
1003
+ * The root removed and EVERYTHING the parser made kept, in place: an HTML element written in foreign content breaks
1004
+ * out of it, and lands after it (core's rule — the template shows what the parser made, never less).
1005
+ */
1006
+ if (wrap)
1007
+ content.firstChild.replaceWith(...content.firstChild.childNodes);
1008
+ /**
1009
+ * No script is a data block when any script start tag in the statics holds an `&` (matched whole, quote-aware): the
1010
+ * server reads the RAW type and refuses a character reference there (`dataBlock`), so the client refuses it too.
1011
+ */
1012
+ let data = true;
1013
+ for (const [tag] of strings.join('').matchAll(SCRIPT_START))
1014
+ if (tag.includes('&'))
1015
+ data = false;
1016
+ const seen = new Array(strings.length).fill(false);
1017
+ const found = [];
1018
+ const custom = check(content, seen, found, written, data);
1019
+ /** A hole missing; else the END marker swallowed: the template ends inside a tag, a comment or raw text. */
1020
+ const missing = seen.indexOf(false);
1021
+ if (missing !== -1) {
1022
+ if (missing < strings.length - 1)
1023
+ refuse();
1024
+ throw new TypeError(misuse('html', 'unfinished-tag', true && unfinishedTag()));
1025
+ }
1026
+ /**
1027
+ * The end marker has done its work: removed, so no instance carries it. It is the LAST hole found — the last text in
1028
+ * the source, and holes are found in document order — and anything else in that place refuses the template, so a
1029
+ * broken assumption can only refuse, never remove a node that is not the marker.
1030
+ */
1031
+ const [marker, , , last] = found.pop();
1032
+ if (last !== strings.length - 1)
1033
+ refuse();
1034
+ marker.remove();
1035
+ /** An empty template still has a first node, so an instance of it can be a list item (bounded by its own nodes). */
1036
+ if (content.firstChild === null)
1037
+ content.append(doc.createTextNode(''));
1038
+ /**
1039
+ * A range is "after its boundary": a template that STARTS with a hole gets an empty comment as that boundary, since an
1040
+ * instance's first node has no stable node before it once inserted.
1041
+ */
1042
+ const first = content.firstChild;
1043
+ if (first.nodeType === 8 && TEXT_MARK.test(first.data))
1044
+ content.prepend(doc.createComment(''));
1045
+ /**
1046
+ * A hole that is its ELEMENT's only child needs no range: its marker becomes an empty text node IN THE TEMPLATE, so
1047
+ * every instance is cloned holding it and a render only sets its data (`solePart`).
1048
+ */
1049
+ for (let i = 0; i < found.length; i++) {
1050
+ const [node, name, , at] = found[i];
1051
+ if (name === null && node.parentNode !== content && node.parentNode.childNodes.length === 1) {
1052
+ const parent = node.parentNode;
1053
+ node.replaceWith(doc.createTextNode(''));
1054
+ found[i] = [parent, SOLE, null, at];
1055
+ }
1056
+ }
1057
+ /** A template that is ONE element clones that element: one node to clone and to insert, no fragment (core's root). */
1058
+ const root = content.childNodes.length === 1 && content.firstChild.nodeType === 1 ? content.firstChild : content;
1059
+ return [root, found.map(([node, name, statics, at]) => [pathTo(node, root), name, statics, at]), !custom, root === template];
1060
+ };
1061
+ /**
1062
+ * **One instance: the template's root cloned, and a part per hole, located by its path BEFORE anything commits** (a
1063
+ * committed value inserts nodes, which would shift the siblings a later path counts). A plain template is cloned in its
1064
+ * own inert document and adopted on insertion — creating an element in a document with a custom-element registry costs
1065
+ * a definition lookup each; one holding a custom element is imported into the page's document, which upgrades it at
1066
+ * clone time, so a `.prop` commit reaches its setter (core's rule, `@verajs/renderer`'s instantiate).
1067
+ */
1068
+ const instantiate = (strings, doc, type) => {
1069
+ let entry = prepared.get(strings);
1070
+ if (entry === undefined) {
1071
+ /**
1072
+ * A forged template (JSON-shaped, `genuine`) renders as the forgery's text, as HTML: its own values are never read,
1073
+ * and its kind never chooses a namespace.
1074
+ */
1075
+ const real = genuine(strings);
1076
+ if (real !== strings)
1077
+ return instantiate(real, doc, 1);
1078
+ prepared.set(strings, (entry = prepare(strings, doc, type)));
1079
+ }
1080
+ const [root, holes, plain, wrapped] = entry;
1081
+ let clone = plain ? root.cloneNode(true) : doc.importNode(root, true);
1082
+ /**
1083
+ * A plain loop: a `map` arrow here would capture `clone`, a closure made on every instance (the hot-path rule).
1084
+ * **`parts` is a copy of `holes`, overwritten in place, so its storage is EXACTLY one slot per hole** (2026-11-17):
1085
+ * `parts` lives as long as the instance, and `[]` grown by `push` makes V8 reserve 17 slots for 3 entries (shown by
1086
+ * `%DebugPrint` on the built bundle). In Chrome, after rows were created and cleared on the page, appending 1 000 rows
1087
+ * was ~9% slower with `push` on every page: not its own script, which was within 0.15 ms, but the page's collection
1088
+ * schedule and the layout that followed it. A copy of `holes` has the right length and is already PACKED_ELEMENTS
1089
+ * (holes are tuples), so storing a part never changes its kind. The trade, accepted by Brian: on the first append in
1090
+ * a fresh page, exact-size arrays read slow on ~6 of 10 page loads (~+5%), where `push` did not.
1091
+ */
1092
+ const parts = holes.slice();
1093
+ for (let i = 0; i < holes.length; i++) {
1094
+ const [path, name, statics] = holes[i];
1095
+ let node = clone;
1096
+ for (let step = 0; step < path.length; step++) {
1097
+ node = node.firstChild;
1098
+ for (let hops = path[step]; hops > 0; hops--)
1099
+ node = node.nextSibling;
1100
+ }
1101
+ parts[i] = (name === null ? childPart(node.previousSibling, node)
1102
+ : name === SOLE ? solePart(node.firstChild)
1103
+ : name === TEXT ? textPart(node, statics)
1104
+ : attrPart(node, name, statics));
1105
+ }
1106
+ /** On the server the root is the parse's `<template>` element: its children, located above, are the instance. */
1107
+ if (wrapped) {
1108
+ const fragment = doc.createDocumentFragment();
1109
+ fragment.append(...clone.childNodes);
1110
+ clone = fragment;
1111
+ }
1112
+ return [clone, parts, holes];
1113
+ };
1114
+ const commit = (parts, holes, values) => {
1115
+ for (let i = 0; i < parts.length; i++)
1116
+ parts[i](values, holes[i][3]);
1117
+ };
1118
+ /** Removes `first` and every node after it, up to and with `last`. */
1119
+ const removeRun = (first, last) => {
1120
+ /** Every node here is a child node (an element, text or a comment), so it has `remove`. */
1121
+ for (let node = first;;) {
1122
+ const next = node.nextSibling;
1123
+ node.remove();
1124
+ if (node === last)
1125
+ return;
1126
+ node = next;
1127
+ }
1128
+ };
1129
+ /**
1130
+ * **Core's child rule for a list** (2026-11-19, the tier suites: a `Set` rendered `[object Set]`): an array, or any other
1131
+ * iterable OBJECT that is not a node — a `Set`, a `Map`'s entries, a generator — renders its items; a string (iterable
1132
+ * too, but a primitive) is one text, and a `<select>` or `<form>` (iterable nodes) is placed, never listed. Asked after
1133
+ * the template check, so a template or an array pays nothing for it.
1134
+ */
1135
+ const isList = (value) => Array.isArray(value) ||
1136
+ (value !== null && typeof value === 'object' && typeof value[Symbol.iterator] === 'function' && value.nodeType === undefined);
1137
+ /**
1138
+ * A value's text at a child position. An object holding `strings` is template-SHAPED — a forgery (`JSON.parse`) or a
1139
+ * wrapper only core's `hold`/`tag` build — and never a template here: it renders as the constant text any object renders
1140
+ * as, NEVER converted (its own `toString` may be data, and a string there throws), as core renders a forgery.
1141
+ */
1142
+ const childText = (value) => value == null ? '' : typeof value === 'object' && value.strings !== undefined ? FORGED : `${value}`;
1143
+ const FORGED = `${{}}`;
1144
+ /** Never a value: what an attribute part last wrote before its first write (core's `UNSET`). */
1145
+ const UNSET = {};
1146
+ /**
1147
+ * **A new list item from `list[i]`, inserted into `parent` before `before`** — no comment of its own unless it needs one:
1148
+ * a template instance is bounded by its own first and last nodes (a one-element template is that element; one that
1149
+ * starts with a hole has a boundary comment; one that ends with a hole ends at that hole's comment), and a text value is
1150
+ * its text node. Anything else (a nested list) is a range between two comments, since nothing else bounds it.
1151
+ */
1152
+ const makeItem = (source, at, parent, before) => {
1153
+ const value = source[at];
1154
+ const doc = parent.ownerDocument;
1155
+ if (value?._$litType$) {
1156
+ const { strings, values, _$litType$: type } = value;
1157
+ const [clone, parts, holes] = /*@__NOINLINE__*/ instantiate(strings, doc, type);
1158
+ commit(parts, holes, values);
1159
+ const fragment = clone.nodeType === 11;
1160
+ const item = { _first: fragment ? clone.firstChild : clone, _last: fragment ? clone.lastChild : clone, _strings: strings, _parts: parts, _holes: holes };
1161
+ /** Development: an element placed where its namespace does not render (a list's batch is checked where it lands). */
1162
+ if (true && parent.nodeType !== 11)
1163
+ checkForeign('lite', parent, landing(clone), RETAG);
1164
+ parent.insertBefore(clone, before);
1165
+ return item;
1166
+ }
1167
+ if (isList(value)) {
1168
+ const first = doc.createComment('');
1169
+ const last = doc.createComment('');
1170
+ parent.insertBefore(first, before);
1171
+ parent.insertBefore(last, before);
1172
+ const range = childPart(first, last);
1173
+ range(source, at);
1174
+ return { _first: first, _last: last, _range: range };
1175
+ }
1176
+ if (true )
1177
+ onlyCore(value);
1178
+ if (true )
1179
+ sayBooleanChild(value);
1180
+ const text = doc.createTextNode(childText(value));
1181
+ parent.insertBefore(text, before);
1182
+ return { _first: text, _last: text, _value: value };
1183
+ };
1184
+ /** Renders `source[at]` into `items[i]`: in place when it is the same kind, or a new item takes its place. */
1185
+ const updateItem = (items, i, source, at) => {
1186
+ const item = items[i];
1187
+ const value = source[at];
1188
+ if (value?._$litType$) {
1189
+ if (item._strings === value.strings)
1190
+ return commit(item._parts, item._holes, value.values);
1191
+ }
1192
+ else if (isList(value)) {
1193
+ if (item._range !== undefined)
1194
+ return item._range(source, at);
1195
+ }
1196
+ else if (item._strings === undefined && item._range === undefined) {
1197
+ /** Compared with the value it last WROTE, never read back from the DOM (a read is a call into the engine per item). */
1198
+ if (value !== item._value) {
1199
+ if (true )
1200
+ sayBooleanChild(value);
1201
+ item._first.data = childText((item._value = value));
1202
+ }
1203
+ return;
1204
+ }
1205
+ items[i] = makeItem(source, at, item._last.parentNode, item._last.nextSibling);
1206
+ removeRun(item._first, item._last);
1207
+ };
1208
+ /**
1209
+ * **A range: the nodes after `start` (from its parent's first child when `start` is `null`) up to `end`**, a comment kept
1210
+ * while the part lives. Everything the part shows, and everything its nested parts show, however they changed since,
1211
+ * lies inside it — so clearing removes exactly the range, and a range that is its parent's whole content clears in one
1212
+ * call. A single value is ONE item and a list is one item per element (`makeItem`, `updateItem`), so a template instance
1213
+ * (filled BEFORE it is inserted: one insertion) and text are made the same way in both; new list items are rendered into
1214
+ * one fragment and inserted once.
1215
+ */
1216
+ const childPart = (start, end) => {
1217
+ /** What the range shows: one item for a single value, one per element for a list (`list`), nothing when `undefined`. */
1218
+ let items;
1219
+ let list = false;
1220
+ const clear = () => {
1221
+ if (items === undefined)
1222
+ return;
1223
+ if (start === null && end.nextSibling === null)
1224
+ end.parentNode.replaceChildren(end);
1225
+ else
1226
+ for (let node = start === null ? end.parentNode.firstChild : start.nextSibling; node !== end;) {
1227
+ const next = node.nextSibling;
1228
+ node.remove();
1229
+ node = next;
1230
+ }
1231
+ items = undefined;
1232
+ };
1233
+ return (values, at) => {
1234
+ let value = values[at];
1235
+ /** A non-array list (core's rule, `isList`) renders as the array of its items, read once per render. */
1236
+ if (!Array.isArray(value) && !value?._$litType$ && isList(value))
1237
+ value = [...value];
1238
+ if (Array.isArray(value)) {
1239
+ if (!list || items === undefined || value.length === 0) {
1240
+ clear();
1241
+ items = [];
1242
+ list = true;
1243
+ }
1244
+ const had = items.length;
1245
+ if (had > value.length) {
1246
+ /** The dropped items are one run of nodes: the first dropped item's first to the last item's last. */
1247
+ removeRun(items[value.length]._first, items[had - 1]._last);
1248
+ items.length = value.length;
1249
+ }
1250
+ for (let i = 0; i < Math.min(had, value.length); i++)
1251
+ updateItem(items, i, value, i);
1252
+ if (had < value.length) {
1253
+ /** New items are built in one fragment and inserted once. */
1254
+ const batch = end.ownerDocument.createDocumentFragment();
1255
+ for (let i = had; i < value.length; i++)
1256
+ items.push(makeItem(value, i, batch, null));
1257
+ if (true )
1258
+ checkForeign('lite', end.parentNode, landing(batch), RETAG);
1259
+ end.before(batch);
1260
+ }
1261
+ }
1262
+ else if (value == null)
1263
+ clear();
1264
+ else if (list || items === undefined) {
1265
+ clear();
1266
+ list = false;
1267
+ items = [makeItem(values, at, end.parentNode, end)];
1268
+ }
1269
+ else
1270
+ updateItem(items, 0, values, at);
1271
+ };
1272
+ };
1273
+ /**
1274
+ * **A hole that is its element's only child** (`<td>${id}</td>`, every cell of a table): it sets the data of the text node
1275
+ * the template already holds there — no comment, no insertion — until a value that is not text arrives (a template, a
1276
+ * list), when a comment takes the text's place as the end of a range that takes over for good.
1277
+ */
1278
+ const solePart = (text) => {
1279
+ let range;
1280
+ /** The value last written, compared instead of reading the DOM back; `undefined` matches the template's empty text. */
1281
+ let last;
1282
+ return (values, at) => {
1283
+ const value = values[at];
1284
+ if (range === undefined && (value == null || typeof value !== 'object')) {
1285
+ if (value !== last) {
1286
+ if (true )
1287
+ sayBooleanChild(value);
1288
+ text.data = (last = value) == null ? '' : `${value}`;
1289
+ }
1290
+ }
1291
+ else {
1292
+ if (range === undefined) {
1293
+ const end = text.ownerDocument.createComment('');
1294
+ text.replaceWith(end);
1295
+ range = childPart(null, end);
1296
+ }
1297
+ range(values, at);
1298
+ }
1299
+ };
1300
+ };
1301
+ /**
1302
+ * A value as text, for a text-only element's content — the rule every tier and the server follow: `null`/`undefined`
1303
+ * none, a list its items' text (nested lists flattened by the same rule), a TEMPLATE refused (`template-in-text`, as
1304
+ * `@verajs/ssr` refuses it), otherwise the value as a string. A forged template (strings not owning `raw`) is no
1305
+ * template: its string.
1306
+ */
1307
+ const textOf = (value) => {
1308
+ if (value == null)
1309
+ return '';
1310
+ if (Array.isArray(value)) {
1311
+ let text = '';
1312
+ for (const item of value)
1313
+ text += textOf(item);
1314
+ return text;
1315
+ }
1316
+ const strings = value._$litType$ ? value.strings : undefined;
1317
+ if (Array.isArray(strings) && Object.hasOwn(strings, 'raw'))
1318
+ throw new TypeError(misuse('html', 'template-in-text', true && templateInText()));
1319
+ return `${value}`;
1320
+ };
1321
+ /**
1322
+ * **A text-only element's content** (`title`, `textarea`, `style`, a JSON data block): its statics and its holes' values
1323
+ * as text, written as `textContent` (never parsed) when they changed — compared with the text last written.
1324
+ */
1325
+ const textPart = (element, statics) => {
1326
+ let last;
1327
+ /**
1328
+ * An HTML `<style>`'s or JSON block's text is serialized VERBATIM by the browser, so written as it is, a value would
1329
+ * become markup the moment the page is saved through `innerHTML`/`outerHTML` and parsed again (2026-11-18, measured on
1330
+ * three engines). So the COMPOSED text — statics and values together, since a closer can form across a hole (a static
1331
+ * `<` before a value `/style>`) — is written closed (`closedRawText`), as the renderer and `@verajs/ssr` write it, byte
1332
+ * for byte. HTML elements only — the upper-case `tagName` of an HTML document: an SVG `<style>` or `<script>` is
1333
+ * serialized escaped like any text, as core and the server leave it. Title and textarea are RCDATA, which
1334
+ * serialization escapes already.
1335
+ */
1336
+ const raw = element.tagName === 'STYLE' ? 1 : element.tagName === 'SCRIPT' ? 2 : 0;
1337
+ return (values, at) => {
1338
+ let text = statics[0];
1339
+ for (let i = 1; i < statics.length; i++)
1340
+ text += textOf(values[at + i - 1]) + statics[i];
1341
+ if (text !== last)
1342
+ element.textContent = raw ? /*@__NOINLINE__*/ closedRawText((last = text), raw > 1) : (last = text);
1343
+ };
1344
+ };
1345
+ /** One attribute hole: `@event`, `.prop`, `!live`, `?bool`, or an attribute, whole or with statics around its holes. */
1346
+ const attrPart = (element, name, statics) => {
1347
+ const prefix = name[0];
1348
+ const real = name.slice(1);
1349
+ const target = element;
1350
+ /** The value last written; a sentinel at first, so a first `undefined` is WRITTEN as core writes it (2026-11-19). */
1351
+ let last = UNSET;
1352
+ if (prefix === '@') {
1353
+ let handler;
1354
+ /** One listener per hole, registered once; a new handler only replaces what it calls. `this` is the element (core's). */
1355
+ element.addEventListener(real, {
1356
+ handleEvent(event) {
1357
+ if (typeof handler === 'function')
1358
+ handler.call(element, event);
1359
+ else
1360
+ handler?.handleEvent?.(event);
1361
+ },
1362
+ });
1363
+ return (values, at) => {
1364
+ if (true )
1365
+ sayListener(element, real, values[at], handler == null);
1366
+ handler = values[at];
1367
+ };
1368
+ }
1369
+ if (prefix === '?')
1370
+ return (values, at) => {
1371
+ if (!!values[at] !== last)
1372
+ element.toggleAttribute(real, (last = !!values[at]));
1373
+ };
1374
+ /** `.prop` and `!live` write a property; anything else an attribute, by its parser name. */
1375
+ const property = prefix === '.' || prefix === '!';
1376
+ const key = property ? real : name;
1377
+ /**
1378
+ * Refused, as core refuses them: `.__proto__` would replace the element's prototype; a bound inline handler or `srcdoc`
1379
+ * attribute would run its value as code or markup. Kept a CALL, never pasted in (CLAUDE.md, the one-caller rule): as
1380
+ * this function's only caller, the minifier would substitute it here as an arrow made and invoked on every call —
1381
+ * every attribute hole created (both checks).
1382
+ */
1383
+ if (property ? real === '__proto__' : /*@__NOINLINE__*/ refusedName(name))
1384
+ return () => { };
1385
+ const check = /*@__NOINLINE__*/ urlCheck(key);
1386
+ /** A component's URL-named property is its own business (often an object): only a string is checked there (core's). */
1387
+ const custom = property && element.localName.includes('-');
1388
+ const whole = statics.length === 2 && !statics[0] && !statics[1];
1389
+ /** Development: the script URL last refused, so a refusal is said each time the value changes (core's rule). */
1390
+ let refused;
1391
+ return (values, at) => {
1392
+ /** The statics and values joined by a plain loop: a `reduce` arrow here would capture `values` and `at` on every commit. */
1393
+ let value = values[at];
1394
+ if (!whole) {
1395
+ let joined = statics[0];
1396
+ for (let i = 1; i < statics.length; i++)
1397
+ joined += `${values[at + i - 1] ?? ''}${statics[i]}`;
1398
+ value = joined;
1399
+ }
1400
+ /**
1401
+ * A script URL is refused on the JOINED value and its attribute removed, as core does, for an attribute and a property
1402
+ * alike. Converted ONCE, so the string checked is the string written: an object whose `toString` answers differently
1403
+ * each time cannot pass as `https:` and be written as `javascript:`.
1404
+ */
1405
+ if (check !== null && value != null && (!custom || typeof value === 'string')) {
1406
+ value = `${value}`;
1407
+ if (check.test(value)) {
1408
+ if (true && value !== refused)
1409
+ sayScriptUrl(element, key);
1410
+ if (true )
1411
+ refused = value;
1412
+ element.removeAttribute(key);
1413
+ last = UNSET;
1414
+ return;
1415
+ }
1416
+ }
1417
+ /** A LIVE property is compared against the element's current value (what was typed), as core's `!name`. */
1418
+ if (prefix === '!') {
1419
+ if (target[key] !== value)
1420
+ target[key] = value;
1421
+ }
1422
+ else if (value !== last) {
1423
+ last = value;
1424
+ if (property)
1425
+ target[key] = value;
1426
+ else if (value == null)
1427
+ element.removeAttribute(key);
1428
+ else {
1429
+ if (true && whole)
1430
+ sayAttributeValue(element, key, values[at]);
1431
+ element.setAttribute(key, value);
1432
+ }
1433
+ }
1434
+ };
1435
+ };
1436
+ /** Paints `result` into `root`: the first paint clears what was there (served markup included) and anchors one range. */
1437
+ const patch = (result, root) => {
1438
+ if (root._$t$ === undefined) {
1439
+ const end = root.ownerDocument.createComment('');
1440
+ root.replaceChildren(end);
1441
+ root._$t$ = childPart(null, end);
1442
+ }
1443
+ root._$t$([result], 0);
1444
+ };
1445
+
1446
+ /**
1447
+ * **When a small-tier component renders: a write queues it, and one microtask renders every queued component**, however
1448
+ * many writes landed first. No scheduler, no priorities, no tracking graph: a declared prop's setter and a signal's setter both end here.
1449
+ */
1450
+ /**
1451
+ * Module state: the component whose render function is running, so a signal read during it subscribes that component.
1452
+ * Module-level because a signal is created anywhere (a module, a setup) and must find the render reading it. An object,
1453
+ * not an exported `let`: a hot read of an exported binding is slower (CLAUDE.md).
1454
+ */
1455
+ const reading = { element: undefined };
1456
+ /**
1457
+ * Module state: the components waiting to render, in the order they were queued. ONE microtask renders them all, and a
1458
+ * render queued DURING that flush (a parent's commit handing a child new props) joins it, so a parent and its children
1459
+ * are drawn before anything that awaited the write runs (the full tier's flush, `@verajs/core`'s, does the same). Module-level because every write,
1460
+ * from any component or signal, queues here.
1461
+ */
1462
+ const pending = [];
1463
+ /** Lets go of every signal `element` read: before each render (which reads afresh), and when it is retired. */
1464
+ const unlink = (element) => {
1465
+ if (element._$l$ !== undefined)
1466
+ for (const readers of element._$l$)
1467
+ readers.delete(element);
1468
+ element._$l$ = undefined;
1469
+ };
1470
+ /**
1471
+ * Renders `element` now: its render function's result, patched into its root (`patch`). Nothing for an
1472
+ * element that is not connected, or whose setup returned no render function.
1473
+ * - It is no longer queued from the moment it starts, so a write DURING its own render queues it again (and a queued
1474
+ * entry for a render that already happened, on connect, is skipped by the flush).
1475
+ * - It subscribes only to what THIS render reads: it leaves every signal the last one read first, so a component never
1476
+ * holds a signal it no longer reads (a long-lived shell reading a churning list's rows would otherwise grow).
1477
+ * - `reading` is restored in a `finally`, so a render that throws never leaves later reads subscribing the wrong component.
1478
+ */
1479
+ const render = (element) => {
1480
+ element._$u$ = false;
1481
+ const draw = element._$f$;
1482
+ if (typeof draw === 'function' && element.isConnected) {
1483
+ unlink(element);
1484
+ const outer = reading.element;
1485
+ reading.element = element;
1486
+ let result;
1487
+ try {
1488
+ result = draw();
1489
+ }
1490
+ finally {
1491
+ reading.element = outer;
1492
+ }
1493
+ /** Kept a CALL, never pasted in (CLAUDE.md, the one-caller rule): as this function's only caller, the minifier would substitute it here as an arrow made and invoked on every render. */
1494
+ /*@__NOINLINE__*/ patch(result, element._$r$);
1495
+ }
1496
+ };
1497
+ /**
1498
+ * Renders every component still queued, walking the queue by index. One that throws is reported as its error escapes:
1499
+ * it and everything before it are consumed, and whatever remains is rendered by a fresh flush, so one failure never
1500
+ * strands the rest or renders anything twice.
1501
+ */
1502
+ const flush = () => {
1503
+ let i = 0;
1504
+ try {
1505
+ for (; i < pending.length; i++)
1506
+ if (pending[i]._$u$)
1507
+ render(pending[i]);
1508
+ }
1509
+ finally {
1510
+ pending.splice(0, i + 1);
1511
+ if (pending.length !== 0)
1512
+ queueMicrotask(flush);
1513
+ }
1514
+ };
1515
+ /** Queues one render of `element`; a second write before it runs adds nothing. */
1516
+ const queue = (element) => {
1517
+ if (!element._$u$) {
1518
+ element._$u$ = true;
1519
+ if (pending.push(element) === 1)
1520
+ queueMicrotask(flush);
1521
+ }
1522
+ };
1523
+
1524
+ /** An array or plain-object default is copied per element, as core copies it; nested values stay shared. */
1525
+ const own = (value) => Array.isArray(value) ? [...value] : value?.constructor === Object ? { ...value } : value;
1526
+ /** Lets go of a component for good: its signals stop queuing it, and a later connect runs its setup again (as core). */
1527
+ const retire = (element) => {
1528
+ unlink(element);
1529
+ element._$f$ = undefined;
1530
+ };
1531
+ /** Development: an option only core has (`foreignNodes`, `persist`, a module's key, a `ShadowRootInit`), said once per tag and key. */
1532
+ const checkOptions = (tag, options) => {
1533
+ for (const [key, value] of Object.entries(options))
1534
+ if (!['tag', 'props', 'attributes', 'methods', 'shadow'].includes(key) || (key === 'shadow' && ![undefined, false, 'open', 'closed'].includes(value)))
1535
+ warnOnce('lite', `define('${tag}')`, 'tier-needs-core', true && (() => PROSE['tier-needs-core'](`\`${key}: ${typeof value === 'object' ? 'an object' : String(value)}\``)), `${tag} ${key}`);
1536
+ };
1537
+ /**
1538
+ * Development: what a setup returned, when it is not a render function — core's words: a value is drawn once (in both
1539
+ * packages), a promise is an async setup, which is core's.
1540
+ */
1541
+ const checkSetupResult = (element, out) => {
1542
+ if (typeof out?.then === 'function')
1543
+ warnOnce('lite', `<${element.localName}>`, 'tier-needs-core', true && (() => PROSE['tier-needs-core']('an async setup')), element.constructor);
1544
+ else if (out !== undefined && typeof out !== 'function') {
1545
+ const kind = Array.isArray(out) ? 'an array' : typeof out === 'object' ? 'a template or object' : `a ${typeof out}`;
1546
+ errorOnce('lite', `<${element.localName}>`, 'setup-returned-value', true && (() => setupReturnedValue(kind)), element.constructor);
1547
+ }
1548
+ };
1549
+ /**
1550
+ * **`@verajs/lite`'s `define`**, rendering through its one renderer (`patch.ts`, called by `render` in `schedule.ts`).
1551
+ * `@verajs/core`'s call shape — `define(tag, setup)` or `define({ tag, props, attributes, methods, shadow }, setup)` — with the
1552
+ * reactivity reduced to a setter: a declared prop is an accessor on the generated prototype over the element's ONE values
1553
+ * record (`_$v$`, core's name and meaning), and a write that differs by `Object.is` queues one render. An observed
1554
+ * attribute arrives as its camel-cased prop, one way, as in core.
1555
+ *
1556
+ * - **Setup runs once per life, as core's:** a component removed and re-added in the same task (a move) keeps it; one
1557
+ * still out a microtask later is retired, and its next connect sets it up again. Props survive, as core's do.
1558
+ * - **A value set before the tag was defined** is an own property hiding the accessor: handed over through it at connect.
1559
+ * - **An own `__proto__` key** (`JSON.parse` makes one) is skipped in props and methods, as core skips it.
1560
+ * - **A setup that returns a value, not a render function, draws it once** (core's behavior and core's development error);
1561
+ * one that returns nothing, or a promise (an async setup, core's alone), draws nothing.
1562
+ * - An author's `methods.disconnectedCallback` runs first on removal, as core chains it.
1563
+ * - Development checks the definition in core's words (`checkDefinition`) and names every option only core has.
1564
+ */
1565
+ const define = (target, setup) => {
1566
+ let tag = target;
1567
+ let props;
1568
+ let attributes = [];
1569
+ let methods;
1570
+ let shadow;
1571
+ if (typeof target !== 'string')
1572
+ ({ tag, props, attributes = [], methods, shadow } = target);
1573
+ if (true ) {
1574
+ checkDefinition('lite', tag, setup, methods, props, typeof target === 'string' ? undefined : target.attributes);
1575
+ if (typeof target !== 'string')
1576
+ checkOptions(tag, target);
1577
+ }
1578
+ /** Each declared attribute is a prop under its camel name, default `null` unless a declared prop shares it. */
1579
+ const camels = {};
1580
+ const declared = {};
1581
+ for (const name of attributes)
1582
+ declared[(camels[name] = camel(name))] = null;
1583
+ const defaults = { ...declared, ...props };
1584
+ const keys = Object.keys(defaults).filter((key) => key !== '__proto__');
1585
+ const fill = () => {
1586
+ const record = {};
1587
+ for (const key of keys)
1588
+ record[key] = own(defaults[key]);
1589
+ return record;
1590
+ };
1591
+ const write = (element, key, value) => {
1592
+ const record = (element._$v$ ??= fill());
1593
+ if (!Object.is(record[key], value)) {
1594
+ record[key] = value;
1595
+ queue(element);
1596
+ }
1597
+ };
1598
+ const Class = class extends HTMLElement {
1599
+ };
1600
+ const installed = { ...methods };
1601
+ delete installed.__proto__;
1602
+ /** Methods first, so a method named like a callback never replaces one (core's order). */
1603
+ Object.assign(Class.prototype, installed, {
1604
+ constructor: Class,
1605
+ connectedCallback() {
1606
+ if (this._$f$ === undefined) {
1607
+ for (const key of keys)
1608
+ if (Object.hasOwn(this, key)) {
1609
+ const value = this[key];
1610
+ delete this[key];
1611
+ this[key] = value;
1612
+ }
1613
+ /** `shadowRoot` first: a declarative shadow root the server sent is the one to render into. */
1614
+ this._$r$ ??= shadow ? (this.shadowRoot ?? this.attachShadow({ mode: shadow })) : this;
1615
+ const out = setup(this);
1616
+ if (true )
1617
+ checkSetupResult(this, out);
1618
+ /** A promise is an async setup, which is core's: it draws nothing here (development says so). */
1619
+ this._$f$ =
1620
+ typeof out === 'function'
1621
+ ? out
1622
+ : out === undefined || typeof out.then === 'function'
1623
+ ? null
1624
+ : () => out;
1625
+ }
1626
+ render(this);
1627
+ },
1628
+ disconnectedCallback() {
1629
+ installed.disconnectedCallback?.call(this);
1630
+ queueMicrotask(() => {
1631
+ /** Kept a CALL, never pasted in (CLAUDE.md, the one-caller rule): as this function's only caller, the minifier would substitute it here as an arrow made and invoked on every call — every removal. */
1632
+ if (!this.isConnected) /*@__NOINLINE__*/
1633
+ retire(this);
1634
+ });
1635
+ },
1636
+ });
1637
+ /** Observed attributes only on a tag that declares some: every callback a class defines is creation work. */
1638
+ if (attributes.length) {
1639
+ Class.observedAttributes = attributes;
1640
+ Class.prototype.attributeChangedCallback = function (name, _old, value) {
1641
+ write(this, camels[name], value);
1642
+ };
1643
+ }
1644
+ for (const key of keys)
1645
+ Object.defineProperty(Class.prototype, key, {
1646
+ get() {
1647
+ return (this._$v$ ??= fill())[key];
1648
+ },
1649
+ set(value) {
1650
+ write(this, key, value);
1651
+ },
1652
+ configurable: true,
1653
+ enumerable: true,
1654
+ });
1655
+ customElements.define(tag, Class);
1656
+ return customElements.get(tag);
1657
+ };
1658
+
1659
+ /** Where a signal keeps its value and its readers: symbols private to this copy, so no key, spread or JSON shows them. */
1660
+ const HELD = Symbol();
1661
+ const READERS = Symbol();
1662
+ /**
1663
+ * **What every small-tier signal shares: one accessor pair on one frozen prototype — the full tier's (`@verajs/core`'s) shape** (`modules/signal.ts`),
1664
+ * so a signal reads, writes, stringifies and enumerates the same in every tier: `Object.keys` and `for…in` list nothing,
1665
+ * `JSON.stringify` writes the value, its tag is `[object Signal]`. Reading `.value` during a render subscribes that
1666
+ * component (`reading`); a write that differs by `Object.is` queues every subscriber. The component, not a graph, is
1667
+ * the unit: no computed, no effect, nothing to unlink but the components, which let go when they are retired.
1668
+ */
1669
+ const SIGNAL = Object.freeze(Object.defineProperties({}, {
1670
+ [Symbol.toStringTag]: { value: 'Signal' },
1671
+ value: {
1672
+ get() {
1673
+ const element = reading.element;
1674
+ if (element !== undefined) {
1675
+ const readers = (this[READERS] ??= new Set());
1676
+ readers.add(element);
1677
+ (element._$l$ ??= new Set()).add(readers);
1678
+ }
1679
+ return this[HELD];
1680
+ },
1681
+ set(next) {
1682
+ if (Object.is(this[HELD], next))
1683
+ return;
1684
+ this[HELD] = next;
1685
+ const readers = this[READERS];
1686
+ if (readers !== undefined)
1687
+ for (const element of readers)
1688
+ queue(element);
1689
+ },
1690
+ },
1691
+ toJSON: {
1692
+ value() {
1693
+ return this[HELD];
1694
+ },
1695
+ },
1696
+ }));
1697
+ /**
1698
+ * **A reactive box for one value, read and written as `.value`; shallow, as core's default.** Replacing `.value` re-renders
1699
+ * every component that read it; mutating inside it does not. Core's `{ deep: true }` is core's alone.
1700
+ */
1701
+ const signal = (initialValue, options) => {
1702
+ if (true && options !== undefined)
1703
+ warnOnce('lite', 'signal', 'tier-needs-core', true && (() => PROSE['tier-needs-core']("`signal`'s options (`{ deep: true }`)")));
1704
+ const box = Object.create(SIGNAL);
1705
+ box[HELD] = initialValue;
1706
+ return box;
1707
+ };
1708
+
1709
+ /**
1710
+ * **`@verajs/lite`'s template tags, `html`, `svg` and `mathml`**: the same tags as `@verajs/core`'s
1711
+ * (`packages/core/src/store/store.ts`), a second copy on purpose (2026-11-18). When both packages took the tags from one
1712
+ * shared-utils module, they moved within core's production bundle, and core's create1k measured +3.5% slower in Chrome
1713
+ * (20 sessions, A/A valid); with its own copy, core's bundle is byte-identical to the one raced at release.
1714
+ * `tests/lite.test.mjs` holds the two copies to one shape — never fold them back into one. Each tag is written out, as
1715
+ * core's are (one function per kind: no tag built by a factory, so each stays a plain function the engine inlines).
1716
+ *
1717
+ * Called with a string instead of tagged, development names it, in core's words (`tag-called`): `html('<p>x</p>')` puts a
1718
+ * string where the strings array goes and fails much later, naming nothing. Production folds the check away.
1719
+ */
1720
+ const tagCalled = (type, strings) => {
1721
+ if (!Array.isArray(strings)) {
1722
+ const name = ['html', 'svg', 'mathml'][type - 1];
1723
+ throw new TypeError(misuse(name, 'tag-called', true && tagCalled$1(name, typeof strings === 'string' ? JSON.stringify(strings) : String(strings), '<p>hi</p>')));
1724
+ }
1725
+ };
1726
+ /** The `html` tagged template. */
1727
+ const html = (strings, ...values) => {
1728
+ if (true )
1729
+ tagCalled(1, strings);
1730
+ return { ['_$litType$']: 1, strings, values };
1731
+ };
1732
+ /** The `svg` tagged template — markup parsed as SVG, for a fragment that is not inside an `<svg>` element. */
1733
+ const svg = (strings, ...values) => {
1734
+ if (true )
1735
+ tagCalled(2, strings);
1736
+ return { ['_$litType$']: 2, strings, values };
1737
+ };
1738
+ /** The `mathml` tagged template — markup parsed as MathML, for a fragment that is not inside a `<math>` element. */
1739
+ const mathml = (strings, ...values) => {
1740
+ if (true )
1741
+ tagCalled(3, strings);
1742
+ return { ['_$litType$']: 3, strings, values };
1743
+ };
1744
+
1745
+ export { define, html, mathml, signal, svg };
1746
+ //# sourceMappingURL=vera-lite.js.map