@homepages/concrete 11.0.0 → 13.0.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 (322) hide show
  1. package/CHANGELOG.md +203 -0
  2. package/README.md +8 -10
  3. package/codemods/fixtures-are-data.mjs +7 -0
  4. package/codemods/fixtures-list-properties.mjs +6 -0
  5. package/codemods/manifest.json +17 -0
  6. package/codemods/steps/fixtures-list-properties.mjs +16 -0
  7. package/codemods/steps/fixtures-to-data.mjs +41 -0
  8. package/dist/artifact/playground/client/assets/archivo-latin-ext-wght-normal-C4zznr8T.woff2 +0 -0
  9. package/dist/artifact/playground/client/assets/archivo-latin-wght-normal-E0tuGl4L.woff2 +0 -0
  10. package/dist/artifact/playground/client/assets/archivo-vietnamese-wght-normal-XAtsl5Q_.woff2 +0 -0
  11. package/dist/artifact/playground/client/assets/index-Bmvcss4B.js +1338 -0
  12. package/dist/artifact/playground/client/assets/index-C01UCAWD.css +1 -0
  13. package/dist/artifact/playground/client/index.html +2 -2
  14. package/dist/artifact/playground/client/island-canvas-host.mjs +1 -1
  15. package/dist/artifact/playground/host.mjs +110 -60
  16. package/dist/base.css +19 -59
  17. package/dist/cli/build/icons.js +1 -1
  18. package/dist/cli/build/index.js +11 -10
  19. package/dist/cli/build/manifest.js +44 -0
  20. package/dist/cli/build/record.js +123 -0
  21. package/dist/cli/build/sections.js +28 -18
  22. package/dist/cli/build/source.js +1 -1
  23. package/dist/cli/build/static.js +8 -5
  24. package/dist/cli/build/template-build.js +614 -0
  25. package/dist/cli/check/analyze.js +18 -1
  26. package/dist/cli/check/load-workspace.js +2 -2
  27. package/dist/cli/check/portable-names.js +1 -1
  28. package/dist/cli/check/render/corpus.js +119 -0
  29. package/dist/cli/check/render/invariants.js +1 -0
  30. package/dist/cli/check/stages/bundles.js +15 -18
  31. package/dist/cli/check/stages/composition.js +8 -25
  32. package/dist/cli/check/stages/fixtures.js +14 -10
  33. package/dist/cli/check/stages/logic.js +7 -23
  34. package/dist/cli/check/stages/render.js +12 -14
  35. package/dist/cli/check/stages/sections.js +22 -66
  36. package/dist/cli/check/stages/stylesheet.js +4 -26
  37. package/dist/cli/check/stages/workspace.js +27 -22
  38. package/dist/cli/commands.js +51 -23
  39. package/dist/cli/currency/preamble.js +1 -1
  40. package/dist/cli/currency/resolve-latest.js +3 -2
  41. package/dist/cli/dev/capture-browser.js +26 -0
  42. package/dist/cli/dev/fixture-schema.js +441 -0
  43. package/dist/cli/dev/folder-files.js +244 -0
  44. package/dist/cli/dev/index.js +7 -3
  45. package/dist/cli/dev/playground-server.js +34 -0
  46. package/dist/cli/dev/section-ladders.js +76 -0
  47. package/dist/cli/dev/server.js +120 -304
  48. package/dist/cli/install/background.js +16 -0
  49. package/dist/cli/install/index.js +45 -0
  50. package/dist/cli/install/tools.js +27 -0
  51. package/dist/cli/media/derive.js +19 -13
  52. package/dist/cli/media/deriver-plugin.js +14 -3
  53. package/dist/cli/property/fixture-list.js +46 -0
  54. package/dist/cli/property/index.js +12 -9
  55. package/dist/cli/property/library.js +12 -10
  56. package/dist/cli/publish/artifact.js +90 -0
  57. package/dist/cli/publish/captures.js +61 -0
  58. package/dist/cli/publish/fixtures.js +17 -0
  59. package/dist/cli/publish/index.js +10 -18
  60. package/dist/cli/{build → publish}/playground.js +3 -3
  61. package/dist/cli/publish/report.js +15 -33
  62. package/dist/cli/upgrade/codemod.d.ts +14 -0
  63. package/dist/cli/upgrade/fixture-conversion.d.ts +11 -0
  64. package/dist/cli/upgrade/fixture-conversion.js +54 -0
  65. package/dist/cli/upgrade/fixture-modules.js +125 -0
  66. package/dist/cli/upgrade/fixtures-to-data.d.ts +40 -0
  67. package/dist/cli/upgrade/fixtures-to-data.js +498 -0
  68. package/dist/cli/upgrade/index.js +18 -2
  69. package/dist/cli/upgrade/legacy-fixtures.d.ts +34 -0
  70. package/dist/cli/upgrade/legacy-fixtures.js +22 -0
  71. package/dist/cli/upgrade/stage.js +1 -1
  72. package/dist/cli/workspace-fixtures.js +80 -0
  73. package/dist/cli.js +1 -0
  74. package/dist/css/compile.js +9 -3
  75. package/dist/fixtures/bundle-rule.js +16 -16
  76. package/dist/fixtures/media-plugin.js +12 -33
  77. package/dist/fixtures/synthesize-empties.js +3 -2
  78. package/dist/index.d.ts +7 -7
  79. package/dist/{playground-island-runtime.d.ts → island-runtime.d.ts} +1 -2
  80. package/dist/{playground-island-runtime.js → island-runtime.js} +1 -2
  81. package/dist/islands/client-module.js +1 -1
  82. package/dist/{cli/dev → islands}/tsconfig-paths.js +2 -14
  83. package/dist/islands/wrap.js +40 -0
  84. package/dist/node_modules/.pnpm/acorn@8.18.0/node_modules/acorn/dist/acorn.js +5119 -0
  85. package/dist/packages/external/concrete/package.js +1 -1
  86. package/dist/packages/internal/bundle-evaluation/dist/cache.js +36 -0
  87. package/dist/packages/internal/bundle-evaluation/dist/evaluate.js +174 -0
  88. package/dist/packages/internal/bundle-evaluation/dist/index.js +5 -0
  89. package/dist/packages/internal/bundle-evaluation/dist/section-code.js +10 -0
  90. package/dist/packages/internal/capture-settle/dist/index.js +2 -2
  91. package/dist/packages/internal/capture-settle/dist/settle.js +88 -13
  92. package/dist/packages/internal/code-fingerprint/dist/index.js +57 -0
  93. package/dist/packages/internal/content-doc-ops/dist/index.js +176 -0
  94. package/dist/packages/internal/content-doc-ops/dist/made-rows.js +15 -0
  95. package/dist/packages/internal/deliverable-reads/dist/bootstrap.js +81 -0
  96. package/dist/packages/internal/deliverable-reads/dist/display.js +21 -0
  97. package/dist/packages/internal/deliverable-reads/dist/format.js +15 -0
  98. package/dist/packages/internal/deliverable-reads/dist/index.js +7 -0
  99. package/dist/packages/internal/deliverable-reads/dist/pages.js +29 -0
  100. package/dist/packages/internal/deliverable-reads/dist/requirements.js +72 -0
  101. package/dist/{cli/capture → packages/internal/download-files/dist}/bundle.js +8 -4
  102. package/dist/packages/internal/download-files/dist/capture-origin.js +126 -0
  103. package/dist/packages/internal/download-files/dist/capture-routes.js +139 -0
  104. package/dist/packages/internal/download-files/dist/capture-shell.js +38 -0
  105. package/dist/packages/internal/download-files/dist/capture.js +74 -0
  106. package/dist/packages/internal/download-files/dist/egress-watch.js +38 -0
  107. package/dist/packages/internal/download-files/dist/files.js +7 -0
  108. package/dist/packages/internal/download-files/dist/finish.js +35 -0
  109. package/dist/packages/internal/download-files/dist/fleet.js +94 -0
  110. package/dist/packages/internal/download-files/dist/format.js +40 -0
  111. package/dist/packages/internal/download-files/dist/make.js +105 -0
  112. package/dist/packages/internal/download-files/dist/master-tally.js +32 -0
  113. package/dist/packages/internal/download-files/dist/names.js +24 -0
  114. package/dist/packages/internal/download-files/dist/pdf-boxes.js +33 -0
  115. package/dist/packages/internal/download-files/dist/pdf-image-placements.js +194 -0
  116. package/dist/packages/internal/download-files/dist/pdf-images.js +289 -0
  117. package/dist/packages/internal/file-store/dist/files.js +8 -0
  118. package/dist/packages/internal/file-store/dist/lru.js +40 -0
  119. package/dist/packages/internal/file-store/dist/refusal.js +12 -0
  120. package/dist/packages/internal/file-store/dist/trees.js +151 -0
  121. package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +1 -1
  122. package/dist/packages/internal/fill-bake/dist/compute-reads.js +48 -22
  123. package/dist/packages/internal/fill-bake/dist/held-rows.js +2 -0
  124. package/dist/packages/internal/fill-bake/dist/index.js +6 -1
  125. package/dist/packages/internal/fill-bake/dist/item-merge.js +4 -3
  126. package/dist/packages/internal/fill-bake/dist/resolve-instance.js +9 -0
  127. package/dist/packages/internal/fill-bake/dist/resolve.js +3 -0
  128. package/dist/packages/internal/fill-bake/dist/round-trip.js +2 -0
  129. package/dist/packages/internal/fill-bake/dist/strip.js +6 -0
  130. package/dist/packages/internal/fill-vocabulary/dist/holder.js +1 -1
  131. package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +1 -1
  132. package/dist/packages/internal/fill-vocabulary/dist/verbs.js +1 -1
  133. package/dist/packages/internal/format-geometry/dist/capture.js +3 -11
  134. package/dist/packages/internal/format-geometry/dist/format.d.ts +2 -8
  135. package/dist/packages/internal/format-geometry/dist/geometry.js +2 -13
  136. package/dist/packages/internal/island-runtime/dist/index.js +1 -10
  137. package/dist/packages/internal/island-runtime/dist/use-capture-ready.d.ts +5 -0
  138. package/dist/packages/internal/lead-fields/dist/ingest.js +72 -0
  139. package/dist/packages/internal/media-resolution/dist/video.js +6 -2
  140. package/dist/packages/internal/page-render/dist/addresses.js +57 -0
  141. package/dist/packages/internal/page-render/dist/index.js +6 -0
  142. package/dist/packages/internal/page-render/dist/kept.js +30 -0
  143. package/dist/packages/internal/page-render/dist/nav.js +42 -0
  144. package/dist/packages/internal/page-render/dist/render.js +152 -0
  145. package/dist/packages/internal/page-shell/dist/assemble.js +161 -0
  146. package/dist/packages/internal/page-shell/dist/escape.js +10 -0
  147. package/dist/packages/internal/page-shell/dist/frame.js +23 -0
  148. package/dist/packages/internal/page-shell/dist/index.js +26 -0
  149. package/dist/packages/internal/playground/dist/build-fingerprint.js +18 -0
  150. package/dist/packages/internal/playground/dist/fixture-conversions/list-names-properties.js +76 -0
  151. package/dist/packages/internal/playground/dist/fixture-formats.d.ts +37 -0
  152. package/dist/packages/internal/playground/dist/fixture-formats.js +20 -0
  153. package/dist/packages/internal/playground/dist/host/bootstrap.js +108 -0
  154. package/dist/packages/internal/playground/dist/host/built.js +202 -0
  155. package/dist/packages/internal/playground/dist/host/catalog-fixture.js +53 -0
  156. package/dist/packages/internal/playground/dist/host/download.js +34 -0
  157. package/dist/packages/internal/playground/dist/host/env.js +11 -0
  158. package/dist/packages/internal/playground/dist/host/everywhere-saves.js +353 -0
  159. package/dist/packages/internal/playground/dist/host/fixture-addresses.js +52 -0
  160. package/dist/packages/internal/playground/dist/host/fixture-documents.js +494 -0
  161. package/dist/packages/internal/playground/dist/host/fixture-operations.js +364 -0
  162. package/dist/packages/internal/playground/dist/host/fixture-units.js +93 -0
  163. package/dist/{fixtures → packages/internal/playground/dist/host}/image-dimensions.js +1 -1
  164. package/dist/packages/internal/playground/dist/host/leads.js +41 -0
  165. package/dist/packages/internal/playground/dist/host/media-saves.js +309 -0
  166. package/dist/{fixtures → packages/internal/playground/dist/host}/media-store.js +79 -26
  167. package/dist/packages/internal/playground/dist/host/overridable.js +9 -0
  168. package/dist/packages/internal/playground/dist/host/owned-saves.js +203 -0
  169. package/dist/{playground → packages/internal/playground/dist}/host/page-state.js +1 -1
  170. package/dist/packages/internal/playground/dist/host/program.js +54 -0
  171. package/dist/packages/internal/playground/dist/host/property-derive.js +216 -0
  172. package/dist/packages/internal/playground/dist/host/property-saves.js +74 -0
  173. package/dist/{fixtures → packages/internal/playground/dist/host}/property.js +88 -229
  174. package/dist/packages/internal/playground/dist/host/provenance.js +49 -0
  175. package/dist/packages/internal/playground/dist/host/resolve.js +553 -0
  176. package/dist/packages/internal/playground/dist/host/row-images.js +41 -0
  177. package/dist/{fixtures → packages/internal/playground/dist/host}/rows.js +1 -1
  178. package/dist/packages/internal/playground/dist/host/save.js +429 -0
  179. package/dist/packages/internal/playground/dist/host/serve.js +952 -0
  180. package/dist/packages/internal/playground/dist/host/site.js +79 -0
  181. package/dist/packages/internal/playground/dist/host/slots.js +202 -0
  182. package/dist/packages/internal/playground/dist/host/stated-content.js +93 -0
  183. package/dist/packages/internal/playground/dist/host/stored-fixtures.js +135 -0
  184. package/dist/packages/internal/playground/dist/host/violations.js +7 -0
  185. package/dist/packages/internal/playground/dist/jobs/lanes.js +24 -0
  186. package/dist/packages/internal/playground/dist/jobs/memory-queue.js +112 -0
  187. package/dist/packages/internal/playground/dist/jobs/probe.js +37 -0
  188. package/dist/packages/internal/playground/dist/jobs/queue.js +28 -0
  189. package/dist/packages/internal/playground/dist/jobs/runner.js +207 -0
  190. package/dist/packages/internal/playground/dist/layout.js +14 -0
  191. package/dist/packages/internal/playground/dist/platform.js +33 -0
  192. package/dist/packages/internal/playground/dist/server/changes.js +57 -0
  193. package/dist/packages/internal/playground/dist/server/crop.js +47 -0
  194. package/dist/packages/internal/playground/dist/server/derived-files.js +88 -0
  195. package/dist/packages/internal/playground/dist/server/download.js +158 -0
  196. package/dist/{cli/dev → packages/internal/playground/dist/server}/http.js +4 -12
  197. package/dist/packages/internal/playground/dist/server/jobs.js +29 -0
  198. package/dist/{cli/dev → packages/internal/playground/dist/server}/listen.js +4 -11
  199. package/dist/packages/internal/playground/dist/server/playground-server.js +424 -0
  200. package/dist/{cli/dev → packages/internal/playground/dist/server}/request-error.js +1 -1
  201. package/dist/packages/internal/playground/dist/server/size-ladders.js +170 -0
  202. package/dist/packages/internal/playground/dist/server/verification.js +75 -0
  203. package/dist/packages/internal/playground/dist/server/verify-build.js +139 -0
  204. package/dist/packages/internal/playground/dist/wire.js +78 -0
  205. package/dist/packages/internal/property-facts/dist/registry-facts.js +1 -1
  206. package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +1 -1
  207. package/dist/packages/internal/section-contracts/dist/reads-acyclic-contract.js +1 -1
  208. package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +1 -1
  209. package/dist/packages/internal/site-files/dist/head.js +59 -0
  210. package/dist/packages/internal/site-files/dist/index.js +4 -0
  211. package/dist/packages/internal/site-files/dist/site.js +211 -0
  212. package/dist/packages/internal/static-assets-binding/dist/index.js +32 -0
  213. package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +38 -5
  214. package/dist/packages/internal/template-artifact/dist/asset-mime.js +8 -1
  215. package/dist/packages/internal/template-artifact/dist/build.js +148 -0
  216. package/dist/packages/internal/template-artifact/dist/composition.js +62 -0
  217. package/dist/packages/internal/template-artifact/dist/index.js +2 -2
  218. package/dist/packages/internal/template-artifact/dist/layout.js +48 -12
  219. package/dist/packages/internal/template-artifact/dist/manifest.js +3 -10
  220. package/dist/packages/internal/template-artifact/dist/verify.js +51 -31
  221. package/dist/packages/internal/template-contracts/dist/address-value.js +6 -1
  222. package/dist/packages/internal/template-contracts/dist/content-categories.js +10 -1
  223. package/dist/packages/internal/template-contracts/dist/fact-compute.d.ts +1 -1
  224. package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +1 -1
  225. package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +3 -3
  226. package/dist/packages/internal/template-contracts/dist/fact-registry.js +59 -32
  227. package/dist/packages/internal/template-contracts/dist/fill-spec.js +14 -1
  228. package/dist/packages/internal/template-contracts/dist/list.d.ts +3 -3
  229. package/dist/packages/internal/template-contracts/dist/media-candidates.js +67 -2
  230. package/dist/packages/internal/template-contracts/dist/media-offer.js +180 -0
  231. package/dist/packages/internal/template-contracts/dist/object.d.ts +2 -2
  232. package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +9 -2
  233. package/dist/packages/internal/template-contracts/dist/read-graph.js +36 -2
  234. package/dist/packages/internal/template-contracts/dist/ref-locate.js +16 -1
  235. package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +9 -10
  236. package/dist/packages/internal/template-contracts/dist/registry-facts.js +12 -1
  237. package/dist/packages/internal/template-contracts/dist/registry-graph.js +112 -0
  238. package/dist/packages/internal/template-contracts/dist/registry-shape.js +15 -2
  239. package/dist/packages/internal/template-contracts/dist/require-graph.js +300 -0
  240. package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +3 -3
  241. package/dist/packages/internal/template-contracts/dist/row.d.ts +3 -3
  242. package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +1 -1
  243. package/dist/{schema → packages/internal/template-contracts/dist}/section-nav.d.ts +1 -1
  244. package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +4 -4
  245. package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +3 -1
  246. package/dist/packages/internal/template-contracts/dist/slot-catalog.js +24 -1
  247. package/dist/packages/internal/template-contracts/dist/slot-overrides.js +26 -1
  248. package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +1 -1
  249. package/dist/packages/internal/template-contracts/dist/slot-types.js +1 -1
  250. package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +1 -1
  251. package/dist/packages/internal/template-contracts/dist/table-members.js +7 -2
  252. package/dist/packages/internal/template-contracts/dist/video-value.d.ts +1 -1
  253. package/dist/packages/internal/upload-formats/dist/heic.js +35 -0
  254. package/dist/packages/internal/upload-formats/dist/index.js +80 -0
  255. package/dist/packages/internal/upload-formats/dist/magic-bytes.js +293 -0
  256. package/dist/platform/paths.js +1 -0
  257. package/dist/platform/process.js +49 -1
  258. package/dist/primitives/FrameShell.d.ts +5 -2
  259. package/dist/primitives/FrameShell.js +2 -1
  260. package/dist/rules/registry.js +28 -4
  261. package/dist/schema/fact.d.ts +2 -2
  262. package/dist/schema/facts-view.d.ts +1 -1
  263. package/dist/schema/format.d.ts +0 -1
  264. package/dist/schema/format.js +1 -2
  265. package/dist/schema/manifest.js +18 -24
  266. package/dist/schema/section-props.d.ts +1 -1
  267. package/dist/schema/section-schema.d.ts +1 -1
  268. package/dist/schema/section-schema.js +1 -0
  269. package/dist/section/declare.d.ts +1 -1
  270. package/dist/section/discovery.js +6 -2
  271. package/dist/section/publish-shape.js +38 -0
  272. package/dist/section/section.d.ts +1 -1
  273. package/dist/site-analytics.js +6 -1
  274. package/dist/site-runtime/window-height.js +19 -0
  275. package/dist/template/define-template.d.ts +25 -4
  276. package/dist/template/define-template.js +3 -0
  277. package/dist/template/logic-shim.d.ts +1 -1
  278. package/dist/template/materialize.js +3 -1
  279. package/dist/template/running-copy.js +0 -1
  280. package/dist/template/section-reads.js +1 -1
  281. package/guide/reference/cli/INDEX.md +6 -5
  282. package/guide/reference/cli/build.md +10 -8
  283. package/guide/reference/cli/check.md +4 -2
  284. package/guide/reference/cli/dev.md +6 -2
  285. package/guide/reference/cli/install.md +41 -0
  286. package/guide/reference/cli/property-add.md +5 -4
  287. package/guide/reference/cli/property-list.md +2 -2
  288. package/guide/reference/cli/publish.md +5 -5
  289. package/guide/reference/cli/upgrade.md +1 -1
  290. package/guide/reference/rules/INDEX.md +9 -5
  291. package/package.json +14 -30
  292. package/dist/artifact/playground/client/assets/index-ByeGGedv.js +0 -1259
  293. package/dist/artifact/playground/client/assets/index-CxWPYOH2.css +0 -1
  294. package/dist/cli/build/artifact.js +0 -220
  295. package/dist/cli/build/captures.js +0 -48
  296. package/dist/cli/build/fixtures.js +0 -92
  297. package/dist/cli/capture/capture-browser.js +0 -37
  298. package/dist/cli/capture/capture.js +0 -113
  299. package/dist/cli/check/render/inputs.js +0 -60
  300. package/dist/cli/check/render/nav.js +0 -31
  301. package/dist/cli/dev/crop.js +0 -20
  302. package/dist/cli/dev/fixture-ladders.js +0 -96
  303. package/dist/cli/dev/hmr.js +0 -26
  304. package/dist/cli/dev/islands.js +0 -234
  305. package/dist/cli/dev/load-template.js +0 -52
  306. package/dist/cli/dev/vite.js +0 -114
  307. package/dist/cli/dev/workspace-reader.js +0 -248
  308. package/dist/cli/publish/freshness.js +0 -64
  309. package/dist/fixtures/brand.d.ts +0 -4
  310. package/dist/fixtures/brand.js +0 -8
  311. package/dist/fixtures/load.js +0 -159
  312. package/dist/fixtures/resolve.js +0 -392
  313. package/dist/fixtures.d.ts +0 -429
  314. package/dist/fixtures.js +0 -23
  315. package/dist/packages/internal/canvas-core/dist/island-host.js +0 -62
  316. package/dist/packages/internal/canvas-core/dist/island-shields.js +0 -30
  317. package/dist/playground/canvas-island-host.d.ts +0 -11
  318. package/dist/playground/canvas-island-host.js +0 -29
  319. package/dist/playground/canvas-markers.js +0 -14
  320. package/dist/playground/host/paths.js +0 -8
  321. package/dist/playground/layout.js +0 -17
  322. package/dist/playground/wire.js +0 -28
@@ -0,0 +1,202 @@
1
+ import { PLAYGROUND_CANVAS_ISLAND_HOST, SECTION_FILES, builtTreePath, sectionPath } from "../../../template-artifact/dist/layout.js";
2
+ import { readBuild as readBuild$1 } from "../../../template-artifact/dist/build.js";
3
+ import { ROUTES } from "../wire.js";
4
+
5
+ //#region ../../internal/playground/dist/host/built.js
6
+ function localKey(templateKey, published) {
7
+ return published.startsWith(`${templateKey}/`) ? published.slice(templateKey.length + 1) : published;
8
+ }
9
+ function buildFolder(view, read) {
10
+ return { async readText(path) {
11
+ const file = await view.readText(builtTreePath(path));
12
+ read.push(`${path}@${file?.fingerprint ?? "-"}`);
13
+ return file;
14
+ } };
15
+ }
16
+ function viewOf(build) {
17
+ const { composition } = build;
18
+ const local = (key) => localKey(build.key, key);
19
+ const pages = composition.pages.map((page) => ({
20
+ id: page.id,
21
+ label: page.label,
22
+ ..."path" in page ? { path: page.path } : {},
23
+ ..."direction" in page && page.direction !== void 0 ? { direction: page.direction } : {},
24
+ ...page.optional === true ? { optional: true } : {},
25
+ sections: page.sections.map((s) => ({
26
+ instanceId: s.instance_id,
27
+ section: local(s.section)
28
+ }))
29
+ }));
30
+ const published = /* @__PURE__ */ new Map();
31
+ const instances = composition.pages.flatMap((page) => page.sections).filter((s, at, all) => all.findIndex((o) => o.instance_id === s.instance_id) === at).map((s) => {
32
+ const section = build.sections.get(s.section);
33
+ published.set(local(s.section), s.section);
34
+ const schema = section.schema;
35
+ const slots = schema.slots ?? {};
36
+ const variant = schema.display?.variant;
37
+ return {
38
+ instanceId: s.instance_id,
39
+ section: local(s.section),
40
+ label: section.displayName,
41
+ sectionSchema: {
42
+ slots,
43
+ slot_order: [...schema.slot_order ?? Object.keys(slots)]
44
+ },
45
+ display: {
46
+ required: s.required === true,
47
+ variant: variant === void 0 ? null : {
48
+ cases: [...variant.cases ?? []],
49
+ locked: variant.locked === true
50
+ }
51
+ },
52
+ version: {
53
+ schema,
54
+ fillSpec: section.fillSpec
55
+ }
56
+ };
57
+ });
58
+ return {
59
+ template: {
60
+ key: build.key,
61
+ name: build.displayName,
62
+ output: composition.output,
63
+ formats: composition.output === "website" ? [] : composition.formats,
64
+ pages,
65
+ canvases: composition.canvases.map((c) => ({
66
+ id: c.id,
67
+ label: c.label,
68
+ pages: [...c.pages]
69
+ })),
70
+ instances
71
+ },
72
+ binding: build.staticAssets,
73
+ fixtureList: build.fixtureList,
74
+ published
75
+ };
76
+ }
77
+ async function readBuild(view) {
78
+ const read = [];
79
+ return {
80
+ build: viewOf(await readBuild$1(buildFolder(view, read))),
81
+ key: [...read].sort().join("\n")
82
+ };
83
+ }
84
+ function builtFileUrl(env, filename, buildBase) {
85
+ return buildBase === void 0 ? env.url(`${ROUTES.build}${filename}`) : `${buildBase}${filename}`;
86
+ }
87
+ function builtIslands(env, binding, buildBase) {
88
+ const islands = Object.entries(binding.islands);
89
+ if (islands.length === 0) return {
90
+ map: {},
91
+ canvasHost: null,
92
+ importMap: {},
93
+ documentLoader: { kind: "none" }
94
+ };
95
+ const { island_runtime: runtime, react_vendor: vendor, react_vendor_core: core } = binding;
96
+ if (runtime === null || vendor === null || core === null) throw new Error("The build binds islands but no island runtime or React vendor.");
97
+ const url = (filename) => builtFileUrl(env, filename, buildBase);
98
+ const map = Object.fromEntries(islands.map(([key, ref]) => [key, url(ref.filename)]));
99
+ const importMap = Object.fromEntries(Object.entries(vendor).map(([specifier, ref]) => [specifier, url(ref.filename)]));
100
+ return {
101
+ map,
102
+ canvasHost: env.url(PLAYGROUND_CANVAS_ISLAND_HOST),
103
+ importMap,
104
+ documentLoader: {
105
+ kind: "bundles",
106
+ runtime: { url: url(runtime.filename) },
107
+ islandMap: map,
108
+ reactVendorMap: importMap,
109
+ reactVendorCore: { url: url(core.filename) }
110
+ }
111
+ };
112
+ }
113
+ function shippedHalf(env) {
114
+ const { captures } = env;
115
+ if (captures === void 0) return {};
116
+ return {
117
+ captured: () => captures.fixtures(),
118
+ shipped: (path) => captures.read(path)
119
+ };
120
+ }
121
+ function builtEnv(env) {
122
+ let read = null;
123
+ let held = null;
124
+ const readAt = (view) => {
125
+ if (read?.version === view.version) return read.build;
126
+ const reading = readBuild(view).then(({ build, key }) => {
127
+ if (held?.key === key) return held.build;
128
+ held = {
129
+ key,
130
+ build
131
+ };
132
+ return build;
133
+ });
134
+ read = {
135
+ version: view.version,
136
+ build: reading
137
+ };
138
+ reading.catch(() => {
139
+ if (read?.build === reading) read = null;
140
+ });
141
+ return reading;
142
+ };
143
+ const current = async () => readAt(await env.files.current());
144
+ const publishedKey = (build, key) => {
145
+ const published = build.published.get(key);
146
+ if (published === void 0) throw new Error(`The composition places no section "${key}".`);
147
+ return published;
148
+ };
149
+ const computesAt = async (build, key) => {
150
+ const published = publishedKey(build, key);
151
+ const schema = build.template.instances.find((i) => i.section === key).version?.schema ?? {};
152
+ const computed = (await env.loadModule(sectionPath(published, SECTION_FILES.logic))).computed ?? {};
153
+ return {
154
+ localKey: key,
155
+ schema: {
156
+ slots: schema.slots ?? {},
157
+ display: schema.display ?? {}
158
+ },
159
+ bakeContext: {
160
+ computed,
161
+ section_key: key
162
+ }
163
+ };
164
+ };
165
+ return {
166
+ reader: {
167
+ template: async () => (await current()).template,
168
+ islands: async (buildBase) => builtIslands(env, (await current()).binding, buildBase),
169
+ computes: async (key) => computesAt(await current(), key),
170
+ binding: async () => (await current()).binding,
171
+ ...shippedHalf(env)
172
+ },
173
+ site: {
174
+ binding: async () => (await current()).binding,
175
+ async buildFile(path) {
176
+ const read = await (await env.files.current()).readBytes(builtTreePath(path));
177
+ if (read === null) throw new Error(`The build has no file at "${path}".`);
178
+ return read.bytes;
179
+ },
180
+ shareImage: env.shareImage
181
+ },
182
+ readAt,
183
+ computesAt,
184
+ renderer: {
185
+ async section(key) {
186
+ const path = sectionPath(publishedKey(await current(), key), SECTION_FILES.renderer);
187
+ const component = (await env.loadModule(path)).default;
188
+ if (typeof component !== "function" && (typeof component !== "object" || component === null)) throw new Error(`${path} has no default-exported component.`);
189
+ return component;
190
+ },
191
+ createElement: (type, props) => env.react.createElement(type, props),
192
+ renderToString: (element, options) => env.react.renderToString(element, options)
193
+ },
194
+ stylesheets: async (buildBase) => {
195
+ const { binding } = await current();
196
+ return [builtFileUrl(env, binding.base_css.filename, buildBase), builtFileUrl(env, binding.template_css.filename, buildBase)];
197
+ }
198
+ };
199
+ }
200
+
201
+ //#endregion
202
+ export { builtEnv };
@@ -0,0 +1,53 @@
1
+ import { candidateSet } from "../../../template-contracts/dist/media-candidates.js";
2
+ import { fixtureAddresses } from "./fixture-addresses.js";
3
+
4
+ //#region ../../internal/playground/dist/host/catalog-fixture.js
5
+ function textOf(value) {
6
+ return typeof value === "string" && value !== "" ? value : null;
7
+ }
8
+ function propertySummary(facts) {
9
+ return {
10
+ listingIntent: textOf(facts.listing_intent),
11
+ units: facts.units.length,
12
+ photos: candidateSet(facts, {
13
+ kinds: ["image"],
14
+ from: ["property.property_media"]
15
+ }).length
16
+ };
17
+ }
18
+ function docFingerprint(instances) {
19
+ const text = JSON.stringify(instances);
20
+ let h1 = 3735928559;
21
+ let h2 = 1103547991;
22
+ for (let i = 0; i < text.length; i++) {
23
+ const ch = text.charCodeAt(i);
24
+ h1 = Math.imul(h1 ^ ch, 2654435761);
25
+ h2 = Math.imul(h2 ^ ch, 1597334677);
26
+ }
27
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
28
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
29
+ return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(16).padStart(14, "0");
30
+ }
31
+ function catalogFixture(plan, property, fixture) {
32
+ const pagesOff = Object.entries(fixture.pages ?? {}).flatMap(([pageId, state]) => state.enabled ? [] : [pageId]);
33
+ return {
34
+ name: fixture.id,
35
+ doc: docFingerprint(fixture.instances),
36
+ ...fixture.capturable === false ? { capturable: false } : {},
37
+ ...pagesOff.length > 0 ? { pagesOff } : {},
38
+ addresses: fixtureAddresses(plan, property, fixture)
39
+ };
40
+ }
41
+ function fixturesOn(held, property) {
42
+ return held.fixtures.filter((fixture) => fixture.property === property.file);
43
+ }
44
+ function catalogProperty(plan, held, property) {
45
+ return {
46
+ name: property.name,
47
+ summary: propertySummary(property.facts),
48
+ content: fixturesOn(held, property).map((fixture) => catalogFixture(plan, property.name, fixture))
49
+ };
50
+ }
51
+
52
+ //#endregion
53
+ export { catalogFixture, catalogProperty, docFingerprint, fixturesOn, propertySummary };
@@ -0,0 +1,34 @@
1
+ import { addressComplete, addressView, normalizeAddressValue } from "../../../template-contracts/dist/address-value.js";
2
+ import { CAPTURE_FILES } from "../../../template-artifact/dist/layout.js";
3
+
4
+ //#region ../../internal/playground/dist/host/download.js
5
+ const PAGE_IMAGE = ".png";
6
+ function parseDownloadPath(rest) {
7
+ if (rest.length === 0) return { page: null };
8
+ const [name] = rest;
9
+ if (rest.length !== 1 || name === void 0 || !name.endsWith(PAGE_IMAGE) || name.length === 4) return null;
10
+ return { page: name.slice(0, -4) };
11
+ }
12
+ function propertyAddressOf(facts) {
13
+ const value = facts.address;
14
+ if (!addressComplete(value)) return null;
15
+ const normalized = normalizeAddressValue(value);
16
+ return normalized === null ? null : addressView(normalized).display;
17
+ }
18
+ function attachmentDisposition(name) {
19
+ return `attachment; filename*=UTF-8''${encodeURIComponent(name)}`;
20
+ }
21
+ function shippedDownloadPath(input) {
22
+ const at = `${input.fixture}/${input.format}/`;
23
+ if (input.file.contentType === "application/pdf") return `${at}${CAPTURE_FILES.document}`;
24
+ if (input.file.contentType === "application/zip") return `${at}${CAPTURE_FILES.bundle}`;
25
+ return `${at}${input.file.page ?? ""}${PAGE_IMAGE}`;
26
+ }
27
+ function correctedDownloadLocation(url, named, owner) {
28
+ const from = `/properties/${encodeURIComponent(named)}/content/`;
29
+ const at = url.pathname.lastIndexOf(from);
30
+ return `${at < 0 ? url.pathname : `${url.pathname.slice(0, at)}/properties/${encodeURIComponent(owner)}/content/${url.pathname.slice(at + from.length)}`}${url.search}`;
31
+ }
32
+
33
+ //#endregion
34
+ export { attachmentDisposition, correctedDownloadLocation, parseDownloadPath, propertyAddressOf, shippedDownloadPath };
@@ -0,0 +1,11 @@
1
+ //#region ../../internal/playground/dist/host/env.js
2
+ var HostRefusal = class extends Error {
3
+ status;
4
+ constructor(status, message) {
5
+ super(message);
6
+ this.status = status;
7
+ }
8
+ };
9
+
10
+ //#endregion
11
+ export { HostRefusal };
@@ -0,0 +1,353 @@
1
+ import { normalizeAddressValue } from "../../../template-contracts/dist/address-value.js";
2
+ import { withSubsetOrder } from "../../../template-contracts/dist/media-candidates.js";
3
+ import { tableHome, tableNames } from "../../../template-contracts/dist/registry-shape.js";
4
+ import { pickedMediaField, propertyFacts } from "../../../template-contracts/dist/fact-registry.js";
5
+ import { tableFields } from "../../../template-contracts/dist/table-members.js";
6
+ import { comparableImageId, contactImageId } from "./property-derive.js";
7
+ import { HostRefusal } from "./env.js";
8
+ import { withMadeRows } from "../../../content-doc-ops/dist/made-rows.js";
9
+ import { factWrite } from "./property-saves.js";
10
+
11
+ //#region ../../internal/playground/dist/host/everywhere-saves.js
12
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
13
+ const NO_MEDIA = {
14
+ staged: /* @__PURE__ */ new Map(),
15
+ adoptedMember: (instance, slot) => {
16
+ throw new HostRefusal(422, `"${instance}.${slot}": this batch reads no section, so nothing adopts.`);
17
+ }
18
+ };
19
+ function applyEverywhere(target, property, ops, onContentOp, media = NO_MEDIA) {
20
+ const working = {
21
+ property: { ...property },
22
+ rowIds: /* @__PURE__ */ new Map(),
23
+ media,
24
+ committed: /* @__PURE__ */ new Set()
25
+ };
26
+ for (const sent of ops) {
27
+ const op = withMadeRows(sent, working.rowIds);
28
+ if (op.op === "set_slot" || op.op === "relink_slot") onContentOp(op);
29
+ else applyFactOp(target, working, op);
30
+ }
31
+ return {
32
+ property: working.property,
33
+ rowIds: working.rowIds,
34
+ committed: working.committed
35
+ };
36
+ }
37
+ function applyFactOp(target, working, op) {
38
+ switch (op.op) {
39
+ case "set_value":
40
+ working.property = factWrite(target, working.property, op.path, op.value);
41
+ return;
42
+ case "add_row":
43
+ addRow(working, op.home, op.path, op.value, op.temp_id);
44
+ return;
45
+ case "remove_row":
46
+ removeRow(working, op.home, op.path);
47
+ return;
48
+ case "pick":
49
+ pick(working, op.path, op.id);
50
+ return;
51
+ case "unpick":
52
+ unpick(working, op.path, op.id);
53
+ return;
54
+ case "order":
55
+ order(working, op.home, op.path, op.ids);
56
+ return;
57
+ case "set_list":
58
+ setList(working, op.path, op.list);
59
+ return;
60
+ case "clear_media":
61
+ clearMedia(working, op.path);
62
+ return;
63
+ case "commit_media":
64
+ commitMedia(working, op.path, op.media_id);
65
+ return;
66
+ case "adopt_media":
67
+ adoptMedia(working, op.instance_id, op.slot, op.row_id, op.media_id);
68
+ return;
69
+ }
70
+ }
71
+ const isTable = (name) => tableNames().includes(name);
72
+ function listDeclaration(key, path) {
73
+ const pages = propertyFacts.pages;
74
+ const declaration = (Object.hasOwn(pages, key) ? pages[key] : void 0)?.declaration;
75
+ if (declaration?.type !== "list") throw new HostRefusal(400, `"${path}" names no list the property holds.`);
76
+ return declaration;
77
+ }
78
+ function rowsOf(property, key) {
79
+ const rows = property[key];
80
+ return Array.isArray(rows) ? rows : [];
81
+ }
82
+ function fieldsOf(element, table) {
83
+ if (element.type === "object") return element.fields;
84
+ if (element.type === "row" && table !== null && isTable(table)) return tableFields(table);
85
+ return {};
86
+ }
87
+ function identityOf(element, item) {
88
+ if (!isRecord(item)) return null;
89
+ const picked = pickedMediaField(element);
90
+ if (picked !== null) return mediaIdOf(item[picked]);
91
+ if (typeof item["id"] === "string") return item["id"];
92
+ return mediaIdOf(item);
93
+ }
94
+ function mediaIdOf(value) {
95
+ if (typeof value === "string" && value !== "") return value;
96
+ if (!isRecord(value)) return null;
97
+ for (const key of ["media", "media_id"]) if (typeof value[key] === "string" && value[key] !== "") return value[key];
98
+ return null;
99
+ }
100
+ function isMediaPick(declaration) {
101
+ return [
102
+ "media",
103
+ "image",
104
+ "video",
105
+ "tour",
106
+ "document"
107
+ ].includes(declaration.type) && declaration.from !== void 0;
108
+ }
109
+ function isOwnedMedia(declaration) {
110
+ return [
111
+ "image",
112
+ "video",
113
+ "tour",
114
+ "document"
115
+ ].includes(declaration.type) && declaration.from === void 0;
116
+ }
117
+ function listAt(property, path) {
118
+ const parts = path.split(".");
119
+ const [key] = parts;
120
+ const top = listDeclaration(key, path);
121
+ if (parts.length === 1) return {
122
+ path,
123
+ element: top.element,
124
+ items: rowsOf(property, key),
125
+ write: (items) => ({
126
+ ...property,
127
+ [key]: [...items]
128
+ })
129
+ };
130
+ if (parts.length !== 3) throw new HostRefusal(400, `"${path}" names no list: a list is a fact, or a row's list member.`);
131
+ const [, rowId, member] = parts;
132
+ const field = fieldsOf(top.element, key)[member];
133
+ if (field?.type !== "list") throw new HostRefusal(400, `"${path}" names no list a ${key} row holds.`);
134
+ const rows = rowsOf(property, key);
135
+ const row = rows.find((r) => identityOf(top.element, r) === rowId);
136
+ if (!isRecord(row)) throw new HostRefusal(404, `The property document holds no ${key} row "${rowId}".`);
137
+ const items = Array.isArray(row[member]) ? row[member] : [];
138
+ return {
139
+ path,
140
+ element: field.element,
141
+ items,
142
+ write: (next) => ({
143
+ ...property,
144
+ [key]: rows.map((r) => r === row ? {
145
+ ...row,
146
+ [member]: [...next]
147
+ } : r)
148
+ })
149
+ };
150
+ }
151
+ function itemAt(property, path) {
152
+ const cut = path.lastIndexOf(".");
153
+ if (cut < 0) throw new HostRefusal(400, `"${path}" names no row or item.`);
154
+ return {
155
+ list: listAt(property, path.slice(0, cut)),
156
+ id: path.slice(cut + 1)
157
+ };
158
+ }
159
+ function documentValue(declaration, value, at) {
160
+ if (value === void 0) return null;
161
+ if (isOwnedMedia(declaration)) {
162
+ if (value === null) return null;
163
+ throw new HostRefusal(422, `${at}: a row's own image is set by committing a file staged for it, not by a value.`);
164
+ }
165
+ if (isMediaPick(declaration)) {
166
+ const id = mediaIdOf(value);
167
+ return id === null ? null : { media: id };
168
+ }
169
+ if (declaration.type === "address") return value === null ? null : normalizeAddressValue(value);
170
+ if (declaration.type === "list") return (Array.isArray(value) ? value : []).filter((entry) => entry !== null && entry !== void 0 && entry !== "").map((entry, i) => documentValue(declaration.element, entry, `${at}[${String(i)}]`));
171
+ if (declaration.type === "object") return isRecord(value) ? documentObject(declaration.fields, value, at) : null;
172
+ return value;
173
+ }
174
+ const isDerived = (declaration) => declaration.source?.kind === "compute";
175
+ function documentObject(fields, value, at) {
176
+ for (const name of Object.keys(value)) {
177
+ if (name === "id") continue;
178
+ const field = Object.hasOwn(fields, name) ? fields[name] : void 0;
179
+ if (field === void 0) throw new HostRefusal(400, `${at}: the item declares no field "${name}".`);
180
+ if (isDerived(field)) throw new HostRefusal(400, `${at}: "${name}" is derived, so no one writes it.`);
181
+ }
182
+ const out = {};
183
+ for (const [name, field] of Object.entries(fields)) {
184
+ if (isDerived(field)) continue;
185
+ out[name] = Object.hasOwn(value, name) ? documentValue(field, value[name], `${at}.${name}`) : field.type === "list" ? [] : null;
186
+ }
187
+ return out;
188
+ }
189
+ const newRowId = () => globalThis.crypto.randomUUID();
190
+ function addRow(working, home, path, value, tempId) {
191
+ const fields = isRecord(value) ? value : {};
192
+ if (home === "library") {
193
+ if (path !== "contacts" || !isTable(path) || tableHome(path) !== "library") throw new HostRefusal(400, `"${path}" names no list of the library.`);
194
+ const id = newRowId();
195
+ const row = {
196
+ id,
197
+ ...documentObject(tableFields(path), fields, `add_row "${path}"`)
198
+ };
199
+ working.property = {
200
+ ...working.property,
201
+ contacts: [...rowsOf(working.property, "contacts"), row]
202
+ };
203
+ working.rowIds.set(tempId, id);
204
+ return;
205
+ }
206
+ const list = listAt(working.property, path);
207
+ const { element } = list;
208
+ if (element.type !== "object") throw new HostRefusal(422, `"${path}" is a list of ${element.type === "row" ? "rows the library holds, so add one there and pick it" : "picks, so pick one"}.`);
209
+ const added = documentObject(element.fields, fields, `add_row "${path}"`);
210
+ const picked = pickedMediaField(element);
211
+ if (picked !== null) {
212
+ const reference = identityOf(element, added);
213
+ if (reference === null) throw new HostRefusal(400, `add_row "${path}": an item of this list is named by the ${picked} it picks; pick one.`);
214
+ const held = list.items.find((item) => identityOf(element, item) === reference);
215
+ working.property = held === void 0 ? list.write([added, ...list.items]) : list.write(list.items.map((item) => item === held ? {
216
+ ...item,
217
+ ...stated(added, fields)
218
+ } : item));
219
+ working.rowIds.set(tempId, reference);
220
+ return;
221
+ }
222
+ const id = newRowId();
223
+ working.property = list.write([{
224
+ id,
225
+ ...added
226
+ }, ...list.items]);
227
+ working.rowIds.set(tempId, id);
228
+ }
229
+ function stated(added, carried) {
230
+ return Object.fromEntries(Object.entries(added).filter(([name]) => Object.hasOwn(carried, name)));
231
+ }
232
+ function removeRow(working, home, path) {
233
+ if (home === "library" && path.split(".")[0] !== "contacts") throw new HostRefusal(400, `"${path}" names no row of the library.`);
234
+ const { list, id } = itemAt(working.property, path);
235
+ if (!list.items.some((item) => identityOf(list.element, item) === id)) throw new HostRefusal(404, `"${list.path}" holds no item "${id}".`);
236
+ working.property = list.write(list.items.filter((item) => identityOf(list.element, item) !== id));
237
+ }
238
+ function pick(working, path, id) {
239
+ const list = listAt(working.property, path);
240
+ const { element } = list;
241
+ if (element.type === "row") {
242
+ if (!list.items.some((item) => identityOf(element, item) === id)) throw new HostRefusal(404, `The fixture's library holds no ${path} row "${id}".`);
243
+ return;
244
+ }
245
+ if (!isMediaPick(element)) throw new HostRefusal(400, `"${path}" is not a list of picks.`);
246
+ if (list.items.some((item) => identityOf(element, item) === id)) return;
247
+ if (!rowsOf(working.property, "uploads").some((upload) => isRecord(upload) && upload["id"] === id)) throw new HostRefusal(404, `The property's uploads hold no "${id}" to pick.`);
248
+ working.property = list.write([...list.items, { media: id }]);
249
+ }
250
+ function unpick(working, path, id) {
251
+ const list = listAt(working.property, path);
252
+ if (list.element.type !== "row" && !isMediaPick(list.element)) throw new HostRefusal(400, `"${path}" is not a list of picks.`);
253
+ if (!list.items.some((item) => identityOf(list.element, item) === id)) return;
254
+ working.property = list.write(list.items.filter((item) => identityOf(list.element, item) !== id));
255
+ }
256
+ function order(working, home, path, ids) {
257
+ if (home === "library") throw new HostRefusal(422, `The fixture's library is its property's ${path}; order them on the property.`);
258
+ const list = listAt(working.property, path);
259
+ const held = list.items.map((item) => identityOf(list.element, item) ?? "");
260
+ const next = withSubsetOrder(held, ids);
261
+ const byId = new Map(list.items.map((item, i) => [held[i], item]));
262
+ if (next.every((id, i) => id === held[i])) return;
263
+ working.property = list.write(next.map((id) => byId.get(id)));
264
+ }
265
+ function setList(working, path, desired) {
266
+ if (path.split(".").length !== 3) throw new HostRefusal(400, `"${path}" names no list nested in a row.`);
267
+ const list = listAt(working.property, path);
268
+ const { element } = list;
269
+ if (desired.kind === "picks") {
270
+ if (!isMediaPick(element)) throw new HostRefusal(400, `"${path}" is not a list of picks.`);
271
+ const held = new Map(list.items.map((item) => [identityOf(element, item), item]));
272
+ working.property = list.write(desired.media_ids.map((id) => held.get(id) ?? { media: id }));
273
+ return;
274
+ }
275
+ if (element.type !== "object") return;
276
+ const unmatched = [...list.items];
277
+ const take = (id) => {
278
+ if (id === null) return void 0;
279
+ const at = unmatched.findIndex((item) => identityOf(element, item) === id);
280
+ return at < 0 ? void 0 : unmatched.splice(at, 1)[0];
281
+ };
282
+ const picked = pickedMediaField(element);
283
+ const next = desired.items.map((wanted, i) => {
284
+ const held = take(wanted.id) ?? (picked === null ? void 0 : take(mediaIdOf(wanted.fields[picked])));
285
+ const at = `set_list "${path}"[${String(i)}]`;
286
+ if (isRecord(held)) {
287
+ const edits = {};
288
+ for (const [name, value] of Object.entries(wanted.fields)) {
289
+ const field = Object.hasOwn(element.fields, name) ? element.fields[name] : void 0;
290
+ if (field === void 0) throw new HostRefusal(400, `${at}: the item declares no field "${name}".`);
291
+ edits[name] = documentValue(field, value === "" ? null : value, `${at}.${name}`);
292
+ }
293
+ return {
294
+ ...held,
295
+ ...edits
296
+ };
297
+ }
298
+ const fields = Object.fromEntries(Object.entries(wanted.fields).filter(([, value]) => value !== null));
299
+ const added = documentObject(element.fields, fields, at);
300
+ if (picked !== null) {
301
+ if (identityOf(element, added) === null) throw new HostRefusal(400, `${at}: an item of this list is named by the ${picked} it picks; pick one.`);
302
+ return added;
303
+ }
304
+ return {
305
+ id: newRowId(),
306
+ ...added
307
+ };
308
+ });
309
+ working.property = list.write(next);
310
+ }
311
+ function ownedRowFieldAt(property, path) {
312
+ const parts = path.split(".");
313
+ if (parts.length !== 3) throw new HostRefusal(400, `"${path}" is in no row, so nothing can own its media.`);
314
+ const [table, rowId, member] = parts;
315
+ const { list } = itemAt(property, `${table}.${rowId}`);
316
+ const field = fieldsOf(list.element, table)[member];
317
+ if (field === void 0 || !isOwnedMedia(field)) throw new HostRefusal(400, `"${path}" is not an owned media field.`);
318
+ const row = list.items.find((item) => identityOf(list.element, item) === rowId);
319
+ if (!isRecord(row)) throw new HostRefusal(404, `The property document holds no ${table} row "${rowId}".`);
320
+ return {
321
+ table,
322
+ rowId,
323
+ member,
324
+ kind: field.type,
325
+ heldId: table === "comparables" ? comparableImageId(rowId) : contactImageId(rowId, member),
326
+ held: row[member],
327
+ write: (value) => list.write(list.items.map((item) => item === row ? {
328
+ ...row,
329
+ [member]: value
330
+ } : item))
331
+ };
332
+ }
333
+ function clearMedia(working, path) {
334
+ const field = ownedRowFieldAt(working.property, path);
335
+ if (field.held === null || field.held === void 0) return;
336
+ working.property = field.write(null);
337
+ }
338
+ function commitMedia(working, path, mediaId) {
339
+ const field = ownedRowFieldAt(working.property, path);
340
+ if (mediaId === field.heldId && field.held !== null && field.held !== void 0) return;
341
+ const staged = working.media.staged.get(mediaId);
342
+ if (staged === void 0) throw new HostRefusal(404, `"${path}" holds no media "${mediaId}": no such file was uploaded for it in the property's folder or staged in the content fixture named.`);
343
+ if (staged.kind !== field.kind) throw new HostRefusal(415, `"${path}" holds ${field.kind === "image" ? "an" : "a"} ${field.kind}, and "${mediaId}" is ${staged.kind === "image" ? "an" : "a"} ${staged.kind}.`);
344
+ working.property = field.write(staged.file);
345
+ working.committed.add(mediaId);
346
+ }
347
+ function adoptMedia(working, instance, slot, rowId, mediaId) {
348
+ const member = working.media.adoptedMember(instance, slot);
349
+ commitMedia(working, `${member.table}.${rowId}.${member.member}`, mediaId);
350
+ }
351
+
352
+ //#endregion
353
+ export { applyEverywhere, ownedRowFieldAt };