@taggor/component 0.4.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/assets.d.ts +2 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/assets.d.ts +2 -2
- package/dist/assets.js +2 -2
- package/dist/bounded-json.d.ts +3 -3
- package/dist/bounded-json.js +3 -3
- package/dist/build/check-messages.js +3 -3
- package/dist/build/check-messages.js.map +1 -1
- package/dist/build/extract-manifest.d.ts +5 -5
- package/dist/build/extract-manifest.d.ts.map +1 -1
- package/dist/build/extract-manifest.js +4 -4
- package/dist/build/extract-styles.js +2 -2
- package/dist/build/find-definition.d.ts +2 -2
- package/dist/build/find-definition.js +2 -2
- package/dist/build/index.d.ts +3 -3
- package/dist/build/index.js +3 -3
- package/dist/consent.d.ts +8 -9
- package/dist/consent.d.ts.map +1 -1
- package/dist/consent.js +6 -7
- package/dist/consent.js.map +1 -1
- package/dist/data-client.d.ts +2 -2
- package/dist/data-client.d.ts.map +1 -1
- package/dist/data-declaration.d.ts +1 -1
- package/dist/data-errors.d.ts +2 -2
- package/dist/data-errors.js +3 -3
- package/dist/data-errors.js.map +1 -1
- package/dist/data-transport.d.ts +5 -5
- package/dist/data-transport.d.ts.map +1 -1
- package/dist/debug.d.ts +2 -2
- package/dist/define-component.d.ts +19 -20
- package/dist/define-component.d.ts.map +1 -1
- package/dist/define-component.js +10 -10
- package/dist/define-component.js.map +1 -1
- package/dist/define-library.d.ts +1 -1
- package/dist/define-library.d.ts.map +1 -1
- package/dist/edge-transport.d.ts +1 -1
- package/dist/edge-transport.d.ts.map +1 -1
- package/dist/edge-transport.js +2 -2
- package/dist/edge-transport.js.map +1 -1
- package/dist/events.d.ts +6 -7
- package/dist/events.d.ts.map +1 -1
- package/dist/form-field.d.ts +1 -1
- package/dist/form-field.js +1 -1
- package/dist/host.d.ts +5 -5
- package/dist/host.js +3 -3
- package/dist/index.d.ts +13 -13
- package/dist/index.js +13 -13
- package/dist/intl-format.d.ts +3 -3
- package/dist/intl-format.js +3 -3
- package/dist/issued-proofs.d.ts +3 -3
- package/dist/issued-proofs.js +3 -3
- package/dist/locale.js +1 -1
- package/dist/memory-transport.d.ts +3 -3
- package/dist/messages.js +1 -1
- package/dist/none.d.ts +1 -1
- package/dist/none.js +1 -1
- package/dist/props.d.ts +6 -6
- package/dist/slots.js +2 -2
- package/dist/submit-result.js +1 -1
- package/dist/testing/form-internals.d.ts +2 -2
- package/dist/testing/form-internals.js +2 -2
- package/dist/testing/index.d.ts +3 -3
- package/dist/testing/index.js +3 -3
- package/dist/testing/mount-component.d.ts +7 -7
- package/dist/testing/mount-component.d.ts.map +1 -1
- package/dist/testing/mount-component.js +17 -17
- package/dist/testing/mount-component.js.map +1 -1
- package/dist/testing/visitor.d.ts +1 -1
- package/dist/testing/visitor.js +1 -1
- package/dist/theming.d.ts +1 -1
- package/dist/turnstile.d.ts +8 -8
- package/dist/turnstile.js +8 -8
- package/dist/turnstile.js.map +1 -1
- package/dist/use-font.d.ts +1 -1
- package/dist/use-font.d.ts.map +1 -1
- package/dist/use-font.js +4 -5
- package/dist/use-font.js.map +1 -1
- package/dist/use-locale.js +1 -1
- package/dist/use-taggor-data.d.ts +6 -6
- package/dist/use-taggor-data.js +11 -11
- package/dist/use-taggor-data.js.map +1 -1
- package/dist/use-track.d.ts +1 -1
- package/dist/use-track.js +1 -1
- package/dist/value-types.d.ts +5 -5
- package/dist/value-types.js +3 -3
- package/dist/visitor-action.d.ts +5 -5
- package/dist/visitor-action.d.ts.map +1 -1
- package/dist/visitor-action.js +6 -7
- package/dist/visitor-action.js.map +1 -1
- package/package.json +3 -3
package/dist/host.d.ts
CHANGED
|
@@ -5,17 +5,17 @@ import type { DataTransport } from "./data-transport.js";
|
|
|
5
5
|
* - `element`: the custom element on the host page (its light DOM holds the slotted content).
|
|
6
6
|
* - `shadowRoot`: the component's own open shadow root, where the component renders.
|
|
7
7
|
* - `emit(name, detail)`: dispatches the declared event `name` as a `CustomEvent` on `element`
|
|
8
|
-
* after validating `detail` against the manifest
|
|
8
|
+
* after validating `detail` against the manifest. Called as a plain function (no
|
|
9
9
|
* `this`); it never throws.
|
|
10
|
-
* - `transport
|
|
10
|
+
* - `transport`: where `useTaggorData` and `useTrack` send submissions and tracked
|
|
11
11
|
* interactions (`createEdgeTransport` on a real page, `createMemoryTransport` in tests and in
|
|
12
12
|
* `taggor dev`). Absent: submissions end in the `unavailable` error and tracking is a no-op.
|
|
13
|
-
* - `debug` (
|
|
13
|
+
* - `debug` (set by the debug mode): the data hooks log a `console.warn` for
|
|
14
14
|
* calls they ignore (an undeclared interaction or prop). Absent or false: they stay silent.
|
|
15
|
-
* - `signal
|
|
15
|
+
* - `signal`: aborted when the runtime really unmounts the component (removed from the
|
|
16
16
|
* page, not moved); `useTaggorData` passes it to `transport.submit`, so a submission still in
|
|
17
17
|
* flight is cancelled. A new signal per mount. Absent: nothing is cancelled.
|
|
18
|
-
* - `internals
|
|
18
|
+
* - `internals`: the element's `ElementInternals`, given only to a component whose manifest
|
|
19
19
|
* declares `formAssociated: true`; `useFormField` sets the form value and validity through it.
|
|
20
20
|
* Absent: no form participation (not declared, a browser without form-associated custom
|
|
21
21
|
* elements, or `@taggor/component/testing` in happy-dom).
|
package/dist/host.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The host of a mounted component
|
|
2
|
+
* The host of a mounted component: what the runtime gives the component of a
|
|
3
3
|
* `ComponentDefinition` when it mounts it, and `useHost`, the hook that exposes the element and its
|
|
4
|
-
* shadow root to the author.
|
|
5
|
-
* hooks read
|
|
4
|
+
* shadow root to the author. It also carries the optional data transport and debug flag the data
|
|
5
|
+
* hooks read, and the optional `internals` of a form field component.
|
|
6
6
|
*
|
|
7
7
|
* The context lives in the component's own copy of the SDK: the runtime never imports it (it passes
|
|
8
8
|
* the host as a component prop and `defineTaggorComponent`'s component provides it), so two copies of the
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @taggor/component
|
|
2
|
+
* @taggor/component: the authoring SDK a component's code imports. `defineTaggorComponent` declares a
|
|
3
3
|
* component (manifest fields, styles, render), `prop.<type>()` declares props whose value types
|
|
4
4
|
* `render` receives, `emit` (in `render`'s context) only accepts declared events, and `useHost` /
|
|
5
|
-
* `useSlot` reach the custom element, its shadow root and its slotted content.
|
|
6
|
-
*
|
|
5
|
+
* `useSlot` reach the custom element, its shadow root and its slotted content. The data
|
|
6
|
+
* hooks are `useTaggorData` (submit to a declared collection) and `useTrack` (measure a declared
|
|
7
7
|
* interaction), over the `DataTransport` the runtime injects (`createEdgeTransport`,
|
|
8
|
-
* `createMemoryTransport`). Unused hooks and transports are dropped by tree-shaking.
|
|
9
|
-
*
|
|
10
|
-
* (`ComponentEventMap`)
|
|
11
|
-
* and the `<Consent>` checkbox, whose proof `useTaggorData` requires and sends.
|
|
12
|
-
* i18n
|
|
13
|
-
* `Intl` helpers), dropped by tree-shaking from components that do not call it.
|
|
14
|
-
* assets
|
|
15
|
-
* `@taggor/component/assets`) and `useFont`/`fontFamily`, which add a component's
|
|
16
|
-
* without any CSS there.
|
|
17
|
-
* `formAssociated: true` submits with the page's `<form>`, and its validity.
|
|
8
|
+
* `createMemoryTransport`). Unused hooks and transports are dropped by tree-shaking. Theming
|
|
9
|
+
* (`cssVar` and `part`, typed by `cssVars` and `parts`) and the host page event types
|
|
10
|
+
* (`ComponentEventMap`) are here too. Components that collect personal data use consent:
|
|
11
|
+
* `useConsent` and the `<Consent>` checkbox, whose proof `useTaggorData` requires and sends.
|
|
12
|
+
* For i18n there is `useLocale` (the visitor's language among the component's message catalogs,
|
|
13
|
+
* `t` and thin `Intl` helpers), dropped by tree-shaking from components that do not call it.
|
|
14
|
+
* For assets there are the `ImageUrl`/`FontUrl` types of asset imports (declared for `*.svg`,
|
|
15
|
+
* `*.woff2`… in `@taggor/component/assets`) and `useFont`/`fontFamily`, which add a component's
|
|
16
|
+
* font to the document without any CSS there. Form field components use `useFormField`, which
|
|
17
|
+
* sets what a component with `formAssociated: true` submits with the page's `<form>`, and its validity.
|
|
18
18
|
*
|
|
19
19
|
* This entry goes into every component bundle, so it has no side effects (`sideEffects: false`,
|
|
20
20
|
* nothing registered or assigned to a global), imports no Zod (only `import type` from
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @taggor/component
|
|
2
|
+
* @taggor/component: the authoring SDK a component's code imports. `defineTaggorComponent` declares a
|
|
3
3
|
* component (manifest fields, styles, render), `prop.<type>()` declares props whose value types
|
|
4
4
|
* `render` receives, `emit` (in `render`'s context) only accepts declared events, and `useHost` /
|
|
5
|
-
* `useSlot` reach the custom element, its shadow root and its slotted content.
|
|
6
|
-
*
|
|
5
|
+
* `useSlot` reach the custom element, its shadow root and its slotted content. The data
|
|
6
|
+
* hooks are `useTaggorData` (submit to a declared collection) and `useTrack` (measure a declared
|
|
7
7
|
* interaction), over the `DataTransport` the runtime injects (`createEdgeTransport`,
|
|
8
|
-
* `createMemoryTransport`). Unused hooks and transports are dropped by tree-shaking.
|
|
9
|
-
*
|
|
10
|
-
* (`ComponentEventMap`)
|
|
11
|
-
* and the `<Consent>` checkbox, whose proof `useTaggorData` requires and sends.
|
|
12
|
-
* i18n
|
|
13
|
-
* `Intl` helpers), dropped by tree-shaking from components that do not call it.
|
|
14
|
-
* assets
|
|
15
|
-
* `@taggor/component/assets`) and `useFont`/`fontFamily`, which add a component's
|
|
16
|
-
* without any CSS there.
|
|
17
|
-
* `formAssociated: true` submits with the page's `<form>`, and its validity.
|
|
8
|
+
* `createMemoryTransport`). Unused hooks and transports are dropped by tree-shaking. Theming
|
|
9
|
+
* (`cssVar` and `part`, typed by `cssVars` and `parts`) and the host page event types
|
|
10
|
+
* (`ComponentEventMap`) are here too. Components that collect personal data use consent:
|
|
11
|
+
* `useConsent` and the `<Consent>` checkbox, whose proof `useTaggorData` requires and sends.
|
|
12
|
+
* For i18n there is `useLocale` (the visitor's language among the component's message catalogs,
|
|
13
|
+
* `t` and thin `Intl` helpers), dropped by tree-shaking from components that do not call it.
|
|
14
|
+
* For assets there are the `ImageUrl`/`FontUrl` types of asset imports (declared for `*.svg`,
|
|
15
|
+
* `*.woff2`… in `@taggor/component/assets`) and `useFont`/`fontFamily`, which add a component's
|
|
16
|
+
* font to the document without any CSS there. Form field components use `useFormField`, which
|
|
17
|
+
* sets what a component with `formAssociated: true` submits with the page's `<form>`, and its validity.
|
|
18
18
|
*
|
|
19
19
|
* This entry goes into every component bundle, so it has no side effects (`sideEffects: false`,
|
|
20
20
|
* nothing registered or assigned to a global), imports no Zod (only `import type` from
|
package/dist/intl-format.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Thin helpers over the browser's `Intl
|
|
2
|
+
* Thin helpers over the browser's `Intl`: numbers, money and dates in the component's
|
|
3
3
|
* language, with no formatting library in the bundle. `useLocale` hands them out bound to the
|
|
4
4
|
* chosen language.
|
|
5
5
|
*
|
|
@@ -25,12 +25,12 @@ export declare function formatNumber(locale: string, value: number, options?: In
|
|
|
25
25
|
*/
|
|
26
26
|
export declare function formatCurrency(locale: string, value: number, currency: string, options?: Intl.NumberFormatOptions): string;
|
|
27
27
|
/**
|
|
28
|
-
* Formats a date (`"
|
|
28
|
+
* Formats a date (`"2025-10-30"` → `30/10/2026` in pt-BR, `10/30/2026` in en).
|
|
29
29
|
*
|
|
30
30
|
* Inputs: a language tag, a `Date`, a timestamp or a date text, and optional
|
|
31
31
|
* `Intl.DateTimeFormat` options. A calendar date (`YYYY-MM-DD`, what a `date` prop holds) is shown
|
|
32
32
|
* as that day everywhere: it is formatted in UTC unless the options set `timeZone`, since
|
|
33
|
-
* `new Date("
|
|
33
|
+
* `new Date("2025-10-30")` is midnight UTC, which is still the 29th west of Greenwich. Output: the
|
|
34
34
|
* formatted text; an invalid date, tag or option gives `""`. Errors: none. Side effects: none.
|
|
35
35
|
*/
|
|
36
36
|
export declare function formatDate(locale: string, value: Date | number | string, options?: Intl.DateTimeFormatOptions): string;
|
package/dist/intl-format.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Thin helpers over the browser's `Intl
|
|
2
|
+
* Thin helpers over the browser's `Intl`: numbers, money and dates in the component's
|
|
3
3
|
* language, with no formatting library in the bundle. `useLocale` hands them out bound to the
|
|
4
4
|
* chosen language.
|
|
5
5
|
*
|
|
@@ -40,12 +40,12 @@ export function formatCurrency(locale, value, currency, options) {
|
|
|
40
40
|
return safely(() => new Intl.NumberFormat(locale, { ...options, style: "currency", currency }).format(value), `${currency} ${String(value)}`);
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
* Formats a date (`"
|
|
43
|
+
* Formats a date (`"2025-10-30"` → `30/10/2026` in pt-BR, `10/30/2026` in en).
|
|
44
44
|
*
|
|
45
45
|
* Inputs: a language tag, a `Date`, a timestamp or a date text, and optional
|
|
46
46
|
* `Intl.DateTimeFormat` options. A calendar date (`YYYY-MM-DD`, what a `date` prop holds) is shown
|
|
47
47
|
* as that day everywhere: it is formatted in UTC unless the options set `timeZone`, since
|
|
48
|
-
* `new Date("
|
|
48
|
+
* `new Date("2025-10-30")` is midnight UTC, which is still the 29th west of Greenwich. Output: the
|
|
49
49
|
* formatted text; an invalid date, tag or option gives `""`. Errors: none. Side effects: none.
|
|
50
50
|
*/
|
|
51
51
|
export function formatDate(locale, value, options) {
|
package/dist/issued-proofs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The consent proofs this copy of the SDK issued
|
|
2
|
+
* The consent proofs this copy of the SDK issued: `useConsent` adds
|
|
3
3
|
* every proof it builds, and `useTaggorData`'s `submit` sends personal data only with a proof in
|
|
4
4
|
* the set. A proof written by hand, `{ given: true, text_hash: await consentTextHash(…), locale }`,
|
|
5
5
|
* is a plain object that was never added, so it ends in `consent_required` like a missing one.
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
* A `WeakSet` keeps no proof alive and has no global name: each component's bundle has its own copy
|
|
8
8
|
* of the SDK, so one component can never vouch for another's proof.
|
|
9
9
|
*
|
|
10
|
-
* Scope
|
|
10
|
+
* Scope: this stops the naive forgery, not a component that subverts its own
|
|
11
11
|
* realm on purpose. The set lives in the untrusted bundle: a component can replace
|
|
12
12
|
* `WeakSet.prototype.has` or `add` (looked up at call time), reach Preact's hook state to get a
|
|
13
13
|
* proof issued, or skip the SDK and call the ingest itself. Against that, the gate, the AUP and the
|
|
14
|
-
* server-side check of the proof
|
|
14
|
+
* server-side check of the proof apply; threat model §6, residual 3. A proof the component
|
|
15
15
|
* kept stays in the set after the visitor unticks the box (residual 1).
|
|
16
16
|
*/
|
|
17
17
|
/** Proofs `useConsent` built for a ticked box (frozen objects). */
|
package/dist/issued-proofs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The consent proofs this copy of the SDK issued
|
|
2
|
+
* The consent proofs this copy of the SDK issued: `useConsent` adds
|
|
3
3
|
* every proof it builds, and `useTaggorData`'s `submit` sends personal data only with a proof in
|
|
4
4
|
* the set. A proof written by hand, `{ given: true, text_hash: await consentTextHash(…), locale }`,
|
|
5
5
|
* is a plain object that was never added, so it ends in `consent_required` like a missing one.
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
* A `WeakSet` keeps no proof alive and has no global name: each component's bundle has its own copy
|
|
8
8
|
* of the SDK, so one component can never vouch for another's proof.
|
|
9
9
|
*
|
|
10
|
-
* Scope
|
|
10
|
+
* Scope: this stops the naive forgery, not a component that subverts its own
|
|
11
11
|
* realm on purpose. The set lives in the untrusted bundle: a component can replace
|
|
12
12
|
* `WeakSet.prototype.has` or `add` (looked up at call time), reach Preact's hook state to get a
|
|
13
13
|
* proof issued, or skip the SDK and call the ingest itself. Against that, the gate, the AUP and the
|
|
14
|
-
* server-side check of the proof
|
|
14
|
+
* server-side check of the proof apply; threat model §6, residual 3. A proof the component
|
|
15
15
|
* kept stays in the set after the visitor unticks the box (residual 1).
|
|
16
16
|
*/
|
|
17
17
|
/** Proofs `useConsent` built for a ticked box (frozen objects). */
|
package/dist/locale.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Which language a component speaks
|
|
2
|
+
* Which language a component speaks: the candidates a page offers, in the order of the
|
|
3
3
|
* contract (`SPEC.md` §3, `locales`), and the pure choice of one of the languages the component
|
|
4
4
|
* ships messages for.
|
|
5
5
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The in-memory data transport
|
|
3
|
-
* sending them, for unit tests, `@taggor/component/testing`
|
|
2
|
+
* The in-memory data transport: records submissions and tracked interactions instead of
|
|
3
|
+
* sending them, for unit tests, `@taggor/component/testing` and `taggor dev`. Each
|
|
4
4
|
* submission is answered by a `respond` function, so a test can play an accepted submission, a
|
|
5
5
|
* validation error, a network failure or a slow server.
|
|
6
6
|
*/
|
|
@@ -20,7 +20,7 @@ export interface MemoryTransport extends DataTransport {
|
|
|
20
20
|
/** Every `track` call received (kind `custom`), in order: what a component's `useTrack` sent. */
|
|
21
21
|
readonly tracked: readonly TrackedEvent[];
|
|
22
22
|
/**
|
|
23
|
-
* Every declared event the component emitted that reached the transport (
|
|
23
|
+
* Every declared event the component emitted that reached the transport (kind
|
|
24
24
|
* `interaction`), in order. Kept apart from `tracked` so the tests of a component that counts its
|
|
25
25
|
* tracked calls keep meaning what they say.
|
|
26
26
|
*/
|
package/dist/messages.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Message catalogs of a component
|
|
2
|
+
* Message catalogs of a component: one flat JSON object per language, imported by the
|
|
3
3
|
* component's code and declared in `defineTaggorComponent({ locales: { default, messages } })`, and `t`, the
|
|
4
4
|
* lookup that turns a key and its variables into text.
|
|
5
5
|
*
|
package/dist/none.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `None` (
|
|
2
|
+
* `None` (moved here so the data types can use it without importing
|
|
3
3
|
* `define-component.ts`): the empty declaration map. Types only.
|
|
4
4
|
*/
|
|
5
5
|
/** An empty declaration map: the type of `props`, `events`, `slots` or `data` when omitted. */
|
package/dist/none.js
CHANGED
package/dist/props.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Prop declarations for authors
|
|
2
|
+
* Prop declarations for authors: the `prop.<type>(options)` builders and `PropsOf`, the
|
|
3
3
|
* type `render` receives. The declaration is the contract's own `PropDeclaration` (the nine types
|
|
4
|
-
* of `propTypeCatalog
|
|
4
|
+
* of `propTypeCatalog`), written as plain data: a builder only adds `type`, so what the
|
|
5
5
|
* author writes is exactly what lands in the manifest and what the runtime coerces with.
|
|
6
6
|
*
|
|
7
7
|
* Why the types cannot diverge from the runtime: `PropsOf` reads the value type from the
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* `default`, because the runtime falls back to `default` (possibly absent) whenever an attribute
|
|
11
11
|
* is missing or invalid (`attributeToValue`, `propertyToValue`).
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
* `render` sees them
|
|
13
|
+
* Every value is `DeepReadonly`, because the runtime freezes the props in depth before
|
|
14
|
+
* `render` sees them; copy before sorting or changing (`[...props.items].sort()`).
|
|
15
15
|
*/
|
|
16
16
|
import type { PropDeclarationOf, PropType, PropValueTypes } from "@taggor/contract/zod-free";
|
|
17
17
|
import type { DeepReadonly, ValueOf } from "./value-types.js";
|
|
@@ -35,14 +35,14 @@ type HasDefault<D> = D extends {
|
|
|
35
35
|
} ? undefined extends Default ? false : true : false;
|
|
36
36
|
/**
|
|
37
37
|
* The value `render` receives for one declaration: read-only in depth (the runtime deep-freezes
|
|
38
|
-
* props
|
|
38
|
+
* props), and `| undefined` when there is no `default`.
|
|
39
39
|
*/
|
|
40
40
|
export type PropValueOf<D> = DeepReadonly<HasDefault<D> extends true ? DeclaredValue<D> : DeclaredValue<D> | undefined>;
|
|
41
41
|
/**
|
|
42
42
|
* The props object `render` receives: every declared prop, typed from its declaration
|
|
43
43
|
* (`prop.number({ default: 1.2 })` → `number`; without a default → `number | undefined`), and
|
|
44
44
|
* read-only at every level (`prop.array` → `readonly T[]`, `prop.object` → readonly fields),
|
|
45
|
-
* since the runtime hands them over deep-frozen
|
|
45
|
+
* since the runtime hands them over deep-frozen.
|
|
46
46
|
*/
|
|
47
47
|
export type PropsOf<P> = {
|
|
48
48
|
readonly [K in keyof P]: PropValueOf<P[K]>;
|
package/dist/slots.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Slots for authors
|
|
2
|
+
* Slots for authors: `useSlot(name)` says whether the page put content into a slot, so a
|
|
3
3
|
* component can render its own fallback (a default title) only when the slot is empty.
|
|
4
4
|
*
|
|
5
5
|
* Content is never copied: the component renders a native `<slot name="…">` and the browser projects
|
|
6
|
-
* the light DOM nodes
|
|
6
|
+
* the light DOM nodes. This module only reads the host element's children; it never
|
|
7
7
|
* reads or writes HTML (golden rule 5).
|
|
8
8
|
*/
|
|
9
9
|
import { useEffect, useState } from "preact/hooks";
|
package/dist/submit-result.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Reading untrusted submit results
|
|
2
|
+
* Reading untrusted submit results: the edge's error body and whatever a transport
|
|
3
3
|
* resolves to both pass through here before the hook trusts them, so a malformed answer becomes
|
|
4
4
|
* `network_error` instead of an exception on the visitor's page (golden rule 2).
|
|
5
5
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Recording `ElementInternals` for `mountComponent
|
|
3
|
-
* a form field component (`formAssociated: true
|
|
2
|
+
* Recording `ElementInternals` for `mountComponent`: happy-dom has no `attachInternals`, so
|
|
3
|
+
* a form field component (`formAssociated: true`) mounted in an author's test got no
|
|
4
4
|
* `host.internals`, and `useFormField` recorded nothing. This module gives the component's own element
|
|
5
5
|
* class an `attachInternals` that returns internals which keep what the component set (the form value,
|
|
6
6
|
* the validity flags, the message and its anchor), so the test can read them back, which real
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Recording `ElementInternals` for `mountComponent
|
|
3
|
-
* a form field component (`formAssociated: true
|
|
2
|
+
* Recording `ElementInternals` for `mountComponent`: happy-dom has no `attachInternals`, so
|
|
3
|
+
* a form field component (`formAssociated: true`) mounted in an author's test got no
|
|
4
4
|
* `host.internals`, and `useFormField` recorded nothing. This module gives the component's own element
|
|
5
5
|
* class an `attachInternals` that returns internals which keep what the component set (the form value,
|
|
6
6
|
* the validity flags, the message and its anchor), so the test can read them back, which real
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@taggor/component/testing
|
|
2
|
+
* `@taggor/component/testing`: helpers for component authors' unit tests, in Vitest with
|
|
3
3
|
* `environment: "happy-dom"`. `mountComponent` mounts a definition in the runtime's real Custom Element
|
|
4
|
-
* wrapper (`createComponentElement
|
|
4
|
+
* wrapper (`createComponentElement`) with an in-memory data transport, and returns helpers to
|
|
5
5
|
* query the shadow root, change attributes and props, wait for the component to settle, read the
|
|
6
6
|
* events it emitted (`expectEvent`) and the submissions it sent (`transport.submissions`); for a
|
|
7
|
-
* form field component, `form` holds the value and validity it set on its internals
|
|
7
|
+
* form field component, `form` holds the value and validity it set on its internals.
|
|
8
8
|
*
|
|
9
9
|
* Test-only: this entry imports the runtime and `preact/test-utils`, so it must never be imported
|
|
10
10
|
* by a component's own code; `bundle.test.ts` proves the SDK's main entry does not reach it.
|
package/dist/testing/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@taggor/component/testing
|
|
2
|
+
* `@taggor/component/testing`: helpers for component authors' unit tests, in Vitest with
|
|
3
3
|
* `environment: "happy-dom"`. `mountComponent` mounts a definition in the runtime's real Custom Element
|
|
4
|
-
* wrapper (`createComponentElement
|
|
4
|
+
* wrapper (`createComponentElement`) with an in-memory data transport, and returns helpers to
|
|
5
5
|
* query the shadow root, change attributes and props, wait for the component to settle, read the
|
|
6
6
|
* events it emitted (`expectEvent`) and the submissions it sent (`transport.submissions`); for a
|
|
7
|
-
* form field component, `form` holds the value and validity it set on its internals
|
|
7
|
+
* form field component, `form` holds the value and validity it set on its internals.
|
|
8
8
|
*
|
|
9
9
|
* Test-only: this entry imports the runtime and `preact/test-utils`, so it must never be imported
|
|
10
10
|
* by a component's own code; `bundle.test.ts` proves the SDK's main entry does not reach it.
|
|
@@ -8,7 +8,7 @@ import { type FormFieldRecord } from "./form-internals.js";
|
|
|
8
8
|
export interface MountOptions<W> {
|
|
9
9
|
/** Attributes of the element, as a page writes them (`{ headline: "Hi", "max-amount": "5" }`). */
|
|
10
10
|
readonly attrs?: Readonly<Record<string, string>>;
|
|
11
|
-
/** Props set by property before the element connects (`el.items = [...]
|
|
11
|
+
/** Props set by property before the element connects (`el.items = [...]`). */
|
|
12
12
|
readonly props?: {
|
|
13
13
|
readonly [K in keyof ComponentPropsOf<W>]?: ComponentPropsOf<W>[K];
|
|
14
14
|
};
|
|
@@ -48,7 +48,7 @@ export interface MountedComponent<W> {
|
|
|
48
48
|
/**
|
|
49
49
|
* For a form field (`formAssociated: true`): what the component set on its internals so far, read
|
|
50
50
|
* live (`form.value` as given to `setFormValue`, `form.validity.valid`, `form.validationMessage`
|
|
51
|
-
* and its `anchor
|
|
51
|
+
* and its `anchor`). `undefined` for any other component.
|
|
52
52
|
*/
|
|
53
53
|
readonly form: FormFieldRecord | undefined;
|
|
54
54
|
/**
|
|
@@ -67,9 +67,9 @@ export interface MountedComponent<W> {
|
|
|
67
67
|
/**
|
|
68
68
|
* Runs `interaction` (a click, typing) as the visitor and waits until the component settled:
|
|
69
69
|
* effects, re-renders, pending promise callbacks such as a submission's answer, and pending
|
|
70
|
-
* `crypto.subtle` digests such as the consent label's hash
|
|
70
|
+
* `crypto.subtle` digests such as the consent label's hash. The events the
|
|
71
71
|
* interaction dispatches synchronously are trusted (`event.isTrusted`), as a visitor's input is;
|
|
72
|
-
* the ones dispatched later are not (
|
|
72
|
+
* the ones dispatched later are not (consent is ticked only inside a visitor's action).
|
|
73
73
|
*/
|
|
74
74
|
act(interaction?: () => unknown): Promise<void>;
|
|
75
75
|
/**
|
|
@@ -86,17 +86,17 @@ export interface MountedComponent<W> {
|
|
|
86
86
|
* Inputs: a definition made by `defineTaggorComponent` and `MountOptions` (`attrs`, `props`, `slots`,
|
|
87
87
|
* `respond`, `debug`, `contractVersion`). The tag is registered once per test file through
|
|
88
88
|
* `createComponentElement` (later mounts reuse it); a form field's class gets the recording
|
|
89
|
-
* `attachInternals` then
|
|
89
|
+
* `attachInternals` then. Output: a `MountedComponent`, after the first render
|
|
90
90
|
* and its effects. Errors: rejects when the runtime refuses to define the tag (another component took
|
|
91
91
|
* it in this file, or the contract version is unusable); a component that throws while rendering is
|
|
92
92
|
* not an error here: it shows its fallback and the failure is in `failures`. Side effects: defines
|
|
93
93
|
* the tag in `customElements`, appends the element to `document.body`, listens to its declared
|
|
94
94
|
* events and, once per document, wraps `crypto.subtle.digest` in a pass-through that records the
|
|
95
|
-
* pending digests, so `mountComponent` and every helper that settles wait for them
|
|
95
|
+
* pending digests, so `mountComponent` and every helper that settles wait for them.
|
|
96
96
|
*/
|
|
97
97
|
export declare function mountComponent<W extends MountableComponent>(definition: W, options?: MountOptions<W>): Promise<MountedComponent<W>>;
|
|
98
98
|
/**
|
|
99
|
-
* Unmounts every component `mountComponent` put on the page
|
|
99
|
+
* Unmounts every component `mountComponent` put on the page; for an `afterEach`.
|
|
100
100
|
*
|
|
101
101
|
* Inputs: none. Output: resolves after the unmounts (effect cleanups, aborted signals). Errors:
|
|
102
102
|
* none. Side effects: removes those elements from the document.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount-component.d.ts","sourceRoot":"","sources":["../../src/testing/mount-component.ts"],"names":[],"mappings":"AAyBA,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EAEtB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,eAAe,EACrB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAuC,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGhG,yDAAyD;AACzD,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,kGAAkG;IAClG,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClD,
|
|
1
|
+
{"version":3,"file":"mount-component.d.ts","sourceRoot":"","sources":["../../src/testing/mount-component.ts"],"names":[],"mappings":"AAyBA,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EAEtB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,eAAe,EACrB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAuC,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGhG,yDAAyD;AACzD,MAAM,WAAW,YAAY,CAAC,CAAC;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CAAC,CAAC,CAAC,CAAC,CA6E9B;AAED;;;;;GAKG;AACH,wBAAsB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAK7C"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `mountComponent
|
|
3
|
-
* real Custom Element wrapper (`createComponentElement` of `@taggor/runtime
|
|
2
|
+
* `mountComponent`: mounts a component definition for an author's unit test, in the runtime's
|
|
3
|
+
* real Custom Element wrapper (`createComponentElement` of `@taggor/runtime`), so the test
|
|
4
4
|
* sees what a visitor's page sees: an open shadow root, attributes coerced by the contract, props
|
|
5
|
-
* deep-frozen
|
|
5
|
+
* deep-frozen, events validated and dispatched as `<tag>:<event>`,
|
|
6
6
|
* slots projected natively and the error boundary's fallback. Nothing here re-implements the
|
|
7
7
|
* runtime; the additions are the data transport, an in-memory one (`createMemoryTransport`),
|
|
8
|
-
* because the runtime's host has no transport until the loader injects one
|
|
9
|
-
* form field (`formAssociated: true
|
|
10
|
-
* element class (happy-dom has none
|
|
8
|
+
* because the runtime's host has no transport until the loader injects one, and, for a
|
|
9
|
+
* form field (`formAssociated: true`), recording `ElementInternals` on the component's
|
|
10
|
+
* element class (happy-dom has none), which the runtime attaches and hands to the component
|
|
11
11
|
* as on a page, so `form` shows the value and validity the component set.
|
|
12
12
|
*
|
|
13
|
-
* `act(interaction)` runs the interaction as the visitor (`asVisitor
|
|
13
|
+
* `act(interaction)` runs the interaction as the visitor (`asVisitor`): the events it
|
|
14
14
|
* dispatches synchronously are trusted, as a visitor's own click is, so `<Consent>` records the
|
|
15
15
|
* tick; events dispatched anywhere else (attribute and prop changes, timers) stay untrusted.
|
|
16
16
|
*
|
|
17
17
|
* Settling waits for the state, never for a time: one macrotask for promise callbacks, then every
|
|
18
18
|
* pending `crypto.subtle` digest (the consent hash runs on Node's threadpool and may land after
|
|
19
|
-
* any number of macrotasks under load
|
|
19
|
+
* any number of macrotasks under load).
|
|
20
20
|
*
|
|
21
21
|
* Needs a DOM: Vitest with `environment: "happy-dom"` (or `// @vitest-environment happy-dom`).
|
|
22
22
|
* Test-only code: it lives in the `@taggor/component/testing` entry and never reaches a component bundle
|
|
@@ -34,13 +34,13 @@ import { asVisitor } from "./visitor.js";
|
|
|
34
34
|
const registrations = new WeakMap();
|
|
35
35
|
/** The test host extras of each mounted element, read by the wrapping component. */
|
|
36
36
|
const extrasByElement = new WeakMap();
|
|
37
|
-
/** The elements mounted
|
|
37
|
+
/** The elements currently mounted, for `cleanup`. */
|
|
38
38
|
const mounted = new Set();
|
|
39
39
|
/**
|
|
40
40
|
* The definition with its component wrapped to add the test transport and debug flag to the
|
|
41
41
|
* runtime's host. The host keeps the runtime's live getters (`shadowRoot`, `signal`), its `emit`,
|
|
42
|
-
* so events still go through the runtime's validation, and its `internals` (
|
|
43
|
-
* field, the recording ones of `installFormInternals
|
|
42
|
+
* so events still go through the runtime's validation, and its `internals` (for a form
|
|
43
|
+
* field, the recording ones of `installFormInternals`).
|
|
44
44
|
*/
|
|
45
45
|
function withTestHost(definition) {
|
|
46
46
|
const hosts = new WeakMap();
|
|
@@ -98,9 +98,9 @@ function register(definition, contractVersion) {
|
|
|
98
98
|
return registration;
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
|
-
* Digests started through `crypto.subtle` and
|
|
102
|
-
* `crypto.subtle.digest` in an effect
|
|
103
|
-
* resolve after any number of macrotasks when the pool is busy (
|
|
101
|
+
* Digests started through `crypto.subtle` and still pending. `useConsent` hashes its label with
|
|
102
|
+
* `crypto.subtle.digest` in an effect; Node runs that on the libuv threadpool, so it can
|
|
103
|
+
* resolve after any number of macrotasks when the pool is busy (a loaded `make check`
|
|
104
104
|
* submitted before the proof existed). Tracking them lets `settle` wait for the state, not a time.
|
|
105
105
|
*/
|
|
106
106
|
const pendingDigests = new Set();
|
|
@@ -175,13 +175,13 @@ function setProperties(element, props) {
|
|
|
175
175
|
* Inputs: a definition made by `defineTaggorComponent` and `MountOptions` (`attrs`, `props`, `slots`,
|
|
176
176
|
* `respond`, `debug`, `contractVersion`). The tag is registered once per test file through
|
|
177
177
|
* `createComponentElement` (later mounts reuse it); a form field's class gets the recording
|
|
178
|
-
* `attachInternals` then
|
|
178
|
+
* `attachInternals` then. Output: a `MountedComponent`, after the first render
|
|
179
179
|
* and its effects. Errors: rejects when the runtime refuses to define the tag (another component took
|
|
180
180
|
* it in this file, or the contract version is unusable); a component that throws while rendering is
|
|
181
181
|
* not an error here: it shows its fallback and the failure is in `failures`. Side effects: defines
|
|
182
182
|
* the tag in `customElements`, appends the element to `document.body`, listens to its declared
|
|
183
183
|
* events and, once per document, wraps `crypto.subtle.digest` in a pass-through that records the
|
|
184
|
-
* pending digests, so `mountComponent` and every helper that settles wait for them
|
|
184
|
+
* pending digests, so `mountComponent` and every helper that settles wait for them.
|
|
185
185
|
*/
|
|
186
186
|
export async function mountComponent(definition, options = {}) {
|
|
187
187
|
trackDigests();
|
|
@@ -255,7 +255,7 @@ export async function mountComponent(definition, options = {}) {
|
|
|
255
255
|
};
|
|
256
256
|
}
|
|
257
257
|
/**
|
|
258
|
-
* Unmounts every component `mountComponent` put on the page
|
|
258
|
+
* Unmounts every component `mountComponent` put on the page; for an `afterEach`.
|
|
259
259
|
*
|
|
260
260
|
* Inputs: none. Output: resolves after the unmounts (effect cleanups, aborted signals). Errors:
|
|
261
261
|
* none. Side effects: removes those elements from the document.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount-component.js","sourceRoot":"","sources":["../../src/testing/mount-component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,sBAAsB,GAKvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAKxC,OAAO,EACL,qBAAqB,GAG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
+
* Visitor actions in a test: `useConsent` records a tick only inside a trusted event
|
|
3
3
|
* (`event.isTrusted`, set by the browser for the visitor's own input), and happy-dom marks no
|
|
4
4
|
* event trusted, so a test's `click()` would never tick consent. `asVisitor` runs an interaction
|
|
5
5
|
* as the visitor: every event dispatched synchronously inside it reads `isTrusted: true`. Events
|
package/dist/testing/visitor.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Visitor actions in a test
|
|
2
|
+
* Visitor actions in a test: `useConsent` records a tick only inside a trusted event
|
|
3
3
|
* (`event.isTrusted`, set by the browser for the visitor's own input), and happy-dom marks no
|
|
4
4
|
* event trusted, so a test's `click()` would never tick consent. `asVisitor` runs an interaction
|
|
5
5
|
* as the visitor: every event dispatched synchronously inside it reads `isTrusted: true`. Events
|
package/dist/theming.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Theming helpers for authors
|
|
2
|
+
* Theming helpers for authors: `cssVar` reads a declared public CSS variable and
|
|
3
3
|
* `part` names declared parts, so the styling API a host page relies on (`--fs-primary-color`,
|
|
4
4
|
* `finance-simulator::part(button)`) is exactly the one the manifest declares. Both are typed by
|
|
5
5
|
* the component's `cssVars` and `parts`: an undeclared name is a compile error. The builder checks
|