@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.
Files changed (401) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +743 -0
  3. package/dist/catalogue.d.ts +70 -0
  4. package/dist/catalogue.js +88 -0
  5. package/dist/cli/args.d.ts +17 -0
  6. package/dist/cli/args.js +83 -0
  7. package/dist/cli/filesystem.d.ts +15 -0
  8. package/dist/cli/filesystem.js +31 -0
  9. package/dist/cli/index.d.ts +12 -0
  10. package/dist/cli/index.js +12 -0
  11. package/dist/cli/main.d.ts +3 -0
  12. package/dist/cli/main.js +30 -0
  13. package/dist/cli/namespace.d.ts +40 -0
  14. package/dist/cli/namespace.js +40 -0
  15. package/dist/cli/plan.d.ts +84 -0
  16. package/dist/cli/plan.js +113 -0
  17. package/dist/cli/run.d.ts +17 -0
  18. package/dist/cli/run.js +75 -0
  19. package/dist/cli/templates.d.ts +43 -0
  20. package/dist/cli/templates.js +134 -0
  21. package/dist/closed-set.d.ts +34 -0
  22. package/dist/closed-set.js +34 -0
  23. package/dist/data/adapter.d.ts +123 -0
  24. package/dist/data/adapter.js +91 -0
  25. package/dist/data/binding.d.ts +48 -0
  26. package/dist/data/binding.js +39 -0
  27. package/dist/data/catalogue.d.ts +26 -0
  28. package/dist/data/catalogue.js +6 -0
  29. package/dist/data/index.d.ts +14 -0
  30. package/dist/data/index.js +14 -0
  31. package/dist/data/plan.d.ts +58 -0
  32. package/dist/data/plan.js +0 -0
  33. package/dist/data/resolution.d.ts +91 -0
  34. package/dist/data/resolution.js +96 -0
  35. package/dist/data/resolve.d.ts +46 -0
  36. package/dist/data/resolve.js +37 -0
  37. package/dist/data/source.d.ts +40 -0
  38. package/dist/data/source.js +45 -0
  39. package/dist/deadline.d.ts +57 -0
  40. package/dist/deadline.js +78 -0
  41. package/dist/frame/catalogue.d.ts +24 -0
  42. package/dist/frame/catalogue.js +5 -0
  43. package/dist/frame/index.d.ts +12 -0
  44. package/dist/frame/index.js +12 -0
  45. package/dist/frame/origin.d.ts +87 -0
  46. package/dist/frame/origin.js +114 -0
  47. package/dist/frame/resolution.d.ts +85 -0
  48. package/dist/frame/resolution.js +79 -0
  49. package/dist/grammar.d.ts +26 -0
  50. package/dist/grammar.js +28 -0
  51. package/dist/ids.d.ts +57 -0
  52. package/dist/ids.js +104 -0
  53. package/dist/index.d.ts +26 -0
  54. package/dist/index.js +26 -0
  55. package/dist/interactivity.d.ts +50 -0
  56. package/dist/interactivity.js +22 -0
  57. package/dist/interpretation/anthropic.d.ts +22 -0
  58. package/dist/interpretation/anthropic.js +76 -0
  59. package/dist/interpretation/client.d.ts +83 -0
  60. package/dist/interpretation/client.js +2 -0
  61. package/dist/interpretation/draft.d.ts +234 -0
  62. package/dist/interpretation/draft.js +84 -0
  63. package/dist/interpretation/index.d.ts +15 -0
  64. package/dist/interpretation/index.js +15 -0
  65. package/dist/interpretation/interpreter.d.ts +62 -0
  66. package/dist/interpretation/interpreter.js +151 -0
  67. package/dist/interpretation/materialize.d.ts +42 -0
  68. package/dist/interpretation/materialize.js +107 -0
  69. package/dist/interpretation/prompt.d.ts +229 -0
  70. package/dist/interpretation/prompt.js +285 -0
  71. package/dist/interpretation/render.d.ts +76 -0
  72. package/dist/interpretation/render.js +272 -0
  73. package/dist/interpretation/schema.d.ts +49 -0
  74. package/dist/interpretation/schema.js +131 -0
  75. package/dist/json.d.ts +35 -0
  76. package/dist/json.js +11 -0
  77. package/dist/paging.d.ts +60 -0
  78. package/dist/paging.js +49 -0
  79. package/dist/primitive-type.d.ts +32 -0
  80. package/dist/primitive-type.js +39 -0
  81. package/dist/render/addressing.d.ts +59 -0
  82. package/dist/render/addressing.js +60 -0
  83. package/dist/render/anchor.d.ts +105 -0
  84. package/dist/render/anchor.js +84 -0
  85. package/dist/render/behaviour-adjust.d.ts +62 -0
  86. package/dist/render/behaviour-adjust.js +78 -0
  87. package/dist/render/behaviour-copy.d.ts +53 -0
  88. package/dist/render/behaviour-copy.js +75 -0
  89. package/dist/render/behaviour-disclose.d.ts +74 -0
  90. package/dist/render/behaviour-disclose.js +77 -0
  91. package/dist/render/behaviour-present.d.ts +123 -0
  92. package/dist/render/behaviour-present.js +173 -0
  93. package/dist/render/behaviour.d.ts +243 -0
  94. package/dist/render/behaviour.js +284 -0
  95. package/dist/render/control.d.ts +81 -0
  96. package/dist/render/control.js +80 -0
  97. package/dist/render/decorative.d.ts +62 -0
  98. package/dist/render/decorative.js +2 -0
  99. package/dist/render/diagnostics.d.ts +260 -0
  100. package/dist/render/diagnostics.js +61 -0
  101. package/dist/render/disclosed.d.ts +37 -0
  102. package/dist/render/disclosed.js +37 -0
  103. package/dist/render/editable.d.ts +34 -0
  104. package/dist/render/editable.js +35 -0
  105. package/dist/render/frame.d.ts +42 -0
  106. package/dist/render/frame.js +31 -0
  107. package/dist/render/index.d.ts +35 -0
  108. package/dist/render/index.js +35 -0
  109. package/dist/render/inline-variables.d.ts +77 -0
  110. package/dist/render/inline-variables.js +220 -0
  111. package/dist/render/presented.d.ts +82 -0
  112. package/dist/render/presented.js +82 -0
  113. package/dist/render/primitive.d.ts +228 -0
  114. package/dist/render/primitive.js +36 -0
  115. package/dist/render/props.d.ts +48 -0
  116. package/dist/render/props.js +2 -0
  117. package/dist/render/reads.d.ts +73 -0
  118. package/dist/render/reads.js +45 -0
  119. package/dist/render/render.d.ts +164 -0
  120. package/dist/render/render.js +571 -0
  121. package/dist/render/request.d.ts +111 -0
  122. package/dist/render/request.js +60 -0
  123. package/dist/render/text.d.ts +91 -0
  124. package/dist/render/text.js +44 -0
  125. package/dist/render/theme.d.ts +61 -0
  126. package/dist/render/theme.js +52 -0
  127. package/dist/reserved-props.d.ts +35 -0
  128. package/dist/reserved-props.js +45 -0
  129. package/dist/result.d.ts +27 -0
  130. package/dist/result.js +30 -0
  131. package/dist/role.d.ts +71 -0
  132. package/dist/role.js +22 -0
  133. package/dist/runtime/analysis.d.ts +149 -0
  134. package/dist/runtime/analysis.js +187 -0
  135. package/dist/runtime/assessment.d.ts +35 -0
  136. package/dist/runtime/assessment.js +13 -0
  137. package/dist/runtime/disposition.d.ts +102 -0
  138. package/dist/runtime/disposition.js +59 -0
  139. package/dist/runtime/events.d.ts +187 -0
  140. package/dist/runtime/events.js +7 -0
  141. package/dist/runtime/gate.d.ts +43 -0
  142. package/dist/runtime/gate.js +169 -0
  143. package/dist/runtime/index.d.ts +27 -0
  144. package/dist/runtime/index.js +27 -0
  145. package/dist/runtime/intent.d.ts +60 -0
  146. package/dist/runtime/intent.js +36 -0
  147. package/dist/runtime/interpreter.d.ts +117 -0
  148. package/dist/runtime/interpreter.js +46 -0
  149. package/dist/runtime/inverse-interpreter.d.ts +90 -0
  150. package/dist/runtime/inverse-interpreter.js +56 -0
  151. package/dist/runtime/inverse.d.ts +87 -0
  152. package/dist/runtime/inverse.js +48 -0
  153. package/dist/runtime/narration.d.ts +24 -0
  154. package/dist/runtime/narration.js +36 -0
  155. package/dist/runtime/nesting.d.ts +31 -0
  156. package/dist/runtime/nesting.js +46 -0
  157. package/dist/runtime/pipeline.d.ts +124 -0
  158. package/dist/runtime/pipeline.js +178 -0
  159. package/dist/runtime/policy-fingerprint.d.ts +29 -0
  160. package/dist/runtime/policy-fingerprint.js +119 -0
  161. package/dist/runtime/policy-source.d.ts +42 -0
  162. package/dist/runtime/policy-source.js +8 -0
  163. package/dist/runtime/policy.d.ts +156 -0
  164. package/dist/runtime/policy.js +107 -0
  165. package/dist/runtime/proposal.d.ts +423 -0
  166. package/dist/runtime/proposal.js +109 -0
  167. package/dist/runtime/redirection.d.ts +53 -0
  168. package/dist/runtime/redirection.js +38 -0
  169. package/dist/runtime/repointing.d.ts +71 -0
  170. package/dist/runtime/repointing.js +0 -0
  171. package/dist/runtime/reversibility.d.ts +36 -0
  172. package/dist/runtime/reversibility.js +39 -0
  173. package/dist/runtime/stake-level.d.ts +33 -0
  174. package/dist/runtime/stake-level.js +58 -0
  175. package/dist/runtime/stakes.d.ts +47 -0
  176. package/dist/runtime/stakes.js +305 -0
  177. package/dist/runtime/vocabulary.d.ts +122 -0
  178. package/dist/runtime/vocabulary.js +87 -0
  179. package/dist/sdk/audit.d.ts +195 -0
  180. package/dist/sdk/audit.js +128 -0
  181. package/dist/sdk/catalogue.d.ts +37 -0
  182. package/dist/sdk/catalogue.js +16 -0
  183. package/dist/sdk/conformance.d.ts +342 -0
  184. package/dist/sdk/conformance.js +494 -0
  185. package/dist/sdk/copy.d.ts +105 -0
  186. package/dist/sdk/copy.js +90 -0
  187. package/dist/sdk/definition.d.ts +242 -0
  188. package/dist/sdk/definition.js +64 -0
  189. package/dist/sdk/index.d.ts +19 -0
  190. package/dist/sdk/index.js +19 -0
  191. package/dist/sdk/interactivity.d.ts +29 -0
  192. package/dist/sdk/interactivity.js +34 -0
  193. package/dist/sdk/pairings.d.ts +124 -0
  194. package/dist/sdk/pairings.js +81 -0
  195. package/dist/sdk/registry.d.ts +162 -0
  196. package/dist/sdk/registry.js +329 -0
  197. package/dist/sdk/selection.d.ts +46 -0
  198. package/dist/sdk/selection.js +24 -0
  199. package/dist/sdk/text.d.ts +100 -0
  200. package/dist/sdk/text.js +105 -0
  201. package/dist/sdk/vocabulary.d.ts +39 -0
  202. package/dist/sdk/vocabulary.js +36 -0
  203. package/dist/signals/broadcast.d.ts +134 -0
  204. package/dist/signals/broadcast.js +451 -0
  205. package/dist/signals/collect.d.ts +184 -0
  206. package/dist/signals/collect.js +196 -0
  207. package/dist/signals/deliver.d.ts +64 -0
  208. package/dist/signals/deliver.js +85 -0
  209. package/dist/signals/fold.d.ts +112 -0
  210. package/dist/signals/fold.js +76 -0
  211. package/dist/signals/index.d.ts +31 -0
  212. package/dist/signals/index.js +31 -0
  213. package/dist/signals/ingest.d.ts +51 -0
  214. package/dist/signals/ingest.js +70 -0
  215. package/dist/signals/intake.d.ts +149 -0
  216. package/dist/signals/intake.js +154 -0
  217. package/dist/signals/journal.d.ts +94 -0
  218. package/dist/signals/journal.js +11 -0
  219. package/dist/signals/kinds.d.ts +22 -0
  220. package/dist/signals/kinds.js +22 -0
  221. package/dist/signals/ledger.d.ts +46 -0
  222. package/dist/signals/ledger.js +81 -0
  223. package/dist/signals/memory.d.ts +17 -0
  224. package/dist/signals/memory.js +99 -0
  225. package/dist/signals/migrate.d.ts +27 -0
  226. package/dist/signals/migrate.js +78 -0
  227. package/dist/signals/postgres.d.ts +7 -0
  228. package/dist/signals/postgres.js +295 -0
  229. package/dist/signals/rollup.d.ts +142 -0
  230. package/dist/signals/rollup.js +0 -0
  231. package/dist/signals/schema.d.ts +534 -0
  232. package/dist/signals/schema.js +92 -0
  233. package/dist/signals/signal.d.ts +381 -0
  234. package/dist/signals/signal.js +150 -0
  235. package/dist/signals/tally.d.ts +70 -0
  236. package/dist/signals/tally.js +2 -0
  237. package/dist/signals/view.d.ts +51 -0
  238. package/dist/signals/view.js +54 -0
  239. package/dist/store/attribution.d.ts +125 -0
  240. package/dist/store/attribution.js +116 -0
  241. package/dist/store/database.d.ts +14 -0
  242. package/dist/store/database.js +2 -0
  243. package/dist/store/driver.d.ts +29 -0
  244. package/dist/store/driver.js +39 -0
  245. package/dist/store/errors.d.ts +56 -0
  246. package/dist/store/errors.js +37 -0
  247. package/dist/store/index.d.ts +16 -0
  248. package/dist/store/index.js +16 -0
  249. package/dist/store/memory.d.ts +3 -0
  250. package/dist/store/memory.js +115 -0
  251. package/dist/store/migrate.d.ts +54 -0
  252. package/dist/store/migrate.js +122 -0
  253. package/dist/store/postgres-holds.d.ts +4 -0
  254. package/dist/store/postgres-holds.js +192 -0
  255. package/dist/store/postgres.d.ts +8 -0
  256. package/dist/store/postgres.js +262 -0
  257. package/dist/store/replay.d.ts +94 -0
  258. package/dist/store/replay.js +82 -0
  259. package/dist/store/revert.d.ts +116 -0
  260. package/dist/store/revert.js +243 -0
  261. package/dist/store/schema.d.ts +371 -0
  262. package/dist/store/schema.js +78 -0
  263. package/dist/store/source.d.ts +23 -0
  264. package/dist/store/source.js +37 -0
  265. package/dist/store/store.d.ts +231 -0
  266. package/dist/store/store.js +52 -0
  267. package/dist/store/undone.d.ts +18 -0
  268. package/dist/store/undone.js +89 -0
  269. package/dist/submit/catalogue.d.ts +20 -0
  270. package/dist/submit/catalogue.js +5 -0
  271. package/dist/submit/declaration.d.ts +39 -0
  272. package/dist/submit/declaration.js +30 -0
  273. package/dist/submit/endpoint.d.ts +131 -0
  274. package/dist/submit/endpoint.js +160 -0
  275. package/dist/submit/index.d.ts +13 -0
  276. package/dist/submit/index.js +13 -0
  277. package/dist/submit/plan.d.ts +49 -0
  278. package/dist/submit/plan.js +47 -0
  279. package/dist/submit/resolution.d.ts +61 -0
  280. package/dist/submit/resolution.js +64 -0
  281. package/dist/submit/resolve.d.ts +45 -0
  282. package/dist/submit/resolve.js +36 -0
  283. package/dist/telemetry/calibration.d.ts +132 -0
  284. package/dist/telemetry/calibration.js +151 -0
  285. package/dist/telemetry/episode.d.ts +140 -0
  286. package/dist/telemetry/episode.js +272 -0
  287. package/dist/telemetry/event.d.ts +2310 -0
  288. package/dist/telemetry/event.js +405 -0
  289. package/dist/telemetry/index.d.ts +15 -0
  290. package/dist/telemetry/index.js +15 -0
  291. package/dist/telemetry/journal.d.ts +116 -0
  292. package/dist/telemetry/journal.js +11 -0
  293. package/dist/telemetry/memory.d.ts +24 -0
  294. package/dist/telemetry/memory.js +75 -0
  295. package/dist/telemetry/migrate.d.ts +26 -0
  296. package/dist/telemetry/migrate.js +40 -0
  297. package/dist/telemetry/postgres.d.ts +6 -0
  298. package/dist/telemetry/postgres.js +139 -0
  299. package/dist/telemetry/retention.d.ts +131 -0
  300. package/dist/telemetry/retention.js +217 -0
  301. package/dist/telemetry/schema.d.ts +113 -0
  302. package/dist/telemetry/schema.js +33 -0
  303. package/dist/telemetry/sink.d.ts +42 -0
  304. package/dist/telemetry/sink.js +61 -0
  305. package/dist/testing/contracts.d.ts +34 -0
  306. package/dist/testing/contracts.js +34 -0
  307. package/dist/testing/definitions.d.ts +15 -0
  308. package/dist/testing/definitions.js +48 -0
  309. package/dist/testing/doubles.d.ts +94 -0
  310. package/dist/testing/doubles.js +141 -0
  311. package/dist/testing/episode-harness.d.ts +49 -0
  312. package/dist/testing/episode-harness.js +65 -0
  313. package/dist/testing/filesystem.d.ts +17 -0
  314. package/dist/testing/filesystem.js +17 -0
  315. package/dist/testing/fixtures.d.ts +57 -0
  316. package/dist/testing/fixtures.js +84 -0
  317. package/dist/testing/hold-contract.d.ts +19 -0
  318. package/dist/testing/hold-contract.js +374 -0
  319. package/dist/testing/index.d.ts +41 -0
  320. package/dist/testing/index.js +41 -0
  321. package/dist/testing/journal-contract.d.ts +17 -0
  322. package/dist/testing/journal-contract.js +353 -0
  323. package/dist/testing/model-replies.d.ts +34 -0
  324. package/dist/testing/model-replies.js +101 -0
  325. package/dist/testing/primitives.d.ts +7 -0
  326. package/dist/testing/primitives.js +29 -0
  327. package/dist/testing/reader-signal-contract.d.ts +38 -0
  328. package/dist/testing/reader-signal-contract.js +318 -0
  329. package/dist/testing/row-security.d.ts +17 -0
  330. package/dist/testing/row-security.js +21 -0
  331. package/dist/testing/store-contract.d.ts +25 -0
  332. package/dist/testing/store-contract.js +500 -0
  333. package/dist/theme/apply.d.ts +17 -0
  334. package/dist/theme/apply.js +60 -0
  335. package/dist/theme/contrast.d.ts +197 -0
  336. package/dist/theme/contrast.js +259 -0
  337. package/dist/theme/derive.d.ts +77 -0
  338. package/dist/theme/derive.js +167 -0
  339. package/dist/theme/faces.d.ts +73 -0
  340. package/dist/theme/faces.js +119 -0
  341. package/dist/theme/font-packs.d.ts +25 -0
  342. package/dist/theme/font-packs.js +257 -0
  343. package/dist/theme/index.d.ts +20 -0
  344. package/dist/theme/index.js +20 -0
  345. package/dist/theme/lab.d.ts +30 -0
  346. package/dist/theme/lab.js +46 -0
  347. package/dist/theme/library.d.ts +114 -0
  348. package/dist/theme/library.js +300 -0
  349. package/dist/theme/measure.d.ts +144 -0
  350. package/dist/theme/measure.js +145 -0
  351. package/dist/theme/palettes.d.ts +64 -0
  352. package/dist/theme/palettes.js +497 -0
  353. package/dist/theme/registry.d.ts +59 -0
  354. package/dist/theme/registry.js +60 -0
  355. package/dist/theme/separation.d.ts +177 -0
  356. package/dist/theme/separation.js +203 -0
  357. package/dist/theme/style-presets.d.ts +60 -0
  358. package/dist/theme/style-presets.js +124 -0
  359. package/dist/theme/theme.d.ts +253 -0
  360. package/dist/theme/theme.js +171 -0
  361. package/dist/tree/apply.d.ts +16 -0
  362. package/dist/tree/apply.js +104 -0
  363. package/dist/tree/builders.d.ts +19 -0
  364. package/dist/tree/builders.js +20 -0
  365. package/dist/tree/compare.d.ts +68 -0
  366. package/dist/tree/compare.js +75 -0
  367. package/dist/tree/configuration.d.ts +25 -0
  368. package/dist/tree/configuration.js +108 -0
  369. package/dist/tree/delta.d.ts +288 -0
  370. package/dist/tree/delta.js +88 -0
  371. package/dist/tree/errors.d.ts +69 -0
  372. package/dist/tree/errors.js +34 -0
  373. package/dist/tree/identity.d.ts +117 -0
  374. package/dist/tree/identity.js +145 -0
  375. package/dist/tree/index.d.ts +21 -0
  376. package/dist/tree/index.js +21 -0
  377. package/dist/tree/inverse.d.ts +24 -0
  378. package/dist/tree/inverse.js +112 -0
  379. package/dist/tree/mutation.d.ts +18 -0
  380. package/dist/tree/mutation.js +49 -0
  381. package/dist/tree/naming.d.ts +4 -0
  382. package/dist/tree/naming.js +35 -0
  383. package/dist/tree/navigation.d.ts +38 -0
  384. package/dist/tree/navigation.js +83 -0
  385. package/dist/tree/node.d.ts +103 -0
  386. package/dist/tree/node.js +46 -0
  387. package/dist/tree/outline.d.ts +28 -0
  388. package/dist/tree/outline.js +10 -0
  389. package/dist/tree/tree.d.ts +83 -0
  390. package/dist/tree/tree.js +62 -0
  391. package/dist/write/commit.d.ts +124 -0
  392. package/dist/write/commit.js +234 -0
  393. package/dist/write/held.d.ts +674 -0
  394. package/dist/write/held.js +185 -0
  395. package/dist/write/index.d.ts +11 -0
  396. package/dist/write/index.js +11 -0
  397. package/dist/write/liveness.d.ts +132 -0
  398. package/dist/write/liveness.js +91 -0
  399. package/dist/write/revert.d.ts +79 -0
  400. package/dist/write/revert.js +134 -0
  401. package/package.json +160 -0
@@ -0,0 +1,60 @@
1
+ import { resolveTreeData } from "../data/resolve.js";
2
+ import { err, ok } from "../result.js";
3
+ import { resolveTreeSubmissions } from "../submit/resolve.js";
4
+ import { parseTree } from "../tree/tree.js";
5
+ import { renderLoomTree } from "./render.js";
6
+ export const renderRequest = async (request, dependencies) => {
7
+ const loaded = await dependencies.source.load(request);
8
+ if (!loaded.ok)
9
+ return err({ code: "source-failed", error: loaded.error });
10
+ const parsed = parseTree(loaded.value);
11
+ if (!parsed.ok)
12
+ return err({ code: "invalid-tree", error: parsed.error });
13
+ const tree = parsed.value;
14
+ /**
15
+ * A source that answers with a different document than the one asked for is a
16
+ * cache-key or routing fault, and serving it would render one tenant's page
17
+ * under another's request. Cheap to check, so it is checked.
18
+ */
19
+ if (tree.treeId !== request.treeId) {
20
+ return err({ code: "tree-id-mismatch", requested: request.treeId, received: tree.treeId });
21
+ }
22
+ /**
23
+ * The only await between loading the tree and rendering it, and the reason
24
+ * this function is async at all. Both seams happen after the parse, because a
25
+ * plan is read off a tree that has been proved to be one, and before the walk,
26
+ * because the walk cannot wait for anything (0058, 0065).
27
+ *
28
+ * They run together rather than in turn. Neither knows about the other, and a
29
+ * page with a form and an integration should not pay for both in series.
30
+ */
31
+ const [data, submissions] = await Promise.all([
32
+ dependencies.sources
33
+ ? resolveTreeData(tree, {
34
+ registry: dependencies.sources,
35
+ ...(request.context ? { context: request.context } : {}),
36
+ })
37
+ : undefined,
38
+ dependencies.endpoints
39
+ ? resolveTreeSubmissions(tree, {
40
+ registry: dependencies.endpoints,
41
+ ...(request.context ? { context: request.context } : {}),
42
+ })
43
+ : undefined,
44
+ ]);
45
+ const rendered = renderLoomTree(tree, {
46
+ resolver: dependencies.resolver,
47
+ editMode: request.editMode,
48
+ ...(request.addressed ? { addressed: true } : {}),
49
+ ...(dependencies.validator ? { validator: dependencies.validator } : {}),
50
+ ...(dependencies.themes ? { themes: dependencies.themes } : {}),
51
+ ...(data ? { data } : {}),
52
+ ...(submissions ? { submissions } : {}),
53
+ ...(dependencies.origins ? { origins: dependencies.origins } : {}),
54
+ ...(dependencies.text ? { text: dependencies.text } : {}),
55
+ ...(dependencies.slots ? { slots: dependencies.slots } : {}),
56
+ ...(dependencies.themeValues ? { themeValues: dependencies.themeValues } : {}),
57
+ });
58
+ return ok({ ...rendered, tree });
59
+ };
60
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1,91 @@
1
+ import type { PrimitiveType } from "../primitive-type.js";
2
+ /**
3
+ * The text seam: the strings a primitive owns, and the deployment's chance to
4
+ * translate them.
5
+ *
6
+ * Almost every user-facing string on a Loom page comes from the tree, where a
7
+ * model wrote it and the Gate weighed it. A few cannot. A marker glyph carries
8
+ * an accessible name the visible label does not say; a disclosure control needs
9
+ * a name for the thing it opens. Those strings are not content anyone proposed —
10
+ * they belong to the registered component, the way its markup does.
11
+ *
12
+ * Making them props would put an accessible name inside the space a model
13
+ * writes, which is the shape 0053 and 0055 both refused. Leaving them inline in
14
+ * the component makes a German deployment render an English "Not included" in
15
+ * the middle of a German pricing table, with nowhere to fix it.
16
+ *
17
+ * So a primitive **declares** the strings it needs, in its own language, and a
18
+ * host may supply a dictionary that replaces them. What reaches the primitive is
19
+ * a resolved map: the translation where there is one, the declared string where
20
+ * there is not. Never a missing key, because the failure this seam exists to
21
+ * prevent is a control with no name at all.
22
+ *
23
+ * The two halves have different owners, and the renderer gets them from
24
+ * different places. **Declarations come with the component**, off the same
25
+ * registry that resolved it, because they are part of the primitive the way its
26
+ * markup is. **A dictionary is the host's**, wired deliberately, because which
27
+ * language a visitor gets is not the framework's to decide. `RenderOptions.text`
28
+ * is the second of those and not the first (0063).
29
+ */
30
+ /**
31
+ * The strings a primitive receives, by declared key.
32
+ *
33
+ * `TKey` is the union of keys the primitive declared, so a component that reads
34
+ * `loom.text.exlcuded` is a compile error at the point of declaration rather
35
+ * than an empty accessible name in production. It defaults to `never` — a
36
+ * primitive that declared no text can read no text, which is the honest type for
37
+ * the map it is handed.
38
+ */
39
+ export type PrimitiveText<TKey extends string = never> = Readonly<Record<TKey, string>>;
40
+ /**
41
+ * The map handed to a primitive that declares nothing, and the answer for a type
42
+ * the resolver does not know.
43
+ *
44
+ * Null-prototype for the reason `staticPrimitiveResolver` gives: text keys are
45
+ * lowercase identifiers and `constructor`, `toString` and `valueOf` are all
46
+ * valid ones, so an ordinary object would answer `loom.text.constructor` with a
47
+ * function off `Object.prototype`.
48
+ */
49
+ export declare const NO_TEXT: PrimitiveText<string>;
50
+ /**
51
+ * The renderer's whole dependency on translation: one lookup, by primitive type.
52
+ *
53
+ * A **separate interface** from `PrimitiveResolver`, for the reason `props.ts`
54
+ * gives for `PropsValidator` being separate: which language a deployment serves
55
+ * is a decision made at the composition root, and burying it in whichever
56
+ * resolver happened to be wired in would make a host that serves two languages
57
+ * register its library twice.
58
+ *
59
+ * A registry built by §4's SDK satisfies this interface with the declared
60
+ * strings themselves, so an untranslated deployment needs no dictionary and no
61
+ * wiring — the renderer reads the declarations off the resolver it already has.
62
+ *
63
+ * The lookup is synchronous and pure. Merging a dictionary is
64
+ * `textResolverFor`'s job, done once per dictionary rather than once per node.
65
+ */
66
+ export interface TextResolver {
67
+ readonly textFor: (type: PrimitiveType) => PrimitiveText<string>;
68
+ }
69
+ /**
70
+ * Whether a resolver can also answer for the strings its primitives declared.
71
+ *
72
+ * This is an **exact** test rather than a heuristic, and the reason is worth
73
+ * stating: the only way to declare text is `definePrimitive`, and the only thing
74
+ * that carries a declaration to the renderer is `createPrimitiveRegistry`, whose
75
+ * result is a `TextResolver`. A resolver that is not one — `staticPrimitiveResolver`
76
+ * over a map of components, or a host's own — has no declarations to lose. So
77
+ * "does this resolver satisfy `TextResolver`" and "does anything here declare
78
+ * strings" are the same question, and answering the first answers the second.
79
+ */
80
+ export declare const isTextResolver: (value: object) => value is TextResolver;
81
+ /**
82
+ * A primitive's declared strings with a host's answers laid over them, for the
83
+ * one case where both are in play and they are not the same object.
84
+ *
85
+ * Total by construction: every key either side carries is in the result, so a
86
+ * host resolver that answers for half the library — or for a different library
87
+ * entirely — leaves no declared key behind. Frozen and null-prototype for the
88
+ * reason `NO_TEXT` gives.
89
+ */
90
+ export declare const overlayText: (declared: PrimitiveText<string>, supplied: PrimitiveText<string>) => PrimitiveText<string>;
91
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The map handed to a primitive that declares nothing, and the answer for a type
3
+ * the resolver does not know.
4
+ *
5
+ * Null-prototype for the reason `staticPrimitiveResolver` gives: text keys are
6
+ * lowercase identifiers and `constructor`, `toString` and `valueOf` are all
7
+ * valid ones, so an ordinary object would answer `loom.text.constructor` with a
8
+ * function off `Object.prototype`.
9
+ */
10
+ export const NO_TEXT = Object.freeze(Object.create(null));
11
+ /**
12
+ * Whether a resolver can also answer for the strings its primitives declared.
13
+ *
14
+ * This is an **exact** test rather than a heuristic, and the reason is worth
15
+ * stating: the only way to declare text is `definePrimitive`, and the only thing
16
+ * that carries a declaration to the renderer is `createPrimitiveRegistry`, whose
17
+ * result is a `TextResolver`. A resolver that is not one — `staticPrimitiveResolver`
18
+ * over a map of components, or a host's own — has no declarations to lose. So
19
+ * "does this resolver satisfy `TextResolver`" and "does anything here declare
20
+ * strings" are the same question, and answering the first answers the second.
21
+ */
22
+ export const isTextResolver = (value) => typeof value.textFor === "function";
23
+ /**
24
+ * A primitive's declared strings with a host's answers laid over them, for the
25
+ * one case where both are in play and they are not the same object.
26
+ *
27
+ * Total by construction: every key either side carries is in the result, so a
28
+ * host resolver that answers for half the library — or for a different library
29
+ * entirely — leaves no declared key behind. Frozen and null-prototype for the
30
+ * reason `NO_TEXT` gives.
31
+ */
32
+ export const overlayText = (declared, supplied) => {
33
+ if (Object.keys(supplied).length === 0)
34
+ return declared;
35
+ if (Object.keys(declared).length === 0)
36
+ return supplied;
37
+ const merged = Object.create(null);
38
+ for (const [key, value] of Object.entries(declared))
39
+ merged[key] = value;
40
+ for (const [key, value] of Object.entries(supplied))
41
+ merged[key] = value;
42
+ return Object.freeze(merged);
43
+ };
44
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1,61 @@
1
+ import type { CSSProperties } from "react";
2
+ import type { JsonObject } from "../json.js";
3
+ import type { ThemeError, ThemeRegistry } from "../theme/registry.js";
4
+ import type { ResolvedTheme } from "../theme/theme.js";
5
+ /**
6
+ * The theme read out of the runtime's own props.
7
+ *
8
+ * 0049 put a theme in the tree as three registered ids carried on the root
9
+ * node's props, so that re-theming is an ordinary `configure` the Gate weighs
10
+ * like anything else. That left one question open: props belong to the
11
+ * primitive, and a root primitive declaring a strict schema would reject a key
12
+ * it never asked for — blanking the page over the theme rather than wearing it.
13
+ *
14
+ * So the `loom:` prefix names a **reserved namespace** ([`reserved-props.ts`](../reserved-props.ts)):
15
+ * keys under it belong to the runtime, are read here, and are removed from the
16
+ * bag before either the validator or the primitive sees it. That keeps 0049's
17
+ * other promise too — a primitive reads `var(--loom-accent)` and never learns
18
+ * which palette is mounted, which it could not claim if the palette id arrived
19
+ * in its props.
20
+ *
21
+ * Reserved keys the runtime does not recognise are dropped, and say so in a
22
+ * diagnostic: a namespace that silently swallows whatever is put in it is a
23
+ * place for data to go missing.
24
+ */
25
+ export { isReservedPropKey, partitionReservedProps, RESERVED_PROP_PREFIX, THEME_PROP_KEY, type PartitionedProps, } from "../reserved-props.js";
26
+ export type ThemeResolution = {
27
+ readonly outcome: "themed";
28
+ readonly theme: ResolvedTheme;
29
+ }
30
+ /** The node names no theme — the ordinary case for every node but the root. */
31
+ | {
32
+ readonly outcome: "unthemed";
33
+ }
34
+ /** Named, and the registry refused it: an unknown id, or a malformed selection. */
35
+ | {
36
+ readonly outcome: "unresolved";
37
+ readonly error: ThemeError;
38
+ }
39
+ /** Named, and this render was given no registry to resolve it against. */
40
+ | {
41
+ readonly outcome: "unregistered";
42
+ };
43
+ /**
44
+ * There is no fallback theme, deliberately. A host-supplied default would mount
45
+ * a look the tree does not name, which makes the page a function of deployment
46
+ * config as well as of the tree — the failure that rejecting host-supplied
47
+ * theming outright was meant to prevent (0049). An unthemed tree renders
48
+ * unstyled, and says so.
49
+ */
50
+ export declare const resolveTheme: (reserved: JsonObject, registry: ThemeRegistry | undefined) => ThemeResolution;
51
+ /**
52
+ * A resolved theme as a style object the root primitive applies.
53
+ *
54
+ * React passes any `--`-prefixed key in a style object straight through to the
55
+ * element, so the custom properties reach the DOM; its `CSSProperties` type has
56
+ * no index signature to describe them. The conversion is therefore a
57
+ * types-only step, and it happens once here rather than in every primitive that
58
+ * has to apply it.
59
+ */
60
+ export declare const themeStyle: (theme: ResolvedTheme) => CSSProperties;
61
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1,52 @@
1
+ import { THEME_PROP_KEY } from "../reserved-props.js";
2
+ import { themeVariables } from "../theme/apply.js";
3
+ /**
4
+ * The theme read out of the runtime's own props.
5
+ *
6
+ * 0049 put a theme in the tree as three registered ids carried on the root
7
+ * node's props, so that re-theming is an ordinary `configure` the Gate weighs
8
+ * like anything else. That left one question open: props belong to the
9
+ * primitive, and a root primitive declaring a strict schema would reject a key
10
+ * it never asked for — blanking the page over the theme rather than wearing it.
11
+ *
12
+ * So the `loom:` prefix names a **reserved namespace** ([`reserved-props.ts`](../reserved-props.ts)):
13
+ * keys under it belong to the runtime, are read here, and are removed from the
14
+ * bag before either the validator or the primitive sees it. That keeps 0049's
15
+ * other promise too — a primitive reads `var(--loom-accent)` and never learns
16
+ * which palette is mounted, which it could not claim if the palette id arrived
17
+ * in its props.
18
+ *
19
+ * Reserved keys the runtime does not recognise are dropped, and say so in a
20
+ * diagnostic: a namespace that silently swallows whatever is put in it is a
21
+ * place for data to go missing.
22
+ */
23
+ export { isReservedPropKey, partitionReservedProps, RESERVED_PROP_PREFIX, THEME_PROP_KEY, } from "../reserved-props.js";
24
+ /**
25
+ * There is no fallback theme, deliberately. A host-supplied default would mount
26
+ * a look the tree does not name, which makes the page a function of deployment
27
+ * config as well as of the tree — the failure that rejecting host-supplied
28
+ * theming outright was meant to prevent (0049). An unthemed tree renders
29
+ * unstyled, and says so.
30
+ */
31
+ export const resolveTheme = (reserved, registry) => {
32
+ const declared = reserved[THEME_PROP_KEY];
33
+ if (declared === undefined)
34
+ return { outcome: "unthemed" };
35
+ if (!registry)
36
+ return { outcome: "unregistered" };
37
+ const resolved = registry.resolve(declared);
38
+ return resolved.ok
39
+ ? { outcome: "themed", theme: resolved.value }
40
+ : { outcome: "unresolved", error: resolved.error };
41
+ };
42
+ /**
43
+ * A resolved theme as a style object the root primitive applies.
44
+ *
45
+ * React passes any `--`-prefixed key in a style object straight through to the
46
+ * element, so the custom properties reach the DOM; its `CSSProperties` type has
47
+ * no index signature to describe them. The conversion is therefore a
48
+ * types-only step, and it happens once here rather than in every primitive that
49
+ * has to apply it.
50
+ */
51
+ export const themeStyle = (theme) => themeVariables(theme);
52
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1,35 @@
1
+ import type { JsonObject } from "./json.js";
2
+ /**
3
+ * The runtime's own corner of a node's props.
4
+ *
5
+ * [0050](../decisions/0050-the-runtimes-props-are-namespaced-and-the-root-mounts-the-theme.md)
6
+ * reserved the `loom:` prefix and said what the next key would cost: "a key and
7
+ * a diagnostic rather than another record". `loom:data` is that next key, and
8
+ * the namespace moved here from `render/theme.ts` when it acquired a second
9
+ * reader — the data seam has to know which keys are the runtime's, and it is not
10
+ * part of rendering. A reserved key is a property of a node's props, so it lives
11
+ * beside `json.ts` rather than inside either of the two things that read one.
12
+ */
13
+ /** Prop keys under this prefix belong to the runtime rather than to a primitive. */
14
+ export declare const RESERVED_PROP_PREFIX = "loom:";
15
+ /** The palette, font pack and style preset a tree names, honoured on the root node (0049). */
16
+ export declare const THEME_PROP_KEY = "loom:theme";
17
+ /** A node's bindings — what it asks the host to answer, honoured on any node (0058). */
18
+ export declare const DATA_PROP_KEY = "loom:data";
19
+ /** A node's submission — which registered endpoint a form posts to, on any node (0065). */
20
+ export declare const SUBMIT_PROP_KEY = "loom:submit";
21
+ /** The fragment a node answers to, so the page's own links can point at it, on any node (0098). */
22
+ export declare const ANCHOR_PROP_KEY = "loom:anchor";
23
+ export declare const isReservedPropKey: (key: string) => boolean;
24
+ export type PartitionedProps = {
25
+ /** What the primitive and the validator see. */
26
+ readonly props: JsonObject;
27
+ /** What the runtime reads, keyed as it appears in the tree. */
28
+ readonly reserved: JsonObject;
29
+ };
30
+ /**
31
+ * Splitting costs one pass over the keys, and allocates nothing at all for the
32
+ * ordinary node that carries no reserved key — which is most of them.
33
+ */
34
+ export declare const partitionReservedProps: (props: JsonObject) => PartitionedProps;
35
+ //# sourceMappingURL=reserved-props.d.ts.map
@@ -0,0 +1,45 @@
1
+ /**
2
+ * The runtime's own corner of a node's props.
3
+ *
4
+ * [0050](../decisions/0050-the-runtimes-props-are-namespaced-and-the-root-mounts-the-theme.md)
5
+ * reserved the `loom:` prefix and said what the next key would cost: "a key and
6
+ * a diagnostic rather than another record". `loom:data` is that next key, and
7
+ * the namespace moved here from `render/theme.ts` when it acquired a second
8
+ * reader — the data seam has to know which keys are the runtime's, and it is not
9
+ * part of rendering. A reserved key is a property of a node's props, so it lives
10
+ * beside `json.ts` rather than inside either of the two things that read one.
11
+ */
12
+ /** Prop keys under this prefix belong to the runtime rather than to a primitive. */
13
+ export const RESERVED_PROP_PREFIX = "loom:";
14
+ /** The palette, font pack and style preset a tree names, honoured on the root node (0049). */
15
+ export const THEME_PROP_KEY = `${RESERVED_PROP_PREFIX}theme`;
16
+ /** A node's bindings — what it asks the host to answer, honoured on any node (0058). */
17
+ export const DATA_PROP_KEY = `${RESERVED_PROP_PREFIX}data`;
18
+ /** A node's submission — which registered endpoint a form posts to, on any node (0065). */
19
+ export const SUBMIT_PROP_KEY = `${RESERVED_PROP_PREFIX}submit`;
20
+ /** The fragment a node answers to, so the page's own links can point at it, on any node (0098). */
21
+ export const ANCHOR_PROP_KEY = `${RESERVED_PROP_PREFIX}anchor`;
22
+ export const isReservedPropKey = (key) => key.startsWith(RESERVED_PROP_PREFIX);
23
+ const NO_RESERVED_PROPS = Object.freeze({});
24
+ /**
25
+ * Splitting costs one pass over the keys, and allocates nothing at all for the
26
+ * ordinary node that carries no reserved key — which is most of them.
27
+ */
28
+ export const partitionReservedProps = (props) => {
29
+ const keys = Object.keys(props);
30
+ if (!keys.some(isReservedPropKey))
31
+ return { props, reserved: NO_RESERVED_PROPS };
32
+ const own = {};
33
+ const reserved = {};
34
+ for (const key of keys) {
35
+ const value = props[key];
36
+ if (value === undefined)
37
+ continue;
38
+ if (isReservedPropKey(key))
39
+ reserved[key] = value;
40
+ else
41
+ own[key] = value;
42
+ }
43
+ return { props: own, reserved };
44
+ };
45
+ //# sourceMappingURL=reserved-props.js.map
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Loom never throws across a module seam. Every fallible operation returns a
3
+ * Result so callers must acknowledge failure in the type system.
4
+ */
5
+ /** Either a value or an error, and the type says which until the caller checks. */
6
+ export type Result<TValue, TError> = {
7
+ readonly ok: true;
8
+ readonly value: TValue;
9
+ } | {
10
+ readonly ok: false;
11
+ readonly error: TError;
12
+ };
13
+ export declare const ok: <TValue>(value: TValue) => Result<TValue, never>;
14
+ export declare const err: <TError>(error: TError) => Result<never, TError>;
15
+ export declare const mapResult: <TValue, TNext, TError>(result: Result<TValue, TError>, transform: (value: TValue) => TNext) => Result<TNext, TError>;
16
+ export declare const flatMapResult: <TValue, TNext, TError>(result: Result<TValue, TError>, transform: (value: TValue) => Result<TNext, TError>) => Result<TNext, TError>;
17
+ /**
18
+ * Folds a sequence of fallible steps over an accumulator, short-circuiting on
19
+ * the first error. This is how atomic multi-operation deltas are applied.
20
+ */
21
+ export declare const reduceResult: <TItem, TAccumulator, TError>(items: readonly TItem[], initial: TAccumulator, step: (accumulator: TAccumulator, item: TItem, index: number) => Result<TAccumulator, TError>) => Result<TAccumulator, TError>;
22
+ /**
23
+ * Exhaustiveness guard for discriminated unions. Reaching it is a type error at
24
+ * compile time and an explicit failure at runtime.
25
+ */
26
+ export declare const assertNever: (value: never, context: string) => never;
27
+ //# sourceMappingURL=result.d.ts.map
package/dist/result.js ADDED
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Loom never throws across a module seam. Every fallible operation returns a
3
+ * Result so callers must acknowledge failure in the type system.
4
+ */
5
+ export const ok = (value) => ({ ok: true, value });
6
+ export const err = (error) => ({ ok: false, error });
7
+ export const mapResult = (result, transform) => (result.ok ? ok(transform(result.value)) : result);
8
+ export const flatMapResult = (result, transform) => (result.ok ? transform(result.value) : result);
9
+ /**
10
+ * Folds a sequence of fallible steps over an accumulator, short-circuiting on
11
+ * the first error. This is how atomic multi-operation deltas are applied.
12
+ */
13
+ export const reduceResult = (items, initial, step) => {
14
+ let accumulator = initial;
15
+ for (const [index, item] of items.entries()) {
16
+ const stepped = step(accumulator, item, index);
17
+ if (!stepped.ok)
18
+ return stepped;
19
+ accumulator = stepped.value;
20
+ }
21
+ return ok(accumulator);
22
+ };
23
+ /**
24
+ * Exhaustiveness guard for discriminated unions. Reaching it is a type error at
25
+ * compile time and an explicit failure at runtime.
26
+ */
27
+ export const assertNever = (value, context) => {
28
+ throw new Error(`${context}: unhandled variant ${JSON.stringify(value)}`);
29
+ };
30
+ //# sourceMappingURL=result.js.map
package/dist/role.d.ts ADDED
@@ -0,0 +1,71 @@
1
+ /**
2
+ * What part a primitive plays, said by the author who knows and asked by every
3
+ * consumer that needs a semantic fact about a component rather than its name.
4
+ *
5
+ * A registry can already answer what exists, what each accepts and what each
6
+ * projects. What it could not answer is anything *about* a primitive beyond its
7
+ * identifier — so a consumer wanting "which of these carries the page's title?"
8
+ * had one move available: match on the type string. The portal did exactly that
9
+ * and filed it, with the array it had to write:
10
+ *
11
+ * ```ts
12
+ * const TITLE_TYPES: readonly string[] = ["loom.heading"]
13
+ * ```
14
+ *
15
+ * That array is correct for a deployment that registered `loom.heading` and
16
+ * wrong for one that registered `acme.hero`, and nothing in the registry could
17
+ * be asked instead. A `description` is prose for a model to read and cannot be
18
+ * matched on; a type is an identifier, and an identifier is not a category.
19
+ *
20
+ * ## Why it is a role and not a boolean
21
+ *
22
+ * `submits` is a boolean because a primitive either posts or does not, and there
23
+ * is no second question of that shape. This is the opposite: the categorical
24
+ * question a host asks about a primitive is one of a family, and the members
25
+ * arrive one filed consumer at a time. A boolean per member — `isHeading`,
26
+ * `isByline` — is one more field on every definition there is, per question
27
+ * anyone ever asks. One optional field carrying a closed vocabulary grows by a
28
+ * string.
29
+ *
30
+ * ## What a role is not
31
+ *
32
+ * **It is not a position.** "The page's title" is the *first* heading in reading
33
+ * order, and which node is first is a fact about a tree, not about a primitive.
34
+ * A primitive can say it is a heading; only a tree can say which heading leads.
35
+ * Keeping those apart is what lets one declaration serve a page name, an
36
+ * outline, and a table of contents rather than only the first of them.
37
+ *
38
+ * **It is not a licence.** Nothing in the runtime renders, validates or refuses
39
+ * differently because of a role. It is read by hosts, the same way `submits` is
40
+ * read by an audit: a fact carried from the author who knows it to the consumer
41
+ * who needs it, and nowhere in between.
42
+ */
43
+ /**
44
+ * The vocabulary, and it has one member on purpose.
45
+ *
46
+ * `heading` is what was asked for, by the one consumer that filed for it. The
47
+ * members that were considered and left out — a page root, a body text, a byline
48
+ * — were all derived from what the portal happens to register rather than from a
49
+ * consumer asking a categorical question about them, and a vocabulary invented
50
+ * ahead of its readers is a vocabulary that is wrong in a way nobody can measure.
51
+ *
52
+ * The bar for a second member is the bar this one cleared: a consumer that
53
+ * cannot answer its question from the registry, written down as a finding.
54
+ */
55
+ export type PrimitiveRole = "heading";
56
+ /**
57
+ * Every role, so a host can render the vocabulary rather than keep its own copy
58
+ * of it — the same reason every other closed set in this package is exported.
59
+ */
60
+ export declare const PRIMITIVE_ROLES: readonly PrimitiveRole[];
61
+ /**
62
+ * One line per role, for a host putting the vocabulary in front of a person.
63
+ *
64
+ * Written for the author choosing a declaration rather than for the consumer
65
+ * reading one: the question at the declaration site is "is my component this?",
66
+ * and the answer has to be decidable without reading the runtime.
67
+ */
68
+ export declare const describePrimitiveRole: (role: PrimitiveRole) => string;
69
+ /** Whether a string a host wrote is a role the runtime knows. */
70
+ export declare const isPrimitiveRole: (value: string) => value is PrimitiveRole;
71
+ //# sourceMappingURL=role.d.ts.map
package/dist/role.js ADDED
@@ -0,0 +1,22 @@
1
+ import { everyMemberOf } from "./closed-set.js";
2
+ /**
3
+ * Every role, so a host can render the vocabulary rather than keep its own copy
4
+ * of it — the same reason every other closed set in this package is exported.
5
+ */
6
+ export const PRIMITIVE_ROLES = everyMemberOf()(["heading"]);
7
+ /**
8
+ * One line per role, for a host putting the vocabulary in front of a person.
9
+ *
10
+ * Written for the author choosing a declaration rather than for the consumer
11
+ * reading one: the question at the declaration site is "is my component this?",
12
+ * and the answer has to be decidable without reading the runtime.
13
+ */
14
+ export const describePrimitiveRole = (role) => {
15
+ switch (role) {
16
+ case "heading":
17
+ return "names the section it heads — the text a reader takes as the title of what follows";
18
+ }
19
+ };
20
+ /** Whether a string a host wrote is a role the runtime knows. */
21
+ export const isPrimitiveRole = (value) => PRIMITIVE_ROLES.includes(value);
22
+ //# sourceMappingURL=role.js.map