@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
@@ -1,4 +1,6 @@
1
1
  import { createElement, Fragment } from "react";
2
+ import { DEFAULT_AUDIENCE_ID } from "../audience/audience.js";
3
+ import { parseBindings } from "../data/binding.js";
2
4
  import { NO_DATA } from "../data/resolution.js";
3
5
  import { NO_FRAMES } from "../frame/resolution.js";
4
6
  import { ANCHOR_PROP_KEY, DATA_PROP_KEY, SUBMIT_PROP_KEY } from "../reserved-props.js";
@@ -6,31 +8,61 @@ import { assertNever } from "../result.js";
6
8
  import { themeVariables } from "../theme/apply.js";
7
9
  import { findNode, textOf } from "../tree/navigation.js";
8
10
  import { createAnchorLedger, resolveAnchor, } from "./anchor.js";
9
- import { isBehaviourResolver, NO_RESOLVED_BEHAVIOURS, resolveBehaviours, } from "./behaviour.js";
11
+ import { isBehaviourResolver, NO_RESOLVED_BEHAVIOURS, NO_CONTROL_NAME_PROPS, resolveBehaviours, resolveControlNames, } from "./behaviour.js";
10
12
  import { literalThemeElement } from "./inline-variables.js";
11
13
  import { editableAttributes } from "./editable.js";
14
+ import { checkAnswers, isAnswerReader, } from "./expected.js";
12
15
  import { isFrameResolver, resolveNodeFrames } from "./frame.js";
13
16
  import { NO_SLOTS, } from "./primitive.js";
14
- import { isBindingReader, unreadBindings } from "./reads.js";
17
+ import { isBindingReader, unreadBindings, } from "./reads.js";
18
+ import { isSlotPlacer, unplacedSlots } from "./slots.js";
19
+ import { isUnshownReader, readUnshown, unshownRows, } from "./unshown.js";
15
20
  import { isTextResolver, NO_TEXT, overlayText, } from "./text.js";
16
21
  import { partitionReservedProps, resolveTheme, themeStyle, THEME_PROP_KEY } from "./theme.js";
17
- const renderChildren = (children, context) => children.length === 0 ? null : children.map((child) => renderNode(child, context));
22
+ /**
23
+ * Whether this render's ramps may read the width they are laid out at.
24
+ *
25
+ * A caller asking for literals is feeding a medium with no cascade, which
26
+ * resolves a container unit exactly as poorly as it resolves a `var()` — so the
27
+ * ramps mount as the pack's declared pixels and the root's declarations agree
28
+ * with the values substituted beneath them (0283).
29
+ */
30
+ const rampFor = (options) => options.themeValues === "literals" ? "fixed" : "fluid";
31
+ /**
32
+ * A list of nodes, each walked from its own root.
33
+ *
34
+ * The `.map` is one level and spends no frame per level; each `renderSubtree`
35
+ * carries its own stack. Only a decorative copy starts a list this way now — a
36
+ * node's own children are rendered by the walk that reached it.
37
+ */
38
+ const renderNodeList = (children, context) => children.length === 0 ? null : children.map((child) => renderSubtree(child, context));
18
39
  const isRootNode = (node, context) => node.id === context.tree.root.id;
19
- const renderElementBody = (node, context) => {
40
+ /**
41
+ * The children this element receives, split the way its primitive takes them.
42
+ *
43
+ * It renders nothing. The walk has already rendered every child by the time
44
+ * this runs (0380), and what is left is the routing — which is why the slot
45
+ * rules above are a statement about `from.kind` rather than about recursion.
46
+ */
47
+ const elementBodyFrom = (node, rendered) => {
20
48
  if (!node.children.some((child) => child.kind === "slot")) {
21
- return { children: renderChildren(node.children, context), slots: NO_SLOTS };
49
+ return {
50
+ children: rendered.length === 0 ? null : rendered.map((child) => child.element),
51
+ slots: NO_SLOTS,
52
+ };
22
53
  }
23
54
  const slots = Object.create(null);
24
55
  const rest = [];
25
- for (const child of node.children) {
26
- if (child.kind !== "slot") {
27
- rest.push(renderNode(child, context));
56
+ for (const child of rendered) {
57
+ if (child.from.kind !== "slot") {
58
+ rest.push(child.element);
28
59
  continue;
29
60
  }
30
- const placed = renderNode(child, context);
31
- const existing = slots[child.name];
32
- slots[child.name] =
33
- existing === undefined ? placed : [...(Array.isArray(existing) ? existing : [existing]), placed];
61
+ const existing = slots[child.from.name];
62
+ slots[child.from.name] =
63
+ existing === undefined
64
+ ? child.element
65
+ : [...(Array.isArray(existing) ? existing : [existing]), child.element];
34
66
  }
35
67
  return { children: rest.length === 0 ? null : rest, slots: Object.freeze(slots) };
36
68
  };
@@ -56,7 +88,7 @@ const decorativeChildrenFor = (node, context) => {
56
88
  let rendered = false;
57
89
  return () => {
58
90
  if (!rendered) {
59
- copy = renderChildren(node.children, {
91
+ copy = renderNodeList(node.children, {
60
92
  ...context,
61
93
  editMode: false,
62
94
  addressed: false,
@@ -83,7 +115,11 @@ const renderContextFor = (node, slots, data, submit, frames, anchor, text, behav
83
115
  ...(submit ? { submit } : {}),
84
116
  ...(anchor ? { anchor } : {}),
85
117
  ...(context.editMode || context.addressed
86
- ? { editable: editableAttributes(node, isRoot ? context.tree : undefined) }
118
+ ? {
119
+ editable: isRoot
120
+ ? editableAttributes(node, context.tree, context.audience)
121
+ : editableAttributes(node),
122
+ }
87
123
  : {}),
88
124
  ...(theme ? { theme } : {}),
89
125
  };
@@ -111,7 +147,11 @@ const nodeDataFor = (node, declared, context) => {
111
147
  unavailable: problem.unavailable,
112
148
  });
113
149
  }
114
- const data = context.data.lookup(node.id);
150
+ const given = context.data.lookup(node.id);
151
+ const declaredReads = context.reads?.bindingsReadBy(node.type);
152
+ const { data, refused } = checkAnswers(given, declaredReads, context.expects?.answersExpectedBy(node.type), node.props);
153
+ if (refused.length > 0)
154
+ reportRefusedAnswers(node, declared, refused, context);
115
155
  /**
116
156
  * A resolution that answered nothing for a node that asked for something has
117
157
  * never heard of the node: `buildDataResolution` gives every planned binding an
@@ -126,9 +166,76 @@ const nodeDataFor = (node, declared, context) => {
126
166
  if (reported === 0 && !hasAnswers(data) && asksForSomething(declared)) {
127
167
  context.collect({ code: "data-unresolved", nodeId: node.id, resolution: "unrelated" });
128
168
  }
129
- reportUnreadBindings(node, data, context);
169
+ reportUnreadBindings(node, data, declaredReads, context);
170
+ reportUnshownRows(node, data, context);
130
171
  return data;
131
172
  };
173
+ /**
174
+ * A diagnostic for every region this node filled that its primitive places
175
+ * nowhere.
176
+ *
177
+ * Measured on the node's own slot *children* rather than on `body.slots`, which
178
+ * is the same list by construction and is built by walking the subtree. Reading
179
+ * the children keeps this node's diagnostic ahead of its descendants' in the
180
+ * collected order, which is what every other report in this walk does.
181
+ *
182
+ * Silent unless the resolver can say what a primitive places, which is the same
183
+ * bargain `reads` makes: `undefined` is a resolver with no registry behind it,
184
+ * or a type no registry holds, and neither is a primitive claiming it places
185
+ * nothing. A primitive that declared no regions *is* one — `slots` is the one
186
+ * declaration where leaving it out and declaring it empty are the same claim
187
+ * (`sdk/definition.ts`), and 0051 made that claim operational.
188
+ */
189
+ const reportUnplacedSlots = (node, context) => {
190
+ const filled = [];
191
+ for (const child of node.children)
192
+ if (child.kind === "slot")
193
+ filled.push(child.name);
194
+ if (filled.length === 0)
195
+ return;
196
+ for (const name of unplacedSlots(filled, context.placer?.slotsPlacedBy(node.type))) {
197
+ context.collect({ code: "slot-unplaced", nodeId: node.id, type: node.type, name });
198
+ }
199
+ };
200
+ /**
201
+ * A diagnostic for every answer this node was given that its primitive declared
202
+ * it cannot read.
203
+ *
204
+ * Reported as `data-unavailable`, which is the code it is: the binding has no
205
+ * value, and the reason it carries says whose schema refused it — the source's
206
+ * own, or the primitive reading it (0357). A code of its own would have said the
207
+ * same thing one word differently and split anything counting bindings that went
208
+ * unanswered across two codes.
209
+ *
210
+ * The source id comes from the node's own `loom:data`, re-parsed here rather
211
+ * than carried down from the plan. It costs a parse on the one path where an
212
+ * answer was refused and nothing at all on every other node, which is the
213
+ * trade worth making: the plan's own copy would have to travel through the
214
+ * resolution to reach here, and a resolution is asked about a node id and
215
+ * deliberately knows nothing about what the node declared.
216
+ *
217
+ * A refusal whose name is not in that map cannot happen on a rendered node — a
218
+ * ready answer under a name is there because the plan read that name off this
219
+ * node — and is passed over rather than reported against a source nobody named.
220
+ * `nameRead` guards the same impossibility for the same reason.
221
+ */
222
+ const reportRefusedAnswers = (node, declared, refused, context) => {
223
+ const bindings = parseBindings(declared);
224
+ if (!bindings.ok)
225
+ return;
226
+ for (const [name, bound] of bindings.value) {
227
+ const refusal = refused.find((candidate) => candidate.name === name);
228
+ if (!refusal)
229
+ continue;
230
+ context.collect({
231
+ code: "data-unavailable",
232
+ nodeId: node.id,
233
+ name,
234
+ source: bound.source,
235
+ unavailable: { reason: "unreadable-answer", detail: refusal.detail },
236
+ });
237
+ }
238
+ };
132
239
  /**
133
240
  * A diagnostic for every name this node was answered under that its primitive
134
241
  * says it does not read.
@@ -149,8 +256,7 @@ const nodeDataFor = (node, declared, context) => {
149
256
  * declaration may name the prop that names the binding rather than the binding
150
257
  * (0184), and this walk is the only place holding both.
151
258
  */
152
- const reportUnreadBindings = (node, data, context) => {
153
- const declared = context.reads?.bindingsReadBy(node.type);
259
+ const reportUnreadBindings = (node, data, declared, context) => {
154
260
  if (declared === undefined)
155
261
  return;
156
262
  const asked = [];
@@ -160,6 +266,50 @@ const reportUnreadBindings = (node, data, context) => {
160
266
  context.collect({ code: "data-unread", nodeId: node.id, type: node.type, name });
161
267
  }
162
268
  };
269
+ /**
270
+ * A diagnostic for every answer this node's primitive was given whole and drew
271
+ * part of.
272
+ *
273
+ * The one report in this walk the walk cannot make for itself: whether a row can
274
+ * be read is a question about a shape only the primitive holds, so the primitive
275
+ * declares the reading and this is where it is called (0206). Called with the
276
+ * node's props and its answers because those are what the component gets, so the
277
+ * declaration can be the same function the component calls and the count cannot
278
+ * disagree with the page.
279
+ *
280
+ * Silent unless the primitive has declared, the same bargain `reads` makes: a
281
+ * primitive whose author has said nothing is not a primitive claiming it shows
282
+ * everything it is given.
283
+ *
284
+ * A declaration that cannot be believed is reported as itself and costs the node
285
+ * nothing — it renders exactly as it would have, because a count is bookkeeping
286
+ * about an answer rather than part of drawing it.
287
+ */
288
+ const reportUnshownRows = (node, data, context) => {
289
+ const declaration = context.unshown?.unshownBy(node.type);
290
+ if (declaration === undefined)
291
+ return;
292
+ const readings = readUnshown(declaration, node.props, data);
293
+ if (!readings.ok) {
294
+ context.collect({
295
+ code: "unshown-unreadable",
296
+ nodeId: node.id,
297
+ type: node.type,
298
+ fault: readings.error,
299
+ });
300
+ return;
301
+ }
302
+ for (const reading of unshownRows(readings.value)) {
303
+ context.collect({
304
+ code: "data-unshown",
305
+ nodeId: node.id,
306
+ type: node.type,
307
+ name: reading.name,
308
+ given: reading.given,
309
+ shown: reading.shown,
310
+ });
311
+ }
312
+ };
163
313
  /** Whether the resolution answered this node at all. Early-return rather than
164
314
  * `Object.keys`, because it runs on every bound node of every render and the
165
315
  * question is only ever whether the bag is empty. */
@@ -290,15 +440,22 @@ const nodeAnchorFor = (node, reserved, context) => {
290
440
  * rather than from the markup around it, so a copy button copies what the page
291
441
  * says and not the language label its own primitive rendered beside it.
292
442
  *
443
+ * A control's *name* is read from the tree too, where the primitive named a prop
444
+ * for it (0234), and from nowhere else: a type that named none, or a node that
445
+ * left the prop out, gets the string the primitive declared. Read here rather
446
+ * than in the seam because this is where a node's props are, and a behaviour
447
+ * receives the resolved word rather than the props it came out of.
448
+ *
293
449
  * A behaviour whose name could not be resolved is left out and reported, for
294
450
  * the reason `resolveBehaviours` gives: a control a screen reader announces as
295
451
  * "button" is worse than no control, and this is the only place that can say so.
296
452
  */
297
- const nodeBehavioursFor = (node, text, context) => {
453
+ const nodeBehavioursFor = (node, props, text, context) => {
298
454
  const declared = context.behaviours?.behavioursFor(node.type) ?? [];
299
455
  if (declared.length === 0)
300
456
  return NO_RESOLVED_BEHAVIOURS.behaviours;
301
- const resolved = resolveBehaviours(declared, textOf(node), text);
457
+ const named = resolveControlNames(props, context.behaviours?.controlNamePropsFor?.(node.type) ?? NO_CONTROL_NAME_PROPS);
458
+ const resolved = resolveBehaviours(declared, textOf(node), text, named);
302
459
  for (const { behaviour, key } of resolved.unnamed) {
303
460
  context.collect({ code: "behaviour-unnamed", nodeId: node.id, behaviour, key });
304
461
  }
@@ -329,7 +486,17 @@ const reportUnreadReservedProps = (node, reserved, isRoot, context) => {
329
486
  context.collect({ code: "reserved-prop-unrecognised", nodeId: node.id, key });
330
487
  }
331
488
  };
332
- const renderElement = (node, context) => {
489
+ /**
490
+ * Everything about an element that is settled before its children are walked,
491
+ * returned as the assembly that finishes it — or `null` where the node is
492
+ * omitted and its subtree is never walked at all.
493
+ *
494
+ * The split is at the seam `renderElementBody` used to sit on (0380). It is
495
+ * what lets the walk be a loop: the order props are validated in and anchors
496
+ * are claimed in is document order, which this preserves by running on the way
497
+ * down, and the element itself is built on the way up.
498
+ */
499
+ const prepareElement = (node, context) => {
333
500
  const primitive = context.resolver.resolve(node.type);
334
501
  /**
335
502
  * An unknown primitive omits its whole subtree rather than promoting the
@@ -381,40 +548,108 @@ const renderElement = (node, context) => {
381
548
  */
382
549
  const anchor = reserved[ANCHOR_PROP_KEY] === undefined ? undefined : nodeAnchorFor(node, reserved, context);
383
550
  const text = context.text?.textFor(node.type) ?? NO_TEXT;
384
- const behaviours = nodeBehavioursFor(node, text, context);
385
- const body = renderElementBody(node, context);
386
- const rendered = {
387
- loom: renderContextFor(node, body.slots, data, submit, frames, anchor, text, behaviours, context),
388
- props,
389
- children: body.children,
551
+ const behaviours = nodeBehavioursFor(node, props, text, context);
552
+ reportUnplacedSlots(node, context);
553
+ return (body) => {
554
+ const rendered = {
555
+ loom: renderContextFor(node, body.slots, data, submit, frames, anchor, text, behaviours, context),
556
+ props,
557
+ children: body.children,
558
+ };
559
+ return context.literals
560
+ ? literalThemeElement(primitive, context.literals, node.id, rendered)
561
+ : createElement(primitive, { key: node.id, ...rendered });
390
562
  };
391
- return context.literals
392
- ? literalThemeElement(primitive, context.literals, node.id, rendered)
393
- : createElement(primitive, { key: node.id, ...rendered });
394
563
  };
395
564
  /**
396
- * A slot is a projection point, not a box. It renders its projected content, or
397
- * its own children as the fallback when the host projected nothing, and adds no
398
- * element of its own in either case.
565
+ * A slot is a projection point, not a box: it adds no element of its own
566
+ * whether it carries what the host projected or its own children as the
567
+ * fallback. Which of the two it carries is decided in the walk, because only
568
+ * the fallback has children to render first.
399
569
  */
400
- const renderSlot = (node, context) => {
401
- /** Own-property only, for the reason given in `staticPrimitiveResolver`. */
402
- const projected = Object.hasOwn(context.slots, node.name)
403
- ? context.slots[node.name]
404
- : renderChildren(node.children, context);
405
- return createElement(Fragment, { key: node.id }, projected);
570
+ const slotFragment = (node, projected) => createElement(Fragment, { key: node.id }, projected);
571
+ const readChildren = (work, children) => {
572
+ /** Reversed, so the pop order is the document order the recursion gave. */
573
+ for (let index = children.length - 1; index >= 0; index -= 1) {
574
+ const child = children[index];
575
+ if (child)
576
+ work.push({ step: "read", node: child });
577
+ }
406
578
  };
407
- const renderNode = (node, context) => {
408
- switch (node.kind) {
409
- case "element":
410
- return renderElement(node, context);
411
- case "text":
412
- return node.value;
413
- case "slot":
414
- return renderSlot(node, context);
415
- default:
416
- return assertNever(node, "renderNode");
579
+ /**
580
+ * One subtree, rendered with an **explicit stack** and no call frame per level
581
+ * (0380).
582
+ *
583
+ * Until this was a loop, a page of a thousand elements threw
584
+ * `RangeError: Maximum call stack size exceeded` — on **every** render, and at
585
+ * the shallowest depth anything in the framework stopped at. React is not the
586
+ * reason that bound existed: its own server renderer walks fifty thousand
587
+ * levels in 135 ms, so what stopped a deep page was this function.
588
+ *
589
+ * Nothing about the output moves. Elements are prepared on the way down, in
590
+ * document order, which is what the anchor ledger and the diagnostic order
591
+ * depend on; they are built on the way up, around children that are already
592
+ * `ReactNode`s. A node the renderer omits is pushed as `null` and its subtree
593
+ * is never read, which is how a subtree under an unknown primitive stays silent
594
+ * rather than raising a diagnostic per node.
595
+ */
596
+ const renderSubtree = (root, context) => {
597
+ const work = [{ step: "read", node: root }];
598
+ const finished = [];
599
+ /** The last `count` children, taken off the stack in document order. */
600
+ const take = (count) => finished.splice(finished.length - count, count);
601
+ for (let next = work.pop(); next !== undefined; next = work.pop()) {
602
+ switch (next.step) {
603
+ case "build":
604
+ finished.push({
605
+ from: next.node,
606
+ element: next.assemble(elementBodyFrom(next.node, take(next.children))),
607
+ });
608
+ continue;
609
+ case "fill": {
610
+ const fallback = take(next.children);
611
+ finished.push({
612
+ from: next.node,
613
+ element: slotFragment(next.node, fallback.length === 0 ? null : fallback.map((child) => child.element)),
614
+ });
615
+ continue;
616
+ }
617
+ case "read":
618
+ break;
619
+ default:
620
+ return assertNever(next, "renderSubtree");
621
+ }
622
+ const node = next.node;
623
+ switch (node.kind) {
624
+ case "text":
625
+ finished.push({ from: node, element: node.value });
626
+ break;
627
+ case "slot":
628
+ /** Own-property only, for the reason given in `staticPrimitiveResolver`. */
629
+ if (Object.hasOwn(context.slots, node.name)) {
630
+ finished.push({ from: node, element: slotFragment(node, context.slots[node.name]) });
631
+ break;
632
+ }
633
+ work.push({ step: "fill", node, children: node.children.length });
634
+ readChildren(work, node.children);
635
+ break;
636
+ case "element": {
637
+ const assemble = prepareElement(node, context);
638
+ if (!assemble) {
639
+ finished.push({ from: node, element: null });
640
+ break;
641
+ }
642
+ work.push({ step: "build", node, assemble, children: node.children.length });
643
+ readChildren(work, node.children);
644
+ break;
645
+ }
646
+ default:
647
+ return assertNever(node, "renderSubtree");
648
+ }
417
649
  }
650
+ const rendered = finished[0];
651
+ /** Unreachable: one node in, one element out, and every branch pushes one. */
652
+ return rendered ? rendered.element : null;
418
653
  };
419
654
  /**
420
655
  * The theme is resolved once, from the root, before the walk begins — a tree
@@ -492,24 +727,30 @@ const renderFrom = (tree, from, options, collect) => {
492
727
  if (options.themeValues === "literals" && !theme) {
493
728
  collect({ code: "theme-values-unmounted", nodeId: tree.root.id });
494
729
  }
495
- const element = renderNode(from, {
730
+ const element = renderSubtree(from, {
496
731
  resolver: options.resolver,
497
732
  validator: options.validator,
498
733
  editMode: options.editMode ?? false,
499
734
  addressed: options.addressed ?? false,
735
+ audience: options.audience === DEFAULT_AUDIENCE_ID ? undefined : options.audience,
500
736
  slots: options.slots ?? {},
501
737
  tree,
502
- theme: theme ? themeStyle(theme) : undefined,
738
+ theme: theme ? themeStyle(theme, rampFor(options)) : undefined,
503
739
  data: options.data,
504
740
  submissions: options.submissions,
505
741
  origins: options.origins,
506
742
  frames: isFrameResolver(options.resolver) ? options.resolver : undefined,
507
743
  reads: isBindingReader(options.resolver) ? options.resolver : undefined,
744
+ expects: isAnswerReader(options.resolver) ? options.resolver : undefined,
745
+ unshown: isUnshownReader(options.resolver) ? options.resolver : undefined,
746
+ placer: isSlotPlacer(options.resolver) ? options.resolver : undefined,
508
747
  text: composeText(options.resolver, options.text),
509
748
  behaviours: isBehaviourResolver(options.resolver) ? options.resolver : undefined,
510
749
  anchors: createAnchorLedger(),
511
750
  decorative: false,
512
- literals: options.themeValues === "literals" && theme ? themeVariables(theme) : undefined,
751
+ literals: options.themeValues === "literals" && theme
752
+ ? themeVariables(theme, { ramp: rampFor(options) })
753
+ : undefined,
513
754
  collect,
514
755
  });
515
756
  return { element, theme };
@@ -562,7 +803,7 @@ export const renderLoomExcerpt = (tree, nodeId, options) => {
562
803
  }
563
804
  const { element, theme } = renderFrom(tree, from, options, collect);
564
805
  return {
565
- element: createElement("div", { style: theme ? themeStyle(theme) : undefined }, element),
806
+ element: createElement("div", { style: theme ? themeStyle(theme, rampFor(options)) : undefined }, element),
566
807
  diagnostics,
567
808
  found: true,
568
809
  ...(theme ? { theme } : {}),
@@ -1,3 +1,4 @@
1
+ import type { AudienceId } from "../audience/audience.js";
1
2
  import type { DataRegistry } from "../data/adapter.js";
2
3
  import type { FrameOriginRegistry } from "../frame/origin.js";
3
4
  import type { TreeId } from "../ids.js";
@@ -33,8 +34,14 @@ export type RenderRequest = {
33
34
  * they are about. Off when absent (0136).
34
35
  */
35
36
  readonly addressed?: boolean;
37
+ /**
38
+ * The segment the site's server sorted this reader into, written on an
39
+ * addressed page's root so its signals are filed under it. See
40
+ * `RenderOptions.audience`.
41
+ */
42
+ readonly audience?: AudienceId | undefined;
36
43
  /** Opaque host context — audience, locale, flags — passed through to the source. */
37
- readonly context?: JsonObject;
44
+ readonly context?: JsonObject | undefined;
38
45
  };
39
46
  export type TreeSourceError = {
40
47
  readonly code: "not-found" | "unavailable";
@@ -46,6 +46,7 @@ export const renderRequest = async (request, dependencies) => {
46
46
  resolver: dependencies.resolver,
47
47
  editMode: request.editMode,
48
48
  ...(request.addressed ? { addressed: true } : {}),
49
+ audience: request.audience,
49
50
  ...(dependencies.validator ? { validator: dependencies.validator } : {}),
50
51
  ...(dependencies.themes ? { themes: dependencies.themes } : {}),
51
52
  ...(data ? { data } : {}),
@@ -0,0 +1,52 @@
1
+ import type { PrimitiveType, SlotName } from "../primitive-type.js";
2
+ /**
3
+ * What a primitive says it places, and what a tree filled that it will not.
4
+ *
5
+ * A slot child is a named region of authored content, and the name is how the
6
+ * primitive receiving it decides where it goes
7
+ * ([0051](../../decisions/0051-a-slot-is-a-region-the-primitive-places.md)).
8
+ * 0051 states the cost of that in one line — *a primitive that does not place a
9
+ * region renders nothing for it* — and left it at the cost: the content and
10
+ * everything under it is dropped, the page looks finished, and no diagnostic
11
+ * says it happened.
12
+ *
13
+ * This module is the half that makes it visible. It holds the seam the walk
14
+ * asks, and the comparison it makes; what the walk *calls* the mismatch is the
15
+ * diagnostic vocabulary's business, the same split `reads.ts` makes for the
16
+ * binding nobody reads.
17
+ */
18
+ /**
19
+ * Which regions a primitive says it places, asked per type.
20
+ *
21
+ * Structural, and detected the way `BindingReader` and `FrameResolver` are: a
22
+ * registry built by the SDK satisfies it, and a host resolving from a plain map
23
+ * has registered nothing that could declare a region in the first place — so
24
+ * there is nothing here to wire and nothing that can go missing.
25
+ *
26
+ * `undefined` means *this resolver cannot say*, which is the answer for a type
27
+ * no registry holds. It is not a primitive's own answer, and that is the one
28
+ * asymmetry with `reads`: `slots` is the declaration where leaving it out and
29
+ * declaring it empty are the same claim, said so in `definition.ts` since §4
30
+ * and relied on by the catalogue (0013) and by the conformance probe, which
31
+ * reads the declared list as the complete one. So a primitive that has said
32
+ * nothing has said it places none, and the region a tree fills on it is
33
+ * reported.
34
+ */
35
+ export interface SlotPlacer {
36
+ readonly slotsPlacedBy: (type: PrimitiveType) => readonly SlotName[] | undefined;
37
+ }
38
+ export declare const isSlotPlacer: (value: object) => value is SlotPlacer;
39
+ /**
40
+ * The regions this node filled that its primitive places nowhere.
41
+ *
42
+ * Deduplicated, because two slot children may share a name and both be placed
43
+ * (0051) — which means both are dropped together, by one mistake, and a list
44
+ * that said it twice would make the count a function of how many times the tree
45
+ * spelled it.
46
+ *
47
+ * Name-sorted, because the caller reports one diagnostic per name and a
48
+ * diagnostic list whose order depends on child order is one a test can only
49
+ * assert loosely.
50
+ */
51
+ export declare const unplacedSlots: (filled: Iterable<string>, placed: readonly SlotName[] | undefined) => readonly string[];
52
+ //# sourceMappingURL=slots.d.ts.map
@@ -0,0 +1,24 @@
1
+ export const isSlotPlacer = (value) => typeof value.slotsPlacedBy === "function";
2
+ /**
3
+ * The regions this node filled that its primitive places nowhere.
4
+ *
5
+ * Deduplicated, because two slot children may share a name and both be placed
6
+ * (0051) — which means both are dropped together, by one mistake, and a list
7
+ * that said it twice would make the count a function of how many times the tree
8
+ * spelled it.
9
+ *
10
+ * Name-sorted, because the caller reports one diagnostic per name and a
11
+ * diagnostic list whose order depends on child order is one a test can only
12
+ * assert loosely.
13
+ */
14
+ export const unplacedSlots = (filled, placed) => {
15
+ if (placed === undefined)
16
+ return [];
17
+ const places = new Set(placed);
18
+ const unplaced = new Set();
19
+ for (const name of filled)
20
+ if (!places.has(name))
21
+ unplaced.add(name);
22
+ return [...unplaced].sort();
23
+ };
24
+ //# sourceMappingURL=slots.js.map
@@ -1,5 +1,7 @@
1
1
  import type { CSSProperties } from "react";
2
2
  import type { JsonObject } from "../json.js";
3
+ import { type RampMode } from "../theme/apply.js";
4
+ import { type PaletteScheme } from "../theme/measure.js";
3
5
  import type { ThemeError, ThemeRegistry } from "../theme/registry.js";
4
6
  import type { ResolvedTheme } from "../theme/theme.js";
5
7
  /**
@@ -57,5 +59,56 @@ export declare const resolveTheme: (reserved: JsonObject, registry: ThemeRegistr
57
59
  * types-only step, and it happens once here rather than in every primitive that
58
60
  * has to apply it.
59
61
  */
60
- export declare const themeStyle: (theme: ResolvedTheme) => CSSProperties;
62
+ export declare const themeStyle: (theme: ResolvedTheme, ramp?: RampMode) => CSSProperties;
63
+ /**
64
+ * The ground a host paints when it draws a frame standing in for the page.
65
+ *
66
+ * `themeStyle` hands over every variable a primitive reads, and a host drawing a
67
+ * whole page needs nothing else — the root primitive paints `bg-canvas` itself.
68
+ * A host drawing *part* of a tree is the case this exists for: an excerpt rooted
69
+ * at a band has no root primitive above it, so the frame around it has to paint
70
+ * the ground the excerpt would have sat on, and the frame is the host's rather
71
+ * than the tree's.
72
+ *
73
+ * It was written by hand twice before it was here, by one lane, in one week, and
74
+ * the second copy cost a **1.10:1** contrast ratio on the frame whose whole job
75
+ * was to show a stranger what they were about to lose: a stylesheet carried
76
+ * `background-color` and `color-scheme` as constants, the tree's palette moved
77
+ * from a light one to a dark one, and the two stopped agreeing. Nothing errored,
78
+ * because a stylesheet holding a copy of a decision the tree owns is not a thing
79
+ * any test in either place could see (0049).
80
+ *
81
+ * `bg-canvas` rather than `bg-surface`, because that is what the root primitive
82
+ * paints and therefore what is behind any band excerpted out of the page; a band
83
+ * that paints a surface of its own paints it over this, exactly as it does in
84
+ * place. `color` alongside it because a frame setting only the ground leaves
85
+ * anything inheriting its colour reading the *host's* ink on the tree's paper —
86
+ * the tree's own primitives read `--loom-fg-default` and are unaffected, and
87
+ * everything the host puts in that frame is not.
88
+ */
89
+ export type ThemeGround = {
90
+ readonly backgroundColor: string;
91
+ readonly color: string;
92
+ /**
93
+ * Absent — rather than guessed — when either end of the palette's body-copy
94
+ * pair is a colour `channelsOf` declines to read, in which case whatever
95
+ * `color-scheme` the host's own stylesheet sets stands. Every registered
96
+ * palette declares both as hex and resolves.
97
+ */
98
+ readonly colorScheme?: PaletteScheme;
99
+ };
100
+ /**
101
+ * A resolved theme as the three declarations a host's own frame applies.
102
+ *
103
+ * Takes a `ResolvedTheme` and not a `ThemeResolution`, which is the same bargain
104
+ * `themeStyle` makes: there is no fallback theme, so *the tree names no theme* is
105
+ * a case the host has to answer for its own chrome and not one the runtime can
106
+ * answer by handing back a ground. An unthemed excerpt inherits the same nothing
107
+ * an unthemed page does.
108
+ *
109
+ * `undefined` is the other case and a narrower one — a palette whose pair cannot
110
+ * be read. Both ends come from the palette either way, so a frame re-themes with
111
+ * everything else and cannot be legible under one palette and not another.
112
+ */
113
+ export declare const themeGround: (theme: ResolvedTheme) => ThemeGround | undefined;
61
114
  //# sourceMappingURL=theme.d.ts.map