@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,4 +1,361 @@
1
- import "../../template-contracts/dist/slot-catalog.js";
2
- import "../../property-facts/dist/derive-facts-view.js";
3
- import "./derive-source.js";
4
- import "./bake-property-ref.js";
1
+ import { normalizeAddressValue } from "../../template-contracts/dist/address-value.js";
2
+ import { DISPLAY_ENTRIES } from "../../template-contracts/dist/slot-catalog.js";
3
+ import { heldRowTableOf, holderOf, mirrorRefOf, rowTablesOf, sectionSlotAt, slotTableOf } from "../../template-contracts/dist/ref-locate.js";
4
+ import { memberSourceOf } from "../../template-contracts/dist/row-sources.js";
5
+ import { isSlotOverridden, itemOverridesForSlot, objectFieldOf, objectFieldSlotId } from "../../template-contracts/dist/slot-overrides.js";
6
+ import { declaredSlotRefs } from "./derive-source.js";
7
+ import { declaredDisplay } from "./display.js";
8
+ import { computedRow, isGrammarList, objectElementFields, projectElements, readResolvedRowMember } from "./list-grammar.js";
9
+ import { identifiedElements, inDeclaredCases, resolveDerivedHandle, rowComputesOf } from "./bake-property-ref.js";
10
+ import { isDisplayOverridden } from "../../template-contracts/dist/display-overrides.js";
11
+ import { mergeLinkedValue } from "./linked-merge.js";
12
+ import { mergeSourcedItems } from "./item-merge.js";
13
+
14
+ //#region ../../internal/fill-bake/dist/compute-reads.js
15
+ const DISPLAY_PREFIX = "display.";
16
+ const nodeId = (instanceId, key) => `${instanceId} ${key}`;
17
+ const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
18
+ function storedRefValue(instance, key) {
19
+ if (instance === void 0) return void 0;
20
+ if (key === `${DISPLAY_PREFIX}visibility`) return instance.enabled ? "visible" : "hidden";
21
+ if (key === `${DISPLAY_PREFIX}variant`) return instance.variant;
22
+ if (Object.hasOwn(instance.slots, key)) return instance.slots[key];
23
+ const field = objectFieldOf(key);
24
+ if (field === null) return void 0;
25
+ const object = instance.slots[field.object];
26
+ return isRecord(object) ? object[field.field] : void 0;
27
+ }
28
+ function applyComputeReads(input) {
29
+ const declarations = collectDeclarations(input.sections);
30
+ if (declarations.size === 0) return {
31
+ contentDoc: input.contentDoc,
32
+ changed: false,
33
+ changes: []
34
+ };
35
+ const working = new Map(input.contentDoc.instances.map((inst) => [inst.instance_id, { ...inst }]));
36
+ const cloned = /* @__PURE__ */ new Set();
37
+ const ownSlots = (inst) => {
38
+ if (!cloned.has(inst.instance_id)) {
39
+ inst.slots = { ...inst.slots };
40
+ cloned.add(inst.instance_id);
41
+ }
42
+ return inst.slots;
43
+ };
44
+ const writeSlot = (inst, key, value) => {
45
+ const field = objectFieldOf(key);
46
+ const slots = ownSlots(inst);
47
+ if (field === null || Object.hasOwn(slots, key)) {
48
+ slots[key] = value;
49
+ return;
50
+ }
51
+ const object = slots[field.object];
52
+ slots[field.object] = {
53
+ ...isRecord(object) ? object : {},
54
+ [field.field]: value
55
+ };
56
+ };
57
+ const { facts } = input;
58
+ const localKeyOf = (instanceId) => (input.typing?.get(instanceId) ?? input.sections.get(instanceId))?.localKey;
59
+ const targetFrom = (fromInstance, ref) => input.placement.locate({
60
+ kind: "section",
61
+ section: ref.section,
62
+ slot: ref.slot
63
+ }, {
64
+ instanceId: fromInstance,
65
+ section: localKeyOf(fromInstance) ?? ""
66
+ })?.instanceId;
67
+ const targetOf = (decl, ref) => targetFrom(decl.instanceId, ref);
68
+ const readStored = (instanceId, key) => storedRefValue(instanceId === void 0 ? void 0 : working.get(instanceId), key);
69
+ const typingOf = (instanceId) => input.typing?.get(instanceId) ?? input.sections.get(instanceId);
70
+ const sectionSlots = (localKey) => {
71
+ const instanceId = input.placement.readable(localKey);
72
+ return instanceId === void 0 ? void 0 : typingOf(instanceId)?.schema.slots;
73
+ };
74
+ const tableAt = (instanceId, slot) => {
75
+ const typing = instanceId === void 0 ? void 0 : typingOf(instanceId);
76
+ if (typing === void 0) return null;
77
+ return slotTableOf({
78
+ section: typing.localKey,
79
+ slots: typing.schema.slots ?? {},
80
+ sectionSlots
81
+ }, slot);
82
+ };
83
+ const settledRows = /* @__PURE__ */ new Map();
84
+ const projectionOf = (decl, table) => ({
85
+ element: decl.def.element ?? {},
86
+ table,
87
+ facts,
88
+ computes: rowComputesOf(decl.key, objectElementFields(decl.def), facts, decl.section.bakeContext)
89
+ });
90
+ const listValue = (inst, decl, table, items) => {
91
+ const current = inst.slots[decl.key];
92
+ if (objectElementFields(decl.def) === void 0) return mergeLinkedValue(current, items);
93
+ return mergeSourcedItems({
94
+ current: Array.isArray(current) ? current : [],
95
+ freshSource: items,
96
+ overrides: itemOverridesForSlot(inst.slot_overrides, decl.key),
97
+ generatedFields: [],
98
+ membership: "source"
99
+ });
100
+ };
101
+ const memberAt = (instanceId, rowPath, field) => {
102
+ const typing = input.typing?.get(instanceId) ?? input.sections.get(instanceId);
103
+ const def = typing === void 0 ? void 0 : sectionSlotAt(typing.schema.slots ?? {}, rowPath);
104
+ const stored = readStored(instanceId, rowPath);
105
+ if (def?.type === "address") return { value: readResolvedRowMember({
106
+ table: null,
107
+ id: null,
108
+ element: normalizeAddressValue(stored)
109
+ }, field, facts) };
110
+ const rowId = typeof stored === "string" && stored !== "" ? stored : null;
111
+ const table = def === void 0 ? null : heldRowTableOf(facts, rowTablesOf(def), rowId);
112
+ const settled = settledRows.get(nodeId(instanceId, rowPath));
113
+ const row = settled !== void 0 && settled.id === rowId ? settled : {
114
+ table,
115
+ id: rowId
116
+ };
117
+ if (row.table === null && row.element === void 0 && row.id !== null) return void 0;
118
+ return { value: readResolvedRowMember(row, field, facts) };
119
+ };
120
+ const holderPath = (decl, slot) => {
121
+ const slots = decl.section.schema.slots ?? {};
122
+ const field = objectFieldOf(decl.key);
123
+ const siblings = field === null ? void 0 : slots[field.object]?.fields;
124
+ return holderOf(slots, field === null || siblings === void 0 ? {} : {
125
+ container: field.object,
126
+ siblings
127
+ }, slot)?.path;
128
+ };
129
+ const rowReaderOf = (decl) => (member, slot) => {
130
+ const path = holderPath(decl, slot);
131
+ return path === void 0 ? void 0 : memberAt(decl.instanceId, path, member)?.value;
132
+ };
133
+ const valueOf = (inst, decl) => {
134
+ if (decl.kind === "reader") return memberAt(decl.instanceId, decl.rowPath, decl.field);
135
+ if (decl.kind === "mirror") {
136
+ const upstreamInstance = targetOf(decl, decl.ref);
137
+ const upstream = readStored(upstreamInstance, decl.ref.slot);
138
+ const table = tableAt(decl.instanceId, decl.key);
139
+ if (decl.def.type === "row") {
140
+ const row = computedRow(upstream, rowTablesOf(decl.def), facts);
141
+ settledRows.set(nodeId(decl.instanceId, decl.key), {
142
+ ...row,
143
+ element: upstream
144
+ });
145
+ return { value: row.id };
146
+ }
147
+ if (decl.def.type !== "list") return { value: upstream ?? null };
148
+ const items = projectElements(identifiedElements(Array.isArray(upstream) ? upstream : [], table), projectionOf(decl, table));
149
+ return { value: listValue(inst, decl, table, items) };
150
+ }
151
+ const resolved = resolveDerivedHandle(decl.transform, decl.source, facts, decl.section.bakeContext, { slot_id: decl.key }, (ref) => readStored(targetOf(decl, ref), ref.slot), rowReaderOf(decl));
152
+ if (decl.def.type === "row") {
153
+ const row = computedRow(resolved?.value ?? null, rowTablesOf(decl.def), facts);
154
+ settledRows.set(nodeId(decl.instanceId, decl.key), row);
155
+ return { value: row.id };
156
+ }
157
+ if (isGrammarList(decl.def)) {
158
+ const table = tableAt(decl.instanceId, decl.key);
159
+ const items = projectElements(identifiedElements(resolved?.value ?? [], table), projectionOf(decl, table));
160
+ return { value: listValue(inst, decl, table, items) };
161
+ }
162
+ const isList = decl.def.type === "list";
163
+ const fresh = resolved === null ? isList ? [] : null : resolved.value ?? (isList ? [] : null);
164
+ return { value: mergeLinkedValue(storedRefValue(inst, decl.key), fresh) };
165
+ };
166
+ const write = (decl) => {
167
+ const inst = working.get(decl.instanceId);
168
+ if (inst === void 0) return false;
169
+ if (decl.kind === "display") return writeDisplay(inst, decl, facts, (ref) => readStored(targetOf(decl, ref), ref.slot), rowReaderOf(decl));
170
+ if (isSlotOverridden(inst.slot_overrides, decl.key)) return false;
171
+ const settled = valueOf(inst, decl);
172
+ if (settled === void 0 || sameValue(storedRefValue(inst, decl.key), settled.value)) return false;
173
+ writeSlot(inst, decl.key, settled.value);
174
+ return true;
175
+ };
176
+ const changes = [];
177
+ const settled = /* @__PURE__ */ new Set();
178
+ const onWalk = /* @__PURE__ */ new Set();
179
+ const settle = (decl) => {
180
+ const id = nodeId(decl.instanceId, decl.key);
181
+ if (settled.has(id) || onWalk.has(id)) return;
182
+ onWalk.add(id);
183
+ for (const ref of decl.slotRefs) {
184
+ const target = targetOf(decl, ref);
185
+ const upstream = target === void 0 ? void 0 : declarations.get(nodeId(target, ref.slot));
186
+ if (upstream !== void 0) settle(upstream);
187
+ }
188
+ if (decl.kind === "derived" || decl.kind === "display") for (const slot of memberReadSlots(decl.source)) {
189
+ const path = holderPath(decl, slot);
190
+ const holder = path === void 0 ? void 0 : declarations.get(nodeId(decl.instanceId, path));
191
+ if (holder !== void 0) settle(holder);
192
+ }
193
+ onWalk.delete(id);
194
+ settled.add(id);
195
+ if (write(decl)) changes.push({
196
+ instance_id: decl.instanceId,
197
+ slot: decl.key
198
+ });
199
+ };
200
+ for (const decl of declarations.values()) settle(decl);
201
+ if (changes.length === 0) return {
202
+ contentDoc: input.contentDoc,
203
+ changed: false,
204
+ changes
205
+ };
206
+ const instances = input.contentDoc.instances.map((inst) => working.get(inst.instance_id) ?? inst);
207
+ return {
208
+ contentDoc: {
209
+ ...input.contentDoc,
210
+ instances
211
+ },
212
+ changed: true,
213
+ changes
214
+ };
215
+ }
216
+ function writeDisplay(inst, decl, facts, readSlot, readRow) {
217
+ if (isDisplayOverridden(inst.display_overrides, decl.displayEntry)) return false;
218
+ const resolved = resolveDerivedHandle(decl.transform, decl.source, facts, decl.section.bakeContext, { display_entry: decl.displayEntry }, readSlot, readRow);
219
+ if (resolved === null) return false;
220
+ const def = declaredDisplay(decl.section.schema)[decl.displayEntry];
221
+ const answer = def === void 0 ? null : inDeclaredCases(def, decl.displayEntry, resolved.value, decl.section.bakeContext);
222
+ if (answer === null) return false;
223
+ if (decl.displayEntry === "visibility") {
224
+ const enabled = answer !== "hidden";
225
+ if (inst.enabled === enabled) return false;
226
+ inst.enabled = enabled;
227
+ return true;
228
+ }
229
+ if (inst.variant === answer) return false;
230
+ inst.variant = answer;
231
+ return true;
232
+ }
233
+ function collectDeclarations(sections) {
234
+ const out = /* @__PURE__ */ new Map();
235
+ for (const [instanceId, section] of sections) {
236
+ const slots = section.schema.slots ?? {};
237
+ const placed = [];
238
+ for (const [key, def] of Object.entries(slots)) {
239
+ placed.push({
240
+ path: key,
241
+ def,
242
+ reader: {}
243
+ });
244
+ if (def.type !== "object") continue;
245
+ const siblings = def.fields ?? {};
246
+ for (const [field, fieldDef] of Object.entries(siblings)) placed.push({
247
+ path: objectFieldSlotId(key, field),
248
+ def: fieldDef,
249
+ reader: {
250
+ container: key,
251
+ siblings
252
+ }
253
+ });
254
+ }
255
+ for (const { path, def } of placed) {
256
+ const mirror = mirrorRefOf(def);
257
+ if (mirror !== null) {
258
+ out.set(nodeId(instanceId, path), {
259
+ kind: "mirror",
260
+ instanceId,
261
+ key: path,
262
+ slotRefs: [mirror],
263
+ section,
264
+ ref: mirror,
265
+ def
266
+ });
267
+ continue;
268
+ }
269
+ const transform = transformOf(def.source);
270
+ const slotRefs = declaredSlotRefs(def.source);
271
+ if (transform === null || slotRefs.length === 0) continue;
272
+ out.set(nodeId(instanceId, path), {
273
+ kind: "derived",
274
+ instanceId,
275
+ key: path,
276
+ slotRefs,
277
+ section,
278
+ transform,
279
+ source: def.source,
280
+ def
281
+ });
282
+ }
283
+ const settledRowAt = (reader, slot) => {
284
+ const rowPath = holderOf(slots, reader, slot)?.path;
285
+ const row = rowPath === void 0 ? void 0 : out.get(nodeId(instanceId, rowPath));
286
+ return row !== void 0 && (row.kind === "mirror" || row.kind === "derived") && row.def.type === "row" ? rowPath : void 0;
287
+ };
288
+ for (let joined = true; joined;) {
289
+ joined = false;
290
+ for (const { path, def, reader } of placed) {
291
+ if (out.has(nodeId(instanceId, path))) continue;
292
+ const member = memberSourceOf(def.source);
293
+ const rowPath = member === null ? void 0 : settledRowAt(reader, member.slot);
294
+ if (member !== null && rowPath !== void 0) {
295
+ out.set(nodeId(instanceId, path), {
296
+ kind: "reader",
297
+ instanceId,
298
+ key: path,
299
+ slotRefs: [{
300
+ kind: "section",
301
+ section: section.localKey,
302
+ slot: rowPath
303
+ }],
304
+ section,
305
+ rowPath,
306
+ field: member.field
307
+ });
308
+ joined = true;
309
+ continue;
310
+ }
311
+ const transform = transformOf(def.source);
312
+ if (transform === null || !memberReadSlots(def.source).some((slot) => settledRowAt(reader, slot) !== void 0)) continue;
313
+ out.set(nodeId(instanceId, path), {
314
+ kind: "derived",
315
+ instanceId,
316
+ key: path,
317
+ slotRefs: [],
318
+ section,
319
+ transform,
320
+ source: def.source,
321
+ def
322
+ });
323
+ joined = true;
324
+ }
325
+ }
326
+ const display = declaredDisplay(section.schema);
327
+ for (const entry of DISPLAY_ENTRIES) {
328
+ const source = display[entry]?.source;
329
+ const transform = transformOf(source);
330
+ const slotRefs = declaredSlotRefs(source);
331
+ if (transform === null) continue;
332
+ if (slotRefs.length === 0 && !memberReadSlots(source).some((slot) => settledRowAt({}, slot) !== void 0)) continue;
333
+ const key = `${DISPLAY_PREFIX}${entry}`;
334
+ out.set(nodeId(instanceId, key), {
335
+ kind: "display",
336
+ instanceId,
337
+ key,
338
+ transform,
339
+ source,
340
+ slotRefs,
341
+ section,
342
+ displayEntry: entry
343
+ });
344
+ }
345
+ }
346
+ return out;
347
+ }
348
+ function memberReadSlots(source) {
349
+ return (isRecord(source) && Array.isArray(source["reads"]) ? source["reads"] : []).flatMap((entry) => isRecord(entry) && entry["kind"] === "row" && typeof entry["slot"] === "string" ? [entry["slot"]] : []);
350
+ }
351
+ function transformOf(source) {
352
+ if (source === null || typeof source !== "object") return null;
353
+ const { kind, transform } = source;
354
+ return kind === "derived" && typeof transform === "string" ? transform : null;
355
+ }
356
+ function sameValue(a, b) {
357
+ return JSON.stringify(a) === JSON.stringify(b);
358
+ }
359
+
360
+ //#endregion
361
+ export { applyComputeReads, storedRefValue };
@@ -1,4 +1,5 @@
1
- import { readFact } from "../../template-contracts/dist/facts-view.js";
1
+ import { readAsRecords, storedAsRefs } from "../../template-contracts/dist/registry-facts.js";
2
+ import { readFactRef } from "../../source-resolution/dist/index.js";
2
3
 
3
4
  //#region ../../internal/fill-bake/dist/derive-source.js
4
5
  function readsOf(source) {
@@ -6,9 +7,9 @@ function readsOf(source) {
6
7
  const reads = source.reads;
7
8
  return Array.isArray(reads) ? reads : [];
8
9
  }
9
- function slotRefOf(entry) {
10
+ function sectionRefOf(entry) {
10
11
  const { kind, section, slot } = entry ?? {};
11
- return kind === "slot" && typeof section === "string" && typeof slot === "string" ? {
12
+ return kind === "section" && typeof section === "string" && typeof slot === "string" ? {
12
13
  kind,
13
14
  section,
14
15
  slot
@@ -16,36 +17,42 @@ function slotRefOf(entry) {
16
17
  }
17
18
  function declaredReads(source) {
18
19
  return readsOf(source).map((entry, i) => {
19
- const { kind, key, field } = entry ?? {};
20
- if (kind === "fact" && typeof key === "string") return {
21
- kind: "fact",
20
+ const { kind, key, slot, field } = entry ?? {};
21
+ if (kind === "home" && typeof key === "string") return {
22
+ kind: "home",
22
23
  key
23
24
  };
24
- if (kind === "row" && typeof field === "string") return {
25
+ if (kind === "row" && typeof slot === "string" && slot !== "" && typeof field === "string") return {
25
26
  kind: "row",
27
+ slot,
26
28
  field
27
29
  };
28
- const slotRef = slotRefOf(entry);
29
- if (slotRef !== null) return slotRef;
30
- throw new Error(`reads[${String(i)}] is not a fact, slot or row ref: ${JSON.stringify(entry)}`);
30
+ if (kind === "element") return { kind: "element" };
31
+ const sectionRef = sectionRefOf(entry);
32
+ if (sectionRef !== null) return sectionRef;
33
+ throw new Error(`reads[${String(i)}] is not a home, section, row or element ref: ${JSON.stringify(entry)}`);
31
34
  });
32
35
  }
33
36
  function declaredSlotRefs(source) {
34
- return readsOf(source).flatMap((entry) => slotRefOf(entry) ?? []);
37
+ return readsOf(source).flatMap((entry) => sectionRefOf(entry) ?? []);
35
38
  }
36
39
  function readsAnySlot(source) {
37
40
  return declaredSlotRefs(source).length > 0;
38
41
  }
39
- function callDerived(fn, source, facts, readSlot, readRow) {
40
- return fn(...declaredReads(source).map((ref) => {
41
- if (ref.kind === "fact") return readFact(facts(), ref.key);
42
+ function callDerived(fn, source, facts, readSlot, readRow, readElement) {
43
+ return storedAsRefs(fn(...declaredReads(source).map((ref) => {
44
+ if (ref.kind === "home") return readFactRef(facts, ref.key);
42
45
  if (ref.kind === "row") {
43
- if (readRow === void 0) throw new Error(`reads the row member "${ref.field}" outside a record list's row`);
44
- return readRow(ref.field);
46
+ if (readRow === void 0) throw new Error(`reads the row member "${ref.field}" with no row in scope`);
47
+ return readRow(ref.field, ref.slot);
48
+ }
49
+ if (ref.kind === "element") {
50
+ if (readElement === void 0) throw new Error("reads the element outside a list's item");
51
+ return readElement();
45
52
  }
46
53
  return readSlot?.(ref);
47
- }));
54
+ }).map((value) => readAsRecords(value, facts))));
48
55
  }
49
56
 
50
57
  //#endregion
51
- export { callDerived, declaredReads, declaredSlotRefs, readsAnySlot };
58
+ export { callDerived, declaredReads, declaredSlotRefs, readFactRef, readsAnySlot };
@@ -1,6 +1,12 @@
1
+ import { projectTableRows, readFactRef, readRowMember } from "../../source-resolution/dist/index.js";
1
2
  import { callDerived, declaredReads, declaredSlotRefs, readsAnySlot } from "./derive-source.js";
2
3
  import { declaredDisplay } from "./display.js";
3
- import { bakeDisplayEntries, bakePropertyRefSlots, derivedSource, directField, projectComputedRows, resolveDerivedHandle, resolveDirectField, rowComputesOf } from "./bake-property-ref.js";
4
- import "./compute-reads.js";
4
+ import { decisionProducing, isGrammarList, objectElementFields, readResolvedRowMember, readsElementRows, rowIdentity } from "./list-grammar.js";
5
+ import { bakeDisplayEntries, bakePropertyRefSlots, boundFactKey, derivedSource, identifiedElements, resolveDerivedHandle, resolveDirectField, rowComputesOf, topLevelRowReader } from "./bake-property-ref.js";
6
+ import { mergeLinkedValue } from "./linked-merge.js";
7
+ import { mergeSourcedItems } from "./item-merge.js";
8
+ import { applyComputeReads, storedRefValue } from "./compute-reads.js";
9
+ import "./item-overrides.js";
10
+ import "./stored-row-reader.js";
5
11
 
6
- export { bakeDisplayEntries, bakePropertyRefSlots, projectComputedRows, rowComputesOf };
12
+ export { applyComputeReads, bakeDisplayEntries, bakePropertyRefSlots };
@@ -0,0 +1,113 @@
1
+ import { mergeLinkedValue } from "./linked-merge.js";
2
+
3
+ //#region ../../internal/fill-bake/dist/item-merge.js
4
+ const isTempId = (id) => typeof id === "string" && id.startsWith("tmp_");
5
+ function oneItemPerIdentity(idKey, current) {
6
+ const out = [];
7
+ const at = /* @__PURE__ */ new Map();
8
+ for (const cur of current) {
9
+ const id = cur[idKey];
10
+ const first = typeof id === "string" ? at.get(id) : void 0;
11
+ if (first === void 0) {
12
+ if (typeof id === "string") at.set(id, out.length);
13
+ out.push(cur);
14
+ continue;
15
+ }
16
+ out[first] = {
17
+ ...cur,
18
+ ...out[first]
19
+ };
20
+ }
21
+ return out;
22
+ }
23
+ function mergeItem(cur, fresh, itemOverrides, generatedFields, idKey, keepUnbaked) {
24
+ const row = keepUnbaked ? { ...cur } : {};
25
+ for (const [field, freshValue] of Object.entries(fresh)) {
26
+ if (field === idKey) {
27
+ row[field] = freshValue;
28
+ continue;
29
+ }
30
+ row[field] = itemOverrides?.[field] === true ? cur[field] : mergeLinkedValue(cur[field], freshValue);
31
+ }
32
+ for (const field of generatedFields) if (field in cur) row[field] = cur[field];
33
+ return row;
34
+ }
35
+ function mergeSourcedItems(input) {
36
+ const membership = input.membership ?? "table";
37
+ const idKey = input.idKey ?? "id";
38
+ const current = oneItemPerIdentity(idKey, input.current);
39
+ if (membership === "table") return mergeTableItems({
40
+ ...input,
41
+ idKey,
42
+ current
43
+ });
44
+ const { freshSource, overrides, generatedFields } = input;
45
+ const currentById = /* @__PURE__ */ new Map();
46
+ for (const cur of current) {
47
+ const id = cur[idKey];
48
+ if (typeof id === "string") currentById.set(id, cur);
49
+ }
50
+ if (membership === "source") return freshSource.map((fresh) => {
51
+ const id = fresh[idKey];
52
+ const cur = typeof id === "string" ? currentById.get(id) : void 0;
53
+ return cur === void 0 ? fresh : mergeItem(cur, fresh, overrides?.[id], generatedFields, idKey, true);
54
+ });
55
+ const freshById = /* @__PURE__ */ new Map();
56
+ for (const fresh of freshSource) {
57
+ const id = fresh[idKey];
58
+ if (typeof id === "string") freshById.set(id, fresh);
59
+ }
60
+ return current.map((cur) => {
61
+ const id = cur[idKey];
62
+ const fresh = typeof id === "string" ? freshById.get(id) : void 0;
63
+ return fresh === void 0 ? cur : mergeItem(cur, fresh, overrides?.[id], generatedFields, idKey, true);
64
+ });
65
+ }
66
+ function mergeTableItems(input) {
67
+ const { current, freshSource, overrides, removed, generatedFields, idKey } = input;
68
+ const freshById = /* @__PURE__ */ new Map();
69
+ for (const f of freshSource) {
70
+ const id = f[idKey];
71
+ if (typeof id === "string") freshById.set(id, f);
72
+ }
73
+ const out = [];
74
+ const emitted = /* @__PURE__ */ new Set();
75
+ for (const cur of current) {
76
+ const id = cur[idKey];
77
+ if (isTempId(id) || typeof id !== "string") {
78
+ out.push(cur);
79
+ continue;
80
+ }
81
+ const fresh = freshById.get(id);
82
+ if (fresh === void 0) continue;
83
+ out.push(mergeItem(cur, fresh, overrides?.[id], generatedFields, idKey, false));
84
+ emitted.add(id);
85
+ }
86
+ for (const fresh of freshSource) {
87
+ const id = fresh[idKey];
88
+ if (typeof id !== "string" || emitted.has(id)) continue;
89
+ if (removed?.[id] === true) continue;
90
+ out.push(fresh);
91
+ }
92
+ const freshIndex = /* @__PURE__ */ new Map();
93
+ freshSource.forEach((f, i) => {
94
+ const id = f[idKey];
95
+ if (typeof id === "string") freshIndex.set(id, i);
96
+ });
97
+ return out.map((row, i) => {
98
+ const id = row[idKey];
99
+ return {
100
+ row,
101
+ i,
102
+ idx: typeof id === "string" ? freshIndex.get(id) : void 0
103
+ };
104
+ }).sort((a, b) => {
105
+ if (a.idx === void 0 && b.idx === void 0) return a.i - b.i;
106
+ if (a.idx === void 0) return 1;
107
+ if (b.idx === void 0) return -1;
108
+ return a.idx - b.idx;
109
+ }).map((x) => x.row);
110
+ }
111
+
112
+ //#endregion
113
+ export { mergeSourcedItems };
@@ -0,0 +1 @@
1
+ import "../../template-contracts/dist/ref-locate.js";
@@ -0,0 +1,38 @@
1
+ import { elementIdentity } from "../../template-contracts/dist/ref-locate.js";
2
+
3
+ //#region ../../internal/fill-bake/dist/linked-merge.js
4
+ const isFields = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
5
+ function uploadOf(value) {
6
+ if (!isFields(value)) return null;
7
+ return typeof value["asset_id"] === "string" && value["asset_id"] !== "" ? value["asset_id"] : null;
8
+ }
9
+ function mergeLinkedValue(current, fresh) {
10
+ const upload = uploadOf(fresh);
11
+ if (upload !== null) return uploadOf(current) === upload ? current : fresh;
12
+ if (Array.isArray(fresh)) return Array.isArray(current) ? mergeLinkedList(current, fresh) : fresh;
13
+ if (isFields(fresh)) return isFields(current) ? mergeLinkedFields(current, fresh) : fresh;
14
+ return fresh;
15
+ }
16
+ function mergeLinkedFields(current, fresh) {
17
+ const merged = {};
18
+ for (const [field, value] of Object.entries(fresh)) merged[field] = mergeLinkedValue(current[field], value);
19
+ return merged;
20
+ }
21
+ function mergeLinkedList(current, fresh) {
22
+ const twins = /* @__PURE__ */ new Map();
23
+ for (const entry of current) {
24
+ const identity = elementIdentity(entry);
25
+ if (identity === null) continue;
26
+ const queue = twins.get(identity);
27
+ if (queue === void 0) twins.set(identity, [entry]);
28
+ else queue.push(entry);
29
+ }
30
+ return fresh.map((entry) => {
31
+ const identity = elementIdentity(entry);
32
+ const queue = identity === null ? void 0 : twins.get(identity);
33
+ return queue === void 0 || queue.length === 0 ? entry : mergeLinkedValue(queue.shift(), entry);
34
+ });
35
+ }
36
+
37
+ //#endregion
38
+ export { mergeLinkedValue };