@gyral/core 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +87 -0
- package/README.md +7 -5
- package/dist/children.d.ts +5 -2
- package/dist/children.js +8 -3
- package/dist/children.js.map +1 -1
- package/dist/command.js +6 -0
- package/dist/command.js.map +1 -1
- package/dist/compiler/ast.d.ts +21 -0
- package/dist/compiler/ast.js +145 -0
- package/dist/compiler/ast.js.map +1 -0
- package/dist/compiler/compile.d.ts +38 -0
- package/dist/compiler/compile.js +129 -0
- package/dist/compiler/compile.js.map +1 -0
- package/dist/compiler/hooks.d.ts +18 -0
- package/dist/compiler/hooks.js +186 -0
- package/dist/compiler/hooks.js.map +1 -0
- package/dist/compiler/parse5-check.d.ts +21 -0
- package/dist/compiler/parse5-check.js +55 -0
- package/dist/compiler/parse5-check.js.map +1 -0
- package/dist/compiler/scan.d.ts +31 -0
- package/dist/compiler/scan.js +152 -0
- package/dist/compiler/scan.js.map +1 -0
- package/dist/compiler/source.d.ts +34 -0
- package/dist/compiler/source.js +114 -0
- package/dist/compiler/source.js.map +1 -0
- package/dist/define.d.ts +2 -2
- package/dist/define.js +35 -327
- package/dist/define.js.map +1 -1
- package/dist/devtools-events.d.ts +5 -0
- package/dist/devtools-events.js.map +1 -1
- package/dist/devtools-off.d.ts +1 -0
- package/dist/devtools-off.js +1 -0
- package/dist/devtools-off.js.map +1 -1
- package/dist/devtools.d.ts +1 -0
- package/dist/devtools.js +3 -2
- package/dist/devtools.js.map +1 -1
- package/dist/drivers-scope.d.ts +1 -1
- package/dist/drivers-scope.js +1 -8
- package/dist/drivers-scope.js.map +1 -1
- package/dist/element-types.d.ts +5 -3
- package/dist/element-types.js.map +1 -1
- package/dist/element.d.ts +3 -0
- package/dist/element.js +269 -0
- package/dist/element.js.map +1 -0
- package/dist/eslint/imports.d.ts +24 -0
- package/dist/eslint/imports.js +78 -0
- package/dist/eslint/imports.js.map +1 -0
- package/dist/eslint/index.d.ts +15 -0
- package/dist/eslint/index.js +15 -0
- package/dist/eslint/index.js.map +1 -0
- package/dist/eslint/locate.d.ts +33 -0
- package/dist/eslint/locate.js +132 -0
- package/dist/eslint/locate.js.map +1 -0
- package/dist/eslint/row-purity-rule.d.ts +2 -0
- package/dist/eslint/row-purity-rule.js +103 -0
- package/dist/eslint/row-purity-rule.js.map +1 -0
- package/dist/eslint/template-rule.d.ts +5 -0
- package/dist/eslint/template-rule.js +66 -0
- package/dist/eslint/template-rule.js.map +1 -0
- package/dist/features.d.ts +39 -0
- package/dist/features.js +2 -0
- package/dist/features.js.map +1 -0
- package/dist/focus.d.ts +7 -12
- package/dist/focus.js +13 -10
- package/dist/focus.js.map +1 -1
- package/dist/hooks/invalid.d.ts +14 -0
- package/dist/hooks/invalid.js +72 -0
- package/dist/hooks/invalid.js.map +1 -0
- package/dist/hooks/labelled-by.d.ts +13 -0
- package/dist/hooks/labelled-by.js +51 -0
- package/dist/hooks/labelled-by.js.map +1 -0
- package/dist/host-model.d.ts +48 -0
- package/dist/host-model.js +155 -0
- package/dist/host-model.js.map +1 -0
- package/dist/hydration-client.d.ts +9 -0
- package/dist/hydration-client.js +35 -0
- package/dist/hydration-client.js.map +1 -0
- package/dist/hydration.d.ts +13 -19
- package/dist/hydration.js +45 -45
- package/dist/hydration.js.map +1 -1
- package/dist/index.d.ts +9 -17
- package/dist/index.js +9 -18
- package/dist/index.js.map +1 -1
- package/dist/intent.d.ts +31 -8
- package/dist/intent.js +82 -27
- package/dist/intent.js.map +1 -1
- package/dist/internal/interpreter.d.ts +7 -1
- package/dist/internal/interpreter.js +11 -4
- package/dist/internal/interpreter.js.map +1 -1
- package/dist/invokers-shim.d.ts +6 -0
- package/dist/invokers-shim.js +32 -0
- package/dist/invokers-shim.js.map +1 -0
- package/dist/invokers.d.ts +3 -5
- package/dist/invokers.js +11 -51
- package/dist/invokers.js.map +1 -1
- package/dist/islands.d.ts +0 -2
- package/dist/islands.js +4 -11
- package/dist/islands.js.map +1 -1
- package/dist/light-dom.d.ts +3 -52
- package/dist/light-dom.js +5 -100
- package/dist/light-dom.js.map +1 -1
- package/dist/prop.d.ts +66 -0
- package/dist/prop.js +22 -0
- package/dist/prop.js.map +1 -0
- package/dist/props.d.ts +52 -21
- package/dist/props.js +150 -34
- package/dist/props.js.map +1 -1
- package/dist/scheduler.d.ts +39 -0
- package/dist/scheduler.js +230 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/server-component.d.ts +10 -0
- package/dist/server-component.js +102 -0
- package/dist/server-component.js.map +1 -0
- package/dist/server-specs.d.ts +6 -0
- package/dist/server-specs.js +13 -0
- package/dist/server-specs.js.map +1 -0
- package/dist/server.d.ts +28 -0
- package/dist/server.js +50 -0
- package/dist/server.js.map +1 -0
- package/dist/settled.d.ts +10 -0
- package/dist/settled.js +40 -0
- package/dist/settled.js.map +1 -0
- package/dist/states.d.ts +3 -3
- package/dist/states.js +4 -7
- package/dist/states.js.map +1 -1
- package/dist/store-binding.d.ts +6 -3
- package/dist/store-binding.js +5 -6
- package/dist/store-binding.js.map +1 -1
- package/dist/store-scope.d.ts +6 -7
- package/dist/store-scope.js +11 -26
- package/dist/store-scope.js.map +1 -1
- package/dist/store.d.ts +3 -0
- package/dist/store.js +9 -2
- package/dist/store.js.map +1 -1
- package/dist/stores-provider.d.ts +2 -6
- package/dist/stores-provider.js +21 -55
- package/dist/stores-provider.js.map +1 -1
- package/dist/transitions.d.ts +5 -6
- package/dist/transitions.js +11 -20
- package/dist/transitions.js.map +1 -1
- package/dist/types.d.ts +19 -23
- package/dist/types.js.map +1 -1
- package/dist/view/attributes.d.ts +6 -0
- package/dist/view/attributes.js +10 -0
- package/dist/view/attributes.js.map +1 -0
- package/dist/view/compiled.d.ts +1 -0
- package/dist/view/compiled.js +6 -0
- package/dist/view/compiled.js.map +1 -0
- package/dist/view/dev-off.d.ts +1 -0
- package/dist/view/dev-off.js +4 -0
- package/dist/view/dev-off.js.map +1 -0
- package/dist/view/dev.d.ts +1 -0
- package/dist/view/dev.js +5 -0
- package/dist/view/dev.js.map +1 -0
- package/dist/view/flags.d.ts +1 -0
- package/dist/view/flags.js +4 -0
- package/dist/view/flags.js.map +1 -0
- package/dist/view/index.d.ts +21 -0
- package/dist/view/index.js +21 -0
- package/dist/view/index.js.map +1 -0
- package/dist/view/normalize/check.d.ts +20 -0
- package/dist/view/normalize/check.js +78 -0
- package/dist/view/normalize/check.js.map +1 -0
- package/dist/view/normalize/emit.d.ts +13 -0
- package/dist/view/normalize/emit.js +136 -0
- package/dist/view/normalize/emit.js.map +1 -0
- package/dist/view/normalize/entities.d.ts +4 -0
- package/dist/view/normalize/entities.js +38 -0
- package/dist/view/normalize/entities.js.map +1 -0
- package/dist/view/normalize/errors.d.ts +9 -0
- package/dist/view/normalize/errors.js +19 -0
- package/dist/view/normalize/errors.js.map +1 -0
- package/dist/view/normalize/id.d.ts +7 -0
- package/dist/view/normalize/id.js +48 -0
- package/dist/view/normalize/id.js.map +1 -0
- package/dist/view/normalize/normalize.d.ts +15 -0
- package/dist/view/normalize/normalize.js +36 -0
- package/dist/view/normalize/normalize.js.map +1 -0
- package/dist/view/normalize/repairs.d.ts +24 -0
- package/dist/view/normalize/repairs.js +166 -0
- package/dist/view/normalize/repairs.js.map +1 -0
- package/dist/view/normalize/rules.d.ts +30 -0
- package/dist/view/normalize/rules.js +90 -0
- package/dist/view/normalize/rules.js.map +1 -0
- package/dist/view/normalize/shape.d.ts +5 -0
- package/dist/view/normalize/shape.js +38 -0
- package/dist/view/normalize/shape.js.map +1 -0
- package/dist/view/normalize/source.d.ts +13 -0
- package/dist/view/normalize/source.js +34 -0
- package/dist/view/normalize/source.js.map +1 -0
- package/dist/view/normalize/tag-states.d.ts +23 -0
- package/dist/view/normalize/tag-states.js +192 -0
- package/dist/view/normalize/tag-states.js.map +1 -0
- package/dist/view/normalize/tokenizer.d.ts +5 -0
- package/dist/view/normalize/tokenizer.js +233 -0
- package/dist/view/normalize/tokenizer.js.map +1 -0
- package/dist/view/normalize/tokens.d.ts +51 -0
- package/dist/view/normalize/tokens.js +24 -0
- package/dist/view/normalize/tokens.js.map +1 -0
- package/dist/view/normalize/tree.d.ts +59 -0
- package/dist/view/normalize/tree.js +190 -0
- package/dist/view/normalize/tree.js.map +1 -0
- package/dist/view/normalize/types.d.ts +126 -0
- package/dist/view/normalize/types.js +26 -0
- package/dist/view/normalize/types.js.map +1 -0
- package/dist/view/normalize/whitespace.d.ts +2 -0
- package/dist/{template-whitespace.js → view/normalize/whitespace.js} +24 -34
- package/dist/view/normalize/whitespace.js.map +1 -0
- package/dist/view/prepare-stub.d.ts +3 -0
- package/dist/view/prepare-stub.js +7 -0
- package/dist/view/prepare-stub.js.map +1 -0
- package/dist/view/prepare.d.ts +8 -0
- package/dist/view/prepare.js +57 -0
- package/dist/view/prepare.js.map +1 -0
- package/dist/view/registry.d.ts +63 -0
- package/dist/view/registry.js +19 -0
- package/dist/view/registry.js.map +1 -0
- package/dist/view/render/adopt-attr.d.ts +14 -0
- package/dist/view/render/adopt-attr.js +77 -0
- package/dist/view/render/adopt-attr.js.map +1 -0
- package/dist/view/render/adopt-plan.d.ts +10 -0
- package/dist/view/render/adopt-plan.js +26 -0
- package/dist/view/render/adopt-plan.js.map +1 -0
- package/dist/view/render/adopt.d.ts +3 -0
- package/dist/view/render/adopt.js +269 -0
- package/dist/view/render/adopt.js.map +1 -0
- package/dist/view/render/attr-parts.d.ts +61 -0
- package/dist/view/render/attr-parts.js +229 -0
- package/dist/view/render/attr-parts.js.map +1 -0
- package/dist/view/render/child-part.d.ts +51 -0
- package/dist/view/render/child-part.js +170 -0
- package/dist/view/render/child-part.js.map +1 -0
- package/dist/view/render/dev-check.d.ts +12 -0
- package/dist/view/render/dev-check.js +122 -0
- package/dist/view/render/dev-check.js.map +1 -0
- package/dist/view/render/hook-part.d.ts +3 -0
- package/dist/view/render/hook-part.js +20 -0
- package/dist/view/render/hook-part.js.map +1 -0
- package/dist/view/render/hooks.d.ts +40 -0
- package/dist/view/render/hooks.js +46 -0
- package/dist/view/render/hooks.js.map +1 -0
- package/dist/view/render/hydrate.d.ts +10 -0
- package/dist/view/render/hydrate.js +33 -0
- package/dist/view/render/hydrate.js.map +1 -0
- package/dist/view/render/instance.d.ts +33 -0
- package/dist/view/render/instance.js +107 -0
- package/dist/view/render/instance.js.map +1 -0
- package/dist/view/render/list.d.ts +20 -0
- package/dist/view/render/list.js +156 -0
- package/dist/view/render/list.js.map +1 -0
- package/dist/view/render/mismatch.d.ts +10 -0
- package/dist/view/render/mismatch.js +53 -0
- package/dist/view/render/mismatch.js.map +1 -0
- package/dist/view/render/nodes.d.ts +10 -0
- package/dist/view/render/nodes.js +37 -0
- package/dist/view/render/nodes.js.map +1 -0
- package/dist/view/render/place.d.ts +18 -0
- package/dist/view/render/place.js +69 -0
- package/dist/view/render/place.js.map +1 -0
- package/dist/view/render/plan.d.ts +26 -0
- package/dist/view/render/plan.js +124 -0
- package/dist/view/render/plan.js.map +1 -0
- package/dist/view/render/raw.d.ts +18 -0
- package/dist/view/render/raw.js +68 -0
- package/dist/view/render/raw.js.map +1 -0
- package/dist/view/render/render.d.ts +12 -0
- package/dist/view/render/render.js +60 -0
- package/dist/view/render/render.js.map +1 -0
- package/dist/view/render/reorder.d.ts +4 -0
- package/dist/view/render/reorder.js +101 -0
- package/dist/view/render/reorder.js.map +1 -0
- package/dist/view/render/rows.d.ts +23 -0
- package/dist/view/render/rows.js +95 -0
- package/dist/view/render/rows.js.map +1 -0
- package/dist/view/render/seen.d.ts +11 -0
- package/dist/view/render/seen.js +17 -0
- package/dist/view/render/seen.js.map +1 -0
- package/dist/view/render/values.d.ts +29 -0
- package/dist/view/render/values.js +13 -0
- package/dist/view/render/values.js.map +1 -0
- package/dist/view/render/warn.d.ts +14 -0
- package/dist/view/render/warn.js +69 -0
- package/dist/view/render/warn.js.map +1 -0
- package/dist/view/server/component.d.ts +9 -0
- package/dist/view/server/component.js +42 -0
- package/dist/view/server/component.js.map +1 -0
- package/dist/view/server/escape.d.ts +10 -0
- package/dist/view/server/escape.js +34 -0
- package/dist/view/server/escape.js.map +1 -0
- package/dist/view/server/index.d.ts +28 -0
- package/dist/view/server/index.js +72 -0
- package/dist/view/server/index.js.map +1 -0
- package/dist/view/server/sha256.d.ts +2 -0
- package/dist/view/server/sha256.js +75 -0
- package/dist/view/server/sha256.js.map +1 -0
- package/dist/view/server/tags.d.ts +57 -0
- package/dist/view/server/tags.js +121 -0
- package/dist/view/server/tags.js.map +1 -0
- package/dist/view/server/values.d.ts +16 -0
- package/dist/view/server/values.js +86 -0
- package/dist/view/server/values.js.map +1 -0
- package/dist/view/server/writer.d.ts +16 -0
- package/dist/view/server/writer.js +155 -0
- package/dist/view/server/writer.js.map +1 -0
- package/dist/view/styles.d.ts +25 -0
- package/dist/view/styles.js +58 -0
- package/dist/view/styles.js.map +1 -0
- package/dist/view/template-element.d.ts +3 -0
- package/dist/view/template-element.js +25 -0
- package/dist/view/template-element.js.map +1 -0
- package/dist/view/template.d.ts +21 -0
- package/dist/view/template.js +30 -0
- package/dist/view/template.js.map +1 -0
- package/dist/vite.d.ts +45 -6
- package/dist/vite.js +150 -25
- package/dist/vite.js.map +1 -1
- package/package.json +39 -4
- package/dist/accessible-name.d.ts +0 -19
- package/dist/accessible-name.js +0 -56
- package/dist/accessible-name.js.map +0 -1
- package/dist/element-directive.d.ts +0 -20
- package/dist/element-directive.js +0 -31
- package/dist/element-directive.js.map +0 -1
- package/dist/invalid.d.ts +0 -21
- package/dist/invalid.js +0 -70
- package/dist/invalid.js.map +0 -1
- package/dist/lit-html-check.d.ts +0 -6
- package/dist/lit-html-check.js +0 -48
- package/dist/lit-html-check.js.map +0 -1
- package/dist/live-boolean.d.ts +0 -22
- package/dist/live-boolean.js +0 -34
- package/dist/live-boolean.js.map +0 -1
- package/dist/styles.d.ts +0 -12
- package/dist/styles.js +0 -11
- package/dist/styles.js.map +0 -1
- package/dist/template-whitespace.d.ts +0 -7
- package/dist/template-whitespace.js.map +0 -1
- package/dist/templates.d.ts +0 -5
- package/dist/templates.js +0 -15
- package/dist/templates.js.map +0 -1
- package/dist/textarea.d.ts +0 -26
- package/dist/textarea.js +0 -85
- package/dist/textarea.js.map +0 -1
package/dist/stores-provider.js
CHANGED
|
@@ -1,57 +1,23 @@
|
|
|
1
|
-
// `<gyral-stores>`
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
|
|
1
|
+
// `<gyral-stores>` on the server (ADR 0013, view/06-server.md "Components"). In the browser a
|
|
2
|
+
// provider is a plain element: scopeFor() walks the DOM to it. On the server it is written as a
|
|
3
|
+
// plain element too, and the renderer gives its subtree the provider's registry (components'
|
|
4
|
+
// `ctx.read` resolves there) and writes its `data-gyral-stores` seed: the states of the
|
|
5
|
+
// instances passed in `.instances`. Stores not listed start from `init` on both sides.
|
|
6
6
|
import { warnJsonHazard } from './json-safety.js';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// Written before the attributes render; the client restores it (providerScope()).
|
|
24
|
-
if (value !== undefined && value.length > 0) {
|
|
25
|
-
const seed = Object.fromEntries(value.map((i) => [i.store.name, i.state]));
|
|
26
|
-
for (const [name, state] of Object.entries(seed)) {
|
|
27
|
-
warnJsonHazard(`store "${name}" in <${STORES_ELEMENT}>`, state, 'state');
|
|
28
|
-
}
|
|
29
|
-
this.setAttribute(STORE_SEED_ATTRIBUTE, JSON.stringify(seed));
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
constructor() {
|
|
33
|
-
super();
|
|
34
|
-
// Lit's SSR routes a slotted child's events slot → getRootNode() → host, and the root is
|
|
35
|
-
// only this element's shadow root if one exists; the renderer never calls connectedCallback
|
|
36
|
-
// (which would create it), so attach it here.
|
|
37
|
-
this.attachShadow({ mode: 'open' });
|
|
38
|
-
this.addEventListener(STORES_REQUEST, (event) => {
|
|
39
|
-
event.stopPropagation();
|
|
40
|
-
event.detail.registry = providerScope(this);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
render() {
|
|
44
|
-
return html `<slot></slot>`;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Registers `<gyral-stores>` for server renders; `@gyral/ssr` calls it. A no-op in the browser,
|
|
49
|
-
* where a plain `<gyral-stores>` element already scopes stores and the server's shadow root
|
|
50
|
-
* (a `<slot>`) needs no JavaScript. Idempotent.
|
|
51
|
-
*/
|
|
52
|
-
export function defineStoresProvider() {
|
|
53
|
-
if (onServer && customElements.get(STORES_ELEMENT) === undefined) {
|
|
54
|
-
customElements.define(STORES_ELEMENT, GyralStores);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
7
|
+
import { STORE_SEED_ATTRIBUTE, STORES_ELEMENT, StoreRegistry } from './store-scope.js';
|
|
8
|
+
import { DEV } from './view/index.js';
|
|
9
|
+
export const storesProvider = {
|
|
10
|
+
tag: STORES_ELEMENT,
|
|
11
|
+
open({ properties }) {
|
|
12
|
+
const listed = properties['instances'];
|
|
13
|
+
const instances = Array.isArray(listed) ? listed : [];
|
|
14
|
+
const registry = new StoreRegistry(instances);
|
|
15
|
+
if (instances.length === 0)
|
|
16
|
+
return { scope: registry, attributes: {} };
|
|
17
|
+
const snapshot = registry.snapshot();
|
|
18
|
+
if (DEV)
|
|
19
|
+
warnJsonHazard(`<${STORES_ELEMENT}>`, snapshot, 'seed');
|
|
20
|
+
return { scope: registry, attributes: { [STORE_SEED_ATTRIBUTE]: JSON.stringify(snapshot) } };
|
|
21
|
+
},
|
|
22
|
+
};
|
|
57
23
|
//# sourceMappingURL=stores-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stores-provider.js","sourceRoot":"","sources":["../src/stores-provider.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"stores-provider.js","sourceRoot":"","sources":["../src/stores-provider.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,gGAAgG;AAChG,6FAA6F;AAC7F,wFAAwF;AACxF,uFAAuF;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEvF,OAAO,EAAE,GAAG,EAAuB,MAAM,iBAAiB,CAAC;AAE3D,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C,GAAG,EAAE,cAAc;IACnB,IAAI,CAAC,EAAE,UAAU,EAAE;QACjB,MAAM,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;QACvC,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,MAAsC,CAAC,CAAC,CAAC,EAAE,CAAC;QACvF,MAAM,QAAQ,GAAG,IAAI,aAAa,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;QACvE,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACrC,IAAI,GAAG;YAAE,cAAc,CAAC,IAAI,cAAc,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QACjE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,CAAC,oBAAoB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;IAC/F,CAAC;CACF,CAAC","sourcesContent":["// `<gyral-stores>` on the server (ADR 0013, view/06-server.md \"Components\"). In the browser a\n// provider is a plain element: scopeFor() walks the DOM to it. On the server it is written as a\n// plain element too, and the renderer gives its subtree the provider's registry (components'\n// `ctx.read` resolves there) and writes its `data-gyral-stores` seed: the states of the\n// instances passed in `.instances`. Stores not listed start from `init` on both sides.\nimport { warnJsonHazard } from './json-safety.js';\nimport { STORE_SEED_ATTRIBUTE, STORES_ELEMENT, StoreRegistry } from './store-scope.js';\nimport type { AnyStoreInstance } from './store.js';\nimport { DEV, type ServerProvider } from './view/index.js';\n\nexport const storesProvider: ServerProvider = {\n tag: STORES_ELEMENT,\n open({ properties }) {\n const listed = properties['instances'];\n const instances = Array.isArray(listed) ? (listed as readonly AnyStoreInstance[]) : [];\n const registry = new StoreRegistry(instances);\n if (instances.length === 0) return { scope: registry, attributes: {} };\n const snapshot = registry.snapshot();\n if (DEV) warnJsonHazard(`<${STORES_ELEMENT}>`, snapshot, 'seed');\n return { scope: registry, attributes: { [STORE_SEED_ATTRIBUTE]: JSON.stringify(snapshot) } };\n },\n};\n"]}
|
package/dist/transitions.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/** True when a view transition may run now (API present, motion not reduced). */
|
|
2
|
-
export declare
|
|
2
|
+
export declare const canTransition: () => boolean;
|
|
3
3
|
/**
|
|
4
|
-
* Runs `update`
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* rejected `ready` is expected and swallowed.
|
|
4
|
+
* Runs `update` (a whole flush) as a view transition's update callback. A transition skipped
|
|
5
|
+
* by a newer one still runs its update (per spec); its rejected promises are expected and
|
|
6
|
+
* swallowed. Call only after `canTransition()`.
|
|
8
7
|
*/
|
|
9
|
-
export declare function
|
|
8
|
+
export declare function startTransition(update: () => void): void;
|
package/dist/transitions.js
CHANGED
|
@@ -1,26 +1,17 @@
|
|
|
1
|
-
// View Transitions for
|
|
2
|
-
// without the API, or with reduced motion requested,
|
|
3
|
-
|
|
1
|
+
// View Transitions for the scheduler (view/04-scheduler.md "View transitions", ADR 0001
|
|
2
|
+
// addendum). An ADR 0003 enhancement: without the API, or with reduced motion requested, the
|
|
3
|
+
// flush runs as normal.
|
|
4
4
|
const ignore = () => undefined;
|
|
5
5
|
/** True when a view transition may run now (API present, motion not reduced). */
|
|
6
|
-
export
|
|
7
|
-
if (typeof document === 'undefined' || !supportsViewTransitions(document))
|
|
8
|
-
return false;
|
|
9
|
-
return !window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
10
|
-
}
|
|
6
|
+
export const canTransition = () => 'startViewTransition' in document && !matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
11
7
|
/**
|
|
12
|
-
* Runs `update`
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* rejected `ready` is expected and swallowed.
|
|
8
|
+
* Runs `update` (a whole flush) as a view transition's update callback. A transition skipped
|
|
9
|
+
* by a newer one still runs its update (per spec); its rejected promises are expected and
|
|
10
|
+
* swallowed. Call only after `canTransition()`.
|
|
16
11
|
*/
|
|
17
|
-
export function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const transition = document.startViewTransition(() => update().then(resolve, reject));
|
|
22
|
-
transition.ready.catch(ignore);
|
|
23
|
-
transition.finished.catch(ignore);
|
|
24
|
-
});
|
|
12
|
+
export function startTransition(update) {
|
|
13
|
+
const transition = document.startViewTransition(update);
|
|
14
|
+
transition.ready.catch(ignore);
|
|
15
|
+
transition.finished.catch(ignore);
|
|
25
16
|
}
|
|
26
17
|
//# sourceMappingURL=transitions.js.map
|
package/dist/transitions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transitions.js","sourceRoot":"","sources":["../src/transitions.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"transitions.js","sourceRoot":"","sources":["../src/transitions.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,6FAA6F;AAC7F,wBAAwB;AAWxB,MAAM,MAAM,GAAG,GAAS,EAAE,CAAC,SAAS,CAAC;AAErC,iFAAiF;AACjF,MAAM,CAAC,MAAM,aAAa,GAAG,GAAY,EAAE,CACzC,qBAAqB,IAAI,QAAQ,IAAI,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC;AAE/F;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,MAAkB;IAChD,MAAM,UAAU,GAAI,QAA8C,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC/F,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC","sourcesContent":["// View Transitions for the scheduler (view/04-scheduler.md \"View transitions\", ADR 0001\n// addendum). An ADR 0003 enhancement: without the API, or with reduced motion requested, the\n// flush runs as normal.\n\ninterface ViewTransitionLike {\n readonly ready: Promise<unknown>;\n readonly finished: Promise<unknown>;\n}\n\ninterface ViewTransitionDocument {\n startViewTransition(update: () => void): ViewTransitionLike;\n}\n\nconst ignore = (): void => undefined;\n\n/** True when a view transition may run now (API present, motion not reduced). */\nexport const canTransition = (): boolean =>\n 'startViewTransition' in document && !matchMedia('(prefers-reduced-motion: reduce)').matches;\n\n/**\n * Runs `update` (a whole flush) as a view transition's update callback. A transition skipped\n * by a newer one still runs its update (per spec); its rejected promises are expected and\n * swallowed. Call only after `canTransition()`.\n */\nexport function startTransition(update: () => void): void {\n const transition = (document as Document & ViewTransitionDocument).startViewTransition(update);\n transition.ready.catch(ignore);\n transition.finished.catch(ignore);\n}\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Styles } from './
|
|
1
|
+
import type { Prop } from './prop.js';
|
|
2
|
+
import type { ChildValue, Styles } from './view/index.js';
|
|
3
3
|
import type { CommandInfo } from './invokers.js';
|
|
4
4
|
import type { HydrateStrategy } from './islands.js';
|
|
5
5
|
import type { DriverOverrides, Next } from './command.js';
|
|
@@ -106,25 +106,13 @@ export type IntentNames<M extends Tagged> = {
|
|
|
106
106
|
readonly [K in M['_tag']]: K;
|
|
107
107
|
};
|
|
108
108
|
/**
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* - `default: value`: used whenever the element's value is `undefined`.
|
|
114
|
-
* A prop whose type includes `undefined` needs neither.
|
|
109
|
+
* The prop builders for props type `P` (view/05-element.md "Props"): one `prop.*` builder per
|
|
110
|
+
* key. A builder's output type must fit the prop's type, so a prop whose type excludes
|
|
111
|
+
* `undefined` needs `required: true` or a `default` (the honesty rule, ADR 0007 addendum).
|
|
112
|
+
* Without explicit type arguments, `define()` infers `P` from the builders.
|
|
115
113
|
*/
|
|
116
|
-
export type PropDeclaration<T> = PropertyDeclaration & (undefined extends T ? {
|
|
117
|
-
readonly required?: false;
|
|
118
|
-
readonly default?: T;
|
|
119
|
-
} : {
|
|
120
|
-
readonly required: true;
|
|
121
|
-
readonly default?: undefined;
|
|
122
|
-
} | {
|
|
123
|
-
readonly required?: false;
|
|
124
|
-
readonly default: T;
|
|
125
|
-
});
|
|
126
114
|
export type PropDeclarations<P> = {
|
|
127
|
-
readonly [K in keyof P]-?:
|
|
115
|
+
readonly [K in keyof P]-?: Prop<P[K]>;
|
|
128
116
|
};
|
|
129
117
|
/** State of a component that keeps none (a pure view of its props). Its `init` is optional. */
|
|
130
118
|
export type Stateless = Readonly<Record<string, never>>;
|
|
@@ -137,17 +125,17 @@ type InitField<S, M extends Tagged, P> = Stateless extends S ? {
|
|
|
137
125
|
};
|
|
138
126
|
export type ComponentSpec<S, M extends Tagged, P> = SpecBody<S, M, P> & InitField<S, M, P>;
|
|
139
127
|
interface SpecBody<S, M extends Tagged, P> {
|
|
140
|
-
/**
|
|
128
|
+
/** The component's inputs, declared with `prop.*` builders. */
|
|
141
129
|
readonly props?: PropDeclarations<P>;
|
|
142
130
|
/** INTENT: platform events to messages. */
|
|
143
131
|
readonly intent: Intents<M>;
|
|
144
132
|
/** MODEL: pure state transitions. */
|
|
145
133
|
readonly update: Update<S, M, P>;
|
|
146
134
|
/** VIEW: pure function of state and props. Name intents in markup; never attach closures. */
|
|
147
|
-
readonly view: (state: S, intents: IntentNames<M>, ctx: Ctx<P>) =>
|
|
135
|
+
readonly view: (state: S, intents: IntentNames<M>, ctx: Ctx<P>) => ChildValue;
|
|
148
136
|
/**
|
|
149
|
-
* Shadow-root styles: `css`
|
|
150
|
-
*
|
|
137
|
+
* Shadow-root styles: `css` values, plain CSS strings, or arrays of them, nested freely.
|
|
138
|
+
* Each maps to one shared `CSSStyleSheet`. Ignored (with a warning) when `shadow: false`.
|
|
151
139
|
*/
|
|
152
140
|
readonly styles?: Styles;
|
|
153
141
|
/**
|
|
@@ -176,6 +164,14 @@ interface SpecBody<S, M extends Tagged, P> {
|
|
|
176
164
|
* reorders). Skipped without browser support or when reduced motion is requested.
|
|
177
165
|
*/
|
|
178
166
|
readonly viewTransition?: (prev: S, next: S, msg: Tagged) => boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Messages from bursty sources (a WebSocket feed, a sensor) whose renders wait for the next
|
|
169
|
+
* animation frame, so many messages in one frame cost one render: `renderOnFrame: ['Ticked']`.
|
|
170
|
+
* Reducers still run at once. Any other change to the component renders in the usual
|
|
171
|
+
* microtask flush, taking pending frame work with it. `'StoreChanged'` covers store changes.
|
|
172
|
+
* Pages that get no frames (hidden) render from a 100 ms timer. view/04-scheduler.md.
|
|
173
|
+
*/
|
|
174
|
+
readonly renderOnFrame?: readonly (M['_tag'] | 'StoreChanged')[];
|
|
179
175
|
/**
|
|
180
176
|
* Boolean facts about the state, exposed to CSS as custom states:
|
|
181
177
|
* `states: (s) => ({ loading: s._tag === 'Loading' })` enables `:host(:state(loading))` and
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Prop } from './prop.js';\nimport type { ChildValue, Styles } from './view/index.js';\nimport type { CommandInfo } from './invokers.js';\nimport type { HydrateStrategy } from './islands.js';\nimport type { DriverOverrides, Next } from './command.js';\nimport type { AnyStore, StoreChanged, StoreRef } from './store.js';\n\n/** Every message is a tagged object; the tag is also the intent name used in markup. */\nexport interface Tagged {\n readonly _tag: string;\n}\n\n/** What the intent layer sees when a `data-intent` element fires its trigger event. */\nexport interface IntentInput {\n /** The `data-intent` value (a message tag). */\n readonly name: string;\n readonly event: Event;\n /** The element carrying `data-intent`. */\n readonly target: Element;\n /** `value` of the input, select, textarea or button that carries the intent. */\n readonly value: string | undefined;\n /** `checked` for checkbox and radio inputs. */\n readonly checked: boolean | undefined;\n /** Submitted data (including the submitter button) when the intent is on a `<form>`. */\n readonly formData: FormData | undefined;\n /** The output a child component emitted, when the intent is on a child element. */\n readonly detail: unknown;\n /** `KeyboardEvent.key` for `keydown`/`keyup` intents. */\n readonly key: string | undefined;\n /** For `toggle` intents (popover, `<details>`): the state it changed to. */\n readonly newState: 'open' | 'closed' | undefined;\n /** For `command` intents: the invoker's command (e.g. `--clear`) and source (gyral-czi.6). */\n readonly command: CommandInfo | undefined;\n}\n\n/** Reads a declared store's current state, typed by the store (ADR 0013). */\nexport type StoreReader = <S>(store: StoreRef<S>) => S;\n\n/** Read-only context handed to every reducer and to the view (ADR 0007, 0013). */\nexport interface Ctx<P> {\n /** Props from above. */\n readonly props: P;\n /** Stores from the side: `read(cart).lines`. The store must be in `spec.stores`. */\n readonly read: StoreReader;\n}\n\n/** Framework message: declared props changed after the first render (ADR 0007). */\nexport interface PropsChanged<P> {\n readonly _tag: 'PropsChanged';\n readonly props: P;\n readonly prev: P;\n}\n\n/**\n * Framework message: the component is live in the browser (ADR 0012 addendum). Sent once,\n * after the first client render has completed, to every client-side instance. Use it for\n * progressive enhancement: render the no-JS form on the server and in the first client render\n * (so hydration matches), then switch to the enhanced UI in the `Hydrated` reducer.\n */\nexport interface Hydrated {\n readonly _tag: 'Hydrated';\n /** `true` when the instance resumed from server-rendered markup (a hydration seed). */\n readonly serverRendered: boolean;\n}\n\n/** One validation problem. `path` is dot-joined and matches the field's `name`. */\nexport interface FieldIssue {\n readonly path: string;\n readonly message: string;\n}\n\n/** Submitted text values of a form (Files are dropped: they can't be re-filled). */\nexport type FormFields = Readonly<Record<string, string | readonly string[]>>;\n\n/** Framework message: an intent's input failed schema validation (ADR 0008). */\nexport interface IntentRejected {\n readonly _tag: 'IntentRejected';\n /** The `data-intent` name whose input was rejected. */\n readonly intent: string;\n readonly issues: readonly FieldIssue[];\n /**\n * For `form()` rejections: what the user submitted, so the view can re-fill the form. On\n * the no-JS path (ADR 0008 server half) the server re-renders the page from this.\n */\n // `| undefined` so schemas with plain optional fields (valibot `optional`) can produce it.\n readonly values?: FormFields | undefined;\n}\n\ntype ParseResult<M> = M | IntentRejected | undefined;\n\n/**\n * Parses a platform event into one message variant, `IntentRejected`, or `undefined` to\n * ignore it. May be async because schema validation may be.\n */\nexport type IntentParser<M> = (input: IntentInput) => ParseResult<M> | Promise<ParseResult<M>>;\n\ntype Variant<M extends Tagged, K extends M['_tag']> = Extract<M, { readonly _tag: K }>;\n\n/** Intent parsers keyed by the message tag they produce. Messages from drivers need none. */\nexport type Intents<M extends Tagged> = {\n readonly [K in M['_tag']]?: IntentParser<Variant<M, K>>;\n};\n\ntype Reducer<S, M, Msg, P> = (state: S, msg: Msg, ctx: Ctx<P>) => Next<S, M>;\n\n/**\n * One pure reducer per message tag (exhaustive by construction), plus optional reducers\n * for framework messages. Reducers may return commands.\n */\nexport type Update<S, M extends Tagged, P = object> = {\n readonly [K in M['_tag']]: Reducer<S, M, Variant<M, K>, P>;\n} & {\n readonly PropsChanged?: Reducer<S, M, PropsChanged<P>, P>;\n readonly IntentRejected?: Reducer<S, M, IntentRejected, P>;\n readonly StoreChanged?: Reducer<S, M, StoreChanged, P>;\n readonly Hydrated?: Reducer<S, M, Hydrated, P>;\n};\n\n/** Typed intent names handed to the view, so `data-intent=${i.Increment}` is checked. */\nexport type IntentNames<M extends Tagged> = { readonly [K in M['_tag']]: K };\n\n/**\n * The prop builders for props type `P` (view/05-element.md \"Props\"): one `prop.*` builder per\n * key. A builder's output type must fit the prop's type, so a prop whose type excludes\n * `undefined` needs `required: true` or a `default` (the honesty rule, ADR 0007 addendum).\n * Without explicit type arguments, `define()` infers `P` from the builders.\n */\nexport type PropDeclarations<P> = { readonly [K in keyof P]-?: Prop<P[K]> };\n\n/** State of a component that keeps none (a pure view of its props). Its `init` is optional. */\nexport type Stateless = Readonly<Record<string, never>>;\n\n/** Initial model state (and optional commands), computed from props on first render. */\ntype Init<S, M, P> = (props: P) => Next<S, M>;\n\n// `init` may be omitted only when an empty object is a valid state (Stateless, all-optional).\ntype InitField<S, M extends Tagged, P> = Stateless extends S\n ? { readonly init?: Init<S, M, P> }\n : { readonly init: Init<S, M, P> };\n\nexport type ComponentSpec<S, M extends Tagged, P> = SpecBody<S, M, P> & InitField<S, M, P>;\n\ninterface SpecBody<S, M extends Tagged, P> {\n /** The component's inputs, declared with `prop.*` builders. */\n readonly props?: PropDeclarations<P>;\n /** INTENT: platform events to messages. */\n readonly intent: Intents<M>;\n /** MODEL: pure state transitions. */\n readonly update: Update<S, M, P>;\n /** VIEW: pure function of state and props. Name intents in markup; never attach closures. */\n readonly view: (state: S, intents: IntentNames<M>, ctx: Ctx<P>) => ChildValue;\n /**\n * Shadow-root styles: `css` values, plain CSS strings, or arrays of them, nested freely.\n * Each maps to one shared `CSSStyleSheet`. Ignored (with a warning) when `shadow: false`.\n */\n readonly styles?: Styles;\n /**\n * `false` renders the view as the element's own light-DOM children (ADR 0014): document CSS\n * applies, and the server writes plain children instead of a `<template shadowrootmode>`.\n * For page-level components (listings, articles). No `<slot>`s and no `styles`. Default `true`.\n */\n readonly shadow?: boolean;\n /**\n * When a server-rendered instance hydrates (gyral-4k7.4): `load` (default), `idle`,\n * `visible` (scrolled into view) or `interaction` (first pointer/focus). Client-only\n * renders are unaffected.\n */\n readonly hydrate?: HydrateStrategy;\n /** Extra event types that may trigger intents via `data-intent-on` (e.g. `pointerdown`). */\n readonly events?: readonly string[];\n /** Driver substitutions by name, for every instance (ADR 0006). */\n readonly drivers?: DriverOverrides;\n /**\n * Stores this component reads with `ctx.read(store)` and writes with `send(store, msg)`.\n * Their changes re-render it (and reach the optional `StoreChanged` reducer). ADR 0013.\n */\n readonly stores?: readonly AnyStore[];\n /**\n * Return `true` to render this state change inside a View Transition (route changes, list\n * reorders). Skipped without browser support or when reduced motion is requested.\n */\n readonly viewTransition?: (prev: S, next: S, msg: Tagged) => boolean;\n /**\n * Messages from bursty sources (a WebSocket feed, a sensor) whose renders wait for the next\n * animation frame, so many messages in one frame cost one render: `renderOnFrame: ['Ticked']`.\n * Reducers still run at once. Any other change to the component renders in the usual\n * microtask flush, taking pending frame work with it. `'StoreChanged'` covers store changes.\n * Pages that get no frames (hidden) render from a 100 ms timer. view/04-scheduler.md.\n */\n readonly renderOnFrame?: readonly (M['_tag'] | 'StoreChanged')[];\n /**\n * Boolean facts about the state, exposed to CSS as custom states:\n * `states: (s) => ({ loading: s._tag === 'Loading' })` enables `:host(:state(loading))` and\n * `gy-x:state(loading)`. Applied after each render; feature-detected; not on the server.\n */\n readonly states?: (state: S) => Readonly<Record<string, boolean>>;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Host attribute holding a component's JSON seed (ADR 0012); the client removes it. */
|
|
2
|
+
export declare const SEED_ATTRIBUTE = "data-gyral-seed";
|
|
3
|
+
/** Marks a server-rendered light-DOM host (ADR 0014), so hydration knows its own content. */
|
|
4
|
+
export declare const LIGHT_ATTRIBUTE = "data-gyral-light";
|
|
5
|
+
/** A deferred island's strategy (07 "Islands"), next to `defer-hydration`. */
|
|
6
|
+
export declare const ISLAND_ATTRIBUTE = "data-gyral-hydrate";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Host attributes the server renderer writes (view/06-server.md "Components") and the client
|
|
2
|
+
// reads (07). Core's hydration.ts, light-dom.ts and islands.ts declare the same names for the
|
|
3
|
+
// client; server-components.node.test.ts checks that they match.
|
|
4
|
+
/** Host attribute holding a component's JSON seed (ADR 0012); the client removes it. */
|
|
5
|
+
export const SEED_ATTRIBUTE = 'data-gyral-seed';
|
|
6
|
+
/** Marks a server-rendered light-DOM host (ADR 0014), so hydration knows its own content. */
|
|
7
|
+
export const LIGHT_ATTRIBUTE = 'data-gyral-light';
|
|
8
|
+
/** A deferred island's strategy (07 "Islands"), next to `defer-hydration`. */
|
|
9
|
+
export const ISLAND_ATTRIBUTE = 'data-gyral-hydrate';
|
|
10
|
+
//# sourceMappingURL=attributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attributes.js","sourceRoot":"","sources":["../../src/view/attributes.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,8FAA8F;AAC9F,iEAAiE;AACjE,wFAAwF;AACxF,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAChD,6FAA6F;AAC7F,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAClD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,gBAAgB,GAAG,oBAAoB,CAAC","sourcesContent":["// Host attributes the server renderer writes (view/06-server.md \"Components\") and the client\n// reads (07). Core's hydration.ts, light-dom.ts and islands.ts declare the same names for the\n// client; server-components.node.test.ts checks that they match.\n/** Host attribute holding a component's JSON seed (ADR 0012); the client removes it. */\nexport const SEED_ATTRIBUTE = 'data-gyral-seed';\n/** Marks a server-rendered light-DOM host (ADR 0014), so hydration knows its own content. */\nexport const LIGHT_ATTRIBUTE = 'data-gyral-light';\n/** A deferred island's strategy (07 \"Islands\"), next to `defer-hydration`. */\nexport const ISLAND_ATTRIBUTE = 'data-gyral-hydrate';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { compiled } from './template.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// `@gyral/core/compiled`: the entry the Vite template compiler's output imports `compiled`
|
|
2
|
+
// from (view/01-templates.md "Compiled"). Internal: apps never import it themselves, and it is
|
|
3
|
+
// not documented as API. A subpath of its own, so the main entry's API stays as documented
|
|
4
|
+
// and compiled code still shares the one template module with `html` (same package copy).
|
|
5
|
+
export { compiled } from './template.js';
|
|
6
|
+
//# sourceMappingURL=compiled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiled.js","sourceRoot":"","sources":["../../src/view/compiled.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,+FAA+F;AAC/F,2FAA2F;AAC3F,0FAA0F;AAC1F,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC","sourcesContent":["// `@gyral/core/compiled`: the entry the Vite template compiler's output imports `compiled`\n// from (view/01-templates.md \"Compiled\"). Internal: apps never import it themselves, and it is\n// not documented as API. A subpath of its own, so the main entry's API stays as documented\n// and compiled code still shares the one template module with `html` (same package copy).\nexport { compiled } from './template.js';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEV: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-off.js","sourceRoot":"","sources":["../../src/view/dev-off.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,sFAAsF;AACtF,MAAM,CAAC,MAAM,GAAG,GAAY,KAAK,CAAC","sourcesContent":["// Production build of the view layer's flag (`#view-dev` without the `development` condition):\n// a literal `false`, so bundlers drop every `if (DEV)` check and warning. See dev.ts.\nexport const DEV: boolean = false;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEV: boolean;
|
package/dist/view/dev.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Development build of the view layer's flag, resolved through core's `#view-dev` import with
|
|
2
|
+
// the `development` condition (view/09-template-rules.md "One rule set, three places"). Checks
|
|
3
|
+
// and warnings are guarded with `if (DEV)`; production builds get dev-off.ts, so they vanish.
|
|
4
|
+
export const DEV = true;
|
|
5
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/view/dev.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,+FAA+F;AAC/F,8FAA8F;AAC9F,MAAM,CAAC,MAAM,GAAG,GAAY,IAAI,CAAC","sourcesContent":["// Development build of the view layer's flag, resolved through core's `#view-dev` import with\n// the `development` condition (view/09-template-rules.md \"One rule set, three places\"). Checks\n// and warnings are guarded with `if (DEV)`; production builds get dev-off.ts, so they vanish.\nexport const DEV: boolean = true;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DEV } from '#view-dev';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flags.js","sourceRoot":"","sources":["../../src/view/flags.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,2FAA2F;AAC3F,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC","sourcesContent":["// The development flag for view/ modules that may not use `#` imports themselves (view/server/,\n// ADR 0018 \"Where it lives\"): core's `#view-dev`, resolved by the `development` condition.\nexport { DEV } from '#view-dev';\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { DEV } from '#view-dev';
|
|
2
|
+
export { html, compiled, isTemplateResult, templateOf, type TemplateResult } from './template.js';
|
|
3
|
+
export { templateElement } from './template-element.js';
|
|
4
|
+
export { normalize, analyze, type Analysis } from './normalize/normalize.js';
|
|
5
|
+
export { checkTemplate, type TemplateIssue } from './normalize/check.js';
|
|
6
|
+
export { templateId } from './normalize/id.js';
|
|
7
|
+
export { TemplateError } from './normalize/errors.js';
|
|
8
|
+
export { shapeMismatch, repairError } from './normalize/shape.js';
|
|
9
|
+
export type { NormalizedTemplate, PartSpec, Path, Segment, Shape, ShapeNode, TemplateObject, } from './normalize/types.js';
|
|
10
|
+
export { hydrate } from './render/hydrate.js';
|
|
11
|
+
export { render, renderBatch } from './render/render.js';
|
|
12
|
+
export type { Markup, SeenMarkup } from './render/seen.js';
|
|
13
|
+
export { HydrationMismatch } from './render/mismatch.js';
|
|
14
|
+
export { each } from './render/list.js';
|
|
15
|
+
export { raw } from './render/raw.js';
|
|
16
|
+
export { nothing, type ChildValue, type ListResult, type RawResult } from './render/values.js';
|
|
17
|
+
export { defineHook } from './render/hook-part.js';
|
|
18
|
+
export type { HookAttributes, HookResult, HookSpec } from './render/hooks.js';
|
|
19
|
+
export { css, isStyleSource, sheetsFor, styleTexts, type CssValue, type StyleSource, type Styles, } from './styles.js';
|
|
20
|
+
export { ISLAND_ATTRIBUTE, LIGHT_ATTRIBUTE, SEED_ATTRIBUTE } from './attributes.js';
|
|
21
|
+
export { registerServerComponent, registerServerProvider, serverComponent, serverComponents, serverProvider, type ServerComponent, type ServerProvider, type ServerRenderInput, type ServerRendering, } from './registry.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// The view layer's entry point for the rest of core (ADR 0018 "Where it lives"): code outside
|
|
2
|
+
// view/ imports only this module. @gyral/core's index re-exports the public part of it.
|
|
3
|
+
export { DEV } from '#view-dev';
|
|
4
|
+
export { html, compiled, isTemplateResult, templateOf } from './template.js';
|
|
5
|
+
export { templateElement } from './template-element.js';
|
|
6
|
+
export { normalize, analyze } from './normalize/normalize.js';
|
|
7
|
+
export { checkTemplate } from './normalize/check.js';
|
|
8
|
+
export { templateId } from './normalize/id.js';
|
|
9
|
+
export { TemplateError } from './normalize/errors.js';
|
|
10
|
+
export { shapeMismatch, repairError } from './normalize/shape.js';
|
|
11
|
+
export { hydrate } from './render/hydrate.js';
|
|
12
|
+
export { render, renderBatch } from './render/render.js';
|
|
13
|
+
export { HydrationMismatch } from './render/mismatch.js';
|
|
14
|
+
export { each } from './render/list.js';
|
|
15
|
+
export { raw } from './render/raw.js';
|
|
16
|
+
export { nothing } from './render/values.js';
|
|
17
|
+
export { defineHook } from './render/hook-part.js';
|
|
18
|
+
export { css, isStyleSource, sheetsFor, styleTexts, } from './styles.js';
|
|
19
|
+
export { ISLAND_ATTRIBUTE, LIGHT_ATTRIBUTE, SEED_ATTRIBUTE } from './attributes.js';
|
|
20
|
+
export { registerServerComponent, registerServerProvider, serverComponent, serverComponents, serverProvider, } from './registry.js';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/view/index.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,wFAAwF;AACxF,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,gBAAgB,EAAE,UAAU,EAAuB,MAAM,eAAe,CAAC;AAClG,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAiB,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAsB,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAWlE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,OAAO,EAAoD,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EACL,GAAG,EACH,aAAa,EACb,SAAS,EACT,UAAU,GAIX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACpF,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,cAAc,GAKf,MAAM,eAAe,CAAC","sourcesContent":["// The view layer's entry point for the rest of core (ADR 0018 \"Where it lives\"): code outside\n// view/ imports only this module. @gyral/core's index re-exports the public part of it.\nexport { DEV } from '#view-dev';\nexport { html, compiled, isTemplateResult, templateOf, type TemplateResult } from './template.js';\nexport { templateElement } from './template-element.js';\nexport { normalize, analyze, type Analysis } from './normalize/normalize.js';\nexport { checkTemplate, type TemplateIssue } from './normalize/check.js';\nexport { templateId } from './normalize/id.js';\nexport { TemplateError } from './normalize/errors.js';\nexport { shapeMismatch, repairError } from './normalize/shape.js';\nexport type {\n NormalizedTemplate,\n PartSpec,\n Path,\n Segment,\n Shape,\n ShapeNode,\n TemplateObject,\n} from './normalize/types.js';\n\nexport { hydrate } from './render/hydrate.js';\nexport { render, renderBatch } from './render/render.js';\nexport type { Markup, SeenMarkup } from './render/seen.js';\nexport { HydrationMismatch } from './render/mismatch.js';\nexport { each } from './render/list.js';\nexport { raw } from './render/raw.js';\nexport { nothing, type ChildValue, type ListResult, type RawResult } from './render/values.js';\nexport { defineHook } from './render/hook-part.js';\nexport type { HookAttributes, HookResult, HookSpec } from './render/hooks.js';\nexport {\n css,\n isStyleSource,\n sheetsFor,\n styleTexts,\n type CssValue,\n type StyleSource,\n type Styles,\n} from './styles.js';\nexport { ISLAND_ATTRIBUTE, LIGHT_ATTRIBUTE, SEED_ATTRIBUTE } from './attributes.js';\nexport {\n registerServerComponent,\n registerServerProvider,\n serverComponent,\n serverComponents,\n serverProvider,\n type ServerComponent,\n type ServerProvider,\n type ServerRenderInput,\n type ServerRendering,\n} from './registry.js';\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TemplateError } from './errors.js';
|
|
2
|
+
/** A position in the minified strings: string index, offset in that string. */
|
|
3
|
+
export type At = readonly [index: number, offset: number];
|
|
4
|
+
/** A template's first rule violation, and where the normalizer was when it found it. */
|
|
5
|
+
export interface TemplateIssue {
|
|
6
|
+
/** The same error `normalize(strings)` throws. */
|
|
7
|
+
readonly error: TemplateError;
|
|
8
|
+
/** The whitespace-minified strings the rules read (as many as the input). */
|
|
9
|
+
readonly strings: readonly string[];
|
|
10
|
+
/** Where reading stopped. */
|
|
11
|
+
readonly at: At;
|
|
12
|
+
/**
|
|
13
|
+
* Where the token the error is about starts, when the tree builder found it in a tag, an end
|
|
14
|
+
* tag or a run of text (the token ends at `at`). Undefined when the tokenizer found it at
|
|
15
|
+
* `at` itself, or at a child hole (then `at` is the end of the string before the hole).
|
|
16
|
+
*/
|
|
17
|
+
readonly from: At | undefined;
|
|
18
|
+
}
|
|
19
|
+
/** The template's first rule violation, or undefined when `normalize` would accept it. */
|
|
20
|
+
export declare function checkTemplate(strings: readonly string[]): TemplateIssue | undefined;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// The template rules (view/09-template-rules.md) as a check that reports where it stopped, for
|
|
2
|
+
// tools that point at the markup (the ESLint plugin, @gyral/core/eslint). It runs the same
|
|
3
|
+
// steps as `analyze` (normalize.ts) up to the last one that can fail: minify whitespace, then
|
|
4
|
+
// tokenize and build the tree (emit and the id never throw). Like the compiler and the runtime,
|
|
5
|
+
// it stops at a template's first error: the tokenizer can't recover from one.
|
|
6
|
+
import { TemplateError } from './errors.js';
|
|
7
|
+
import { Source } from './source.js';
|
|
8
|
+
import { tokenize } from './tokenizer.js';
|
|
9
|
+
import { TreeBuilder } from './tree.js';
|
|
10
|
+
import { minifyStrings } from './whitespace.js';
|
|
11
|
+
/** Forwards tokens to the tree builder, remembering where the current token started. */
|
|
12
|
+
class Tracker {
|
|
13
|
+
constructor(src, tree) {
|
|
14
|
+
this.src = src;
|
|
15
|
+
this.tree = tree;
|
|
16
|
+
this.mark = [0, 0];
|
|
17
|
+
}
|
|
18
|
+
/** A token starts at `mark`; an error before `after` is about it (a child hole: the hole). */
|
|
19
|
+
before(about = true) {
|
|
20
|
+
this.from = about ? this.mark : undefined;
|
|
21
|
+
}
|
|
22
|
+
after() {
|
|
23
|
+
this.from = undefined;
|
|
24
|
+
this.mark = [this.src.i, this.src.pos];
|
|
25
|
+
}
|
|
26
|
+
text(raw) {
|
|
27
|
+
this.before();
|
|
28
|
+
this.tree.text(raw);
|
|
29
|
+
this.after();
|
|
30
|
+
}
|
|
31
|
+
comment(raw) {
|
|
32
|
+
this.before();
|
|
33
|
+
this.tree.comment(raw);
|
|
34
|
+
this.after();
|
|
35
|
+
}
|
|
36
|
+
doctype(raw) {
|
|
37
|
+
this.before();
|
|
38
|
+
this.tree.doctype(raw);
|
|
39
|
+
this.after();
|
|
40
|
+
}
|
|
41
|
+
start(tag) {
|
|
42
|
+
this.before();
|
|
43
|
+
const mode = this.tree.start(tag);
|
|
44
|
+
this.after();
|
|
45
|
+
return mode;
|
|
46
|
+
}
|
|
47
|
+
end(name) {
|
|
48
|
+
this.before();
|
|
49
|
+
this.tree.end(name);
|
|
50
|
+
this.after();
|
|
51
|
+
}
|
|
52
|
+
hole(kind) {
|
|
53
|
+
this.before(false);
|
|
54
|
+
this.tree.hole(kind);
|
|
55
|
+
this.after();
|
|
56
|
+
}
|
|
57
|
+
finish() {
|
|
58
|
+
this.before();
|
|
59
|
+
this.tree.finish();
|
|
60
|
+
this.after();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** The template's first rule violation, or undefined when `normalize` would accept it. */
|
|
64
|
+
export function checkTemplate(strings) {
|
|
65
|
+
const normalized = minifyStrings(strings);
|
|
66
|
+
const src = new Source(normalized, undefined);
|
|
67
|
+
const tracker = new Tracker(src, new TreeBuilder(src));
|
|
68
|
+
try {
|
|
69
|
+
tokenize(src, tracker);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
if (!(error instanceof TemplateError))
|
|
73
|
+
throw error;
|
|
74
|
+
return { error, strings: normalized, at: [src.i, src.pos], from: tracker.from };
|
|
75
|
+
}
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../../src/view/normalize/check.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,2FAA2F;AAC3F,8FAA8F;AAC9F,gGAAgG;AAChG,8EAA8E;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAA8C,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAqBhD,wFAAwF;AACxF,MAAM,OAAO;IAIX,YACmB,GAAW,EACX,IAAiB;QADjB,QAAG,GAAH,GAAG,CAAQ;QACX,SAAI,GAAJ,IAAI,CAAa;QALpC,SAAI,GAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAMf,CAAC;IAEJ,8FAA8F;IACtF,MAAM,CAAC,KAAK,GAAG,IAAI;QACzB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5C,CAAC;IAEO,KAAK;QACX,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,CAAC,GAAW;QACd,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IACD,OAAO,CAAC,GAAW;QACjB,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IACD,OAAO,CAAC,GAAW;QACjB,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IACD,KAAK,CAAC,GAAa;QACjB,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IACD,GAAG,CAAC,IAAY;QACd,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpB,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IACD,IAAI,CAAC,IAAsB;QACzB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACnB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrB,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IACD,MAAM;QACJ,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACnB,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;CACF;AAED,0FAA0F;AAC1F,MAAM,UAAU,aAAa,CAAC,OAA0B;IACtD,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAC1C,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,IAAI,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;IACvD,IAAI,CAAC;QACH,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,aAAa,CAAC;YAAE,MAAM,KAAK,CAAC;QACnD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;IAClF,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// The template rules (view/09-template-rules.md) as a check that reports where it stopped, for\n// tools that point at the markup (the ESLint plugin, @gyral/core/eslint). It runs the same\n// steps as `analyze` (normalize.ts) up to the last one that can fail: minify whitespace, then\n// tokenize and build the tree (emit and the id never throw). Like the compiler and the runtime,\n// it stops at a template's first error: the tokenizer can't recover from one.\nimport { TemplateError } from './errors.js';\nimport { Source } from './source.js';\nimport { tokenize, type ContentMode, type Sink, type StartTag } from './tokenizer.js';\nimport { TreeBuilder } from './tree.js';\nimport { minifyStrings } from './whitespace.js';\n\n/** A position in the minified strings: string index, offset in that string. */\nexport type At = readonly [index: number, offset: number];\n\n/** A template's first rule violation, and where the normalizer was when it found it. */\nexport interface TemplateIssue {\n /** The same error `normalize(strings)` throws. */\n readonly error: TemplateError;\n /** The whitespace-minified strings the rules read (as many as the input). */\n readonly strings: readonly string[];\n /** Where reading stopped. */\n readonly at: At;\n /**\n * Where the token the error is about starts, when the tree builder found it in a tag, an end\n * tag or a run of text (the token ends at `at`). Undefined when the tokenizer found it at\n * `at` itself, or at a child hole (then `at` is the end of the string before the hole).\n */\n readonly from: At | undefined;\n}\n\n/** Forwards tokens to the tree builder, remembering where the current token started. */\nclass Tracker implements Sink {\n mark: At = [0, 0];\n from: At | undefined;\n\n constructor(\n private readonly src: Source,\n private readonly tree: TreeBuilder,\n ) {}\n\n /** A token starts at `mark`; an error before `after` is about it (a child hole: the hole). */\n private before(about = true): void {\n this.from = about ? this.mark : undefined;\n }\n\n private after(): void {\n this.from = undefined;\n this.mark = [this.src.i, this.src.pos];\n }\n\n text(raw: string): void {\n this.before();\n this.tree.text(raw);\n this.after();\n }\n comment(raw: string): void {\n this.before();\n this.tree.comment(raw);\n this.after();\n }\n doctype(raw: string): void {\n this.before();\n this.tree.doctype(raw);\n this.after();\n }\n start(tag: StartTag): ContentMode {\n this.before();\n const mode = this.tree.start(tag);\n this.after();\n return mode;\n }\n end(name: string): void {\n this.before();\n this.tree.end(name);\n this.after();\n }\n hole(kind: 'child' | 'text'): void {\n this.before(false);\n this.tree.hole(kind);\n this.after();\n }\n finish(): void {\n this.before();\n this.tree.finish();\n this.after();\n }\n}\n\n/** The template's first rule violation, or undefined when `normalize` would accept it. */\nexport function checkTemplate(strings: readonly string[]): TemplateIssue | undefined {\n const normalized = minifyStrings(strings);\n const src = new Source(normalized, undefined);\n const tracker = new Tracker(src, new TreeBuilder(src));\n try {\n tokenize(src, tracker);\n } catch (error) {\n if (!(error instanceof TemplateError)) throw error;\n return { error, strings: normalized, at: [src.i, src.pos], from: tracker.from };\n }\n return undefined;\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TreeNode } from './tree.js';
|
|
2
|
+
import { type PartSpec, type Segment, type Shape } from './types.js';
|
|
3
|
+
export interface Emitted {
|
|
4
|
+
readonly html: string;
|
|
5
|
+
readonly parts: PartSpec[];
|
|
6
|
+
readonly segments: Segment[];
|
|
7
|
+
readonly shape: Shape;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Emits the HTML, part table, segments and shape for a template's tree. A `server` template
|
|
11
|
+
* (a page shell) gets no anchors: hydration never walks it, and the browser never renders it.
|
|
12
|
+
*/
|
|
13
|
+
export declare function emit(root: readonly TreeNode[], server: boolean): Emitted;
|