@jam-overture/loom 0.1.0 → 0.3.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 (414) hide show
  1. package/README.md +3 -1
  2. package/dist/application/application.d.ts +109 -0
  3. package/dist/application/application.js +97 -0
  4. package/dist/application/memory.d.ts +20 -0
  5. package/dist/application/memory.js +79 -0
  6. package/dist/application/store.d.ts +101 -0
  7. package/dist/application/store.js +25 -0
  8. package/dist/audience/audience.d.ts +36 -0
  9. package/dist/audience/audience.js +41 -0
  10. package/dist/audience/compose.d.ts +112 -0
  11. package/dist/audience/compose.js +134 -0
  12. package/dist/audience/memory.d.ts +14 -0
  13. package/dist/audience/memory.js +71 -0
  14. package/dist/audience/overlay-store.d.ts +343 -0
  15. package/dist/audience/overlay-store.js +217 -0
  16. package/dist/audience/rule.d.ts +121 -0
  17. package/dist/audience/rule.js +78 -0
  18. package/dist/cli/index.d.ts +3 -4
  19. package/dist/cli/index.js +3 -4
  20. package/dist/cli/templates.js +19 -0
  21. package/dist/data/adapter.d.ts +9 -1
  22. package/dist/data/adapter.js +2 -0
  23. package/dist/data/plan.js +0 -0
  24. package/dist/data/resolution.d.ts +23 -1
  25. package/dist/data/resolve.d.ts +31 -4
  26. package/dist/data/resolve.js +11 -3
  27. package/dist/ids.d.ts +10 -0
  28. package/dist/ids.js +11 -1
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.js +1 -0
  31. package/dist/interpretation/anthropic.d.ts +1 -1
  32. package/dist/interpretation/anthropic.js +2 -22
  33. package/dist/interpretation/client.d.ts +1 -1
  34. package/dist/interpretation/materialize.js +67 -22
  35. package/dist/interpretation/openai-compatible.d.ts +36 -0
  36. package/dist/interpretation/openai-compatible.js +79 -0
  37. package/dist/interpretation/status.d.ts +19 -0
  38. package/dist/interpretation/status.js +26 -0
  39. package/dist/live/index.d.ts +73 -0
  40. package/dist/live/index.js +73 -0
  41. package/dist/live/pages.d.ts +187 -0
  42. package/dist/live/pages.js +161 -0
  43. package/dist/live/pull.d.ts +147 -0
  44. package/dist/live/pull.js +398 -0
  45. package/dist/live/pulling.d.ts +79 -0
  46. package/dist/live/pulling.js +117 -0
  47. package/dist/live/window.d.ts +129 -0
  48. package/dist/live/window.js +132 -0
  49. package/dist/patch.d.ts +54 -0
  50. package/dist/patch.js +44 -0
  51. package/dist/project/closing.d.ts +51 -0
  52. package/dist/project/closing.js +53 -0
  53. package/dist/project/memory.d.ts +20 -0
  54. package/dist/project/memory.js +97 -0
  55. package/dist/project/project.d.ts +90 -0
  56. package/dist/project/project.js +91 -0
  57. package/dist/project/store.d.ts +135 -0
  58. package/dist/project/store.js +41 -0
  59. package/dist/registered.d.ts +64 -0
  60. package/dist/registered.js +118 -0
  61. package/dist/render/addressed.d.ts +35 -0
  62. package/dist/render/addressed.js +79 -0
  63. package/dist/render/behaviour-adjust.d.ts +11 -19
  64. package/dist/render/behaviour-adjust.js +75 -21
  65. package/dist/render/behaviour-present.d.ts +8 -0
  66. package/dist/render/behaviour-present.js +57 -6
  67. package/dist/render/behaviour.d.ts +98 -17
  68. package/dist/render/behaviour.js +91 -26
  69. package/dist/render/control-name.d.ts +68 -0
  70. package/dist/render/control-name.js +37 -0
  71. package/dist/render/diagnostics.d.ts +72 -0
  72. package/dist/render/diagnostics.js +7 -0
  73. package/dist/render/document-theme.d.ts +70 -0
  74. package/dist/render/document-theme.js +139 -0
  75. package/dist/render/editable.d.ts +15 -1
  76. package/dist/render/editable.js +13 -1
  77. package/dist/render/expected.d.ts +98 -0
  78. package/dist/render/expected.js +88 -0
  79. package/dist/render/index.d.ts +4 -0
  80. package/dist/render/index.js +4 -0
  81. package/dist/render/reads.d.ts +11 -0
  82. package/dist/render/reads.js +12 -1
  83. package/dist/render/render.d.ts +11 -0
  84. package/dist/render/render.js +294 -53
  85. package/dist/render/request.d.ts +8 -1
  86. package/dist/render/request.js +1 -0
  87. package/dist/render/slots.d.ts +52 -0
  88. package/dist/render/slots.js +24 -0
  89. package/dist/render/theme.d.ts +54 -1
  90. package/dist/render/theme.js +23 -1
  91. package/dist/render/unshown.d.ts +152 -0
  92. package/dist/render/unshown.js +80 -0
  93. package/dist/runtime/analysis.d.ts +94 -9
  94. package/dist/runtime/analysis.js +54 -9
  95. package/dist/runtime/assessment.d.ts +36 -2
  96. package/dist/runtime/assessment.js +27 -2
  97. package/dist/runtime/auto-apply-ceiling.d.ts +54 -0
  98. package/dist/runtime/auto-apply-ceiling.js +66 -0
  99. package/dist/runtime/checks.d.ts +148 -0
  100. package/dist/runtime/checks.js +112 -0
  101. package/dist/runtime/disposition.d.ts +96 -0
  102. package/dist/runtime/disposition.js +46 -0
  103. package/dist/runtime/gate.js +91 -10
  104. package/dist/runtime/index.d.ts +4 -0
  105. package/dist/runtime/index.js +4 -0
  106. package/dist/runtime/irreversibility.d.ts +64 -0
  107. package/dist/runtime/irreversibility.js +45 -0
  108. package/dist/runtime/nesting.d.ts +13 -1
  109. package/dist/runtime/nesting.js +41 -24
  110. package/dist/runtime/pipeline.d.ts +43 -0
  111. package/dist/runtime/pipeline.js +10 -2
  112. package/dist/runtime/policy-change.d.ts +93 -0
  113. package/dist/runtime/policy-change.js +305 -0
  114. package/dist/runtime/policy-log.d.ts +406 -0
  115. package/dist/runtime/policy-log.js +285 -0
  116. package/dist/runtime/policy.d.ts +8 -6
  117. package/dist/runtime/policy.js +5 -2
  118. package/dist/runtime/repointing.js +0 -0
  119. package/dist/runtime/reversibility.d.ts +11 -9
  120. package/dist/runtime/stakes.d.ts +129 -1
  121. package/dist/runtime/stakes.js +240 -26
  122. package/dist/runtime/vocabulary.d.ts +164 -7
  123. package/dist/runtime/vocabulary.js +181 -8
  124. package/dist/sdk/audit.d.ts +174 -3
  125. package/dist/sdk/audit.js +176 -17
  126. package/dist/sdk/catalogue.d.ts +9 -1
  127. package/dist/sdk/conformance.d.ts +37 -3
  128. package/dist/sdk/conformance.js +25 -4
  129. package/dist/sdk/definition.d.ts +129 -5
  130. package/dist/sdk/definition.js +66 -0
  131. package/dist/sdk/registry.d.ts +45 -2
  132. package/dist/sdk/registry.js +102 -1
  133. package/dist/signals/acted.contract.d.ts +21 -0
  134. package/dist/signals/acted.contract.js +236 -0
  135. package/dist/signals/acted.d.ts +359 -0
  136. package/dist/signals/acted.js +135 -0
  137. package/dist/signals/action-change.d.ts +507 -0
  138. package/dist/signals/action-change.js +265 -0
  139. package/dist/signals/action.d.ts +331 -0
  140. package/dist/signals/action.js +182 -0
  141. package/dist/signals/agenda.d.ts +585 -0
  142. package/dist/signals/agenda.js +295 -0
  143. package/dist/signals/applied-window.contract.d.ts +23 -0
  144. package/dist/signals/applied-window.contract.js +160 -0
  145. package/dist/signals/arrivals.contract.d.ts +21 -0
  146. package/dist/signals/arrivals.contract.js +180 -0
  147. package/dist/signals/arrivals.d.ts +375 -0
  148. package/dist/signals/arrivals.js +254 -0
  149. package/dist/signals/arriving.d.ts +210 -0
  150. package/dist/signals/arriving.js +133 -0
  151. package/dist/signals/audiences.d.ts +528 -0
  152. package/dist/signals/audiences.js +255 -0
  153. package/dist/signals/broadcast.d.ts +33 -17
  154. package/dist/signals/broadcast.js +255 -32
  155. package/dist/signals/change.d.ts +378 -0
  156. package/dist/signals/change.js +327 -0
  157. package/dist/signals/collect.d.ts +169 -34
  158. package/dist/signals/collect.js +186 -38
  159. package/dist/signals/conversion.d.ts +348 -0
  160. package/dist/signals/conversion.js +235 -0
  161. package/dist/signals/copy-change.d.ts +553 -0
  162. package/dist/signals/copy-change.js +377 -0
  163. package/dist/signals/copy.d.ts +337 -0
  164. package/dist/signals/copy.js +211 -0
  165. package/dist/signals/correlated.contract.d.ts +24 -0
  166. package/dist/signals/correlated.contract.js +94 -0
  167. package/dist/signals/counters.d.ts +97 -0
  168. package/dist/signals/counters.js +160 -0
  169. package/dist/signals/deliver.d.ts +23 -4
  170. package/dist/signals/deliver.js +34 -6
  171. package/dist/signals/deployment-change.d.ts +395 -0
  172. package/dist/signals/deployment-change.js +309 -0
  173. package/dist/signals/deployment.d.ts +278 -0
  174. package/dist/signals/deployment.js +178 -0
  175. package/dist/signals/door.d.ts +114 -0
  176. package/dist/signals/door.js +77 -0
  177. package/dist/signals/expire.d.ts +192 -0
  178. package/dist/signals/expire.js +213 -0
  179. package/dist/signals/fold.d.ts +10 -0
  180. package/dist/signals/fold.js +5 -1
  181. package/dist/signals/form-action.d.ts +302 -0
  182. package/dist/signals/form-action.js +169 -0
  183. package/dist/signals/form-copy.d.ts +523 -0
  184. package/dist/signals/form-copy.js +346 -0
  185. package/dist/signals/forms.d.ts +247 -0
  186. package/dist/signals/forms.js +147 -0
  187. package/dist/signals/frontier.d.ts +268 -0
  188. package/dist/signals/frontier.js +145 -0
  189. package/dist/signals/funnel-change.d.ts +548 -0
  190. package/dist/signals/funnel-change.js +361 -0
  191. package/dist/signals/funnel-hours.contract.d.ts +21 -0
  192. package/dist/signals/funnel-hours.contract.js +221 -0
  193. package/dist/signals/funnel-hours.d.ts +293 -0
  194. package/dist/signals/funnel-hours.js +99 -0
  195. package/dist/signals/funnel.d.ts +592 -0
  196. package/dist/signals/funnel.js +231 -0
  197. package/dist/signals/health.d.ts +694 -0
  198. package/dist/signals/health.js +573 -0
  199. package/dist/signals/index.d.ts +60 -0
  200. package/dist/signals/index.js +60 -0
  201. package/dist/signals/ingest.d.ts +56 -1
  202. package/dist/signals/ingest.js +91 -1
  203. package/dist/signals/inside.d.ts +190 -0
  204. package/dist/signals/inside.js +263 -0
  205. package/dist/signals/join.d.ts +56 -0
  206. package/dist/signals/join.js +60 -0
  207. package/dist/signals/journal.d.ts +123 -9
  208. package/dist/signals/kept.contract.d.ts +22 -0
  209. package/dist/signals/kept.contract.js +111 -0
  210. package/dist/signals/kinds.d.ts +8 -6
  211. package/dist/signals/kinds.js +14 -6
  212. package/dist/signals/library-action.d.ts +430 -0
  213. package/dist/signals/library-action.js +336 -0
  214. package/dist/signals/library-agenda-change.d.ts +324 -0
  215. package/dist/signals/library-agenda-change.js +199 -0
  216. package/dist/signals/library-agenda.d.ts +258 -0
  217. package/dist/signals/library-agenda.js +167 -0
  218. package/dist/signals/library-change.d.ts +477 -0
  219. package/dist/signals/library-change.js +335 -0
  220. package/dist/signals/library-copy-change.d.ts +498 -0
  221. package/dist/signals/library-copy-change.js +476 -0
  222. package/dist/signals/library-pace.d.ts +319 -0
  223. package/dist/signals/library-pace.js +305 -0
  224. package/dist/signals/library-reach-change.d.ts +646 -0
  225. package/dist/signals/library-reach-change.js +542 -0
  226. package/dist/signals/library-reach.d.ts +377 -0
  227. package/dist/signals/library-reach.js +227 -0
  228. package/dist/signals/library-senders-change.d.ts +457 -0
  229. package/dist/signals/library-senders-change.js +367 -0
  230. package/dist/signals/library-senders-reach-change.d.ts +486 -0
  231. package/dist/signals/library-senders-reach-change.js +538 -0
  232. package/dist/signals/library-senders-reach.d.ts +340 -0
  233. package/dist/signals/library-senders-reach.js +252 -0
  234. package/dist/signals/library-senders.d.ts +271 -0
  235. package/dist/signals/library-senders.js +180 -0
  236. package/dist/signals/library-word-reach-change.d.ts +567 -0
  237. package/dist/signals/library-word-reach-change.js +564 -0
  238. package/dist/signals/library.d.ts +306 -0
  239. package/dist/signals/library.js +178 -0
  240. package/dist/signals/memory.d.ts +9 -0
  241. package/dist/signals/memory.js +246 -14
  242. package/dist/signals/migrate.d.ts +20 -4
  243. package/dist/signals/migrate.js +269 -8
  244. package/dist/signals/notice.d.ts +389 -0
  245. package/dist/signals/notice.js +250 -0
  246. package/dist/signals/pace-change.d.ts +501 -0
  247. package/dist/signals/pace-change.js +310 -0
  248. package/dist/signals/pace.d.ts +296 -0
  249. package/dist/signals/pace.js +291 -0
  250. package/dist/signals/page-views.d.ts +365 -0
  251. package/dist/signals/page-views.js +218 -0
  252. package/dist/signals/part-pace.d.ts +378 -0
  253. package/dist/signals/part-pace.js +333 -0
  254. package/dist/signals/parts.d.ts +354 -0
  255. package/dist/signals/parts.js +232 -0
  256. package/dist/signals/postgres.d.ts +16 -2
  257. package/dist/signals/postgres.js +753 -76
  258. package/dist/signals/progress.d.ts +212 -0
  259. package/dist/signals/progress.js +150 -0
  260. package/dist/signals/ratios.d.ts +108 -0
  261. package/dist/signals/ratios.js +40 -0
  262. package/dist/signals/reach.d.ts +309 -0
  263. package/dist/signals/reach.js +93 -0
  264. package/dist/signals/readable.d.ts +34 -0
  265. package/dist/signals/readable.js +34 -0
  266. package/dist/signals/readership.d.ts +381 -0
  267. package/dist/signals/readership.js +308 -0
  268. package/dist/signals/region-pages.d.ts +173 -0
  269. package/dist/signals/region-pages.js +62 -0
  270. package/dist/signals/region.d.ts +287 -0
  271. package/dist/signals/region.js +198 -0
  272. package/dist/signals/retention.d.ts +163 -0
  273. package/dist/signals/retention.js +75 -0
  274. package/dist/signals/rhythm.d.ts +302 -0
  275. package/dist/signals/rhythm.js +262 -0
  276. package/dist/signals/rollup.d.ts +194 -4
  277. package/dist/signals/rollup.js +0 -0
  278. package/dist/signals/schema.d.ts +1069 -1
  279. package/dist/signals/schema.js +393 -3
  280. package/dist/signals/signal.d.ts +237 -11
  281. package/dist/signals/signal.js +70 -10
  282. package/dist/signals/silence-census.d.ts +205 -0
  283. package/dist/signals/silence-census.js +87 -0
  284. package/dist/signals/silences.d.ts +1147 -0
  285. package/dist/signals/silences.js +996 -0
  286. package/dist/signals/subtrees.d.ts +123 -0
  287. package/dist/signals/subtrees.js +102 -0
  288. package/dist/signals/tally.d.ts +262 -12
  289. package/dist/signals/unread.d.ts +292 -0
  290. package/dist/signals/unread.js +137 -0
  291. package/dist/signals/window-agenda.d.ts +276 -0
  292. package/dist/signals/window-agenda.js +83 -0
  293. package/dist/signals/window-figures.d.ts +148 -0
  294. package/dist/signals/window-figures.js +42 -0
  295. package/dist/signals/window-funnels.d.ts +88 -0
  296. package/dist/signals/window-funnels.js +47 -0
  297. package/dist/signals/window.d.ts +866 -0
  298. package/dist/signals/window.js +693 -0
  299. package/dist/signals/words.d.ts +24 -0
  300. package/dist/signals/words.js +24 -0
  301. package/dist/store/cache.d.ts +101 -0
  302. package/dist/store/cache.js +149 -0
  303. package/dist/store/history.d.ts +82 -0
  304. package/dist/store/history.js +36 -0
  305. package/dist/store/index.d.ts +30 -0
  306. package/dist/store/index.js +30 -0
  307. package/dist/store/memory.d.ts +2 -1
  308. package/dist/store/memory.js +48 -12
  309. package/dist/store/migrate.d.ts +106 -0
  310. package/dist/store/migrate.js +323 -7
  311. package/dist/store/postgres-applications.d.ts +4 -0
  312. package/dist/store/postgres-applications.js +197 -0
  313. package/dist/store/postgres-audience.d.ts +14 -0
  314. package/dist/store/postgres-audience.js +272 -0
  315. package/dist/store/postgres-holds.d.ts +10 -1
  316. package/dist/store/postgres-holds.js +116 -101
  317. package/dist/store/postgres-policy-log.d.ts +14 -0
  318. package/dist/store/postgres-policy-log.js +240 -0
  319. package/dist/store/postgres-projects.d.ts +4 -0
  320. package/dist/store/postgres-projects.js +217 -0
  321. package/dist/store/postgres.d.ts +17 -1
  322. package/dist/store/postgres.js +60 -9
  323. package/dist/store/replay.d.ts +102 -1
  324. package/dist/store/replay.js +190 -19
  325. package/dist/store/reseed.d.ts +238 -0
  326. package/dist/store/reseed.js +308 -0
  327. package/dist/store/schema.d.ts +762 -2
  328. package/dist/store/schema.js +218 -5
  329. package/dist/store/source.d.ts +57 -1
  330. package/dist/store/source.js +65 -1
  331. package/dist/store/store.d.ts +29 -6
  332. package/dist/submit/resolve.d.ts +1 -1
  333. package/dist/submit/resolve.js +2 -1
  334. package/dist/telemetry/calibration.d.ts +25 -0
  335. package/dist/telemetry/calibration.js +27 -1
  336. package/dist/telemetry/event.d.ts +391 -33
  337. package/dist/telemetry/event.js +84 -20
  338. package/dist/telemetry/index.d.ts +2 -0
  339. package/dist/telemetry/index.js +2 -0
  340. package/dist/telemetry/journal.d.ts +104 -3
  341. package/dist/telemetry/journal.js +9 -0
  342. package/dist/telemetry/lookup.d.ts +27 -0
  343. package/dist/telemetry/lookup.js +18 -0
  344. package/dist/telemetry/memory.js +33 -1
  345. package/dist/telemetry/migrate.js +22 -1
  346. package/dist/telemetry/postgres.d.ts +10 -1
  347. package/dist/telemetry/postgres.js +188 -90
  348. package/dist/telemetry/remeasure.d.ts +78 -0
  349. package/dist/telemetry/remeasure.js +83 -0
  350. package/dist/telemetry/retention.d.ts +2 -2
  351. package/dist/telemetry/schema.d.ts +17 -0
  352. package/dist/telemetry/schema.js +27 -1
  353. package/dist/telemetry/sink.d.ts +2 -2
  354. package/dist/telemetry/window.d.ts +135 -0
  355. package/dist/telemetry/window.js +101 -0
  356. package/dist/testing/application-contract.d.ts +14 -0
  357. package/dist/testing/application-contract.js +270 -0
  358. package/dist/testing/audience-overlay-contract.d.ts +31 -0
  359. package/dist/testing/audience-overlay-contract.js +354 -0
  360. package/dist/testing/contracts.d.ts +13 -7
  361. package/dist/testing/contracts.js +13 -7
  362. package/dist/testing/definitions.d.ts +78 -0
  363. package/dist/testing/definitions.js +134 -9
  364. package/dist/testing/doubles.d.ts +103 -0
  365. package/dist/testing/doubles.js +143 -0
  366. package/dist/testing/index.d.ts +2 -2
  367. package/dist/testing/index.js +2 -2
  368. package/dist/testing/journal-contract.js +297 -6
  369. package/dist/testing/model-contract.d.ts +110 -0
  370. package/dist/testing/model-contract.js +150 -0
  371. package/dist/testing/policy-log-contract.d.ts +26 -0
  372. package/dist/testing/policy-log-contract.js +344 -0
  373. package/dist/testing/project-contract.d.ts +14 -0
  374. package/dist/testing/project-contract.js +266 -0
  375. package/dist/testing/reader-signal-contract.d.ts +27 -2
  376. package/dist/testing/reader-signal-contract.js +475 -5
  377. package/dist/testing/store-contract.d.ts +7 -1
  378. package/dist/testing/store-contract.js +84 -3
  379. package/dist/theme/apply.d.ts +20 -1
  380. package/dist/theme/apply.js +5 -3
  381. package/dist/theme/contrast.d.ts +19 -14
  382. package/dist/theme/contrast.js +181 -17
  383. package/dist/theme/derive.d.ts +22 -0
  384. package/dist/theme/derive.js +54 -1
  385. package/dist/theme/library.js +1 -1
  386. package/dist/theme/measure.d.ts +34 -0
  387. package/dist/theme/measure.js +30 -1
  388. package/dist/theme/palettes.js +7 -7
  389. package/dist/theme/ramp.d.ts +64 -0
  390. package/dist/theme/ramp.js +114 -0
  391. package/dist/theme/registry.d.ts +9 -0
  392. package/dist/theme/registry.js +11 -1
  393. package/dist/theme/separation.d.ts +97 -3
  394. package/dist/theme/separation.js +75 -0
  395. package/dist/tree/apply.js +13 -0
  396. package/dist/tree/compare.d.ts +9 -0
  397. package/dist/tree/compare.js +18 -0
  398. package/dist/tree/mutation.d.ts +18 -0
  399. package/dist/tree/mutation.js +24 -12
  400. package/dist/tree/navigation.d.ts +5 -0
  401. package/dist/tree/navigation.js +32 -10
  402. package/dist/tree/outline.d.ts +7 -0
  403. package/dist/tree/outline.js +9 -5
  404. package/dist/write/computed.d.ts +60 -0
  405. package/dist/write/computed.js +61 -0
  406. package/dist/write/held.d.ts +59 -0
  407. package/dist/write/index.d.ts +5 -2
  408. package/dist/write/index.js +5 -2
  409. package/dist/write/reseed.d.ts +151 -0
  410. package/dist/write/reseed.js +184 -0
  411. package/dist/write/revert.js +2 -16
  412. package/package.json +25 -3
  413. package/dist/runtime/inverse-interpreter.d.ts +0 -90
  414. package/dist/runtime/inverse-interpreter.js +0 -56
package/dist/sdk/audit.js CHANGED
@@ -1,4 +1,5 @@
1
- import { describeProbeFailures, probeConfigurations, probeEditableDecoration, probePlacement, probeStates, probeSubmissionPlacement, } from "./conformance.js";
1
+ import { namesRead } from "../render/reads.js";
2
+ import { describeProbeFailures, probeConfigurationsFrom, probeEditableDecoration, probePlacement, probeStates, probeSubmissionPlacement, } from "./conformance.js";
2
3
  const unplacedIn = (placement) => placement.outcome === "probed" ? placement.unplacedSlots : [];
3
4
  const unplacedBehavioursIn = (placement) => placement.outcome === "probed" ? placement.unplacedBehaviours : [];
4
5
  /**
@@ -7,25 +8,140 @@ const unplacedBehavioursIn = (placement) => placement.outcome === "probed" ? pla
7
8
  * same failures as one that answered despite some of them; only `not-callable`
8
9
  * has none, because nothing was called.
9
10
  */
10
- const throwingIn = (type, placement) => {
11
- const failures = placement.outcome === "probed" ? placement.threw : placement.failures;
11
+ const throwingIn = (primitive, placement) => {
12
+ const threw = placement.outcome === "probed" ? placement.threw : placement.failures;
13
+ const failures = threw.filter((failure) => accepts(primitive.validate(failure.props)));
12
14
  if (failures.length === 0)
13
15
  return [];
14
- return [{ type, failures, everyConfiguration: placement.outcome === "not-probeable" }];
16
+ return [{ type: primitive.type, failures, everyConfiguration: placement.outcome === "not-probeable" }];
15
17
  };
16
18
  const NO_ANSWERS = Object.freeze([]);
19
+ const EMPTY_PROPS = Object.freeze([{}]);
20
+ /**
21
+ * A props bag as a key, for telling two bases apart.
22
+ *
23
+ * Top-level keys sorted, so a caller writing the same bag in another order does
24
+ * not get it probed twice; nested values are compared as written, which is as
25
+ * far as this needs to go — the cost of missing a duplicate is one extra call.
26
+ */
27
+ const keyOf = (props) => JSON.stringify(Object.keys(props).sort().map((name) => [name, props[name]]));
28
+ /**
29
+ * The empty bag first, then whatever the caller supplied for this type, with
30
+ * duplicates dropped.
31
+ *
32
+ * The empty bag stays even when props were supplied: for most primitives it is
33
+ * the configuration the schema accepts, and for the rest it is the one the
34
+ * audit reports as refused — dropping it would hide the fact that this
35
+ * primitive cannot be probed without help. Deduplicating is what makes handing
36
+ * over a bag the probe already had change nothing at all.
37
+ */
38
+ const basesFor = (supplied) => {
39
+ if (supplied === undefined)
40
+ return EMPTY_PROPS;
41
+ const seen = new Set(EMPTY_PROPS.map(keyOf));
42
+ const bases = [...EMPTY_PROPS];
43
+ for (const base of supplied) {
44
+ const key = keyOf(base);
45
+ if (seen.has(key))
46
+ continue;
47
+ seen.add(key);
48
+ bases.push(base);
49
+ }
50
+ return bases;
51
+ };
52
+ /**
53
+ * Whether this primitive's own validator accepts these props.
54
+ *
55
+ * `undeclared` counts as accepted, because it means the registration carries no
56
+ * schema for the type and nothing refused anything — the same reading
57
+ * `render.ts` gives it.
58
+ */
59
+ const accepts = (verdict) => verdict.outcome !== "invalid";
60
+ const refusedIn = (primitive, configurations) => configurations.flatMap((props) => {
61
+ const verdict = primitive.validate(props);
62
+ return verdict.outcome === "invalid" ? [{ props, issues: verdict.issues }] : [];
63
+ });
64
+ const requiredPropsOf = (primitive) => (primitive.declaredProps ?? []).filter((prop) => prop.required).map((prop) => prop.name);
65
+ /**
66
+ * The entry for a primitive the probe never reached, as nought or one.
67
+ *
68
+ * The test is `not-probeable` **and** nothing accepted having answered, so a
69
+ * class component stays where 0012 put it: `not-callable` means nothing was
70
+ * called under any bag, accepted or not, and handing it props would not change
71
+ * that.
72
+ */
73
+ const unconfigured = (primitive, verdict, configurations, supplied) => {
74
+ if (verdict.outcome !== "not-probeable" || verdict.cause !== "threw")
75
+ return [];
76
+ const refused = refusedIn(primitive, configurations);
77
+ if (refused.length === 0 || refused.length < configurations.length)
78
+ return [];
79
+ return [
80
+ {
81
+ type: primitive.type,
82
+ required: [...requiredPropsOf(primitive)].sort(),
83
+ reason: supplied === undefined ? "no-props" : "props-not-accepted",
84
+ refused,
85
+ },
86
+ ];
87
+ };
88
+ /**
89
+ * Whether one probed state answers something this primitive will look for.
90
+ *
91
+ * `Object.hasOwn` rather than a truthiness test on the read, because a name
92
+ * answered with a failure is still a name answered: the state reaches the
93
+ * primitive's did-not-answer branch *having been asked*, which is a state the
94
+ * probe was told about and is not what this list reports.
95
+ */
96
+ const answersAName = (answer, reads) => namesRead(reads, answer.props ?? {}).some((name) => Object.hasOwn(answer.data, name));
97
+ /**
98
+ * One registration and the answers this call held for it, as nought or one entry.
99
+ *
100
+ * Derived from the registration and the options alone — no probe outcome reaches
101
+ * here — because the claim is that the audit was not told something, and a probe
102
+ * result cannot make that true or false.
103
+ *
104
+ * An empty `reads` is not a bound primitive and reports nothing, the way an
105
+ * empty `frames` does: there is no answer anybody could have handed it.
106
+ */
107
+ const unansweredReader = (type, reads, answers) => {
108
+ if (reads === undefined || reads.length === 0)
109
+ return [];
110
+ if (answers.length === 0)
111
+ return [{ type, reads, reason: "no-answers" }];
112
+ if (answers.some((answer) => answersAName(answer, reads)))
113
+ return [];
114
+ return [{ type, reads, reason: "names-not-answered" }];
115
+ };
17
116
  export const auditRegistry = (registry, options = {}) => {
18
- const audits = registry.primitives.map((primitive) => {
19
- const configurations = probeStates(probeConfigurations(primitive.choices), options.answers?.get(primitive.type) ?? NO_ANSWERS);
117
+ /**
118
+ * One pass, holding the registration beside its audit. What the probe was
119
+ * handed is needed again afterwards — to ask the primitive's own validator
120
+ * whether a configuration that threw was one it accepts — and a second lookup
121
+ * by type would be a second chance to get the pairing wrong.
122
+ */
123
+ const probed = registry.primitives.map((primitive) => {
124
+ const supplied = options.props?.get(primitive.type);
125
+ const states = probeStates(probeConfigurationsFrom(basesFor(supplied), primitive.choices), options.answers?.get(primitive.type) ?? NO_ANSWERS);
126
+ const configurations = states.map((state) => state.props);
20
127
  return {
21
- type: primitive.type,
22
- verdict: probeEditableDecoration(primitive.component, primitive.text, configurations, primitive.frames),
23
- placement: probePlacement(primitive.component, primitive.slots, primitive.text, configurations, primitive.behaviours, primitive.frames),
24
- submission: probeSubmissionPlacement(primitive.component, primitive.text, configurations, primitive.frames),
25
- declaresSubmits: primitive.submits,
26
- framesProps: primitive.frames,
128
+ primitive,
129
+ supplied,
130
+ configurations,
131
+ audit: {
132
+ type: primitive.type,
133
+ verdict: probeEditableDecoration(primitive.component, primitive.text, states, primitive.frames),
134
+ placement: probePlacement(primitive.component, primitive.slots, primitive.text, states, primitive.behaviours, primitive.frames),
135
+ submission: probeSubmissionPlacement(primitive.component, primitive.text, states, primitive.frames),
136
+ declaresSubmits: primitive.submits,
137
+ framesProps: primitive.frames,
138
+ refusedConfigurations: refusedIn(primitive, configurations),
139
+ },
27
140
  };
28
141
  });
142
+ const audits = probed.map((entry) => entry.audit);
143
+ const notConfigured = probed.flatMap((entry) => unconfigured(entry.primitive, entry.audit.verdict, entry.configurations, entry.supplied));
144
+ const unreached = new Set(notConfigured.map((entry) => entry.type));
29
145
  const places = (audit) => audit.submission.outcome === "places";
30
146
  return {
31
147
  audits,
@@ -44,17 +160,21 @@ export const auditRegistry = (registry, options = {}) => {
44
160
  .filter((audit) => audit.declaresSubmits && audit.submission.outcome === "not-placed")
45
161
  .map((audit) => audit.type),
46
162
  notDecorated: audits.filter((audit) => audit.verdict.outcome === "not-decorated").map((audit) => audit.type),
47
- notProbeable: audits.filter((audit) => audit.verdict.outcome === "not-probeable").map((audit) => audit.type),
163
+ notProbeable: audits
164
+ .filter((audit) => audit.verdict.outcome === "not-probeable" && !unreached.has(audit.type))
165
+ .map((audit) => audit.type),
166
+ notConfigured,
48
167
  unplacedSlots: audits
49
168
  .filter((audit) => unplacedIn(audit.placement).length > 0)
50
169
  .map((audit) => ({ type: audit.type, slots: unplacedIn(audit.placement) })),
51
170
  unplacedBehaviours: audits
52
171
  .filter((audit) => unplacedBehavioursIn(audit.placement).length > 0)
53
172
  .map((audit) => ({ type: audit.type, behaviours: unplacedBehavioursIn(audit.placement) })),
173
+ notAnswered: registry.primitives.flatMap((primitive) => unansweredReader(primitive.type, primitive.reads, options.answers?.get(primitive.type) ?? NO_ANSWERS)),
54
174
  leaves: audits
55
175
  .filter((audit) => audit.placement.outcome === "probed" && !audit.placement.rendersChildren)
56
176
  .map((audit) => audit.type),
57
- throwsOnDeclaredProps: audits.flatMap((audit) => throwingIn(audit.type, audit.placement)),
177
+ throwsOnDeclaredProps: probed.flatMap((entry) => throwingIn(entry.primitive, entry.audit.placement)),
58
178
  };
59
179
  };
60
180
  /**
@@ -121,8 +241,47 @@ const describeSubmission = (entry) => {
121
241
  }
122
242
  return entry.declaresSubmits ? "; declares `submits` and places no address" : "";
123
243
  };
244
+ const describeDeclaration = (declaration) => typeof declaration === "string"
245
+ ? `\`${declaration}\``
246
+ : `whatever its \`${declaration.fromProp}\` prop says, or \`${declaration.default}\` where it says nothing`;
247
+ /**
248
+ * Said only when there is something to say, and said before the answers clause
249
+ * because it is the stronger of the two: an unanswered binding makes the
250
+ * clauses above describe one branch of a primitive, and no accepted
251
+ * configuration at all makes them describe a call no tree could make (0267).
252
+ */
253
+ const describeConfiguration = (unconfigured) => {
254
+ if (unconfigured === undefined)
255
+ return "";
256
+ const requires = unconfigured.required.length === 0
257
+ ? "requires props"
258
+ : `requires \`${unconfigured.required.join("`, `")}\``;
259
+ const handed = unconfigured.reason === "no-props"
260
+ ? "was handed none"
261
+ : "was handed none its schema accepts";
262
+ return `; ${requires} and ${handed}, so nothing above is a claim about this component`;
263
+ };
264
+ /**
265
+ * Said only when there is something to say, like `describeSubmission`, and said
266
+ * last because it is the one clause that is not an observation. The clauses
267
+ * before it may be describing this primitive's unanswered branch, and a reader
268
+ * fixing something needs to know that before believing them.
269
+ */
270
+ const describeAnswers = (unanswered) => {
271
+ if (unanswered === undefined)
272
+ return "";
273
+ const reads = unanswered.reads.map(describeDeclaration).join(", ");
274
+ const cause = unanswered.reason === "no-answers"
275
+ ? "was probed with no answer"
276
+ : "was handed no answer under a name it reads";
277
+ return `; reads ${reads} and ${cause}, so what it draws only when answered was never probed`;
278
+ };
124
279
  /** One line per primitive, for a CLI or a failing test's message. */
125
- export const describeRegistryAudit = (audit) => audit.audits
126
- .map((entry) => `${entry.type}: ${describeVerdict(entry.verdict)}; ${describePlacement(entry.placement)}${describeSubmission(entry)}`)
127
- .join("\n");
280
+ export const describeRegistryAudit = (audit) => {
281
+ const unanswered = new Map(audit.notAnswered.map((entry) => [entry.type, entry]));
282
+ const unconfigured = new Map(audit.notConfigured.map((entry) => [entry.type, entry]));
283
+ return audit.audits
284
+ .map((entry) => `${entry.type}: ${describeVerdict(entry.verdict)}; ${describePlacement(entry.placement)}${describeSubmission(entry)}${describeConfiguration(unconfigured.get(entry.type))}${describeAnswers(unanswered.get(entry.type))}`)
285
+ .join("\n");
286
+ };
128
287
  //# sourceMappingURL=audit.js.map
@@ -23,8 +23,16 @@ import type { PrimitiveRegistry } from "./registry.js";
23
23
  * `export type *` never carried them and `sdk.catalogueFields` is `undefined`.
24
24
  * Naming the three types the catalogue is made of says the true thing in a way
25
25
  * the generator reads correctly.
26
+ *
27
+ * `ClosedChoice` is the fourth and is not part of the catalogue — it is
28
+ * deliberately left out of one (`catalogue.ts` says why). It is here because
29
+ * two published signatures hold one: `PrimitiveEntry.choices` and
30
+ * `probeConfigurations`, so a host could pass one and read one and had no way
31
+ * to write the type of a function that takes one. `CataloguedProp` is the same
32
+ * kind of small projection and was already exported, which is what made the
33
+ * omission an oversight rather than a decision.
26
34
  */
27
- export type { CataloguedPrimitive, CataloguedProp, PrimitiveCatalogue } from "../catalogue.js";
35
+ export type { CataloguedPrimitive, CataloguedProp, ClosedChoice, PrimitiveCatalogue, } from "../catalogue.js";
28
36
  /**
29
37
  * The registry, projected into the catalogue other components read.
30
38
  *
@@ -30,7 +30,15 @@ import { type PaletteSlot } from "../theme/theme.js";
30
30
  * `registry.ts` never calls a primitive. Enforcement is the host's call, which
31
31
  * is why the verdict is a value.
32
32
  */
33
- /** A configuration the schema accepts that the component threw on. */
33
+ /**
34
+ * A configuration the probe built that the component threw on.
35
+ *
36
+ * Built *from* the schema, which is not the same as accepted *by* it: the
37
+ * default configuration is `{}`, and a primitive with a required prop refuses
38
+ * that (0267). Whether a failure here is a fault of the component is
39
+ * `auditRegistry`'s partition, because the validator it needs lives on the
40
+ * registration rather than in this module.
41
+ */
34
42
  export type ProbeFailure = {
35
43
  readonly props: JsonObject;
36
44
  readonly reason: string;
@@ -133,6 +141,27 @@ export type ProbeAnswers = {
133
141
  * that way, and a primitive that were would be one nobody can read.
134
142
  */
135
143
  export declare const probeConfigurations: (choices: readonly ClosedChoice[]) => readonly JsonObject[];
144
+ /**
145
+ * The same, from props a caller supplied rather than from nothing (0267).
146
+ *
147
+ * `probeConfigurations` starts from `{}`, which is a props bag the schema of any
148
+ * primitive with a required prop refuses — thirty-two of the hundred and seven
149
+ * starter primitives, where it is every configuration the probe builds. Those
150
+ * primitives answer anyway, because handing React a missing prop renders
151
+ * nothing; the first one to *read* a required prop throws, and a throw under a
152
+ * bag no valid tree can carry is not a fault of the component.
153
+ *
154
+ * A base is **supplied, not derived**, for the reason `ProbeAnswers` is: a
155
+ * required `z.string().min(1)` has no value the probe can read off the schema,
156
+ * and one it invented would make everything downstream a function of the guess.
157
+ * Whoever registered the primitive knows a bag it accepts.
158
+ *
159
+ * Each base is varied by each closed choice in turn — the sum again, not the
160
+ * product — so a caller who hands one bag gets that bag and that bag under
161
+ * every value its schema closes over, which is what 0075 asks for and what `{}`
162
+ * could not deliver for a primitive that requires anything.
163
+ */
164
+ export declare const probeConfigurationsFrom: (bases: readonly JsonObject[], choices: readonly ClosedChoice[]) => readonly JsonObject[];
136
165
  /**
137
166
  * The states a primitive is probed in: what its schema closes over, then what
138
167
  * its registrant declared it can be answered with (0185).
@@ -213,8 +242,13 @@ export type PlacementVerdict = {
213
242
  /**
214
243
  * Configurations built from the primitive's own schema that it threw on.
215
244
  * Never a reason to distrust the verdict — the configurations that
216
- * answered still answered — and always a fault: a component that throws
217
- * on a value its schema accepts is one a valid tree can crash a page with.
245
+ * answered still answered.
246
+ *
247
+ * A fault for every one of them its schema **accepts**, which is the
248
+ * partition `auditRegistry` makes and this module cannot: a component that
249
+ * throws on a value its schema accepts is one a valid tree can crash a
250
+ * page with, and one that throws on the empty bag it requires props
251
+ * against is a component nobody has handed props to yet (0267).
218
252
  */
219
253
  readonly threw: readonly ProbeFailure[];
220
254
  } | NotProbeable;
@@ -89,10 +89,31 @@ const namesIn = (data) => {
89
89
  * particular values together is not found. Nothing in the library is shaped
90
90
  * that way, and a primitive that were would be one nobody can read.
91
91
  */
92
- export const probeConfigurations = (choices) => [
93
- {},
94
- ...choices.flatMap(({ name, options }) => options.map((option) => ({ [name]: option }))),
95
- ];
92
+ export const probeConfigurations = (choices) => probeConfigurationsFrom([{}], choices);
93
+ /**
94
+ * The same, from props a caller supplied rather than from nothing (0267).
95
+ *
96
+ * `probeConfigurations` starts from `{}`, which is a props bag the schema of any
97
+ * primitive with a required prop refuses — thirty-two of the hundred and seven
98
+ * starter primitives, where it is every configuration the probe builds. Those
99
+ * primitives answer anyway, because handing React a missing prop renders
100
+ * nothing; the first one to *read* a required prop throws, and a throw under a
101
+ * bag no valid tree can carry is not a fault of the component.
102
+ *
103
+ * A base is **supplied, not derived**, for the reason `ProbeAnswers` is: a
104
+ * required `z.string().min(1)` has no value the probe can read off the schema,
105
+ * and one it invented would make everything downstream a function of the guess.
106
+ * Whoever registered the primitive knows a bag it accepts.
107
+ *
108
+ * Each base is varied by each closed choice in turn — the sum again, not the
109
+ * product — so a caller who hands one bag gets that bag and that bag under
110
+ * every value its schema closes over, which is what 0075 asks for and what `{}`
111
+ * could not deliver for a primitive that requires anything.
112
+ */
113
+ export const probeConfigurationsFrom = (bases, choices) => bases.flatMap((base) => [
114
+ base,
115
+ ...choices.flatMap(({ name, options }) => options.map((option) => ({ ...base, [name]: option }))),
116
+ ]);
96
117
  /**
97
118
  * The states a primitive is probed in: what its schema closes over, then what
98
119
  * its registrant declared it can be answered with (0185).
@@ -1,11 +1,13 @@
1
- import type { ZodType, ZodTypeDef } from "zod";
1
+ import type { ZodType, ZodTypeAny, ZodTypeDef } from "zod";
2
2
  import { type CataloguedProp, type ClosedChoice } from "../catalogue.js";
3
3
  import type { InteractiveWhen } from "../interactivity.js";
4
4
  import type { JsonObject, JsonObjectView } from "../json.js";
5
5
  import type { BehaviourName } from "../render/behaviour.js";
6
6
  import type { LoomPrimitive } from "../render/primitive.js";
7
7
  import type { PropsVerdict } from "../render/props.js";
8
+ import type { AnswerExpectation } from "../render/expected.js";
8
9
  import type { BindingDeclaration } from "../render/reads.js";
10
+ import type { UnshownDeclaration } from "../render/unshown.js";
9
11
  import { type PrimitiveText } from "../render/text.js";
10
12
  import type { PrimitiveRole } from "../role.js";
11
13
  /**
@@ -54,6 +56,15 @@ import type { PrimitiveRole } from "../role.js";
54
56
  * primitive never reads (0181). Each entry is a fixed name or the name a prop
55
57
  * gives (0184). Optional, and the second declaration where leaving it out and
56
58
  * declaring it empty differ.
59
+ * - `expects` — the shape of answer it can read under each of those names, so an
60
+ * answer the source was happy with and this primitive cannot draw is the named
61
+ * absence of an answer rather than whatever a hand-written parse fell through
62
+ * to (0357). Optional, keyed by declared name, and the top level only: each
63
+ * row stays the primitive's to read.
64
+ * - `unshown` — its own reading of the answers it was given, so the walk can say
65
+ * that eleven of twelve rows arrived and were not drawn (0206). The only
66
+ * declaration here that is a function, because how many rows survived a shape
67
+ * is not data about a primitive. Optional, and read at render time.
57
68
  */
58
69
  export type PrimitiveDefinition<TProps extends JsonObjectView = JsonObject, TText extends string = never, TBehaviour extends BehaviourName = never> = {
59
70
  readonly type: string;
@@ -74,7 +85,7 @@ export type PrimitiveDefinition<TProps extends JsonObjectView = JsonObject, TTex
74
85
  * declares; the registry refuses a declaration that names one it does not, so
75
86
  * a renamed prop cannot leave this quietly pointing at nothing.
76
87
  */
77
- readonly interactive?: InteractiveWhen;
88
+ readonly interactive?: InteractiveWhen | undefined;
78
89
  /**
79
90
  * `true` for a primitive whose job includes sending what it collected. It
80
91
  * takes no conditional form, unlike `interactive`: a card is a target only
@@ -115,6 +126,28 @@ export type PrimitiveDefinition<TProps extends JsonObjectView = JsonObject, TTex
115
126
  * `interactive` or the Gate will let one sit inside an anchor.
116
127
  */
117
128
  readonly behaviours?: readonly TBehaviour[];
129
+ /**
130
+ * The prop each control takes its name from — `{ present: "label" }` on a
131
+ * dialog whose trigger carries the page's own call to action.
132
+ *
133
+ * Optional, and absent for almost every primitive that takes a control at all.
134
+ * A control's name is normally a string this primitive declares, which is what
135
+ * makes *Copy* the same word on every code panel in a deployment and lets one
136
+ * dictionary translate all of them. This is the exception for the control whose
137
+ * words are **content**: a trigger that opens a dialog says *Watch the demo*,
138
+ * the next one says *Book a call*, and neither is a fact about the primitive or
139
+ * a thing a translator should hold.
140
+ *
141
+ * Three checks follow, and the first two are the registry's. The behaviour must
142
+ * be one this primitive declared, and the prop must be one its schema declares
143
+ * — the same drift `frames` and `interactive` are checked against, failing the
144
+ * same silent way: a prop renamed and a declaration left pointing at nothing
145
+ * would quietly go back to the declared string for ever. The third is not a
146
+ * check but a property: the declared text is still required, so the control has
147
+ * a name in every language before any node is written, and a node that fills
148
+ * the prop with nothing gets it.
149
+ */
150
+ readonly names?: Readonly<Partial<Record<TBehaviour, string>>>;
118
151
  /**
119
152
  * What part this primitive plays — `"heading"` on anything a reader takes as
120
153
  * the title of what follows, whatever it is called. Optional, and absent on
@@ -133,7 +166,7 @@ export type PrimitiveDefinition<TProps extends JsonObjectView = JsonObject, TTex
133
166
  * over a string the runtime does not know, so the registry refuses one rather
134
167
  * than letting a misspelling read as "declares no role".
135
168
  */
136
- readonly role?: PrimitiveRole;
169
+ readonly role?: PrimitiveRole | undefined;
137
170
  /**
138
171
  * The props whose values a reader reads as words — `["value", "label",
139
172
  * "caption"]` on a stat, `[]` on an arrangement that shows none of its own.
@@ -150,7 +183,7 @@ export type PrimitiveDefinition<TProps extends JsonObjectView = JsonObject, TTex
150
183
  * not — the same drift `frames` and `interactive` are checked for, with less
151
184
  * riding on it and the same silence when it happens.
152
185
  */
153
- readonly copy?: readonly string[];
186
+ readonly copy?: readonly string[] | undefined;
154
187
  /**
155
188
  * The binding names this primitive reads an answer under — `["entries"]` on a
156
189
  * feed, `[]` on everything that draws only what the tree wrote.
@@ -180,7 +213,75 @@ export type PrimitiveDefinition<TProps extends JsonObjectView = JsonObject, TTex
180
213
  * `fromProp` — is checked against the schema the way `copy` and `frames` are,
181
214
  * so a declaration cannot go on naming a prop that was renamed away.
182
215
  */
183
- readonly reads?: readonly BindingDeclaration[];
216
+ readonly reads?: readonly BindingDeclaration[] | undefined;
217
+ /**
218
+ * The shape of answer this primitive can read, per binding name it reads —
219
+ * `{ entries: z.array(z.unknown()) }` on a feed, `{ value: figureSchema }` on
220
+ * a figure.
221
+ *
222
+ * The seam validates an answer against the **source's** schema, which is a
223
+ * claim about a host's database and says nothing about what can go on a page;
224
+ * so a bound primitive carries its own schema for what it draws (0180). Until
225
+ * this existed that schema was private to the component, which left the one
226
+ * mistake nothing could catch: a list bound to a primitive that draws a
227
+ * figure resolves cleanly, is handed over, and is refused inside a component
228
+ * where the only report of it is whatever that component chose to draw.
229
+ *
230
+ * **The top level only.** A row's shape is the one thing only the component
231
+ * knows, and a listing that skips a row it cannot read is doing its job
232
+ * rather than failing (0175); what it dropped is reported with a count by
233
+ * `unshown` (0206). So an expectation answers *is this the kind of answer I
234
+ * asked for* and never *is every row in it drawable*, and the two halves stay
235
+ * where each can be told the truth.
236
+ *
237
+ * Keyed by the name as **declared** — the string, or a prop-named
238
+ * declaration's `default` (0184). A node that renames the binding it draws
239
+ * from has not changed the shape this primitive draws, so the expectation
240
+ * belongs to the declaration rather than to whatever the node called it.
241
+ *
242
+ * Every key must be a name `reads` declares. The registry refuses one that is
243
+ * not, which is the drift `frames`, `copy` and `names` are each checked for
244
+ * and fails the same silent way: a binding renamed in `reads` would leave an
245
+ * expectation here checking nothing, for ever.
246
+ *
247
+ * `ZodTypeAny`, like every other schema this file holds and for the same
248
+ * reason: the output type is discarded, so the only thing the declaration has
249
+ * to be is a Zod schema. Narrowing it to one producing `JsonValue` would
250
+ * refuse `z.array(z.unknown())`, which is the schema the library's own feed
251
+ * actually holds.
252
+ *
253
+ * Optional, and unlike `reads` and `copy` there is no claim in its absence to
254
+ * distinguish from an empty one: a primitive that has declared no expectation
255
+ * for a name is handed that name's answer exactly as it was before this
256
+ * existed. `{}` says the same thing, so nothing reads it differently.
257
+ */
258
+ readonly expects?: Readonly<Record<string, ZodTypeAny>>;
259
+ /**
260
+ * What this primitive made of each answer it was given: the rows it found and
261
+ * the rows it placed. The walk reports the ones where those differ.
262
+ *
263
+ * The one way a binding can be wrong that nothing outside the component can
264
+ * see. A source can answer perfectly, under a name the primitive reads, with
265
+ * rows the primitive then declines one at a time — because a row's shape is
266
+ * the primitive's own, and eleven of twelve failing it is the author's problem
267
+ * and nobody else's. The reader is told without a count (0175); this is how
268
+ * the author is told with one (0206).
269
+ *
270
+ * A function, where everything above is data, and that is the honest shape
271
+ * rather than a shortcut. `reads` is a list of names, and a name is data —
272
+ * which is why it has a `fromProp` form instead of a callback (0184). A count
273
+ * of rows that survived a schema is not data about a primitive; it is the
274
+ * primitive reading an answer, and the primitive already contains that code,
275
+ * because it had to decide what to skip in order to skip it. Declare the
276
+ * function the component calls and the two cannot disagree.
277
+ *
278
+ * Pure, synchronous, and handed exactly what the component is handed of the
279
+ * same two things. It may not throw and may not return a reading that cannot
280
+ * describe an answer; both are caught and reported as
281
+ * `unshown-unreadable` against the primitive rather than allowed to cost the
282
+ * page, because rendering is total.
283
+ */
284
+ readonly unshown?: UnshownDeclaration | undefined;
184
285
  readonly component: LoomPrimitive<TProps, TText, TBehaviour>;
185
286
  };
186
287
  /**
@@ -212,6 +313,12 @@ export type PrimitiveEntry = {
212
313
  readonly frames: readonly string[];
213
314
  /** Declared behaviour names, still raw: the registry is what checks them. */
214
315
  readonly behaviours: readonly string[];
316
+ /**
317
+ * Which prop names which control, still raw: the registry is what checks that
318
+ * both halves of each pair exist. Empty for the primitive that named none,
319
+ * which is almost all of them.
320
+ */
321
+ readonly names: Readonly<Record<string, string>>;
215
322
  /**
216
323
  * The declared role, still raw: the registry is what checks it, for the same
217
324
  * reason it checks a behaviour name. `undefined` for the primitive that plays
@@ -230,6 +337,23 @@ export type PrimitiveEntry = {
230
337
  * two mean different things here and all the way out to the render walk.
231
338
  */
232
339
  readonly reads: readonly BindingDeclaration[] | undefined;
340
+ /**
341
+ * The declared answer shapes, erased to validators and keyed by declared
342
+ * name. `undefined` for the primitive that declared none, which is every
343
+ * primitive that reads no data and most of the ones that do.
344
+ *
345
+ * Erased here rather than carried as schemas for `validate`'s reason: the one
346
+ * place that still holds every schema is the one place that should turn it
347
+ * into a function, and nothing in the render path then depends on which
348
+ * schema library declared it.
349
+ */
350
+ readonly expects: Readonly<Record<string, AnswerExpectation>> | undefined;
351
+ /**
352
+ * The declared reading of this node's answers, or `undefined` where the author
353
+ * has not said. Nothing to check at registration — there are no names in it
354
+ * and no props it could name — so it is carried straight through.
355
+ */
356
+ readonly unshown: UnshownDeclaration | undefined;
233
357
  readonly validate: (props: JsonObject) => PropsVerdict;
234
358
  };
235
359
  /**
@@ -15,6 +15,69 @@ const freezeText = (text) => {
15
15
  copy[key] = value;
16
16
  return Object.freeze(copy);
17
17
  };
18
+ /**
19
+ * The raw declaration for a primitive that named no control. Null-prototype for
20
+ * the reason `NO_TEXT` gives: a lookup under `constructor` must answer nothing.
21
+ */
22
+ const NO_NAMES = Object.freeze(Object.create(null));
23
+ /**
24
+ * Declared control names, copied and frozen for `freezeText`'s reason: the
25
+ * caller keeps the literal it passed, and an entry sharing it is one mutation
26
+ * away from a rendered page's buttons changing under it.
27
+ */
28
+ const freezeNames = (names) => {
29
+ if (!names)
30
+ return NO_NAMES;
31
+ const copy = Object.create(null);
32
+ for (const [behaviour, prop] of Object.entries(names)) {
33
+ if (prop !== undefined)
34
+ copy[behaviour] = prop;
35
+ }
36
+ return Object.freeze(copy);
37
+ };
38
+ /**
39
+ * The first reason a schema gave, as one line a diagnostic can carry.
40
+ *
41
+ * Private here and private again in `data/adapter.ts`, which says the same
42
+ * sentence about a source's own schema. Shared between them it would have to be
43
+ * exported from the package, and a formatter for somebody else's error type is
44
+ * not a thing this library should promise to keep.
45
+ */
46
+ const firstIssueOf = (error) => {
47
+ const [issue] = error.issues;
48
+ if (!issue)
49
+ return "refused, without saying why";
50
+ const path = issue.path.length === 0 ? "" : `${issue.path.map(String).join(".")}: `;
51
+ return `${path}${issue.message}`;
52
+ };
53
+ /**
54
+ * Declared answer shapes, erased to validators at declaration.
55
+ *
56
+ * Copied into a frozen null-prototype map for `freezeText`'s reason, and erased
57
+ * for `validate`'s: the schema is turned into a function in the one place that
58
+ * still holds it, so the render path never has to know it was Zod.
59
+ *
60
+ * The parse output is discarded and the answer the primitive receives is the one
61
+ * the source gave, which is the same bargain `verdictFor` makes with props and is
62
+ * load-bearing for the same reason. An expectation is a gate rather than a
63
+ * transform: 0180 is explicit that unknown keys on a row are stripped and not
64
+ * refused, and a page assembled from whatever this schema happened to keep would
65
+ * be a function of this deployment's schema version rather than of the answer.
66
+ */
67
+ const freezeExpectations = (expects) => {
68
+ if (!expects)
69
+ return undefined;
70
+ const copy = Object.create(null);
71
+ for (const [name, schema] of Object.entries(expects)) {
72
+ copy[name] = (answer) => {
73
+ const parsed = schema.safeParse(answer);
74
+ return parsed.success
75
+ ? { outcome: "readable" }
76
+ : { outcome: "unreadable", detail: firstIssueOf(parsed.error) };
77
+ };
78
+ }
79
+ return Object.freeze(copy);
80
+ };
18
81
  const toIssue = (issue) => ({
19
82
  path: issue.path.length === 0 ? "props" : issue.path.map(String).join("."),
20
83
  message: issue.message,
@@ -45,9 +108,12 @@ export const definePrimitive = (definition) => ({
45
108
  submits: definition.submits ?? false,
46
109
  frames: definition.frames ?? [],
47
110
  behaviours: definition.behaviours ?? [],
111
+ names: freezeNames(definition.names),
48
112
  role: definition.role,
49
113
  copy: definition.copy,
50
114
  reads: definition.reads,
115
+ expects: freezeExpectations(definition.expects),
116
+ unshown: definition.unshown,
51
117
  /**
52
118
  * The one narrowing cast in the SDK, and the invariant that makes it sound:
53
119
  * a registry hands the renderer this component and the validator built from