@taggor/runtime 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/compat/before-compat.js +1 -1
- package/dist/compat/index.d.ts.map +1 -1
- package/dist/compat/index.js +3 -3
- package/dist/compat/scope.d.ts +2 -2
- package/dist/element/attributes.d.ts +7 -7
- package/dist/element/attributes.d.ts.map +1 -1
- package/dist/element/attributes.js +6 -6
- package/dist/element/component-controller.d.ts +14 -14
- package/dist/element/component-controller.d.ts.map +1 -1
- package/dist/element/component-controller.js +28 -28
- package/dist/element/component-controller.js.map +1 -1
- package/dist/element/contract-gate.d.ts +2 -2
- package/dist/element/contract-gate.js +2 -2
- package/dist/element/create-component-element.d.ts +11 -11
- package/dist/element/create-component-element.js +15 -15
- package/dist/element/create-component-element.js.map +1 -1
- package/dist/element/define-element.d.ts +4 -4
- package/dist/element/define-element.d.ts.map +1 -1
- package/dist/element/define-element.js +1 -1
- package/dist/element/define-element.js.map +1 -1
- package/dist/element/diagnostics.d.ts +2 -2
- package/dist/element/error-boundary.d.ts +2 -2
- package/dist/element/error-boundary.d.ts.map +1 -1
- package/dist/element/error-boundary.js +1 -1
- package/dist/element/error-report.d.ts +2 -2
- package/dist/element/error-report.d.ts.map +1 -1
- package/dist/element/error-report.js +14 -7
- package/dist/element/error-report.js.map +1 -1
- package/dist/element/events.d.ts +5 -6
- package/dist/element/events.d.ts.map +1 -1
- package/dist/element/events.js +5 -6
- package/dist/element/events.js.map +1 -1
- package/dist/element/handler-guard.d.ts +3 -3
- package/dist/element/handler-guard.js +5 -5
- package/dist/element/handler-guard.js.map +1 -1
- package/dist/element/index.d.ts +1 -2
- package/dist/element/index.d.ts.map +1 -1
- package/dist/element/index.js +1 -2
- package/dist/element/index.js.map +1 -1
- package/dist/element/props-script.d.ts +1 -1
- package/dist/element/props-script.js +1 -1
- package/dist/element/styles.d.ts +11 -9
- package/dist/element/styles.d.ts.map +1 -1
- package/dist/element/styles.js +10 -8
- package/dist/element/styles.js.map +1 -1
- package/dist/element/types.d.ts +22 -22
- package/dist/element/types.d.ts.map +1 -1
- package/dist/host/api.d.ts +3 -3
- package/dist/host/api.d.ts.map +1 -1
- package/dist/host/api.js +9 -10
- package/dist/host/api.js.map +1 -1
- package/dist/host/barrier.d.ts +2 -2
- package/dist/host/barrier.js +3 -3
- package/dist/host/barrier.js.map +1 -1
- package/dist/host/index.d.ts +2 -2
- package/dist/host/index.js +2 -2
- package/dist/host/registry.d.ts +2 -2
- package/dist/host/registry.js +2 -2
- package/dist/host/registry.js.map +1 -1
- package/dist/host/types.d.ts +1 -1
- package/dist/host/types.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/loader/config.d.ts +7 -7
- package/dist/loader/config.d.ts.map +1 -1
- package/dist/loader/config.js +4 -4
- package/dist/loader/config.js.map +1 -1
- package/dist/loader/entry.js +9 -4
- package/dist/loader/entry.js.map +1 -1
- package/dist/loader/lazy-transport.d.ts +1 -1
- package/dist/loader/lazy-transport.js +1 -1
- package/dist/loader/loader-code.d.ts +1 -1
- package/dist/loader/loader-code.js +2 -2
- package/dist/loader/loading.d.ts +1 -1
- package/dist/loader/loading.js +1 -1
- package/dist/loader/page-state.d.ts +4 -2
- package/dist/loader/page-state.d.ts.map +1 -1
- package/dist/loader/resilient-import.d.ts +2 -2
- package/dist/loader/resilient-import.d.ts.map +1 -1
- package/dist/loader/resilient-import.js +1 -1
- package/dist/loader/run.d.ts +9 -8
- package/dist/loader/run.d.ts.map +1 -1
- package/dist/loader/run.js +54 -44
- package/dist/loader/run.js.map +1 -1
- package/dist/loader/script-url.d.ts +4 -4
- package/dist/loader/script-url.js +5 -5
- package/dist/loader/script-url.js.map +1 -1
- package/dist/loader/script.d.ts +2 -2
- package/dist/loader/script.js +2 -2
- package/dist/server/render-fragment.d.ts +1 -1
- package/dist/server/render-fragment.d.ts.map +1 -1
- package/dist/server/render-fragment.js +2 -2
- package/dist/server/render-fragment.js.map +1 -1
- package/dist/server/ssr-code.d.ts +1 -1
- package/dist/server/ssr-code.js +3 -3
- package/dist/server/worker.d.ts +2 -2
- package/dist/server/worker.js +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The browser half of the runtime error telemetry
|
|
3
|
-
* `
|
|
4
|
-
* scrubs, hashes and records it (apps/edge `domain/error-event.ts` owns the wire format).
|
|
2
|
+
* The browser half of the runtime error telemetry: a caught component failure becomes one
|
|
3
|
+
* keepalive `fetch` to `POST /e/<siteKey>` of the delivery origin, where the edge validates,
|
|
4
|
+
* scrubs, hashes and records it (apps/edge `domain/error-event.ts` owns the wire format). A CORS
|
|
5
|
+
* request, not `sendBeacon`: a beacon's `Origin` follows the page's Referrer-Policy and is `null`
|
|
6
|
+
* in Firefox and WebKit under `no-referrer` or `same-origin`, which the edge refuses.
|
|
5
7
|
*
|
|
6
8
|
* Body: `error <versionHash> <phase> <frames> <message>`; `phase` is the failure phase
|
|
7
9
|
* (`render`, `handler`, `lifecycle`), `frames` the end of each stack line that names this component's
|
|
@@ -14,7 +16,8 @@
|
|
|
14
16
|
*
|
|
15
17
|
* Bounded (golden rule 2): at most `RUNTIME_ERRORS_PER_COMPONENT_PER_PAGE` reports per component tag
|
|
16
18
|
* for the page's life, so a component in an error loop costs five beacons; every step is inside
|
|
17
|
-
* `try`, a page without `
|
|
19
|
+
* `try`, a page without `fetch` sends nothing, a failed request is swallowed, and nothing here can
|
|
20
|
+
* throw at the page or leave a rejection on it. The
|
|
18
21
|
* site key comes from the loader's shared page record (`Symbol.for("taggor.loader")`, claim
|
|
19
22
|
* `"<siteKey>\n<version>"`, `loader/page-state.ts`); a claim of another version or site is not ours
|
|
20
23
|
* to report on. Written tersely: the runtime is at its byte ceiling.
|
|
@@ -25,8 +28,8 @@ const sent = new Map();
|
|
|
25
28
|
* Reports one caught failure.
|
|
26
29
|
* Inputs: the component tag, the published version hash, the failure phase, the caught value and
|
|
27
30
|
* the delivery origin (the loader's runtime URL; never `import.meta.url`, which is a syntax error
|
|
28
|
-
* when a host page loads the bundle as a classic script and made props.e2e.ts fail
|
|
29
|
-
* Output: none. Errors: never throws. Side effects: at most one
|
|
31
|
+
* when a host page loads the bundle as a classic script and made props.e2e.ts fail).
|
|
32
|
+
* Output: none. Errors: never throws. Side effects: at most one request and the per-tag counter.
|
|
30
33
|
*/
|
|
31
34
|
export function reportFailure(tag, version, phase, error, origin) {
|
|
32
35
|
try {
|
|
@@ -42,7 +45,11 @@ export function reportFailure(tag, version, phase, error, origin) {
|
|
|
42
45
|
.map((line) => line.split(version)[1])
|
|
43
46
|
.slice(0, RUNTIME_ERROR_MAX_FRAMES)
|
|
44
47
|
.join();
|
|
45
|
-
|
|
48
|
+
fetch(new URL(`/e/${site}`, origin), {
|
|
49
|
+
method: "POST",
|
|
50
|
+
body: `error ${version} ${phase} ${frames} ${String(message).slice(0, RUNTIME_ERROR_MESSAGE_MAX)}`,
|
|
51
|
+
keepalive: true,
|
|
52
|
+
}).catch(() => undefined);
|
|
46
53
|
}
|
|
47
54
|
catch {
|
|
48
55
|
// Telemetry never reaches the page.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-report.js","sourceRoot":"","sources":["../../src/element/error-report.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"error-report.js","sourceRoot":"","sources":["../../src/element/error-report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,qCAAqC,GACtC,MAAM,2BAA2B,CAAC;AAEnC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAkB,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC3B,GAAW,EACX,OAAe,EACf,KAAa,EACb,KAAc,EACd,MAAc;IAEd,IAAI,CAAC;Q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/element/events.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Component events
|
|
2
|
+
* Component events: the host's `emit(name, detail)`, which dispatches a declared event on
|
|
3
3
|
* the host element as a `CustomEvent` named `<tag>:<event>`, so the page sees the host as `target`
|
|
4
4
|
* and never a node of the shadow root.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* The `<tag>` prefix is given at dispatch time by the caller, never read from the
|
|
7
7
|
* manifest here: the controller passes the tag the element's class is really registered under
|
|
8
8
|
* (its `localName`), so after a collision a component never dispatches events under the declared tag
|
|
9
9
|
* that belongs to another script.
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
* value is deep-frozen (the contract's `deepFreeze`), so every page listener sees the same data
|
|
22
22
|
* and the component holds no reference to it. The value rule is the contract's, never
|
|
23
23
|
* re-implemented here.
|
|
24
|
-
* - without `structuredClone` (Chrome < 98, Firefox < 94, Safari < 15.4) nothing is dispatched
|
|
25
|
-
*
|
|
24
|
+
* - without `structuredClone` (Chrome < 98, Firefox < 94, Safari < 15.4) nothing is dispatched:
|
|
25
|
+
* the declarations could not be copied, and checking the live component object would
|
|
26
26
|
* run its getters and Proxy traps again.
|
|
27
27
|
*
|
|
28
28
|
* A dropped `emit` comes back as a message for the debug log (`event-dropped`); it names the
|
|
@@ -53,8 +53,7 @@ export declare function readEventRoutes(events: unknown): EventRoutes;
|
|
|
53
53
|
/**
|
|
54
54
|
* Handles one `emit` call: dispatches the declared event `name` on `target`, or says why not.
|
|
55
55
|
*
|
|
56
|
-
* Inputs: the host element, the routes, the event tag (the tag the element is registered under,
|
|
57
|
-
* TAG-320), the `name` and `detail` the component passed (any values) and whether
|
|
56
|
+
* Inputs: the host element, the routes, the event tag (the tag the element is registered under), the `name` and `detail` the component passed (any values) and whether
|
|
58
57
|
* the component is mounted (connected and not failed). Output: `undefined` when a
|
|
59
58
|
* `CustomEvent` was dispatched (type `<tag>:<name>`, the declared `bubbles`/`composed`, and a
|
|
60
59
|
* `detail` that is a new, deep-frozen value holding only the declared data); otherwise the debug
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/element/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAA0B,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAErF,uDAAuD;AACvD,MAAM,WAAW,UAAU;IACzB,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,uEAAuE;AACvE,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAE1D;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,WAAW,CAkB5D;AAED
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/element/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAA0B,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAErF,uDAAuD;AACvD,MAAM,WAAW,UAAU;IACzB,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,uEAAuE;AACvE,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAE1D;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,WAAW,CAkB5D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,WAAW,EACnB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,OAAO,GACf,MAAM,GAAG,SAAS,CA6BpB"}
|
package/dist/element/events.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Component events
|
|
2
|
+
* Component events: the host's `emit(name, detail)`, which dispatches a declared event on
|
|
3
3
|
* the host element as a `CustomEvent` named `<tag>:<event>`, so the page sees the host as `target`
|
|
4
4
|
* and never a node of the shadow root.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* The `<tag>` prefix is given at dispatch time by the caller, never read from the
|
|
7
7
|
* manifest here: the controller passes the tag the element's class is really registered under
|
|
8
8
|
* (its `localName`), so after a collision a component never dispatches events under the declared tag
|
|
9
9
|
* that belongs to another script.
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
* value is deep-frozen (the contract's `deepFreeze`), so every page listener sees the same data
|
|
22
22
|
* and the component holds no reference to it. The value rule is the contract's, never
|
|
23
23
|
* re-implemented here.
|
|
24
|
-
* - without `structuredClone` (Chrome < 98, Firefox < 94, Safari < 15.4) nothing is dispatched
|
|
25
|
-
*
|
|
24
|
+
* - without `structuredClone` (Chrome < 98, Firefox < 94, Safari < 15.4) nothing is dispatched:
|
|
25
|
+
* the declarations could not be copied, and checking the live component object would
|
|
26
26
|
* run its getters and Proxy traps again.
|
|
27
27
|
*
|
|
28
28
|
* A dropped `emit` comes back as a message for the debug log (`event-dropped`); it names the
|
|
@@ -64,8 +64,7 @@ export function readEventRoutes(events) {
|
|
|
64
64
|
/**
|
|
65
65
|
* Handles one `emit` call: dispatches the declared event `name` on `target`, or says why not.
|
|
66
66
|
*
|
|
67
|
-
* Inputs: the host element, the routes, the event tag (the tag the element is registered under,
|
|
68
|
-
* TAG-320), the `name` and `detail` the component passed (any values) and whether
|
|
67
|
+
* Inputs: the host element, the routes, the event tag (the tag the element is registered under), the `name` and `detail` the component passed (any values) and whether
|
|
69
68
|
* the component is mounted (connected and not failed). Output: `undefined` when a
|
|
70
69
|
* `CustomEvent` was dispatched (type `<tag>:<name>`, the declared `bubbles`/`composed`, and a
|
|
71
70
|
* `detail` that is a new, deep-frozen value holding only the declared data); otherwise the debug
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/element/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAoB,MAAM,2BAA2B,CAAC;AAcrF;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,MAAe;IAC7C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC7C,IAAI,CAAC;QACH,MAAM,IAAI,GAAY,eAAe,CAAC,MAAM,CAAC,CAAC;QAC9C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,OAAO,MAAM,CAAC;QACnC,KAAK,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACvD,2FAA2F;YAC3F,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;gBAAE,SAAS;YACzE,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE;gBACf,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAgB;gBAC5C,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,KAAK,KAAK;gBACzC,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,KAAK,KAAK;aAC5C,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,yFAAyF;IAC3F,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CA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,SAAS,CAAC;IACtE,uFAAuF;IACvF,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,0BAA0B,CAAC;IAC3D,MAAM,OAAO,GAAG,UAAU,IAAc,aAAa,CAAC;IACtD,qFAAqF;IACrF,IAAI,CAAC,OAAO;QAAE,OAAO,GAAG,OAAO,aAAa,CAAC;IAC7C,IAAI,OAAsC,CAAC;IAC3C,IAAI,CAAC;QACH,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9D,CAAC;IAAC,MAAM,CAAC;QACP,4FAA4F;QAC5F,oBAAoB;QACpB,OAAO,GAAG,OAAO,gBAAgB,CAAC;IACpC,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,EAAE;QAAE,OAAO,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAClD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACpC,IAAI,CAAC;QACH,MAAM,CAAC,aAAa,CAClB,IAAI,WAAW,CAAC,GAAG,GAAG,IAAI,IAAc,EAAE,EAAE;YAC1C,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC;YACjC,OAAO;YACP,QAAQ;SACT,CAAC,CACH,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,OAAO,iBAAiB,CAAC;IACrC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Event handler guard
|
|
2
|
+
* Event handler guard: routes an exception thrown by a component's DOM event handler to
|
|
3
3
|
* that component's error boundary instead of the page.
|
|
4
4
|
*
|
|
5
5
|
* Why: Preact's error boundaries catch render and effect errors, but an `onClick` that throws is
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
*
|
|
12
12
|
* The hook is installed on the first `createComponentElement`, never at import (golden rule 2), and
|
|
13
13
|
* chains any `options.vnode` already set. It changes only the runtime's own copy of Preact, which
|
|
14
|
-
* is why component bundles must share it rather than bring their own
|
|
14
|
+
* is why component bundles must share it rather than bring their own.
|
|
15
15
|
* An error from a handler outside every registered component is rethrown unchanged.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
17
|
+
* A wrapper is stamped with a private class field (`WrapperStamp`), not tracked in a
|
|
18
18
|
* WeakSet or cached in a WeakMap per handler. Handlers are new closures on every render, and those weak
|
|
19
19
|
* tables grew the retained heap by about 14 bytes per mount even after the entries died
|
|
20
20
|
* (measured in Chromium by e2e/lifecycle.e2e.ts); the only per-root state left is
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Event handler guard
|
|
2
|
+
* Event handler guard: routes an exception thrown by a component's DOM event handler to
|
|
3
3
|
* that component's error boundary instead of the page.
|
|
4
4
|
*
|
|
5
5
|
* Why: Preact's error boundaries catch render and effect errors, but an `onClick` that throws is
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
*
|
|
12
12
|
* The hook is installed on the first `createComponentElement`, never at import (golden rule 2), and
|
|
13
13
|
* chains any `options.vnode` already set. It changes only the runtime's own copy of Preact, which
|
|
14
|
-
* is why component bundles must share it rather than bring their own
|
|
14
|
+
* is why component bundles must share it rather than bring their own.
|
|
15
15
|
* An error from a handler outside every registered component is rethrown unchanged.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
17
|
+
* A wrapper is stamped with a private class field (`WrapperStamp`), not tracked in a
|
|
18
18
|
* WeakSet or cached in a WeakMap per handler. Handlers are new closures on every render, and those weak
|
|
19
19
|
* tables grew the retained heap by about 14 bytes per mount even after the entries died
|
|
20
20
|
* (measured in Chromium by e2e/lifecycle.e2e.ts); the only per-root state left is
|
|
@@ -30,7 +30,7 @@ const guardedOptions = new WeakSet();
|
|
|
30
30
|
* never forwards it to its target nor answers for it through a trap, and an object inheriting
|
|
31
31
|
* from a wrapper does not have it. A symbol property, even compared with a private value, can be
|
|
32
32
|
* copied from a real wrapper's descriptor and replayed by a Proxy trap, so a handler could skip
|
|
33
|
-
* the guard and throw at the page
|
|
33
|
+
* the guard and throw at the page. No table, so nothing grows.
|
|
34
34
|
*/
|
|
35
35
|
// Return override: `new WrapperStamp(fn)` adds the private field to `fn` itself, because this
|
|
36
36
|
// base constructor returns the object it is given instead of a new one.
|
|
@@ -104,7 +104,7 @@ export function guarded(handler) {
|
|
|
104
104
|
if (isWrapper(handler))
|
|
105
105
|
return handler;
|
|
106
106
|
const wrapper = function (...args) {
|
|
107
|
-
// Resolve the
|
|
107
|
+
// Resolve the host element before the handler runs: `currentTarget` is null once the dispatch is
|
|
108
108
|
// over, and the component unregisters its root on disconnect, which may happen before an async
|
|
109
109
|
// handler settles.
|
|
110
110
|
const target = currentTargetOf(args[0]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler-guard.js","sourceRoot":"","sources":["../../src/element/handler-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,OAAO,EAAc,MAAM,QAAQ,CAAC;AAO7C,MAAM,aAAa,GAAG,IAAI,OAAO,EAAwB,CAAC;AAC1D,MAAM,cAAc,GAAG,IAAI,OAAO,EAAU,CAAC;AAE7C;;;;;;;;GAQG;AACH,8FAA8F;AAC9F,wEAAwE;AACxE,MAAM,SAAS,GAAG,UAAU,MAAc;IACxC,OAAO,MAAM,CAAC;AAChB,CAA8C,CAAC;AAE/C,MAAM,YAAa,SAAQ,SAAS;IACzB,QAAQ,GAAG,IAAI,CAAC;IAEzB,uFAAuF;IACvF,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,IAAI,CAAC;YACH,OAAQ,KAAsB,CAAC,QAAQ,CAAC;QAC1C,CAAC;QAAC,MAAM,CAAC;YACP,wF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SAAS,CAAC,IAAU;IAC3B,IAAI,OAAO,GAAgB,IAAI,CAAC;IAChC,OAAO,OAAO,KAAK,IAAI,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,SAAS,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,SAAS,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAC9C,OAAO,GAAG,MAAM,IAAI,IAAI,CAAC,CAAC,CAAE,IAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/element/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The Custom Element wrapper of the runtime
|
|
3
|
-
* docs/agentes/runtime.md.
|
|
2
|
+
* The Custom Element wrapper of the runtime: `createComponentElement` and its types..
|
|
4
3
|
*/
|
|
5
4
|
export { createComponentElement, type ComponentElementOptions, type ComponentElementRegistration, } from "./create-component-element.js";
|
|
6
5
|
export { GENERIC_TAG, type ElementRegistry } from "./define-element.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/element/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/element/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,sBAAsB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,GAClC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EACL,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,aAAa,GACnB,MAAM,YAAY,CAAC"}
|
package/dist/element/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The Custom Element wrapper of the runtime
|
|
3
|
-
* docs/agentes/runtime.md.
|
|
2
|
+
* The Custom Element wrapper of the runtime: `createComponentElement` and its types..
|
|
4
3
|
*/
|
|
5
4
|
export { createComponentElement, } from "./create-component-element.js";
|
|
6
5
|
export { GENERIC_TAG } from "./define-element.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/element/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/element/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,sBAAsB,GAGvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,WAAW,EAAwB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAA2B,MAAM,kBAAkB,CAAC;AAClG,OAAO,EACL,cAAc,GAUf,MAAM,YAAY,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Props from a `<script type="application/json" data-props>` child
|
|
2
|
+
* Props from a `<script type="application/json" data-props>` child: how a CMS without
|
|
3
3
|
* JavaScript gives a component its `array` and `object` props (any prop, in fact) as one JSON object.
|
|
4
4
|
*
|
|
5
5
|
* ```html
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Props from a `<script type="application/json" data-props>` child
|
|
2
|
+
* Props from a `<script type="application/json" data-props>` child: how a CMS without
|
|
3
3
|
* JavaScript gives a component its `array` and `object` props (any prop, in fact) as one JSON object.
|
|
4
4
|
*
|
|
5
5
|
* ```html
|
package/dist/element/styles.d.ts
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Component styles in the shadow root
|
|
2
|
+
* Component styles in the shadow root: the component's CSS is adopted by its own shadow root,
|
|
3
3
|
* never added to the page (the old prototype's global CSS defect).
|
|
4
4
|
*
|
|
5
5
|
* With constructable stylesheets (`new CSSStyleSheet()` + `adoptedStyleSheets`), one sheet per
|
|
6
6
|
* CSS text is built once per component definition and shared by its instances. Without them (old
|
|
7
7
|
* browsers), the error boundary renders `<style>` elements whose CSS is a text node, never parsed
|
|
8
8
|
* as HTML. `replaceSync` ignores `@import`, so adopted CSS cannot load another stylesheet; the
|
|
9
|
-
* `<style>` fallback does load it, subject to the page's `style-src
|
|
9
|
+
* `<style>` fallback does load it, subject to the page's `style-src`.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* Every component starts with the runtime's minimal host reset (`HOST_RESET`), the first
|
|
12
12
|
* sheet, so the component's own `:host` rules (later in the same shadow tree) and the page's rules on
|
|
13
13
|
* the tag (the outer tree wins over `:host`) both override it. The `<style>` fallback carries the
|
|
14
14
|
* page's CSP nonce when the loader passes one (`createComponentElement`'s `styleNonce`); adopted
|
|
15
15
|
* sheets need none, because CSP's `style-src` does not govern constructed stylesheets.
|
|
16
16
|
*/
|
|
17
17
|
/**
|
|
18
|
-
* The runtime's reset of every component host
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
18
|
+
* The runtime's reset of every component host: a block box, and the `hidden` attribute still
|
|
19
|
+
* hiding it (an author `display` beats the user agent's `[hidden]` rule). It does NOT contain:
|
|
20
|
+
* a shadow, a focus ring, a dropdown or a tooltip may leave the box. A component that
|
|
21
|
+
* wants its paint, layout and `position: fixed` boxes held inside its own box writes
|
|
22
|
+
* `:host { contain: content }`. A fixed layer over the page is the component's own choice; the
|
|
23
|
+
* builder does not judge it.
|
|
22
24
|
*/
|
|
23
|
-
export declare const HOST_RESET = ":host{display:block
|
|
25
|
+
export declare const HOST_RESET = ":host{display:block}:host([hidden]){display:none}";
|
|
24
26
|
/** How a component's CSS reaches its shadow roots. */
|
|
25
27
|
export interface ComponentStyles {
|
|
26
28
|
/** Adds the sheets to `root.adoptedStyleSheets`; returns false when unsupported. */
|
|
@@ -29,7 +31,7 @@ export interface ComponentStyles {
|
|
|
29
31
|
readonly drop: (root: ShadowRoot) => void;
|
|
30
32
|
/** The CSS texts, `HOST_RESET` first, for the `<style>` fallback. */
|
|
31
33
|
readonly css: readonly string[];
|
|
32
|
-
/** The CSP nonce of the `<style>` fallback, when the page gave one
|
|
34
|
+
/** The CSP nonce of the `<style>` fallback, when the page gave one. */
|
|
33
35
|
readonly nonce: string | undefined;
|
|
34
36
|
}
|
|
35
37
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/element/styles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/element/styles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,sDAAsD,CAAC;AAE9E,sDAAsD;AACtD,MAAM,WAAW,eAAe;IAC9B,oFAAoF;IACpF,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC;IAC9C,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IAC1C,qEAAqE;IACrE,QAAQ,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,uEAAuE;IACvE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAUD;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,SAAS,MAAM,EAAE,EAC/B,KAAK,CAAC,EAAE,MAAM,GACb,eAAe,CAwBjB"}
|
package/dist/element/styles.js
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Component styles in the shadow root
|
|
2
|
+
* Component styles in the shadow root: the component's CSS is adopted by its own shadow root,
|
|
3
3
|
* never added to the page (the old prototype's global CSS defect).
|
|
4
4
|
*
|
|
5
5
|
* With constructable stylesheets (`new CSSStyleSheet()` + `adoptedStyleSheets`), one sheet per
|
|
6
6
|
* CSS text is built once per component definition and shared by its instances. Without them (old
|
|
7
7
|
* browsers), the error boundary renders `<style>` elements whose CSS is a text node, never parsed
|
|
8
8
|
* as HTML. `replaceSync` ignores `@import`, so adopted CSS cannot load another stylesheet; the
|
|
9
|
-
* `<style>` fallback does load it, subject to the page's `style-src
|
|
9
|
+
* `<style>` fallback does load it, subject to the page's `style-src`.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* Every component starts with the runtime's minimal host reset (`HOST_RESET`), the first
|
|
12
12
|
* sheet, so the component's own `:host` rules (later in the same shadow tree) and the page's rules on
|
|
13
13
|
* the tag (the outer tree wins over `:host`) both override it. The `<style>` fallback carries the
|
|
14
14
|
* page's CSP nonce when the loader passes one (`createComponentElement`'s `styleNonce`); adopted
|
|
15
15
|
* sheets need none, because CSP's `style-src` does not govern constructed stylesheets.
|
|
16
16
|
*/
|
|
17
17
|
/**
|
|
18
|
-
* The runtime's reset of every component host
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
18
|
+
* The runtime's reset of every component host: a block box, and the `hidden` attribute still
|
|
19
|
+
* hiding it (an author `display` beats the user agent's `[hidden]` rule). It does NOT contain:
|
|
20
|
+
* a shadow, a focus ring, a dropdown or a tooltip may leave the box. A component that
|
|
21
|
+
* wants its paint, layout and `position: fixed` boxes held inside its own box writes
|
|
22
|
+
* `:host { contain: content }`. A fixed layer over the page is the component's own choice; the
|
|
23
|
+
* builder does not judge it.
|
|
22
24
|
*/
|
|
23
|
-
export const HOST_RESET = ":host{display:block
|
|
25
|
+
export const HOST_RESET = ":host{display:block}:host([hidden]){display:none}";
|
|
24
26
|
/** The constructor of constructable stylesheets, when the browser has it. */
|
|
25
27
|
function sheetConstructor() {
|
|
26
28
|
const candidate = globalThis.CSSStyleSheet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/element/styles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/element/styles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,mDAAmD,CAAC;AAc9E,6EAA6E;AAC7E,SAAS,gBAAgB;IACvB,MAAM,SAAS,GAAI,UAAuD,CAAC,aAAa,CAAC;IACzF,OAAO,OAAO,SAAS,KAAK,UAAU,IAAI,OAAO,SAAS,CAAC,SAAS,CAAC,WAAW,KAAK,UAAU;QAC7F,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACnC,YAA+B,EAC/B,KAAc;IAEd,IAAI,MAAmC,CAAC;IACxC,MAAM,KAAK,GAAG,CAAC,KAAoB,EAAE,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IACzE,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC;IAEzD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,GAAG;QACH,KAAK;QACL,KAAK,EAAE,CAAC,IAAgB,EAAE,EAAE;YAC1B,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;YACjC,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC,oBAAoB,IAAI,IAAI,CAAC;gBAAE,OAAO,KAAK,CAAC;YACzE,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;gBAC1B,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC;gBAC1B,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACxB,OAAO,KAAK,CAAC;YACf,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,kBAAkB,GAAG,CAAC,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC;YAC3F,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,EAAE,CAAC,IAAgB,EAAE,EAAE;YACzB,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,CAAC,oBAAoB,IAAI,IAAI,CAAC;gBAAE,OAAO;YACpE,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7E,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/dist/element/types.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Types of the Custom Element wrapper
|
|
2
|
+
* Types of the Custom Element wrapper: what the runtime mounts (`MountableComponent`, the
|
|
3
3
|
* shape `defineTaggorComponent` of `@taggor/component` produces), what it gives the mounted component
|
|
4
4
|
* (`ComponentHost`) and the diagnostics port it reports through (`RuntimeDiagnostics`).
|
|
5
5
|
*
|
|
6
6
|
* The runtime does not depend on `@taggor/component`: the SDK depends on the runtime for its test
|
|
7
|
-
* helpers (`@taggor/component/testing
|
|
8
|
-
* is assignable to `MountableComponent`.
|
|
9
|
-
*
|
|
10
|
-
* warnings
|
|
11
|
-
* `internals
|
|
7
|
+
* helpers (`@taggor/component/testing`), so the definition is described here structurally. A `ComponentDefinition`
|
|
8
|
+
* is assignable to `MountableComponent`. It also carries `contractVersion` and the coercion
|
|
9
|
+
* warnings, the `events` map and the `event-dropped` warning, the property and props script
|
|
10
|
+
* warnings, the form field declarations (`formAssociated`, `delegatesFocus`) and the host's
|
|
11
|
+
* `internals`, the `host-api` warning of `window.taggor` and the host's `transport`.
|
|
12
12
|
*/
|
|
13
13
|
import type { EventDeclaration } from "@taggor/contract";
|
|
14
14
|
import type { PropDeclaration } from "@taggor/contract/zod-free";
|
|
@@ -19,15 +19,15 @@ export declare const COMPONENT_KIND = "taggor.component";
|
|
|
19
19
|
*
|
|
20
20
|
* - `element`: the custom element on the host page (its light DOM holds the slotted content).
|
|
21
21
|
* - `shadowRoot`: the component's own open shadow root, where the component renders.
|
|
22
|
-
* - `emit(name, detail)
|
|
22
|
+
* - `emit(name, detail)`: while the component is mounted, dispatches the declared event
|
|
23
23
|
* `name` on `element` as a `CustomEvent` named `<tag>:<name>`, with a validated, frozen copy of
|
|
24
24
|
* `detail` and the declared `bubbles`/`composed`. Anything else (an undeclared name, a detail
|
|
25
25
|
* the event's schema refuses, a call after the unmount or after a failure) is dropped with an
|
|
26
26
|
* `event-dropped` warning. Called as a plain function; never throws.
|
|
27
|
-
* - `signal
|
|
27
|
+
* - `signal`: aborted when the component is really unmounted (removed, not moved); the
|
|
28
28
|
* SDK's data transport passes it to `fetch`. A new signal per mount; `undefined` only on a
|
|
29
29
|
* page without `AbortController`.
|
|
30
|
-
* - `internals
|
|
30
|
+
* - `internals`: the element's `ElementInternals` when the manifest declares
|
|
31
31
|
* `formAssociated: true` (the SDK's `useFormField` sets the form value and validity through it);
|
|
32
32
|
* `undefined` otherwise, and on a browser without form-associated custom elements.
|
|
33
33
|
*/
|
|
@@ -38,7 +38,7 @@ export interface ComponentHost {
|
|
|
38
38
|
readonly signal?: AbortSignal | undefined;
|
|
39
39
|
readonly internals?: ElementInternals | undefined;
|
|
40
40
|
/**
|
|
41
|
-
* The data transport of the component
|
|
41
|
+
* The data transport of the component, opaque to the runtime: the loader gives components
|
|
42
42
|
* that declare `data` a lazy one (`loader/lazy-transport.ts`); the SDK's data hooks use it.
|
|
43
43
|
*/
|
|
44
44
|
readonly transport?: unknown;
|
|
@@ -53,11 +53,11 @@ export interface MountableManifest {
|
|
|
53
53
|
readonly tag: string;
|
|
54
54
|
readonly contractVersion?: string | undefined;
|
|
55
55
|
readonly props?: Readonly<Record<string, PropDeclaration>> | undefined;
|
|
56
|
-
/** Declared events
|
|
56
|
+
/** Declared events, read once when the element class is created. */
|
|
57
57
|
readonly events?: Readonly<Record<string, EventDeclaration>> | undefined;
|
|
58
|
-
/** A form field component (
|
|
58
|
+
/** A form field component (contract 1.4): the element is form-associated. */
|
|
59
59
|
readonly formAssociated?: boolean | undefined;
|
|
60
|
-
/** Whether the shadow root delegates focus
|
|
60
|
+
/** Whether the shadow root delegates focus; defaults to `formAssociated`. */
|
|
61
61
|
readonly delegatesFocus?: boolean | undefined;
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
@@ -99,36 +99,36 @@ export type WarningCode =
|
|
|
99
99
|
/** The page has no Custom Elements (no `customElements` or `HTMLElement`). */
|
|
100
100
|
| "unsupported"
|
|
101
101
|
/**
|
|
102
|
-
* The manifest's `contractVersion
|
|
102
|
+
* The manifest's `contractVersion`: a newer minor (mounted, its additions ignored) or
|
|
103
103
|
* a version this runtime cannot mount (missing, malformed, newer major, unsupported major).
|
|
104
104
|
*/
|
|
105
105
|
| "contract-version"
|
|
106
106
|
/**
|
|
107
|
-
* A prop declares a `type` this runtime does not know (a newer minor), or
|
|
107
|
+
* A prop declares a `type` this runtime does not know (a newer minor), or is named
|
|
108
108
|
* like a member the element already has (the live `HTMLElement.prototype` chain or a Custom
|
|
109
109
|
* Element callback): the prop is absent, never installed as a property.
|
|
110
110
|
*/
|
|
111
111
|
| "unknown-prop-type"
|
|
112
|
-
/** An attribute's text was refused by its prop type; the prop got its default
|
|
112
|
+
/** An attribute's text was refused by its prop type; the prop got its default. */
|
|
113
113
|
| "invalid-attribute"
|
|
114
|
-
/** A value assigned to a prop's property was refused; the prop got its default
|
|
114
|
+
/** A value assigned to a prop's property was refused; the prop got its default. */
|
|
115
115
|
| "invalid-property"
|
|
116
116
|
/**
|
|
117
|
-
* The `<script type="application/json" data-props>` child
|
|
117
|
+
* The `<script type="application/json" data-props>` child was refused as a whole
|
|
118
118
|
* (prop `*`: too long, too deep, not JSON, not an object) or for one prop (its default).
|
|
119
119
|
*/
|
|
120
120
|
| "invalid-props-script"
|
|
121
121
|
/**
|
|
122
|
-
* An `emit` was not dispatched
|
|
122
|
+
* An `emit` was not dispatched: undeclared name, a detail its schema refuses, or the
|
|
123
123
|
* component is not mounted. The message never carries the refused value.
|
|
124
124
|
*/
|
|
125
125
|
| "event-dropped"
|
|
126
126
|
/**
|
|
127
|
-
* A method of the host page API (`window.taggor
|
|
127
|
+
* A method of the host page API (`window.taggor`) got an argument it cannot use and
|
|
128
128
|
* returned `undefined`; `tag` is `"taggor"`.
|
|
129
129
|
*/
|
|
130
130
|
| "host-api";
|
|
131
|
-
/** A warning for debug mode
|
|
131
|
+
/** A warning for debug mode; the message is plain text, never HTML. */
|
|
132
132
|
export interface RuntimeWarning {
|
|
133
133
|
readonly code: WarningCode;
|
|
134
134
|
readonly tag: string;
|
|
@@ -136,7 +136,7 @@ export interface RuntimeWarning {
|
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
138
138
|
* The diagnostics port of the runtime. Both functions are called inside a `try`, so a throwing
|
|
139
|
-
* implementation never reaches the page. Debug mode
|
|
139
|
+
* implementation never reaches the page. Debug mode wires them to the console
|
|
140
140
|
* (`consoleDiagnostics`); production will send failures to telemetry.
|
|
141
141
|
*/
|
|
142
142
|
export interface RuntimeDiagnostics {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/element/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE,qFAAqF;AACrF,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAEjD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACvD,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,SAAS,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAClD;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,GAAG,SAAS,CAAC;IACvE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/element/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE,qFAAqF;AACrF,eAAO,MAAM,cAA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dist/host/api.d.ts
CHANGED
|
@@ -30,9 +30,9 @@ export declare function createHostApi(options: HostApiOptions): TaggorHostApi;
|
|
|
30
30
|
*
|
|
31
31
|
* Inputs: the API and the global object (default `globalThis`). Output: `true` when installed;
|
|
32
32
|
* `false` when `taggor` already is an own property of the global (the page's own `var taggor`, or
|
|
33
|
-
* another Taggor snippet, which
|
|
34
|
-
* none. Side effects: one writable, configurable, non-enumerable property. Not locked on purpose
|
|
35
|
-
*
|
|
33
|
+
* another Taggor snippet, which may be indexed by version) or the global refuses it. Errors:
|
|
34
|
+
* none. Side effects: one writable, configurable, non-enumerable property. Not locked on purpose:
|
|
35
|
+
* a non-configurable global would make a later classic script of the page
|
|
36
36
|
* that declares `taggor` (`const`, `let`, `class`, `function`) fail with a SyntaxError, and a
|
|
37
37
|
* strict-mode assignment throw, stopping the whole script. The API object itself is frozen.
|
|
38
38
|
*/
|
package/dist/host/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/host/api.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,YAAY,CAAC;AAE/D,uDAAuD;AACvD,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,WAAW,CAAC,OAAO,EAAE,mBAAmB,CAAC,GAAG,SAAS,CAAC;IAC3E,sFAAsF;IACtF,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;IACpD,kGAAkG;IAClG,QAAQ,CAAC,WAAW,CAAC,EAAE,kBAAkB,CAAC;IAC1C,qFAAqF;IACrF,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,kBAAkB,GAAG,qBAAqB,CAAC,CAAC;CAChF;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/host/api.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,YAAY,CAAC;AAE/D,uDAAuD;AACvD,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,WAAW,CAAC,OAAO,EAAE,mBAAmB,CAAC,GAAG,SAAS,CAAC;IAC3E,sFAAsF;IACtF,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;IACpD,kGAAkG;IAClG,QAAQ,CAAC,WAAW,CAAC,EAAE,kBAAkB,CAAC;IAC1C,qFAAqF;IACrF,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,kBAAkB,GAAG,qBAAqB,CAAC,CAAC;CAChF;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa,CAgFpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,EAAE,MAAM,GAAE,MAAmB,GAAG,OAAO,CAavF"}
|
package/dist/host/api.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The host page API
|
|
2
|
+
* The host page API: `createHostApi` builds the frozen `window.taggor` object
|
|
3
3
|
* (`version`, `ready`, `get`, `on`, `components`), and `installHostApi` puts it on the page, the only
|
|
4
4
|
* global Taggor creates.
|
|
5
5
|
*
|
|
6
|
-
* Not part of the runtime bundle (`bundle.test.ts` fences it out): the loader
|
|
6
|
+
* Not part of the runtime bundle (`bundle.test.ts` fences it out): the loader bundles
|
|
7
7
|
* it, so `window.taggor` exists from the snippet's first run, before the runtime is downloaded,
|
|
8
8
|
* and the runtime only pays for its live component registry (`registry.ts`). The loader passes the
|
|
9
9
|
* runtime's `liveComponents` once it imported the runtime (`undefined` before: no component yet) and
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* Every method is total (golden rule 2): it never throws at the page, whatever it is given (a
|
|
13
13
|
* Proxy, a revoked Proxy, a throwing getter, a primitive, a lost `this`); an invalid argument
|
|
14
14
|
* gives `undefined` and a `host-api` warning through the diagnostics port, which only debug mode
|
|
15
|
-
* prints
|
|
15
|
+
* prints. Nothing here touches the page's DOM except the listeners `on` adds.
|
|
16
16
|
*/
|
|
17
17
|
import { CONTRACT_VERSION } from "@taggor/contract/zod-free";
|
|
18
18
|
import { guardDiagnostics, silentDiagnostics } from "../element/diagnostics.js";
|
|
@@ -34,7 +34,7 @@ export function createHostApi(options) {
|
|
|
34
34
|
message: `taggor.${call}: invalid argument, returned undefined`,
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
|
-
/** The info of a live component element still in the document
|
|
37
|
+
/** The info of a live component element still in the document. */
|
|
38
38
|
const connected = (info) => info?.element.isConnected === true ? info : undefined;
|
|
39
39
|
const read = (element) => {
|
|
40
40
|
try {
|
|
@@ -62,8 +62,7 @@ export function createHostApi(options) {
|
|
|
62
62
|
const target = options.document ?? document;
|
|
63
63
|
const type = `${tag}:${event}`;
|
|
64
64
|
// One listener per call, so each subscription stops on its own, even for the same handler.
|
|
65
|
-
// Only events whose origin is a live component element reach the handler
|
|
66
|
-
// A4): page code can still dispatch a forged event on a component element, so the handler
|
|
65
|
+
// Only events whose origin is a live component element reach the handler: page code can still dispatch a forged event on a component element, so the handler
|
|
67
66
|
// checks the `detail` it uses.
|
|
68
67
|
const listener = (dispatched) => {
|
|
69
68
|
let fromComponent = false;
|
|
@@ -96,7 +95,7 @@ export function createHostApi(options) {
|
|
|
96
95
|
const infos = [];
|
|
97
96
|
try {
|
|
98
97
|
for (const reader of options.live()?.values() ?? []) {
|
|
99
|
-
// One reader at a time: a bad entry never hides the others
|
|
98
|
+
// One reader at a time: a bad entry never hides the others.
|
|
100
99
|
try {
|
|
101
100
|
const info = connected(reader());
|
|
102
101
|
if (info !== undefined)
|
|
@@ -119,9 +118,9 @@ export function createHostApi(options) {
|
|
|
119
118
|
*
|
|
120
119
|
* Inputs: the API and the global object (default `globalThis`). Output: `true` when installed;
|
|
121
120
|
* `false` when `taggor` already is an own property of the global (the page's own `var taggor`, or
|
|
122
|
-
* another Taggor snippet, which
|
|
123
|
-
* none. Side effects: one writable, configurable, non-enumerable property. Not locked on purpose
|
|
124
|
-
*
|
|
121
|
+
* another Taggor snippet, which may be indexed by version) or the global refuses it. Errors:
|
|
122
|
+
* none. Side effects: one writable, configurable, non-enumerable property. Not locked on purpose:
|
|
123
|
+
* a non-configurable global would make a later classic script of the page
|
|
125
124
|
* that declares `taggor` (`const`, `let`, `class`, `function`) fail with a SyntaxError, and a
|
|
126
125
|
* strict-mode assignment throw, stopping the whole script. The API object itself is frozen.
|
|
127
126
|
*/
|