@jam-overture/loom 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +743 -0
- package/dist/catalogue.d.ts +70 -0
- package/dist/catalogue.js +88 -0
- package/dist/cli/args.d.ts +17 -0
- package/dist/cli/args.js +83 -0
- package/dist/cli/filesystem.d.ts +15 -0
- package/dist/cli/filesystem.js +31 -0
- package/dist/cli/index.d.ts +12 -0
- package/dist/cli/index.js +12 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.js +30 -0
- package/dist/cli/namespace.d.ts +40 -0
- package/dist/cli/namespace.js +40 -0
- package/dist/cli/plan.d.ts +84 -0
- package/dist/cli/plan.js +113 -0
- package/dist/cli/run.d.ts +17 -0
- package/dist/cli/run.js +75 -0
- package/dist/cli/templates.d.ts +43 -0
- package/dist/cli/templates.js +134 -0
- package/dist/closed-set.d.ts +34 -0
- package/dist/closed-set.js +34 -0
- package/dist/data/adapter.d.ts +123 -0
- package/dist/data/adapter.js +91 -0
- package/dist/data/binding.d.ts +48 -0
- package/dist/data/binding.js +39 -0
- package/dist/data/catalogue.d.ts +26 -0
- package/dist/data/catalogue.js +6 -0
- package/dist/data/index.d.ts +14 -0
- package/dist/data/index.js +14 -0
- package/dist/data/plan.d.ts +58 -0
- package/dist/data/plan.js +0 -0
- package/dist/data/resolution.d.ts +91 -0
- package/dist/data/resolution.js +96 -0
- package/dist/data/resolve.d.ts +46 -0
- package/dist/data/resolve.js +37 -0
- package/dist/data/source.d.ts +40 -0
- package/dist/data/source.js +45 -0
- package/dist/deadline.d.ts +57 -0
- package/dist/deadline.js +78 -0
- package/dist/frame/catalogue.d.ts +24 -0
- package/dist/frame/catalogue.js +5 -0
- package/dist/frame/index.d.ts +12 -0
- package/dist/frame/index.js +12 -0
- package/dist/frame/origin.d.ts +87 -0
- package/dist/frame/origin.js +114 -0
- package/dist/frame/resolution.d.ts +85 -0
- package/dist/frame/resolution.js +79 -0
- package/dist/grammar.d.ts +26 -0
- package/dist/grammar.js +28 -0
- package/dist/ids.d.ts +57 -0
- package/dist/ids.js +104 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +26 -0
- package/dist/interactivity.d.ts +50 -0
- package/dist/interactivity.js +22 -0
- package/dist/interpretation/anthropic.d.ts +22 -0
- package/dist/interpretation/anthropic.js +76 -0
- package/dist/interpretation/client.d.ts +83 -0
- package/dist/interpretation/client.js +2 -0
- package/dist/interpretation/draft.d.ts +234 -0
- package/dist/interpretation/draft.js +84 -0
- package/dist/interpretation/index.d.ts +15 -0
- package/dist/interpretation/index.js +15 -0
- package/dist/interpretation/interpreter.d.ts +62 -0
- package/dist/interpretation/interpreter.js +151 -0
- package/dist/interpretation/materialize.d.ts +42 -0
- package/dist/interpretation/materialize.js +107 -0
- package/dist/interpretation/prompt.d.ts +229 -0
- package/dist/interpretation/prompt.js +285 -0
- package/dist/interpretation/render.d.ts +76 -0
- package/dist/interpretation/render.js +272 -0
- package/dist/interpretation/schema.d.ts +49 -0
- package/dist/interpretation/schema.js +131 -0
- package/dist/json.d.ts +35 -0
- package/dist/json.js +11 -0
- package/dist/paging.d.ts +60 -0
- package/dist/paging.js +49 -0
- package/dist/primitive-type.d.ts +32 -0
- package/dist/primitive-type.js +39 -0
- package/dist/render/addressing.d.ts +59 -0
- package/dist/render/addressing.js +60 -0
- package/dist/render/anchor.d.ts +105 -0
- package/dist/render/anchor.js +84 -0
- package/dist/render/behaviour-adjust.d.ts +62 -0
- package/dist/render/behaviour-adjust.js +78 -0
- package/dist/render/behaviour-copy.d.ts +53 -0
- package/dist/render/behaviour-copy.js +75 -0
- package/dist/render/behaviour-disclose.d.ts +74 -0
- package/dist/render/behaviour-disclose.js +77 -0
- package/dist/render/behaviour-present.d.ts +123 -0
- package/dist/render/behaviour-present.js +173 -0
- package/dist/render/behaviour.d.ts +243 -0
- package/dist/render/behaviour.js +284 -0
- package/dist/render/control.d.ts +81 -0
- package/dist/render/control.js +80 -0
- package/dist/render/decorative.d.ts +62 -0
- package/dist/render/decorative.js +2 -0
- package/dist/render/diagnostics.d.ts +260 -0
- package/dist/render/diagnostics.js +61 -0
- package/dist/render/disclosed.d.ts +37 -0
- package/dist/render/disclosed.js +37 -0
- package/dist/render/editable.d.ts +34 -0
- package/dist/render/editable.js +35 -0
- package/dist/render/frame.d.ts +42 -0
- package/dist/render/frame.js +31 -0
- package/dist/render/index.d.ts +35 -0
- package/dist/render/index.js +35 -0
- package/dist/render/inline-variables.d.ts +77 -0
- package/dist/render/inline-variables.js +220 -0
- package/dist/render/presented.d.ts +82 -0
- package/dist/render/presented.js +82 -0
- package/dist/render/primitive.d.ts +228 -0
- package/dist/render/primitive.js +36 -0
- package/dist/render/props.d.ts +48 -0
- package/dist/render/props.js +2 -0
- package/dist/render/reads.d.ts +73 -0
- package/dist/render/reads.js +45 -0
- package/dist/render/render.d.ts +164 -0
- package/dist/render/render.js +571 -0
- package/dist/render/request.d.ts +111 -0
- package/dist/render/request.js +60 -0
- package/dist/render/text.d.ts +91 -0
- package/dist/render/text.js +44 -0
- package/dist/render/theme.d.ts +61 -0
- package/dist/render/theme.js +52 -0
- package/dist/reserved-props.d.ts +35 -0
- package/dist/reserved-props.js +45 -0
- package/dist/result.d.ts +27 -0
- package/dist/result.js +30 -0
- package/dist/role.d.ts +71 -0
- package/dist/role.js +22 -0
- package/dist/runtime/analysis.d.ts +149 -0
- package/dist/runtime/analysis.js +187 -0
- package/dist/runtime/assessment.d.ts +35 -0
- package/dist/runtime/assessment.js +13 -0
- package/dist/runtime/disposition.d.ts +102 -0
- package/dist/runtime/disposition.js +59 -0
- package/dist/runtime/events.d.ts +187 -0
- package/dist/runtime/events.js +7 -0
- package/dist/runtime/gate.d.ts +43 -0
- package/dist/runtime/gate.js +169 -0
- package/dist/runtime/index.d.ts +27 -0
- package/dist/runtime/index.js +27 -0
- package/dist/runtime/intent.d.ts +60 -0
- package/dist/runtime/intent.js +36 -0
- package/dist/runtime/interpreter.d.ts +117 -0
- package/dist/runtime/interpreter.js +46 -0
- package/dist/runtime/inverse-interpreter.d.ts +90 -0
- package/dist/runtime/inverse-interpreter.js +56 -0
- package/dist/runtime/inverse.d.ts +87 -0
- package/dist/runtime/inverse.js +48 -0
- package/dist/runtime/narration.d.ts +24 -0
- package/dist/runtime/narration.js +36 -0
- package/dist/runtime/nesting.d.ts +31 -0
- package/dist/runtime/nesting.js +46 -0
- package/dist/runtime/pipeline.d.ts +124 -0
- package/dist/runtime/pipeline.js +178 -0
- package/dist/runtime/policy-fingerprint.d.ts +29 -0
- package/dist/runtime/policy-fingerprint.js +119 -0
- package/dist/runtime/policy-source.d.ts +42 -0
- package/dist/runtime/policy-source.js +8 -0
- package/dist/runtime/policy.d.ts +156 -0
- package/dist/runtime/policy.js +107 -0
- package/dist/runtime/proposal.d.ts +423 -0
- package/dist/runtime/proposal.js +109 -0
- package/dist/runtime/redirection.d.ts +53 -0
- package/dist/runtime/redirection.js +38 -0
- package/dist/runtime/repointing.d.ts +71 -0
- package/dist/runtime/repointing.js +0 -0
- package/dist/runtime/reversibility.d.ts +36 -0
- package/dist/runtime/reversibility.js +39 -0
- package/dist/runtime/stake-level.d.ts +33 -0
- package/dist/runtime/stake-level.js +58 -0
- package/dist/runtime/stakes.d.ts +47 -0
- package/dist/runtime/stakes.js +305 -0
- package/dist/runtime/vocabulary.d.ts +122 -0
- package/dist/runtime/vocabulary.js +87 -0
- package/dist/sdk/audit.d.ts +195 -0
- package/dist/sdk/audit.js +128 -0
- package/dist/sdk/catalogue.d.ts +37 -0
- package/dist/sdk/catalogue.js +16 -0
- package/dist/sdk/conformance.d.ts +342 -0
- package/dist/sdk/conformance.js +494 -0
- package/dist/sdk/copy.d.ts +105 -0
- package/dist/sdk/copy.js +90 -0
- package/dist/sdk/definition.d.ts +242 -0
- package/dist/sdk/definition.js +64 -0
- package/dist/sdk/index.d.ts +19 -0
- package/dist/sdk/index.js +19 -0
- package/dist/sdk/interactivity.d.ts +29 -0
- package/dist/sdk/interactivity.js +34 -0
- package/dist/sdk/pairings.d.ts +124 -0
- package/dist/sdk/pairings.js +81 -0
- package/dist/sdk/registry.d.ts +162 -0
- package/dist/sdk/registry.js +329 -0
- package/dist/sdk/selection.d.ts +46 -0
- package/dist/sdk/selection.js +24 -0
- package/dist/sdk/text.d.ts +100 -0
- package/dist/sdk/text.js +105 -0
- package/dist/sdk/vocabulary.d.ts +39 -0
- package/dist/sdk/vocabulary.js +36 -0
- package/dist/signals/broadcast.d.ts +134 -0
- package/dist/signals/broadcast.js +451 -0
- package/dist/signals/collect.d.ts +184 -0
- package/dist/signals/collect.js +196 -0
- package/dist/signals/deliver.d.ts +64 -0
- package/dist/signals/deliver.js +85 -0
- package/dist/signals/fold.d.ts +112 -0
- package/dist/signals/fold.js +76 -0
- package/dist/signals/index.d.ts +31 -0
- package/dist/signals/index.js +31 -0
- package/dist/signals/ingest.d.ts +51 -0
- package/dist/signals/ingest.js +70 -0
- package/dist/signals/intake.d.ts +149 -0
- package/dist/signals/intake.js +154 -0
- package/dist/signals/journal.d.ts +94 -0
- package/dist/signals/journal.js +11 -0
- package/dist/signals/kinds.d.ts +22 -0
- package/dist/signals/kinds.js +22 -0
- package/dist/signals/ledger.d.ts +46 -0
- package/dist/signals/ledger.js +81 -0
- package/dist/signals/memory.d.ts +17 -0
- package/dist/signals/memory.js +99 -0
- package/dist/signals/migrate.d.ts +27 -0
- package/dist/signals/migrate.js +78 -0
- package/dist/signals/postgres.d.ts +7 -0
- package/dist/signals/postgres.js +295 -0
- package/dist/signals/rollup.d.ts +142 -0
- package/dist/signals/rollup.js +0 -0
- package/dist/signals/schema.d.ts +534 -0
- package/dist/signals/schema.js +92 -0
- package/dist/signals/signal.d.ts +381 -0
- package/dist/signals/signal.js +150 -0
- package/dist/signals/tally.d.ts +70 -0
- package/dist/signals/tally.js +2 -0
- package/dist/signals/view.d.ts +51 -0
- package/dist/signals/view.js +54 -0
- package/dist/store/attribution.d.ts +125 -0
- package/dist/store/attribution.js +116 -0
- package/dist/store/database.d.ts +14 -0
- package/dist/store/database.js +2 -0
- package/dist/store/driver.d.ts +29 -0
- package/dist/store/driver.js +39 -0
- package/dist/store/errors.d.ts +56 -0
- package/dist/store/errors.js +37 -0
- package/dist/store/index.d.ts +16 -0
- package/dist/store/index.js +16 -0
- package/dist/store/memory.d.ts +3 -0
- package/dist/store/memory.js +115 -0
- package/dist/store/migrate.d.ts +54 -0
- package/dist/store/migrate.js +122 -0
- package/dist/store/postgres-holds.d.ts +4 -0
- package/dist/store/postgres-holds.js +192 -0
- package/dist/store/postgres.d.ts +8 -0
- package/dist/store/postgres.js +262 -0
- package/dist/store/replay.d.ts +94 -0
- package/dist/store/replay.js +82 -0
- package/dist/store/revert.d.ts +116 -0
- package/dist/store/revert.js +243 -0
- package/dist/store/schema.d.ts +371 -0
- package/dist/store/schema.js +78 -0
- package/dist/store/source.d.ts +23 -0
- package/dist/store/source.js +37 -0
- package/dist/store/store.d.ts +231 -0
- package/dist/store/store.js +52 -0
- package/dist/store/undone.d.ts +18 -0
- package/dist/store/undone.js +89 -0
- package/dist/submit/catalogue.d.ts +20 -0
- package/dist/submit/catalogue.js +5 -0
- package/dist/submit/declaration.d.ts +39 -0
- package/dist/submit/declaration.js +30 -0
- package/dist/submit/endpoint.d.ts +131 -0
- package/dist/submit/endpoint.js +160 -0
- package/dist/submit/index.d.ts +13 -0
- package/dist/submit/index.js +13 -0
- package/dist/submit/plan.d.ts +49 -0
- package/dist/submit/plan.js +47 -0
- package/dist/submit/resolution.d.ts +61 -0
- package/dist/submit/resolution.js +64 -0
- package/dist/submit/resolve.d.ts +45 -0
- package/dist/submit/resolve.js +36 -0
- package/dist/telemetry/calibration.d.ts +132 -0
- package/dist/telemetry/calibration.js +151 -0
- package/dist/telemetry/episode.d.ts +140 -0
- package/dist/telemetry/episode.js +272 -0
- package/dist/telemetry/event.d.ts +2310 -0
- package/dist/telemetry/event.js +405 -0
- package/dist/telemetry/index.d.ts +15 -0
- package/dist/telemetry/index.js +15 -0
- package/dist/telemetry/journal.d.ts +116 -0
- package/dist/telemetry/journal.js +11 -0
- package/dist/telemetry/memory.d.ts +24 -0
- package/dist/telemetry/memory.js +75 -0
- package/dist/telemetry/migrate.d.ts +26 -0
- package/dist/telemetry/migrate.js +40 -0
- package/dist/telemetry/postgres.d.ts +6 -0
- package/dist/telemetry/postgres.js +139 -0
- package/dist/telemetry/retention.d.ts +131 -0
- package/dist/telemetry/retention.js +217 -0
- package/dist/telemetry/schema.d.ts +113 -0
- package/dist/telemetry/schema.js +33 -0
- package/dist/telemetry/sink.d.ts +42 -0
- package/dist/telemetry/sink.js +61 -0
- package/dist/testing/contracts.d.ts +34 -0
- package/dist/testing/contracts.js +34 -0
- package/dist/testing/definitions.d.ts +15 -0
- package/dist/testing/definitions.js +48 -0
- package/dist/testing/doubles.d.ts +94 -0
- package/dist/testing/doubles.js +141 -0
- package/dist/testing/episode-harness.d.ts +49 -0
- package/dist/testing/episode-harness.js +65 -0
- package/dist/testing/filesystem.d.ts +17 -0
- package/dist/testing/filesystem.js +17 -0
- package/dist/testing/fixtures.d.ts +57 -0
- package/dist/testing/fixtures.js +84 -0
- package/dist/testing/hold-contract.d.ts +19 -0
- package/dist/testing/hold-contract.js +374 -0
- package/dist/testing/index.d.ts +41 -0
- package/dist/testing/index.js +41 -0
- package/dist/testing/journal-contract.d.ts +17 -0
- package/dist/testing/journal-contract.js +353 -0
- package/dist/testing/model-replies.d.ts +34 -0
- package/dist/testing/model-replies.js +101 -0
- package/dist/testing/primitives.d.ts +7 -0
- package/dist/testing/primitives.js +29 -0
- package/dist/testing/reader-signal-contract.d.ts +38 -0
- package/dist/testing/reader-signal-contract.js +318 -0
- package/dist/testing/row-security.d.ts +17 -0
- package/dist/testing/row-security.js +21 -0
- package/dist/testing/store-contract.d.ts +25 -0
- package/dist/testing/store-contract.js +500 -0
- package/dist/theme/apply.d.ts +17 -0
- package/dist/theme/apply.js +60 -0
- package/dist/theme/contrast.d.ts +197 -0
- package/dist/theme/contrast.js +259 -0
- package/dist/theme/derive.d.ts +77 -0
- package/dist/theme/derive.js +167 -0
- package/dist/theme/faces.d.ts +73 -0
- package/dist/theme/faces.js +119 -0
- package/dist/theme/font-packs.d.ts +25 -0
- package/dist/theme/font-packs.js +257 -0
- package/dist/theme/index.d.ts +20 -0
- package/dist/theme/index.js +20 -0
- package/dist/theme/lab.d.ts +30 -0
- package/dist/theme/lab.js +46 -0
- package/dist/theme/library.d.ts +114 -0
- package/dist/theme/library.js +300 -0
- package/dist/theme/measure.d.ts +144 -0
- package/dist/theme/measure.js +145 -0
- package/dist/theme/palettes.d.ts +64 -0
- package/dist/theme/palettes.js +497 -0
- package/dist/theme/registry.d.ts +59 -0
- package/dist/theme/registry.js +60 -0
- package/dist/theme/separation.d.ts +177 -0
- package/dist/theme/separation.js +203 -0
- package/dist/theme/style-presets.d.ts +60 -0
- package/dist/theme/style-presets.js +124 -0
- package/dist/theme/theme.d.ts +253 -0
- package/dist/theme/theme.js +171 -0
- package/dist/tree/apply.d.ts +16 -0
- package/dist/tree/apply.js +104 -0
- package/dist/tree/builders.d.ts +19 -0
- package/dist/tree/builders.js +20 -0
- package/dist/tree/compare.d.ts +68 -0
- package/dist/tree/compare.js +75 -0
- package/dist/tree/configuration.d.ts +25 -0
- package/dist/tree/configuration.js +108 -0
- package/dist/tree/delta.d.ts +288 -0
- package/dist/tree/delta.js +88 -0
- package/dist/tree/errors.d.ts +69 -0
- package/dist/tree/errors.js +34 -0
- package/dist/tree/identity.d.ts +117 -0
- package/dist/tree/identity.js +145 -0
- package/dist/tree/index.d.ts +21 -0
- package/dist/tree/index.js +21 -0
- package/dist/tree/inverse.d.ts +24 -0
- package/dist/tree/inverse.js +112 -0
- package/dist/tree/mutation.d.ts +18 -0
- package/dist/tree/mutation.js +49 -0
- package/dist/tree/naming.d.ts +4 -0
- package/dist/tree/naming.js +35 -0
- package/dist/tree/navigation.d.ts +38 -0
- package/dist/tree/navigation.js +83 -0
- package/dist/tree/node.d.ts +103 -0
- package/dist/tree/node.js +46 -0
- package/dist/tree/outline.d.ts +28 -0
- package/dist/tree/outline.js +10 -0
- package/dist/tree/tree.d.ts +83 -0
- package/dist/tree/tree.js +62 -0
- package/dist/write/commit.d.ts +124 -0
- package/dist/write/commit.js +234 -0
- package/dist/write/held.d.ts +674 -0
- package/dist/write/held.js +185 -0
- package/dist/write/index.d.ts +11 -0
- package/dist/write/index.js +11 -0
- package/dist/write/liveness.d.ts +132 -0
- package/dist/write/liveness.js +91 -0
- package/dist/write/revert.d.ts +79 -0
- package/dist/write/revert.js +134 -0
- package/package.json +160 -0
package/dist/sdk/text.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { NO_TEXT } from "../render/text.js";
|
|
3
|
+
/**
|
|
4
|
+
* Translating the strings primitives own.
|
|
5
|
+
*
|
|
6
|
+
* A registry already answers `textFor` with the strings its primitives
|
|
7
|
+
* declared, which is what a deployment serving the authors' own language wants.
|
|
8
|
+
* This is the other half: what a deployment serving a different language
|
|
9
|
+
* supplies, what a translator has to be given to produce it, and what tells a
|
|
10
|
+
* host that the two have drifted apart.
|
|
11
|
+
*
|
|
12
|
+
* All three are pure projections over a registry. Nothing here renders, and
|
|
13
|
+
* nothing here reads a request — which language a visitor gets is the host's to
|
|
14
|
+
* decide, from headers or a path segment or a stored preference, and the
|
|
15
|
+
* framework never guesses at it.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* A dictionary addresses one string as `${primitive type}.${key}` — the same
|
|
19
|
+
* flat key a translation file uses, so a dictionary can be a JSON file a
|
|
20
|
+
* translator edits and a diff between two languages is readable.
|
|
21
|
+
*
|
|
22
|
+
* The address is unambiguous because a text key never contains a dot
|
|
23
|
+
* (`textKeySchema`), so the last dot always separates the type from the key.
|
|
24
|
+
*/
|
|
25
|
+
export const textMessageKey = (type, key) => `${type}.${key}`;
|
|
26
|
+
/**
|
|
27
|
+
* A language tag, kept loose on purpose. It is carried for reporting — which
|
|
28
|
+
* dictionary is this, and which one was incomplete — and nothing in the
|
|
29
|
+
* framework branches on it, so validating it against the full BCP-47 grammar
|
|
30
|
+
* would buy strictness nobody spends.
|
|
31
|
+
*/
|
|
32
|
+
const localeSchema = z.string().regex(/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/);
|
|
33
|
+
export const textDictionarySchema = z.object({
|
|
34
|
+
locale: localeSchema,
|
|
35
|
+
/**
|
|
36
|
+
* Empty translations are refused rather than accepted and ignored. A
|
|
37
|
+
* translator who deletes a string leaves a control with no accessible name,
|
|
38
|
+
* which is the exact failure the seam exists to prevent; refusing the
|
|
39
|
+
* dictionary at the boundary is where that gets caught, because by render time
|
|
40
|
+
* there is nobody left to tell.
|
|
41
|
+
*/
|
|
42
|
+
messages: z.record(z.string(), z.string().min(1)),
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* Every string the registered library owns, in registration order and key-sorted
|
|
46
|
+
* within each primitive — the extraction a translation file is written from.
|
|
47
|
+
*
|
|
48
|
+
* Deliberately **not** part of `catalogueOf`. That catalogue is what a model is
|
|
49
|
+
* told it may build (0013), and these strings are the one part of the page a
|
|
50
|
+
* model must not write: an accessible name is a promise about what a control
|
|
51
|
+
* does, and it belongs to whoever wrote the control.
|
|
52
|
+
*/
|
|
53
|
+
export const textCatalogue = (registry) => registry.primitives.flatMap((primitive) => Object.entries(primitive.text)
|
|
54
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
55
|
+
.map(([key, source]) => ({ type: primitive.type, key, source })));
|
|
56
|
+
/**
|
|
57
|
+
* A resolver over the registry's declarations with a dictionary laid on top.
|
|
58
|
+
*
|
|
59
|
+
* The merge happens once, here, rather than once per node during a walk: a page
|
|
60
|
+
* with fifty perks in it does fifty map reads and no string work at all. A host
|
|
61
|
+
* serving several languages builds one of these per dictionary and keeps them,
|
|
62
|
+
* which is also why this takes a dictionary rather than reading one.
|
|
63
|
+
*
|
|
64
|
+
* A key the dictionary does not carry keeps the declared string. That is not a
|
|
65
|
+
* failure mode to be reported at render time — it is the ordinary state of a
|
|
66
|
+
* translation in progress, and `textCoverage` is where a host finds out about it
|
|
67
|
+
* once rather than on every request.
|
|
68
|
+
*/
|
|
69
|
+
export const textResolverFor = (registry, dictionary) => {
|
|
70
|
+
const byType = new Map();
|
|
71
|
+
for (const primitive of registry.primitives) {
|
|
72
|
+
const resolved = Object.create(null);
|
|
73
|
+
for (const [key, source] of Object.entries(primitive.text)) {
|
|
74
|
+
const address = textMessageKey(primitive.type, key);
|
|
75
|
+
/** Own-property only: a dictionary is parsed JSON, and `toString` is a key. */
|
|
76
|
+
resolved[key] = Object.hasOwn(dictionary.messages, address)
|
|
77
|
+
? (dictionary.messages[address] ?? source)
|
|
78
|
+
: source;
|
|
79
|
+
}
|
|
80
|
+
byType.set(primitive.type, Object.freeze(resolved));
|
|
81
|
+
}
|
|
82
|
+
return { textFor: (type) => byType.get(type) ?? NO_TEXT };
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* What a dictionary covers, and where it has drifted from the library.
|
|
86
|
+
*
|
|
87
|
+
* Reported, never enforced — the same bargain 0012 struck for conformance. A
|
|
88
|
+
* partially translated deployment is a normal state and a legitimate choice; a
|
|
89
|
+
* host that would rather it were not asserts on this in a test or a build step,
|
|
90
|
+
* which is a decision it makes rather than one registration makes for it.
|
|
91
|
+
*/
|
|
92
|
+
export const textCoverage = (registry, dictionary) => {
|
|
93
|
+
const declared = textCatalogue(registry);
|
|
94
|
+
const addresses = new Set(declared.map((entry) => textMessageKey(entry.type, entry.key)));
|
|
95
|
+
const untranslated = declared.filter((entry) => !Object.hasOwn(dictionary.messages, textMessageKey(entry.type, entry.key)));
|
|
96
|
+
return {
|
|
97
|
+
locale: dictionary.locale,
|
|
98
|
+
translated: declared.length - untranslated.length,
|
|
99
|
+
untranslated,
|
|
100
|
+
unknown: Object.keys(dictionary.messages)
|
|
101
|
+
.filter((address) => !addresses.has(address))
|
|
102
|
+
.sort(),
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { PrimitiveType } from "../primitive-type.js";
|
|
2
|
+
import type { PropsVocabulary } from "../runtime/vocabulary.js";
|
|
3
|
+
import type { PrimitiveRegistry } from "./registry.js";
|
|
4
|
+
/**
|
|
5
|
+
* How a library tells the Gate which primitives exist at all.
|
|
6
|
+
*
|
|
7
|
+
* The renderer already resolves against this registry and reports an
|
|
8
|
+
* `unknown-primitive` diagnostic for anything it does not hold. Reading the
|
|
9
|
+
* same list into a policy is what lets the write path refuse the node before
|
|
10
|
+
* the log keeps it (0173).
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Every type a registry can draw, in the shape a Gate policy takes.
|
|
14
|
+
*
|
|
15
|
+
* Derived rather than hand-written for the reason `interactiveTypesFor` gives,
|
|
16
|
+
* and the cost of getting it wrong here is higher: a hand-kept list that is
|
|
17
|
+
* missing a type the registry has refuses changes the deployment could have
|
|
18
|
+
* drawn perfectly well, and every primitive added is a chance to forget.
|
|
19
|
+
*
|
|
20
|
+
* Deriving it is still the host's explicit call. A deployment that wants the
|
|
21
|
+
* check off leaves this out of its policy and gets the runtime's prior
|
|
22
|
+
* behaviour; a deployment with a second registry concatenates two of these.
|
|
23
|
+
*/
|
|
24
|
+
export declare const registeredTypesFor: (registry: PrimitiveRegistry) => readonly PrimitiveType[];
|
|
25
|
+
/**
|
|
26
|
+
* What a registry's primitives accept, in the shape the write path takes.
|
|
27
|
+
*
|
|
28
|
+
* `PrimitiveRegistry` already satisfies `PropsValidator` — the renderer is
|
|
29
|
+
* handed the registry itself — so this is a one-line adapter and that is the
|
|
30
|
+
* point of it. A host that writes the closure by hand can write a different
|
|
31
|
+
* one, and a deployment whose Gate and whose renderer disagree about which
|
|
32
|
+
* props are acceptable has a hole that no test of either seam alone finds.
|
|
33
|
+
*
|
|
34
|
+
* Wiring it is still the host's explicit call, for the reason
|
|
35
|
+
* `registeredTypesFor` gives one layer up: a runtime handed none checks
|
|
36
|
+
* nothing, which is the behaviour every deployment had before 0179.
|
|
37
|
+
*/
|
|
38
|
+
export declare const propsVocabularyFor: (registry: PrimitiveRegistry) => PropsVocabulary;
|
|
39
|
+
//# sourceMappingURL=vocabulary.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a library tells the Gate which primitives exist at all.
|
|
3
|
+
*
|
|
4
|
+
* The renderer already resolves against this registry and reports an
|
|
5
|
+
* `unknown-primitive` diagnostic for anything it does not hold. Reading the
|
|
6
|
+
* same list into a policy is what lets the write path refuse the node before
|
|
7
|
+
* the log keeps it (0173).
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Every type a registry can draw, in the shape a Gate policy takes.
|
|
11
|
+
*
|
|
12
|
+
* Derived rather than hand-written for the reason `interactiveTypesFor` gives,
|
|
13
|
+
* and the cost of getting it wrong here is higher: a hand-kept list that is
|
|
14
|
+
* missing a type the registry has refuses changes the deployment could have
|
|
15
|
+
* drawn perfectly well, and every primitive added is a chance to forget.
|
|
16
|
+
*
|
|
17
|
+
* Deriving it is still the host's explicit call. A deployment that wants the
|
|
18
|
+
* check off leaves this out of its policy and gets the runtime's prior
|
|
19
|
+
* behaviour; a deployment with a second registry concatenates two of these.
|
|
20
|
+
*/
|
|
21
|
+
export const registeredTypesFor = (registry) => registry.primitives.map((primitive) => primitive.type);
|
|
22
|
+
/**
|
|
23
|
+
* What a registry's primitives accept, in the shape the write path takes.
|
|
24
|
+
*
|
|
25
|
+
* `PrimitiveRegistry` already satisfies `PropsValidator` — the renderer is
|
|
26
|
+
* handed the registry itself — so this is a one-line adapter and that is the
|
|
27
|
+
* point of it. A host that writes the closure by hand can write a different
|
|
28
|
+
* one, and a deployment whose Gate and whose renderer disagree about which
|
|
29
|
+
* props are acceptable has a hole that no test of either seam alone finds.
|
|
30
|
+
*
|
|
31
|
+
* Wiring it is still the host's explicit call, for the reason
|
|
32
|
+
* `registeredTypesFor` gives one layer up: a runtime handed none checks
|
|
33
|
+
* nothing, which is the behaviour every deployment had before 0179.
|
|
34
|
+
*/
|
|
35
|
+
export const propsVocabularyFor = (registry) => (type, props) => registry.validateProps(type, props);
|
|
36
|
+
//# sourceMappingURL=vocabulary.js.map
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { type Result } from "../result.js";
|
|
2
|
+
import type { ReaderSignalBatch, ReaderSignalKind } from "./signal.js";
|
|
3
|
+
import { type RandomBytes } from "./view.js";
|
|
4
|
+
/**
|
|
5
|
+
* Broadcasting reader signals from a rendered Loom page.
|
|
6
|
+
*
|
|
7
|
+
* The browser half of the seam. Point it at the root element of a page rendered
|
|
8
|
+
* with `addressed: true` and it watches the nodes on that page, gathers what
|
|
9
|
+
* readers do with them, and delivers a batch every few seconds — as a DOM event
|
|
10
|
+
* anything on the page can listen for, and to a `send` function if the host
|
|
11
|
+
* gives one.
|
|
12
|
+
*
|
|
13
|
+
* **Off unless a host calls it.** The library renders no script and starts no
|
|
14
|
+
* observer on its own; a page that never calls this broadcasts nothing (0136).
|
|
15
|
+
*
|
|
16
|
+
* **Configured by the host, never by the tree.** Which kinds and which primitive
|
|
17
|
+
* types are broadcast is an argument here, not a prop a proposal could set — a
|
|
18
|
+
* model must not be able to switch measurement of readers on by writing a delta.
|
|
19
|
+
*
|
|
20
|
+
* **It reads the page, not the components.** Every fact it needs is already on
|
|
21
|
+
* the markup: identity from the addressed attributes, what a reader can aim at
|
|
22
|
+
* from the elements HTML gives targets, and a disclosure from the attribute the
|
|
23
|
+
* disclose control stamps. No primitive is instrumented, so no primitive can
|
|
24
|
+
* forget to be.
|
|
25
|
+
*
|
|
26
|
+
* **A press says which regions it was in.** A reader aims at a button, and a
|
|
27
|
+
* button is an addressed node of its own, so the node an `activated` names is
|
|
28
|
+
* the control rather than the band. The addressed elements above it go on the
|
|
29
|
+
* signal as `within`, read off the walk this was already doing — because which
|
|
30
|
+
* region a node sat in is a fact about the page at the moment of the press, and
|
|
31
|
+
* nothing downstream can recover it afterwards.
|
|
32
|
+
*
|
|
33
|
+
* **It keeps up with a page that changes.** Nodes that arrive after it started
|
|
34
|
+
* are watched and nodes that leave stop counting, so a band behind a Suspense
|
|
35
|
+
* boundary, a list that grows, and every region a proposal has just changed are
|
|
36
|
+
* measured like the rest. What it does *not* follow is the page becoming a
|
|
37
|
+
* different page: the tree and revision are read once, off the root, and every
|
|
38
|
+
* batch is filed under them. **A new root, or a new revision in the same root,
|
|
39
|
+
* is a new broadcast** — `stop()` the old one and start another, or a
|
|
40
|
+
* client-side navigation files its signals under the revision it left.
|
|
41
|
+
*/
|
|
42
|
+
/** The DOM event a batch is dispatched as, on the root element. It bubbles. */
|
|
43
|
+
/**
|
|
44
|
+
* The delivery helper travels with this entry point rather than getting one of
|
|
45
|
+
* its own.
|
|
46
|
+
*
|
|
47
|
+
* `deliver.ts` imports nothing at runtime, so it costs the same bytes reached
|
|
48
|
+
* from here as it would through a door of its own — and a host who is starting
|
|
49
|
+
* a broadcaster in a browser bundle is exactly the host who needs a `send`. One
|
|
50
|
+
* import line for the two things that are always used together.
|
|
51
|
+
*/
|
|
52
|
+
export { DEFAULT_READER_SIGNAL_PATH, deliverReaderSignals, type DeliverOptions, type PostBatch, type SendBeacon, } from "./deliver.js";
|
|
53
|
+
export declare const READER_SIGNALS_EVENT = "loom:signals";
|
|
54
|
+
/** Something that reports elements coming into and out of view. The browser's `IntersectionObserver` unless a host passes its own. */
|
|
55
|
+
export type VisibilityObserver = {
|
|
56
|
+
readonly observe: (element: Element) => void;
|
|
57
|
+
readonly disconnect: () => void;
|
|
58
|
+
};
|
|
59
|
+
export type VisibilityEntry = {
|
|
60
|
+
readonly target: Element;
|
|
61
|
+
readonly visible: boolean;
|
|
62
|
+
};
|
|
63
|
+
export type ObserveVisibility = (onChange: (entries: readonly VisibilityEntry[]) => void) => VisibilityObserver;
|
|
64
|
+
/** The primitive types to report on: one list for every kind, or a list per kind (0136). */
|
|
65
|
+
export type ReaderSignalTypes = readonly string[] | {
|
|
66
|
+
readonly [Kind in ReaderSignalKind]?: readonly string[];
|
|
67
|
+
};
|
|
68
|
+
export type ReaderSignalOptions = {
|
|
69
|
+
/** Called with every batch. A throw or rejection here is contained and never reaches the page. */
|
|
70
|
+
readonly send?: (batch: ReaderSignalBatch) => void | Promise<void>;
|
|
71
|
+
/** Which kinds to broadcast. Every kind when absent. */
|
|
72
|
+
readonly kinds?: readonly ReaderSignalKind[];
|
|
73
|
+
/**
|
|
74
|
+
* Which primitive types to broadcast about. Every addressed type when absent.
|
|
75
|
+
*
|
|
76
|
+
* A list applies to every kind. An object sets it per kind — time on screen
|
|
77
|
+
* for sections, activations for links — and a kind it does not name is
|
|
78
|
+
* reported for every type, exactly as if `types` were absent for that kind.
|
|
79
|
+
* Whether a kind is reported at all is still `kinds`.
|
|
80
|
+
*/
|
|
81
|
+
readonly types?: ReaderSignalTypes;
|
|
82
|
+
/** How often a batch is delivered. Five seconds when absent. */
|
|
83
|
+
readonly flushEveryMs?: number;
|
|
84
|
+
/**
|
|
85
|
+
* How the broadcaster learns what is on screen. The browser's
|
|
86
|
+
* `IntersectionObserver` when absent; a test passes its own.
|
|
87
|
+
*/
|
|
88
|
+
readonly observeVisibility?: ObserveVisibility;
|
|
89
|
+
/**
|
|
90
|
+
* Whether a delegated signal carries the addressed nodes it happened inside.
|
|
91
|
+
* On when absent.
|
|
92
|
+
*
|
|
93
|
+
* `activated` and `disclosed` are filed against the control a reader aimed
|
|
94
|
+
* at, which is an addressed node of its own — so without the ancestry a
|
|
95
|
+
* deployment can report which button was pressed and never which region it
|
|
96
|
+
* was in. Off is for a host that reports on controls only and would rather
|
|
97
|
+
* not carry the walk in every batch.
|
|
98
|
+
*/
|
|
99
|
+
readonly within?: boolean;
|
|
100
|
+
/** The clock. `Date.now` when absent. */
|
|
101
|
+
readonly now?: () => number;
|
|
102
|
+
/**
|
|
103
|
+
* Where the view key's randomness comes from. The browser's
|
|
104
|
+
* `crypto.getRandomValues` when absent; a test passes its own so it can name
|
|
105
|
+
* the key it expects.
|
|
106
|
+
*/
|
|
107
|
+
readonly random?: RandomBytes;
|
|
108
|
+
};
|
|
109
|
+
export type ReaderSignalBroadcast = {
|
|
110
|
+
/** Deliver whatever has been gathered, now. */
|
|
111
|
+
readonly flush: () => void;
|
|
112
|
+
/** Deliver what is left and stop observing. Safe to call twice. */
|
|
113
|
+
readonly stop: () => void;
|
|
114
|
+
};
|
|
115
|
+
export type ReaderSignalBroadcastError = {
|
|
116
|
+
/** The root carries no tree id or revision — the page was not rendered with `addressed: true`. */
|
|
117
|
+
readonly code: "unaddressed";
|
|
118
|
+
readonly detail: string;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Start broadcasting reader signals from the page under `root`.
|
|
122
|
+
*
|
|
123
|
+
* Returns an error rather than broadcasting nothing when the page is not
|
|
124
|
+
* addressed, because a silent broadcaster on an unaddressed page is exactly the
|
|
125
|
+
* misconfiguration nobody would notice.
|
|
126
|
+
*
|
|
127
|
+
* Nodes added under `root` afterwards are picked up and nodes removed stop
|
|
128
|
+
* counting. The tree and revision are not: they are read once, here, and a page
|
|
129
|
+
* that becomes a different page — a client-side navigation, a re-render at a new
|
|
130
|
+
* revision into the same root — needs `stop()` and a new broadcast, or its
|
|
131
|
+
* signals are filed under the revision it left.
|
|
132
|
+
*/
|
|
133
|
+
export declare const broadcastReaderSignals: (root: Element, options?: ReaderSignalOptions) => Result<ReaderSignalBroadcast, ReaderSignalBroadcastError>;
|
|
134
|
+
//# sourceMappingURL=broadcast.d.ts.map
|