@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,500 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { sequentialIdFactory, treeIdSchema } from "../ids.js";
3
+ import { buildElement } from "../tree/builders.js";
4
+ import { createTree } from "../tree/tree.js";
5
+ import { FIXED_INSTANT } from "./doubles.js";
6
+ import { sampleTree } from "./fixtures.js";
7
+ /**
8
+ * One suite, run against every `TreeStore`.
9
+ *
10
+ * `memory.ts` has described itself as "the reference implementation ... what a
11
+ * SQL or KV implementation will be checked against" since the day it was written.
12
+ * That was a promise; this is what makes it true. A behavioural disagreement
13
+ * between the in-memory store and Postgres is now a test failure rather than
14
+ * something discovered in production.
15
+ *
16
+ * Only behaviour the *contract* promises belongs here. Anything specific to one
17
+ * implementation — how it reports a connection failure, what it exposes beyond
18
+ * the interface — stays in that implementation's own test file.
19
+ */
20
+ export const appendOf = (delta, proposal = "p_1") => ({
21
+ proposalId: proposal,
22
+ delta,
23
+ provenance: {
24
+ origin: "user-instruction",
25
+ interpreter: "scripted",
26
+ authoredBy: "model",
27
+ confidence: 0.9,
28
+ interpretedAt: FIXED_INSTANT,
29
+ },
30
+ appliedAt: FIXED_INSTANT,
31
+ });
32
+ export const removalOf = (tree, nodeId, baseRevision = tree.revision) => ({
33
+ deltaId: sequentialIdFactory("s").deltaId(),
34
+ treeId: tree.treeId,
35
+ baseRevision,
36
+ operations: [{ op: "remove", nodeId: nodeId }],
37
+ });
38
+ /** A tree that exists and has never been changed — not the same as no tree. */
39
+ const EMPTY_LOG = { revisions: [], older: null, newer: null };
40
+ export const treeNamed = (namespace) => {
41
+ const ids = sequentialIdFactory(namespace);
42
+ return createTree(buildElement(ids, { type: "loom.page" }), ids);
43
+ };
44
+ /**
45
+ * A delta that reconfigures one node, so a test can append as many as it likes
46
+ * to the same tree. Removals run out of nodes; reconfiguring a title does not.
47
+ */
48
+ const retitle = (tree, nodeId, baseRevision, title) => ({
49
+ deltaId: sequentialIdFactory("s").deltaId(),
50
+ treeId: tree.treeId,
51
+ baseRevision,
52
+ operations: [{ op: "configure", nodeId, set: { title }, unset: [] }],
53
+ });
54
+ /** A tree with `count` entries in its log, appended one at a time from revision 0. */
55
+ const treeWithLog = async (store, count) => {
56
+ const { tree, ids } = sampleTree();
57
+ await store.create(tree);
58
+ for (const revision of Array.from({ length: count }, (_, index) => index)) {
59
+ await store.append(tree.treeId, appendOf(retitle(tree, ids.page, revision, `title ${revision + 1}`), `p_${revision + 1}`));
60
+ }
61
+ return tree;
62
+ };
63
+ const revisionNumbers = (page) => page.ok ? page.value.revisions.map((stored) => stored.revision) : [];
64
+ /**
65
+ * `makeStore` returns a store with nothing in it. Each test gets its own, so the
66
+ * suite never depends on the order it runs in.
67
+ */
68
+ export const describeTreeStoreContract = (name, makeStore) => {
69
+ const freshStore = async () => await makeStore();
70
+ describe(`${name} — TreeStore contract`, () => {
71
+ it("stores a tree once and reads it back at revision 0 with an empty log", async () => {
72
+ const { tree } = sampleTree();
73
+ const store = await freshStore();
74
+ expect((await store.create(tree)).ok).toBe(true);
75
+ expect(await store.head(tree.treeId)).toEqual({ ok: true, value: tree });
76
+ expect(await store.revisions(tree.treeId)).toEqual({ ok: true, value: EMPTY_LOG });
77
+ });
78
+ it("refuses to create the same tree twice", async () => {
79
+ const { tree } = sampleTree();
80
+ const store = await freshStore();
81
+ await store.create(tree);
82
+ expect(await store.create(tree)).toEqual({
83
+ ok: false,
84
+ error: { code: "already-exists", treeId: tree.treeId },
85
+ });
86
+ });
87
+ it("distinguishes a tree it does not have from one with no history", async () => {
88
+ const store = await freshStore();
89
+ const absent = treeIdSchema.parse("t_absent");
90
+ expect(await store.head(absent)).toEqual({
91
+ ok: false,
92
+ error: { code: "not-found", treeId: absent },
93
+ });
94
+ expect(await store.revisions(absent)).toEqual({
95
+ ok: false,
96
+ error: { code: "not-found", treeId: absent },
97
+ });
98
+ });
99
+ it("advances the snapshot and appends to the log in one step", async () => {
100
+ const { tree, ids } = sampleTree();
101
+ const store = await freshStore();
102
+ await store.create(tree);
103
+ const appended = await store.append(tree.treeId, appendOf(removalOf(tree, ids.footer)));
104
+ expect(appended.ok && appended.value.revision).toBe(1);
105
+ const head = await store.head(tree.treeId);
106
+ const log = await store.revisions(tree.treeId);
107
+ expect(head.ok && head.value.revision).toBe(1);
108
+ expect(log.ok && log.value.revisions).toHaveLength(1);
109
+ expect(log.ok && log.value.revisions[0]?.revision).toBe(1);
110
+ expect(log.ok && log.value.revisions[0]?.provenance.interpreter).toBe("scripted");
111
+ expect(log.ok && log.value.revisions[0]?.appliedAt).toBe(FIXED_INSTANT);
112
+ });
113
+ /**
114
+ * Who allowed a change (0029). Both stores have to agree on the *absence* as well as the value: a
115
+ * null column and an absent key must read back the same, or the two
116
+ * implementations differ on what an unapproved change looks like.
117
+ */
118
+ it("keeps who allowed a change, and keeps it absent when nobody had to", async () => {
119
+ const { tree, ids } = sampleTree();
120
+ const store = await freshStore();
121
+ await store.create(tree);
122
+ await store.append(tree.treeId, appendOf(removalOf(tree, ids.footer)));
123
+ await store.append(tree.treeId, {
124
+ ...appendOf(removalOf(tree, ids.header, 1), "p_2"),
125
+ answeredBy: "reviewer:ana",
126
+ });
127
+ const log = await store.revisions(tree.treeId);
128
+ if (!log.ok)
129
+ throw new Error("expected a log");
130
+ expect(log.value.revisions.map((stored) => stored.answeredBy)).toEqual([
131
+ undefined,
132
+ "reviewer:ana",
133
+ ]);
134
+ expect("answeredBy" in (log.value.revisions[0] ?? {})).toBe(false);
135
+ });
136
+ /** The whole of concurrency control, stated once for every implementation. */
137
+ it("refuses a delta whose base revision is not the head, and says which is which", async () => {
138
+ const { tree, ids } = sampleTree();
139
+ const store = await freshStore();
140
+ await store.create(tree);
141
+ await store.append(tree.treeId, appendOf(removalOf(tree, ids.footer)));
142
+ expect(await store.append(tree.treeId, appendOf(removalOf(tree, ids.header, 0)))).toEqual({
143
+ ok: false,
144
+ error: { code: "revision-conflict", treeId: tree.treeId, expected: 0, found: 1 },
145
+ });
146
+ });
147
+ it("reports a delta that does not apply as rejected, not as a conflict", async () => {
148
+ const { tree } = sampleTree();
149
+ const store = await freshStore();
150
+ await store.create(tree);
151
+ const missing = await store.append(tree.treeId, appendOf(removalOf(tree, "n_999")));
152
+ expect(missing.ok).toBe(false);
153
+ expect(missing.ok ? "" : missing.error.code).toBe("delta-rejected");
154
+ });
155
+ /** The atomicity the store promises, asserted from the outside (0016). */
156
+ it("leaves the snapshot and the log untouched when an append is refused", async () => {
157
+ const { tree } = sampleTree();
158
+ const store = await freshStore();
159
+ await store.create(tree);
160
+ await store.append(tree.treeId, appendOf(removalOf(tree, "n_999")));
161
+ expect(await store.head(tree.treeId)).toEqual({ ok: true, value: tree });
162
+ expect(await store.revisions(tree.treeId)).toEqual({ ok: true, value: EMPTY_LOG });
163
+ });
164
+ it("refuses to append to a tree it does not have", async () => {
165
+ const { tree } = sampleTree();
166
+ const store = await freshStore();
167
+ expect(await store.append(tree.treeId, appendOf(removalOf(tree, "n_1")))).toEqual({
168
+ ok: false,
169
+ error: { code: "not-found", treeId: tree.treeId },
170
+ });
171
+ });
172
+ it("keeps trees separate", async () => {
173
+ const store = await freshStore();
174
+ const first = sampleTree().tree;
175
+ const second = treeNamed("o");
176
+ await store.create(first);
177
+ await store.create(second);
178
+ expect((await store.head(second.treeId)).ok).toBe(true);
179
+ expect((await store.head(first.treeId)).ok && first.treeId).not.toBe(second.treeId);
180
+ });
181
+ describe("list", () => {
182
+ it("orders by tree id rather than by insertion", async () => {
183
+ const store = await freshStore();
184
+ for (const namespace of ["c", "a", "b"])
185
+ await store.create(treeNamed(namespace));
186
+ const page = await store.list();
187
+ expect(page.ok && page.value.trees.map((listing) => listing.treeId)).toEqual([
188
+ "t_a1",
189
+ "t_b1",
190
+ "t_c1",
191
+ ]);
192
+ });
193
+ it("reports the revision, which is also the length of the log", async () => {
194
+ const { tree, ids } = sampleTree();
195
+ const store = await freshStore();
196
+ await store.create(tree);
197
+ await store.append(tree.treeId, appendOf(removalOf(tree, ids.footer)));
198
+ expect((await store.list()).ok && (await store.list())).toEqual({
199
+ ok: true,
200
+ value: { trees: [{ treeId: tree.treeId, revision: 1 }], cursor: null },
201
+ });
202
+ });
203
+ it("is empty with a null cursor when nothing is stored", async () => {
204
+ const store = await freshStore();
205
+ expect(await store.list()).toEqual({ ok: true, value: { trees: [], cursor: null } });
206
+ });
207
+ it("hands back a cursor only while there is another page", async () => {
208
+ const store = await freshStore();
209
+ for (const namespace of ["a", "b", "c"])
210
+ await store.create(treeNamed(namespace));
211
+ const first = await store.list({ limit: 2 });
212
+ expect(first.ok && first.value.trees.map((l) => l.treeId)).toEqual(["t_a1", "t_b1"]);
213
+ expect(first.ok && first.value.cursor).toBe("t_b1");
214
+ const cursor = first.ok ? first.value.cursor : null;
215
+ const second = await store.list(cursor === null ? {} : { cursor });
216
+ expect(second.ok && second.value.trees.map((l) => l.treeId)).toEqual(["t_c1"]);
217
+ expect(second.ok && second.value.cursor).toBeNull();
218
+ });
219
+ /** A page that exactly empties the store must not promise another one. */
220
+ it("does not hand back a cursor when the page ends on the last tree", async () => {
221
+ const store = await freshStore();
222
+ for (const namespace of ["a", "b"])
223
+ await store.create(treeNamed(namespace));
224
+ const page = await store.list({ limit: 2 });
225
+ expect(page.ok && page.value.trees).toHaveLength(2);
226
+ expect(page.ok && page.value.cursor).toBeNull();
227
+ });
228
+ /**
229
+ * A cursor names a position, not a row. A tree deleted between two pages
230
+ * must not strand the caller — keyset pagination gets this right and
231
+ * offset pagination does not, which is why the cursor is a tree id.
232
+ */
233
+ it("resumes after a cursor that names no stored tree", async () => {
234
+ const store = await freshStore();
235
+ for (const namespace of ["a", "c"])
236
+ await store.create(treeNamed(namespace));
237
+ const page = await store.list({ cursor: "t_b1" });
238
+ expect(page.ok && page.value.trees.map((l) => l.treeId)).toEqual(["t_c1"]);
239
+ });
240
+ it("clamps a limit the caller should not get, rather than honouring it", async () => {
241
+ const store = await freshStore();
242
+ for (const namespace of ["a", "b", "c"])
243
+ await store.create(treeNamed(namespace));
244
+ const page = await store.list({ limit: 0 });
245
+ expect(page.ok && page.value.trees).toHaveLength(1);
246
+ });
247
+ });
248
+ /**
249
+ * The log is read a page at a time, from either end (0026). These are the
250
+ * same promises made about the telemetry journal (0025), asserted here for
251
+ * the log because the two are separate contracts that happen to agree.
252
+ */
253
+ describe("revisions", () => {
254
+ it("reads forward from the oldest entry by default", async () => {
255
+ const store = await freshStore();
256
+ const tree = await treeWithLog(store, 5);
257
+ expect(revisionNumbers(await store.revisions(tree.treeId, { limit: 3 }))).toEqual([1, 2, 3]);
258
+ });
259
+ it("reads the newest entries when asked for the older end", async () => {
260
+ const store = await freshStore();
261
+ const tree = await treeWithLog(store, 5);
262
+ expect(revisionNumbers(await store.revisions(tree.treeId, { direction: "older", limit: 2 }))).toEqual([4, 5]);
263
+ });
264
+ /**
265
+ * The whole reason a direction exists: a page taken from the newest end
266
+ * still arrives in applied order, so `replayTree` and every reader can fold
267
+ * it without knowing which end it came from.
268
+ */
269
+ it("returns a backwards page in applied order", async () => {
270
+ const store = await freshStore();
271
+ const tree = await treeWithLog(store, 4);
272
+ const page = await store.revisions(tree.treeId, { direction: "older", limit: 3 });
273
+ expect(revisionNumbers(page)).toEqual([2, 3, 4]);
274
+ });
275
+ it("names both ends of a page, and only the ends that exist", async () => {
276
+ const store = await freshStore();
277
+ const tree = await treeWithLog(store, 3);
278
+ const newest = await store.revisions(tree.treeId, { direction: "older", limit: 2 });
279
+ expect(newest.ok && newest.value.older).toBe("2");
280
+ expect(newest.ok && newest.value.newer).toBeNull();
281
+ const oldest = await store.revisions(tree.treeId, { limit: 2 });
282
+ expect(oldest.ok && oldest.value.older).toBeNull();
283
+ expect(oldest.ok && oldest.value.newer).toBe("2");
284
+ });
285
+ it("walks a whole log backwards and reassembles it", async () => {
286
+ const store = await freshStore();
287
+ const tree = await treeWithLog(store, 5);
288
+ const first = await store.revisions(tree.treeId, { direction: "older", limit: 2 });
289
+ const firstCursor = first.ok ? first.value.older : null;
290
+ const second = await store.revisions(tree.treeId, {
291
+ direction: "older",
292
+ limit: 2,
293
+ ...(firstCursor === null ? {} : { cursor: firstCursor }),
294
+ });
295
+ const secondCursor = second.ok ? second.value.older : null;
296
+ const third = await store.revisions(tree.treeId, {
297
+ direction: "older",
298
+ limit: 2,
299
+ ...(secondCursor === null ? {} : { cursor: secondCursor }),
300
+ });
301
+ expect([
302
+ ...revisionNumbers(third),
303
+ ...revisionNumbers(second),
304
+ ...revisionNumbers(first),
305
+ ]).toEqual([1, 2, 3, 4, 5]);
306
+ expect(third.ok && third.value.older).toBeNull();
307
+ });
308
+ /** A resumed page names the end it came from, so paging is reversible. */
309
+ it("names the newer end of a resumed backwards page", async () => {
310
+ const store = await freshStore();
311
+ const tree = await treeWithLog(store, 4);
312
+ const first = await store.revisions(tree.treeId, { direction: "older", limit: 2 });
313
+ const cursor = first.ok ? first.value.older : null;
314
+ const second = await store.revisions(tree.treeId, {
315
+ direction: "older",
316
+ limit: 2,
317
+ ...(cursor === null ? {} : { cursor }),
318
+ });
319
+ expect(revisionNumbers(second)).toEqual([1, 2]);
320
+ expect(second.ok && second.value.newer).toBe("2");
321
+ const back = await store.revisions(tree.treeId, {
322
+ limit: 2,
323
+ ...(second.ok && second.value.newer !== null ? { cursor: second.value.newer } : {}),
324
+ });
325
+ expect(revisionNumbers(back)).toEqual(revisionNumbers(first));
326
+ });
327
+ /**
328
+ * Reversibility is not one step. A reader who has walked to the oldest end
329
+ * of a long log walks back out of it the same way they came in, and every
330
+ * page on the way has to name the end they are still moving toward — not
331
+ * only the first one, which is the only case a single step ever exercises.
332
+ */
333
+ it("walks a whole log forwards again and reassembles it", async () => {
334
+ const store = await freshStore();
335
+ const tree = await treeWithLog(store, 5);
336
+ const oldest = await store.revisions(tree.treeId, { direction: "newer", limit: 2 });
337
+ const firstCursor = oldest.ok ? oldest.value.newer : null;
338
+ const second = await store.revisions(tree.treeId, {
339
+ direction: "newer",
340
+ limit: 2,
341
+ ...(firstCursor === null ? {} : { cursor: firstCursor }),
342
+ });
343
+ const secondCursor = second.ok ? second.value.newer : null;
344
+ const third = await store.revisions(tree.treeId, {
345
+ direction: "newer",
346
+ limit: 2,
347
+ ...(secondCursor === null ? {} : { cursor: secondCursor }),
348
+ });
349
+ expect([
350
+ ...revisionNumbers(oldest),
351
+ ...revisionNumbers(second),
352
+ ...revisionNumbers(third),
353
+ ]).toEqual([1, 2, 3, 4, 5]);
354
+ expect(third.ok && third.value.newer).toBeNull();
355
+ });
356
+ /**
357
+ * A page reached by moving forwards has entries behind it by construction —
358
+ * the cursor it resumed from came off one. A reader who steps forward and
359
+ * then changes their mind must not find the way back missing.
360
+ */
361
+ it("names the older end of a resumed forwards page", async () => {
362
+ const store = await freshStore();
363
+ const tree = await treeWithLog(store, 4);
364
+ const oldest = await store.revisions(tree.treeId, { direction: "newer", limit: 2 });
365
+ const cursor = oldest.ok ? oldest.value.newer : null;
366
+ const forward = await store.revisions(tree.treeId, {
367
+ direction: "newer",
368
+ limit: 2,
369
+ ...(cursor === null ? {} : { cursor }),
370
+ });
371
+ expect(revisionNumbers(forward)).toEqual([3, 4]);
372
+ expect(forward.ok && forward.value.older).toBe("3");
373
+ const back = await store.revisions(tree.treeId, {
374
+ direction: "older",
375
+ limit: 2,
376
+ ...(forward.ok && forward.value.older !== null ? { cursor: forward.value.older } : {}),
377
+ });
378
+ expect(revisionNumbers(back)).toEqual(revisionNumbers(oldest));
379
+ });
380
+ /**
381
+ * The step a reader takes after arriving at a revision a link named. The
382
+ * anchored page is not an end of the log, so it has entries on both sides,
383
+ * and the cursor it reports for its newer end has to resume like any other.
384
+ */
385
+ it("steps forward from an anchored page", async () => {
386
+ const store = await freshStore();
387
+ const tree = await treeWithLog(store, 5);
388
+ const anchored = await store.revisions(tree.treeId, {
389
+ direction: "older",
390
+ limit: 2,
391
+ at: 3,
392
+ });
393
+ expect(revisionNumbers(anchored)).toEqual([2, 3]);
394
+ const cursor = anchored.ok ? anchored.value.newer : null;
395
+ expect(cursor).not.toBeNull();
396
+ const forward = await store.revisions(tree.treeId, {
397
+ direction: "newer",
398
+ limit: 2,
399
+ ...(cursor === null ? {} : { cursor }),
400
+ });
401
+ expect(revisionNumbers(forward)).toEqual([4, 5]);
402
+ });
403
+ it("clamps a limit the caller should not get, rather than honouring it", async () => {
404
+ const store = await freshStore();
405
+ const tree = await treeWithLog(store, 3);
406
+ expect(revisionNumbers(await store.revisions(tree.treeId, { limit: 0 }))).toHaveLength(1);
407
+ });
408
+ /**
409
+ * A revision a caller names is a position it may open at (0043). The
410
+ * property that distinguishes it from a cursor is inclusion: a reader sent
411
+ * to revision 3 is there to read revision 3.
412
+ */
413
+ describe("opening at a named revision", () => {
414
+ it("includes the revision it was pointed at, at the newest end", async () => {
415
+ const store = await freshStore();
416
+ const tree = await treeWithLog(store, 6);
417
+ expect(revisionNumbers(await store.revisions(tree.treeId, { at: 4, direction: "older", limit: 3 }))).toEqual([2, 3, 4]);
418
+ });
419
+ it("includes it at the oldest end when reading forward", async () => {
420
+ const store = await freshStore();
421
+ const tree = await treeWithLog(store, 6);
422
+ expect(revisionNumbers(await store.revisions(tree.treeId, { at: 4, limit: 3 }))).toEqual([
423
+ 4, 5, 6,
424
+ ]);
425
+ });
426
+ it("names the end the anchor leaves entries on", async () => {
427
+ const store = await freshStore();
428
+ const tree = await treeWithLog(store, 6);
429
+ const page = await store.revisions(tree.treeId, { at: 4, direction: "older", limit: 2 });
430
+ expect(revisionNumbers(page)).toEqual([3, 4]);
431
+ expect(page.ok && page.value.older).toBe("3");
432
+ expect(page.ok && page.value.newer).toBe("4");
433
+ });
434
+ /**
435
+ * The case a cursor cannot produce and an anchor can: the newest entry.
436
+ * `resumed` is true for any cursor, because a cursor came from a page —
437
+ * an anchor is inside its own page, so claiming a newer end here would
438
+ * offer a reader a page that does not exist.
439
+ */
440
+ it("claims no newer end when pointed at the newest entry", async () => {
441
+ const store = await freshStore();
442
+ const tree = await treeWithLog(store, 3);
443
+ const page = await store.revisions(tree.treeId, { at: 3, direction: "older", limit: 2 });
444
+ expect(revisionNumbers(page)).toEqual([2, 3]);
445
+ expect(page.ok && page.value.newer).toBeNull();
446
+ });
447
+ it("claims no older end when pointed forward at the first entry", async () => {
448
+ const store = await freshStore();
449
+ const tree = await treeWithLog(store, 3);
450
+ const page = await store.revisions(tree.treeId, { at: 1, limit: 2 });
451
+ expect(revisionNumbers(page)).toEqual([1, 2]);
452
+ expect(page.ok && page.value.older).toBeNull();
453
+ });
454
+ /**
455
+ * A revision no entry holds is a stale link, not a broken store. Reading
456
+ * older from beyond the end is the newest page, and reading older from
457
+ * before the start is empty — both are what the position means.
458
+ */
459
+ it("answers a revision the log does not hold with the entries on that side", async () => {
460
+ const store = await freshStore();
461
+ const tree = await treeWithLog(store, 3);
462
+ const beyond = await store.revisions(tree.treeId, {
463
+ at: 99,
464
+ direction: "older",
465
+ limit: 2,
466
+ });
467
+ expect(revisionNumbers(beyond)).toEqual([2, 3]);
468
+ expect(beyond.ok && beyond.value.newer).toBeNull();
469
+ const before = await store.revisions(tree.treeId, { at: 0, direction: "older" });
470
+ expect(revisionNumbers(before)).toEqual([]);
471
+ });
472
+ /** The page a cursor would have produced, reached without holding one. */
473
+ it("agrees with the cursor that names the same position", async () => {
474
+ const store = await freshStore();
475
+ const tree = await treeWithLog(store, 6);
476
+ const anchored = await store.revisions(tree.treeId, {
477
+ at: 4,
478
+ direction: "older",
479
+ limit: 2,
480
+ });
481
+ const cursored = await store.revisions(tree.treeId, {
482
+ cursor: "5",
483
+ direction: "older",
484
+ limit: 2,
485
+ });
486
+ expect(revisionNumbers(anchored)).toEqual(revisionNumbers(cursored));
487
+ });
488
+ });
489
+ it("keeps one tree's log out of another's", async () => {
490
+ const store = await freshStore();
491
+ const mine = await treeWithLog(store, 2);
492
+ const other = treeNamed("o");
493
+ await store.create(other);
494
+ expect(revisionNumbers(await store.revisions(mine.treeId))).toEqual([1, 2]);
495
+ expect(revisionNumbers(await store.revisions(other.treeId))).toEqual([]);
496
+ });
497
+ });
498
+ });
499
+ };
500
+ //# sourceMappingURL=store-contract.js.map
@@ -0,0 +1,17 @@
1
+ import { type ResolvedTheme } from "./theme.js";
2
+ /**
3
+ * A resolved theme, flattened into CSS custom properties.
4
+ *
5
+ * Pure, like the renderer it feeds: the same theme always produces the same
6
+ * variables, so two requests for one revision cannot disagree about what the
7
+ * page looks like any more than they can disagree about what it contains.
8
+ *
9
+ * CSS variables rather than class names or inline styles on every node, for one
10
+ * reason that matters downstream: a primitive reads `var(--loom-accent)` without
11
+ * knowing which palette is mounted, so re-theming a tree changes nothing about
12
+ * the tree and touches no primitive. A theme change is one `configure` on the
13
+ * root, and every node below re-reads through the cascade.
14
+ */
15
+ export type ThemeVariables = Readonly<Record<string, string>>;
16
+ export declare const themeVariables: (theme: ResolvedTheme) => ThemeVariables;
17
+ //# sourceMappingURL=apply.d.ts.map
@@ -0,0 +1,60 @@
1
+ import { chromaValue, paletteMeasures } from "./measure.js";
2
+ import { PALETTE_SLOTS } from "./theme.js";
3
+ export const themeVariables = (theme) => {
4
+ const variables = {};
5
+ for (const slot of PALETTE_SLOTS) {
6
+ const value = theme.palette.slots[slot];
7
+ if (value !== undefined)
8
+ variables[`--loom-${slot}`] = value;
9
+ }
10
+ /**
11
+ * What the palette is, beside what it holds (0131).
12
+ *
13
+ * Derived, so a host palette gets them without declaring anything and a
14
+ * re-theme changes them with everything else. Omitted rather than defaulted
15
+ * where a colour could not be measured, for the reason `--loom-mono-family` is
16
+ * omitted: a primitive supplies its own `var()` fallback, and a default
17
+ * written here would put this file's guess above the palette's silence.
18
+ */
19
+ const measures = paletteMeasures(theme.palette);
20
+ for (const [slot, chroma] of Object.entries(measures.chroma)) {
21
+ variables[`--loom-${slot}-chroma`] = chromaValue(chroma);
22
+ }
23
+ const { scrim } = measures;
24
+ const scrimGround = scrim && theme.palette.slots[scrim.ground];
25
+ const scrimInk = scrim && theme.palette.slots[scrim.foreground];
26
+ if (scrimGround !== undefined && scrimInk !== undefined) {
27
+ variables["--loom-scrim"] = scrimGround;
28
+ variables["--loom-scrim-fg"] = scrimInk;
29
+ }
30
+ variables["--loom-heading-family"] = theme.fontPack.headingFamily;
31
+ variables["--loom-body-family"] = theme.fontPack.bodyFamily;
32
+ /**
33
+ * Omitted rather than defaulted when the pack declares none. The primitive
34
+ * asking for it supplies the system stack as its `var()` fallback, so an
35
+ * absent variable resolves to a real face; writing a default here would
36
+ * instead put this file's opinion about monospace above the reader's (0085).
37
+ */
38
+ if (theme.fontPack.monoFamily) {
39
+ variables["--loom-mono-family"] = theme.fontPack.monoFamily;
40
+ }
41
+ variables["--loom-heading-weight"] = String(theme.fontPack.headingWeight);
42
+ variables["--loom-body-weight"] = String(theme.fontPack.bodyWeight);
43
+ theme.fontPack.scaleRamp.forEach((step, index) => {
44
+ variables[`--loom-scale-${index + 1}`] = `${step}px`;
45
+ });
46
+ const { radii, spacingScale, motion, density } = theme.stylePreset;
47
+ variables["--loom-radius-sm"] = `${radii.sm}px`;
48
+ variables["--loom-radius-md"] = `${radii.md}px`;
49
+ variables["--loom-radius-lg"] = `${radii.lg}px`;
50
+ variables["--loom-radius-full"] = `${radii.full}px`;
51
+ spacingScale.forEach((step, index) => {
52
+ variables[`--loom-spacing-${index + 1}`] = `${step}px`;
53
+ });
54
+ variables["--loom-motion-fast"] = `${motion.fast}ms`;
55
+ variables["--loom-motion-medium"] = `${motion.medium}ms`;
56
+ variables["--loom-motion-slow"] = `${motion.slow}ms`;
57
+ variables["--loom-density"] = density;
58
+ return variables;
59
+ };
60
+ //# sourceMappingURL=apply.js.map