@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.
- package/CHANGELOG.md +184 -0
- package/README.md +8 -10
- package/codemods/fixtures-are-data.mjs +7 -0
- package/codemods/fixtures-list-properties.mjs +6 -0
- package/codemods/manifest.json +11 -0
- package/codemods/steps/fixtures-list-properties.mjs +16 -0
- package/codemods/steps/fixtures-to-data.mjs +41 -0
- package/dist/artifact/playground/client/assets/archivo-latin-ext-wght-normal-C4zznr8T.woff2 +0 -0
- package/dist/artifact/playground/client/assets/archivo-latin-wght-normal-E0tuGl4L.woff2 +0 -0
- package/dist/artifact/playground/client/assets/archivo-vietnamese-wght-normal-XAtsl5Q_.woff2 +0 -0
- package/dist/artifact/playground/client/assets/index-Bmvcss4B.js +1338 -0
- package/dist/artifact/playground/client/assets/index-C01UCAWD.css +1 -0
- package/dist/artifact/playground/client/index.html +2 -2
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -1
- package/dist/artifact/playground/host.mjs +110 -59
- package/dist/base.css +2 -2
- package/dist/cli/build/icons.js +1 -1
- package/dist/cli/build/index.js +11 -10
- package/dist/cli/build/manifest.js +44 -0
- package/dist/cli/build/record.js +123 -0
- package/dist/cli/build/sections.js +28 -18
- package/dist/cli/build/source.js +1 -1
- package/dist/cli/build/static.js +8 -5
- package/dist/cli/build/template-build.js +614 -0
- package/dist/cli/check/analyze.js +18 -1
- package/dist/cli/check/load-workspace.js +2 -2
- package/dist/cli/check/portable-names.js +1 -1
- package/dist/cli/check/render/corpus.js +119 -0
- package/dist/cli/check/render/invariants.js +1 -0
- package/dist/cli/check/stages/bundles.js +15 -18
- package/dist/cli/check/stages/composition.js +8 -25
- package/dist/cli/check/stages/fixtures.js +14 -10
- package/dist/cli/check/stages/logic.js +7 -23
- package/dist/cli/check/stages/render.js +12 -14
- package/dist/cli/check/stages/sections.js +22 -66
- package/dist/cli/check/stages/stylesheet.js +4 -26
- package/dist/cli/check/stages/workspace.js +27 -22
- package/dist/cli/commands.js +51 -23
- package/dist/cli/currency/preamble.js +1 -1
- package/dist/cli/currency/resolve-latest.js +3 -2
- package/dist/cli/dev/capture-browser.js +26 -0
- package/dist/cli/dev/fixture-schema.js +441 -0
- package/dist/cli/dev/folder-files.js +244 -0
- package/dist/cli/dev/index.js +7 -3
- package/dist/cli/dev/playground-server.js +34 -0
- package/dist/cli/dev/section-ladders.js +76 -0
- package/dist/cli/dev/server.js +120 -304
- package/dist/cli/install/background.js +16 -0
- package/dist/cli/install/index.js +45 -0
- package/dist/cli/install/tools.js +27 -0
- package/dist/cli/media/derive.js +19 -13
- package/dist/cli/media/deriver-plugin.js +14 -3
- package/dist/cli/property/fixture-list.js +46 -0
- package/dist/cli/property/index.js +12 -9
- package/dist/cli/property/library.js +12 -10
- package/dist/cli/publish/artifact.js +90 -0
- package/dist/cli/publish/captures.js +61 -0
- package/dist/cli/publish/fixtures.js +17 -0
- package/dist/cli/publish/index.js +10 -18
- package/dist/cli/{build → publish}/playground.js +3 -3
- package/dist/cli/publish/report.js +15 -33
- package/dist/cli/upgrade/codemod.d.ts +14 -0
- package/dist/cli/upgrade/fixture-conversion.d.ts +11 -0
- package/dist/cli/upgrade/fixture-conversion.js +54 -0
- package/dist/cli/upgrade/fixture-modules.js +125 -0
- package/dist/cli/upgrade/fixtures-to-data.d.ts +40 -0
- package/dist/cli/upgrade/fixtures-to-data.js +498 -0
- package/dist/cli/upgrade/index.js +18 -2
- package/dist/cli/upgrade/legacy-fixtures.d.ts +34 -0
- package/dist/cli/upgrade/legacy-fixtures.js +22 -0
- package/dist/cli/upgrade/stage.js +1 -1
- package/dist/cli/workspace-fixtures.js +80 -0
- package/dist/cli.js +1 -0
- package/dist/css/compile.js +9 -3
- package/dist/fixtures/bundle-rule.js +16 -16
- package/dist/fixtures/media-plugin.js +12 -33
- package/dist/fixtures/synthesize-empties.js +3 -2
- package/dist/index.d.ts +7 -7
- package/dist/{playground-island-runtime.d.ts → island-runtime.d.ts} +1 -2
- package/dist/{playground-island-runtime.js → island-runtime.js} +1 -2
- package/dist/islands/client-module.js +1 -1
- package/dist/{cli/dev → islands}/tsconfig-paths.js +2 -14
- package/dist/islands/wrap.js +40 -0
- package/dist/node_modules/.pnpm/acorn@8.18.0/node_modules/acorn/dist/acorn.js +5119 -0
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/bundle-evaluation/dist/cache.js +36 -0
- package/dist/packages/internal/bundle-evaluation/dist/evaluate.js +174 -0
- package/dist/packages/internal/bundle-evaluation/dist/index.js +5 -0
- package/dist/packages/internal/bundle-evaluation/dist/section-code.js +10 -0
- package/dist/packages/internal/capture-settle/dist/index.js +2 -2
- package/dist/packages/internal/capture-settle/dist/settle.js +88 -13
- package/dist/packages/internal/code-fingerprint/dist/index.js +57 -0
- package/dist/packages/internal/content-doc-ops/dist/index.js +176 -0
- package/dist/packages/internal/content-doc-ops/dist/made-rows.js +15 -0
- package/dist/packages/internal/deliverable-reads/dist/bootstrap.js +81 -0
- package/dist/packages/internal/deliverable-reads/dist/display.js +21 -0
- package/dist/packages/internal/deliverable-reads/dist/format.js +15 -0
- package/dist/packages/internal/deliverable-reads/dist/index.js +7 -0
- package/dist/packages/internal/deliverable-reads/dist/pages.js +29 -0
- package/dist/packages/internal/deliverable-reads/dist/requirements.js +72 -0
- package/dist/{cli/capture → packages/internal/download-files/dist}/bundle.js +8 -4
- package/dist/packages/internal/download-files/dist/capture-origin.js +126 -0
- package/dist/packages/internal/download-files/dist/capture-routes.js +139 -0
- package/dist/packages/internal/download-files/dist/capture-shell.js +38 -0
- package/dist/packages/internal/download-files/dist/capture.js +74 -0
- package/dist/packages/internal/download-files/dist/egress-watch.js +38 -0
- package/dist/packages/internal/download-files/dist/files.js +7 -0
- package/dist/packages/internal/download-files/dist/finish.js +35 -0
- package/dist/packages/internal/download-files/dist/fleet.js +94 -0
- package/dist/packages/internal/download-files/dist/format.js +40 -0
- package/dist/packages/internal/download-files/dist/make.js +105 -0
- package/dist/packages/internal/download-files/dist/master-tally.js +32 -0
- package/dist/packages/internal/download-files/dist/names.js +24 -0
- package/dist/packages/internal/download-files/dist/pdf-boxes.js +33 -0
- package/dist/packages/internal/download-files/dist/pdf-image-placements.js +194 -0
- package/dist/packages/internal/download-files/dist/pdf-images.js +289 -0
- package/dist/packages/internal/file-store/dist/files.js +8 -0
- package/dist/packages/internal/file-store/dist/lru.js +40 -0
- package/dist/packages/internal/file-store/dist/refusal.js +12 -0
- package/dist/packages/internal/file-store/dist/trees.js +151 -0
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +1 -1
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +47 -21
- package/dist/packages/internal/fill-bake/dist/index.js +5 -1
- package/dist/packages/internal/fill-bake/dist/item-merge.js +4 -3
- package/dist/packages/internal/fill-bake/dist/resolve-instance.js +9 -0
- package/dist/packages/internal/fill-bake/dist/resolve.js +3 -0
- package/dist/packages/internal/fill-bake/dist/round-trip.js +2 -0
- package/dist/packages/internal/fill-bake/dist/strip.js +6 -0
- package/dist/packages/internal/fill-vocabulary/dist/holder.js +1 -1
- package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +1 -1
- package/dist/packages/internal/fill-vocabulary/dist/verbs.js +1 -1
- package/dist/packages/internal/island-runtime/dist/index.js +1 -10
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.d.ts +5 -0
- package/dist/packages/internal/lead-fields/dist/ingest.js +72 -0
- package/dist/packages/internal/media-resolution/dist/video.js +6 -2
- package/dist/packages/internal/page-render/dist/addresses.js +57 -0
- package/dist/packages/internal/page-render/dist/index.js +6 -0
- package/dist/packages/internal/page-render/dist/kept.js +30 -0
- package/dist/packages/internal/page-render/dist/nav.js +42 -0
- package/dist/packages/internal/page-render/dist/render.js +152 -0
- package/dist/packages/internal/page-shell/dist/assemble.js +161 -0
- package/dist/packages/internal/page-shell/dist/escape.js +10 -0
- package/dist/packages/internal/page-shell/dist/frame.js +23 -0
- package/dist/packages/internal/page-shell/dist/index.js +26 -0
- package/dist/packages/internal/playground/dist/build-fingerprint.js +18 -0
- package/dist/packages/internal/playground/dist/fixture-conversions/list-names-properties.js +76 -0
- package/dist/packages/internal/playground/dist/fixture-formats.d.ts +37 -0
- package/dist/packages/internal/playground/dist/fixture-formats.js +20 -0
- package/dist/packages/internal/playground/dist/host/bootstrap.js +108 -0
- package/dist/packages/internal/playground/dist/host/built.js +202 -0
- package/dist/packages/internal/playground/dist/host/catalog-fixture.js +53 -0
- package/dist/packages/internal/playground/dist/host/download.js +34 -0
- package/dist/packages/internal/playground/dist/host/env.js +11 -0
- package/dist/packages/internal/playground/dist/host/everywhere-saves.js +353 -0
- package/dist/packages/internal/playground/dist/host/fixture-addresses.js +52 -0
- package/dist/packages/internal/playground/dist/host/fixture-documents.js +494 -0
- package/dist/packages/internal/playground/dist/host/fixture-operations.js +364 -0
- package/dist/packages/internal/playground/dist/host/fixture-units.js +93 -0
- package/dist/{fixtures → packages/internal/playground/dist/host}/image-dimensions.js +1 -1
- package/dist/packages/internal/playground/dist/host/leads.js +41 -0
- package/dist/packages/internal/playground/dist/host/media-saves.js +309 -0
- package/dist/{fixtures → packages/internal/playground/dist/host}/media-store.js +79 -26
- package/dist/packages/internal/playground/dist/host/overridable.js +9 -0
- package/dist/packages/internal/playground/dist/host/owned-saves.js +203 -0
- package/dist/{playground → packages/internal/playground/dist}/host/page-state.js +1 -1
- package/dist/packages/internal/playground/dist/host/program.js +54 -0
- package/dist/packages/internal/playground/dist/host/property-derive.js +216 -0
- package/dist/packages/internal/playground/dist/host/property-saves.js +74 -0
- package/dist/{fixtures → packages/internal/playground/dist/host}/property.js +88 -229
- package/dist/packages/internal/playground/dist/host/provenance.js +49 -0
- package/dist/packages/internal/playground/dist/host/resolve.js +553 -0
- package/dist/packages/internal/playground/dist/host/row-images.js +41 -0
- package/dist/{fixtures → packages/internal/playground/dist/host}/rows.js +1 -1
- package/dist/packages/internal/playground/dist/host/save.js +429 -0
- package/dist/packages/internal/playground/dist/host/serve.js +952 -0
- package/dist/packages/internal/playground/dist/host/site.js +79 -0
- package/dist/packages/internal/playground/dist/host/slots.js +202 -0
- package/dist/packages/internal/playground/dist/host/stated-content.js +93 -0
- package/dist/packages/internal/playground/dist/host/stored-fixtures.js +135 -0
- package/dist/packages/internal/playground/dist/host/violations.js +7 -0
- package/dist/packages/internal/playground/dist/jobs/lanes.js +24 -0
- package/dist/packages/internal/playground/dist/jobs/memory-queue.js +112 -0
- package/dist/packages/internal/playground/dist/jobs/probe.js +37 -0
- package/dist/packages/internal/playground/dist/jobs/queue.js +28 -0
- package/dist/packages/internal/playground/dist/jobs/runner.js +207 -0
- package/dist/packages/internal/playground/dist/layout.js +14 -0
- package/dist/packages/internal/playground/dist/platform.js +33 -0
- package/dist/packages/internal/playground/dist/server/changes.js +57 -0
- package/dist/packages/internal/playground/dist/server/crop.js +47 -0
- package/dist/packages/internal/playground/dist/server/derived-files.js +88 -0
- package/dist/packages/internal/playground/dist/server/download.js +158 -0
- package/dist/{cli/dev → packages/internal/playground/dist/server}/http.js +4 -12
- package/dist/packages/internal/playground/dist/server/jobs.js +29 -0
- package/dist/{cli/dev → packages/internal/playground/dist/server}/listen.js +4 -11
- package/dist/packages/internal/playground/dist/server/playground-server.js +424 -0
- package/dist/{cli/dev → packages/internal/playground/dist/server}/request-error.js +1 -1
- package/dist/packages/internal/playground/dist/server/size-ladders.js +170 -0
- package/dist/packages/internal/playground/dist/server/verification.js +75 -0
- package/dist/packages/internal/playground/dist/server/verify-build.js +139 -0
- package/dist/packages/internal/playground/dist/wire.js +78 -0
- package/dist/packages/internal/property-facts/dist/registry-facts.js +1 -1
- package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +1 -1
- package/dist/packages/internal/section-contracts/dist/reads-acyclic-contract.js +1 -1
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +1 -1
- package/dist/packages/internal/site-files/dist/head.js +59 -0
- package/dist/packages/internal/site-files/dist/index.js +4 -0
- package/dist/packages/internal/site-files/dist/site.js +211 -0
- package/dist/packages/internal/static-assets-binding/dist/index.js +32 -0
- package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +38 -5
- package/dist/packages/internal/template-artifact/dist/asset-mime.js +8 -1
- package/dist/packages/internal/template-artifact/dist/build.js +148 -0
- package/dist/packages/internal/template-artifact/dist/composition.js +62 -0
- package/dist/packages/internal/template-artifact/dist/index.js +2 -2
- package/dist/packages/internal/template-artifact/dist/layout.js +48 -12
- package/dist/packages/internal/template-artifact/dist/manifest.js +3 -10
- package/dist/packages/internal/template-artifact/dist/verify.js +51 -31
- package/dist/packages/internal/template-contracts/dist/address-value.js +6 -1
- package/dist/packages/internal/template-contracts/dist/content-categories.js +10 -1
- package/dist/packages/internal/template-contracts/dist/fact-compute.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +3 -3
- package/dist/packages/internal/template-contracts/dist/fact-registry.js +59 -32
- package/dist/packages/internal/template-contracts/dist/fill-spec.js +14 -1
- package/dist/packages/internal/template-contracts/dist/list.d.ts +3 -3
- package/dist/packages/internal/template-contracts/dist/media-candidates.js +67 -2
- package/dist/packages/internal/template-contracts/dist/media-offer.js +180 -0
- package/dist/packages/internal/template-contracts/dist/object.d.ts +2 -2
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +9 -2
- package/dist/packages/internal/template-contracts/dist/read-graph.js +36 -2
- package/dist/packages/internal/template-contracts/dist/ref-locate.js +16 -1
- package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +9 -10
- package/dist/packages/internal/template-contracts/dist/registry-facts.js +12 -1
- package/dist/packages/internal/template-contracts/dist/registry-graph.js +112 -0
- package/dist/packages/internal/template-contracts/dist/registry-shape.js +15 -2
- package/dist/packages/internal/template-contracts/dist/require-graph.js +300 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +3 -3
- package/dist/packages/internal/template-contracts/dist/row.d.ts +3 -3
- package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +1 -1
- package/dist/{schema → packages/internal/template-contracts/dist}/section-nav.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +4 -4
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +3 -1
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +24 -1
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +26 -1
- package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/slot-types.js +1 -1
- package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/table-members.js +7 -2
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +1 -1
- package/dist/packages/internal/upload-formats/dist/heic.js +35 -0
- package/dist/packages/internal/upload-formats/dist/index.js +80 -0
- package/dist/packages/internal/upload-formats/dist/magic-bytes.js +293 -0
- package/dist/platform/paths.js +1 -0
- package/dist/platform/process.js +49 -1
- package/dist/rules/registry.js +27 -3
- package/dist/schema/fact.d.ts +2 -2
- package/dist/schema/facts-view.d.ts +1 -1
- package/dist/schema/section-props.d.ts +1 -1
- package/dist/schema/section-schema.d.ts +1 -1
- package/dist/schema/section-schema.js +1 -0
- package/dist/section/declare.d.ts +1 -1
- package/dist/section/discovery.js +6 -2
- package/dist/section/publish-shape.js +38 -0
- package/dist/section/section.d.ts +1 -1
- package/dist/template/define-template.d.ts +14 -4
- package/dist/template/define-template.js +2 -0
- package/dist/template/logic-shim.d.ts +1 -1
- package/dist/template/materialize.js +1 -1
- package/dist/template/running-copy.js +0 -1
- package/dist/template/section-reads.js +1 -1
- package/guide/reference/cli/INDEX.md +6 -5
- package/guide/reference/cli/build.md +10 -8
- package/guide/reference/cli/check.md +4 -2
- package/guide/reference/cli/dev.md +6 -2
- package/guide/reference/cli/install.md +41 -0
- package/guide/reference/cli/property-add.md +5 -4
- package/guide/reference/cli/property-list.md +2 -2
- package/guide/reference/cli/publish.md +5 -5
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +8 -4
- package/package.json +14 -30
- package/dist/artifact/playground/client/assets/index-BcLGpWLR.js +0 -1266
- package/dist/artifact/playground/client/assets/index-CxWPYOH2.css +0 -1
- package/dist/cli/build/artifact.js +0 -220
- package/dist/cli/build/captures.js +0 -48
- package/dist/cli/build/fixtures.js +0 -92
- package/dist/cli/capture/capture-browser.js +0 -37
- package/dist/cli/capture/capture.js +0 -115
- package/dist/cli/check/render/inputs.js +0 -60
- package/dist/cli/check/render/nav.js +0 -31
- package/dist/cli/dev/crop.js +0 -20
- package/dist/cli/dev/fixture-ladders.js +0 -96
- package/dist/cli/dev/hmr.js +0 -26
- package/dist/cli/dev/islands.js +0 -234
- package/dist/cli/dev/load-template.js +0 -52
- package/dist/cli/dev/vite.js +0 -114
- package/dist/cli/dev/workspace-reader.js +0 -249
- package/dist/cli/publish/freshness.js +0 -64
- package/dist/fixtures/brand.d.ts +0 -4
- package/dist/fixtures/brand.js +0 -8
- package/dist/fixtures/load.js +0 -159
- package/dist/fixtures/resolve.js +0 -392
- package/dist/fixtures.d.ts +0 -429
- package/dist/fixtures.js +0 -23
- package/dist/packages/internal/canvas-core/dist/island-host.js +0 -62
- package/dist/packages/internal/canvas-core/dist/island-shields.js +0 -30
- package/dist/playground/canvas-island-host.d.ts +0 -11
- package/dist/playground/canvas-island-host.js +0 -29
- package/dist/playground/canvas-markers.js +0 -14
- package/dist/playground/host/paths.js +0 -8
- package/dist/playground/layout.js +0 -17
- 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 };
|