@verajs/ssr 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +369 -8
- package/package.json +37 -4
- package/src/vera/escaping.js +135 -0
- package/src/vera/events.js +164 -0
- package/src/vera/frames.js +102 -0
- package/src/vera/index.js +1116 -46
- package/src/vera/nodes.js +2270 -0
- package/src/vera/parse.js +381 -0
- package/src/vera/reflections.js +811 -0
- package/src/vera/registry.js +9 -0
- package/src/vera/select.js +234 -0
- package/src/vera/serializer.js +835 -32
- package/src/vera/shim.js +734 -108
- package/src/vera/stylesheets.js +155 -0
- package/src/vera/views.js +240 -0
- package/types/escaping.d.ts +27 -0
- package/types/events.d.ts +4 -0
- package/types/frames.d.ts +12 -0
- package/types/index.d.ts +13 -0
- package/types/nodes.d.ts +738 -0
- package/types/parse.d.ts +19 -0
- package/types/reflections.d.ts +657 -0
- package/types/registry.d.ts +8 -0
- package/types/select.d.ts +5 -0
- package/types/serializer.d.ts +26 -0
- package/types/shim.d.ts +23 -0
- package/types/stylesheets.d.ts +53 -0
- package/types/views.d.ts +26 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function serializeTemplate(template: any): any;
|
|
2
|
+
/**
|
|
3
|
+
* A name that cannot be written into a tag safely.
|
|
4
|
+
*
|
|
5
|
+
* A spread's keys are the one part of a template that is runtime data — that is what the module is
|
|
6
|
+
* for — and they were interpolated into the open tag with no check at all, while every *value*
|
|
7
|
+
* around them was escaped. A key carrying a quote or a `>` therefore closed the attribute, or the
|
|
8
|
+
* element:
|
|
9
|
+
*
|
|
10
|
+
* spread({ 'x><script>alert(1)</script': '1' })
|
|
11
|
+
* -> <b x><script>alert(1)</script="1">x</b>
|
|
12
|
+
*
|
|
13
|
+
* The set is the HTML attribute-name restriction — control characters, whitespace, `"`, `'`, `>`,
|
|
14
|
+
* `/`, `=` — plus `<` and a backtick, which the specification permits and no real name uses.
|
|
15
|
+
*
|
|
16
|
+
* It is deliberately **stricter than `setAttribute`**, which was measured in Chromium and accepts
|
|
17
|
+
* `"`, `'` and `<` while rejecting whitespace, `>`, `=`, `/` and NUL. A name the platform accepts
|
|
18
|
+
* but markup cannot carry is unusable in a framework that server-renders, so `@verajs/renderer/spread`
|
|
19
|
+
* applies this same rule client-side and the two sides agree on every key rather than one of them
|
|
20
|
+
* quietly serving different markup.
|
|
21
|
+
*
|
|
22
|
+
* The control-character range is the point of the rule, not a mistake in it: a name carrying one
|
|
23
|
+
* is exactly what must never reach markup.
|
|
24
|
+
*/
|
|
25
|
+
export const UNSAFE_ATTRIBUTE_NAME: RegExp;
|
|
26
|
+
export function serializeValue(value: any, raw?: boolean): any;
|
package/types/shim.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which parts of a URL `location` carries — the one place that knows.
|
|
3
|
+
*
|
|
4
|
+
* `index.js` kept its own copy for `applyLocation`/`restoreLocation` to walk. They agreed, and
|
|
5
|
+
* nothing made them: a part added to one list would be installed and never restored, or restored
|
|
6
|
+
* from a property the install never wrote. Same single fact, same reasoning as `RAW_TEXT_ELEMENTS`
|
|
7
|
+
* below it — CODE-PRINCIPLES #5.
|
|
8
|
+
*/
|
|
9
|
+
export const LOCATION_PARTS: string[];
|
|
10
|
+
export function installShims(): Map<any, any>;
|
|
11
|
+
import { escapeHtml } from './escaping.js';
|
|
12
|
+
import { escapeStyleText } from './escaping.js';
|
|
13
|
+
import { escapeRawText } from './escaping.js';
|
|
14
|
+
import { RAW_TEXT_ELEMENTS } from './escaping.js';
|
|
15
|
+
import { hoistedStyles } from './stylesheets.js';
|
|
16
|
+
import { beginHoisting } from './stylesheets.js';
|
|
17
|
+
import { setRenderingTag } from './stylesheets.js';
|
|
18
|
+
import { flushFrames } from './frames.js';
|
|
19
|
+
import { flushFramesAsync } from './frames.js';
|
|
20
|
+
import { registry } from './registry.js';
|
|
21
|
+
import { pendingInstances } from './nodes.js';
|
|
22
|
+
import { INSTANCE_ATTRIBUTE } from './nodes.js';
|
|
23
|
+
export { escapeHtml, escapeStyleText, escapeRawText, RAW_TEXT_ELEMENTS, hoistedStyles, beginHoisting, setRenderingTag, flushFrames, flushFramesAsync, registry, pendingInstances, INSTANCE_ATTRIBUTE };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `CSSStyleSheet`, and the collection of styles a render hoists out of the components it touched.
|
|
3
|
+
*
|
|
4
|
+
* A component's CSS reaches the page two ways — a `<style>` element in its shadow root, serialized
|
|
5
|
+
* with it, or a constructed sheet adopted into the document, which has no markup of its own. The
|
|
6
|
+
* second is what `hoistedStyles` holds, keyed by the tag that was rendering when it was adopted, so
|
|
7
|
+
* a page assembled from several islands can ship each component's CSS exactly once.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* `@scope (tag) { … }` styles hoisted by light-DOM components, **keyed by the component that
|
|
11
|
+
* hoisted them** — the page shell embeds only the ones on the page it is building.
|
|
12
|
+
*
|
|
13
|
+
* A flat array here meant `renderToString` returned every style the *process* had ever hoisted, so
|
|
14
|
+
* request two shipped request one's CSS and request fifty shipped everyone's. `adoptStyles` hoists
|
|
15
|
+
* once per class by design, so it never grew without bound — it simply described the wrong page.
|
|
16
|
+
*/
|
|
17
|
+
export const hoistedStyles: Map<any, any>;
|
|
18
|
+
export function setRenderingTag(tag: any): string;
|
|
19
|
+
export class StyleSheetShim {
|
|
20
|
+
cssText: string;
|
|
21
|
+
/**
|
|
22
|
+
* **`cssText` is always a string**, because the platform's argument is a `USVString` and it
|
|
23
|
+
* parses what it is given. Assigning the caller's value straight through left a number, an array
|
|
24
|
+
* or a plain object sitting on `cssText`, which then reached the `<style>` block by concatenation
|
|
25
|
+
* — so the wrong text appeared a long way from the call that caused it. Template coercion also
|
|
26
|
+
* refuses a symbol with a `TypeError`, which is what every engine does
|
|
27
|
+
* (`tests/browser/dom-string-coercion.test.js`).
|
|
28
|
+
*/
|
|
29
|
+
replaceSync(cssText: any): void;
|
|
30
|
+
/** The async spelling of the same thing; `adoptStyles` uses `replaceSync`, a component may not. */
|
|
31
|
+
replace(cssText: any): Promise<this>;
|
|
32
|
+
insertRule(rule: any): number;
|
|
33
|
+
/**
|
|
34
|
+
* There is no rule *list* — this holds the stylesheet as text, which is all the markup needs —
|
|
35
|
+
* so a rule cannot be addressed by index. Deleting one is refused rather than silently ignored.
|
|
36
|
+
*/
|
|
37
|
+
deleteRule(): void;
|
|
38
|
+
/** The pre-standard spellings, which are still what some libraries reach for. */
|
|
39
|
+
addRule(selector: any, style: any): number;
|
|
40
|
+
removeRule(): void;
|
|
41
|
+
get cssRules(): never[];
|
|
42
|
+
get rules(): never[];
|
|
43
|
+
get ownerRule(): null;
|
|
44
|
+
get ownerNode(): null;
|
|
45
|
+
get parentStyleSheet(): null;
|
|
46
|
+
get href(): null;
|
|
47
|
+
get title(): null;
|
|
48
|
+
get media(): never[];
|
|
49
|
+
get type(): string;
|
|
50
|
+
disabled: boolean;
|
|
51
|
+
}
|
|
52
|
+
export function beginHoisting(): void;
|
|
53
|
+
export function hoist(cssText: any): void;
|
package/types/views.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function datasetView(element: any): {};
|
|
2
|
+
export function tokenListView(element: any, attribute: any): {
|
|
3
|
+
add: (...names: any[]) => void;
|
|
4
|
+
remove: (...names: any[]) => void;
|
|
5
|
+
toggle: (name: any, force: any) => any;
|
|
6
|
+
/** Replaces in place, and answers `false` without writing when the old token is not there. */
|
|
7
|
+
replace: (oldToken: any, newToken: any) => boolean;
|
|
8
|
+
contains: (name: any) => any;
|
|
9
|
+
/**
|
|
10
|
+
* `supports` throws for these two lists in every engine — `class` and `part` define no supported
|
|
11
|
+
* tokens, and the spec says a `DOMTokenList` with none raises `TypeError`. Present and throwing
|
|
12
|
+
* is the accurate shim; absent would be a `TypeError` too, but the wrong one.
|
|
13
|
+
*/
|
|
14
|
+
supports: () => never;
|
|
15
|
+
item: (index: any) => any;
|
|
16
|
+
forEach: (callback: any, thisArg: any) => any;
|
|
17
|
+
keys: () => any;
|
|
18
|
+
values: () => any;
|
|
19
|
+
entries: () => any;
|
|
20
|
+
/** `String(el.classList)` is the attribute's value, not `[object Object]`. */
|
|
21
|
+
toString: () => any;
|
|
22
|
+
value: any;
|
|
23
|
+
readonly length: any;
|
|
24
|
+
[Symbol.iterator]: () => any;
|
|
25
|
+
};
|
|
26
|
+
export function styleView(element: any): {};
|