@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,364 @@
1
+ import { dataFixtureId, propertyName, resolveReference } from "./fixture-documents.js";
2
+ import { contentFixtureUnit, propertyUnit, readFixtureListing, unitOfPath, unitsOf } from "./fixture-units.js";
3
+ import { HostRefusal } from "./env.js";
4
+ import { documentText } from "./save.js";
5
+
6
+ //#region ../../internal/playground/dist/host/fixture-operations.js
7
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
8
+ const NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
9
+ const FILE_MEMBERS = [
10
+ "file",
11
+ "poster",
12
+ "preview"
13
+ ];
14
+ const NEW_PROPERTY_DOCUMENT = "property.json";
15
+ const EMPTY_PROPERTY = {
16
+ listing_intent: null,
17
+ description: null
18
+ };
19
+ function folderReads(view) {
20
+ return {
21
+ list: async (folder) => (await view.list(folder)).map((entry) => entry.path),
22
+ readBytes: async (path) => (await view.readBytes(path))?.bytes ?? null
23
+ };
24
+ }
25
+ function parseFixtureOperation(text) {
26
+ let body;
27
+ try {
28
+ body = JSON.parse(text);
29
+ } catch (err) {
30
+ throw new HostRefusal(400, `request body is not JSON: ${err instanceof Error ? err.message : String(err)}`);
31
+ }
32
+ if (!isRecord(body)) throw new HostRefusal(400, "A fixture operation is a JSON object.");
33
+ const { op, kind, name } = body;
34
+ if (op !== "new" && op !== "rename" && op !== "duplicate" && op !== "delete") throw new HostRefusal(400, "A fixture operation's op is \"new\", \"rename\", \"duplicate\" or \"delete\".");
35
+ if (kind !== "property" && kind !== "content") throw new HostRefusal(400, "A fixture operation's kind is \"property\" or \"content\".");
36
+ if (typeof name !== "string") throw new HostRefusal(400, "A fixture operation names the fixture.");
37
+ if (op === "new") {
38
+ if (kind === "property") return {
39
+ op,
40
+ kind,
41
+ name
42
+ };
43
+ if (typeof body.property !== "string") throw new HostRefusal(400, "A new content fixture names the property it is on.");
44
+ return {
45
+ op,
46
+ kind,
47
+ name,
48
+ property: body.property
49
+ };
50
+ }
51
+ if (op === "delete") return {
52
+ op,
53
+ kind,
54
+ name
55
+ };
56
+ if (typeof body.to !== "string") throw new HostRefusal(400, `A ${op} names the new name, as "to".`);
57
+ return {
58
+ op,
59
+ kind,
60
+ name,
61
+ to: body.to
62
+ };
63
+ }
64
+ const folderOf = (path) => path.slice(0, path.lastIndexOf("/") + 1);
65
+ const listed = (folder) => folder.replace(/\/$/, "");
66
+ async function fixtureOperation(list, reads, operation) {
67
+ if (list === null) throw new HostRefusal(409, "This template names no fixture list, so it has no fixtures to change; name one in template.ts.");
68
+ const fixtures = await read(list, reads);
69
+ const { op, kind, name } = operation;
70
+ if (operation.op === "new") {
71
+ admitName(fixtures, kind, name);
72
+ return operation.kind === "property" ? newProperty(fixtures, name) : newContent(fixtures, name, operation.property);
73
+ }
74
+ if (op === "delete") return kind === "property" ? deleteProperty(fixtures, name) : deleteContent(fixtures, name);
75
+ const to = operation.to;
76
+ admitName(fixtures, kind, to);
77
+ if (op === "rename") return kind === "property" ? renameProperty(fixtures, name, to) : renameContent(fixtures, name, to);
78
+ return kind === "property" ? duplicateProperty(fixtures, name, to) : duplicateContent(fixtures, name, to);
79
+ }
80
+ async function read(list, reads) {
81
+ const text = await reads.readText(list);
82
+ if (text === null) throw new HostRefusal(409, `The fixture list "${list}" is gone; reload the playground.`);
83
+ let doc;
84
+ try {
85
+ doc = JSON.parse(text);
86
+ } catch (err) {
87
+ throw new HostRefusal(409, `The fixture list "${list}" does not parse as JSON (${err instanceof Error ? err.message : String(err)}); fix it, then try again.`);
88
+ }
89
+ if (!isRecord(doc) || !Array.isArray(doc["properties"]) || !Array.isArray(doc["fixtures"])) throw new HostRefusal(409, `The fixture list "${list}" does not list properties and fixtures; fix it, then try again.`);
90
+ const listing = await readFixtureListing((path) => reads.readText(path), list);
91
+ return {
92
+ reads,
93
+ list: {
94
+ path: list,
95
+ doc,
96
+ properties: doc["properties"],
97
+ fixtures: doc["fixtures"]
98
+ },
99
+ listing,
100
+ units: unitsOf(listing)
101
+ };
102
+ }
103
+ const KIND_WORDS = {
104
+ property: "property",
105
+ content: "content fixture"
106
+ };
107
+ function admitName({ listing }, kind, name) {
108
+ if (!NAME.test(name)) throw new HostRefusal(400, `"${name}" is not a name: a ${KIND_WORDS[kind]}'s name is lowercase letters, digits and dashes, as "lake-house" is.`);
109
+ if (kind === "property") {
110
+ if (listing.properties.some((p) => propertyName(p) === name)) throw new HostRefusal(409, `There is already a property "${name}".`);
111
+ return;
112
+ }
113
+ const holder = listing.fixtures.find((f) => dataFixtureId(f) === name);
114
+ if (holder === void 0) return;
115
+ const on = listing.named.get(holder);
116
+ throw new HostRefusal(409, `There is already a content fixture "${name}"${on === void 0 ? "" : `, on the property "${propertyName(on)}"`}.`);
117
+ }
118
+ async function admitPlace({ reads }, paths, folders) {
119
+ for (const path of paths) if (await reads.readText(path) !== null) throw new HostRefusal(409, `"${path}" is already there; move it, or choose another name.`);
120
+ for (const folder of folders) {
121
+ const held = await reads.list(listed(folder));
122
+ if (held.length > 0) throw new HostRefusal(409, `"${folder}" already holds "${held[0]}"; move it, or choose another name.`);
123
+ }
124
+ }
125
+ function propertyNamed({ listing }, name) {
126
+ const property = listing.properties.find((p) => propertyName(p) === name);
127
+ if (property === void 0) throw new HostRefusal(404, `There is no property "${name}" (have: ${listing.properties.map(propertyName).join(", ") || "none"}).`);
128
+ return property;
129
+ }
130
+ function contentNamed({ listing }, name) {
131
+ const fixture = listing.fixtures.find((f) => dataFixtureId(f) === name);
132
+ if (fixture === void 0) throw new HostRefusal(404, `There is no content fixture "${name}" (have: ${listing.fixtures.map(dataFixtureId).join(", ") || "none"}).`);
133
+ return fixture;
134
+ }
135
+ const contentOn = ({ listing }, property) => listing.fixtures.filter((f) => listing.named.get(f) === property);
136
+ function propertyOfContent(fixtures, fixture) {
137
+ const property = fixtures.listing.named.get(fixture);
138
+ if (property === void 0) throw new HostRefusal(409, `The content fixture "${dataFixtureId(fixture)}" names no property that resolves; fix "${fixture}", then try again.`);
139
+ return propertyName(property);
140
+ }
141
+ async function filesOf({ reads, units }, unit) {
142
+ const under = (await reads.list(listed(unit.folder))).filter((path) => {
143
+ const owner = unitOfPath(path, units);
144
+ return owner !== null && owner.kind === unit.kind && owner.key === unit.key;
145
+ });
146
+ return unit.kind === "fixture" ? [unit.key, ...under] : under;
147
+ }
148
+ function entryFor(list, path) {
149
+ const folder = folderOf(list.path);
150
+ if (!path.startsWith(folder)) throw new HostRefusal(409, `"${path}" is outside the fixture list's folder, so the list cannot name it.`);
151
+ return path.slice(folder.length);
152
+ }
153
+ function replaced(list, entries, path, entry) {
154
+ return entries.flatMap((stated) => {
155
+ const ref = resolveReference(list.path, stated);
156
+ if (!("path" in ref) || ref.path !== path) return [stated];
157
+ return entry === null ? [] : [entry];
158
+ });
159
+ }
160
+ function listWrite(list, members) {
161
+ return {
162
+ path: list.path,
163
+ text: documentText({
164
+ ...list.doc,
165
+ properties: members.properties ?? list.properties,
166
+ fixtures: members.fixtures ?? list.fixtures
167
+ })
168
+ };
169
+ }
170
+ async function documentAt({ reads }, path) {
171
+ const text = await reads.readText(path);
172
+ if (text === null) throw new HostRefusal(409, `"${path}" is gone; reload the playground.`);
173
+ let doc;
174
+ try {
175
+ doc = JSON.parse(text);
176
+ } catch (err) {
177
+ throw new HostRefusal(409, `"${path}" does not parse as JSON (${err instanceof Error ? err.message : String(err)}); fix the file, then try again.`);
178
+ }
179
+ if (!isRecord(doc)) throw new HostRefusal(409, `"${path}" is not a JSON object; fix the file, then try again.`);
180
+ return doc;
181
+ }
182
+ function withOwnFolder(doc, file, from, to) {
183
+ if (!Array.isArray(doc["files"])) return doc;
184
+ const base = folderOf(file);
185
+ const files = doc["files"].map((entry) => {
186
+ if (!isRecord(entry)) return entry;
187
+ const next = { ...entry };
188
+ for (const member of FILE_MEMBERS) {
189
+ const ref = resolveReference(file, entry[member]);
190
+ if ("path" in ref && ref.path.startsWith(from)) next[member] = `${to}${ref.path.slice(from.length)}`.slice(base.length);
191
+ }
192
+ return next;
193
+ });
194
+ return {
195
+ ...doc,
196
+ files
197
+ };
198
+ }
199
+ function propertyReference(fixture, property) {
200
+ const folder = folderOf(fixture);
201
+ if (!property.startsWith(folder)) throw new HostRefusal(409, `"${property}" is not inside the folder of "${fixture}", so the content fixture cannot name it.`);
202
+ return property.slice(folder.length);
203
+ }
204
+ const moves = (files, from, to) => files.map((path) => ({
205
+ path: `${to}${path.slice(from.length)}`,
206
+ from: path
207
+ }));
208
+ async function copies({ reads }, files, from, to) {
209
+ const writes = [];
210
+ for (const path of files) {
211
+ const bytes = await reads.readBytes(path);
212
+ if (bytes === null) throw new HostRefusal(409, `"${path}" is gone; reload the playground.`);
213
+ writes.push({
214
+ path: `${to}${path.slice(from.length)}`,
215
+ bytes
216
+ });
217
+ }
218
+ return writes;
219
+ }
220
+ const removals = (files) => files.map((path) => ({
221
+ path,
222
+ remove: true
223
+ }));
224
+ async function newProperty(fixtures, name) {
225
+ const folder = `${folderOf(fixtures.list.path)}properties/${name}/`;
226
+ const file = `${folder}${NEW_PROPERTY_DOCUMENT}`;
227
+ await admitPlace(fixtures, [], [folder]);
228
+ return {
229
+ writes: [{
230
+ path: file,
231
+ text: documentText(EMPTY_PROPERTY)
232
+ }, listWrite(fixtures.list, { properties: [...fixtures.list.properties, entryFor(fixtures.list, file)] })],
233
+ at: { property: name }
234
+ };
235
+ }
236
+ async function newContent(fixtures, name, on) {
237
+ const property = propertyNamed(fixtures, on);
238
+ const file = `${folderOf(fixtures.list.path)}${name}.json`;
239
+ const own = contentFixtureUnit(file).folder;
240
+ await admitPlace(fixtures, [file], [own]);
241
+ return {
242
+ writes: [{
243
+ path: file,
244
+ text: documentText({ property: propertyReference(file, property) })
245
+ }, listWrite(fixtures.list, { fixtures: [...fixtures.list.fixtures, entryFor(fixtures.list, file)] })],
246
+ at: {
247
+ property: on,
248
+ content: name
249
+ }
250
+ };
251
+ }
252
+ async function renameContent(fixtures, name, to) {
253
+ const file = contentNamed(fixtures, name);
254
+ const unit = contentFixtureUnit(file);
255
+ const next = `${folderOf(file)}${to}.json`;
256
+ const nextFolder = contentFixtureUnit(next).folder;
257
+ await admitPlace(fixtures, [next], [nextFolder]);
258
+ const doc = withOwnFolder(await documentAt(fixtures, file), file, unit.folder, nextFolder);
259
+ const own = (await filesOf(fixtures, unit)).filter((path) => path !== file);
260
+ return {
261
+ writes: [
262
+ {
263
+ path: next,
264
+ text: documentText(doc)
265
+ },
266
+ ...moves(own, unit.folder, nextFolder),
267
+ {
268
+ path: file,
269
+ remove: true
270
+ },
271
+ listWrite(fixtures.list, { fixtures: replaced(fixtures.list, fixtures.list.fixtures, file, entryFor(fixtures.list, next)) })
272
+ ],
273
+ at: {
274
+ property: propertyOfContent(fixtures, file),
275
+ content: to
276
+ }
277
+ };
278
+ }
279
+ async function renameProperty(fixtures, name, to) {
280
+ const file = propertyNamed(fixtures, name);
281
+ const unit = propertyUnit(file);
282
+ const nextFolder = `${folderOf(listed(unit.folder))}${to}/`;
283
+ const next = `${nextFolder}${file.slice(unit.folder.length)}`;
284
+ await admitPlace(fixtures, [], [nextFolder]);
285
+ const renamed = [];
286
+ for (const fixture of contentOn(fixtures, file)) {
287
+ const doc = await documentAt(fixtures, fixture);
288
+ renamed.push({
289
+ path: fixture,
290
+ text: documentText({
291
+ ...doc,
292
+ property: propertyReference(fixture, next)
293
+ })
294
+ });
295
+ }
296
+ return {
297
+ writes: [
298
+ ...moves(await filesOf(fixtures, unit), unit.folder, nextFolder),
299
+ ...renamed,
300
+ listWrite(fixtures.list, { properties: replaced(fixtures.list, fixtures.list.properties, file, entryFor(fixtures.list, next)) })
301
+ ],
302
+ at: { property: to }
303
+ };
304
+ }
305
+ async function duplicateContent(fixtures, name, to) {
306
+ const file = contentNamed(fixtures, name);
307
+ const unit = contentFixtureUnit(file);
308
+ const next = `${folderOf(file)}${to}.json`;
309
+ const nextFolder = contentFixtureUnit(next).folder;
310
+ await admitPlace(fixtures, [next], [nextFolder]);
311
+ const doc = withOwnFolder(await documentAt(fixtures, file), file, unit.folder, nextFolder);
312
+ const own = (await filesOf(fixtures, unit)).filter((path) => path !== file);
313
+ return {
314
+ writes: [
315
+ {
316
+ path: next,
317
+ text: documentText(doc)
318
+ },
319
+ ...await copies(fixtures, own, unit.folder, nextFolder),
320
+ listWrite(fixtures.list, { fixtures: [...fixtures.list.fixtures, entryFor(fixtures.list, next)] })
321
+ ],
322
+ at: {
323
+ property: propertyOfContent(fixtures, file),
324
+ content: to
325
+ }
326
+ };
327
+ }
328
+ async function duplicateProperty(fixtures, name, to) {
329
+ const file = propertyNamed(fixtures, name);
330
+ const unit = propertyUnit(file);
331
+ const nextFolder = `${folderOf(listed(unit.folder))}${to}/`;
332
+ const next = `${nextFolder}${file.slice(unit.folder.length)}`;
333
+ await admitPlace(fixtures, [], [nextFolder]);
334
+ return {
335
+ writes: [...await copies(fixtures, await filesOf(fixtures, unit), unit.folder, nextFolder), listWrite(fixtures.list, { properties: [...fixtures.list.properties, entryFor(fixtures.list, next)] })],
336
+ at: { property: to }
337
+ };
338
+ }
339
+ async function deleteContent(fixtures, name) {
340
+ const file = contentNamed(fixtures, name);
341
+ const property = fixtures.listing.named.get(file);
342
+ return {
343
+ writes: [...removals(await filesOf(fixtures, contentFixtureUnit(file))), listWrite(fixtures.list, { fixtures: replaced(fixtures.list, fixtures.list.fixtures, file, null) })],
344
+ at: property === void 0 ? null : { property: propertyName(property) }
345
+ };
346
+ }
347
+ async function deleteProperty(fixtures, name) {
348
+ const file = propertyNamed(fixtures, name);
349
+ const on = contentOn(fixtures, file);
350
+ const removed = await filesOf(fixtures, propertyUnit(file));
351
+ for (const fixture of on) removed.push(...await filesOf(fixtures, contentFixtureUnit(fixture)));
352
+ let entries = fixtures.list.fixtures;
353
+ for (const fixture of on) entries = replaced(fixtures.list, entries, fixture, null);
354
+ return {
355
+ writes: [...removals(removed), listWrite(fixtures.list, {
356
+ properties: replaced(fixtures.list, fixtures.list.properties, file, null),
357
+ fixtures: entries
358
+ })],
359
+ at: null
360
+ };
361
+ }
362
+
363
+ //#endregion
364
+ export { fixtureOperation, folderReads, parseFixtureOperation };
@@ -0,0 +1,93 @@
1
+ import { dataFixtureId, resolveReference } from "./fixture-documents.js";
2
+
3
+ //#region ../../internal/playground/dist/host/fixture-units.js
4
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
5
+ function folderOf(path) {
6
+ return path.slice(0, path.lastIndexOf("/") + 1);
7
+ }
8
+ async function readJson(read, path) {
9
+ const text = await read(path);
10
+ if (text === null) return null;
11
+ try {
12
+ const parsed = JSON.parse(text);
13
+ return isRecord(parsed) ? parsed : null;
14
+ } catch {
15
+ return null;
16
+ }
17
+ }
18
+ function resolvedEntries(list, member) {
19
+ const paths = [];
20
+ for (const entry of Array.isArray(member) ? member : []) {
21
+ const ref = resolveReference(list, entry);
22
+ if ("path" in ref && !paths.includes(ref.path)) paths.push(ref.path);
23
+ }
24
+ return paths;
25
+ }
26
+ async function readFixtureListing(read, list) {
27
+ const doc = await readJson(read, list);
28
+ const properties = resolvedEntries(list, doc?.["properties"]);
29
+ const fixtures = resolvedEntries(list, doc?.["fixtures"]);
30
+ const named = /* @__PURE__ */ new Map();
31
+ for (const fixture of fixtures) {
32
+ const property = await propertyOf(read, fixture);
33
+ if (property !== null) named.set(fixture, property);
34
+ }
35
+ return {
36
+ list,
37
+ properties,
38
+ fixtures,
39
+ named
40
+ };
41
+ }
42
+ async function propertyOf(read, fixture) {
43
+ const doc = await readJson(read, fixture);
44
+ if (doc === null) return null;
45
+ const ref = resolveReference(fixture, doc["property"]);
46
+ return "path" in ref ? ref.path : null;
47
+ }
48
+ function contentFixtureUnit(fixture) {
49
+ return {
50
+ kind: "fixture",
51
+ key: fixture,
52
+ folder: `${folderOf(fixture)}${dataFixtureId(fixture)}/`
53
+ };
54
+ }
55
+ function propertyUnit(property) {
56
+ const folder = folderOf(property);
57
+ return {
58
+ kind: "property",
59
+ key: folder,
60
+ folder
61
+ };
62
+ }
63
+ function unitsOf(listing) {
64
+ const units = /* @__PURE__ */ new Map();
65
+ for (const fixture of listing.fixtures) units.set(fixture, contentFixtureUnit(fixture));
66
+ for (const property of [...listing.properties, ...listing.named.values()]) {
67
+ const unit = propertyUnit(property);
68
+ if (!units.has(unit.key)) units.set(unit.key, unit);
69
+ }
70
+ return [...units.values()];
71
+ }
72
+ function unitOfPath(path, units) {
73
+ let best = null;
74
+ let bestDepth = -1;
75
+ for (const unit of units) {
76
+ if (unit.kind === "fixture" && unit.key === path) return unit;
77
+ const folder = unit.folder;
78
+ if (!path.startsWith(folder)) continue;
79
+ const depth = folder.length;
80
+ if (depth > bestDepth || depth === bestDepth && unit.kind === "property") {
81
+ best = unit;
82
+ bestDepth = depth;
83
+ }
84
+ }
85
+ return best;
86
+ }
87
+ function listEntryFor(list, path) {
88
+ const folder = folderOf(list);
89
+ return path.startsWith(folder) ? path.slice(folder.length) : null;
90
+ }
91
+
92
+ //#endregion
93
+ export { contentFixtureUnit, listEntryFor, propertyOf, propertyUnit, readFixtureListing, unitOfPath, unitsOf };
@@ -1,4 +1,4 @@
1
- //#region src/fixtures/image-dimensions.ts
1
+ //#region ../../internal/playground/dist/host/image-dimensions.js
2
2
  function png(bytes) {
3
3
  if (bytes.length < 24) return null;
4
4
  const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
@@ -0,0 +1,41 @@
1
+ import { isLeadIngestRefusal, leadIngestBody, leadIngestHeaders, leadIngestSize, leadTimestampFresh } from "../../../lead-fields/dist/ingest.js";
2
+
3
+ //#region ../../internal/playground/dist/host/leads.js
4
+ const PLAYGROUND_SITE = {
5
+ siteId: "00000000-0000-4000-8000-00000000c0de",
6
+ siteSecret: "706c617967726f756e642d6c6561642d666f726d2d6e6f7468696e672d6b657074"
7
+ };
8
+ function json(status, body) {
9
+ return new Response(JSON.stringify(body), {
10
+ status,
11
+ headers: { "content-type": "application/json; charset=utf-8" }
12
+ });
13
+ }
14
+ function hexBytes(hex) {
15
+ const out = new Uint8Array(/* @__PURE__ */ new ArrayBuffer(hex.length / 2));
16
+ for (let i = 0; i < out.length; i++) out[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
17
+ return out;
18
+ }
19
+ async function signatureOf(message) {
20
+ const key = await crypto.subtle.importKey("raw", hexBytes(PLAYGROUND_SITE.siteSecret), {
21
+ name: "HMAC",
22
+ hash: "SHA-256"
23
+ }, false, ["sign"]);
24
+ return [...new Uint8Array(await crypto.subtle.sign("HMAC", key, new TextEncoder().encode(message)))].map((byte) => byte.toString(16).padStart(2, "0")).join("");
25
+ }
26
+ async function answerLead(request, nowSeconds = Math.floor(Date.now() / 1e3)) {
27
+ if (request.method !== "POST") return json(405, { error: "method_not_allowed" });
28
+ const headers = leadIngestHeaders((name) => request.headers.get(name));
29
+ if (isLeadIngestRefusal(headers)) return json(headers.status, { error: headers.error });
30
+ const rawBody = await request.text();
31
+ const tooLarge = leadIngestSize(rawBody);
32
+ if (tooLarge !== null) return json(tooLarge.status, { error: tooLarge.error });
33
+ if (headers.siteId !== PLAYGROUND_SITE.siteId || !leadTimestampFresh(headers.timestamp, nowSeconds)) return json(401, { error: "unauthorized" });
34
+ if (headers.signature.toLowerCase() !== await signatureOf(`${headers.timestamp}.${rawBody}`)) return json(401, { error: "unauthorized" });
35
+ const body = leadIngestBody(rawBody);
36
+ if (isLeadIngestRefusal(body)) return json(body.status, { error: body.error });
37
+ return json(200, { ok: true });
38
+ }
39
+
40
+ //#endregion
41
+ export { PLAYGROUND_SITE, answerLead };