@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.
- package/CHANGELOG.md +203 -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 +17 -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 -60
- package/dist/base.css +19 -59
- 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 +48 -22
- package/dist/packages/internal/fill-bake/dist/held-rows.js +2 -0
- package/dist/packages/internal/fill-bake/dist/index.js +6 -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/format-geometry/dist/capture.js +3 -11
- package/dist/packages/internal/format-geometry/dist/format.d.ts +2 -8
- package/dist/packages/internal/format-geometry/dist/geometry.js +2 -13
- 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/primitives/FrameShell.d.ts +5 -2
- package/dist/primitives/FrameShell.js +2 -1
- package/dist/rules/registry.js +28 -4
- package/dist/schema/fact.d.ts +2 -2
- package/dist/schema/facts-view.d.ts +1 -1
- package/dist/schema/format.d.ts +0 -1
- package/dist/schema/format.js +1 -2
- package/dist/schema/manifest.js +18 -24
- 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/site-analytics.js +6 -1
- package/dist/site-runtime/window-height.js +19 -0
- package/dist/template/define-template.d.ts +25 -4
- package/dist/template/define-template.js +3 -0
- package/dist/template/logic-shim.d.ts +1 -1
- package/dist/template/materialize.js +3 -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 +9 -5
- package/package.json +14 -30
- package/dist/artifact/playground/client/assets/index-ByeGGedv.js +0 -1259
- 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 -113
- 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 -248
- 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,161 @@
|
|
|
1
|
+
import { FRAME_ROOT_CLASS } from "../../format-geometry/dist/capture.js";
|
|
2
|
+
import { CAPTURE_IN_VIEW_SCRIPT } from "../../capture-settle/dist/settle.js";
|
|
3
|
+
import "../../capture-settle/dist/index.js";
|
|
4
|
+
import { escapeAttr, jsonForScript } from "./escape.js";
|
|
5
|
+
import { frameRootAttrsFromTokens, frameRootHtml } from "./frame.js";
|
|
6
|
+
|
|
7
|
+
//#region ../../internal/page-shell/dist/assemble.js
|
|
8
|
+
function assembleDocument(input) {
|
|
9
|
+
switch (input.destination) {
|
|
10
|
+
case "published": return publishedDocument(input);
|
|
11
|
+
case "capture": return captureDocument(input);
|
|
12
|
+
case "canvas": return canvasDocument(input);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function captureInViewTag(loader) {
|
|
16
|
+
if (loader.kind === "none" || Object.keys(loader.islandMap).length === 0) return [];
|
|
17
|
+
return [`<script>${CAPTURE_IN_VIEW_SCRIPT}<\/script>`];
|
|
18
|
+
}
|
|
19
|
+
const MARGIN_RESET = "html, body { margin: 0; padding: 0; }";
|
|
20
|
+
function iconTag(icon) {
|
|
21
|
+
const attrs = [`rel="${icon.rel}"`, `href="${escapeAttr(icon.href)}"`];
|
|
22
|
+
if (icon.sizes !== void 0) attrs.push(`sizes="${escapeAttr(icon.sizes)}"`);
|
|
23
|
+
if (icon.type !== void 0) attrs.push(`type="${escapeAttr(icon.type)}"`);
|
|
24
|
+
return `<link ${attrs.join(" ")} />`;
|
|
25
|
+
}
|
|
26
|
+
function publishedDocument(input) {
|
|
27
|
+
const { meta } = input;
|
|
28
|
+
const head = [
|
|
29
|
+
`<meta charset="utf-8" />`,
|
|
30
|
+
`<meta name="viewport" content="width=device-width, initial-scale=1" />`,
|
|
31
|
+
`<title>${escapeAttr(meta.title)}</title>`,
|
|
32
|
+
`<meta name="description" content="${escapeAttr(meta.description)}" />`
|
|
33
|
+
];
|
|
34
|
+
if (meta.canonical) head.push(`<link rel="canonical" href="${escapeAttr(meta.canonical)}" />`);
|
|
35
|
+
for (const icon of meta.icons ?? []) head.push(iconTag(icon));
|
|
36
|
+
head.push(`<meta property="og:type" content="website" />`);
|
|
37
|
+
if (meta.siteName) head.push(`<meta property="og:site_name" content="${escapeAttr(meta.siteName)}" />`);
|
|
38
|
+
head.push(`<meta property="og:title" content="${escapeAttr(meta.title)}" />`);
|
|
39
|
+
head.push(`<meta property="og:description" content="${escapeAttr(meta.description)}" />`);
|
|
40
|
+
if (meta.ogUrl) head.push(`<meta property="og:url" content="${escapeAttr(meta.ogUrl)}" />`);
|
|
41
|
+
if (meta.ogImage) {
|
|
42
|
+
head.push(`<meta property="og:image" content="${escapeAttr(meta.ogImage)}" />`);
|
|
43
|
+
if (meta.ogImageWidth) head.push(`<meta property="og:image:width" content="${meta.ogImageWidth}" />`);
|
|
44
|
+
if (meta.ogImageHeight) head.push(`<meta property="og:image:height" content="${meta.ogImageHeight}" />`);
|
|
45
|
+
if (meta.ogImageType) head.push(`<meta property="og:image:type" content="${escapeAttr(meta.ogImageType)}" />`);
|
|
46
|
+
if (meta.ogImageAlt) head.push(`<meta property="og:image:alt" content="${escapeAttr(meta.ogImageAlt)}" />`);
|
|
47
|
+
head.push(`<meta name="twitter:card" content="summary_large_image" />`);
|
|
48
|
+
head.push(`<meta name="twitter:title" content="${escapeAttr(meta.title)}" />`);
|
|
49
|
+
head.push(`<meta name="twitter:description" content="${escapeAttr(meta.description)}" />`);
|
|
50
|
+
head.push(`<meta name="twitter:image" content="${escapeAttr(meta.ogImage)}" />`);
|
|
51
|
+
}
|
|
52
|
+
head.push(...stylesheetTags(input.stylesheets));
|
|
53
|
+
head.push(...islandHeadTags(input.islands));
|
|
54
|
+
if (input.prefetchUrls && input.prefetchUrls.length > 0) head.push(`<script type="speculationrules">${jsonForScript({ prefetch: [{
|
|
55
|
+
source: "list",
|
|
56
|
+
urls: [...input.prefetchUrls]
|
|
57
|
+
}] })}<\/script>`);
|
|
58
|
+
const siteConfigTag = input.siteConfig ? `\n <script type="application/json" id="concrete-site-config">${jsonForScript(input.siteConfig)}<\/script>` : "";
|
|
59
|
+
return htmlDocument({
|
|
60
|
+
lang: meta.lang ?? "en",
|
|
61
|
+
head,
|
|
62
|
+
body: ` <body class="concrete-root">\n${input.root.bodyHtml}${siteConfigTag}${islandBodyTags(input.islands, "viewport")}\n` + (input.analyticsJs === void 0 ? "" : ` <script type="module" src="${escapeAttr(input.analyticsJs.url)}"><\/script>\n`) + ` </body>`
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function captureDocument(input) {
|
|
66
|
+
const head = [`<meta charset="utf-8" />`];
|
|
67
|
+
if (input.title !== void 0) head.push(`<title>${escapeAttr(input.title)}</title>`);
|
|
68
|
+
head.push(...stylesheetTags(input.stylesheets));
|
|
69
|
+
const rules = [MARGIN_RESET, ...pageBreakRules(input.root)];
|
|
70
|
+
head.push(styleBlock(rules));
|
|
71
|
+
head.push(...captureInViewTag(input.islands));
|
|
72
|
+
head.push(...islandHeadTags(input.islands));
|
|
73
|
+
return htmlDocument({
|
|
74
|
+
lang: "en",
|
|
75
|
+
head,
|
|
76
|
+
body: ` <body>${rootHtml(input.root)}${islandBodyTags(input.islands, "eager")}</body>`
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function canvasDocument(input) {
|
|
80
|
+
const links = input.stylesheets.hrefs.map((href) => `<link rel="stylesheet" href="${escapeAttr(href)}">`).join("");
|
|
81
|
+
return `<!doctype html>
|
|
82
|
+
<html>
|
|
83
|
+
<head>
|
|
84
|
+
<meta charset="utf-8">
|
|
85
|
+
<base href="${escapeAttr(input.base)}">
|
|
86
|
+
<!-- Cascade-layer order is fixed by FIRST declaration, document-wide. The
|
|
87
|
+
kernel's document defaults must lose to everything a template declares,
|
|
88
|
+
so their layer is pre-declared here, before any template stylesheet,
|
|
89
|
+
pinning it below every layer those go on to declare. -->
|
|
90
|
+
<style>@layer ${input.defaultsLayer};</style>
|
|
91
|
+
${links}${editorHostHead(input.islands)}
|
|
92
|
+
<style>${input.frameCss}</style>
|
|
93
|
+
</head>
|
|
94
|
+
<body>
|
|
95
|
+
<div id="${escapeAttr(input.root.id)}"${canvasRootAttrs(input.root)}></div>
|
|
96
|
+
</body>
|
|
97
|
+
</html>`;
|
|
98
|
+
}
|
|
99
|
+
function canvasRootAttrs(root) {
|
|
100
|
+
if (!root.pageBox) return "";
|
|
101
|
+
const attrs = frameRootAttrsFromTokens(root.pageBox.formatId, root.pageBox.tokens, root.pageBox.direction);
|
|
102
|
+
return ` class="${escapeAttr(attrs.class)}" data-format="${escapeAttr(attrs.dataFormat)}"` + (attrs.dataDirection === void 0 ? "" : ` data-direction="${attrs.dataDirection}"`) + ` style="${escapeAttr(attrs.style)}"`;
|
|
103
|
+
}
|
|
104
|
+
function editorHostHead(loader) {
|
|
105
|
+
if (loader.kind === "none" || Object.keys(loader.islandMap).length === 0) return "";
|
|
106
|
+
const host = !loader.hostScriptSrc ? "" : `
|
|
107
|
+
<script id="tr-island-host" type="module" src="${escapeAttr(loader.hostScriptSrc)}"><\/script>`;
|
|
108
|
+
return `${Object.keys(loader.importMap).length === 0 ? "" : `
|
|
109
|
+
<script type="importmap">${jsonForScript({ imports: loader.importMap })}<\/script>`}
|
|
110
|
+
<script>window.__TR_ISLAND_MAP=${jsonForScript(loader.islandMap)};<\/script>
|
|
111
|
+
<!-- id is the contract the host's readiness gate keys off — it waits on THIS
|
|
112
|
+
element's load event, not a timeout, so a slow cold first load still
|
|
113
|
+
activates without a refresh. -->${host}`;
|
|
114
|
+
}
|
|
115
|
+
function htmlDocument(parts) {
|
|
116
|
+
const headHtml = parts.head.map((tag) => ` ${tag}`).join("\n");
|
|
117
|
+
return `<!doctype html>
|
|
118
|
+
<html lang="${escapeAttr(parts.lang)}">
|
|
119
|
+
<head>
|
|
120
|
+
${headHtml}
|
|
121
|
+
</head>
|
|
122
|
+
${parts.body}
|
|
123
|
+
</html>
|
|
124
|
+
`;
|
|
125
|
+
}
|
|
126
|
+
function rootHtml(root) {
|
|
127
|
+
if (root.kind === "frame") return frameRootHtml(root.format, root.sectionHtml, root.direction);
|
|
128
|
+
return root.pages.map((page) => frameRootHtml(root.format, page.sectionHtml, page.direction)).join("\n");
|
|
129
|
+
}
|
|
130
|
+
function pageBreakRules(root) {
|
|
131
|
+
if (root.kind !== "frameStack") return [];
|
|
132
|
+
return [`body > .${FRAME_ROOT_CLASS} { break-after: page; }`, `body > .${FRAME_ROOT_CLASS}:last-child { break-after: auto; }`];
|
|
133
|
+
}
|
|
134
|
+
function stylesheetTags(stylesheets) {
|
|
135
|
+
if (stylesheets.kind === "links") return stylesheets.hrefs.map((href) => `<link rel="stylesheet" href="${escapeAttr(href)}" />`);
|
|
136
|
+
return stylesheets.css.map((css) => `<style>${css}</style>`);
|
|
137
|
+
}
|
|
138
|
+
function styleBlock(rules) {
|
|
139
|
+
const [first, ...rest] = rules;
|
|
140
|
+
if (first === void 0) return `<style></style>`;
|
|
141
|
+
if (rest.length === 0) return `<style>${first}</style>`;
|
|
142
|
+
return `<style>${first}\n ${rest.join("\n ")}\n </style>`;
|
|
143
|
+
}
|
|
144
|
+
function islandHeadTags(loader) {
|
|
145
|
+
if (loader.kind !== "bundles" || Object.keys(loader.islandMap).length === 0) return [];
|
|
146
|
+
const tags = [`<script type="importmap">${jsonForScript({ imports: loader.reactVendorMap })}<\/script>`];
|
|
147
|
+
for (const url of [
|
|
148
|
+
loader.runtime.url,
|
|
149
|
+
...Object.values(loader.reactVendorMap),
|
|
150
|
+
loader.reactVendorCore.url
|
|
151
|
+
]) tags.push(`<link rel="modulepreload" href="${escapeAttr(url)}" />`);
|
|
152
|
+
return tags;
|
|
153
|
+
}
|
|
154
|
+
function islandBodyTags(loader, schedule) {
|
|
155
|
+
if (loader.kind === "none") return "";
|
|
156
|
+
if (Object.keys(loader.islandMap).length === 0) return "";
|
|
157
|
+
return `\n <script>window.__TR_ISLAND_MAP=${jsonForScript(loader.islandMap)};${schedule === "eager" ? ` window.__TR_ISLAND_SCHEDULE = "eager";` : ""}<\/script>\n <script type="module" src="${escapeAttr(loader.runtime.url)}"><\/script>`;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
//#endregion
|
|
161
|
+
export { assembleDocument };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region ../../internal/page-shell/dist/escape.js
|
|
2
|
+
function escapeAttr(value) {
|
|
3
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
4
|
+
}
|
|
5
|
+
function jsonForScript(value) {
|
|
6
|
+
return JSON.stringify(value).replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { escapeAttr, jsonForScript };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FRAME_ROOT_CLASS, frameTokens } from "../../format-geometry/dist/capture.js";
|
|
2
|
+
import { escapeAttr } from "./escape.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../internal/page-shell/dist/frame.js
|
|
5
|
+
function frameRootAttrs(format, direction = "column") {
|
|
6
|
+
return frameRootAttrsFromTokens(format.id, { ...frameTokens(format) }, direction);
|
|
7
|
+
}
|
|
8
|
+
function frameRootAttrsFromTokens(formatId, tokens, direction = "column") {
|
|
9
|
+
return {
|
|
10
|
+
class: FRAME_ROOT_CLASS,
|
|
11
|
+
dataFormat: formatId,
|
|
12
|
+
style: Object.entries(tokens).map(([name, value]) => `${name}:${value}`).join(";"),
|
|
13
|
+
...direction === "row" ? { dataDirection: "row" } : {}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function frameRootHtml(format, sectionHtml, direction = "column") {
|
|
17
|
+
const attrs = frameRootAttrs(format, direction);
|
|
18
|
+
const directionAttr = attrs.dataDirection === void 0 ? "" : `data-direction="${attrs.dataDirection}" `;
|
|
19
|
+
return `<div class="${escapeAttr(attrs.class)}" data-format="${escapeAttr(attrs.dataFormat)}" ${directionAttr}style="${escapeAttr(attrs.style)}">${sectionHtml.join("")}</div>`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { frameRootAttrs, frameRootAttrsFromTokens, frameRootHtml };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { escapeAttr, jsonForScript } from "./escape.js";
|
|
2
|
+
import { frameRootAttrs, frameRootAttrsFromTokens, frameRootHtml } from "./frame.js";
|
|
3
|
+
import { assembleDocument } from "./assemble.js";
|
|
4
|
+
|
|
5
|
+
//#region ../../internal/page-shell/dist/index.js
|
|
6
|
+
function renderPage(input) {
|
|
7
|
+
return assembleDocument({
|
|
8
|
+
destination: "published",
|
|
9
|
+
root: {
|
|
10
|
+
kind: "plain",
|
|
11
|
+
bodyHtml: input.bodyHtml
|
|
12
|
+
},
|
|
13
|
+
islands: input.islands,
|
|
14
|
+
stylesheets: {
|
|
15
|
+
kind: "links",
|
|
16
|
+
hrefs: [input.baseCss.url, input.templateCss.url]
|
|
17
|
+
},
|
|
18
|
+
meta: input.meta,
|
|
19
|
+
...input.analyticsJs ? { analyticsJs: input.analyticsJs } : {},
|
|
20
|
+
...input.siteConfig ? { siteConfig: input.siteConfig } : {},
|
|
21
|
+
...input.prefetchUrls ? { prefetchUrls: input.prefetchUrls } : {}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { assembleDocument, renderPage };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BUILD_DIR } from "../../template-artifact/dist/layout.js";
|
|
2
|
+
import { EMPTY_TREE, TreeReader, applyToTree } from "../../file-store/dist/trees.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../internal/playground/dist/build-fingerprint.js
|
|
5
|
+
const noTrees = new TreeReader(() => Promise.resolve(/* @__PURE__ */ new Map()));
|
|
6
|
+
async function buildFingerprint(view) {
|
|
7
|
+
const files = await view.list(BUILD_DIR);
|
|
8
|
+
if (files.length === 0) return null;
|
|
9
|
+
const changes = new Map(files.map((file) => [file.path.slice(BUILD_DIR.length + 1), {
|
|
10
|
+
fingerprint: file.fingerprint,
|
|
11
|
+
size: file.size
|
|
12
|
+
}]));
|
|
13
|
+
const { root } = await applyToTree(noTrees, EMPTY_TREE, changes);
|
|
14
|
+
return root;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { buildFingerprint };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { dataFixtureId, resolveReference } from "../host/fixture-documents.js";
|
|
2
|
+
import { listEntryFor } from "../host/fixture-units.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../internal/playground/dist/fixture-conversions/list-names-properties.js
|
|
5
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6
|
+
function labelIsName(label, id) {
|
|
7
|
+
return label.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") === id;
|
|
8
|
+
}
|
|
9
|
+
const encoder = new TextEncoder();
|
|
10
|
+
const decoder = new TextDecoder();
|
|
11
|
+
const write = (path, doc) => ({
|
|
12
|
+
path,
|
|
13
|
+
bytes: encoder.encode(`${JSON.stringify(doc, null, 2)}\n`)
|
|
14
|
+
});
|
|
15
|
+
async function readDocuments(files) {
|
|
16
|
+
const docs = /* @__PURE__ */ new Map();
|
|
17
|
+
for (const path of files.paths) {
|
|
18
|
+
if (!path.endsWith(".json")) continue;
|
|
19
|
+
const bytes = await files.read(path);
|
|
20
|
+
if (bytes === null) continue;
|
|
21
|
+
try {
|
|
22
|
+
const parsed = JSON.parse(decoder.decode(bytes));
|
|
23
|
+
if (isRecord(parsed)) docs.set(path, parsed);
|
|
24
|
+
} catch {}
|
|
25
|
+
}
|
|
26
|
+
return docs;
|
|
27
|
+
}
|
|
28
|
+
const isList = (doc) => Array.isArray(doc["fixtures"]) && doc["property"] === void 0;
|
|
29
|
+
const listNamesProperties = {
|
|
30
|
+
slug: "fixtures-list-properties",
|
|
31
|
+
async convert(files) {
|
|
32
|
+
const docs = await readDocuments(files);
|
|
33
|
+
const edits = [];
|
|
34
|
+
const notes = [];
|
|
35
|
+
const contentFixtures = /* @__PURE__ */ new Set();
|
|
36
|
+
for (const [list, doc] of docs) {
|
|
37
|
+
if (!isList(doc)) continue;
|
|
38
|
+
const named = [];
|
|
39
|
+
for (const entry of doc["fixtures"]) {
|
|
40
|
+
const ref = resolveReference(list, entry);
|
|
41
|
+
if (!("path" in ref)) continue;
|
|
42
|
+
contentFixtures.add(ref.path);
|
|
43
|
+
const fixture = docs.get(ref.path);
|
|
44
|
+
const property = fixture === void 0 ? null : resolveReference(ref.path, fixture["property"]);
|
|
45
|
+
if (property === null || !("path" in property)) continue;
|
|
46
|
+
const listed = listEntryFor(list, property.path);
|
|
47
|
+
if (listed !== null && !named.includes(listed)) named.push(listed);
|
|
48
|
+
}
|
|
49
|
+
if (doc["properties"] !== void 0) continue;
|
|
50
|
+
const converted = {};
|
|
51
|
+
for (const [key, value] of Object.entries(doc)) {
|
|
52
|
+
if (key === "fixtures") converted["properties"] = named;
|
|
53
|
+
converted[key] = value;
|
|
54
|
+
}
|
|
55
|
+
edits.push(write(list, converted));
|
|
56
|
+
}
|
|
57
|
+
for (const [path, doc] of docs) {
|
|
58
|
+
if (!contentFixtures.has(path) && !(typeof doc["property"] === "string" && doc["label"] !== void 0)) continue;
|
|
59
|
+
if (doc["label"] === void 0) continue;
|
|
60
|
+
const { label, ...rest } = doc;
|
|
61
|
+
edits.push(write(path, rest));
|
|
62
|
+
const id = dataFixtureId(path);
|
|
63
|
+
if (typeof label === "string" && !labelIsName(label, id)) notes.push({
|
|
64
|
+
path,
|
|
65
|
+
note: `its label "${label}" said more than its name, "${id}", which is its only name now; rename the file if the name should say it`
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
edits,
|
|
70
|
+
notes
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
export { labelIsName, listNamesProperties };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region ../../internal/playground/dist/fixture-formats.d.ts
|
|
2
|
+
/** The fixtures' files as a conversion reads them: every path under `fixtures/`, and a reader. */
|
|
3
|
+
interface FixtureFiles {
|
|
4
|
+
/** Every file under `fixtures/`, as the tree names it (`fixtures/index.json`), sorted. */
|
|
5
|
+
readonly paths: readonly string[];
|
|
6
|
+
/** A file's bytes; null when there is no file at the path. */
|
|
7
|
+
read(path: string): Promise<Uint8Array | null>;
|
|
8
|
+
}
|
|
9
|
+
/** One file a conversion writes, or removes, under `fixtures/`. */
|
|
10
|
+
type FixtureEdit = {
|
|
11
|
+
readonly path: string;
|
|
12
|
+
readonly bytes: Uint8Array;
|
|
13
|
+
} | {
|
|
14
|
+
readonly path: string;
|
|
15
|
+
readonly remove: true;
|
|
16
|
+
};
|
|
17
|
+
/** What a conversion left for the author in one file it read: the codemod reports it, the console has no one to tell. */
|
|
18
|
+
interface FixtureNote {
|
|
19
|
+
/** The file, under `fixtures/`. */
|
|
20
|
+
readonly path: string;
|
|
21
|
+
/** What the author may want to do, in a sentence. */
|
|
22
|
+
readonly note: string;
|
|
23
|
+
}
|
|
24
|
+
/** A conversion's answer: its edits, and its notes. */
|
|
25
|
+
interface FixtureConverted {
|
|
26
|
+
readonly edits: readonly FixtureEdit[];
|
|
27
|
+
readonly notes: readonly FixtureNote[];
|
|
28
|
+
}
|
|
29
|
+
/** One format change: the fixtures in the format before it, converted to the next. */
|
|
30
|
+
interface FixtureConversion {
|
|
31
|
+
/** Its name, as its codemod is named: lowercase letters, digits and dashes. */
|
|
32
|
+
readonly slug: string;
|
|
33
|
+
/** The edits that convert `files`, none when they are already in the next format, and what it left for the author. */
|
|
34
|
+
convert(files: FixtureFiles): Promise<FixtureConverted>;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { FixtureConversion, FixtureConverted, FixtureEdit, FixtureFiles, FixtureNote };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FIXTURES_DIR } from "../../template-artifact/dist/layout.js";
|
|
2
|
+
import { listNamesProperties } from "./fixture-conversions/list-names-properties.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../internal/playground/dist/fixture-formats.js
|
|
5
|
+
const FIXTURES_ROOT = `${FIXTURES_DIR}/`;
|
|
6
|
+
const FIXTURE_CONVERSIONS = [listNamesProperties];
|
|
7
|
+
async function runFixtureConversion(conversion, files) {
|
|
8
|
+
const converted = await conversion.convert(files);
|
|
9
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10
|
+
for (const edit of converted.edits) {
|
|
11
|
+
if (!edit.path.startsWith(FIXTURES_ROOT) || edit.path.split("/").some((s) => s === "" || s === "." || s === "..")) throw new Error(`${conversion.slug}: it writes "${edit.path}", which is not a file under ${FIXTURES_ROOT}`);
|
|
12
|
+
if (seen.has(edit.path)) throw new Error(`${conversion.slug}: it edits "${edit.path}" twice`);
|
|
13
|
+
seen.add(edit.path);
|
|
14
|
+
}
|
|
15
|
+
for (const note of converted.notes) if (!files.paths.includes(note.path)) throw new Error(`${conversion.slug}: it notes "${note.path}", which is not a file it read`);
|
|
16
|
+
return converted;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { FIXTURE_CONVERSIONS, runFixtureConversion };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { templateFormatOf } from "../../../deliverable-reads/dist/format.js";
|
|
2
|
+
import { deliverableSubjectOf, templateSubjectOf } from "../../../deliverable-reads/dist/requirements.js";
|
|
3
|
+
import "../../../deliverable-reads/dist/index.js";
|
|
4
|
+
import { sectionGraphOf, templateGraphOf } from "../../../template-contracts/dist/read-graph.js";
|
|
5
|
+
import { CONTENT_CATEGORY_LABELS } from "../../../template-contracts/dist/content-categories.js";
|
|
6
|
+
import { HostRefusal } from "./env.js";
|
|
7
|
+
|
|
8
|
+
//#region ../../internal/playground/dist/host/bootstrap.js
|
|
9
|
+
const WEBSITE_FORMAT = {
|
|
10
|
+
id: "website",
|
|
11
|
+
label: CONTENT_CATEGORY_LABELS.website,
|
|
12
|
+
category: "website"
|
|
13
|
+
};
|
|
14
|
+
function bootstrapComposition(template) {
|
|
15
|
+
const required = new Map(template.instances.map((i) => [i.instanceId, i.display.required]));
|
|
16
|
+
return {
|
|
17
|
+
output: template.output,
|
|
18
|
+
pages: template.pages.map((page) => ({
|
|
19
|
+
id: page.id,
|
|
20
|
+
label: page.label,
|
|
21
|
+
...page.path === void 0 ? {} : { path: page.path },
|
|
22
|
+
...page.direction === void 0 ? {} : { direction: page.direction },
|
|
23
|
+
...page.optional === void 0 ? {} : { optional: page.optional },
|
|
24
|
+
sections: page.sections.map((s) => ({
|
|
25
|
+
section: s.section,
|
|
26
|
+
instance_id: s.instanceId,
|
|
27
|
+
required: required.get(s.instanceId) === true
|
|
28
|
+
}))
|
|
29
|
+
})),
|
|
30
|
+
canvases: template.canvases
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function bootstrapFormat(template, formatId) {
|
|
34
|
+
if (template.output === "website") return templateFormatOf(WEBSITE_FORMAT);
|
|
35
|
+
const format = formatId === null ? template.formats[0] : template.formats.find((f) => f.id === formatId);
|
|
36
|
+
if (format === void 0) throw new HostRefusal(404, `The template declares no format "${formatId ?? ""}" (have: ${template.formats.map((f) => f.id).join(", ")}).`);
|
|
37
|
+
return templateFormatOf(format);
|
|
38
|
+
}
|
|
39
|
+
function fixtureContentDoc(fixture) {
|
|
40
|
+
const pageState = Object.entries(fixture.pages ?? {}).map(([pageId, state]) => ({
|
|
41
|
+
page_id: pageId,
|
|
42
|
+
enabled: state.enabled
|
|
43
|
+
}));
|
|
44
|
+
return {
|
|
45
|
+
instances: fixture.instances,
|
|
46
|
+
...pageState.length === 0 ? {} : { page_state: pageState }
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function fixtureDeliverable(template, fixture, format) {
|
|
50
|
+
return {
|
|
51
|
+
id: fixture.id,
|
|
52
|
+
property_id: fixture.id,
|
|
53
|
+
type: template.output,
|
|
54
|
+
state: "active",
|
|
55
|
+
format_id: format.id,
|
|
56
|
+
site_slug: null,
|
|
57
|
+
content_doc: { ...fixtureContentDoc(fixture) },
|
|
58
|
+
created_at: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
59
|
+
published_at: null,
|
|
60
|
+
published_domain: null,
|
|
61
|
+
has_outstanding_changes: false,
|
|
62
|
+
outstanding_change_reason: null
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function sectionVersions(template) {
|
|
66
|
+
const out = /* @__PURE__ */ new Map();
|
|
67
|
+
for (const instance of template.instances) {
|
|
68
|
+
if (out.has(instance.section)) continue;
|
|
69
|
+
if (instance.version === void 0) throw new HostRefusal(501, `The section "${instance.section}" has no published shape here, so this playground opens no editor over it. Run \`concrete check\` for the reason.`);
|
|
70
|
+
out.set(instance.section, {
|
|
71
|
+
instance,
|
|
72
|
+
version: instance.version
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
function bootstrapSection(key, instance, version) {
|
|
78
|
+
return {
|
|
79
|
+
section_key: key,
|
|
80
|
+
section_display_name: instance.label,
|
|
81
|
+
render_key: key,
|
|
82
|
+
schema: { ...version.schema },
|
|
83
|
+
fill_spec: { ...version.fillSpec }
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function subjectBuild(template) {
|
|
87
|
+
const graphs = /* @__PURE__ */ new Map();
|
|
88
|
+
const sections = /* @__PURE__ */ new Map();
|
|
89
|
+
for (const [key, { version }] of sectionVersions(template)) {
|
|
90
|
+
graphs.set(key, sectionGraphOf(version.schema, version.fillSpec));
|
|
91
|
+
sections.set(key, { schema: version.schema });
|
|
92
|
+
}
|
|
93
|
+
const composition = bootstrapComposition(template);
|
|
94
|
+
return {
|
|
95
|
+
composition,
|
|
96
|
+
readGraph: templateGraphOf(composition.pages, graphs),
|
|
97
|
+
sections
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function templateSubject(template) {
|
|
101
|
+
return templateSubjectOf(template.key, subjectBuild(template));
|
|
102
|
+
}
|
|
103
|
+
function fixtureSubject(template, fixture) {
|
|
104
|
+
return deliverableSubjectOf(fixture.id, subjectBuild(template), fixtureContentDoc(fixture));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
//#endregion
|
|
108
|
+
export { bootstrapComposition, bootstrapFormat, bootstrapSection, fixtureContentDoc, fixtureDeliverable, fixtureSubject, sectionVersions, templateSubject };
|