@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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { poolingPrimitiveOf } from "../../template-contracts/dist/row-planners.js";
|
|
2
1
|
import { listItemFieldsOf } from "../../template-contracts/dist/row-sources.js";
|
|
2
|
+
import { poolingPrimitiveOf } from "../../template-contracts/dist/row-planners.js";
|
|
3
3
|
import "./row-planners.js";
|
|
4
4
|
|
|
5
5
|
//#region ../../internal/fill-vocabulary/dist/holder.js
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { listItemFieldsOf } from "../../template-contracts/dist/row-sources.js";
|
|
1
2
|
import { isValueKind } from "../../template-contracts/dist/value-contracts.js";
|
|
2
3
|
import { plannerForField } from "../../template-contracts/dist/row-planners.js";
|
|
3
|
-
import { listItemFieldsOf } from "../../template-contracts/dist/row-sources.js";
|
|
4
4
|
import "./row-planners.js";
|
|
5
5
|
import { bindsElement, holderLabel, holderOf, isFactBound } from "./holder.js";
|
|
6
6
|
import { pickIsUnique, readFillVerb, verbRunsOn, writesElements } from "./verbs.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { listItemFieldsOf } from "../../template-contracts/dist/row-sources.js";
|
|
1
2
|
import { FINDABLE_KINDS, isFindableKind } from "../../template-contracts/dist/findable.js";
|
|
2
3
|
import { isValueKind } from "../../template-contracts/dist/value-contracts.js";
|
|
3
|
-
import { listItemFieldsOf } from "../../template-contracts/dist/row-sources.js";
|
|
4
4
|
import { bindsElement, holderOf, poolOfKind } from "./holder.js";
|
|
5
5
|
|
|
6
6
|
//#region ../../internal/fill-vocabulary/dist/verbs.js
|
|
@@ -118,15 +118,6 @@ async function hydrateIslands(options) {
|
|
|
118
118
|
}
|
|
119
119
|
return handles;
|
|
120
120
|
}
|
|
121
|
-
function unmountIslands(root = document) {
|
|
122
|
-
const self = root instanceof Element && root.matches(`[${"data-tr-island"}]`) ? [root] : [];
|
|
123
|
-
for (const element of [...self, ...root.querySelectorAll(`[${ATTR_ISLAND_KEY}]`)]) {
|
|
124
|
-
const reactRoot = roots.get(element);
|
|
125
|
-
if (!reactRoot) continue;
|
|
126
|
-
roots.delete(element);
|
|
127
|
-
reactRoot.unmount();
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
121
|
|
|
131
122
|
//#endregion
|
|
132
|
-
export { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, ATTR_SECTION_INSTANCE_ID, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, IslandPropsError, deserializeIslandProps, hydrateIslands, islandId, islandsCaptureReady, serializeIslandProps
|
|
123
|
+
export { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, ATTR_SECTION_INSTANCE_ID, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, IslandPropsError, deserializeIslandProps, hydrateIslands, islandId, islandsCaptureReady, serializeIslandProps };
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
* that paints everything during mount needs none of this — never calling the
|
|
12
12
|
* hook is the default contract.
|
|
13
13
|
*
|
|
14
|
+
* Start the engine at the state it is captured in: a map constructed with its
|
|
15
|
+
* fitted `bounds`, never at a placeholder camera it moves away from on load.
|
|
16
|
+
* An engine keeps what it fetched for its first state, and whether that arrived
|
|
17
|
+
* before the move changes the pixels from one shot to the next.
|
|
18
|
+
*
|
|
14
19
|
* Where nothing captures (an editor canvas, a published website) the hold is
|
|
15
20
|
* never read, so the hook costs nothing there.
|
|
16
21
|
*/
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region ../../internal/lead-fields/dist/ingest.js
|
|
2
|
+
const LEAD_INGEST_MAX_BODY = 16 * 1024;
|
|
3
|
+
const LEAD_SIGNATURE_WINDOW_SECONDS = 300;
|
|
4
|
+
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
5
|
+
function isLeadIngestRefusal(value) {
|
|
6
|
+
return "error" in value;
|
|
7
|
+
}
|
|
8
|
+
function leadIngestHeaders(header) {
|
|
9
|
+
const siteId = header("x-site-id");
|
|
10
|
+
const timestamp = header("x-timestamp");
|
|
11
|
+
const signature = header("x-signature");
|
|
12
|
+
const idempotencyKey = header("idempotency-key");
|
|
13
|
+
if (!siteId || !UUID_RE.test(siteId)) return {
|
|
14
|
+
status: 401,
|
|
15
|
+
error: "unauthorized"
|
|
16
|
+
};
|
|
17
|
+
if (!timestamp || !signature) return {
|
|
18
|
+
status: 401,
|
|
19
|
+
error: "unauthorized"
|
|
20
|
+
};
|
|
21
|
+
if (!idempotencyKey || !UUID_RE.test(idempotencyKey)) return {
|
|
22
|
+
status: 400,
|
|
23
|
+
error: "idempotency_key_required"
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
siteId,
|
|
27
|
+
timestamp,
|
|
28
|
+
signature,
|
|
29
|
+
idempotencyKey
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function leadIngestSize(rawBody) {
|
|
33
|
+
return rawBody.length > 16384 ? {
|
|
34
|
+
status: 413,
|
|
35
|
+
error: "too_large"
|
|
36
|
+
} : null;
|
|
37
|
+
}
|
|
38
|
+
function leadTimestampFresh(timestamp, nowSeconds) {
|
|
39
|
+
const ts = Number(timestamp);
|
|
40
|
+
return Number.isFinite(ts) && Math.abs(nowSeconds - ts) <= 300;
|
|
41
|
+
}
|
|
42
|
+
function leadIngestBody(rawBody) {
|
|
43
|
+
let parsed;
|
|
44
|
+
try {
|
|
45
|
+
parsed = JSON.parse(rawBody);
|
|
46
|
+
} catch {
|
|
47
|
+
return {
|
|
48
|
+
status: 400,
|
|
49
|
+
error: "invalid_body"
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const payload = parsed && typeof parsed === "object" ? parsed : {};
|
|
53
|
+
const fields = payload.fields;
|
|
54
|
+
if (!fields || typeof fields !== "object" || Array.isArray(fields)) return {
|
|
55
|
+
status: 400,
|
|
56
|
+
error: "invalid_body"
|
|
57
|
+
};
|
|
58
|
+
const emailRaw = fields.email;
|
|
59
|
+
const email = typeof emailRaw === "string" ? emailRaw.trim() : "";
|
|
60
|
+
if (!email) return {
|
|
61
|
+
status: 400,
|
|
62
|
+
error: "invalid_body"
|
|
63
|
+
};
|
|
64
|
+
return {
|
|
65
|
+
fields,
|
|
66
|
+
email,
|
|
67
|
+
sourceUrl: typeof payload.source_url === "string" ? payload.source_url.slice(0, 2048) : null
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
export { LEAD_INGEST_MAX_BODY, isLeadIngestRefusal, leadIngestBody, leadIngestHeaders, leadIngestSize, leadTimestampFresh };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { videoEmbedUrl } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
-
import { contentMediaIdOf, videoSourceOf } from "../../template-contracts/dist/registry-facts.js";
|
|
2
|
+
import { JOB_FAILED_ERROR, contentMediaIdOf, videoSourceOf } from "../../template-contracts/dist/registry-facts.js";
|
|
3
3
|
import { readLadder } from "./store.js";
|
|
4
4
|
|
|
5
5
|
//#region ../../internal/media-resolution/dist/video.js
|
|
@@ -15,6 +15,10 @@ async function attachPosterResponsive(out, previewKey, store) {
|
|
|
15
15
|
if (responsive) out.poster_responsive = responsive;
|
|
16
16
|
return out;
|
|
17
17
|
}
|
|
18
|
+
function encodeNeverLands(record) {
|
|
19
|
+
const failure = record.failed_outputs?.transcode;
|
|
20
|
+
return failure === void 0 ? record.state === "failed" : failure !== JOB_FAILED_ERROR;
|
|
21
|
+
}
|
|
18
22
|
async function resolveVideoSlot(value, records, store) {
|
|
19
23
|
if (value === null) return null;
|
|
20
24
|
if (typeof value !== "object") return DEFAULT;
|
|
@@ -60,7 +64,7 @@ async function resolveVideoSlot(value, records, store) {
|
|
|
60
64
|
media_id: videoId,
|
|
61
65
|
state: record.state
|
|
62
66
|
}, "resolve-video-slot: no encode; poster-only");
|
|
63
|
-
if (record
|
|
67
|
+
if (!encodeNeverLands(record)) store.notePending?.({
|
|
64
68
|
kind: "video",
|
|
65
69
|
id: videoId
|
|
66
70
|
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { DOCUMENT_FORMATS } from "../../upload-formats/dist/index.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../internal/page-render/dist/addresses.js
|
|
4
|
+
const docExtByCt = {};
|
|
5
|
+
const docCtByExt = {};
|
|
6
|
+
for (const format of DOCUMENT_FORMATS) {
|
|
7
|
+
const ext = format.extension.slice(1);
|
|
8
|
+
docCtByExt[ext] = format.mimeTypes[0];
|
|
9
|
+
for (const mime of format.mimeTypes) docExtByCt[mime] = ext;
|
|
10
|
+
}
|
|
11
|
+
const EXT_BY_CT = {
|
|
12
|
+
"image/avif": "avif",
|
|
13
|
+
"image/webp": "webp",
|
|
14
|
+
"image/jpeg": "jpg",
|
|
15
|
+
"image/png": "png",
|
|
16
|
+
"image/svg+xml": "svg",
|
|
17
|
+
"video/mp4": "mp4",
|
|
18
|
+
...docExtByCt
|
|
19
|
+
};
|
|
20
|
+
const CT_BY_EXT = {
|
|
21
|
+
avif: "image/avif",
|
|
22
|
+
webp: "image/webp",
|
|
23
|
+
jpg: "image/jpeg",
|
|
24
|
+
jpeg: "image/jpeg",
|
|
25
|
+
png: "image/png",
|
|
26
|
+
svg: "image/svg+xml",
|
|
27
|
+
mp4: "video/mp4",
|
|
28
|
+
...docCtByExt
|
|
29
|
+
};
|
|
30
|
+
const DIR_BY_FAMILY = {
|
|
31
|
+
image: "img",
|
|
32
|
+
video: "video"
|
|
33
|
+
};
|
|
34
|
+
function familyDirFor(contentType) {
|
|
35
|
+
if (docExtByCt[contentType]) return "doc";
|
|
36
|
+
return DIR_BY_FAMILY[contentType.split("/")[0]] ?? null;
|
|
37
|
+
}
|
|
38
|
+
function extOf(key) {
|
|
39
|
+
const basename = (key.split("/").pop() ?? "").split("?")[0] ?? "";
|
|
40
|
+
const dot = basename.lastIndexOf(".");
|
|
41
|
+
if (dot <= 0) return null;
|
|
42
|
+
const ext = basename.slice(dot + 1);
|
|
43
|
+
return /^[a-zA-Z0-9]+$/.test(ext) ? ext.toLowerCase() : null;
|
|
44
|
+
}
|
|
45
|
+
function contentTypeFor(key, hint) {
|
|
46
|
+
if (hint && EXT_BY_CT[hint]) return hint;
|
|
47
|
+
const ext = extOf(key);
|
|
48
|
+
return ext ? CT_BY_EXT[ext] ?? null : null;
|
|
49
|
+
}
|
|
50
|
+
function mediaPath(key, contentType, filename, hash) {
|
|
51
|
+
const dir = familyDirFor(contentType);
|
|
52
|
+
if (!dir) return null;
|
|
53
|
+
return `assets/${dir}/${hash(filename === null ? key : `${key}\n${filename}`).slice(0, 16)}.${EXT_BY_CT[contentType]}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { contentTypeFor, mediaPath };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { contentTypeFor, mediaPath } from "./addresses.js";
|
|
2
|
+
import { keptInProcess } from "./kept.js";
|
|
3
|
+
import { bareName, pageHref, resolvePageNav } from "./nav.js";
|
|
4
|
+
import { displayCase, pagePlan, renderPage, renderPageSection, renderSection, resolveSectionInputs, sectionFingerprint, snapshotNav, snapshotNavPages } from "./render.js";
|
|
5
|
+
|
|
6
|
+
export { bareName, contentTypeFor, keptInProcess, mediaPath, pagePlan, renderPage, renderPageSection };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region ../../internal/page-render/dist/kept.js
|
|
2
|
+
const KEPT_PER_SECTION = 64;
|
|
3
|
+
function keptInProcess(hash, perSection = 64) {
|
|
4
|
+
const bySection = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
const holder = (component) => typeof component === "object" && component !== null || typeof component === "function" ? component : null;
|
|
6
|
+
return {
|
|
7
|
+
hash,
|
|
8
|
+
kept(component, fingerprint) {
|
|
9
|
+
const held = holder(component);
|
|
10
|
+
const kept = held === null ? void 0 : bySection.get(held);
|
|
11
|
+
const section = kept?.get(fingerprint);
|
|
12
|
+
if (section === void 0) return void 0;
|
|
13
|
+
kept.delete(fingerprint);
|
|
14
|
+
kept.set(fingerprint, section);
|
|
15
|
+
return section;
|
|
16
|
+
},
|
|
17
|
+
keep(component, fingerprint, section) {
|
|
18
|
+
const held = holder(component);
|
|
19
|
+
if (held === null) return;
|
|
20
|
+
let kept = bySection.get(held);
|
|
21
|
+
if (kept === void 0) bySection.set(held, kept = /* @__PURE__ */ new Map());
|
|
22
|
+
kept.delete(fingerprint);
|
|
23
|
+
kept.set(fingerprint, section);
|
|
24
|
+
if (kept.size > perSection) kept.delete(kept.keys().next().value);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { keptInProcess };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region ../../internal/page-render/dist/nav.js
|
|
2
|
+
function bareName(sectionKey) {
|
|
3
|
+
return sectionKey.split("/").pop();
|
|
4
|
+
}
|
|
5
|
+
function pageHref(contentBase, path) {
|
|
6
|
+
const base = contentBase.replace(/\/+$/, "");
|
|
7
|
+
return path === "/" ? `${base}/` : `${base}${path}/`;
|
|
8
|
+
}
|
|
9
|
+
function resolvePageNav(input) {
|
|
10
|
+
const { pages, currentPageId, contentBase } = input;
|
|
11
|
+
const current = pages.find((p) => p.id === currentPageId);
|
|
12
|
+
if (current === void 0) throw new Error(`nav: page "${currentPageId}" is not one of the declared pages (${pages.map((p) => p.id).join(", ")}).`);
|
|
13
|
+
const pageOf = /* @__PURE__ */ new Map();
|
|
14
|
+
for (const page of pages) {
|
|
15
|
+
if (page.id !== current.id && page.enabled === false) continue;
|
|
16
|
+
for (const section of page.sections) {
|
|
17
|
+
if (section.enabled === false) continue;
|
|
18
|
+
const name = bareName(section.key);
|
|
19
|
+
if (!pageOf.has(name) || page.id === current.id) pageOf.set(name, {
|
|
20
|
+
page,
|
|
21
|
+
anchor: section.anchor
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const anchors = {};
|
|
26
|
+
for (const [name, { page, anchor }] of pageOf) {
|
|
27
|
+
if (anchor === void 0 || anchor === "") continue;
|
|
28
|
+
anchors[name] = page.id === current.id ? `#${anchor}` : `${pageHref(contentBase, page.path)}#${anchor}`;
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
anchors,
|
|
32
|
+
pages: pages.filter((p) => p.enabled !== false).map((p) => ({
|
|
33
|
+
id: p.id,
|
|
34
|
+
label: p.label,
|
|
35
|
+
href: pageHref(contentBase, p.path),
|
|
36
|
+
current: p.id === current.id
|
|
37
|
+
}))
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { bareName, pageHref, resolvePageNav };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { resolvePageNav } from "./nav.js";
|
|
2
|
+
import { defaultDisplayCase } from "../../deliverable-reads/dist/display.js";
|
|
3
|
+
import { defaultForSlotType } from "../../template-contracts/dist/primitive-descriptors.js";
|
|
4
|
+
import "../../deliverable-reads/dist/index.js";
|
|
5
|
+
import { resolveSlotValue } from "../../media-resolution/dist/slot.js";
|
|
6
|
+
import "../../media-resolution/dist/index.js";
|
|
7
|
+
import { fillSectionAssetRefs } from "../../static-assets-binding/dist/section-asset-url.js";
|
|
8
|
+
|
|
9
|
+
//#region ../../internal/page-render/dist/render.js
|
|
10
|
+
function displayCase(stored, schema) {
|
|
11
|
+
return stored ?? defaultDisplayCase(schema.display);
|
|
12
|
+
}
|
|
13
|
+
function sectionFingerprint(hash, inputs, identifierPrefix, buildBase) {
|
|
14
|
+
return hash(JSON.stringify([
|
|
15
|
+
identifierPrefix,
|
|
16
|
+
buildBase ?? null,
|
|
17
|
+
inputs
|
|
18
|
+
]));
|
|
19
|
+
}
|
|
20
|
+
async function resolveSectionInputs(input) {
|
|
21
|
+
const { schema } = input;
|
|
22
|
+
const slots = {};
|
|
23
|
+
for (const [id, def] of Object.entries(schema.slots ?? {})) slots[id] = defaultForSlotType(def.type);
|
|
24
|
+
for (const [id, value] of Object.entries(input.values)) {
|
|
25
|
+
if (value === void 0) continue;
|
|
26
|
+
slots[id] = await resolveSlotValue(value, schema.slots?.[id], input.media);
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
slots,
|
|
30
|
+
variant: displayCase(input.variant, schema),
|
|
31
|
+
nav: {
|
|
32
|
+
selfAnchor: input.nav.selfAnchor ?? schema.anchor,
|
|
33
|
+
anchors: input.nav.anchors,
|
|
34
|
+
pages: input.nav.pages
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
async function renderSection(input) {
|
|
39
|
+
const inputs = input.inputs ?? await resolveSectionInputs(input);
|
|
40
|
+
const { kept } = input;
|
|
41
|
+
const fingerprint = kept === void 0 ? null : sectionFingerprint(kept.hash, inputs, input.identifierPrefix, input.buildBase);
|
|
42
|
+
const answered = fingerprint === null ? void 0 : kept.kept(input.component, fingerprint);
|
|
43
|
+
if (answered !== void 0) return {
|
|
44
|
+
...answered,
|
|
45
|
+
inputs
|
|
46
|
+
};
|
|
47
|
+
const filled = fillSectionAssetRefs(input.react.renderToString(input.react.createElement(input.component, { ...inputs }), { identifierPrefix: input.identifierPrefix }), input.buildBase === void 0 ? { kind: "canonical" } : {
|
|
48
|
+
kind: "underBuildBase",
|
|
49
|
+
buildBase: input.buildBase
|
|
50
|
+
});
|
|
51
|
+
const made = {
|
|
52
|
+
html: filled.text,
|
|
53
|
+
buildFiles: filled.files
|
|
54
|
+
};
|
|
55
|
+
if (fingerprint !== null) kept.keep(input.component, fingerprint, made);
|
|
56
|
+
return {
|
|
57
|
+
...made,
|
|
58
|
+
inputs
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function pagePlan(snapshot, pageId) {
|
|
62
|
+
const page = pageOf(snapshot, pageId);
|
|
63
|
+
const held = new Map(snapshot.instances.map((instance) => [instance.instanceId, instance]));
|
|
64
|
+
return page.sections.flatMap((placed) => {
|
|
65
|
+
const instance = held.get(placed.instanceId);
|
|
66
|
+
return instance?.enabled === true ? [instance] : [];
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function pageOf(snapshot, pageId) {
|
|
70
|
+
const page = snapshot.pages.find((p) => p.id === pageId);
|
|
71
|
+
if (page === void 0) throw new Error(`The composition declares no page "${pageId}" (have: ${snapshot.pages.map((p) => p.id).join(", ")}).`);
|
|
72
|
+
return page;
|
|
73
|
+
}
|
|
74
|
+
async function snapshotNavPages(snapshot) {
|
|
75
|
+
const enabled = new Map(snapshot.instances.map((instance) => [instance.instanceId, instance.enabled]));
|
|
76
|
+
const pages = [];
|
|
77
|
+
for (const page of snapshot.pages) {
|
|
78
|
+
const sections = [];
|
|
79
|
+
for (const placed of page.sections) {
|
|
80
|
+
const { schema } = await snapshot.section(placed.section);
|
|
81
|
+
sections.push({
|
|
82
|
+
key: placed.section,
|
|
83
|
+
anchor: schema.anchor,
|
|
84
|
+
enabled: enabled.get(placed.instanceId) === true
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
pages.push({
|
|
88
|
+
id: page.id,
|
|
89
|
+
label: page.label,
|
|
90
|
+
path: page.path ?? `/${page.id}`,
|
|
91
|
+
enabled: snapshot.pageEnabled(page.id),
|
|
92
|
+
sections
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return pages;
|
|
96
|
+
}
|
|
97
|
+
async function snapshotNav(snapshot, pageId, contentBase) {
|
|
98
|
+
if (snapshot.output !== "website") return {
|
|
99
|
+
anchors: {},
|
|
100
|
+
pages: []
|
|
101
|
+
};
|
|
102
|
+
return resolvePageNav({
|
|
103
|
+
pages: await snapshotNavPages(snapshot),
|
|
104
|
+
currentPageId: pageId,
|
|
105
|
+
contentBase
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async function renderInstance(request, instance, sectionKey, nav) {
|
|
109
|
+
const { react, snapshot, over } = request;
|
|
110
|
+
const laid = over?.[instance.instanceId];
|
|
111
|
+
const section = await snapshot.section(sectionKey);
|
|
112
|
+
const rendered = await renderSection({
|
|
113
|
+
react,
|
|
114
|
+
component: section.component,
|
|
115
|
+
schema: section.schema,
|
|
116
|
+
values: {
|
|
117
|
+
...instance.values,
|
|
118
|
+
...laid?.values
|
|
119
|
+
},
|
|
120
|
+
variant: laid?.variant ?? instance.variant,
|
|
121
|
+
nav,
|
|
122
|
+
media: snapshot.media(),
|
|
123
|
+
identifierPrefix: instance.instanceId,
|
|
124
|
+
buildBase: request.buildBase,
|
|
125
|
+
kept: request.kept
|
|
126
|
+
});
|
|
127
|
+
return {
|
|
128
|
+
instanceId: instance.instanceId,
|
|
129
|
+
...rendered
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
async function renderPage(request) {
|
|
133
|
+
const page = pageOf(request.snapshot, request.pageId);
|
|
134
|
+
const nav = await snapshotNav(request.snapshot, page.id, request.contentBase);
|
|
135
|
+
const keyOf = new Map(page.sections.map((placed) => [placed.instanceId, placed.section]));
|
|
136
|
+
const out = [];
|
|
137
|
+
for (const instance of pagePlan(request.snapshot, page.id)) out.push(await renderInstance(request, instance, keyOf.get(instance.instanceId), nav));
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
140
|
+
async function renderPageSection(request, instanceId) {
|
|
141
|
+
const page = pageOf(request.snapshot, request.pageId);
|
|
142
|
+
const placed = [page, ...request.snapshot.pages].flatMap((p) => p.sections).find((p) => p.instanceId === instanceId);
|
|
143
|
+
if (placed === void 0) throw new Error(`The composition places no instance "${instanceId}".`);
|
|
144
|
+
return renderInstance(request, request.snapshot.instances.find((i) => i.instanceId === instanceId) ?? {
|
|
145
|
+
instanceId,
|
|
146
|
+
values: {},
|
|
147
|
+
enabled: false
|
|
148
|
+
}, placed.section, await snapshotNav(request.snapshot, page.id, request.contentBase));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
//#endregion
|
|
152
|
+
export { displayCase, pagePlan, renderPage, renderPageSection, renderSection, resolveSectionInputs, sectionFingerprint, snapshotNav, snapshotNavPages };
|
|
@@ -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 };
|