@homepages/concrete 12.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 (311) hide show
  1. package/CHANGELOG.md +184 -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 +11 -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 -59
  16. package/dist/base.css +2 -2
  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 +47 -21
  123. package/dist/packages/internal/fill-bake/dist/index.js +5 -1
  124. package/dist/packages/internal/fill-bake/dist/item-merge.js +4 -3
  125. package/dist/packages/internal/fill-bake/dist/resolve-instance.js +9 -0
  126. package/dist/packages/internal/fill-bake/dist/resolve.js +3 -0
  127. package/dist/packages/internal/fill-bake/dist/round-trip.js +2 -0
  128. package/dist/packages/internal/fill-bake/dist/strip.js +6 -0
  129. package/dist/packages/internal/fill-vocabulary/dist/holder.js +1 -1
  130. package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +1 -1
  131. package/dist/packages/internal/fill-vocabulary/dist/verbs.js +1 -1
  132. package/dist/packages/internal/island-runtime/dist/index.js +1 -10
  133. package/dist/packages/internal/island-runtime/dist/use-capture-ready.d.ts +5 -0
  134. package/dist/packages/internal/lead-fields/dist/ingest.js +72 -0
  135. package/dist/packages/internal/media-resolution/dist/video.js +6 -2
  136. package/dist/packages/internal/page-render/dist/addresses.js +57 -0
  137. package/dist/packages/internal/page-render/dist/index.js +6 -0
  138. package/dist/packages/internal/page-render/dist/kept.js +30 -0
  139. package/dist/packages/internal/page-render/dist/nav.js +42 -0
  140. package/dist/packages/internal/page-render/dist/render.js +152 -0
  141. package/dist/packages/internal/page-shell/dist/assemble.js +161 -0
  142. package/dist/packages/internal/page-shell/dist/escape.js +10 -0
  143. package/dist/packages/internal/page-shell/dist/frame.js +23 -0
  144. package/dist/packages/internal/page-shell/dist/index.js +26 -0
  145. package/dist/packages/internal/playground/dist/build-fingerprint.js +18 -0
  146. package/dist/packages/internal/playground/dist/fixture-conversions/list-names-properties.js +76 -0
  147. package/dist/packages/internal/playground/dist/fixture-formats.d.ts +37 -0
  148. package/dist/packages/internal/playground/dist/fixture-formats.js +20 -0
  149. package/dist/packages/internal/playground/dist/host/bootstrap.js +108 -0
  150. package/dist/packages/internal/playground/dist/host/built.js +202 -0
  151. package/dist/packages/internal/playground/dist/host/catalog-fixture.js +53 -0
  152. package/dist/packages/internal/playground/dist/host/download.js +34 -0
  153. package/dist/packages/internal/playground/dist/host/env.js +11 -0
  154. package/dist/packages/internal/playground/dist/host/everywhere-saves.js +353 -0
  155. package/dist/packages/internal/playground/dist/host/fixture-addresses.js +52 -0
  156. package/dist/packages/internal/playground/dist/host/fixture-documents.js +494 -0
  157. package/dist/packages/internal/playground/dist/host/fixture-operations.js +364 -0
  158. package/dist/packages/internal/playground/dist/host/fixture-units.js +93 -0
  159. package/dist/{fixtures → packages/internal/playground/dist/host}/image-dimensions.js +1 -1
  160. package/dist/packages/internal/playground/dist/host/leads.js +41 -0
  161. package/dist/packages/internal/playground/dist/host/media-saves.js +309 -0
  162. package/dist/{fixtures → packages/internal/playground/dist/host}/media-store.js +79 -26
  163. package/dist/packages/internal/playground/dist/host/overridable.js +9 -0
  164. package/dist/packages/internal/playground/dist/host/owned-saves.js +203 -0
  165. package/dist/{playground → packages/internal/playground/dist}/host/page-state.js +1 -1
  166. package/dist/packages/internal/playground/dist/host/program.js +54 -0
  167. package/dist/packages/internal/playground/dist/host/property-derive.js +216 -0
  168. package/dist/packages/internal/playground/dist/host/property-saves.js +74 -0
  169. package/dist/{fixtures → packages/internal/playground/dist/host}/property.js +88 -229
  170. package/dist/packages/internal/playground/dist/host/provenance.js +49 -0
  171. package/dist/packages/internal/playground/dist/host/resolve.js +553 -0
  172. package/dist/packages/internal/playground/dist/host/row-images.js +41 -0
  173. package/dist/{fixtures → packages/internal/playground/dist/host}/rows.js +1 -1
  174. package/dist/packages/internal/playground/dist/host/save.js +429 -0
  175. package/dist/packages/internal/playground/dist/host/serve.js +952 -0
  176. package/dist/packages/internal/playground/dist/host/site.js +79 -0
  177. package/dist/packages/internal/playground/dist/host/slots.js +202 -0
  178. package/dist/packages/internal/playground/dist/host/stated-content.js +93 -0
  179. package/dist/packages/internal/playground/dist/host/stored-fixtures.js +135 -0
  180. package/dist/packages/internal/playground/dist/host/violations.js +7 -0
  181. package/dist/packages/internal/playground/dist/jobs/lanes.js +24 -0
  182. package/dist/packages/internal/playground/dist/jobs/memory-queue.js +112 -0
  183. package/dist/packages/internal/playground/dist/jobs/probe.js +37 -0
  184. package/dist/packages/internal/playground/dist/jobs/queue.js +28 -0
  185. package/dist/packages/internal/playground/dist/jobs/runner.js +207 -0
  186. package/dist/packages/internal/playground/dist/layout.js +14 -0
  187. package/dist/packages/internal/playground/dist/platform.js +33 -0
  188. package/dist/packages/internal/playground/dist/server/changes.js +57 -0
  189. package/dist/packages/internal/playground/dist/server/crop.js +47 -0
  190. package/dist/packages/internal/playground/dist/server/derived-files.js +88 -0
  191. package/dist/packages/internal/playground/dist/server/download.js +158 -0
  192. package/dist/{cli/dev → packages/internal/playground/dist/server}/http.js +4 -12
  193. package/dist/packages/internal/playground/dist/server/jobs.js +29 -0
  194. package/dist/{cli/dev → packages/internal/playground/dist/server}/listen.js +4 -11
  195. package/dist/packages/internal/playground/dist/server/playground-server.js +424 -0
  196. package/dist/{cli/dev → packages/internal/playground/dist/server}/request-error.js +1 -1
  197. package/dist/packages/internal/playground/dist/server/size-ladders.js +170 -0
  198. package/dist/packages/internal/playground/dist/server/verification.js +75 -0
  199. package/dist/packages/internal/playground/dist/server/verify-build.js +139 -0
  200. package/dist/packages/internal/playground/dist/wire.js +78 -0
  201. package/dist/packages/internal/property-facts/dist/registry-facts.js +1 -1
  202. package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +1 -1
  203. package/dist/packages/internal/section-contracts/dist/reads-acyclic-contract.js +1 -1
  204. package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +1 -1
  205. package/dist/packages/internal/site-files/dist/head.js +59 -0
  206. package/dist/packages/internal/site-files/dist/index.js +4 -0
  207. package/dist/packages/internal/site-files/dist/site.js +211 -0
  208. package/dist/packages/internal/static-assets-binding/dist/index.js +32 -0
  209. package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +38 -5
  210. package/dist/packages/internal/template-artifact/dist/asset-mime.js +8 -1
  211. package/dist/packages/internal/template-artifact/dist/build.js +148 -0
  212. package/dist/packages/internal/template-artifact/dist/composition.js +62 -0
  213. package/dist/packages/internal/template-artifact/dist/index.js +2 -2
  214. package/dist/packages/internal/template-artifact/dist/layout.js +48 -12
  215. package/dist/packages/internal/template-artifact/dist/manifest.js +3 -10
  216. package/dist/packages/internal/template-artifact/dist/verify.js +51 -31
  217. package/dist/packages/internal/template-contracts/dist/address-value.js +6 -1
  218. package/dist/packages/internal/template-contracts/dist/content-categories.js +10 -1
  219. package/dist/packages/internal/template-contracts/dist/fact-compute.d.ts +1 -1
  220. package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +1 -1
  221. package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +3 -3
  222. package/dist/packages/internal/template-contracts/dist/fact-registry.js +59 -32
  223. package/dist/packages/internal/template-contracts/dist/fill-spec.js +14 -1
  224. package/dist/packages/internal/template-contracts/dist/list.d.ts +3 -3
  225. package/dist/packages/internal/template-contracts/dist/media-candidates.js +67 -2
  226. package/dist/packages/internal/template-contracts/dist/media-offer.js +180 -0
  227. package/dist/packages/internal/template-contracts/dist/object.d.ts +2 -2
  228. package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +9 -2
  229. package/dist/packages/internal/template-contracts/dist/read-graph.js +36 -2
  230. package/dist/packages/internal/template-contracts/dist/ref-locate.js +16 -1
  231. package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +9 -10
  232. package/dist/packages/internal/template-contracts/dist/registry-facts.js +12 -1
  233. package/dist/packages/internal/template-contracts/dist/registry-graph.js +112 -0
  234. package/dist/packages/internal/template-contracts/dist/registry-shape.js +15 -2
  235. package/dist/packages/internal/template-contracts/dist/require-graph.js +300 -0
  236. package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +3 -3
  237. package/dist/packages/internal/template-contracts/dist/row.d.ts +3 -3
  238. package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +1 -1
  239. package/dist/{schema → packages/internal/template-contracts/dist}/section-nav.d.ts +1 -1
  240. package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +4 -4
  241. package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +3 -1
  242. package/dist/packages/internal/template-contracts/dist/slot-catalog.js +24 -1
  243. package/dist/packages/internal/template-contracts/dist/slot-overrides.js +26 -1
  244. package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +1 -1
  245. package/dist/packages/internal/template-contracts/dist/slot-types.js +1 -1
  246. package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +1 -1
  247. package/dist/packages/internal/template-contracts/dist/table-members.js +7 -2
  248. package/dist/packages/internal/template-contracts/dist/video-value.d.ts +1 -1
  249. package/dist/packages/internal/upload-formats/dist/heic.js +35 -0
  250. package/dist/packages/internal/upload-formats/dist/index.js +80 -0
  251. package/dist/packages/internal/upload-formats/dist/magic-bytes.js +293 -0
  252. package/dist/platform/paths.js +1 -0
  253. package/dist/platform/process.js +49 -1
  254. package/dist/rules/registry.js +27 -3
  255. package/dist/schema/fact.d.ts +2 -2
  256. package/dist/schema/facts-view.d.ts +1 -1
  257. package/dist/schema/section-props.d.ts +1 -1
  258. package/dist/schema/section-schema.d.ts +1 -1
  259. package/dist/schema/section-schema.js +1 -0
  260. package/dist/section/declare.d.ts +1 -1
  261. package/dist/section/discovery.js +6 -2
  262. package/dist/section/publish-shape.js +38 -0
  263. package/dist/section/section.d.ts +1 -1
  264. package/dist/template/define-template.d.ts +14 -4
  265. package/dist/template/define-template.js +2 -0
  266. package/dist/template/logic-shim.d.ts +1 -1
  267. package/dist/template/materialize.js +1 -1
  268. package/dist/template/running-copy.js +0 -1
  269. package/dist/template/section-reads.js +1 -1
  270. package/guide/reference/cli/INDEX.md +6 -5
  271. package/guide/reference/cli/build.md +10 -8
  272. package/guide/reference/cli/check.md +4 -2
  273. package/guide/reference/cli/dev.md +6 -2
  274. package/guide/reference/cli/install.md +41 -0
  275. package/guide/reference/cli/property-add.md +5 -4
  276. package/guide/reference/cli/property-list.md +2 -2
  277. package/guide/reference/cli/publish.md +5 -5
  278. package/guide/reference/cli/upgrade.md +1 -1
  279. package/guide/reference/rules/INDEX.md +8 -4
  280. package/package.json +14 -30
  281. package/dist/artifact/playground/client/assets/index-BcLGpWLR.js +0 -1266
  282. package/dist/artifact/playground/client/assets/index-CxWPYOH2.css +0 -1
  283. package/dist/cli/build/artifact.js +0 -220
  284. package/dist/cli/build/captures.js +0 -48
  285. package/dist/cli/build/fixtures.js +0 -92
  286. package/dist/cli/capture/capture-browser.js +0 -37
  287. package/dist/cli/capture/capture.js +0 -115
  288. package/dist/cli/check/render/inputs.js +0 -60
  289. package/dist/cli/check/render/nav.js +0 -31
  290. package/dist/cli/dev/crop.js +0 -20
  291. package/dist/cli/dev/fixture-ladders.js +0 -96
  292. package/dist/cli/dev/hmr.js +0 -26
  293. package/dist/cli/dev/islands.js +0 -234
  294. package/dist/cli/dev/load-template.js +0 -52
  295. package/dist/cli/dev/vite.js +0 -114
  296. package/dist/cli/dev/workspace-reader.js +0 -249
  297. package/dist/cli/publish/freshness.js +0 -64
  298. package/dist/fixtures/brand.d.ts +0 -4
  299. package/dist/fixtures/brand.js +0 -8
  300. package/dist/fixtures/load.js +0 -159
  301. package/dist/fixtures/resolve.js +0 -392
  302. package/dist/fixtures.d.ts +0 -429
  303. package/dist/fixtures.js +0 -23
  304. package/dist/packages/internal/canvas-core/dist/island-host.js +0 -62
  305. package/dist/packages/internal/canvas-core/dist/island-shields.js +0 -30
  306. package/dist/playground/canvas-island-host.d.ts +0 -11
  307. package/dist/playground/canvas-island-host.js +0 -29
  308. package/dist/playground/canvas-markers.js +0 -14
  309. package/dist/playground/host/paths.js +0 -8
  310. package/dist/playground/layout.js +0 -17
  311. package/dist/playground/wire.js +0 -28
@@ -0,0 +1,429 @@
1
+ import { sectionSlotAt } from "../../../template-contracts/dist/ref-locate.js";
2
+ import { HostRefusal } from "./env.js";
3
+ import { ContentDocOpsRefusal, applyContentDocOps } from "../../../content-doc-ops/dist/index.js";
4
+ import { applyEverywhere } from "./everywhere-saves.js";
5
+ import { adoptedMemberOf, stagedCommits, withoutUnnamedFiles } from "./owned-saves.js";
6
+ import { landedRowImages } from "./row-images.js";
7
+ import { editorValueToDocument, statedOnly } from "./stated-content.js";
8
+ import { unnamedPropertyFiles } from "./media-saves.js";
9
+
10
+ //#region ../../internal/playground/dist/host/save.js
11
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
12
+ const SAVED = {
13
+ set_slot: true,
14
+ relink_slot: true,
15
+ toggle_section: true,
16
+ set_variant: true,
17
+ toggle_page: true,
18
+ set_value: true,
19
+ add_row: true,
20
+ remove_row: true,
21
+ pick: true,
22
+ unpick: true,
23
+ order: true,
24
+ set_list: true,
25
+ clear_media: true,
26
+ commit_media: true,
27
+ adopt_media: true
28
+ };
29
+ const BATCHES = {
30
+ content: {
31
+ ops: /* @__PURE__ */ new Set([
32
+ "set_slot",
33
+ "relink_slot",
34
+ "toggle_section",
35
+ "set_variant",
36
+ "toggle_page"
37
+ ]),
38
+ max: 200
39
+ },
40
+ everywhere: {
41
+ ops: /* @__PURE__ */ new Set([
42
+ "add_row",
43
+ "remove_row",
44
+ "pick",
45
+ "unpick",
46
+ "order",
47
+ "set_value",
48
+ "set_list",
49
+ "commit_media",
50
+ "clear_media",
51
+ "adopt_media",
52
+ "set_slot",
53
+ "relink_slot"
54
+ ]),
55
+ max: 500
56
+ }
57
+ };
58
+ function parseSaveRequest(text) {
59
+ let body;
60
+ try {
61
+ body = JSON.parse(text);
62
+ } catch (err) {
63
+ throw new HostRefusal(400, `request body is not JSON: ${err instanceof Error ? err.message : String(err)}`);
64
+ }
65
+ if (!isRecord(body)) throw new HostRefusal(400, "A save is a JSON object.");
66
+ const { batch, fixture, property } = body;
67
+ if (batch !== "content" && batch !== "everywhere") throw new HostRefusal(400, "A save's batch is \"content\" or \"everywhere\".");
68
+ if (batch === "content" && typeof fixture !== "string") throw new HostRefusal(400, "A content save names its content fixture.");
69
+ if (batch === "everywhere" && typeof property !== "string") throw new HostRefusal(400, "An Update everywhere save names its property.");
70
+ if (fixture !== void 0 && typeof fixture !== "string") throw new HostRefusal(400, "A save's fixture is a name.");
71
+ const { ops: admitted, max } = BATCHES[batch];
72
+ if (!Array.isArray(body.ops) || body.ops.length === 0 || body.ops.length > max) throw new HostRefusal(400, `A ${batch} batch carries 1 to ${String(max)} ops.`);
73
+ const ops = body.ops.map((op, i) => parseOp(op, i, admitted, batch));
74
+ if (batch === "content") return {
75
+ batch,
76
+ fixture,
77
+ ops
78
+ };
79
+ return {
80
+ batch,
81
+ property,
82
+ ...typeof fixture === "string" ? { fixture } : {},
83
+ ops
84
+ };
85
+ }
86
+ function parseOp(op, index, admitted, batch) {
87
+ const at = `Op ${String(index + 1)}`;
88
+ if (!isRecord(op) || typeof op.op !== "string" || !admitted.has(op.op)) throw new HostRefusal(400, `${at} is no op a ${batch} batch carries.`);
89
+ const name = op.op;
90
+ const saved = SAVED[name];
91
+ if (saved !== true) throw new HostRefusal(422, `${at} is a "${name}", which the playground does not save: ${saved}.`);
92
+ const instance = () => {
93
+ if (typeof op.section_instance_id !== "string") throw new HostRefusal(400, `${at} names a section instance.`);
94
+ return op.section_instance_id;
95
+ };
96
+ const home = () => {
97
+ if (op.home !== "property" && op.home !== "library") throw new HostRefusal(400, `${at}'s home is "property" or "library".`);
98
+ return op.home;
99
+ };
100
+ const path = () => {
101
+ if (typeof op.path !== "string" || op.path === "") throw new HostRefusal(400, `${at} names a fact path.`);
102
+ return op.path;
103
+ };
104
+ const slot = () => {
105
+ if (typeof op.slot_id !== "string") throw new HostRefusal(400, `${at} names a section instance and a slot.`);
106
+ return op.slot_id;
107
+ };
108
+ switch (name) {
109
+ case "set_slot": {
110
+ if (!("value" in op)) throw new HostRefusal(400, `${at} carries the slot's value.`);
111
+ const override = op.override === void 0 ? void 0 : overrideTarget(op.override, `${at}'s override`);
112
+ return {
113
+ op: name,
114
+ section_instance_id: instance(),
115
+ slot_id: slot(),
116
+ value: op.value,
117
+ ...override === void 0 ? {} : { override }
118
+ };
119
+ }
120
+ case "relink_slot": return {
121
+ op: name,
122
+ section_instance_id: instance(),
123
+ slot_id: slot(),
124
+ target: overrideTarget(op.target, `${at}'s target`)
125
+ };
126
+ case "toggle_section":
127
+ if (typeof op.enabled !== "boolean") throw new HostRefusal(400, `${at}'s enabled is a boolean.`);
128
+ return {
129
+ op: name,
130
+ section_instance_id: instance(),
131
+ enabled: op.enabled
132
+ };
133
+ case "set_variant":
134
+ if (typeof op.variant !== "string") throw new HostRefusal(400, `${at}'s variant is a string.`);
135
+ return {
136
+ op: name,
137
+ section_instance_id: instance(),
138
+ variant: op.variant
139
+ };
140
+ case "toggle_page":
141
+ if (typeof op.page_id !== "string" || typeof op.enabled !== "boolean") throw new HostRefusal(400, `${at} names a page and whether it is enabled.`);
142
+ return {
143
+ op: name,
144
+ page_id: op.page_id,
145
+ enabled: op.enabled
146
+ };
147
+ case "set_value":
148
+ if (!("value" in op)) throw new HostRefusal(400, `${at} carries its value.`);
149
+ return {
150
+ op: name,
151
+ home: home(),
152
+ path: path(),
153
+ value: op.value
154
+ };
155
+ case "add_row":
156
+ if (typeof op.temp_id !== "string" || op.temp_id === "" || op.temp_id.length > 200) throw new HostRefusal(400, `${at} carries its row's temp id.`);
157
+ return {
158
+ op: name,
159
+ home: home(),
160
+ path: path(),
161
+ temp_id: op.temp_id,
162
+ ...op.value === void 0 ? {} : { value: op.value }
163
+ };
164
+ case "remove_row":
165
+ case "clear_media": return {
166
+ op: name,
167
+ home: home(),
168
+ path: path()
169
+ };
170
+ case "commit_media":
171
+ if (typeof op.media_id !== "string" || op.media_id === "") throw new HostRefusal(400, `${at} names the staged media it commits.`);
172
+ return {
173
+ op: name,
174
+ home: home(),
175
+ path: path(),
176
+ media_id: op.media_id
177
+ };
178
+ case "adopt_media":
179
+ if (typeof op.instance_id !== "string" || typeof op.slot !== "string") throw new HostRefusal(400, `${at} names a section instance and a slot.`);
180
+ if (typeof op.media_id !== "string" || op.media_id === "" || typeof op.row_id !== "string" || op.row_id === "") throw new HostRefusal(400, `${at} names the slot's media and the row it adopts it onto.`);
181
+ return {
182
+ op: name,
183
+ instance_id: op.instance_id,
184
+ slot: op.slot,
185
+ media_id: op.media_id,
186
+ row_id: op.row_id
187
+ };
188
+ case "pick":
189
+ case "unpick":
190
+ if (typeof op.id !== "string" || op.id === "") throw new HostRefusal(400, `${at} names what it picks.`);
191
+ return {
192
+ op: name,
193
+ path: path(),
194
+ id: op.id
195
+ };
196
+ case "order":
197
+ if (!Array.isArray(op.ids) || !op.ids.every((id) => typeof id === "string" && id !== "")) throw new HostRefusal(400, `${at}'s ids are the list's item ids.`);
198
+ return {
199
+ op: name,
200
+ home: home(),
201
+ path: path(),
202
+ ids: op.ids
203
+ };
204
+ case "set_list": return {
205
+ op: name,
206
+ home: home(),
207
+ path: path(),
208
+ list: nestedList(op.list, `${at}'s list`)
209
+ };
210
+ }
211
+ }
212
+ function nestedList(list, what) {
213
+ if (isRecord(list) && list.kind === "picks" && Array.isArray(list.media_ids) && list.media_ids.every((id) => typeof id === "string")) return {
214
+ kind: "picks",
215
+ media_ids: list.media_ids
216
+ };
217
+ if (isRecord(list) && list.kind === "items" && Array.isArray(list.items)) return {
218
+ kind: "items",
219
+ items: list.items.map((item) => {
220
+ if (!isRecord(item) || !(item.id === null || typeof item.id === "string") || !isRecord(item.fields)) throw new HostRefusal(400, `${what}'s items are each an id (or null) and fields.`);
221
+ return {
222
+ id: item.id,
223
+ fields: item.fields
224
+ };
225
+ })
226
+ };
227
+ throw new HostRefusal(400, `${what} is picks or items.`);
228
+ }
229
+ function overrideTarget(target, what) {
230
+ if (!isRecord(target)) throw new HostRefusal(400, `${what} is no override target.`);
231
+ switch (target.kind) {
232
+ case "scalar":
233
+ case "order": return { kind: target.kind };
234
+ case "item":
235
+ if (typeof target.item_id !== "string" || typeof target.field !== "string") throw new HostRefusal(400, `${what} names an item and its field.`);
236
+ return {
237
+ kind: "item",
238
+ item_id: target.item_id,
239
+ field: target.field
240
+ };
241
+ case "item_removed":
242
+ if (typeof target.item_id !== "string") throw new HostRefusal(400, `${what} names the removed item.`);
243
+ return {
244
+ kind: "item_removed",
245
+ item_id: target.item_id
246
+ };
247
+ default: throw new HostRefusal(400, `${what} is no override target.`);
248
+ }
249
+ }
250
+ function slotDefAt(template, instance, slotId) {
251
+ const declared = template.instances.find((i) => i.instanceId === instance);
252
+ if (declared === void 0) throw new HostRefusal(422, `The composition places no instance "${instance}".`);
253
+ const def = sectionSlotAt(declared.sectionSchema.slots, slotId);
254
+ if (def === void 0) throw new HostRefusal(422, `Section "${declared.section}" declares no slot "${slotId}".`);
255
+ return def;
256
+ }
257
+ function documentText(doc) {
258
+ return `${JSON.stringify(doc, null, 2)}\n`;
259
+ }
260
+ async function readDocument(store, path) {
261
+ const text = await store.readText(path);
262
+ if (text === null) throw new HostRefusal(409, `"${path}" is gone; reload the playground.`);
263
+ let doc;
264
+ try {
265
+ doc = JSON.parse(text);
266
+ } catch (err) {
267
+ throw new HostRefusal(409, `"${path}" does not parse as JSON (${err instanceof Error ? err.message : String(err)}); fix the file, then edit again.`);
268
+ }
269
+ if (!isRecord(doc)) throw new HostRefusal(409, `"${path}" is not a JSON object; fix the file, then edit again.`);
270
+ return { doc };
271
+ }
272
+ const CONTENT_OPS = /* @__PURE__ */ new Set([
273
+ ...BATCHES.content.ops,
274
+ "set_slot",
275
+ "relink_slot"
276
+ ]);
277
+ const isFactOp = (op) => !CONTENT_OPS.has(op.op);
278
+ async function saveDocuments(input) {
279
+ const { template, property, store, ops } = input;
280
+ const contentFixture = (why) => {
281
+ if (input.fixture === void 0) throw new HostRefusal(400, `This save ${why}, so it names the content fixture it saves into.`);
282
+ return input.fixture;
283
+ };
284
+ const writes = [];
285
+ let content = [...ops];
286
+ let rowIds = /* @__PURE__ */ new Map();
287
+ let contentDoc = null;
288
+ if (ops.some(isFactOp)) {
289
+ content = [];
290
+ const { doc } = await readDocument(store, property.property);
291
+ const everywhere = ops;
292
+ if (ops.some((op) => op.op === "adopt_media")) contentFixture("adopts a file a slot owns");
293
+ const commits = input.fixture !== void 0 && ops.some((op) => op.op === "commit_media" || op.op === "adopt_media") ? await stagedCommits(input.fixture, store, doc, everywhere) : null;
294
+ const landed = ops.some((op) => op.op === "commit_media") ? await landedRowImages(store, property.property, doc, everywhere) : /* @__PURE__ */ new Map();
295
+ const result = applyEverywhere(property, doc, ops, (op) => content.push(op), {
296
+ staged: new Map([...landed, ...commits?.staged ?? []]),
297
+ adoptedMember: (instance, slot) => adoptedMemberOf(template, {
298
+ instance,
299
+ slot
300
+ })
301
+ });
302
+ rowIds = result.rowIds;
303
+ const next = documentText(result.property);
304
+ if (next !== documentText(doc)) writes.push({
305
+ path: property.property,
306
+ text: next
307
+ });
308
+ const fromFixture = commits === null ? /* @__PURE__ */ new Set() : new Set([...result.committed].filter((id) => commits.staged.has(id)));
309
+ if (commits !== null && fromFixture.size > 0) {
310
+ const settled = commits.settle(fromFixture);
311
+ writes.push(...settled.moves);
312
+ contentDoc = {
313
+ before: commits.doc,
314
+ after: settled.doc
315
+ };
316
+ }
317
+ writes.push(...unnamedPropertyFiles(property.property, doc, result.property));
318
+ }
319
+ const applied = content.map((op) => {
320
+ if (op.op === "set_slot") return {
321
+ ...op,
322
+ value: editorValueToDocument(slotDefAt(template, op.section_instance_id, op.slot_id), op.value)
323
+ };
324
+ if (op.op === "relink_slot") slotDefAt(template, op.section_instance_id, op.slot_id);
325
+ return op;
326
+ });
327
+ if (applied.length > 0 || contentDoc !== null) {
328
+ const fixture = contentFixture("relinks or sets a slot");
329
+ const before = contentDoc?.before ?? (await readDocument(store, fixture.file)).doc;
330
+ const doc = contentDoc?.after ?? before;
331
+ const { doc: kept, removed } = applied.length === 0 ? {
332
+ doc,
333
+ removed: []
334
+ } : withoutUnnamedFiles(fixture.file, before, appliedContent(template, doc, applied));
335
+ const next = documentText(kept);
336
+ if (next !== documentText(before)) writes.unshift({
337
+ path: fixture.file,
338
+ text: next
339
+ }, ...removed);
340
+ }
341
+ return {
342
+ writes,
343
+ rowIds
344
+ };
345
+ }
346
+ function appliedContent(template, doc, ops) {
347
+ const stated = isRecord(doc["content"]) ? doc["content"] : {};
348
+ const instances = template.instances.map(({ instanceId }) => {
349
+ const own = isRecord(stated[instanceId]) ? stated[instanceId] : {};
350
+ const enabled = typeof own["enabled"] === "boolean" ? own["enabled"] : void 0;
351
+ const variant = typeof own["variant"] === "string" ? own["variant"] : void 0;
352
+ return {
353
+ instance_id: instanceId,
354
+ enabled: enabled ?? true,
355
+ slots: isRecord(own["slots"]) ? own["slots"] : {},
356
+ ...isRecord(own["slot_overrides"]) ? { slot_overrides: own["slot_overrides"] } : {},
357
+ ...variant === void 0 ? {} : { variant },
358
+ ...enabled === void 0 && variant === void 0 ? {} : { display_overrides: {
359
+ ...enabled === void 0 ? {} : { visibility: true },
360
+ ...variant === void 0 ? {} : { variant: true }
361
+ } }
362
+ };
363
+ });
364
+ const pageState = Array.isArray(doc["page_state"]) ? doc["page_state"] : void 0;
365
+ let applied;
366
+ try {
367
+ applied = applyContentDocOps({
368
+ instances,
369
+ ...pageState === void 0 ? {} : { page_state: pageState }
370
+ }, ops, {
371
+ composition: compositionOf(template),
372
+ declaredVariants: new Map(template.instances.flatMap((i) => i.display.variant === null ? [] : [[i.instanceId, i.display.variant]])),
373
+ listsOfObjects: new Map(template.instances.map((i) => [i.instanceId, listsOfObjectsOf(i.sectionSchema.slots)]))
374
+ });
375
+ } catch (err) {
376
+ if (err instanceof ContentDocOpsRefusal) throw new HostRefusal(422, err.message);
377
+ throw err;
378
+ }
379
+ const touched = new Set(ops.flatMap((op) => "section_instance_id" in op ? [op.section_instance_id] : []));
380
+ const content = {};
381
+ for (const instance of applied.instances) {
382
+ if (!touched.has(instance.instance_id)) {
383
+ if (stated[instance.instance_id] !== void 0) content[instance.instance_id] = stated[instance.instance_id];
384
+ continue;
385
+ }
386
+ const { slots, slot_overrides: marks } = statedOnly(template.instances.find((i) => i.instanceId === instance.instance_id).sectionSchema.slots, instance.slots, instance.slot_overrides);
387
+ const own = {
388
+ ...Object.keys(slots).length === 0 ? {} : { slots },
389
+ ...marks === void 0 ? {} : { slot_overrides: marks },
390
+ ...instance.display_overrides?.visibility === true ? { enabled: instance.enabled } : {},
391
+ ...instance.display_overrides?.variant === true && instance.variant !== void 0 ? { variant: instance.variant } : {}
392
+ };
393
+ if (Object.keys(own).length > 0) content[instance.instance_id] = inOrderOf(stated[instance.instance_id], own);
394
+ }
395
+ const next = { ...doc };
396
+ if (Object.keys(content).length === 0) delete next["content"];
397
+ else next["content"] = inOrderOf(stated, content);
398
+ if (applied.page_state !== void 0 && applied.page_state.length > 0) next["page_state"] = applied.page_state;
399
+ return next;
400
+ }
401
+ function compositionOf(template) {
402
+ const required = new Map(template.instances.map((i) => [i.instanceId, i.display.required]));
403
+ return { pages: template.pages.map((page) => ({
404
+ id: page.id,
405
+ optional: page.optional === true,
406
+ sections: page.sections.map((s) => ({
407
+ instance_id: s.instanceId,
408
+ required: required.get(s.instanceId) === true
409
+ }))
410
+ })) };
411
+ }
412
+ function listsOfObjectsOf(slots) {
413
+ const lists = /* @__PURE__ */ new Set();
414
+ for (const [id, def] of Object.entries(slots)) {
415
+ const { type, element } = def;
416
+ if (type === "list" && (element?.type === "object" || element?.type === "row")) lists.add(id);
417
+ }
418
+ return lists;
419
+ }
420
+ function inOrderOf(before, next) {
421
+ if (!isRecord(before)) return next;
422
+ const out = {};
423
+ for (const key of Object.keys(before)) if (key in next) out[key] = next[key];
424
+ for (const [key, value] of Object.entries(next)) if (!(key in out)) out[key] = value;
425
+ return out;
426
+ }
427
+
428
+ //#endregion
429
+ export { documentText, parseSaveRequest, readDocument, saveDocuments };