@homepages/concrete 8.0.0 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. package/CHANGELOG.md +1005 -0
  2. package/README.md +20 -9
  3. package/codemods/list-grammar.mjs +923 -0
  4. package/codemods/manifest.json +64 -0
  5. package/codemods/process-builders.mjs +198 -0
  6. package/codemods/slot-object.mjs +1097 -0
  7. package/codemods/steps/content-object-fields.mjs +324 -0
  8. package/codemods/steps/list-object-form.mjs +6 -7
  9. package/codemods/table-rows.mjs +568 -0
  10. package/codemods/unwrap-object-fields.mjs +310 -0
  11. package/codemods/viewer-slot-document.mjs +131 -0
  12. package/codemods/write-property-as-facts-document.mjs +716 -0
  13. package/codemods/write-the-address-line.mjs +255 -0
  14. package/codemods/write-the-registry-members.mjs +653 -0
  15. package/codemods/write-the-select-from.mjs +141 -0
  16. package/codemods/write-the-sole-from.mjs +369 -0
  17. package/codemods/write-the-table-from.mjs +267 -0
  18. package/codemods/write-the-whole-item.mjs +512 -0
  19. package/codemods/writeback-drop.mjs +168 -0
  20. package/codemods/written-contact-address.mjs +162 -0
  21. package/codemods/written-media-category.mjs +227 -0
  22. package/codemods/written-ref-kinds-name-the-layer.mjs +172 -0
  23. package/codemods/written-uploads-replace-pool-reads.mjs +454 -0
  24. package/codemods/written-uploads-sort-into-lists.mjs +405 -0
  25. package/codemods/written-uploads-stated-in-sorted-lists.mjs +295 -0
  26. package/codemods/written-video-sources-drop.mjs +144 -0
  27. package/codemods/written-without-pick-none.mjs +146 -0
  28. package/codemods/written-without-retired-knowledge.mjs +223 -0
  29. package/codemods/written-without-the-media-key.mjs +202 -0
  30. package/codemods/written-without-the-property-type.mjs +249 -0
  31. package/dist/artifact/playground/client/assets/index-BOYbgBnP.js +1259 -0
  32. package/dist/artifact/playground/client/assets/index-DDOcM0zA.css +1 -0
  33. package/dist/artifact/playground/client/index.html +2 -2
  34. package/dist/artifact/playground/client/island-canvas-host.mjs +1 -1
  35. package/dist/artifact/playground/host.mjs +61 -27
  36. package/dist/base.css +58 -1
  37. package/dist/cli/build/artifact.js +6 -9
  38. package/dist/cli/build/captures.js +2 -12
  39. package/dist/cli/build/esbuild.js +1 -25
  40. package/dist/cli/build/fixtures.js +2 -1
  41. package/dist/cli/build/icons.js +1 -1
  42. package/dist/cli/build/static.js +2 -2
  43. package/dist/cli/capture/capture.js +8 -9
  44. package/dist/cli/check/analyze.js +8 -1
  45. package/dist/cli/check/load-outdir.js +47 -0
  46. package/dist/cli/check/load-workspace.js +4 -4
  47. package/dist/cli/check/render/html.js +1 -2
  48. package/dist/cli/check/render/inputs.js +10 -3
  49. package/dist/cli/check/render/island-frames.js +2 -1
  50. package/dist/cli/check/render/marker-coverage.js +23 -15
  51. package/dist/cli/check/report.js +5 -0
  52. package/dist/cli/check/stages/bundles.js +1 -1
  53. package/dist/cli/check/stages/relations.js +1 -1
  54. package/dist/cli/check/stages/render.js +48 -33
  55. package/dist/cli/check/stages/sections.js +83 -31
  56. package/dist/cli/check/stages/workspace.js +2 -0
  57. package/dist/cli/check/template-key.js +16 -0
  58. package/dist/cli/commands.js +1 -1
  59. package/dist/cli/dev/crop.js +1 -1
  60. package/dist/cli/dev/fixture-ladders.js +96 -0
  61. package/dist/cli/dev/islands.js +12 -123
  62. package/dist/cli/dev/listen.js +20 -1
  63. package/dist/cli/dev/load-template.js +1 -1
  64. package/dist/cli/dev/server.js +35 -10
  65. package/dist/cli/dev/vite.js +9 -7
  66. package/dist/cli/dev/workspace-reader.js +16 -16
  67. package/dist/cli/media/derive.js +43 -57
  68. package/dist/cli/media/frame-rung-floor.js +0 -1
  69. package/dist/cli/property/index.js +1 -6
  70. package/dist/css/inline.js +1 -22
  71. package/dist/eslint/rules/no-marker-literal.js +1 -1
  72. package/dist/fixtures/load.js +16 -7
  73. package/dist/fixtures/media-plugin.js +17 -12
  74. package/dist/fixtures/media-store.js +115 -0
  75. package/dist/fixtures/property.js +345 -126
  76. package/dist/fixtures/resolve.js +260 -251
  77. package/dist/fixtures/rows.js +4 -11
  78. package/dist/fixtures.d.ts +234 -109
  79. package/dist/index.d.ts +25 -16
  80. package/dist/index.js +10 -6
  81. package/dist/islands/marker.js +2 -1
  82. package/dist/packages/external/concrete/package.js +1 -1
  83. package/dist/packages/internal/canvas-core/dist/island-host.js +62 -0
  84. package/dist/packages/internal/canvas-core/dist/island-shields.js +30 -0
  85. package/dist/packages/internal/capture-settle/dist/index.js +3 -0
  86. package/dist/packages/internal/capture-settle/dist/island-markers.d.ts +13 -0
  87. package/dist/packages/internal/capture-settle/dist/island-markers.js +6 -0
  88. package/dist/packages/internal/capture-settle/dist/settle.js +150 -0
  89. package/dist/packages/internal/{image-ladder/dist/crop.js → crop-region/dist/index.js} +21 -20
  90. package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +250 -46
  91. package/dist/packages/internal/fill-bake/dist/compute-reads.js +361 -4
  92. package/dist/packages/internal/fill-bake/dist/derive-source.js +25 -18
  93. package/dist/packages/internal/fill-bake/dist/index.js +9 -3
  94. package/dist/packages/internal/fill-bake/dist/item-merge.js +113 -0
  95. package/dist/packages/internal/fill-bake/dist/item-overrides.js +1 -0
  96. package/dist/packages/internal/fill-bake/dist/linked-merge.js +38 -0
  97. package/dist/packages/internal/fill-bake/dist/list-grammar.js +174 -0
  98. package/dist/packages/internal/fill-bake/dist/stored-row-reader.js +1 -0
  99. package/dist/packages/internal/fill-vocabulary/dist/holder.js +51 -0
  100. package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +363 -0
  101. package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -23
  102. package/dist/packages/internal/fill-vocabulary/dist/verbs.js +60 -0
  103. package/dist/packages/internal/format-geometry/dist/capture.js +11 -147
  104. package/dist/packages/internal/format-geometry/dist/format.d.ts +8 -2
  105. package/dist/packages/internal/format-geometry/dist/geometry.js +13 -2
  106. package/dist/packages/internal/image-ladder/dist/encode.js +27 -14
  107. package/dist/packages/internal/image-ladder/dist/index.js +3 -3
  108. package/dist/packages/internal/image-ladder/dist/policy.js +28 -53
  109. package/dist/packages/internal/island-runtime/dist/capture-holds.js +1 -1
  110. package/dist/packages/internal/island-runtime/dist/contract.d.ts +3 -12
  111. package/dist/packages/internal/island-runtime/dist/contract.js +2 -2
  112. package/dist/packages/internal/island-runtime/dist/index.d.ts +3 -7
  113. package/dist/packages/internal/island-runtime/dist/index.js +2 -1
  114. package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +1 -1
  115. package/dist/packages/internal/media-resolution/dist/crop-key.js +7 -0
  116. package/dist/packages/internal/media-resolution/dist/document.js +63 -0
  117. package/dist/packages/internal/media-resolution/dist/image.js +226 -0
  118. package/dist/packages/internal/media-resolution/dist/index.js +11 -0
  119. package/dist/packages/internal/media-resolution/dist/list.js +112 -0
  120. package/dist/packages/internal/media-resolution/dist/media.js +59 -0
  121. package/dist/packages/internal/media-resolution/dist/records.js +7 -0
  122. package/dist/packages/internal/media-resolution/dist/slot.js +37 -0
  123. package/dist/packages/internal/media-resolution/dist/store.js +19 -0
  124. package/dist/packages/internal/media-resolution/dist/tour.js +59 -0
  125. package/dist/packages/internal/media-resolution/dist/video.js +93 -0
  126. package/dist/packages/internal/property-facts/dist/registry-facts.js +245 -0
  127. package/dist/packages/internal/section-contracts/dist/cap-contract.js +8 -17
  128. package/dist/packages/internal/section-contracts/dist/catalog.js +34 -14
  129. package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +11 -2
  130. package/dist/packages/internal/section-contracts/dist/directly-linked-list-contract.js +21 -0
  131. package/dist/packages/internal/section-contracts/dist/fill-options.js +12 -0
  132. package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +1 -5
  133. package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +95 -0
  134. package/dist/packages/internal/section-contracts/dist/grammar-scope.js +154 -0
  135. package/dist/packages/internal/section-contracts/dist/index.js +7 -2
  136. package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +2 -36
  137. package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +12 -21
  138. package/dist/packages/internal/section-contracts/dist/list-source-contract.js +46 -0
  139. package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +11 -2
  140. package/dist/packages/internal/section-contracts/dist/object-contract.js +92 -0
  141. package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +9 -5
  142. package/dist/packages/internal/section-contracts/dist/reads-acyclic-contract.js +63 -0
  143. package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +6 -17
  144. package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +80 -0
  145. package/dist/packages/internal/section-contracts/dist/row-source-contract.js +67 -0
  146. package/dist/packages/internal/section-contracts/dist/runners.js +77 -18
  147. package/dist/packages/internal/section-contracts/dist/select-contract.js +0 -8
  148. package/dist/packages/internal/section-contracts/dist/source-contract.js +89 -95
  149. package/dist/packages/internal/section-contracts/dist/sources-contract.js +47 -17
  150. package/dist/packages/internal/section-contracts/dist/table-member.js +16 -0
  151. package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +39 -23
  152. package/dist/packages/internal/source-resolution/dist/index.js +113 -73
  153. package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +16 -0
  154. package/dist/packages/internal/street-address/dist/index.js +72 -0
  155. package/dist/packages/internal/template-artifact/dist/asset-mime.js +30 -0
  156. package/dist/packages/internal/template-artifact/dist/layout.js +1 -2
  157. package/dist/packages/internal/template-artifact/dist/manifest.js +1 -1
  158. package/dist/packages/internal/template-artifact/dist/verify.js +12 -29
  159. package/dist/packages/internal/template-contracts/dist/address-value.d.ts +52 -0
  160. package/dist/packages/internal/template-contracts/dist/address-value.js +90 -0
  161. package/dist/packages/internal/template-contracts/dist/comparable-address.js +19 -0
  162. package/dist/{schema → packages/internal/template-contracts/dist}/compute.d.ts +29 -6
  163. package/dist/{schema → packages/internal/template-contracts/dist}/compute.js +11 -13
  164. package/dist/packages/internal/template-contracts/dist/content-pick.js +51 -0
  165. package/dist/packages/internal/template-contracts/dist/decision-fills.js +81 -0
  166. package/dist/packages/internal/template-contracts/dist/display-overrides.js +7 -0
  167. package/dist/packages/internal/template-contracts/dist/document-value.d.ts +16 -5
  168. package/dist/packages/internal/template-contracts/dist/fact-compute.d.ts +24 -0
  169. package/dist/packages/internal/template-contracts/dist/fact-compute.js +30 -0
  170. package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +44 -0
  171. package/dist/packages/internal/template-contracts/dist/fact-keys.js +88 -0
  172. package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +290 -0
  173. package/dist/packages/internal/template-contracts/dist/fact-registry.js +598 -0
  174. package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +10 -24
  175. package/dist/packages/internal/template-contracts/dist/fill-builders.d.ts +157 -0
  176. package/dist/packages/internal/template-contracts/dist/fill-builders.js +79 -0
  177. package/dist/packages/internal/template-contracts/dist/fill-declaration.d.ts +14 -0
  178. package/dist/{schema → packages/internal/template-contracts/dist}/fill-declaration.js +6 -5
  179. package/dist/packages/internal/template-contracts/dist/fill-spec-schema.js +93 -0
  180. package/dist/packages/internal/template-contracts/dist/fill-spec.js +291 -0
  181. package/dist/packages/internal/template-contracts/dist/findable.js +8 -0
  182. package/dist/packages/internal/template-contracts/dist/floor-presets.js +13 -0
  183. package/dist/packages/internal/template-contracts/dist/icon-names.d.ts +5 -0
  184. package/dist/packages/internal/template-contracts/dist/icon-names.js +70 -0
  185. package/dist/packages/internal/template-contracts/dist/legacy-facts.js +167 -0
  186. package/dist/packages/internal/template-contracts/dist/list-editing.js +93 -0
  187. package/dist/packages/internal/template-contracts/dist/list.d.ts +215 -0
  188. package/dist/packages/internal/template-contracts/dist/list.js +258 -0
  189. package/dist/packages/internal/template-contracts/dist/markers.d.ts +2 -2
  190. package/dist/packages/internal/template-contracts/dist/media-candidates.js +38 -0
  191. package/dist/packages/internal/template-contracts/dist/mirror-kind.js +48 -0
  192. package/dist/packages/internal/template-contracts/dist/number-display.js +10 -0
  193. package/dist/packages/internal/template-contracts/dist/object.d.ts +89 -0
  194. package/dist/packages/internal/template-contracts/dist/object.js +131 -0
  195. package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +1 -1
  196. package/dist/packages/internal/template-contracts/dist/primitive-descriptors.d.ts +1 -0
  197. package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +162 -0
  198. package/dist/packages/internal/template-contracts/dist/process-builders.d.ts +77 -0
  199. package/dist/packages/internal/template-contracts/dist/process-builders.js +73 -0
  200. package/dist/packages/internal/template-contracts/dist/read-graph.js +240 -0
  201. package/dist/packages/internal/template-contracts/dist/ref-locate.js +176 -0
  202. package/dist/packages/internal/template-contracts/dist/registry-aliases.js +77 -0
  203. package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +270 -0
  204. package/dist/packages/internal/template-contracts/dist/registry-facts.js +202 -0
  205. package/dist/packages/internal/template-contracts/dist/registry-shape.d.ts +41 -0
  206. package/dist/packages/internal/template-contracts/dist/registry-shape.js +135 -0
  207. package/dist/packages/internal/template-contracts/dist/resolve-scope.js +103 -0
  208. package/dist/packages/internal/{image-descriptor/dist/index.d.ts → template-contracts/dist/responsive-image.d.ts} +1 -1
  209. package/dist/packages/internal/template-contracts/dist/row-planners.js +29 -0
  210. package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +127 -0
  211. package/dist/packages/internal/template-contracts/dist/row-ref.js +101 -0
  212. package/dist/packages/internal/template-contracts/dist/row-sources.js +41 -5
  213. package/dist/packages/internal/template-contracts/dist/row.d.ts +155 -0
  214. package/dist/packages/internal/template-contracts/dist/row.js +84 -0
  215. package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +97 -0
  216. package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +782 -0
  217. package/dist/packages/internal/template-contracts/dist/slot-builders.js +233 -0
  218. package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +233 -405
  219. package/dist/packages/internal/template-contracts/dist/slot-catalog.js +331 -227
  220. package/dist/packages/internal/template-contracts/dist/slot-overrides.js +21 -0
  221. package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +155 -0
  222. package/dist/packages/internal/template-contracts/dist/slot-ref.js +76 -0
  223. package/dist/packages/internal/template-contracts/dist/slot-types.d.ts +163 -0
  224. package/dist/packages/internal/template-contracts/dist/slot-types.js +139 -0
  225. package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +95 -0
  226. package/dist/packages/internal/template-contracts/dist/table-members.d.ts +25 -0
  227. package/dist/packages/internal/template-contracts/dist/table-members.js +90 -0
  228. package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +5 -5
  229. package/dist/packages/internal/template-contracts/dist/value-contracts.js +15 -0
  230. package/dist/packages/internal/template-contracts/dist/video-value.d.ts +2 -2
  231. package/dist/platform/fs.js +5 -2
  232. package/dist/playground/canvas-island-host.d.ts +11 -0
  233. package/dist/playground/canvas-island-host.js +29 -0
  234. package/dist/playground/canvas-markers.js +14 -0
  235. package/dist/playground-island-runtime.d.ts +3 -2
  236. package/dist/playground-island-runtime.js +3 -2
  237. package/dist/primitives/FrameShell.js +0 -1
  238. package/dist/primitives/Image.d.ts +5 -4
  239. package/dist/primitives/Tour.d.ts +1 -1
  240. package/dist/primitives/Video.d.ts +2 -2
  241. package/dist/primitives/index.d.ts +2 -3
  242. package/dist/primitives/picture-sources.js +2 -2
  243. package/dist/primitives/probe-context.js +2 -12
  244. package/dist/primitives/slot-address.d.ts +44 -0
  245. package/dist/primitives/slot-address.js +19 -0
  246. package/dist/primitives/slot-bindings.d.ts +65 -26
  247. package/dist/primitives/slot-bindings.js +104 -46
  248. package/dist/primitives/slot-document.d.ts +23 -18
  249. package/dist/primitives/slot-document.js +39 -14
  250. package/dist/primitives/slot-download.d.ts +39 -0
  251. package/dist/primitives/slot-download.js +39 -0
  252. package/dist/primitives/slot-list.d.ts +3 -3
  253. package/dist/primitives/slot-list.js +0 -2
  254. package/dist/primitives/slot-media.d.ts +24 -5
  255. package/dist/primitives/slot-media.js +6 -9
  256. package/dist/primitives/slot-object.d.ts +49 -0
  257. package/dist/primitives/slot-object.js +20 -0
  258. package/dist/primitives/slot-scalar.d.ts +27 -2
  259. package/dist/primitives/slot-scalar.js +50 -7
  260. package/dist/primitives/slot.d.ts +13 -6
  261. package/dist/primitives/slot.js +10 -3
  262. package/dist/rules/registry.js +25 -30
  263. package/dist/schema/define-schema.d.ts +4 -8
  264. package/dist/schema/define-schema.js +178 -79
  265. package/dist/schema/extract-fill-spec.js +2 -153
  266. package/dist/schema/fact.d.ts +57 -15
  267. package/dist/schema/fact.js +42 -7
  268. package/dist/schema/facts-view.d.ts +14 -0
  269. package/dist/schema/format.d.ts +1 -0
  270. package/dist/schema/format.js +2 -1
  271. package/dist/schema/manifest.js +24 -0
  272. package/dist/schema/property-facts.d.ts +8 -12
  273. package/dist/schema/section-props.d.ts +2 -66
  274. package/dist/schema/section-schema.d.ts +8 -11
  275. package/dist/schema/section-schema.js +27 -10
  276. package/dist/section/declare.d.ts +18 -7
  277. package/dist/section/declare.js +18 -5
  278. package/dist/section/materialize.js +3 -8
  279. package/dist/section/section.d.ts +12 -8
  280. package/dist/section/section.js +1 -1
  281. package/dist/template/logic-shim.d.ts +14 -7
  282. package/dist/template/logic-shim.js +14 -7
  283. package/dist/template/materialize.js +17 -18
  284. package/dist/template/mirror-types.js +30 -31
  285. package/dist/template/section-reads.js +85 -9
  286. package/guide/reference/cli/INDEX.md +2 -2
  287. package/guide/reference/cli/build.md +1 -1
  288. package/guide/reference/cli/check.md +1 -1
  289. package/guide/reference/cli/dev.md +1 -1
  290. package/guide/reference/cli/property-add.md +1 -1
  291. package/guide/reference/cli/property-list.md +2 -2
  292. package/guide/reference/cli/publish.md +1 -1
  293. package/guide/reference/cli/upgrade.md +1 -1
  294. package/guide/reference/rules/INDEX.md +29 -25
  295. package/package.json +9 -8
  296. package/dist/artifact/playground/client/assets/index-CckS2ONm.css +0 -1
  297. package/dist/artifact/playground/client/assets/index-Dn_xT16-.js +0 -1101
  298. package/dist/fixtures/canonical.d.ts +0 -166
  299. package/dist/fixtures/media.js +0 -163
  300. package/dist/packages/internal/fill-vocabulary/dist/origination.js +0 -51
  301. package/dist/packages/internal/fill-vocabulary/dist/row-reads.js +0 -15
  302. package/dist/packages/internal/format-geometry/dist/index.js +0 -4
  303. package/dist/packages/internal/property-facts/dist/derive-facts-view.js +0 -10
  304. package/dist/packages/internal/property-facts/dist/index.js +0 -3
  305. package/dist/packages/internal/property-facts/dist/property-facts-Cy7-O4p0.js +0 -189
  306. package/dist/packages/internal/section-contracts/dist/group-contract.js +0 -19
  307. package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +0 -24
  308. package/dist/packages/internal/template-contracts/dist/collection-editing.js +0 -22
  309. package/dist/packages/internal/template-contracts/dist/facts-view.js +0 -104
  310. package/dist/packages/internal/template-contracts/dist/select-key.js +0 -7
  311. package/dist/primitives/slot-group.d.ts +0 -40
  312. package/dist/primitives/slot-group.js +0 -36
  313. package/dist/schema/extract-used-facts.js +0 -34
  314. package/dist/schema/fill-builders.d.ts +0 -115
  315. package/dist/schema/fill-builders.js +0 -25
  316. package/dist/schema/fill-declaration.d.ts +0 -14
  317. package/dist/schema/fill-spec.js +0 -98
  318. package/dist/schema/layout.d.ts +0 -30
  319. package/dist/schema/layout.js +0 -14
  320. package/dist/schema/row-fields.js +0 -88
  321. package/dist/schema/row-ref.d.ts +0 -59
  322. package/dist/schema/row-ref.js +0 -28
  323. package/dist/schema/runtime-values.d.ts +0 -71
  324. package/dist/schema/section-nav.js +0 -14
  325. package/dist/schema/slot-builders.d.ts +0 -633
  326. package/dist/schema/slot-builders.js +0 -177
  327. package/dist/schema/slot-ref.d.ts +0 -79
  328. package/dist/schema/slot-ref.js +0 -41
  329. package/dist/schema/slot-types.d.ts +0 -111
  330. package/dist/schema/slot-types.js +0 -214
  331. package/dist/section/groups.js +0 -68
@@ -1,11 +1,13 @@
1
- import { COMPUTED, isComputeBinding } from "./compute.js";
2
- import { isFillBinding } from "./fill-builders.js";
3
- import { FILL, FILL_SECTION, fillMark, getFill } from "./fill-declaration.js";
4
- import { groupsFromLayout } from "./layout.js";
5
- import { isSiblingSlot, isSlotRef, serializeRef } from "./slot-ref.js";
1
+ import { isFactRef, isSiblingPage, isSiblingSlot, isSiblingSource, serializeRef } from "../packages/internal/template-contracts/dist/slot-ref.js";
2
+ import { COMPUTED, isComputeBinding } from "../packages/internal/template-contracts/dist/compute.js";
3
+ import { isFillBinding } from "../packages/internal/template-contracts/dist/fill-builders.js";
4
+ import { FILL, FILL_SECTION, fillMark, getFills } from "../packages/internal/template-contracts/dist/fill-declaration.js";
5
+ import { mapSlotRefs, memberResolver, ownKeyRead, ownKeyRefusal, plainSlot, rowScope, unresolvedMember } from "../packages/internal/template-contracts/dist/resolve-scope.js";
6
+ import { declaredFields } from "../packages/internal/template-contracts/dist/object.js";
7
+ import { isReadableFactKey } from "../packages/internal/template-contracts/dist/fact-keys.js";
6
8
 
7
9
  //#region src/schema/define-schema.ts
8
- function derivedSource(transform, reads) {
10
+ function derivedSource(transform, reads, requires) {
9
11
  if (reads === void 0 || reads.length === 0) return {
10
12
  kind: "derived",
11
13
  transform
@@ -13,45 +15,169 @@ function derivedSource(transform, reads) {
13
15
  return {
14
16
  kind: "derived",
15
17
  transform,
16
- reads: reads.map(serializeRef)
18
+ reads: reads.map(serializeRef),
19
+ ...requires === void 0 || requires.length === 0 ? {} : { requires: requires.map(serializeRef) }
17
20
  };
18
21
  }
19
- function siblingResolver(sectionKey, slots) {
20
- const keyOf = new Map(Object.entries(slots).map(([key, slot]) => [slot, key]));
21
- return (at, reads) => reads?.map((read) => {
22
- if (!isSiblingSlot(read)) return read;
23
- const slot = keyOf.get(read);
24
- if (slot === void 0) throw new Error(`\`${at}\` reads the slot "${read.label}", which is not a slot of this section. Read another section's slot through its ref (\`Section.slots.<key>\`), and a sibling through the const the section's \`slots\` record holds.`);
25
- if (sectionKey === void 0) throw new Error(`\`${at}\` reads its sibling slot "${slot}", which needs the section's key — declare it with \`section()\`.`);
26
- return {
27
- section: sectionKey,
28
- slot
29
- };
30
- });
22
+ function assertRequires(at, requires) {
23
+ for (const required of requires ?? []) {
24
+ if (!isFactRef(required)) throw new Error(`\`${at}\` requires a read that is no fact — \`requires\` names the facts the value cannot do without (\`fact.property.address\`). A slot's own requirement is its holder's: mark that slot \`required\`.`);
25
+ if (!isReadableFactKey(required.key)) throw new Error(`\`${at}\` requires "${required.key}", which is not a fact the registry declares.`);
26
+ }
31
27
  }
32
- function resolveBindingReads(at, binding, resolveReads) {
33
- const reads = binding?.reads;
34
- if (binding === void 0 || reads === void 0 || !reads.some(isSiblingSlot)) return binding;
35
- const resolved = resolveReads(at, reads) ?? [];
36
- const upstream = resolved[reads.findIndex((read) => isSiblingSlot(read) && read.source !== void 0)];
37
- if (upstream !== void 0 && isSlotRef(upstream)) throw new Error(`\`${at}\` is filled and reads its sibling slot "${upstream.slot}", which is sourced — a fact, a \`compute()\` or another slot settles it, not a fill. A sourced value settles at finalize, AFTER every fill has run, so the fill would read nothing. Read the refs that slot reads instead, or read a slot a fill writes.`);
38
- const sibling = resolved[reads.findIndex(isSiblingSlot)];
39
- const section = sibling !== void 0 && isSlotRef(sibling) ? sibling.section : void 0;
28
+ function computeSource(scope, at, binding) {
29
+ const resolve = (refs) => refs.map((read) => resolveRead(scope, at, read));
30
+ const requires = binding.requires === void 0 ? void 0 : resolve(binding.requires);
31
+ assertRequires(at, requires);
32
+ return derivedSource(at, resolve(binding.reads), requires);
33
+ }
34
+ function siblingKeys(slots) {
35
+ const keys = /* @__PURE__ */ new Map();
36
+ for (const [key, slot] of Object.entries(slots)) {
37
+ keys.set(slot, key);
38
+ if (slot.type !== "object") continue;
39
+ for (const fields of [slot.fields, declaredFields(slot) ?? {}]) for (const [field, def] of Object.entries(fields)) keys.set(def, `${key}.${field}`);
40
+ }
41
+ return keys;
42
+ }
43
+ function sectionRows(slots) {
44
+ const rows = rowScope(slots);
45
+ for (const [key, slot] of Object.entries(slots)) {
46
+ if (slot.type !== "object") continue;
47
+ for (const [row, field] of rowScope(declaredFields(slot) ?? {})) if (!rows.has(row)) rows.set(row, `${key}.${field}`);
48
+ }
49
+ return rows;
50
+ }
51
+ function siblingRef(scope, at, read) {
52
+ const slot = scope.keyOf.get(read);
53
+ if (slot === void 0) throw new Error(`\`${at}\` reads the slot "${String(read.label ?? read.type)}", which is neither a top-level slot of this section nor a field of one of its objects. Read another section's slot through its ref (\`Section.slots.<key>\`), a sibling or an object's field through the const the section declares it with, and a field of a list's item through the row or the element it reads.`);
54
+ if (scope.sectionKey === void 0) throw new Error(`\`${at}\` reads its sibling slot "${slot}", which needs the section's key — declare it with \`section()\`.`);
40
55
  return {
41
- ...binding,
42
- reads: resolved,
43
- [FILL_SECTION]: section
56
+ section: scope.sectionKey,
57
+ slot
58
+ };
59
+ }
60
+ function resolveRead(scope, at, read) {
61
+ const member = scope.members(read);
62
+ if (member !== read) return member;
63
+ if (isSiblingPage(read)) throw new Error(`\`${at}\` reads a fact registry's page — a section reads a fact through \`fact.*\` (\`fact.property.address\`), never a registry's own declaration.`);
64
+ return isSiblingSlot(read) ? siblingRef(scope, at, read) : read;
65
+ }
66
+ function refuseRegistryKeys(path, slot) {
67
+ const def = slot;
68
+ if (def.type === "list" && isComputeBinding(def.max)) throw new Error(`\`${path}\` computes its \`max\` — no section runner reads a computed bound; declare a number, or bound the list where its items are produced.`);
69
+ if (def.element !== void 0) refuseRegistryKeys(path, def.element);
70
+ if (def.fields !== void 0) for (const [key, field] of Object.entries(def.fields)) refuseRegistryKeys(`${path}.${key}`, field);
71
+ }
72
+ function resolveFill(scope, at, binding) {
73
+ let out;
74
+ const reads = binding.reads;
75
+ if (reads !== void 0) {
76
+ const sourced = reads.find((read) => isSiblingSlot(read) && read.source !== void 0);
77
+ if (sourced !== void 0) {
78
+ const upstream = siblingRef(scope, at, sourced);
79
+ throw new Error(`\`${at}\` is filled and reads its sibling slot "${upstream.slot}", which is sourced — a fact, a \`compute()\` or another slot settles it, not a fill. A sourced value settles at finalize, AFTER every fill has run, so the fill would read nothing. Read the refs that slot reads instead, or read a slot a fill writes.`);
80
+ }
81
+ const resolved = reads.map((read) => resolveRead(scope, at, read));
82
+ if (resolved.some((read, i) => read !== reads[i])) {
83
+ const sameSection = reads.some(isSiblingSlot) ? scope.sectionKey : void 0;
84
+ out = {
85
+ ...binding,
86
+ reads: resolved,
87
+ [FILL_SECTION]: sameSection
88
+ };
89
+ }
90
+ }
91
+ assertRequires(at, binding.requires);
92
+ return out ?? binding;
93
+ }
94
+ function resolveSlot(scope, path, slot) {
95
+ const ownKey = ownKeyRead(slot, scope.rows, path);
96
+ if (ownKey !== void 0) throw new Error(`\`${path}\` ${ownKeyRefusal(ownKey)}`);
97
+ let out = mapSlotRefs(slot, scope.members);
98
+ const source = out.source;
99
+ if (isComputeBinding(source)) {
100
+ scope.computed[path] = source.fn;
101
+ out = {
102
+ ...out,
103
+ source: computeSource(scope, path, source)
104
+ };
105
+ } else if (isSiblingSource(source)) out = {
106
+ ...out,
107
+ source: {
108
+ kind: "section",
109
+ ...siblingRef(scope, path, source.of)
110
+ }
44
111
  };
112
+ const fills = getFills(out);
113
+ if (fills !== void 0) {
114
+ const resolved = fills.map((binding) => resolveFill(scope, path, binding));
115
+ if (resolved.some((binding, i) => binding !== fills[i])) out = {
116
+ ...out,
117
+ [FILL]: resolved
118
+ };
119
+ }
120
+ out = withVariant(out);
121
+ const member = unresolvedMember(out);
122
+ if (member !== void 0) throw new Error(`\`${path}\` reads the member "${member}" of a row that is not in scope — a member is read through a row declared beside its reader (a field of the same object or item), at the section's top level, or as a field of a top-level object.`);
123
+ return plainSlot(out);
45
124
  }
46
- function resolveFillReads(at, slot, resolveReads) {
47
- const binding = getFill(slot);
48
- const resolved = resolveBindingReads(at, binding, resolveReads);
49
- return resolved === binding ? slot : {
50
- ...slot,
51
- [FILL]: resolved
125
+ function withVariant(slot) {
126
+ const when = slot.when;
127
+ if (when === void 0) return slot;
128
+ const rewritten = { ...slot };
129
+ delete rewritten.when;
130
+ rewritten.variant = { cases: typeof when === "string" ? [when] : [...when] };
131
+ return rewritten;
132
+ }
133
+ function resolveNestedItem(list) {
134
+ const element = list.element;
135
+ if (element?.type !== "object") return list;
136
+ const fields = {};
137
+ let changed = false;
138
+ for (const [field, def] of Object.entries(element.fields)) {
139
+ fields[field] = withVariant(def);
140
+ if (fields[field] !== def) changed = true;
141
+ }
142
+ const item = withVariant(changed ? {
143
+ ...element,
144
+ fields
145
+ } : element);
146
+ return item === element ? list : {
147
+ ...list,
148
+ element: item
52
149
  };
53
150
  }
54
- function emitDisplay(display, computed, resolveReads) {
151
+ function resolveFields(scope, container, object) {
152
+ const fields = {};
153
+ let changed = false;
154
+ for (const [field, def] of Object.entries(object.fields)) {
155
+ fields[field] = resolveNestedItem(resolveSlot(scope, `${container}.${field}`, def));
156
+ if (fields[field] !== def) changed = true;
157
+ }
158
+ return changed ? {
159
+ ...object,
160
+ fields
161
+ } : object;
162
+ }
163
+ function resolveTopLevel(scope, key, slot) {
164
+ if (slot.type === "object") {
165
+ let out = resolveFields(scope, key, slot);
166
+ if (out.when !== void 0) out = resolveSlot(scope, key, out);
167
+ return out;
168
+ }
169
+ let out = resolveSlot(scope, key, slot);
170
+ if (out.type === "list" && out.element !== void 0) {
171
+ const element = out.element;
172
+ const resolved = element.type === "object" ? resolveFields(scope, key, element) : resolveSlot(scope, key, element);
173
+ if (resolved !== element) out = {
174
+ ...out,
175
+ element: resolved
176
+ };
177
+ }
178
+ return out;
179
+ }
180
+ function emitDisplay(display, scope) {
55
181
  const out = {};
56
182
  for (const key of ["visibility", "variant"]) {
57
183
  const entry = display[key];
@@ -60,11 +186,11 @@ function emitDisplay(display, computed, resolveReads) {
60
186
  const emitted = { cases: [...entry.cases] };
61
187
  if (entry.locked === true) emitted.locked = true;
62
188
  if (isComputeBinding(entry.source)) {
63
- computed[at] = entry.source.fn;
64
- emitted.source = derivedSource(at, resolveReads(at, entry.source.reads));
189
+ scope.computed[at] = entry.source.fn;
190
+ emitted.source = computeSource(scope, at, entry.source);
65
191
  } else if (isFillBinding(entry.source)) emitted.fill = {
66
192
  pick: entry.source.brief,
67
- ...fillMark(resolveBindingReads(at, entry.source, resolveReads))
193
+ ...fillMark(resolveFill(scope, at, entry.source))
68
194
  };
69
195
  else if (entry.source !== void 0) emitted.source = entry.source;
70
196
  out[key] = emitted;
@@ -73,51 +199,24 @@ function emitDisplay(display, computed, resolveReads) {
73
199
  }
74
200
  function defineSchema(input) {
75
201
  const computed = {};
76
- const resolveReads = siblingResolver(input.key, input.slots);
202
+ const rows = sectionRows(input.slots);
203
+ const scope = {
204
+ sectionKey: input.key,
205
+ keyOf: siblingKeys(input.slots),
206
+ rows,
207
+ members: memberResolver(rows),
208
+ computed
209
+ };
77
210
  const meta = {
78
211
  displayName: input.label,
79
212
  ...input.anchor !== void 0 ? { anchor: input.anchor } : {},
80
- ...input.display !== void 0 ? { display: emitDisplay(input.display, computed, resolveReads) } : {},
81
- ...input.layout !== void 0 ? { groups: groupsFromLayout(input.layout) } : {}
213
+ ...input.display !== void 0 ? { display: emitDisplay(input.display, scope) } : {}
82
214
  };
83
215
  const slots = {};
84
216
  for (const [key, slot] of Object.entries(input.slots)) {
85
- if (slot.type !== "list" && slot.unique !== void 0) throw new Error(`defineSchema: slot "${key}" declares \`unique\` — it is legal only inside a list, on its item or a row field.`);
86
- let emitted = resolveFillReads(key, slot, resolveReads);
87
- const fields = emitted.fields;
88
- if (emitted.type === "list" && fields !== void 0) {
89
- const resolvedFields = Object.fromEntries(Object.entries(fields).map(([field, def]) => {
90
- const at = `${key}.${field}`;
91
- let resolved = resolveFillReads(at, def, resolveReads);
92
- if (isComputeBinding(def.source)) {
93
- computed[at] = def.source.fn;
94
- resolved = {
95
- ...resolved,
96
- source: derivedSource(at, resolveReads(at, def.source.reads))
97
- };
98
- }
99
- return [field, resolved];
100
- }));
101
- if (Object.keys(fields).some((field) => resolvedFields[field] !== fields[field])) emitted = {
102
- ...emitted,
103
- fields: resolvedFields
104
- };
105
- }
106
- if (isComputeBinding(slot.source)) {
107
- computed[key] = slot.source.fn;
108
- emitted = {
109
- ...emitted,
110
- source: derivedSource(key, resolveReads(key, slot.source.reads))
111
- };
112
- }
113
- const when = slot.when;
114
- if (when !== void 0) {
115
- const rewritten = { ...emitted };
116
- delete rewritten.when;
117
- rewritten.variant = { cases: typeof when === "string" ? [when] : [...when] };
118
- emitted = rewritten;
119
- }
120
- slots[key] = emitted;
217
+ if (slot.type !== "object" && slot.label === void 0) throw new Error(`slot "${key}" declares no \`label\` — every slot of a section states the name the editor shows it by.`);
218
+ refuseRegistryKeys(key, slot);
219
+ slots[key] = resolveTopLevel(scope, key, slot);
121
220
  }
122
221
  const result = {
123
222
  meta,
@@ -1,159 +1,8 @@
1
- import { DISPLAY_ENTRIES } from "../packages/internal/template-contracts/dist/slot-catalog.js";
2
- import { getFill, getFillSection } from "./fill-declaration.js";
3
- import { isSerializedSlotRef, isSiblingSlot, serializeRef } from "./slot-ref.js";
4
- import { byCodeUnit } from "../platform/order.js";
5
- import { plannerForField } from "../packages/internal/fill-vocabulary/dist/row-planners.js";
6
- import { isListSlot, originationFor } from "../packages/internal/fill-vocabulary/dist/origination.js";
1
+ import { fillSpecFromSchema as fillSpecFromSchema$1 } from "../packages/internal/template-contracts/dist/fill-spec.js";
7
2
 
8
3
  //#region src/schema/extract-fill-spec.ts
9
- function kindOf(origination) {
10
- switch (origination.kind) {
11
- case "write": return "text";
12
- case "estimate": return "number";
13
- case "pick-one": return "pick";
14
- default: return "list";
15
- }
16
- }
17
- function optionsOf(binding) {
18
- const out = { brief: binding.brief };
19
- if (binding.none !== void 0) out.none = binding.none;
20
- if (binding.count !== void 0) out.count = typeof binding.count === "number" ? binding.count : { ...binding.count };
21
- if (binding.cap !== void 0) out.cap = binding.cap;
22
- const reads = serializedReads(binding.reads);
23
- if (reads.length > 0) out.reads = reads;
24
- return out;
25
- }
26
- function serializedReads(reads) {
27
- return (reads ?? []).map((read) => {
28
- if (isSiblingSlot(read)) throw new Error(`fillSpecFromSchema: a fill reads the slot "${read.label}" by its const, which only a section declared with \`section()\` resolves — read another section's slot through its ref (\`Section.slots.<key>\`).`);
29
- return serializeRef(read);
30
- });
31
- }
32
- function collectReads(into, binding) {
33
- const ownSection = getFillSection(binding);
34
- for (const read of serializedReads(binding?.reads)) if (read.kind === "fact") into.facts.add(read.key);
35
- else if (isSerializedSlotRef(read) && read.section !== ownSection) into.slots.set(`${read.section} ${read.slot}`, read);
36
- }
37
- function editorPickedOrigin(slot) {
38
- return slot.type === "poi";
39
- }
40
- function assertOrigin(key, slot) {
41
- if (slot.source !== void 0 || getFill(slot) !== void 0) return;
42
- if (editorPickedOrigin(slot)) return;
43
- throw new Error(`fillSpecFromSchema: slot "${key}" declares no \`source:\` — nothing would ever write it. Bind it to a fact or a slot, \`compute()\` it, or \`fill()\` it.`);
44
- }
45
- function assertRowOrigins(key, slot) {
46
- for (const [fieldKey, field] of Object.entries(slot.fields ?? {})) {
47
- if (field.source !== void 0 || getFill(field) !== void 0) continue;
48
- throw new Error(`fillSpecFromSchema: row field "${key}.${fieldKey}" declares no \`source:\` — nothing would ever write it. Bind it to a member of the row (\`row.<member>\`), \`compute()\` it, or \`fill()\` it.`);
49
- }
50
- }
51
- function rowFieldDecision(key, fieldKey, field, binding) {
52
- if (plannerForField(field) === void 0) throw new Error(`fillSpecFromSchema: row field "${key}.${fieldKey}" (type "${String(field.type)}") is filled, but a row cannot fill one — a row field is written or picked inside the list's one batched call, which plans text, a select key, an asset, or a list of text, keys or assets.`);
53
- return optionsOf(binding);
54
- }
55
- function recordListDecision(key, slot, reads) {
56
- assertRowOrigins(key, slot);
57
- const fields = {};
58
- for (const [fieldKey, rowField] of Object.entries(slot.fields ?? {})) {
59
- const binding = getFill(rowField);
60
- if (binding === void 0) continue;
61
- collectReads(reads, binding);
62
- fields[fieldKey] = rowFieldDecision(key, fieldKey, rowField, binding);
63
- }
64
- const binding = getFill(slot);
65
- collectReads(reads, binding);
66
- if (binding === void 0 && Object.keys(fields).length === 0) {
67
- assertOrigin(key, slot);
68
- return;
69
- }
70
- const origination = originationFor(slot, Object.keys(fields));
71
- if (binding === void 0) {
72
- if (origination?.kind === "bound-rows") return {
73
- id: key,
74
- kind: "list",
75
- produces: [key],
76
- fields
77
- };
78
- throw new Error(`fillSpecFromSchema: record slot "${key}" fills row fields but its rows have no origin — bind the list to a facts array with \`source:\`, or \`fill()\` the list so the model originates its rows.`);
79
- }
80
- if (origination === void 0) throw new Error(`fillSpecFromSchema: record slot "${key}" fills its rows but no row field is filled — a filled record list is written field by field, so give its row fields their own \`fill()\`.`);
81
- return {
82
- id: key,
83
- kind: "list",
84
- produces: [key],
85
- ...optionsOf(binding),
86
- fields
87
- };
88
- }
89
- function assertNotRowOnly(key, slot) {
90
- if (slot.type !== "select") return;
91
- throw new Error(`fillSpecFromSchema: select slot "${key}" is filled, which only a record row's select field may be — a top-level select is bound with \`source:\`; fill the row field instead.`);
92
- }
93
- function slotDecision(key, slot, binding) {
94
- if (!isListSlot(slot)) assertNotRowOnly(key, slot);
95
- const origination = originationFor(slot);
96
- if (origination === void 0) throw new Error(`fillSpecFromSchema: slot "${key}" (type "${String(slot.type)}") is filled, but no fill produces that type.`);
97
- return {
98
- id: key,
99
- kind: kindOf(origination),
100
- produces: [key],
101
- ...optionsOf(binding)
102
- };
103
- }
104
- const DISPLAY_DECISION_ID = "display";
105
- function displayDecision(schema, reads) {
106
- const display = schema.meta.display;
107
- if (display === void 0) return void 0;
108
- const entries = DISPLAY_ENTRIES.filter((entry) => display[entry]?.fill !== void 0);
109
- if (entries.length === 0) return void 0;
110
- const declared = /* @__PURE__ */ new Map();
111
- for (const entry of entries) {
112
- const binding = getFill(display[entry]?.fill);
113
- collectReads(reads, binding);
114
- for (const read of serializedReads(binding?.reads)) if (read.kind === "fact") declared.set(`fact ${read.key}`, read);
115
- else if (isSerializedSlotRef(read)) declared.set(`slot ${read.section} ${read.slot}`, read);
116
- }
117
- if (DISPLAY_DECISION_ID in schema.slots) throw new Error(`fillSpecFromSchema: slot "${DISPLAY_DECISION_ID}" collides with the decision id reserved for \`meta.display\`'s own fill — rename the slot.`);
118
- return {
119
- id: DISPLAY_DECISION_ID,
120
- kind: "display",
121
- entries,
122
- produces: [],
123
- ...declared.size === 0 ? {} : { reads: [...declared.values()] }
124
- };
125
- }
126
- function sortedRefs(slots) {
127
- return [...slots.values()].sort((a, b) => byCodeUnit(a.section, b.section) || byCodeUnit(a.slot, b.slot));
128
- }
129
4
  function fillSpecFromSchema(schema) {
130
- const decisions = [];
131
- const reads = {
132
- facts: /* @__PURE__ */ new Set(),
133
- slots: /* @__PURE__ */ new Map()
134
- };
135
- for (const [key, slot] of Object.entries(schema.slots)) {
136
- const shape = slot;
137
- if (shape.type === "list" && shape.fields !== void 0) {
138
- const decision = recordListDecision(key, shape, reads);
139
- if (decision !== void 0) decisions.push(decision);
140
- continue;
141
- }
142
- const binding = getFill(slot);
143
- if (binding === void 0) {
144
- assertOrigin(key, shape);
145
- continue;
146
- }
147
- collectReads(reads, binding);
148
- decisions.push(slotDecision(key, shape, binding));
149
- }
150
- const display = displayDecision(schema, reads);
151
- if (display !== void 0) decisions.push(display);
152
- return {
153
- reads: [...reads.facts].sort(),
154
- slot_reads: sortedRefs(reads.slots),
155
- decisions
156
- };
5
+ return fillSpecFromSchema$1(schema);
157
6
  }
158
7
 
159
8
  //#endregion
@@ -1,19 +1,24 @@
1
- import { FACT_GRAPH, FactGraphName, SOURCE_FIELDS, SourceFieldContainer, SourceFieldName } from "../packages/internal/template-contracts/dist/slot-catalog.js";
2
- import { FactRef } from "./slot-ref.js";
1
+ import { AddressMember, AddressValue } from "../packages/internal/template-contracts/dist/address-value.js";
2
+ import { FACT_GRAPH, FactGraphName, REGISTRY_TABLE_KEYS, RegistryTable, SOURCE_FIELDS, SourceFieldContainer, SourceFieldName } from "../packages/internal/template-contracts/dist/slot-catalog.js";
3
+ import { MediaListKey, RegistryFactKey, RegistryFactValue } from "../packages/internal/template-contracts/dist/fact-keys.js";
4
+ import { RegistryTableRow } from "../packages/internal/template-contracts/dist/table-members.js";
5
+ import { FactRef } from "../packages/internal/template-contracts/dist/slot-ref.js";
6
+ import { PropertyFactRegistry } from "../packages/internal/template-contracts/dist/fact-registry.js";
7
+ import { DocumentMediaValue } from "../packages/internal/template-contracts/dist/registry-facts.js";
3
8
  import { FactValue } from "../packages/internal/template-contracts/dist/facts-view.js";
9
+ import "./facts-view.js";
4
10
  //#region src/schema/fact.d.ts
5
11
  type SourceFields = typeof SOURCE_FIELDS;
6
12
  type Graph = typeof FACT_GRAPH;
7
13
  /**
8
- * A slot's `direct` binding: the canonical field itself, writable when the catalog
9
- * gives it a writeback — and a typed {@link FactRef} on the very same two runtime
10
- * members, so one value serves `source:` and a declaration's `reads` alike.
14
+ * A slot's fact binding by a legacy field name: a `home` ref to the canonical field — a typed {@link FactRef}, so one
15
+ * value serves `source:` and a declaration's `reads` alike.
11
16
  */
12
17
  type DirectFactRef<F extends SourceFieldName> = FactRef<F, FactValue<F & FactGraphName>>;
13
18
  /**
14
19
  * A slot's `derived` binding: a value the section's own `compute()` fn
15
20
  * produces, keyed by the slot's own name. No `fact.*` entry emits one — the
16
- * fact namespace is direct-only — so `defineSchema`'s `compute()` rewrite is
21
+ * fact namespace hands out only home refs — so `defineSchema`'s `compute()` rewrite is
17
22
  * the sole producer of this shape.
18
23
  */
19
24
  type DerivedFactRef = {
@@ -38,26 +43,63 @@ type ReadableName = { [K in FactGraphName]: Graph[K] extends {
38
43
  primary_of: string;
39
44
  } ? never : K : never; }[FactGraphName];
40
45
  type Readables = { [K in ReadableName]: FactRef<K, FactValue<K>>; };
46
+ /** A ref to a fact the registry declares, by its registry key (`property.address.city`). */
47
+ type RegistryFactRef<K extends RegistryFactKey> = FactRef<K, RegistryFactValue<K>>;
48
+ type PropertyPages = PropertyFactRegistry["pages"];
49
+ type PartRefs<Path extends string> = { readonly [M in keyof AddressValue as M extends AddressMember ? M : never]: RegistryFactRef<`${Path}.${M & string}` & RegistryFactKey>; };
50
+ type RegistryRefs = { readonly [K in keyof PropertyPages as PropertyPages[K]["declaration"] extends {
51
+ readonly type: "list";
52
+ } ? never : K]: RegistryFactRef<`property.${K & string}` & RegistryFactKey> & (PropertyPages[K]["declaration"] extends {
53
+ readonly type: "address";
54
+ } ? PartRefs<`property.${K & string}`> : unknown); };
55
+ type ColumnRefs<T extends RegistryTable> = { readonly [M in keyof RegistryTableRow<T> as M extends "id" ? never : M & string]: FactRef<`${(typeof REGISTRY_TABLE_KEYS)[T]}.${M & string}`, readonly (RegistryTableRow<T>[M] | null)[]>; };
56
+ type RegistryTableRefs = { readonly [T in RegistryTable]: FactRef<(typeof REGISTRY_TABLE_KEYS)[T], readonly RegistryTableRow<T>[]> & ColumnRefs<T>; };
57
+ type MediaListRefs = { readonly [K in keyof PropertyPages as `property.${K & string}` extends MediaListKey ? K : never]: FactRef<`property.${K & string}`, readonly DocumentMediaValue[]>; };
58
+ type PropertyBranch = Omit<FieldsIn<"property"> & ProjectionsIn<"property">, keyof RegistryRefs | RegistryTable | keyof MediaListRefs> & RegistryRefs & RegistryTableRefs & MediaListRefs;
41
59
  /**
42
60
  * The shape of `fact`: one branch per source-field container (`property`,
43
61
  * `unit`, `contact`), each holding an entry for every canonical field in that
44
62
  * container plus one per declared alias, and beside them one entry per
45
- * readable-only fact. Every entry is a value you pass to a slot builder's
46
- * `source` or to a declaration's `reads`, not a call you make.
63
+ * readable-only fact. The `property` branch spells the facts the fact registry
64
+ * declares as it nests them (`fact.property.address.city`), and each table by its
65
+ * registry key (`fact.property.units`). Every entry is a value you pass to a slot
66
+ * builder's `source` or to a declaration's `reads`, not a call you make.
47
67
  */
48
- type FactNamespace = { [C in SourceFieldContainer]: FieldsIn<C> & ProjectionsIn<C>; } & Readables;
68
+ type FactNamespace = {
69
+ property: PropertyBranch;
70
+ } & { [C in Exclude<SourceFieldContainer, "property">]: FieldsIn<C> & ProjectionsIn<C>; } & Readables;
49
71
  /**
50
72
  * Where a slot's value comes from, and what a declaration reads: a bindable fact
51
73
  * as `fact.<container>.<field>`, a readable-only one as `fact.<key>`.
52
74
  *
53
75
  * The container is the resolution rule: `fact.property.*` reads the property
54
- * root, `fact.unit.*` the primary unit (or the current row inside an
55
- * record list), `fact.contact.*` the primary contact card (likewise). Hover
76
+ * root, `fact.unit.*` the primary unit, `fact.contact.*` the primary contact
77
+ * card — a table's other rows are read through a `row()`. Hover
56
78
  * any entry for its writability — a writable field draws the editor's
57
- * "Update everywhere" toggle, a read-only one does not. A pool entry is
58
- * readable only: it may be named in a `compute`'s or a fill decision's `reads`,
59
- * never bound as a slot's `source:`.
79
+ * "Update everywhere" toggle, a read-only one does not.
80
+ *
81
+ * The property's media is three lists, each named in a `compute`'s or a fill's `reads`
82
+ * and read as its assets' records (`Media`): `fact.property.uploads`, every upload;
83
+ * `fact.property.property_media`, what shows the property — its photos, videos and tours; and
84
+ * `fact.property.floor_plans`, its plans. A media slot is never sourced by one: it
85
+ * picks `from` one (`image({ from: fact.property.property_media, source: fill.pick({ brief }) })`).
86
+ * The property's cover photo, `fact.property.hero`, is one image picked from its media:
87
+ * an `image` slot binds it (`image({ source: fact.property.hero })`), and a `compute()`
88
+ * reads it as its asset's record (`Media`), `null` when the property has none.
89
+ *
90
+ * A table (`fact.property.units`, `.commercial_spaces`, `.contacts`, `.comparables`) is a list's `source:` and
91
+ * a row's `from`. One row's members are read through a row slot —
92
+ * `const agent = row({ label: "Agent", from: fact.property.contacts })`, then
93
+ * `agent.phone` — never off the table itself. A row offers what the facts document holds:
94
+ * a unit's `label`, `null` for an unanswered member, a comparable's `address` as an
95
+ * address whose parts read as `comp.address.city`. In a `compute()`'s `reads` a table is
96
+ * its rows, each its `id` beside those members.
97
+ *
98
+ * A table's column — `fact.property.units.beds` — is one member over every row, in row
99
+ * order, `null` where a row leaves it unanswered: read it where a declaration needs that
100
+ * member and not the whole row, since a whole-table read counts every member as used.
101
+ * `fact.unit.beds` stays the primary row's member.
60
102
  */
61
103
  declare const fact: FactNamespace;
62
104
  //#endregion
63
- export { DerivedFactRef, DirectFactRef, FactNamespace, fact };
105
+ export { DerivedFactRef, DirectFactRef, FactNamespace, RegistryFactRef, fact };
@@ -1,7 +1,22 @@
1
- import { FACT_GRAPH, FACT_PROJECTIONS, SOURCE_FIELDS } from "../packages/internal/template-contracts/dist/slot-catalog.js";
1
+ import { FACT_GRAPH, FACT_PROJECTIONS, REGISTRY_TABLE_KEYS, SOURCE_FIELDS } from "../packages/internal/template-contracts/dist/slot-catalog.js";
2
+ import { mediaListKeys, registryFactKeys } from "../packages/internal/template-contracts/dist/fact-keys.js";
3
+ import { registryMemberNames } from "../packages/internal/template-contracts/dist/table-members.js";
2
4
 
3
5
  //#region src/schema/fact.ts
4
6
  const PROJECTIONS = FACT_PROJECTIONS;
7
+ function withMembers(base, path, members) {
8
+ const refs = new Map(members.map((member) => [member, {
9
+ kind: "home",
10
+ key: `${path}.${member}`
11
+ }]));
12
+ return new Proxy(base, { get(target, key, receiver) {
13
+ if (typeof key === "string" && !(key in target)) {
14
+ const ref = refs.get(key);
15
+ if (ref !== void 0) return ref;
16
+ }
17
+ return Reflect.get(target, key, receiver);
18
+ } });
19
+ }
5
20
  function buildNamespace() {
6
21
  const containers = {
7
22
  property: {},
@@ -9,17 +24,37 @@ function buildNamespace() {
9
24
  contact: {}
10
25
  };
11
26
  for (const [field, descriptor] of Object.entries(SOURCE_FIELDS)) containers[descriptor.container][field] = {
12
- kind: "direct",
13
- field
27
+ kind: "home",
28
+ key: field
14
29
  };
15
30
  for (const [container, entries] of Object.entries(PROJECTIONS)) for (const [name, field] of Object.entries(entries)) containers[container][name] = {
16
- kind: "direct",
17
- field
31
+ kind: "home",
32
+ key: field
33
+ };
34
+ const property = containers.property;
35
+ for (const [table, key] of Object.entries(REGISTRY_TABLE_KEYS)) property[table] = withMembers({
36
+ kind: "home",
37
+ key
38
+ }, key, registryMemberNames(table));
39
+ for (const key of mediaListKeys()) property[key.slice(9)] = {
40
+ kind: "home",
41
+ key
18
42
  };
43
+ const keys = registryFactKeys();
44
+ for (const key of keys) {
45
+ const name = key.slice(9);
46
+ if (name.includes(".")) continue;
47
+ const parts = keys.filter((other) => other.startsWith(`${key}.`)).map((part) => part.slice(key.length + 1));
48
+ const ref = {
49
+ kind: "home",
50
+ key
51
+ };
52
+ property[name] = parts.length > 0 ? withMembers(ref, key, parts) : ref;
53
+ }
19
54
  const namespace = { ...containers };
20
55
  for (const [key, entry] of Object.entries(FACT_GRAPH)) if (entry.role === "readable" && entry.primary_of === void 0) namespace[key] = {
21
- kind: "direct",
22
- field: key
56
+ kind: "home",
57
+ key
23
58
  };
24
59
  return namespace;
25
60
  }
@@ -0,0 +1,14 @@
1
+ import { RegistryTableRow } from "../packages/internal/template-contracts/dist/table-members.js";
2
+ import { AsRead } from "../packages/internal/template-contracts/dist/slot-ref.js";
3
+ import { FactValue, FactsAddress, FactsRow } from "../packages/internal/template-contracts/dist/facts-view.js";
4
+ //#region src/schema/facts-view.d.ts
5
+ /** One unit of `fact.property.units`, as a `compute()` reading the table receives it. */
6
+ type FactsUnit = AsRead<RegistryTableRow<"units">>;
7
+ /** One contact of `fact.property.contacts`, as a `compute()` reading the table receives it. */
8
+ type FactsContact = AsRead<RegistryTableRow<"contacts">>;
9
+ /** One commercial space of `fact.property.commercial_spaces`, as a `compute()` reading the table receives it. */
10
+ type FactsCommercialSpace = AsRead<RegistryTableRow<"commercial_spaces">>;
11
+ /** One comparable of `fact.property.comparables`, as a `compute()` reading the table receives it. */
12
+ type FactsComparable = AsRead<RegistryTableRow<"comparables">>;
13
+ //#endregion
14
+ export { type FactValue, type FactsAddress, FactsCommercialSpace, FactsComparable, FactsContact, FactsUnit };
@@ -16,6 +16,7 @@ interface WebsiteFormat {
16
16
  readonly height?: never;
17
17
  readonly dpi?: never;
18
18
  readonly bleed?: never;
19
+ readonly panels?: never;
19
20
  readonly preset?: never;
20
21
  }
21
22
  //#endregion