@taggor/runtime 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.
- package/LICENSE +21 -0
- package/README.md +49 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/compat/before-compat.d.ts +5 -0
- package/dist/compat/before-compat.d.ts.map +1 -0
- package/dist/compat/before-compat.js +15 -0
- package/dist/compat/before-compat.js.map +1 -0
- package/dist/compat/index.d.ts +90 -0
- package/dist/compat/index.d.ts.map +1 -0
- package/dist/compat/index.js +67 -0
- package/dist/compat/index.js.map +1 -0
- package/dist/compat/scope.d.ts +81 -0
- package/dist/compat/scope.d.ts.map +1 -0
- package/dist/compat/scope.js +107 -0
- package/dist/compat/scope.js.map +1 -0
- package/dist/element/attributes.d.ts +103 -0
- package/dist/element/attributes.d.ts.map +1 -0
- package/dist/element/attributes.js +153 -0
- package/dist/element/attributes.js.map +1 -0
- package/dist/element/component-controller.d.ts +98 -0
- package/dist/element/component-controller.d.ts.map +1 -0
- package/dist/element/component-controller.js +472 -0
- package/dist/element/component-controller.js.map +1 -0
- package/dist/element/contract-gate.d.ts +29 -0
- package/dist/element/contract-gate.d.ts.map +1 -0
- package/dist/element/contract-gate.js +37 -0
- package/dist/element/contract-gate.js.map +1 -0
- package/dist/element/create-component-element.d.ts +93 -0
- package/dist/element/create-component-element.d.ts.map +1 -0
- package/dist/element/create-component-element.js +302 -0
- package/dist/element/create-component-element.js.map +1 -0
- package/dist/element/define-element.d.ts +43 -0
- package/dist/element/define-element.d.ts.map +1 -0
- package/dist/element/define-element.js +61 -0
- package/dist/element/define-element.js.map +1 -0
- package/dist/element/diagnostics.d.ts +35 -0
- package/dist/element/diagnostics.d.ts.map +1 -0
- package/dist/element/diagnostics.js +52 -0
- package/dist/element/diagnostics.js.map +1 -0
- package/dist/element/error-boundary.d.ts +41 -0
- package/dist/element/error-boundary.d.ts.map +1 -0
- package/dist/element/error-boundary.js +36 -0
- package/dist/element/error-boundary.js.map +1 -0
- package/dist/element/error-report.d.ts +9 -0
- package/dist/element/error-report.d.ts.map +1 -0
- package/dist/element/error-report.js +51 -0
- package/dist/element/error-report.js.map +1 -0
- package/dist/element/events.d.ts +69 -0
- package/dist/element/events.d.ts.map +1 -0
- package/dist/element/events.js +115 -0
- package/dist/element/events.js.map +1 -0
- package/dist/element/handler-guard.d.ts +54 -0
- package/dist/element/handler-guard.d.ts.map +1 -0
- package/dist/element/handler-guard.js +162 -0
- package/dist/element/handler-guard.js.map +1 -0
- package/dist/element/index.d.ts +9 -0
- package/dist/element/index.d.ts.map +1 -0
- package/dist/element/index.js +9 -0
- package/dist/element/index.js.map +1 -0
- package/dist/element/props-script.d.ts +37 -0
- package/dist/element/props-script.d.ts.map +1 -0
- package/dist/element/props-script.js +63 -0
- package/dist/element/props-script.js.map +1 -0
- package/dist/element/styles.d.ts +45 -0
- package/dist/element/styles.d.ts.map +1 -0
- package/dist/element/styles.js +66 -0
- package/dist/element/styles.js.map +1 -0
- package/dist/element/types.d.ts +148 -0
- package/dist/element/types.d.ts.map +1 -0
- package/dist/element/types.js +3 -0
- package/dist/element/types.js.map +1 -0
- package/dist/host/api.d.ts +40 -0
- package/dist/host/api.d.ts.map +1 -0
- package/dist/host/api.js +144 -0
- package/dist/host/api.js.map +1 -0
- package/dist/host/barrier.d.ts +27 -0
- package/dist/host/barrier.d.ts.map +1 -0
- package/dist/host/barrier.js +47 -0
- package/dist/host/barrier.js.map +1 -0
- package/dist/host/index.d.ts +11 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +9 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/registry.d.ts +21 -0
- package/dist/host/registry.d.ts.map +1 -0
- package/dist/host/registry.js +29 -0
- package/dist/host/registry.js.map +1 -0
- package/dist/host/types.d.ts +54 -0
- package/dist/host/types.d.ts.map +1 -0
- package/dist/host/types.js +11 -0
- package/dist/host/types.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/loader/config.d.ts +63 -0
- package/dist/loader/config.d.ts.map +1 -0
- package/dist/loader/config.js +115 -0
- package/dist/loader/config.js.map +1 -0
- package/dist/loader/entry.d.ts +2 -0
- package/dist/loader/entry.d.ts.map +1 -0
- package/dist/loader/entry.js +37 -0
- package/dist/loader/entry.js.map +1 -0
- package/dist/loader/lazy-transport.d.ts +26 -0
- package/dist/loader/lazy-transport.d.ts.map +1 -0
- package/dist/loader/lazy-transport.js +59 -0
- package/dist/loader/lazy-transport.js.map +1 -0
- package/dist/loader/loader-code.d.ts +2 -0
- package/dist/loader/loader-code.js +2 -0
- package/dist/loader/loading.d.ts +24 -0
- package/dist/loader/loading.d.ts.map +1 -0
- package/dist/loader/loading.js +29 -0
- package/dist/loader/loading.js.map +1 -0
- package/dist/loader/page-state.d.ts +66 -0
- package/dist/loader/page-state.d.ts.map +1 -0
- package/dist/loader/page-state.js +73 -0
- package/dist/loader/page-state.js.map +1 -0
- package/dist/loader/resilient-import.d.ts +32 -0
- package/dist/loader/resilient-import.d.ts.map +1 -0
- package/dist/loader/resilient-import.js +42 -0
- package/dist/loader/resilient-import.js.map +1 -0
- package/dist/loader/run.d.ts +45 -0
- package/dist/loader/run.d.ts.map +1 -0
- package/dist/loader/run.js +217 -0
- package/dist/loader/run.js.map +1 -0
- package/dist/loader/script-url.d.ts +50 -0
- package/dist/loader/script-url.d.ts.map +1 -0
- package/dist/loader/script-url.js +71 -0
- package/dist/loader/script-url.js.map +1 -0
- package/dist/loader/script.d.ts +31 -0
- package/dist/loader/script.d.ts.map +1 -0
- package/dist/loader/script.js +40 -0
- package/dist/loader/script.js.map +1 -0
- package/dist/server/render-fragment.d.ts +57 -0
- package/dist/server/render-fragment.d.ts.map +1 -0
- package/dist/server/render-fragment.js +182 -0
- package/dist/server/render-fragment.js.map +1 -0
- package/dist/server/ssr-code.d.ts +4 -0
- package/dist/server/ssr-code.js +3 -0
- package/dist/server/worker.d.ts +37 -0
- package/dist/server/worker.d.ts.map +1 -0
- package/dist/server/worker.js +71 -0
- package/dist/server/worker.js.map +1 -0
- package/package.json +86 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/compat/scope.ts"],"names":[],"mappings":"AA2CA,uEAAuE;AACvE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAU,CAAC;AAwB3F,+FAA+F;AAC/F,MAAM,KAAK,GAAkB,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAC1D,iGAAiG;AACjG,MAAM,UAAU,GAAkB,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAEpE,kGAAkG;AAClG,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAyBvD;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAe;IAC/C,MAAM,KAAK,GAAG,MAA+B,CAAC;IAC9C,MAAM,KAAK,GAAgB,EAAE,CAAC;IAC9B,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;QAChC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QACzB,IAAI,IAAI;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;IAC1B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAe,EAAE,KAAkB;IAClE,MAAM,KAAK,GAAG,MAA+B,CAAC;IAC9C,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;QAChC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CA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AAE,KAAK,CAAC,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC,CAAC;IAEF,MAAM,cAAc,GAAmB,CAAC,SAAS,EAAE,EAAE;QACnD,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACvB,CAAC,CAAC;IACF,MAAM,WAAW,GAAG,CAAC,KAAgD,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC;IACjG,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACvB,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC;AACzC,CAAC;AAED,oEAAoE;AACpE,SAAS,IAAI,CAAC,IAAsB,EAAE,KAAc;IAClD,OAAO,IAAI,EAAE,CAAC,KAAc,CAAC,CAAC;AAChC,CAAC;AAED,8FAA8F;AAC9F,SAAS,cAAc,CAAC,KAAoB;IAC1C,KAAK,IAAI,MAAM,GAAG,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,CAAC;QACvD,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;QAClC,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;IACxC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attributes → props of a component (TAG-302, coercion completed by TAG-303): which attributes the
|
|
3
|
+
* element observes and the props object the component receives, both derived from the manifest.
|
|
4
|
+
*
|
|
5
|
+
* Every rule of value lives in the contract (`@taggor/contract/zod-free`, the Zod-free entry the
|
|
6
|
+
* browser may import as values): `attributeToValue` applies the fixed parse of the declared type
|
|
7
|
+
* from `propTypeCatalog`, `propAttributeName` maps `maxValue` to `max-value`. Nothing here parses
|
|
8
|
+
* a value itself, and nothing ever evaluates one: no `eval`, `new Function`, HTML parsing or free
|
|
9
|
+
* `JSON.parse` (golden rule 5; the old runtime's `new Function` over attribute values cannot come
|
|
10
|
+
* back). The only check the runtime adds is browser-side and can only narrow: a `color` the
|
|
11
|
+
* contract accepts must also pass `CSS.supports("color", value)` when the page has it.
|
|
12
|
+
*
|
|
13
|
+
* Invalid text gives the declared default (`false` for a `boolean` without one) and a
|
|
14
|
+
* `PropProblem` the controller shows in debug mode; reading never throws. A prop whose `type` is
|
|
15
|
+
* not in the catalog (a newer contract minor, ADR 0019) is left out: not observed, not passed.
|
|
16
|
+
*
|
|
17
|
+
* TAG-304: a prop whose name the element already has (the caller's `isReserved`: the live
|
|
18
|
+
* `HTMLElement.prototype` chain and the Custom Element callbacks) is left out too, since its
|
|
19
|
+
* property accessor would shadow that member. `propertyValue` is the same coercion for a JS value
|
|
20
|
+
* (a property assignment or an entry of the `<script data-props>` child), through the contract's
|
|
21
|
+
* `propertyToValue` and the same `CSS.supports` narrowing.
|
|
22
|
+
*
|
|
23
|
+
* TAG-613: the props a site gives the component (the `defaults` of its manifest entry) become the
|
|
24
|
+
* `default` of the binding, when the prop's own type accepts them, so the precedence is attribute
|
|
25
|
+
* (or property, or script) > site > the component's declared default, with no extra branch at
|
|
26
|
+
* read time. A value the type refuses, a name that is not a bound prop and a `siteDefaults` that
|
|
27
|
+
* is not an object are ignored without a word: the API checked them against the same declarations
|
|
28
|
+
* before they reached the manifest.
|
|
29
|
+
*/
|
|
30
|
+
import { type PropDeclaration, type ValueProblem } from "@taggor/contract/zod-free";
|
|
31
|
+
import type { MountableManifest } from "./types.js";
|
|
32
|
+
/** A declared prop of a known type, the attribute it is read from and its declaration. */
|
|
33
|
+
export interface PropBinding {
|
|
34
|
+
readonly prop: string;
|
|
35
|
+
readonly attribute: string;
|
|
36
|
+
readonly declaration: PropDeclaration;
|
|
37
|
+
}
|
|
38
|
+
/** The bindings of a manifest and the props left out: unknown type or reserved name (TAG-304). */
|
|
39
|
+
export interface PropBindings {
|
|
40
|
+
readonly bindings: readonly PropBinding[];
|
|
41
|
+
readonly unknown: readonly string[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The props of a manifest with their attributes, in declaration order.
|
|
45
|
+
*
|
|
46
|
+
* Inputs: the manifest and `isReserved` (TAG-304; default: no name is reserved), which says
|
|
47
|
+
* whether a prop name is already a member of the element. Output: frozen `{ bindings, unknown }`:
|
|
48
|
+
* one binding per own key of `manifest.props` that is not reserved and whose declaration has a
|
|
49
|
+
* `type` of `propTypeCatalog`; the other names (reserved, unknown type, not an object) in
|
|
50
|
+
* `unknown`, so the caller can warn. No props gives two empty lists. `siteDefaults` (TAG-613) is the
|
|
51
|
+
* site's value per prop name: an own entry the prop accepts replaces the binding's `default`.
|
|
52
|
+
* Errors: none (`isReserved` must not throw). Side effects: none.
|
|
53
|
+
*/
|
|
54
|
+
export declare function bindProps(manifest: MountableManifest, isReserved?: (prop: string) => boolean, siteDefaults?: unknown): PropBindings;
|
|
55
|
+
/** Why one attribute did not give its prop a value: the contract's code and the text refused. */
|
|
56
|
+
export interface PropProblem {
|
|
57
|
+
readonly prop: string;
|
|
58
|
+
readonly attribute: string;
|
|
59
|
+
readonly problem: ValueProblem;
|
|
60
|
+
/** The refused text; used only to tell a new problem from a repeated one, never logged. */
|
|
61
|
+
readonly text: string;
|
|
62
|
+
}
|
|
63
|
+
/** The props for the component and the attributes that fell back to a default. */
|
|
64
|
+
export interface ReadProps {
|
|
65
|
+
readonly props: Readonly<Record<string, unknown>>;
|
|
66
|
+
readonly problems: readonly PropProblem[];
|
|
67
|
+
}
|
|
68
|
+
/** Whether a `color` the contract accepted is also a color for this browser. */
|
|
69
|
+
export type ColorCheck = (value: string) => boolean;
|
|
70
|
+
/**
|
|
71
|
+
* The browser's color check, `CSS.supports("color", value)`, captured once.
|
|
72
|
+
*
|
|
73
|
+
* Inputs: none (reads `globalThis.CSS`). Output: a `ColorCheck`; without `CSS.supports` it
|
|
74
|
+
* accepts everything (the contract's allowlist still applies), and so it does when reading
|
|
75
|
+
* `CSS` or `CSS.supports` throws; a call that throws counts as unsupported. Errors: none. Side effects: none.
|
|
76
|
+
*/
|
|
77
|
+
export declare function browserColorCheck(): ColorCheck;
|
|
78
|
+
/**
|
|
79
|
+
* Coerces a JS value given to a prop: a property assignment or an entry of the
|
|
80
|
+
* `<script type="application/json" data-props>` child (TAG-304).
|
|
81
|
+
*
|
|
82
|
+
* Inputs: the binding, any value (a Proxy, a throwing getter or a cycle included) and the
|
|
83
|
+
* browser's `ColorCheck`. Output: the contract's `propertyToValue` (a fresh accepted value; the
|
|
84
|
+
* default for `undefined`/`null`; the default and a `problem` for a refused value), with a given
|
|
85
|
+
* `color` also checked by `isColor`. Errors: never throws. Side effects: reads the value once
|
|
86
|
+
* through the contract's `checkValue`.
|
|
87
|
+
*/
|
|
88
|
+
export declare function propertyValue(binding: PropBinding, value: unknown, isColor?: ColorCheck): {
|
|
89
|
+
readonly value: unknown;
|
|
90
|
+
readonly problem?: ValueProblem;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Reads the props of a component from its element's attributes.
|
|
94
|
+
*
|
|
95
|
+
* Inputs: the bindings (`bindProps`), a function returning an attribute's text or `null` when
|
|
96
|
+
* absent (the element's `getAttribute`) and the browser's `ColorCheck` (default: accept all).
|
|
97
|
+
* Output: `{ props, problems }`; `props` is frozen, with one own property per binding: the
|
|
98
|
+
* coerced value, or the default when the attribute is absent or refused (each refusal is one
|
|
99
|
+
* `PropProblem`). Built with `Object.fromEntries`, so a prop name can never write the prototype.
|
|
100
|
+
* Errors: never throws. Side effects: calls `readAttribute` and `isColor`.
|
|
101
|
+
*/
|
|
102
|
+
export declare function readProps(bindings: readonly PropBinding[], readAttribute: (attribute: string) => string | null, isColor?: ColorCheck): ReadProps;
|
|
103
|
+
//# sourceMappingURL=attributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../src/element/attributes.ts"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MG;AACH,wBAAgB,iBAAiB,IAAI,UAAU,CAqB9C;AAeD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,UAAqB,GAC7B;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,CAAA;CAAE,CAE9D;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,SAAS,WAAW,EAAE,EAChC,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,EACnD,OAAO,GAAE,UAAqB,GAC7B,SAAS,CAqBX"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attributes → props of a component (TAG-302, coercion completed by TAG-303): which attributes the
|
|
3
|
+
* element observes and the props object the component receives, both derived from the manifest.
|
|
4
|
+
*
|
|
5
|
+
* Every rule of value lives in the contract (`@taggor/contract/zod-free`, the Zod-free entry the
|
|
6
|
+
* browser may import as values): `attributeToValue` applies the fixed parse of the declared type
|
|
7
|
+
* from `propTypeCatalog`, `propAttributeName` maps `maxValue` to `max-value`. Nothing here parses
|
|
8
|
+
* a value itself, and nothing ever evaluates one: no `eval`, `new Function`, HTML parsing or free
|
|
9
|
+
* `JSON.parse` (golden rule 5; the old runtime's `new Function` over attribute values cannot come
|
|
10
|
+
* back). The only check the runtime adds is browser-side and can only narrow: a `color` the
|
|
11
|
+
* contract accepts must also pass `CSS.supports("color", value)` when the page has it.
|
|
12
|
+
*
|
|
13
|
+
* Invalid text gives the declared default (`false` for a `boolean` without one) and a
|
|
14
|
+
* `PropProblem` the controller shows in debug mode; reading never throws. A prop whose `type` is
|
|
15
|
+
* not in the catalog (a newer contract minor, ADR 0019) is left out: not observed, not passed.
|
|
16
|
+
*
|
|
17
|
+
* TAG-304: a prop whose name the element already has (the caller's `isReserved`: the live
|
|
18
|
+
* `HTMLElement.prototype` chain and the Custom Element callbacks) is left out too, since its
|
|
19
|
+
* property accessor would shadow that member. `propertyValue` is the same coercion for a JS value
|
|
20
|
+
* (a property assignment or an entry of the `<script data-props>` child), through the contract's
|
|
21
|
+
* `propertyToValue` and the same `CSS.supports` narrowing.
|
|
22
|
+
*
|
|
23
|
+
* TAG-613: the props a site gives the component (the `defaults` of its manifest entry) become the
|
|
24
|
+
* `default` of the binding, when the prop's own type accepts them, so the precedence is attribute
|
|
25
|
+
* (or property, or script) > site > the component's declared default, with no extra branch at
|
|
26
|
+
* read time. A value the type refuses, a name that is not a bound prop and a `siteDefaults` that
|
|
27
|
+
* is not an object are ignored without a word: the API checked them against the same declarations
|
|
28
|
+
* before they reached the manifest.
|
|
29
|
+
*/
|
|
30
|
+
import { attributeToValue, propAttributeName, propertyToValue, propTypeCatalog, } from "@taggor/contract/zod-free";
|
|
31
|
+
function isKnownDeclaration(value) {
|
|
32
|
+
if (typeof value !== "object" || value === null)
|
|
33
|
+
return false;
|
|
34
|
+
const type = value.type;
|
|
35
|
+
// `Object.hasOwn`: a `type` such as "constructor" must not find Object.prototype members.
|
|
36
|
+
return typeof type === "string" && Object.hasOwn(propTypeCatalog, type);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The props of a manifest with their attributes, in declaration order.
|
|
40
|
+
*
|
|
41
|
+
* Inputs: the manifest and `isReserved` (TAG-304; default: no name is reserved), which says
|
|
42
|
+
* whether a prop name is already a member of the element. Output: frozen `{ bindings, unknown }`:
|
|
43
|
+
* one binding per own key of `manifest.props` that is not reserved and whose declaration has a
|
|
44
|
+
* `type` of `propTypeCatalog`; the other names (reserved, unknown type, not an object) in
|
|
45
|
+
* `unknown`, so the caller can warn. No props gives two empty lists. `siteDefaults` (TAG-613) is the
|
|
46
|
+
* site's value per prop name: an own entry the prop accepts replaces the binding's `default`.
|
|
47
|
+
* Errors: none (`isReserved` must not throw). Side effects: none.
|
|
48
|
+
*/
|
|
49
|
+
export function bindProps(manifest, isReserved = () => false, siteDefaults) {
|
|
50
|
+
const props = manifest.props ?? {};
|
|
51
|
+
const bindings = [];
|
|
52
|
+
const unknown = [];
|
|
53
|
+
for (const prop of Object.keys(props)) {
|
|
54
|
+
const declaration = props[prop];
|
|
55
|
+
if (!isReserved(prop) && isKnownDeclaration(declaration)) {
|
|
56
|
+
bindings.push(Object.freeze({
|
|
57
|
+
prop,
|
|
58
|
+
attribute: propAttributeName(prop),
|
|
59
|
+
// `value` is the site's value when the type accepts it, else the declaration's own
|
|
60
|
+
// default (also for `undefined`): one call covers "no site value" and "refused".
|
|
61
|
+
declaration: {
|
|
62
|
+
...declaration,
|
|
63
|
+
default: propertyToValue(declaration, siteDefaults?.[prop]).value,
|
|
64
|
+
},
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
unknown.push(prop);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return Object.freeze({ bindings: Object.freeze(bindings), unknown: Object.freeze(unknown) });
|
|
72
|
+
}
|
|
73
|
+
/** Accepts every color: a page without `CSS.supports` keeps the contract's allowlist. */
|
|
74
|
+
const anyColor = () => true;
|
|
75
|
+
/**
|
|
76
|
+
* The browser's color check, `CSS.supports("color", value)`, captured once.
|
|
77
|
+
*
|
|
78
|
+
* Inputs: none (reads `globalThis.CSS`). Output: a `ColorCheck`; without `CSS.supports` it
|
|
79
|
+
* accepts everything (the contract's allowlist still applies), and so it does when reading
|
|
80
|
+
* `CSS` or `CSS.supports` throws; a call that throws counts as unsupported. Errors: none. Side effects: none.
|
|
81
|
+
*/
|
|
82
|
+
export function browserColorCheck() {
|
|
83
|
+
let css;
|
|
84
|
+
let supports;
|
|
85
|
+
try {
|
|
86
|
+
// Page scripts own `CSS`: a getter that throws must not stop the element from being defined.
|
|
87
|
+
css = globalThis.CSS;
|
|
88
|
+
supports = css?.supports;
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return anyColor;
|
|
92
|
+
}
|
|
93
|
+
if (typeof supports !== "function")
|
|
94
|
+
return anyColor;
|
|
95
|
+
return (value) => {
|
|
96
|
+
try {
|
|
97
|
+
return (supports.call(css, "color", value) ===
|
|
98
|
+
true);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/** A given `color` the contract accepted must also pass the browser's check; else the default. */
|
|
106
|
+
function narrow(binding, coerced, given, isColor) {
|
|
107
|
+
if (!("problem" in coerced) &&
|
|
108
|
+
given &&
|
|
109
|
+
binding.declaration.type === "color" &&
|
|
110
|
+
!isColor(coerced.value)) {
|
|
111
|
+
return { value: binding.declaration.default, problem: "not-allowed" };
|
|
112
|
+
}
|
|
113
|
+
return coerced;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Coerces a JS value given to a prop: a property assignment or an entry of the
|
|
117
|
+
* `<script type="application/json" data-props>` child (TAG-304).
|
|
118
|
+
*
|
|
119
|
+
* Inputs: the binding, any value (a Proxy, a throwing getter or a cycle included) and the
|
|
120
|
+
* browser's `ColorCheck`. Output: the contract's `propertyToValue` (a fresh accepted value; the
|
|
121
|
+
* default for `undefined`/`null`; the default and a `problem` for a refused value), with a given
|
|
122
|
+
* `color` also checked by `isColor`. Errors: never throws. Side effects: reads the value once
|
|
123
|
+
* through the contract's `checkValue`.
|
|
124
|
+
*/
|
|
125
|
+
export function propertyValue(binding, value, isColor = anyColor) {
|
|
126
|
+
return narrow(binding, propertyToValue(binding.declaration, value), value != null, isColor);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Reads the props of a component from its element's attributes.
|
|
130
|
+
*
|
|
131
|
+
* Inputs: the bindings (`bindProps`), a function returning an attribute's text or `null` when
|
|
132
|
+
* absent (the element's `getAttribute`) and the browser's `ColorCheck` (default: accept all).
|
|
133
|
+
* Output: `{ props, problems }`; `props` is frozen, with one own property per binding: the
|
|
134
|
+
* coerced value, or the default when the attribute is absent or refused (each refusal is one
|
|
135
|
+
* `PropProblem`). Built with `Object.fromEntries`, so a prop name can never write the prototype.
|
|
136
|
+
* Errors: never throws. Side effects: calls `readAttribute` and `isColor`.
|
|
137
|
+
*/
|
|
138
|
+
export function readProps(bindings, readAttribute, isColor = anyColor) {
|
|
139
|
+
const problems = [];
|
|
140
|
+
const entries = bindings.map((binding) => {
|
|
141
|
+
const text = readAttribute(binding.attribute);
|
|
142
|
+
const { value, problem } = narrow(binding, attributeToValue(binding.declaration, text), text !== null, isColor);
|
|
143
|
+
if (problem !== undefined && text !== null) {
|
|
144
|
+
problems.push(Object.freeze({ prop: binding.prop, attribute: binding.attribute, problem, text }));
|
|
145
|
+
}
|
|
146
|
+
return [binding.prop, value];
|
|
147
|
+
});
|
|
148
|
+
return Object.freeze({
|
|
149
|
+
props: Object.freeze(Object.fromEntries(entries)),
|
|
150
|
+
problems: Object.freeze(problems),
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=attributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attributes.js","sourceRoot":"","sources":["../../src/element/attributes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,eAAe,GAIhB,MAAM,2BAA2B,CAAC;AAoBnC,SAAS,kBAAkB,CAAC,KAAc;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,IAAI,GAAI,KAAqC,CAAC,IAAI,CAAC;IACzD,0FAA0F;IAC1F,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;AAC1E,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,SAAS,CACvB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AAC,OAAO,EAAqB,EAAE;QAC1D,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC9C,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,CAC/B,OAAO,EACP,gBAAgB,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,EAC3C,IAAI,KAAK,IAAI,EACb,OAAO,CACR,CAAC;QACF,IAAI,OAAO,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAC3C,QAAQ,CAAC,IAAI,CACX,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CACnF,CAAC;QACJ,CAAC;QACD,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACjD,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;KAClC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { type ColorCheck, type PropBinding } from "./attributes.js";
|
|
2
|
+
import { type EventRoutes } from "./events.js";
|
|
3
|
+
import type { LiveComponents } from "../host/registry.js";
|
|
4
|
+
import type { ComponentInfo } from "../host/types.js";
|
|
5
|
+
import type { ComponentStyles } from "./styles.js";
|
|
6
|
+
import type { FallbackMode, MountableComponent, RuntimeDiagnostics } from "./types.js";
|
|
7
|
+
/** What a controller needs besides its element. */
|
|
8
|
+
export interface ComponentControllerDeps {
|
|
9
|
+
readonly definition: MountableComponent;
|
|
10
|
+
readonly bindings: readonly PropBinding[];
|
|
11
|
+
/** The declared events (`readEventRoutes`), shared by every element of the definition. */
|
|
12
|
+
readonly events: EventRoutes;
|
|
13
|
+
readonly styles: ComponentStyles;
|
|
14
|
+
/** Already guarded (`guardDiagnostics`): calling it never throws. */
|
|
15
|
+
readonly diagnostics: RuntimeDiagnostics;
|
|
16
|
+
readonly fallback: FallbackMode;
|
|
17
|
+
/** The browser's color check (`browserColorCheck`). */
|
|
18
|
+
readonly isColor: ColorCheck;
|
|
19
|
+
/** A form field (TAG-314): the controller attaches the element's `ElementInternals`. */
|
|
20
|
+
readonly formAssociated: boolean;
|
|
21
|
+
/** The shadow root delegates focus (TAG-314). */
|
|
22
|
+
readonly delegatesFocus: boolean;
|
|
23
|
+
/** Where the connected element is tracked for `window.taggor` (TAG-214). */
|
|
24
|
+
readonly live: LiveComponents;
|
|
25
|
+
/** The published version and the contract version the component is mounted with (TAG-214). */
|
|
26
|
+
readonly version: string | undefined;
|
|
27
|
+
readonly contractVersion: string | undefined;
|
|
28
|
+
/** The data transport given to the component as `host.transport` (TAG-709). */
|
|
29
|
+
readonly transport: unknown;
|
|
30
|
+
}
|
|
31
|
+
/** The lifecycle of one mounted component, mirroring the Custom Element callbacks. */
|
|
32
|
+
export interface ComponentController {
|
|
33
|
+
/** Mounts (or remounts) the component; after a `disconnect` in the same task, keeps the tree. */
|
|
34
|
+
readonly connect: () => void;
|
|
35
|
+
/**
|
|
36
|
+
* Schedules the unmount for a microtask (effect cleanups, abort of `host.signal`); a `connect`
|
|
37
|
+
* before it runs cancels it, keeping the tree. The shadow root is kept for a reconnect.
|
|
38
|
+
*/
|
|
39
|
+
readonly disconnect: () => void;
|
|
40
|
+
/** Re-renders with the new props when a bound attribute changed while connected. */
|
|
41
|
+
readonly attributeChanged: (attribute: string, previous: string | null, next: string | null) => void;
|
|
42
|
+
/**
|
|
43
|
+
* The host form was reset (`formResetCallback`, TAG-314): remounts the component's tree, so its
|
|
44
|
+
* state is the initial one again; nothing while unmounted or failed.
|
|
45
|
+
*/
|
|
46
|
+
readonly formReset: () => void;
|
|
47
|
+
/**
|
|
48
|
+
* Stores the browser's form restoration text (TAG-325) and re-renders a mounted field; nothing
|
|
49
|
+
* is painted while unmounted or failed. Short member name keeps the runtime under its byte ceiling.
|
|
50
|
+
*/
|
|
51
|
+
readonly r: (state: string) => void;
|
|
52
|
+
/**
|
|
53
|
+
* The element's disabled state changed (`formDisabledCallback`, TAG-314): renders again, so the
|
|
54
|
+
* component reads `element.matches(":disabled")`; nothing while unmounted or failed.
|
|
55
|
+
*/
|
|
56
|
+
readonly formDisabled: () => void;
|
|
57
|
+
/** Whether a failure was caught (the fallback is showing). */
|
|
58
|
+
readonly failed: () => boolean;
|
|
59
|
+
/**
|
|
60
|
+
* The form field API of the element (TAG-324): `value` is the last text the component gave
|
|
61
|
+
* `setFormValue` (`""` for none, `null`, a file or form data); another member is read from the
|
|
62
|
+
* internals, or called with `call` (`checkValidity`, `reportValidity`). Without internals (not
|
|
63
|
+
* a form field, or a browser without them): `undefined`, and `true` for a call (nothing blocks
|
|
64
|
+
* the form). Throws only when the page broke the internals (the element's accessor catches).
|
|
65
|
+
*/
|
|
66
|
+
readonly field: (member: string, call?: boolean) => unknown;
|
|
67
|
+
/**
|
|
68
|
+
* What `window.taggor.get` says about the element (TAG-214): frozen, with the current props;
|
|
69
|
+
* `undefined` when reading them throws (a page that broke the element's methods).
|
|
70
|
+
*/
|
|
71
|
+
readonly info: () => ComponentInfo | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* The value the component gets for a bound prop now (property > attribute > script > default),
|
|
74
|
+
* deep-frozen; `undefined` for a name that is not bound (TAG-304).
|
|
75
|
+
*/
|
|
76
|
+
readonly property: (prop: string) => unknown;
|
|
77
|
+
/**
|
|
78
|
+
* Sets a bound prop by property (TAG-304): coerced by the contract (a fresh value; refused gives
|
|
79
|
+
* the default and an `invalid-property` warning), `undefined`/`null` clears it; re-renders when
|
|
80
|
+
* mounted. Never throws, whatever the value (Proxy, throwing getter, cycle).
|
|
81
|
+
*/
|
|
82
|
+
readonly setProperty: (prop: string, value: unknown) => void;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Creates the controller of one element.
|
|
86
|
+
*
|
|
87
|
+
* Inputs: the host element and `ComponentControllerDeps`. Output: a `ComponentController`. Errors: none;
|
|
88
|
+
* no method ever throws (failures go to `diagnostics.reportError` with their phase). Side effects:
|
|
89
|
+
* takes over the element's own properties named like a bound prop (set before the upgrade:
|
|
90
|
+
* deleted and kept as properties, TAG-304) and, for a form field, attaches the element's
|
|
91
|
+
* `ElementInternals` (TAG-314; none when the browser lacks them or the page took them first);
|
|
92
|
+
* otherwise none until `connect`, which reads the
|
|
93
|
+
* `<script data-props>` child the first time (and listens once for `DOMContentLoaded` while the
|
|
94
|
+
* document is loading), attaches an open shadow root (once), adopts the styles, creates the
|
|
95
|
+
* mount's `AbortController` and renders; `disconnect` queues one microtask (the deferred unmount).
|
|
96
|
+
*/
|
|
97
|
+
export declare function createComponentController(element: HTMLElement, deps: ComponentControllerDeps): ComponentController;
|
|
98
|
+
//# sourceMappingURL=component-controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-controller.d.ts","sourceRoot":"","sources":["../../src/element/component-controller.ts"],"names":[],"mappings":"AAgEA,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,WAAW,EAEjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAEV,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAGnB,MAAM,YAAY,CAAC;AASpB,mDAAmD;AACnD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,UAAU,EAAE,kBAAk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