@taggor/runtime 0.3.0 → 0.5.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 +4 -4
- package/dist/compat/scope.d.ts +2 -2
- package/dist/element/attributes.d.ts +8 -8
- package/dist/element/attributes.d.ts.map +1 -1
- package/dist/element/attributes.js +7 -7
- 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 +12 -12
- package/dist/element/create-component-element.js +16 -16
- 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 +1 -1
- package/dist/element/error-report.js +3 -3
- 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 +5 -5
- package/dist/element/styles.d.ts.map +1 -1
- package/dist/element/styles.js +4 -4
- 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 +3 -3
- 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 +8 -8
- 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 +3 -3
- 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 +2 -2
- package/dist/loader/page-state.js +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 +4 -5
- package/dist/loader/run.d.ts.map +1 -1
- package/dist/loader/run.js +12 -13
- package/dist/loader/run.js.map +1 -1
- package/dist/loader/script-url.d.ts +5 -5
- package/dist/loader/script-url.js +6 -6
- 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 +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
package/dist/host/registry.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** The page-global key the registry lives under (a symbol: invisible to `Object.keys
|
|
1
|
+
/** The page-global key the registry lives under (a symbol: invisible to `Object.keys`). */
|
|
2
2
|
const KEY = Symbol.for("taggor.live");
|
|
3
3
|
/**
|
|
4
|
-
* The registry of this page
|
|
4
|
+
* The registry of this page: one map shared by every copy of the runtime, so sites on
|
|
5
5
|
* different runtime majors, each importing its own copy, appear in the one `window.taggor`.
|
|
6
6
|
*
|
|
7
7
|
* Output: the map kept on the page's global, created by the first copy; a private map when the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/host/registry.ts"],"names":[],"mappings":"AAkBA,
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/host/registry.ts"],"names":[],"mappings":"AAkBA,2FAA2F;AAC3F,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AAEtC;;;;;;;;GAQG;AACH,SAAS,YAAY;IACnB,MAAM,IAAI,GAAG,UAAqC,CAAC;IACnD,IAAI,CAAC;QACH,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,GAAG,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7E,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,CAAmB,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,GAAG,EAAE,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAmB,YAAY,EAAE,CAAC"}
|
package/dist/host/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Types of the host page API
|
|
2
|
+
* Types of the host page API: what `window.taggor` offers the customer's site
|
|
3
3
|
* (`TaggorHostApi`) and what it says about one component element (`ComponentInfo`).
|
|
4
4
|
*
|
|
5
5
|
* These are the untyped shapes the runtime implements. The per-component declaration files the
|
package/dist/host/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Types of the host page API
|
|
2
|
+
* Types of the host page API: what `window.taggor` offers the customer's site
|
|
3
3
|
* (`TaggorHostApi`) and what it says about one component element (`ComponentInfo`).
|
|
4
4
|
*
|
|
5
5
|
* These are the untyped shapes the runtime implements. The per-component declaration files the
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @taggor/runtime: the browser side of Taggor.
|
|
3
|
-
*
|
|
4
|
-
* The site loader is
|
|
2
|
+
* @taggor/runtime: the browser side of Taggor. The Custom Element
|
|
3
|
+
* wrapper (`./element`) and the host page API (`./host`, `window.taggor`).
|
|
4
|
+
* The site loader is a separate bundle.
|
|
5
5
|
*
|
|
6
6
|
* Importing this module has no side effects (no `customElements.define`, no global, no Preact
|
|
7
7
|
* hook): everything happens when `createComponentElement` is called, and `window.taggor` exists only
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @taggor/runtime: the browser side of Taggor.
|
|
3
|
-
*
|
|
4
|
-
* The site loader is
|
|
2
|
+
* @taggor/runtime: the browser side of Taggor. The Custom Element
|
|
3
|
+
* wrapper (`./element`) and the host page API (`./host`, `window.taggor`).
|
|
4
|
+
* The site loader is a separate bundle.
|
|
5
5
|
*
|
|
6
6
|
* Importing this module has no side effects (no `customElements.define`, no global, no Preact
|
|
7
7
|
* hook): everything happens when `createComponentElement` is called, and `window.taggor` exists only
|
package/dist/loader/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Reads the configuration the edge embeds in the site loader
|
|
2
|
+
* Reads the configuration the edge embeds in the site loader: the site manifest as
|
|
3
3
|
* served (`/m/<siteKey>.json` shape, plus the `servedOn` day) and two origins' worth of URLs.
|
|
4
4
|
* The loader treats it as untrusted-shaped input anyway (golden rule 5): a wrong type, a bundle
|
|
5
5
|
* outside the loader's own origin or a malformed tag drops that entry, never the page.
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* and `liveComponents`); `manifest.components[]` are the `SiteManifestComponent` entries of
|
|
10
10
|
* `@taggor/contract`. No dependency on the contract package here: this file is in the 3 KB gate.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* The embed may also carry `data`: `{ moduleUrl, siteKey, turnstileSiteKey? }`, what a
|
|
13
13
|
* component that declares `data` needs to submit (the lazy data module of `@taggor/component`, the
|
|
14
14
|
* site key, Turnstile's public key). Absent or malformed, such components mount without a transport
|
|
15
15
|
* and their submissions end in the SDK's `unavailable` error.
|
|
@@ -19,16 +19,16 @@ export interface LoaderComponent {
|
|
|
19
19
|
readonly tag: string;
|
|
20
20
|
/** Absolute URL of the immutable bundle, on the loader's own origin. */
|
|
21
21
|
readonly bundleUrl: string;
|
|
22
|
-
/** The `contractVersion` the published manifest names; the runtime gates on it
|
|
22
|
+
/** The `contractVersion` the published manifest names; the runtime gates on it. */
|
|
23
23
|
readonly contractVersion: string;
|
|
24
24
|
/** The content address of the published version, reported by `window.taggor.get`. */
|
|
25
25
|
readonly version: string;
|
|
26
|
-
/** The props the site gives the component
|
|
26
|
+
/** The props the site gives the component, unchecked: the runtime checks each one. */
|
|
27
27
|
readonly defaults: unknown;
|
|
28
|
-
/** The manifest's `loading` as found; only `idle` means something
|
|
28
|
+
/** The manifest's `loading` as found; only `idle` means something. */
|
|
29
29
|
readonly loading: string | undefined;
|
|
30
30
|
}
|
|
31
|
-
/** Where and how components with data reach the edge
|
|
31
|
+
/** Where and how components with data reach the edge, already checked. */
|
|
32
32
|
export interface LoaderData {
|
|
33
33
|
/** Absolute URL of the lazy data module, on the loader's own origin. */
|
|
34
34
|
readonly moduleUrl: string;
|
|
@@ -42,13 +42,13 @@ export interface LoaderData {
|
|
|
42
42
|
export interface LoaderConfig {
|
|
43
43
|
/** Absolute URL of the runtime module, on the loader's own origin. */
|
|
44
44
|
readonly runtimeUrl: string;
|
|
45
|
-
/** The site's public key, when the manifest carries a well-formed one (
|
|
45
|
+
/** The site's public key, when the manifest carries a well-formed one (dedupe key). */
|
|
46
46
|
readonly siteKey: string | undefined;
|
|
47
47
|
/** The ISO day the edge served the manifest, when it stamped one. */
|
|
48
48
|
readonly servedOn: string | undefined;
|
|
49
49
|
/** Active components by tag (the first entry of a tag wins). */
|
|
50
50
|
readonly components: ReadonlyMap<string, LoaderComponent>;
|
|
51
|
-
/** The data module and keys; absent when the embed has none or they are unusable
|
|
51
|
+
/** The data module and keys; absent when the embed has none or they are unusable. */
|
|
52
52
|
readonly data: LoaderData | undefined;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/loader/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAYH,0DAA0D;AAC1D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/loader/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAYH,0DAA0D;AAC1D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,mFAAmF;IACnF,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,qFAAqF;IACrF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,sFAAsF;IACtF,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAED,0EAA0E;AAC1E,MAAM,WAAW,UAAU;IACzB,wEAAwE;IACxE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,wDAAwD;IACxD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/C;AAED,iCAAiC;AACjC,MAAM,WAAW,YAAY;IAC3B,sEAAsE;IACtE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,uFAAuF;IACvF,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,qEAAqE;IACrE,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,gEAAgE;IAChE,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC1D,qFAAqF;IACrF,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;CACvC;AAuCD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,GAAG,SAAS,CA8CvE"}
|
package/dist/loader/config.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Reads the configuration the edge embeds in the site loader
|
|
2
|
+
* Reads the configuration the edge embeds in the site loader: the site manifest as
|
|
3
3
|
* served (`/m/<siteKey>.json` shape, plus the `servedOn` day) and two origins' worth of URLs.
|
|
4
4
|
* The loader treats it as untrusted-shaped input anyway (golden rule 5): a wrong type, a bundle
|
|
5
5
|
* outside the loader's own origin or a malformed tag drops that entry, never the page.
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* and `liveComponents`); `manifest.components[]` are the `SiteManifestComponent` entries of
|
|
10
10
|
* `@taggor/contract`. No dependency on the contract package here: this file is in the 3 KB gate.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* The embed may also carry `data`: `{ moduleUrl, siteKey, turnstileSiteKey? }`, what a
|
|
13
13
|
* component that declares `data` needs to submit (the lazy data module of `@taggor/component`, the
|
|
14
14
|
* site key, Turnstile's public key). Absent or malformed, such components mount without a transport
|
|
15
15
|
* and their submissions end in the SDK's `unavailable` error.
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
const TAG_NAME = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)+$/;
|
|
19
19
|
/**
|
|
20
20
|
* Most components honored: the contract's `SITE_MANIFEST_MAX_COMPONENTS`, the platform ceiling
|
|
21
|
-
* (the highest plan's `componentsPerSite
|
|
21
|
+
* (the highest plan's `componentsPerSite`), not a plan's own limit. Repeated here because
|
|
22
22
|
* the loader cannot import the contract (3 KB gate); a test keeps the two equal.
|
|
23
23
|
*/
|
|
24
24
|
const MAX_COMPONENTS = 800;
|
|
@@ -89,7 +89,7 @@ export function readLoaderConfig(raw) {
|
|
|
89
89
|
continue;
|
|
90
90
|
}
|
|
91
91
|
// Passed on as found: the runtime reads it with `?.[prop]` and checks each value with its
|
|
92
|
-
// prop's type, so a shape that is not an object only means no site values
|
|
92
|
+
// prop's type, so a shape that is not an object only means no site values.
|
|
93
93
|
components.set(tag, {
|
|
94
94
|
tag,
|
|
95
95
|
bundleUrl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/loader/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,iGAAiG;AACjG,MAAM,QAAQ,GAAG,iCAA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AE,UAAU,CAAC;YACpC,UAAU,EAAE,UAAU;YACtB,IAAI,EAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;SAC5B,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/loader/entry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The loader's browser entry
|
|
2
|
+
* The loader's browser entry, the only file of the loader with side effects. It is the
|
|
3
3
|
* body of the script the edge serves at `/s/<siteKey>.js`: `script.ts` wraps the built bundle in a
|
|
4
4
|
* function that receives the embedded configuration as `__TAGGOR_LOADER_CONFIG__`, so the loader
|
|
5
5
|
* creates no global of its own (the only one is `window.taggor`, installed by `startLoader`).
|
|
@@ -16,11 +16,11 @@ try {
|
|
|
16
16
|
// `import()` reads a TrustedScriptURL as its string; the specifier type is string only in TS.
|
|
17
17
|
// (the lint exception is per file, in this workspace's eslint.config.js)
|
|
18
18
|
importModule: (url) => import(/* @vite-ignore */ url),
|
|
19
|
-
//
|
|
19
|
+
// The `taggor` Trusted Types policy for those URLs, where the browser has Trusted Types.
|
|
20
20
|
scriptUrl: createScriptUrls(globalThis.trustedTypes, (message) => {
|
|
21
21
|
console.warn(message);
|
|
22
22
|
},
|
|
23
|
-
//
|
|
23
|
+
// One policy per page, shared by every snippet.
|
|
24
24
|
pageState().policy),
|
|
25
25
|
observe: (callback, target) => {
|
|
26
26
|
const observer = new MutationObserver(callback);
|
package/dist/loader/entry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../../src/loader/entry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAsB,MAAM,iBAAiB,CAAC;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C;QAClB,CAAC;QACD,MAAM,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC;QACtD,KAAK,EAAE,MAAM,YAAY,iBAAiB,IAAI,MAAM,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;KAC7F,CAAC,CAAC;AACL,CAAC;AAAC,MAAM,CAAC;IACP,iBAAiB;AACnB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The lazy data transport
|
|
2
|
+
* The lazy data transport: what the loader hands to a component that declares `data`, so
|
|
3
3
|
* the heavy part (the data module of `@taggor/component`: edge transport, retry, Turnstile client)
|
|
4
4
|
* is downloaded only when the component first submits or tracks, never at page load and never for a
|
|
5
5
|
* page without such a component. The Turnstile script itself is fetched later still, by the data
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The lazy data transport
|
|
2
|
+
* The lazy data transport: what the loader hands to a component that declares `data`, so
|
|
3
3
|
* the heavy part (the data module of `@taggor/component`: edge transport, retry, Turnstile client)
|
|
4
4
|
* is downloaded only when the component first submits or tracks, never at page load and never for a
|
|
5
5
|
* page without such a component. The Turnstile script itself is fetched later still, by the data
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** The built site loader, a script body that reads `__TAGGOR_LOADER_CONFIG__
|
|
1
|
+
/** The built site loader, a script body that reads `__TAGGOR_LOADER_CONFIG__`. */
|
|
2
2
|
export declare const LOADER_CODE: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// Generated by scripts/build-loader.ts
|
|
2
|
-
export const LOADER_CODE = "\"use strict\";(()=>{function N(){let n=new Set,e,t=()=>{},o=new Promise(r=>{t=r}),i=()=>{e?.size===0&&t()};return Object.freeze({expect:r=>{e??=new Set;for(let d of r)n.has(d)||e.add(d);i()},settle:r=>{n.add(r),e?.delete(r),i()},ready:()=>o.then(()=>{})})}var L=Symbol.for(\"taggor.loader\");function M(){return{sites:new Set,tags:new Map,barrier:N(),runtime:void 0,policy:{}}}function $(n){let e=n;return typeof e==\"object\"&&e!==null&&e.sites instanceof Set&&e.tags instanceof Map&&typeof e.barrier==\"object\"&&typeof e.policy==\"object\"}function _(n=globalThis){try{let e=n[L];if($(e))return e;let t=M();return Object.defineProperty(n,L,{value:t,configurable:!0}),t}catch{return M()}}function P(n,e){return e===void 0?!0:n.sites.has(e)?!1:(n.sites.add(e),!0)}function I(n,e,t,o){let i=`${o??\"\"}\n${t}`,r=n.tags.get(e);return r===void 0?(n.tags.set(e,i),\"mine\"):r===i?\"same\":\"other\"}var R=`${String(1)}.${String(
|
|
1
|
+
// Generated by scripts/build-loader.ts; do not edit.
|
|
2
|
+
export const LOADER_CODE = "\"use strict\";(()=>{function N(){let n=new Set,e,t=()=>{},o=new Promise(r=>{t=r}),i=()=>{e?.size===0&&t()};return Object.freeze({expect:r=>{e??=new Set;for(let d of r)n.has(d)||e.add(d);i()},settle:r=>{n.add(r),e?.delete(r),i()},ready:()=>o.then(()=>{})})}var L=Symbol.for(\"taggor.loader\");function M(){return{sites:new Set,tags:new Map,barrier:N(),runtime:void 0,policy:{}}}function $(n){let e=n;return typeof e==\"object\"&&e!==null&&e.sites instanceof Set&&e.tags instanceof Map&&typeof e.barrier==\"object\"&&typeof e.policy==\"object\"}function _(n=globalThis){try{let e=n[L];if($(e))return e;let t=M();return Object.defineProperty(n,L,{value:t,configurable:!0}),t}catch{return M()}}function P(n,e){return e===void 0?!0:n.sites.has(e)?!1:(n.sites.add(e),!0)}function I(n,e,t,o){let i=`${o??\"\"}\n${t}`,r=n.tags.get(e);return r===void 0?(n.tags.set(e,i),\"mine\"):r===i?\"same\":\"other\"}var R=`${String(1)}.${String(12)}.0`;var H=Object.freeze({major:1,minor:12,majors:Object.freeze([Object.freeze({major:1})])}),E=\"(0|[1-9]\\\\d{0,5})\",ee=new RegExp(`^${E}\\\\.${E}\\\\.${E}$`);var b=Object.freeze({warn:()=>{},reportError:()=>{}});function h(n){return Object.freeze({warn:e=>{try{n.warn(e)}catch{}},reportError:e=>{try{n.reportError(e)}catch{}}})}function U(n){let e=h(n.diagnostics??b),t=r=>{e.warn({code:\"host-api\",tag:\"taggor\",message:`taggor.${r}: invalid argument, returned undefined`})},o=r=>r?.element.isConnected===!0?r:void 0,i=r=>{try{return o(n.live()?.get(r)?.())}catch{return}};return Object.freeze({version:R,ready:()=>n.barrier.ready(),get:r=>{let d=i(r);return d===void 0&&t(\"get\"),d},on:(r,d,s)=>{if(typeof r!=\"string\"||typeof d!=\"string\"||typeof s!=\"function\"){t(\"on\");return}try{let a=n.document??document,p=`${r}:${d}`,g=f=>{let T=!1;try{T=i(f.composedPath()[0])!==void 0}catch{}T&&s(f)};return a.addEventListener(p,g,!0),()=>{try{a.removeEventListener(p,g,!0)}catch{}}}catch{t(\"on\");return}},components:()=>{let r=[];try{for(let d of n.live()?.values()??[])try{let s=o(d());s!==void 0&&r.push(s)}catch{}}catch{}return Object.freeze(r)}})}function w(n,e=globalThis){try{return Object.hasOwn(e,\"taggor\")?!1:(Object.defineProperty(e,\"taggor\",{value:n,writable:!0,configurable:!0,enumerable:!1}),!0)}catch{return!1}}var F=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)+$/;function A(n,e){if(!(typeof n!=\"string\"||n.length>2048))try{let t=new URL(n,e);return t.origin===e&&t.protocol.startsWith(\"http\")?t.href:void 0}catch{return}}function u(n,e){let t=n?.[e];return typeof t==\"string\"?t:void 0}var O=/^[A-Za-z0-9_-]{1,100}$/;function G(n,e){let t=n?.data,o=A(u(t,\"moduleUrl\"),e),i=u(t,\"siteKey\"),r=u(t,\"turnstileSiteKey\");if(!(o===void 0||i===void 0||!O.test(i)))return{moduleUrl:o,baseUrl:e,siteKey:i,turnstileSiteKey:r!==void 0&&O.test(r)?r:void 0}}function v(n){try{let e=new URL(u(n,\"origin\")??\"\").origin,t=A(u(n,\"runtimeUrl\"),e),o=n.manifest,i=o?.components;if(t===void 0||!Array.isArray(i))return;let r=new Map;for(let s of i.slice(0,800)){let a=u(s,\"tag\"),p=A(u(s,\"bundleUrl\"),e),g=u(s,\"contractVersion\"),f=u(s,\"versionHash\");a===void 0||!F.test(a)||r.has(a)||u(s,\"status\")!==\"active\"||p===void 0||g===void 0||f===void 0||r.set(a,{tag:a,bundleUrl:p,contractVersion:g,version:f,defaults:s.defaults,loading:u(s,\"loading\")})}let d=u(o,\"siteKey\");return{runtimeUrl:t,siteKey:d!==void 0&&O.test(d)?d:void 0,servedOn:u(o,\"servedOn\"),components:r,data:G(n,e)}}catch{return}}var x=Object.freeze({ok:!1,code:\"network_error\",fields:Object.freeze([])});function D(n){let e,t=()=>{let o=e??=n();return o.catch(()=>{e===o&&(e=void 0)}),o};return{submit:(o,i,r)=>{try{return t().then(d=>d.submit(o,i,r),()=>x)}catch{return Promise.resolve(x)}},track:o=>{try{t().then(i=>{i.track(o)}).catch(()=>{})}catch{}}}}function k(n,e){let t=o=>new Promise((i,r)=>{let d=e.setTimeout(()=>{r(new Error(\"timeout\"))},1e4),s=()=>{e.clearTimeout(d)};n(o).then(a=>{s(),i(a)},a=>{s(),r(a instanceof Error?a:new Error(\"import failed\"))})});return o=>t(o).catch(()=>new Promise(i=>e.setTimeout(i,1e3)).then(()=>t(o)))}var z={setTimeout:(n,e)=>setTimeout(n,e),clearTimeout:n=>{clearTimeout(n)}};function B(n){return n?.default??void 0}function Y(n,e,t){return D(async()=>(await e(n.moduleUrl)).createDataTransport({baseUrl:n.baseUrl,siteKey:n.siteKey,turnstileSiteKey:n.turnstileSiteKey,nonce:t.nonce,scriptUrl:t.scriptUrl}))}function W(n,e){try{n?.warn({code:\"tag-collision\",tag:e,message:`<${e}> is already loaded by another snippet; the first stays.`})}catch{}}function X(n,e){let t=n?.manifest;return t?.tag===e.tag&&(t.contractVersion===void 0||t.contractVersion===e.contractVersion)}function j(n,e){try{let t={...e,importModule:k(e.importModule,e.timers??z)},o=_(t.target),{barrier:i}=o;w(U({live:()=>o.runtime?.liveComponents,barrier:i,...t.diagnostics===void 0?{}:{diagnostics:t.diagnostics}}),t.target);let r=v(n);if(r===void 0){o.sites.size===0&&i.expect([]);return}if(!P(o,r.siteKey))return;let d=e.scriptUrl??(c=>c),s=async c=>t.importModule(d(c,new URL(r.runtimeUrl).origin)),a=new Map(r.components),p,g=()=>p??=s(r.runtimeUrl).then(c=>(o.runtime=c,o.runtime)),f=async c=>{try{c.loading===\"idle\"&&await s(new URL(\"loading.js\",r.runtimeUrl).href).then(S=>S.idle(),()=>{});let[y,l]=await Promise.all([g(),s(c.bundleUrl)]),m=B(l);m!==void 0&&X(m,c)&&(y.createComponentElement(m,{contractVersion:c.contractVersion,version:c.version,origin:r.runtimeUrl,siteDefaults:c.defaults,...r.servedOn===void 0?{}:{servedOn:r.servedOn},...t.diagnostics===void 0?{}:{diagnostics:t.diagnostics},...t.nonce?{styleNonce:t.nonce}:{},...r.data!==void 0?{transport:Y(r.data,s,t)}:{}}),r.siteKey&&t.beacon?.(new URL(`/e/${r.siteKey}`,r.runtimeUrl),c.version))}catch{}finally{i.settle(c.tag)}},T=()=>{let c=[];if(a.size===0)return c;let y=t.document.querySelectorAll([...a.keys()].join(\",\"));for(let l of y){let m=a.get(l.localName);if(m===void 0)continue;a.delete(l.localName);let S=I(o,m.tag,m.version,r.siteKey);S===\"mine\"?c.push(m):S===\"other\"&&W(t.diagnostics,m.tag)}return c},C=()=>{try{let c=T();i.expect(c.map(l=>l.tag));for(let l of c)f(l);if(a.size===0)return;let y=t.observe(()=>{try{for(let l of T())f(l);a.size===0&&y.disconnect()}catch{}},t.document.documentElement)}catch{i.expect([])}};t.document.readyState===\"loading\"?t.document.addEventListener(\"DOMContentLoaded\",C,{once:!0}):C()}catch{}}var J=\"https://challenges.cloudflare.com\";function K(n,e){let t=new URL(n);if(t.origin!==e||!t.protocol.startsWith(\"http\"))throw new TypeError(\"module URL outside the loader origin\");return t.href}function V(n,e,t={}){return(o,i)=>{let r=K(o,i);if(t.tried!==!0&&n!==void 0){t.tried=!0;try{let d=[i,J];t.policy=n.createPolicy(\"taggor\",{createScriptURL:s=>{let{origin:a}=new URL(s);return K(s,d.includes(a)?a:\"\")}})}catch{e(\"Taggor: the page's trusted-types directive does not list 'taggor'; loading without it.\")}}if(t.policy===void 0)return r;try{return t.policy.createScriptURL(r,i)}catch{return r}}}try{let n=document.currentScript;j(__TAGGOR_LOADER_CONFIG__,{document,importModule:e=>import(e),scriptUrl:V(globalThis.trustedTypes,e=>{console.warn(e)},_().policy),observe:(e,t)=>{let o=new MutationObserver(e);return o.observe(t,{childList:!0,subtree:!0}),o},beacon:(e,t)=>navigator.sendBeacon(e,t),nonce:n instanceof HTMLScriptElement&&n.nonce!==\"\"?n.nonce:void 0})}catch{}})();";
|
package/dist/loader/loading.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The lazy `loading.js` module of the runtime release
|
|
2
|
+
* The lazy `loading.js` module of the runtime release: the waiting a component
|
|
3
3
|
* with `loading: "idle"` does before the loader imports its bundle. It is fetched only by a page
|
|
4
4
|
* that has such a component, so its bytes count against neither the loader nor the runtime budget.
|
|
5
5
|
* Built by `scripts/runtime-release/build.ts` into `rt/<version>/loading.js` (self-contained, no import).
|
package/dist/loader/loading.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The lazy `loading.js` module of the runtime release
|
|
2
|
+
* The lazy `loading.js` module of the runtime release: the waiting a component
|
|
3
3
|
* with `loading: "idle"` does before the loader imports its bundle. It is fetched only by a page
|
|
4
4
|
* that has such a component, so its bytes count against neither the loader nor the runtime budget.
|
|
5
5
|
* Built by `scripts/runtime-release/build.ts` into `rt/<version>/loading.js` (self-contained, no import).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* What every loader on one page shares
|
|
2
|
+
* What every loader on one page shares. A host page can run the snippet more than once
|
|
3
3
|
* (a cache plugin that duplicates scripts, a theme that injects it twice) and can carry the
|
|
4
4
|
* snippets of two sites (two agencies). Each run is a separate closure of the same code, so the
|
|
5
5
|
* runs meet in one record kept on the page's global under `Symbol.for("taggor.loader")`: a symbol
|
|
@@ -59,7 +59,7 @@ export type TagClaim = "mine" | "same" | "other";
|
|
|
59
59
|
* the first definition wins and the caller warns). Another site is never "same", even at the same
|
|
60
60
|
* version: its component would reuse the first site's definition and data transport, so its
|
|
61
61
|
* visitors' submissions would go to the first site's workspace. That is the page-level tag
|
|
62
|
-
* collision
|
|
62
|
+
* collision and cannot be fixed on the client; the warning makes it visible.
|
|
63
63
|
* Errors: none. Side effects: records the first claim.
|
|
64
64
|
*/
|
|
65
65
|
export declare function claimTag(state: PageState, tag: string, version: string, siteKey: string | undefined): TagClaim;
|
|
@@ -58,7 +58,7 @@ export function claimSite(state, siteKey) {
|
|
|
58
58
|
* the first definition wins and the caller warns). Another site is never "same", even at the same
|
|
59
59
|
* version: its component would reuse the first site's definition and data transport, so its
|
|
60
60
|
* visitors' submissions would go to the first site's workspace. That is the page-level tag
|
|
61
|
-
* collision
|
|
61
|
+
* collision and cannot be fixed on the client; the warning makes it visible.
|
|
62
62
|
* Errors: none. Side effects: records the first claim.
|
|
63
63
|
*/
|
|
64
64
|
export function claimTag(state, tag, version, siteKey) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The time limit and the single retry around the loader's module imports
|
|
2
|
+
* The time limit and the single retry around the loader's module imports. A dynamic
|
|
3
3
|
* `import()` cannot be aborted and a hung CDN connection never settles it, so each attempt races a
|
|
4
4
|
* timer; a failure is tried once more after a short backoff. The retry only refetches on a
|
|
5
5
|
* network or HTTP failure (404, 5xx, refused); a hung connection re-enters the same module map
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* handles; nothing here reaches the host page.
|
|
9
9
|
*/
|
|
10
10
|
import type { TrustedScriptUrl } from "./script-url.js";
|
|
11
|
-
/** What `import()` takes: a plain URL or, under Trusted Types, a `TrustedScriptURL
|
|
11
|
+
/** What `import()` takes: a plain URL or, under Trusted Types, a `TrustedScriptURL`. */
|
|
12
12
|
export type ModuleUrl = string | TrustedScriptUrl;
|
|
13
13
|
/** How long one attempt may take before it is abandoned. */
|
|
14
14
|
export declare const IMPORT_TIMEOUT_MS = 10000;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resilient-import.d.ts","sourceRoot":"","sources":["../../src/loader/resilient-import.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,
|
|
1
|
+
{"version":3,"file":"resilient-import.d.ts","sourceRoot":"","sources":["../../src/loader/resilient-import.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,wFAAwF;AACxF,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,gBAAgB,CAAC;AAElD,4DAA4D;AAC5D,eAAO,MAAM,iBAAiB,QAAS,CAAC;AAExC,6DAA6D;AAC7D,eAAO,MAAM,gBAAgB,OAAQ,CAAC;AAEtC,kFAAkF;AAClF,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;IACnE,QAAQ,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,KAAK,KAAK,IAAI,CAAC;CAChD;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,OAAO,CAAC,OAAO,CAAC,EAClD,MAAM,EAAE,MAAM,GACb,CAAC,GAAG,EAAE,SAAS,KAAK,OAAO,CAAC,OAAO,CAAC,CA2BtC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The time limit and the single retry around the loader's module imports
|
|
2
|
+
* The time limit and the single retry around the loader's module imports. A dynamic
|
|
3
3
|
* `import()` cannot be aborted and a hung CDN connection never settles it, so each attempt races a
|
|
4
4
|
* timer; a failure is tried once more after a short backoff. The retry only refetches on a
|
|
5
5
|
* network or HTTP failure (404, 5xx, refused); a hung connection re-enters the same module map
|
package/dist/loader/run.d.ts
CHANGED
|
@@ -10,8 +10,7 @@ export interface LoaderPorts {
|
|
|
10
10
|
/** `import(url)`; rejects when the module does not load. */
|
|
11
11
|
readonly importModule: (url: ModuleUrl) => Promise<unknown>;
|
|
12
12
|
/**
|
|
13
|
-
* Turns a module URL into what `importModule` receives, given the delivery origin (
|
|
14
|
-
* the `taggor` Trusted Types policy of `script-url.ts`). Throws for a URL outside the origin,
|
|
13
|
+
* Turns a module URL into what `importModule` receives, given the delivery origin (the `taggor` Trusted Types policy of `script-url.ts`). Throws for a URL outside the origin,
|
|
15
14
|
* which skips that module. Default: the URL itself.
|
|
16
15
|
*/
|
|
17
16
|
readonly scriptUrl?: (url: string, origin: string) => string | TrustedScriptUrl;
|
|
@@ -19,18 +18,18 @@ export interface LoaderPorts {
|
|
|
19
18
|
readonly observe: (callback: () => void, target: Node) => {
|
|
20
19
|
disconnect(): void;
|
|
21
20
|
};
|
|
22
|
-
/** Where warnings go (default: silent; debug mode
|
|
21
|
+
/** Where warnings go (default: silent; debug mode passes the console). */
|
|
23
22
|
readonly diagnostics?: RuntimeDiagnostics | undefined;
|
|
24
23
|
/** The page's CSP nonce, read from the loader's own script tag. */
|
|
25
24
|
readonly nonce?: string | undefined;
|
|
26
25
|
/** Where `window.taggor` is installed (default `globalThis`). */
|
|
27
26
|
readonly target?: object;
|
|
28
27
|
/**
|
|
29
|
-
* Sends the render signal of a mounted component
|
|
28
|
+
* Sends the render signal of a mounted component: `navigator.sendBeacon` in the
|
|
30
29
|
* browser. Absent: nothing is sent.
|
|
31
30
|
*/
|
|
32
31
|
readonly beacon?: (url: URL, body: string) => void;
|
|
33
|
-
/** The timers of the download time limit and retry backoff (
|
|
32
|
+
/** The timers of the download time limit and retry backoff (default the page's). */
|
|
34
33
|
readonly timers?: Timers;
|
|
35
34
|
}
|
|
36
35
|
/**
|
package/dist/loader/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/loader/run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/loader/run.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAsB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGlF,OAAO,EAAmB,KAAK,SAAS,EAAE,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAErF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,4DAA4D;AAC5D,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,YAAY,GAAG,kBAAkB,GAAG,kBAAkB,CAAC,GAAG;QAC1F,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC;KAChC,CAAC;IACF,4DAA4D;IAC5D,QAAQ,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5D;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,gBAAgB,CAAC;IAChF,oCAAoC;IACpC,QAAQ,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,MAAM,EAAE,IAAI,KAAK;QAAE,UAAU,IAAI,IAAI,CAAA;KAAE,CAAC;IACjF,0EAA0E;IAC1E,QAAQ,CAAC,WAAW,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACtD,mEAAmE;IACnE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,iEAAiE;IACjE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,oFAAoF;IACpF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAwED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,IAAI,CAsHrE"}
|
package/dist/loader/run.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The site loader's logic
|
|
2
|
+
* The site loader's logic: what runs on the host page when `/s/<siteKey>.js` is
|
|
3
3
|
* executed. Written against injected ports (`LoaderPorts`) so it is tested in happy-dom without a
|
|
4
4
|
* network; `entry.ts` wires the browser's own.
|
|
5
5
|
*
|
|
6
|
-
* Order of events: install `window.taggor` at once (it exists before anything is downloaded
|
|
7
|
-
*
|
|
8
|
-
* Firefox import map bug of docs/testing/compatibility.md §4.1); look in the DOM for the tags of
|
|
6
|
+
* Order of events: install `window.taggor` at once (it exists before anything is downloaded); wait for the parser to finish (no `import()` while the document is still loading: the
|
|
7
|
+
* Firefox import map bug); look in the DOM for the tags of
|
|
9
8
|
* the manifest only; download the runtime once and the bundle of each present tag only; register
|
|
10
9
|
* it with `createComponentElement`; keep one `MutationObserver` for tags a single-page app inserts
|
|
11
10
|
* later, until every tag of the manifest was handled.
|
|
12
11
|
*
|
|
13
|
-
*
|
|
12
|
+
* A component whose manifest declares `data` gets a lazy data transport (`lazy-transport.ts`)
|
|
14
13
|
* as `host.transport`; the data module is imported on its first submission, not before.
|
|
15
14
|
*
|
|
16
|
-
*
|
|
15
|
+
* Every import has a 10 s limit and one retry after a backoff (`resilient-import.ts`); a
|
|
17
16
|
* component whose bundle never arrives, answers an error or throws on evaluation is skipped, its tag
|
|
18
17
|
* stays as the page wrote it (the fallback), and the other components are not affected.
|
|
19
18
|
*
|
|
20
|
-
*
|
|
19
|
+
* Once a component is registered the loader reports it with one `beacon` (`sendBeacon` to
|
|
21
20
|
* `/e/<siteKey>` of the delivery origin, body: the published version hash), the browser half of the
|
|
22
21
|
* render count; the edge ingest is `apps/edge` `ingest-event.ts`.
|
|
23
22
|
*
|
|
@@ -32,7 +31,7 @@ import { resilientImport } from "./resilient-import.js";
|
|
|
32
31
|
import { claimSite, claimTag, pageState } from "./page-state.js";
|
|
33
32
|
/**
|
|
34
33
|
* The page's own timers, wrapped: `setTimeout` and `clearTimeout` throw "Illegal invocation" in a
|
|
35
|
-
* browser when called as methods of another object (found by the
|
|
34
|
+
* browser when called as methods of another object (found by the chaos suite).
|
|
36
35
|
*/
|
|
37
36
|
const pageTimers = {
|
|
38
37
|
setTimeout: (callback, ms) => setTimeout(callback, ms),
|
|
@@ -53,7 +52,7 @@ function dataTransport(data, importModule, csp) {
|
|
|
53
52
|
baseUrl: data.baseUrl,
|
|
54
53
|
siteKey: data.siteKey,
|
|
55
54
|
turnstileSiteKey: data.turnstileSiteKey,
|
|
56
|
-
//
|
|
55
|
+
// The Turnstile script the data module injects needs the nonce and a trusted URL.
|
|
57
56
|
nonce: csp.nonce,
|
|
58
57
|
scriptUrl: csp.scriptUrl,
|
|
59
58
|
});
|
|
@@ -73,7 +72,7 @@ function warnConflict(diagnostics, tag) {
|
|
|
73
72
|
}
|
|
74
73
|
}
|
|
75
74
|
/**
|
|
76
|
-
* Whether a bundle's own manifest agrees with the published one (
|
|
75
|
+
* Whether a bundle's own manifest agrees with the published one (the extracted manifest
|
|
77
76
|
* describes the Node branch, which can differ from the browser's). The published manifest names
|
|
78
77
|
* the tag and the contract version; any other tag or version is a divergence and the component is not
|
|
79
78
|
* registered. Props and events are not compared: the published manifest does not carry them yet.
|
|
@@ -97,7 +96,7 @@ export function startLoader(raw, rawPorts) {
|
|
|
97
96
|
...rawPorts,
|
|
98
97
|
importModule: resilientImport(rawPorts.importModule, rawPorts.timers ?? pageTimers),
|
|
99
98
|
};
|
|
100
|
-
//
|
|
99
|
+
// Shared by every loader of the page, so `window.taggor` covers all sites.
|
|
101
100
|
const state = pageState(ports.target);
|
|
102
101
|
const { barrier } = state;
|
|
103
102
|
installHostApi(createHostApi({
|
|
@@ -112,7 +111,7 @@ export function startLoader(raw, rawPorts) {
|
|
|
112
111
|
barrier.expect([]);
|
|
113
112
|
return;
|
|
114
113
|
}
|
|
115
|
-
//
|
|
114
|
+
// The same site's snippet again (cache plugin, theme) does nothing.
|
|
116
115
|
if (!claimSite(state, config.siteKey))
|
|
117
116
|
return;
|
|
118
117
|
const toUrl = rawPorts.scriptUrl ?? ((url) => url);
|
|
@@ -126,7 +125,7 @@ export function startLoader(raw, rawPorts) {
|
|
|
126
125
|
}));
|
|
127
126
|
const mount = async (entry) => {
|
|
128
127
|
try {
|
|
129
|
-
//
|
|
128
|
+
// `idle` waits in the lazy `loading.js`; a release without it (an older ring) or a
|
|
130
129
|
// failed download means "eager", never a skipped component.
|
|
131
130
|
if (entry.loading === "idle") {
|
|
132
131
|
await importUrl(new URL("loading.js", config.runtimeUrl).href).then((module) => module.idle(), () => undefined);
|
package/dist/loader/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/loader/run.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/loader/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EAAE,g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AC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;gBAClD,KAAK,MAAM,KAAK,IAAI,OAAO;oBAAE,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC;gBAC/C,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC;oBAAE,OAAO;gBAC/B,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;oBAClC,IAAI,CAAC;wBACH,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE;4BAAE,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC;wBAC9C,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC;4BAAE,QAAQ,CAAC,UAAU,EAAE,CAAC;oBAChD,CAAC;oBAAC,MAAM,CAAC;wBACP,iDAAiD;oBACnD,CAAC;gBACH,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;YACrC,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACrB,CAAC;QACH,CAAC,CAAC;QAEF,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YAC5C,KAAK,CAAC,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7E,CAAC;aAAM,CAAC;YACN,KAAK,EAAE,CAAC;QACV,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,4DAA4D;IAC9D,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The loader's Trusted Types policy for `import()` URLs
|
|
2
|
+
* The loader's Trusted Types policy for `import()` URLs. A page that sends
|
|
3
3
|
* `require-trusted-types-for 'script'` may also list the policies it allows (`trusted-types
|
|
4
4
|
* taggor`); the loader owns exactly one, named `taggor`, and uses it for nothing but the URLs it
|
|
5
5
|
* passes to `import()`. It never creates a `default` policy (that would reroute the host page's
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
* that lists `trusted-types taggor` for it.
|
|
11
11
|
*
|
|
12
12
|
* Golden rule 2: when the page's CSP does not list `taggor`, `createPolicy` throws; the loader
|
|
13
|
-
* catches it, warns once on the console and imports the checked string (documented fallback
|
|
14
|
-
*
|
|
15
|
-
* 5 B under its ceiling
|
|
13
|
+
* catches it, warns once on the console and imports the checked string (documented fallback).
|
|
14
|
+
* Lives in the loader, not the runtime: the runtime bundle is
|
|
15
|
+
* 5 B under its ceiling, the loader has room.
|
|
16
16
|
*/
|
|
17
17
|
/** What `createScriptURL` returns: a `TrustedScriptURL`, which `import()` reads as its string. */
|
|
18
18
|
export interface TrustedScriptUrl {
|
|
@@ -27,7 +27,7 @@ export interface PolicyFactory {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
* What the loaders of one page share about the policy
|
|
30
|
+
* What the loaders of one page share about the policy: `createPolicy("taggor")` a
|
|
31
31
|
* second time throws on a page whose `trusted-types` lacks `'allow-duplicates'`, so the second
|
|
32
32
|
* snippet reuses the first one's policy (or its refusal, without warning again).
|
|
33
33
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The loader's Trusted Types policy for `import()` URLs
|
|
2
|
+
* The loader's Trusted Types policy for `import()` URLs. A page that sends
|
|
3
3
|
* `require-trusted-types-for 'script'` may also list the policies it allows (`trusted-types
|
|
4
4
|
* taggor`); the loader owns exactly one, named `taggor`, and uses it for nothing but the URLs it
|
|
5
5
|
* passes to `import()`. It never creates a `default` policy (that would reroute the host page's
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
* that lists `trusted-types taggor` for it.
|
|
11
11
|
*
|
|
12
12
|
* Golden rule 2: when the page's CSP does not list `taggor`, `createPolicy` throws; the loader
|
|
13
|
-
* catches it, warns once on the console and imports the checked string (documented fallback
|
|
14
|
-
*
|
|
15
|
-
* 5 B under its ceiling
|
|
13
|
+
* catches it, warns once on the console and imports the checked string (documented fallback).
|
|
14
|
+
* Lives in the loader, not the runtime: the runtime bundle is
|
|
15
|
+
* 5 B under its ceiling, the loader has room.
|
|
16
16
|
*/
|
|
17
|
-
/** Origins the Turnstile script may come from (the data module passes its origin
|
|
17
|
+
/** Origins the Turnstile script may come from (the data module passes its origin). */
|
|
18
18
|
const TURNSTILE_ORIGIN = "https://challenges.cloudflare.com";
|
|
19
19
|
/** `url` when it is http(s) on `origin`; otherwise throws. */
|
|
20
20
|
function checkedUrl(url, origin) {
|
|
@@ -41,7 +41,7 @@ export function createScriptUrls(factory, warn, state = {}) {
|
|
|
41
41
|
if (state.tried !== true && factory !== undefined) {
|
|
42
42
|
state.tried = true;
|
|
43
43
|
try {
|
|
44
|
-
// L1
|
|
44
|
+
// L1: the accepted origins are pinned here, in the closure; the origin a
|
|
45
45
|
// caller passes to `createScriptURL` is ignored, so a page script that reaches the shared
|
|
46
46
|
// policy cannot mint a TrustedScriptURL for another origin.
|
|
47
47
|
const allowed = [origin, TURNSTILE_ORIGIN];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script-url.js","sourceRoot":"","sources":["../../src/loader/script-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAyBH
|
|
1
|
+
{"version":3,"file":"script-url.js","sourceRoot":"","sources":["../../src/loader/script-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAyBH,sFAAsF;AACtF,MAAM,gBAAgB,GAAG,mCAAmC,CAAC;AAE7D,8DAA8D;AAC9D,SAAS,UAAU,CAAC,GAAW,EAAE,MAAc;IAC7C,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ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;QACvD,CAAC;QAAC,MAAM,CAAC;YACP,2FAA2F;YAC3F,4FAA4F;YAC5F,OAAO,OAAO,CAAC;QACjB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/loader/script.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Builds the text of `/s/<siteKey>.js
|
|
2
|
+
* Builds the text of `/s/<siteKey>.js`: the built loader code with the site's
|
|
3
3
|
* configuration embedded. Pure string work, safe to import in a Worker; the loader code itself
|
|
4
4
|
* comes from `dist/loader-code.js` (`scripts/build-loader.ts`), exported as `LOADER_CODE` by
|
|
5
5
|
* `@taggor/runtime/loader-script`.
|
|
@@ -21,7 +21,7 @@ export declare function scriptJson(value: unknown): string;
|
|
|
21
21
|
* as markup if the file is ever inlined. Errors: `TypeError` when the configuration is not
|
|
22
22
|
* serializable. Side effects: none.
|
|
23
23
|
*
|
|
24
|
-
* `prepare` (
|
|
24
|
+
* `prepare` (optional): the source of a function expression the SERVER wrote, called in
|
|
25
25
|
* the browser with the configuration object before the loader reads it (the edge's domain gate,
|
|
26
26
|
* which empties the components on a hostname outside the allowed domains). It must return the
|
|
27
27
|
* configuration; it is never built from request data. The loader bundle does not contain this file,
|