@verajs/lite 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -3
- package/dist/development/vera-lite.d.ts +8 -1
- package/dist/development/vera-lite.d.ts.map +1 -1
- package/dist/development/vera-lite.js +16 -8
- package/dist/development/vera-lite.js.map +1 -1
- package/dist/vera-lite.min.js +1 -1
- package/dist/vera-lite.min.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,8 +5,8 @@ wire.
|
|
|
5
5
|
|
|
6
6
|
| Package | gzipped | A render | For |
|
|
7
7
|
| --- | ---: | --- | --- |
|
|
8
|
-
| `@verajs/lite` | <!--size:lite.gzip-->4.
|
|
9
|
-
| `@verajs/core` + `@verajs/renderer` | <!--size:core.gzip-->8.
|
|
8
|
+
| `@verajs/lite` | <!--size:lite.gzip-->4.19 KB<!--/size:lite.gzip--> | patches the values that changed, in place | small sites |
|
|
9
|
+
| `@verajs/core` + `@verajs/renderer` | <!--size:core.gzip-->8.11 KB<!--/size:core.gzip--> + <!--size:renderer.gzip-->6.25 KB<!--/size:renderer.gzip--> | patches in place, keyed lists, hydration | everything else |
|
|
10
10
|
|
|
11
11
|
<!-- recipe -->
|
|
12
12
|
```js
|
|
@@ -39,6 +39,9 @@ document.body.append(price);
|
|
|
39
39
|
the component once, in a microtask, however many writes came first. A `signal` is the one store: shallow, read and
|
|
40
40
|
written as `.value`, as in `@verajs/core`.
|
|
41
41
|
|
|
42
|
+
**`isServer()`** is `true` while `@verajs/ssr` renders and `false` in a browser, as in `@verajs/core`: guard per-user
|
|
43
|
+
state (storage, cookies, the viewport) with `if (!isServer()) …`, never `typeof localStorage` (a Node 26 server has one).
|
|
44
|
+
|
|
42
45
|
**A render patches in place**, so focus, the caret, typed input and child components survive it. Lite binds text,
|
|
43
46
|
attributes (whole or partial), `?bool`, `.prop`, `!live`, `@event` (or `onClick=${…}`, as in `@verajs/core`), nested
|
|
44
47
|
templates and arrays (unkeyed: items are reused by position). The text of a `<title>`, `<textarea>` or `<style>` takes a value as TEXT, and so does a JSON data
|
|
@@ -81,7 +84,9 @@ a wrapper as its template).
|
|
|
81
84
|
`undefined` gets `undefined` (the platform's setter writes it as the text "undefined" in a field, as core does), and
|
|
82
85
|
development says core's warnings in core's words — a boolean child that renders as a word (`boolean-child`), an attribute
|
|
83
86
|
value that is not text (`attribute-value`), a handler that cannot listen (`not-a-listener`), a misspelled event
|
|
84
|
-
(`event-name-typo`). Production carries none of the warnings.
|
|
87
|
+
(`event-name-typo`). Production carries none of the warnings. One known difference, in the DOM's shape only: a hole that
|
|
88
|
+
is its element's only content and went from a list to text to `null` ends holding only lite's position marker (a comment)
|
|
89
|
+
where a fresh render holds an empty text node — the same text and the same rendering, a different node.
|
|
85
90
|
|
|
86
91
|
**Moving up.** A component written for lite runs on `@verajs/core`: add `@verajs/core` and `@verajs/renderer`, change
|
|
87
92
|
the import, and `wire([renderer])`. The refusals are the same in both: escaped text, no script URLs (in an attribute or
|
|
@@ -98,6 +98,13 @@ declare const define: <M extends Methods = Record<never, never>, P extends objec
|
|
|
98
98
|
methods?: M & ThisType<HTMLElement & WithAttributes<P, A> & M>;
|
|
99
99
|
}), setup: (host: HTMLElement & WithAttributes<P, A> & M) => (() => unknown) | void) => DefinedClass<WithAttributes<P, A> & M>;
|
|
100
100
|
|
|
101
|
+
/**
|
|
102
|
+
* **Whether this code is running on the server** — `true` while `@verajs/ssr` renders, `false` in a browser: the same
|
|
103
|
+
* function as `@verajs/core`'s, so a component that guards per-user state with `if (!isServer()) …` runs unchanged on
|
|
104
|
+
* either tier. Its own copy, because lite imports nothing; both read the flag `@verajs/ssr` sets on the global, when called.
|
|
105
|
+
*/
|
|
106
|
+
declare const isServer: () => boolean;
|
|
107
|
+
|
|
101
108
|
/** The empty call first so a no-argument call matches it, the valued one last so `ReturnType` means the common case (as core). */
|
|
102
109
|
type SignalFactory = {
|
|
103
110
|
<T = undefined>(): Signal<T | undefined>;
|
|
@@ -116,6 +123,6 @@ declare const svg: (strings: TemplateStringsArray, ...values: unknown[]) => Temp
|
|
|
116
123
|
/** The `mathml` tagged template — markup parsed as MathML, for a fragment that is not inside a `<math>` element. */
|
|
117
124
|
declare const mathml: (strings: TemplateStringsArray, ...values: unknown[]) => TemplateResult<3>;
|
|
118
125
|
|
|
119
|
-
export { define, html, mathml, signal, svg };
|
|
126
|
+
export { define, html, isServer, mathml, signal, svg };
|
|
120
127
|
export type { DefineOptions, DefinedClass, LiteElement, LiteRoot, Methods, ResultType, Signal, TemplateResult, WithAttributes };
|
|
121
128
|
//# sourceMappingURL=vera-lite.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vera-lite.d.ts","sources":["../../src/define.ts","../../src/signal.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;AACA;AAGA;AACA;AAGA;AACA;;AAEE;AACF;AAEA;AACA;AACE;AACE;;AAEJ;AAEA;;;AAGG;AACH,0BAA0B,YAAkC,GAAE,cAAE;AAC9D,kBAA+C,WAAW,GAAA,cAAU,0CAAA,YAAA,CAAA,cAAA;;
|
|
1
|
+
{"version":3,"file":"vera-lite.d.ts","sources":["../../src/define.ts","../../src/isServer.ts","../../src/signal.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;AACA;AAGA;AACA;AAGA;AACA;;AAEE;AACF;AAEA;AACA;AACE;AACE;;AAEJ;AAEA;;;AAGG;AACH,0BAA0B,YAAkC,GAAE,cAAE;AAC9D,kBAA+C,WAAW,GAAA,cAAU,0CAAA,YAAA,CAAA,cAAA;;AC3BtE;;;;AAIG;AACH,cAAa,QAAQ;;ACJrB;AACA,KAAA,aAAkB;AAGlB,uBAAA,MAAA;AACA,0BAAsB,MAAA;AACtB;AAGA;;;;;;;;;;;;;;;","names":[]}
|
|
@@ -138,14 +138,15 @@ const unfinishedTag = () => [
|
|
|
138
138
|
'a template cannot end inside a tag — the parser drops an unfinished tag.',
|
|
139
139
|
'Close the tag inside the template.',
|
|
140
140
|
];
|
|
141
|
-
/** The renderer and spread (two bundles)
|
|
141
|
+
/** The renderer and spread (two bundles), `@verajs/lite` and `@verajs/static`; @verajs/ssr refuses the same URLs silently today. */
|
|
142
142
|
const scriptUrl = (name) => [
|
|
143
143
|
`\`${name}\` was given a javascript: URL — refused, and the attribute removed.`,
|
|
144
144
|
'A bound URL is data, and data must never become code.',
|
|
145
145
|
];
|
|
146
146
|
/**
|
|
147
|
-
* The renderer and spread
|
|
148
|
-
* emitter's own spelling of a property binding — a template's
|
|
147
|
+
* The renderer and spread, `@verajs/lite` and `@verajs/static`: `kind` is what the value was (dev-values'
|
|
148
|
+
* `attributeValueKind`); `property` is the emitter's own spelling of a property binding — a template's
|
|
149
|
+
* `.name=${value}`, a spread's `'.name': value`.
|
|
149
150
|
*/
|
|
150
151
|
const attributeValue = (name, kind, property) => [
|
|
151
152
|
`the attribute \`${name}\` was given ${kind}. An attribute value is a string and nothing else.`,
|
|
@@ -240,7 +241,7 @@ const defineTag = (received) => [
|
|
|
240
241
|
`expected a custom element name — a string with a hyphen, not at the start — and received ${received}.`,
|
|
241
242
|
"Name it the way the platform requires: `define('x-card', setup)` or `define({ tag: 'x-card' }, setup)`.",
|
|
242
243
|
];
|
|
243
|
-
const
|
|
244
|
+
const tagDefinedAgain = (tag) => [
|
|
244
245
|
`<${tag}> is already defined; the platform refuses a second definition of a tag and throws next.`,
|
|
245
246
|
'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
|
];
|
|
@@ -249,8 +250,8 @@ const setupReturnedValue = (kind) => [
|
|
|
249
250
|
'Return a render function — `return () => html`…`;` — the setup runs once, the render on every change.',
|
|
250
251
|
];
|
|
251
252
|
/**
|
|
252
|
-
* **A boolean at a child position renders as the WORD** — said in development by `@verajs/renderer
|
|
253
|
-
* (moved from the renderer's table, 2026-11-19:
|
|
253
|
+
* **A boolean at a child position renders as the WORD** — said in development by `@verajs/renderer`, `@verajs/lite` and
|
|
254
|
+
* `@verajs/static` (moved from the renderer's table, 2026-11-19: the small tiers say core's development diagnostics too).
|
|
254
255
|
*/
|
|
255
256
|
const booleanChild = (value) => [
|
|
256
257
|
`a child position was given \`${value}\`, which renders as the word "${value}" — the usual cause is \`\${cond && …}\` with a false \`cond\`.`,
|
|
@@ -514,7 +515,7 @@ const checkDefine = (area, tag, setup, swapping) => {
|
|
|
514
515
|
throw new TypeError(misuse('define', 'define-setup', true && defineSetup(String(setup))));
|
|
515
516
|
/** Silent while `@verajs/hot` is wired (`swapping`: it sets `$hot` on core's registry): a redefine is then a swap. */
|
|
516
517
|
if (customElements.get(tag) !== undefined && true)
|
|
517
|
-
console.warn(diagnostic(area, `define('${tag}')`, '
|
|
518
|
+
console.warn(diagnostic(area, `define('${tag}')`, 'tag-defined-again', true && tagDefinedAgain(tag)));
|
|
518
519
|
};
|
|
519
520
|
/** Development: every check of one `define` call, in order — the tag and setup first, as the platform would throw next. */
|
|
520
521
|
const checkDefinition = (area, tag, setup, methods, props, attributes, swapping) => {
|
|
@@ -1656,6 +1657,13 @@ const define = (target, setup) => {
|
|
|
1656
1657
|
return customElements.get(tag);
|
|
1657
1658
|
};
|
|
1658
1659
|
|
|
1660
|
+
/**
|
|
1661
|
+
* **Whether this code is running on the server** — `true` while `@verajs/ssr` renders, `false` in a browser: the same
|
|
1662
|
+
* function as `@verajs/core`'s, so a component that guards per-user state with `if (!isServer()) …` runs unchanged on
|
|
1663
|
+
* either tier. Its own copy, because lite imports nothing; both read the flag `@verajs/ssr` sets on the global, when called.
|
|
1664
|
+
*/
|
|
1665
|
+
const isServer = () => !!globalThis._$ssr$;
|
|
1666
|
+
|
|
1659
1667
|
/** Where a signal keeps its value and its readers: symbols private to this copy, so no key, spread or JSON shows them. */
|
|
1660
1668
|
const HELD = Symbol();
|
|
1661
1669
|
const READERS = Symbol();
|
|
@@ -1742,5 +1750,5 @@ const mathml = (strings, ...values) => {
|
|
|
1742
1750
|
return { ['_$litType$']: 3, strings, values };
|
|
1743
1751
|
};
|
|
1744
1752
|
|
|
1745
|
-
export { define, html, mathml, signal, svg };
|
|
1753
|
+
export { define, html, isServer, mathml, signal, svg };
|
|
1746
1754
|
//# sourceMappingURL=vera-lite.js.map
|