@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,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 };
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { PLAYGROUND_CANVAS_ISLAND_HOST, SECTION_FILES, builtTreePath, sectionPath } from "../../../template-artifact/dist/layout.js";
|
|
2
|
+
import { readBuild as readBuild$1 } from "../../../template-artifact/dist/build.js";
|
|
3
|
+
import { ROUTES } from "../wire.js";
|
|
4
|
+
|
|
5
|
+
//#region ../../internal/playground/dist/host/built.js
|
|
6
|
+
function localKey(templateKey, published) {
|
|
7
|
+
return published.startsWith(`${templateKey}/`) ? published.slice(templateKey.length + 1) : published;
|
|
8
|
+
}
|
|
9
|
+
function buildFolder(view, read) {
|
|
10
|
+
return { async readText(path) {
|
|
11
|
+
const file = await view.readText(builtTreePath(path));
|
|
12
|
+
read.push(`${path}@${file?.fingerprint ?? "-"}`);
|
|
13
|
+
return file;
|
|
14
|
+
} };
|
|
15
|
+
}
|
|
16
|
+
function viewOf(build) {
|
|
17
|
+
const { composition } = build;
|
|
18
|
+
const local = (key) => localKey(build.key, key);
|
|
19
|
+
const pages = composition.pages.map((page) => ({
|
|
20
|
+
id: page.id,
|
|
21
|
+
label: page.label,
|
|
22
|
+
..."path" in page ? { path: page.path } : {},
|
|
23
|
+
..."direction" in page && page.direction !== void 0 ? { direction: page.direction } : {},
|
|
24
|
+
...page.optional === true ? { optional: true } : {},
|
|
25
|
+
sections: page.sections.map((s) => ({
|
|
26
|
+
instanceId: s.instance_id,
|
|
27
|
+
section: local(s.section)
|
|
28
|
+
}))
|
|
29
|
+
}));
|
|
30
|
+
const published = /* @__PURE__ */ new Map();
|
|
31
|
+
const instances = composition.pages.flatMap((page) => page.sections).filter((s, at, all) => all.findIndex((o) => o.instance_id === s.instance_id) === at).map((s) => {
|
|
32
|
+
const section = build.sections.get(s.section);
|
|
33
|
+
published.set(local(s.section), s.section);
|
|
34
|
+
const schema = section.schema;
|
|
35
|
+
const slots = schema.slots ?? {};
|
|
36
|
+
const variant = schema.display?.variant;
|
|
37
|
+
return {
|
|
38
|
+
instanceId: s.instance_id,
|
|
39
|
+
section: local(s.section),
|
|
40
|
+
label: section.displayName,
|
|
41
|
+
sectionSchema: {
|
|
42
|
+
slots,
|
|
43
|
+
slot_order: [...schema.slot_order ?? Object.keys(slots)]
|
|
44
|
+
},
|
|
45
|
+
display: {
|
|
46
|
+
required: s.required === true,
|
|
47
|
+
variant: variant === void 0 ? null : {
|
|
48
|
+
cases: [...variant.cases ?? []],
|
|
49
|
+
locked: variant.locked === true
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
version: {
|
|
53
|
+
schema,
|
|
54
|
+
fillSpec: section.fillSpec
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
template: {
|
|
60
|
+
key: build.key,
|
|
61
|
+
name: build.displayName,
|
|
62
|
+
output: composition.output,
|
|
63
|
+
formats: composition.output === "website" ? [] : composition.formats,
|
|
64
|
+
pages,
|
|
65
|
+
canvases: composition.canvases.map((c) => ({
|
|
66
|
+
id: c.id,
|
|
67
|
+
label: c.label,
|
|
68
|
+
pages: [...c.pages]
|
|
69
|
+
})),
|
|
70
|
+
instances
|
|
71
|
+
},
|
|
72
|
+
binding: build.staticAssets,
|
|
73
|
+
fixtureList: build.fixtureList,
|
|
74
|
+
published
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
async function readBuild(view) {
|
|
78
|
+
const read = [];
|
|
79
|
+
return {
|
|
80
|
+
build: viewOf(await readBuild$1(buildFolder(view, read))),
|
|
81
|
+
key: [...read].sort().join("\n")
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function builtFileUrl(env, filename, buildBase) {
|
|
85
|
+
return buildBase === void 0 ? env.url(`${ROUTES.build}${filename}`) : `${buildBase}${filename}`;
|
|
86
|
+
}
|
|
87
|
+
function builtIslands(env, binding, buildBase) {
|
|
88
|
+
const islands = Object.entries(binding.islands);
|
|
89
|
+
if (islands.length === 0) return {
|
|
90
|
+
map: {},
|
|
91
|
+
canvasHost: null,
|
|
92
|
+
importMap: {},
|
|
93
|
+
documentLoader: { kind: "none" }
|
|
94
|
+
};
|
|
95
|
+
const { island_runtime: runtime, react_vendor: vendor, react_vendor_core: core } = binding;
|
|
96
|
+
if (runtime === null || vendor === null || core === null) throw new Error("The build binds islands but no island runtime or React vendor.");
|
|
97
|
+
const url = (filename) => builtFileUrl(env, filename, buildBase);
|
|
98
|
+
const map = Object.fromEntries(islands.map(([key, ref]) => [key, url(ref.filename)]));
|
|
99
|
+
const importMap = Object.fromEntries(Object.entries(vendor).map(([specifier, ref]) => [specifier, url(ref.filename)]));
|
|
100
|
+
return {
|
|
101
|
+
map,
|
|
102
|
+
canvasHost: env.url(PLAYGROUND_CANVAS_ISLAND_HOST),
|
|
103
|
+
importMap,
|
|
104
|
+
documentLoader: {
|
|
105
|
+
kind: "bundles",
|
|
106
|
+
runtime: { url: url(runtime.filename) },
|
|
107
|
+
islandMap: map,
|
|
108
|
+
reactVendorMap: importMap,
|
|
109
|
+
reactVendorCore: { url: url(core.filename) }
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function shippedHalf(env) {
|
|
114
|
+
const { captures } = env;
|
|
115
|
+
if (captures === void 0) return {};
|
|
116
|
+
return {
|
|
117
|
+
captured: () => captures.fixtures(),
|
|
118
|
+
shipped: (path) => captures.read(path)
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function builtEnv(env) {
|
|
122
|
+
let read = null;
|
|
123
|
+
let held = null;
|
|
124
|
+
const readAt = (view) => {
|
|
125
|
+
if (read?.version === view.version) return read.build;
|
|
126
|
+
const reading = readBuild(view).then(({ build, key }) => {
|
|
127
|
+
if (held?.key === key) return held.build;
|
|
128
|
+
held = {
|
|
129
|
+
key,
|
|
130
|
+
build
|
|
131
|
+
};
|
|
132
|
+
return build;
|
|
133
|
+
});
|
|
134
|
+
read = {
|
|
135
|
+
version: view.version,
|
|
136
|
+
build: reading
|
|
137
|
+
};
|
|
138
|
+
reading.catch(() => {
|
|
139
|
+
if (read?.build === reading) read = null;
|
|
140
|
+
});
|
|
141
|
+
return reading;
|
|
142
|
+
};
|
|
143
|
+
const current = async () => readAt(await env.files.current());
|
|
144
|
+
const publishedKey = (build, key) => {
|
|
145
|
+
const published = build.published.get(key);
|
|
146
|
+
if (published === void 0) throw new Error(`The composition places no section "${key}".`);
|
|
147
|
+
return published;
|
|
148
|
+
};
|
|
149
|
+
const computesAt = async (build, key) => {
|
|
150
|
+
const published = publishedKey(build, key);
|
|
151
|
+
const schema = build.template.instances.find((i) => i.section === key).version?.schema ?? {};
|
|
152
|
+
const computed = (await env.loadModule(sectionPath(published, SECTION_FILES.logic))).computed ?? {};
|
|
153
|
+
return {
|
|
154
|
+
localKey: key,
|
|
155
|
+
schema: {
|
|
156
|
+
slots: schema.slots ?? {},
|
|
157
|
+
display: schema.display ?? {}
|
|
158
|
+
},
|
|
159
|
+
bakeContext: {
|
|
160
|
+
computed,
|
|
161
|
+
section_key: key
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
return {
|
|
166
|
+
reader: {
|
|
167
|
+
template: async () => (await current()).template,
|
|
168
|
+
islands: async (buildBase) => builtIslands(env, (await current()).binding, buildBase),
|
|
169
|
+
computes: async (key) => computesAt(await current(), key),
|
|
170
|
+
binding: async () => (await current()).binding,
|
|
171
|
+
...shippedHalf(env)
|
|
172
|
+
},
|
|
173
|
+
site: {
|
|
174
|
+
binding: async () => (await current()).binding,
|
|
175
|
+
async buildFile(path) {
|
|
176
|
+
const read = await (await env.files.current()).readBytes(builtTreePath(path));
|
|
177
|
+
if (read === null) throw new Error(`The build has no file at "${path}".`);
|
|
178
|
+
return read.bytes;
|
|
179
|
+
},
|
|
180
|
+
shareImage: env.shareImage
|
|
181
|
+
},
|
|
182
|
+
readAt,
|
|
183
|
+
computesAt,
|
|
184
|
+
renderer: {
|
|
185
|
+
async section(key) {
|
|
186
|
+
const path = sectionPath(publishedKey(await current(), key), SECTION_FILES.renderer);
|
|
187
|
+
const component = (await env.loadModule(path)).default;
|
|
188
|
+
if (typeof component !== "function" && (typeof component !== "object" || component === null)) throw new Error(`${path} has no default-exported component.`);
|
|
189
|
+
return component;
|
|
190
|
+
},
|
|
191
|
+
createElement: (type, props) => env.react.createElement(type, props),
|
|
192
|
+
renderToString: (element, options) => env.react.renderToString(element, options)
|
|
193
|
+
},
|
|
194
|
+
stylesheets: async (buildBase) => {
|
|
195
|
+
const { binding } = await current();
|
|
196
|
+
return [builtFileUrl(env, binding.base_css.filename, buildBase), builtFileUrl(env, binding.template_css.filename, buildBase)];
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
//#endregion
|
|
202
|
+
export { builtEnv };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { candidateSet } from "../../../template-contracts/dist/media-candidates.js";
|
|
2
|
+
import { fixtureAddresses } from "./fixture-addresses.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../internal/playground/dist/host/catalog-fixture.js
|
|
5
|
+
function textOf(value) {
|
|
6
|
+
return typeof value === "string" && value !== "" ? value : null;
|
|
7
|
+
}
|
|
8
|
+
function propertySummary(facts) {
|
|
9
|
+
return {
|
|
10
|
+
listingIntent: textOf(facts.listing_intent),
|
|
11
|
+
units: facts.units.length,
|
|
12
|
+
photos: candidateSet(facts, {
|
|
13
|
+
kinds: ["image"],
|
|
14
|
+
from: ["property.property_media"]
|
|
15
|
+
}).length
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function docFingerprint(instances) {
|
|
19
|
+
const text = JSON.stringify(instances);
|
|
20
|
+
let h1 = 3735928559;
|
|
21
|
+
let h2 = 1103547991;
|
|
22
|
+
for (let i = 0; i < text.length; i++) {
|
|
23
|
+
const ch = text.charCodeAt(i);
|
|
24
|
+
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
25
|
+
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
26
|
+
}
|
|
27
|
+
h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
|
|
28
|
+
h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
|
|
29
|
+
return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(16).padStart(14, "0");
|
|
30
|
+
}
|
|
31
|
+
function catalogFixture(plan, property, fixture) {
|
|
32
|
+
const pagesOff = Object.entries(fixture.pages ?? {}).flatMap(([pageId, state]) => state.enabled ? [] : [pageId]);
|
|
33
|
+
return {
|
|
34
|
+
name: fixture.id,
|
|
35
|
+
doc: docFingerprint(fixture.instances),
|
|
36
|
+
...fixture.capturable === false ? { capturable: false } : {},
|
|
37
|
+
...pagesOff.length > 0 ? { pagesOff } : {},
|
|
38
|
+
addresses: fixtureAddresses(plan, property, fixture)
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function fixturesOn(held, property) {
|
|
42
|
+
return held.fixtures.filter((fixture) => fixture.property === property.file);
|
|
43
|
+
}
|
|
44
|
+
function catalogProperty(plan, held, property) {
|
|
45
|
+
return {
|
|
46
|
+
name: property.name,
|
|
47
|
+
summary: propertySummary(property.facts),
|
|
48
|
+
content: fixturesOn(held, property).map((fixture) => catalogFixture(plan, property.name, fixture))
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
export { catalogFixture, catalogProperty, docFingerprint, fixturesOn, propertySummary };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { addressComplete, addressView, normalizeAddressValue } from "../../../template-contracts/dist/address-value.js";
|
|
2
|
+
import { CAPTURE_FILES } from "../../../template-artifact/dist/layout.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../internal/playground/dist/host/download.js
|
|
5
|
+
const PAGE_IMAGE = ".png";
|
|
6
|
+
function parseDownloadPath(rest) {
|
|
7
|
+
if (rest.length === 0) return { page: null };
|
|
8
|
+
const [name] = rest;
|
|
9
|
+
if (rest.length !== 1 || name === void 0 || !name.endsWith(PAGE_IMAGE) || name.length === 4) return null;
|
|
10
|
+
return { page: name.slice(0, -4) };
|
|
11
|
+
}
|
|
12
|
+
function propertyAddressOf(facts) {
|
|
13
|
+
const value = facts.address;
|
|
14
|
+
if (!addressComplete(value)) return null;
|
|
15
|
+
const normalized = normalizeAddressValue(value);
|
|
16
|
+
return normalized === null ? null : addressView(normalized).display;
|
|
17
|
+
}
|
|
18
|
+
function attachmentDisposition(name) {
|
|
19
|
+
return `attachment; filename*=UTF-8''${encodeURIComponent(name)}`;
|
|
20
|
+
}
|
|
21
|
+
function shippedDownloadPath(input) {
|
|
22
|
+
const at = `${input.fixture}/${input.format}/`;
|
|
23
|
+
if (input.file.contentType === "application/pdf") return `${at}${CAPTURE_FILES.document}`;
|
|
24
|
+
if (input.file.contentType === "application/zip") return `${at}${CAPTURE_FILES.bundle}`;
|
|
25
|
+
return `${at}${input.file.page ?? ""}${PAGE_IMAGE}`;
|
|
26
|
+
}
|
|
27
|
+
function correctedDownloadLocation(url, named, owner) {
|
|
28
|
+
const from = `/properties/${encodeURIComponent(named)}/content/`;
|
|
29
|
+
const at = url.pathname.lastIndexOf(from);
|
|
30
|
+
return `${at < 0 ? url.pathname : `${url.pathname.slice(0, at)}/properties/${encodeURIComponent(owner)}/content/${url.pathname.slice(at + from.length)}`}${url.search}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { attachmentDisposition, correctedDownloadLocation, parseDownloadPath, propertyAddressOf, shippedDownloadPath };
|