@homepages/concrete 8.0.0 → 9.1.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 +1005 -0
- package/README.md +20 -9
- package/codemods/list-grammar.mjs +923 -0
- package/codemods/manifest.json +64 -0
- package/codemods/process-builders.mjs +198 -0
- package/codemods/slot-object.mjs +1097 -0
- package/codemods/steps/content-object-fields.mjs +324 -0
- package/codemods/steps/list-object-form.mjs +6 -7
- package/codemods/table-rows.mjs +568 -0
- package/codemods/unwrap-object-fields.mjs +310 -0
- package/codemods/viewer-slot-document.mjs +131 -0
- package/codemods/write-property-as-facts-document.mjs +716 -0
- package/codemods/write-the-address-line.mjs +255 -0
- package/codemods/write-the-registry-members.mjs +653 -0
- package/codemods/write-the-select-from.mjs +141 -0
- package/codemods/write-the-sole-from.mjs +369 -0
- package/codemods/write-the-table-from.mjs +267 -0
- package/codemods/write-the-whole-item.mjs +512 -0
- package/codemods/writeback-drop.mjs +168 -0
- package/codemods/written-contact-address.mjs +162 -0
- package/codemods/written-media-category.mjs +227 -0
- package/codemods/written-ref-kinds-name-the-layer.mjs +172 -0
- package/codemods/written-uploads-replace-pool-reads.mjs +454 -0
- package/codemods/written-uploads-sort-into-lists.mjs +405 -0
- package/codemods/written-uploads-stated-in-sorted-lists.mjs +295 -0
- package/codemods/written-video-sources-drop.mjs +144 -0
- package/codemods/written-without-pick-none.mjs +146 -0
- package/codemods/written-without-retired-knowledge.mjs +223 -0
- package/codemods/written-without-the-media-key.mjs +202 -0
- package/codemods/written-without-the-property-type.mjs +249 -0
- package/dist/artifact/playground/client/assets/index-BOYbgBnP.js +1259 -0
- package/dist/artifact/playground/client/assets/index-DDOcM0zA.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 +61 -27
- package/dist/base.css +58 -1
- package/dist/cli/build/artifact.js +6 -9
- package/dist/cli/build/captures.js +2 -12
- package/dist/cli/build/esbuild.js +1 -25
- package/dist/cli/build/fixtures.js +2 -1
- package/dist/cli/build/icons.js +1 -1
- package/dist/cli/build/static.js +2 -2
- package/dist/cli/capture/capture.js +8 -9
- package/dist/cli/check/analyze.js +8 -1
- package/dist/cli/check/load-outdir.js +47 -0
- package/dist/cli/check/load-workspace.js +4 -4
- package/dist/cli/check/render/html.js +1 -2
- package/dist/cli/check/render/inputs.js +10 -3
- package/dist/cli/check/render/island-frames.js +2 -1
- package/dist/cli/check/render/marker-coverage.js +23 -15
- package/dist/cli/check/report.js +5 -0
- package/dist/cli/check/stages/bundles.js +1 -1
- package/dist/cli/check/stages/relations.js +1 -1
- package/dist/cli/check/stages/render.js +48 -33
- package/dist/cli/check/stages/sections.js +83 -31
- package/dist/cli/check/stages/workspace.js +2 -0
- package/dist/cli/check/template-key.js +16 -0
- package/dist/cli/commands.js +1 -1
- package/dist/cli/dev/crop.js +1 -1
- package/dist/cli/dev/fixture-ladders.js +96 -0
- package/dist/cli/dev/islands.js +12 -123
- package/dist/cli/dev/listen.js +20 -1
- package/dist/cli/dev/load-template.js +1 -1
- package/dist/cli/dev/server.js +35 -10
- package/dist/cli/dev/vite.js +9 -7
- package/dist/cli/dev/workspace-reader.js +16 -16
- package/dist/cli/media/derive.js +43 -57
- package/dist/cli/media/frame-rung-floor.js +0 -1
- package/dist/cli/property/index.js +1 -6
- package/dist/css/inline.js +1 -22
- package/dist/eslint/rules/no-marker-literal.js +1 -1
- package/dist/fixtures/load.js +16 -7
- package/dist/fixtures/media-plugin.js +17 -12
- package/dist/fixtures/media-store.js +115 -0
- package/dist/fixtures/property.js +345 -126
- package/dist/fixtures/resolve.js +260 -251
- package/dist/fixtures/rows.js +4 -11
- package/dist/fixtures.d.ts +234 -109
- package/dist/index.d.ts +25 -16
- package/dist/index.js +10 -6
- package/dist/islands/marker.js +2 -1
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/canvas-core/dist/island-host.js +62 -0
- package/dist/packages/internal/canvas-core/dist/island-shields.js +30 -0
- package/dist/packages/internal/capture-settle/dist/index.js +3 -0
- package/dist/packages/internal/capture-settle/dist/island-markers.d.ts +13 -0
- package/dist/packages/internal/capture-settle/dist/island-markers.js +6 -0
- package/dist/packages/internal/capture-settle/dist/settle.js +150 -0
- package/dist/packages/internal/{image-ladder/dist/crop.js → crop-region/dist/index.js} +21 -20
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +250 -46
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +361 -4
- package/dist/packages/internal/fill-bake/dist/derive-source.js +25 -18
- package/dist/packages/internal/fill-bake/dist/index.js +9 -3
- package/dist/packages/internal/fill-bake/dist/item-merge.js +113 -0
- package/dist/packages/internal/fill-bake/dist/item-overrides.js +1 -0
- package/dist/packages/internal/fill-bake/dist/linked-merge.js +38 -0
- package/dist/packages/internal/fill-bake/dist/list-grammar.js +174 -0
- package/dist/packages/internal/fill-bake/dist/stored-row-reader.js +1 -0
- package/dist/packages/internal/fill-vocabulary/dist/holder.js +51 -0
- package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +363 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -23
- package/dist/packages/internal/fill-vocabulary/dist/verbs.js +60 -0
- package/dist/packages/internal/format-geometry/dist/capture.js +11 -147
- package/dist/packages/internal/format-geometry/dist/format.d.ts +8 -2
- package/dist/packages/internal/format-geometry/dist/geometry.js +13 -2
- package/dist/packages/internal/image-ladder/dist/encode.js +27 -14
- package/dist/packages/internal/image-ladder/dist/index.js +3 -3
- package/dist/packages/internal/image-ladder/dist/policy.js +28 -53
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +1 -1
- package/dist/packages/internal/island-runtime/dist/contract.d.ts +3 -12
- package/dist/packages/internal/island-runtime/dist/contract.js +2 -2
- package/dist/packages/internal/island-runtime/dist/index.d.ts +3 -7
- package/dist/packages/internal/island-runtime/dist/index.js +2 -1
- package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +1 -1
- package/dist/packages/internal/media-resolution/dist/crop-key.js +7 -0
- package/dist/packages/internal/media-resolution/dist/document.js +63 -0
- package/dist/packages/internal/media-resolution/dist/image.js +226 -0
- package/dist/packages/internal/media-resolution/dist/index.js +11 -0
- package/dist/packages/internal/media-resolution/dist/list.js +112 -0
- package/dist/packages/internal/media-resolution/dist/media.js +59 -0
- package/dist/packages/internal/media-resolution/dist/records.js +7 -0
- package/dist/packages/internal/media-resolution/dist/slot.js +37 -0
- package/dist/packages/internal/media-resolution/dist/store.js +19 -0
- package/dist/packages/internal/media-resolution/dist/tour.js +59 -0
- package/dist/packages/internal/media-resolution/dist/video.js +93 -0
- package/dist/packages/internal/property-facts/dist/registry-facts.js +245 -0
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +8 -17
- package/dist/packages/internal/section-contracts/dist/catalog.js +34 -14
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +11 -2
- package/dist/packages/internal/section-contracts/dist/directly-linked-list-contract.js +21 -0
- package/dist/packages/internal/section-contracts/dist/fill-options.js +12 -0
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +1 -5
- package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +95 -0
- package/dist/packages/internal/section-contracts/dist/grammar-scope.js +154 -0
- package/dist/packages/internal/section-contracts/dist/index.js +7 -2
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +2 -36
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +12 -21
- package/dist/packages/internal/section-contracts/dist/list-source-contract.js +46 -0
- package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +11 -2
- package/dist/packages/internal/section-contracts/dist/object-contract.js +92 -0
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +9 -5
- package/dist/packages/internal/section-contracts/dist/reads-acyclic-contract.js +63 -0
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +6 -17
- package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +80 -0
- package/dist/packages/internal/section-contracts/dist/row-source-contract.js +67 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +77 -18
- package/dist/packages/internal/section-contracts/dist/select-contract.js +0 -8
- package/dist/packages/internal/section-contracts/dist/source-contract.js +89 -95
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +47 -17
- package/dist/packages/internal/section-contracts/dist/table-member.js +16 -0
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +39 -23
- package/dist/packages/internal/source-resolution/dist/index.js +113 -73
- package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +16 -0
- package/dist/packages/internal/street-address/dist/index.js +72 -0
- package/dist/packages/internal/template-artifact/dist/asset-mime.js +30 -0
- package/dist/packages/internal/template-artifact/dist/layout.js +1 -2
- package/dist/packages/internal/template-artifact/dist/manifest.js +1 -1
- package/dist/packages/internal/template-artifact/dist/verify.js +12 -29
- package/dist/packages/internal/template-contracts/dist/address-value.d.ts +52 -0
- package/dist/packages/internal/template-contracts/dist/address-value.js +90 -0
- package/dist/packages/internal/template-contracts/dist/comparable-address.js +19 -0
- package/dist/{schema → packages/internal/template-contracts/dist}/compute.d.ts +29 -6
- package/dist/{schema → packages/internal/template-contracts/dist}/compute.js +11 -13
- package/dist/packages/internal/template-contracts/dist/content-pick.js +51 -0
- package/dist/packages/internal/template-contracts/dist/decision-fills.js +81 -0
- package/dist/packages/internal/template-contracts/dist/display-overrides.js +7 -0
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +16 -5
- package/dist/packages/internal/template-contracts/dist/fact-compute.d.ts +24 -0
- package/dist/packages/internal/template-contracts/dist/fact-compute.js +30 -0
- package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +44 -0
- package/dist/packages/internal/template-contracts/dist/fact-keys.js +88 -0
- package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +290 -0
- package/dist/packages/internal/template-contracts/dist/fact-registry.js +598 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +10 -24
- package/dist/packages/internal/template-contracts/dist/fill-builders.d.ts +157 -0
- package/dist/packages/internal/template-contracts/dist/fill-builders.js +79 -0
- package/dist/packages/internal/template-contracts/dist/fill-declaration.d.ts +14 -0
- package/dist/{schema → packages/internal/template-contracts/dist}/fill-declaration.js +6 -5
- package/dist/packages/internal/template-contracts/dist/fill-spec-schema.js +93 -0
- package/dist/packages/internal/template-contracts/dist/fill-spec.js +291 -0
- package/dist/packages/internal/template-contracts/dist/findable.js +8 -0
- package/dist/packages/internal/template-contracts/dist/floor-presets.js +13 -0
- package/dist/packages/internal/template-contracts/dist/icon-names.d.ts +5 -0
- package/dist/packages/internal/template-contracts/dist/icon-names.js +70 -0
- package/dist/packages/internal/template-contracts/dist/legacy-facts.js +167 -0
- package/dist/packages/internal/template-contracts/dist/list-editing.js +93 -0
- package/dist/packages/internal/template-contracts/dist/list.d.ts +215 -0
- package/dist/packages/internal/template-contracts/dist/list.js +258 -0
- package/dist/packages/internal/template-contracts/dist/markers.d.ts +2 -2
- package/dist/packages/internal/template-contracts/dist/media-candidates.js +38 -0
- package/dist/packages/internal/template-contracts/dist/mirror-kind.js +48 -0
- package/dist/packages/internal/template-contracts/dist/number-display.js +10 -0
- package/dist/packages/internal/template-contracts/dist/object.d.ts +89 -0
- package/dist/packages/internal/template-contracts/dist/object.js +131 -0
- package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.d.ts +1 -0
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +162 -0
- package/dist/packages/internal/template-contracts/dist/process-builders.d.ts +77 -0
- package/dist/packages/internal/template-contracts/dist/process-builders.js +73 -0
- package/dist/packages/internal/template-contracts/dist/read-graph.js +240 -0
- package/dist/packages/internal/template-contracts/dist/ref-locate.js +176 -0
- package/dist/packages/internal/template-contracts/dist/registry-aliases.js +77 -0
- package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +270 -0
- package/dist/packages/internal/template-contracts/dist/registry-facts.js +202 -0
- package/dist/packages/internal/template-contracts/dist/registry-shape.d.ts +41 -0
- package/dist/packages/internal/template-contracts/dist/registry-shape.js +135 -0
- package/dist/packages/internal/template-contracts/dist/resolve-scope.js +103 -0
- package/dist/packages/internal/{image-descriptor/dist/index.d.ts → template-contracts/dist/responsive-image.d.ts} +1 -1
- package/dist/packages/internal/template-contracts/dist/row-planners.js +29 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +127 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.js +101 -0
- package/dist/packages/internal/template-contracts/dist/row-sources.js +41 -5
- package/dist/packages/internal/template-contracts/dist/row.d.ts +155 -0
- package/dist/packages/internal/template-contracts/dist/row.js +84 -0
- package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +97 -0
- package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +782 -0
- package/dist/packages/internal/template-contracts/dist/slot-builders.js +233 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +233 -405
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +331 -227
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +21 -0
- package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +155 -0
- package/dist/packages/internal/template-contracts/dist/slot-ref.js +76 -0
- package/dist/packages/internal/template-contracts/dist/slot-types.d.ts +163 -0
- package/dist/packages/internal/template-contracts/dist/slot-types.js +139 -0
- package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +95 -0
- package/dist/packages/internal/template-contracts/dist/table-members.d.ts +25 -0
- package/dist/packages/internal/template-contracts/dist/table-members.js +90 -0
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +5 -5
- package/dist/packages/internal/template-contracts/dist/value-contracts.js +15 -0
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +2 -2
- package/dist/platform/fs.js +5 -2
- package/dist/playground/canvas-island-host.d.ts +11 -0
- package/dist/playground/canvas-island-host.js +29 -0
- package/dist/playground/canvas-markers.js +14 -0
- package/dist/playground-island-runtime.d.ts +3 -2
- package/dist/playground-island-runtime.js +3 -2
- package/dist/primitives/FrameShell.js +0 -1
- package/dist/primitives/Image.d.ts +5 -4
- package/dist/primitives/Tour.d.ts +1 -1
- package/dist/primitives/Video.d.ts +2 -2
- package/dist/primitives/index.d.ts +2 -3
- package/dist/primitives/picture-sources.js +2 -2
- package/dist/primitives/probe-context.js +2 -12
- package/dist/primitives/slot-address.d.ts +44 -0
- package/dist/primitives/slot-address.js +19 -0
- package/dist/primitives/slot-bindings.d.ts +65 -26
- package/dist/primitives/slot-bindings.js +104 -46
- package/dist/primitives/slot-document.d.ts +23 -18
- package/dist/primitives/slot-document.js +39 -14
- package/dist/primitives/slot-download.d.ts +39 -0
- package/dist/primitives/slot-download.js +39 -0
- package/dist/primitives/slot-list.d.ts +3 -3
- package/dist/primitives/slot-list.js +0 -2
- package/dist/primitives/slot-media.d.ts +24 -5
- package/dist/primitives/slot-media.js +6 -9
- package/dist/primitives/slot-object.d.ts +49 -0
- package/dist/primitives/slot-object.js +20 -0
- package/dist/primitives/slot-scalar.d.ts +27 -2
- package/dist/primitives/slot-scalar.js +50 -7
- package/dist/primitives/slot.d.ts +13 -6
- package/dist/primitives/slot.js +10 -3
- package/dist/rules/registry.js +25 -30
- package/dist/schema/define-schema.d.ts +4 -8
- package/dist/schema/define-schema.js +178 -79
- package/dist/schema/extract-fill-spec.js +2 -153
- package/dist/schema/fact.d.ts +57 -15
- package/dist/schema/fact.js +42 -7
- package/dist/schema/facts-view.d.ts +14 -0
- package/dist/schema/format.d.ts +1 -0
- package/dist/schema/format.js +2 -1
- package/dist/schema/manifest.js +24 -0
- package/dist/schema/property-facts.d.ts +8 -12
- package/dist/schema/section-props.d.ts +2 -66
- package/dist/schema/section-schema.d.ts +8 -11
- package/dist/schema/section-schema.js +27 -10
- package/dist/section/declare.d.ts +18 -7
- package/dist/section/declare.js +18 -5
- package/dist/section/materialize.js +3 -8
- package/dist/section/section.d.ts +12 -8
- package/dist/section/section.js +1 -1
- package/dist/template/logic-shim.d.ts +14 -7
- package/dist/template/logic-shim.js +14 -7
- package/dist/template/materialize.js +17 -18
- package/dist/template/mirror-types.js +30 -31
- package/dist/template/section-reads.js +85 -9
- package/guide/reference/cli/INDEX.md +2 -2
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +1 -1
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +2 -2
- package/guide/reference/cli/publish.md +1 -1
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +29 -25
- package/package.json +9 -8
- package/dist/artifact/playground/client/assets/index-CckS2ONm.css +0 -1
- package/dist/artifact/playground/client/assets/index-Dn_xT16-.js +0 -1101
- package/dist/fixtures/canonical.d.ts +0 -166
- package/dist/fixtures/media.js +0 -163
- package/dist/packages/internal/fill-vocabulary/dist/origination.js +0 -51
- package/dist/packages/internal/fill-vocabulary/dist/row-reads.js +0 -15
- package/dist/packages/internal/format-geometry/dist/index.js +0 -4
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +0 -10
- package/dist/packages/internal/property-facts/dist/index.js +0 -3
- package/dist/packages/internal/property-facts/dist/property-facts-Cy7-O4p0.js +0 -189
- package/dist/packages/internal/section-contracts/dist/group-contract.js +0 -19
- package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +0 -24
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +0 -22
- package/dist/packages/internal/template-contracts/dist/facts-view.js +0 -104
- package/dist/packages/internal/template-contracts/dist/select-key.js +0 -7
- package/dist/primitives/slot-group.d.ts +0 -40
- package/dist/primitives/slot-group.js +0 -36
- package/dist/schema/extract-used-facts.js +0 -34
- package/dist/schema/fill-builders.d.ts +0 -115
- package/dist/schema/fill-builders.js +0 -25
- package/dist/schema/fill-declaration.d.ts +0 -14
- package/dist/schema/fill-spec.js +0 -98
- package/dist/schema/layout.d.ts +0 -30
- package/dist/schema/layout.js +0 -14
- package/dist/schema/row-fields.js +0 -88
- package/dist/schema/row-ref.d.ts +0 -59
- package/dist/schema/row-ref.js +0 -28
- package/dist/schema/runtime-values.d.ts +0 -71
- package/dist/schema/section-nav.js +0 -14
- package/dist/schema/slot-builders.d.ts +0 -633
- package/dist/schema/slot-builders.js +0 -177
- package/dist/schema/slot-ref.d.ts +0 -79
- package/dist/schema/slot-ref.js +0 -41
- package/dist/schema/slot-types.d.ts +0 -111
- package/dist/schema/slot-types.js +0 -214
- package/dist/section/groups.js +0 -68
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { cropsPart } from "../../template-contracts/dist/registry-facts.js";
|
|
2
|
+
import { cropKeyOwner } from "./crop-key.js";
|
|
3
|
+
import { readLadder } from "./store.js";
|
|
4
|
+
import { placeCrop } from "../../template-contracts/dist/content-pick.js";
|
|
5
|
+
|
|
6
|
+
//#region ../../internal/media-resolution/dist/image.js
|
|
7
|
+
function emptyImage() {
|
|
8
|
+
return {
|
|
9
|
+
photo_id: "",
|
|
10
|
+
url: "",
|
|
11
|
+
alt: ""
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function servedKeyOf(asset, mask) {
|
|
15
|
+
const maskKey = mask === void 0 ? void 0 : asset.renditions[mask === "white" ? "mask_white" : "mask_black"]?.key;
|
|
16
|
+
const cutKey = cropsPart(asset.crop) ? asset.renditions.crop?.key : void 0;
|
|
17
|
+
return maskKey ?? asset.renditions.cutout?.key ?? cutKey ?? asset.key;
|
|
18
|
+
}
|
|
19
|
+
async function resolveImageAsset(id, asset, store, opts) {
|
|
20
|
+
if (asset === void 0) {
|
|
21
|
+
store.log?.warn({ id }, "resolve-asset-id: no image asset the render may reach; no asset");
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
if (asset.kind !== "image") {
|
|
25
|
+
store.log?.warn({
|
|
26
|
+
id,
|
|
27
|
+
kind: asset.kind
|
|
28
|
+
}, "resolve-asset-id: asset is not an image; no asset");
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const servedKey = servedKeyOf(asset, opts?.mask);
|
|
33
|
+
return {
|
|
34
|
+
url: await store.servedUrl(servedKey),
|
|
35
|
+
source_key: servedKey
|
|
36
|
+
};
|
|
37
|
+
} catch (err) {
|
|
38
|
+
store.log?.error({
|
|
39
|
+
id,
|
|
40
|
+
err: err.message
|
|
41
|
+
}, "resolve-asset-id: presign failed; no asset");
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function clamp01(n) {
|
|
46
|
+
return n < 0 ? 0 : n > 1 ? 1 : n;
|
|
47
|
+
}
|
|
48
|
+
function normalizeRect(v) {
|
|
49
|
+
const nx = typeof v.nx === "number" ? v.nx : 0;
|
|
50
|
+
const ny = typeof v.ny === "number" ? v.ny : 0;
|
|
51
|
+
const nw = typeof v.nw === "number" ? v.nw : 1;
|
|
52
|
+
const nh = typeof v.nh === "number" ? v.nh : 1;
|
|
53
|
+
if (![
|
|
54
|
+
nx,
|
|
55
|
+
ny,
|
|
56
|
+
nw,
|
|
57
|
+
nh
|
|
58
|
+
].every(Number.isFinite)) return null;
|
|
59
|
+
const r = {
|
|
60
|
+
nx: clamp01(nx),
|
|
61
|
+
ny: clamp01(ny),
|
|
62
|
+
nw: clamp01(nw),
|
|
63
|
+
nh: clamp01(nh)
|
|
64
|
+
};
|
|
65
|
+
if (r.nx === 0 && r.ny === 0 && r.nw === 1 && r.nh === 1) return null;
|
|
66
|
+
return r;
|
|
67
|
+
}
|
|
68
|
+
function renditionKey(rendition) {
|
|
69
|
+
const key = rendition && typeof rendition === "object" ? rendition.key : void 0;
|
|
70
|
+
return typeof key === "string" && key.length > 0 ? key : null;
|
|
71
|
+
}
|
|
72
|
+
function framingCrop(framing, at, mobile) {
|
|
73
|
+
const rect = framing.rect && typeof framing.rect === "object" ? normalizeRect(framing.rect) : null;
|
|
74
|
+
const stored = rect === null ? null : {
|
|
75
|
+
x: rect.nx,
|
|
76
|
+
y: rect.ny,
|
|
77
|
+
width: rect.nw,
|
|
78
|
+
height: rect.nh
|
|
79
|
+
};
|
|
80
|
+
return at === void 0 ? stored : placeCrop(stored, at.imageAspect, at.aspects, mobile);
|
|
81
|
+
}
|
|
82
|
+
function cutKeyOf(framing, photoId, crop) {
|
|
83
|
+
if (!cropsPart(crop)) return null;
|
|
84
|
+
const key = renditionKey((framing.renditions && typeof framing.renditions === "object" ? framing.renditions : {}).crop) ?? (typeof framing.crop_key === "string" && framing.crop_key.length > 0 ? framing.crop_key : null);
|
|
85
|
+
return key !== null && cropKeyOwner(key) === photoId ? key : null;
|
|
86
|
+
}
|
|
87
|
+
function slotCutKey(v, at) {
|
|
88
|
+
return cutKeyOf(v, readAssetId(v), framingCrop(v, at));
|
|
89
|
+
}
|
|
90
|
+
function mobileCutKey(v, at) {
|
|
91
|
+
const mobile = v.mobile && typeof v.mobile === "object" ? v.mobile : at === void 0 ? null : {};
|
|
92
|
+
return mobile === null ? null : cutKeyOf(mobile, readAssetId(v), framingCrop(mobile, at, "mobile"));
|
|
93
|
+
}
|
|
94
|
+
async function mobileCropUrl(key, store) {
|
|
95
|
+
try {
|
|
96
|
+
return { url: await store.servedUrl(key) };
|
|
97
|
+
} catch {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function slotServedKey(v, mask, at) {
|
|
102
|
+
const photoId = readAssetId(v);
|
|
103
|
+
const renditions = v.renditions && typeof v.renditions === "object" ? v.renditions : {};
|
|
104
|
+
const own = (name) => {
|
|
105
|
+
const key = renditionKey(renditions[name]);
|
|
106
|
+
return key !== null && key.startsWith(`processed/cutout/${photoId}/`) ? key : null;
|
|
107
|
+
};
|
|
108
|
+
return (mask === null ? null : own(mask === "white" ? "mask_white" : "mask_black")) ?? own("cutout") ?? (mask === null ? slotCutKey(v, at) : null);
|
|
109
|
+
}
|
|
110
|
+
function readAssetId(v) {
|
|
111
|
+
return typeof v.asset_id === "string" ? v.asset_id : "";
|
|
112
|
+
}
|
|
113
|
+
async function resolveImageValue(value, assets, store, aspects) {
|
|
114
|
+
if (value === null) return {
|
|
115
|
+
value: null,
|
|
116
|
+
desktopKey: null,
|
|
117
|
+
mobileKey: null
|
|
118
|
+
};
|
|
119
|
+
if (!value || typeof value !== "object") return {
|
|
120
|
+
value: emptyImage(),
|
|
121
|
+
desktopKey: null,
|
|
122
|
+
mobileKey: null
|
|
123
|
+
};
|
|
124
|
+
const v = value;
|
|
125
|
+
const rect = v.rect && typeof v.rect === "object" ? normalizeRect(v.rect) : null;
|
|
126
|
+
const ar = typeof v.ar === "number" ? v.ar : null;
|
|
127
|
+
const photoId = readAssetId(v);
|
|
128
|
+
const mask = v.mask === "white" || v.mask === "black" ? v.mask : null;
|
|
129
|
+
const asset = photoId ? assets.get(photoId) : void 0;
|
|
130
|
+
const at = aspects === void 0 ? void 0 : {
|
|
131
|
+
aspects,
|
|
132
|
+
imageAspect: imageAspectOf(asset, ar)
|
|
133
|
+
};
|
|
134
|
+
const mobileKey = photoId ? mobileCutKey(v, at) : null;
|
|
135
|
+
const mobile = mobileKey ? await mobileCropUrl(mobileKey, store) : null;
|
|
136
|
+
const alt = typeof v.alt === "string" ? v.alt : "";
|
|
137
|
+
const placedKey = photoId ? slotServedKey(v, mask, at) : null;
|
|
138
|
+
let base;
|
|
139
|
+
let desktopKey;
|
|
140
|
+
if (placedKey) {
|
|
141
|
+
base = {
|
|
142
|
+
photo_id: photoId,
|
|
143
|
+
url: await store.servedUrl(placedKey),
|
|
144
|
+
alt
|
|
145
|
+
};
|
|
146
|
+
desktopKey = placedKey;
|
|
147
|
+
const uncropped = await resolveImageAsset(photoId, asset, store);
|
|
148
|
+
if (uncropped && uncropped.url !== base.url) base.download_url = uncropped.url;
|
|
149
|
+
} else if (photoId) {
|
|
150
|
+
const served = await resolveImageAsset(photoId, asset, store, mask ? { mask } : void 0);
|
|
151
|
+
if (!served) return {
|
|
152
|
+
value: withUnit(emptyImage(), v),
|
|
153
|
+
desktopKey: null,
|
|
154
|
+
mobileKey
|
|
155
|
+
};
|
|
156
|
+
base = {
|
|
157
|
+
photo_id: photoId,
|
|
158
|
+
url: served.url,
|
|
159
|
+
alt
|
|
160
|
+
};
|
|
161
|
+
desktopKey = served.source_key;
|
|
162
|
+
} else if (typeof v.url === "string" && v.url.length > 0) {
|
|
163
|
+
base = {
|
|
164
|
+
photo_id: "",
|
|
165
|
+
url: v.url,
|
|
166
|
+
alt
|
|
167
|
+
};
|
|
168
|
+
desktopKey = null;
|
|
169
|
+
} else return {
|
|
170
|
+
value: withUnit(emptyImage(), v),
|
|
171
|
+
desktopKey: null,
|
|
172
|
+
mobileKey: null
|
|
173
|
+
};
|
|
174
|
+
return {
|
|
175
|
+
value: withUnit(attach(base, rect, ar, mobile), v),
|
|
176
|
+
desktopKey,
|
|
177
|
+
mobileKey: mobile ? mobileKey : null
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
function imageAspectOf(asset, ar) {
|
|
181
|
+
if (asset?.kind === "image" && asset.width !== null && asset.height !== null && asset.width > 0 && asset.height > 0) return asset.width / asset.height;
|
|
182
|
+
return ar !== null && ar > 0 ? ar : null;
|
|
183
|
+
}
|
|
184
|
+
async function attachResponsive(entries, store) {
|
|
185
|
+
const ladder = await readLadder(store, entries.flatMap((entry) => [entry.desktopKey, entry.mobileKey]).filter((k) => !!k));
|
|
186
|
+
for (const entry of entries) {
|
|
187
|
+
if (!entry.value) continue;
|
|
188
|
+
const responsive = await ladder.responsiveFor(entry.desktopKey);
|
|
189
|
+
if (responsive) entry.value.responsive = responsive;
|
|
190
|
+
if (entry.value.mobile && entry.mobileKey) {
|
|
191
|
+
const mobileResponsive = await ladder.responsiveFor(entry.mobileKey);
|
|
192
|
+
if (mobileResponsive) entry.value.mobile = {
|
|
193
|
+
...entry.value.mobile,
|
|
194
|
+
responsive: mobileResponsive
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
async function resolveImageSlot(value, assets, store, aspects) {
|
|
200
|
+
const entry = await resolveImageValue(value, assets, store, aspects);
|
|
201
|
+
await attachResponsive([entry], store);
|
|
202
|
+
return entry.value;
|
|
203
|
+
}
|
|
204
|
+
function withUnit(resolved, v) {
|
|
205
|
+
const unitId = v.unit_id;
|
|
206
|
+
const unitLabel = v.unit_label;
|
|
207
|
+
if (typeof unitId === "string") resolved.unit_id = unitId;
|
|
208
|
+
else if (unitId === null) resolved.unit_id = null;
|
|
209
|
+
if (typeof unitLabel === "string") resolved.unit_label = unitLabel;
|
|
210
|
+
else if (unitLabel === null) resolved.unit_label = null;
|
|
211
|
+
if ("floor_label" in v) {
|
|
212
|
+
const floorLabel = typeof v.floor_label === "string" ? v.floor_label : null;
|
|
213
|
+
resolved.floor_label = floorLabel;
|
|
214
|
+
if (resolved.alt === "") resolved.alt = floorLabel ?? "Floor plan";
|
|
215
|
+
}
|
|
216
|
+
return resolved;
|
|
217
|
+
}
|
|
218
|
+
function attach(base, rect, ar, mobile) {
|
|
219
|
+
if (rect) base.rect = rect;
|
|
220
|
+
if (ar) base.ar = ar;
|
|
221
|
+
if (mobile) base.mobile = mobile;
|
|
222
|
+
return base;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
//#endregion
|
|
226
|
+
export { attachResponsive, emptyImage, mobileCutKey, normalizeRect, resolveImageAsset, resolveImageSlot, resolveImageValue, servedKeyOf, slotCutKey };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { cropKeyOwner } from "./crop-key.js";
|
|
2
|
+
import { resolveDocumentSlot } from "./document.js";
|
|
3
|
+
import { attachResponsive, emptyImage, mobileCutKey, normalizeRect, resolveImageAsset, resolveImageSlot, resolveImageValue, servedKeyOf, slotCutKey } from "./image.js";
|
|
4
|
+
import { resolveTourSlot } from "./tour.js";
|
|
5
|
+
import { resolveVideoSlot } from "./video.js";
|
|
6
|
+
import { resolveMediaSlot } from "./media.js";
|
|
7
|
+
import { itemContentOf, resolveListSlot } from "./list.js";
|
|
8
|
+
import { recordsOf } from "./records.js";
|
|
9
|
+
import { resolveSlotValue } from "./slot.js";
|
|
10
|
+
|
|
11
|
+
export { cropKeyOwner, recordsOf, resolveSlotValue };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { resolveDocumentSlot } from "./document.js";
|
|
2
|
+
import { slotCropAspects } from "../../template-contracts/dist/content-pick.js";
|
|
3
|
+
import { attachResponsive, emptyImage, resolveImageValue } from "./image.js";
|
|
4
|
+
import { resolveTourSlot } from "./tour.js";
|
|
5
|
+
import { resolveVideoSlot } from "./video.js";
|
|
6
|
+
import { resolveMediaSlot } from "./media.js";
|
|
7
|
+
|
|
8
|
+
//#region ../../internal/media-resolution/dist/list.js
|
|
9
|
+
function primitiveOf(type) {
|
|
10
|
+
if (type === "image") return "image";
|
|
11
|
+
if (type === "video") return "video";
|
|
12
|
+
if (type === "tour") return "tour";
|
|
13
|
+
if (type === "document") return "document";
|
|
14
|
+
if (type === "media") return "media";
|
|
15
|
+
if (type === "poi") return "poi";
|
|
16
|
+
return "scalar";
|
|
17
|
+
}
|
|
18
|
+
function itemContentOf(slot) {
|
|
19
|
+
if (slot?.type !== "list") return null;
|
|
20
|
+
const fields = slot.element?.type === "object" ? slot.element?.fields : void 0;
|
|
21
|
+
return fields != null ? {
|
|
22
|
+
kind: "record",
|
|
23
|
+
fields
|
|
24
|
+
} : {
|
|
25
|
+
kind: "primitive",
|
|
26
|
+
primitive: primitiveOf(slot.element?.type)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async function resolveListSlot(value, slot, ctx) {
|
|
30
|
+
if (!Array.isArray(value)) return [];
|
|
31
|
+
const content = itemContentOf(slot);
|
|
32
|
+
if (content === null) return value;
|
|
33
|
+
return content.kind === "record" ? resolveRecordItems(value, content.fields, ctx) : resolvePrimitiveItems(value, content.primitive, ctx, slot.element);
|
|
34
|
+
}
|
|
35
|
+
async function resolvePrimitiveItems(members, primitive, ctx, element) {
|
|
36
|
+
switch (primitive) {
|
|
37
|
+
case "image": {
|
|
38
|
+
const entries = [];
|
|
39
|
+
for (const member of members) entries.push(await resolveImageValue(member, ctx.assets, ctx.store, slotCropAspects(element?.crop)));
|
|
40
|
+
await attachResponsive(entries, ctx.store);
|
|
41
|
+
return entries.map((entry) => entry.value ?? emptyImage());
|
|
42
|
+
}
|
|
43
|
+
case "video": return (await Promise.all(members.map((member) => resolveVideoSlot(member, ctx.assets, ctx.store)))).filter((v) => v !== null);
|
|
44
|
+
case "tour": return (await Promise.all(members.map((member) => resolveTourSlot(member, ctx.assets, ctx.store)))).filter((t) => t !== null);
|
|
45
|
+
case "document": return (await Promise.all(members.map((member) => resolveDocumentSlot(member, ctx.assets, ctx.store)))).filter((d) => d !== null);
|
|
46
|
+
case "media": return (await Promise.all(members.map((member) => resolveMediaSlot(member, element ?? {}, ctx.assets, ctx.store)))).filter((m) => m !== null);
|
|
47
|
+
case "poi": return members.map((member) => ctx.resolvePoi(member));
|
|
48
|
+
case "scalar": return members;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async function resolveRecordItems(rows, fields, ctx) {
|
|
52
|
+
if (!Object.values(fields).some(fieldResolves)) return rows;
|
|
53
|
+
const imageEntries = [];
|
|
54
|
+
const out = await resolveRecordRows(rows, fields, ctx, imageEntries);
|
|
55
|
+
await attachResponsive(imageEntries, ctx.store);
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
async function resolveRecordRows(rows, fields, ctx, batch) {
|
|
59
|
+
const resolvable = Object.entries(fields).filter(([, field]) => fieldResolves(field));
|
|
60
|
+
if (resolvable.length === 0) return rows;
|
|
61
|
+
const out = [];
|
|
62
|
+
for (const rawRow of rows) {
|
|
63
|
+
if (!rawRow || typeof rawRow !== "object" || Array.isArray(rawRow)) {
|
|
64
|
+
out.push(rawRow);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const row = { ...rawRow };
|
|
68
|
+
for (const [fieldId, field] of resolvable) {
|
|
69
|
+
if (!(fieldId in row)) continue;
|
|
70
|
+
row[fieldId] = await resolveField(row[fieldId], field, ctx, batch);
|
|
71
|
+
}
|
|
72
|
+
out.push(row);
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
function fieldResolves(field) {
|
|
77
|
+
if (primitiveOf(field.type) !== "scalar") return true;
|
|
78
|
+
const content = itemContentOf(field);
|
|
79
|
+
if (content === null) return false;
|
|
80
|
+
if (content.kind === "record") return Object.values(content.fields).some(fieldResolves);
|
|
81
|
+
return content.primitive !== "scalar";
|
|
82
|
+
}
|
|
83
|
+
async function resolveField(value, field, ctx, batch) {
|
|
84
|
+
if (itemContentOf(field) !== null) return resolveNestedList(value, field, ctx, batch);
|
|
85
|
+
switch (primitiveOf(field.type)) {
|
|
86
|
+
case "image": {
|
|
87
|
+
const entry = await resolveImageValue(value, ctx.assets, ctx.store, slotCropAspects(field.crop));
|
|
88
|
+
batch.push(entry);
|
|
89
|
+
return entry.value;
|
|
90
|
+
}
|
|
91
|
+
case "video": return resolveVideoSlot(value, ctx.assets, ctx.store);
|
|
92
|
+
case "tour": return resolveTourSlot(value, ctx.assets, ctx.store);
|
|
93
|
+
case "document": return resolveDocumentSlot(value, ctx.assets, ctx.store);
|
|
94
|
+
case "media": return resolveMediaSlot(value, field, ctx.assets, ctx.store);
|
|
95
|
+
case "poi": return ctx.resolvePoi(value);
|
|
96
|
+
case "scalar": return value;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async function resolveNestedList(value, field, ctx, batch) {
|
|
100
|
+
if (!Array.isArray(value)) return [];
|
|
101
|
+
const content = itemContentOf(field);
|
|
102
|
+
if (content === null) return value;
|
|
103
|
+
if (content.kind === "record") return resolveRecordRows(value, content.fields, ctx, batch);
|
|
104
|
+
if (content.primitive !== "image") return resolvePrimitiveItems(value, content.primitive, ctx, field.element);
|
|
105
|
+
const entries = [];
|
|
106
|
+
for (const member of value) entries.push(await resolveImageValue(member, ctx.assets, ctx.store, slotCropAspects(field.element?.crop)));
|
|
107
|
+
batch.push(...entries);
|
|
108
|
+
return entries.map((entry) => entry.value ?? emptyImage());
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
export { itemContentOf, resolveListSlot };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { declaredKinds } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
+
import { resolveDocumentSlot } from "./document.js";
|
|
3
|
+
import { slotCropAspects } from "../../template-contracts/dist/content-pick.js";
|
|
4
|
+
import { resolveImageSlot } from "./image.js";
|
|
5
|
+
import { resolveTourSlot } from "./tour.js";
|
|
6
|
+
import { resolveVideoSlot } from "./video.js";
|
|
7
|
+
|
|
8
|
+
//#region ../../internal/media-resolution/dist/media.js
|
|
9
|
+
async function resolveMediaSlot(value, declaration, assets, store) {
|
|
10
|
+
if (value === null || typeof value !== "object") return null;
|
|
11
|
+
const assetId = value.asset_id;
|
|
12
|
+
if (typeof assetId !== "string" || assetId === "") return null;
|
|
13
|
+
const asset = assets.get(assetId);
|
|
14
|
+
if (asset === void 0) {
|
|
15
|
+
store.log?.warn({ asset_id: assetId }, "resolve-media-slot: no asset the render may reach");
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
if (!declaredKinds(declaration).includes(asset.kind)) {
|
|
19
|
+
store.log?.warn({
|
|
20
|
+
asset_id: assetId,
|
|
21
|
+
kind: asset.kind
|
|
22
|
+
}, "resolve-media-slot: asset is of a kind the slot does not hold");
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const reference = { asset_id: assetId };
|
|
26
|
+
switch (asset.kind) {
|
|
27
|
+
case "image": {
|
|
28
|
+
const image = await resolveImageSlot(value, assets, store, slotCropAspects(declaration.crop));
|
|
29
|
+
return image === null ? null : {
|
|
30
|
+
...image,
|
|
31
|
+
kind: "image"
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
case "video": {
|
|
35
|
+
const video = await resolveVideoSlot(reference, assets, store);
|
|
36
|
+
return video === null ? null : {
|
|
37
|
+
...video,
|
|
38
|
+
kind: "video"
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
case "tour": {
|
|
42
|
+
const tour = await resolveTourSlot(reference, assets, store);
|
|
43
|
+
return tour === null ? null : {
|
|
44
|
+
...tour,
|
|
45
|
+
kind: "tour"
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
case "document": {
|
|
49
|
+
const document = await resolveDocumentSlot(reference, assets, store);
|
|
50
|
+
return document === null ? null : {
|
|
51
|
+
...document,
|
|
52
|
+
kind: "document"
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
export { resolveMediaSlot };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { resolveDocumentSlot } from "./document.js";
|
|
2
|
+
import { slotCropAspects } from "../../template-contracts/dist/content-pick.js";
|
|
3
|
+
import { resolveImageSlot } from "./image.js";
|
|
4
|
+
import { resolveTourSlot } from "./tour.js";
|
|
5
|
+
import { resolveVideoSlot } from "./video.js";
|
|
6
|
+
import { resolveMediaSlot } from "./media.js";
|
|
7
|
+
import { itemContentOf, resolveListSlot } from "./list.js";
|
|
8
|
+
|
|
9
|
+
//#region ../../internal/media-resolution/dist/slot.js
|
|
10
|
+
async function resolveSlotValue(value, slot, ctx) {
|
|
11
|
+
if (slot === void 0) return value;
|
|
12
|
+
if (itemContentOf(slot) !== null) return resolveListSlot(value, slot, ctx);
|
|
13
|
+
switch (slot.type) {
|
|
14
|
+
case "image": return resolveImageSlot(value, ctx.assets, ctx.store, slotCropAspects(slot.crop));
|
|
15
|
+
case "video": return resolveVideoSlot(value, ctx.assets, ctx.store);
|
|
16
|
+
case "tour": return resolveTourSlot(value, ctx.assets, ctx.store);
|
|
17
|
+
case "document": return resolveDocumentSlot(value, ctx.assets, ctx.store);
|
|
18
|
+
case "media": return resolveMediaSlot(value, slot, ctx.assets, ctx.store);
|
|
19
|
+
case "poi": return ctx.resolvePoi(value);
|
|
20
|
+
case "object": return resolveObject(value, slot, ctx);
|
|
21
|
+
default: return value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function resolveObject(value, slot, ctx) {
|
|
25
|
+
if (slot.fields == null || !value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
26
|
+
const [row] = await resolveListSlot([value], {
|
|
27
|
+
type: "list",
|
|
28
|
+
element: {
|
|
29
|
+
type: "object",
|
|
30
|
+
fields: slot.fields
|
|
31
|
+
}
|
|
32
|
+
}, ctx);
|
|
33
|
+
return row;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { resolveSlotValue };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region ../../internal/media-resolution/dist/store.js
|
|
2
|
+
const NO_LADDER = { responsiveFor: () => Promise.resolve(null) };
|
|
3
|
+
async function readLadder(store, keys) {
|
|
4
|
+
try {
|
|
5
|
+
const ladder = await store.ladder(keys);
|
|
6
|
+
return { responsiveFor: async (key) => {
|
|
7
|
+
try {
|
|
8
|
+
return await ladder.responsiveFor(key);
|
|
9
|
+
} catch {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
} };
|
|
13
|
+
} catch {
|
|
14
|
+
return NO_LADDER;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { readLadder };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { tourEmbedUrl } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
+
import { readLadder } from "./store.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../internal/media-resolution/dist/tour.js
|
|
5
|
+
const DEFAULT = {
|
|
6
|
+
tour_id: "",
|
|
7
|
+
url: "",
|
|
8
|
+
poster: "",
|
|
9
|
+
alt: ""
|
|
10
|
+
};
|
|
11
|
+
async function attachPosterResponsive(out, previewKey, store) {
|
|
12
|
+
if (!previewKey || !out.poster) return out;
|
|
13
|
+
const responsive = await (await readLadder(store, [previewKey])).responsiveFor(previewKey);
|
|
14
|
+
if (responsive) out.poster_responsive = responsive;
|
|
15
|
+
return out;
|
|
16
|
+
}
|
|
17
|
+
async function resolveTourSlot(value, assets, store) {
|
|
18
|
+
if (value === null) return null;
|
|
19
|
+
if (typeof value !== "object") return DEFAULT;
|
|
20
|
+
const v = value;
|
|
21
|
+
const tourId = typeof v.asset_id === "string" ? v.asset_id : "";
|
|
22
|
+
if (!tourId) return DEFAULT;
|
|
23
|
+
const asset = assets.get(tourId);
|
|
24
|
+
if (asset === void 0) {
|
|
25
|
+
store.log?.warn({ tour_id: tourId }, "resolve-tour-slot: no tour asset the render may reach");
|
|
26
|
+
return DEFAULT;
|
|
27
|
+
}
|
|
28
|
+
if (asset.kind !== "tour") {
|
|
29
|
+
store.log?.warn({
|
|
30
|
+
tour_id: tourId,
|
|
31
|
+
kind: asset.kind
|
|
32
|
+
}, "resolve-tour-slot: asset is not a tour");
|
|
33
|
+
return DEFAULT;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const embed = tourEmbedUrl(asset.url);
|
|
37
|
+
if (embed === null) {
|
|
38
|
+
store.log?.warn({ tour_id: tourId }, "resolve-tour-slot: tour link embeds nowhere");
|
|
39
|
+
return DEFAULT;
|
|
40
|
+
}
|
|
41
|
+
const posterKey = asset.renditions.poster?.key ?? null;
|
|
42
|
+
return attachPosterResponsive({
|
|
43
|
+
tour_id: tourId,
|
|
44
|
+
url: embed,
|
|
45
|
+
poster: posterKey ? await store.fileUrl(posterKey) : "",
|
|
46
|
+
alt: typeof v.alt === "string" ? v.alt : "",
|
|
47
|
+
provider: asset.provider
|
|
48
|
+
}, posterKey, store);
|
|
49
|
+
} catch (err) {
|
|
50
|
+
store.log?.error({
|
|
51
|
+
tour_id: tourId,
|
|
52
|
+
err: err.message
|
|
53
|
+
}, "resolve-tour-slot: presign failed; soft-empty tour");
|
|
54
|
+
return DEFAULT;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
export { resolveTourSlot };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { videoEmbedUrl } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
+
import { videoSourceOf } from "../../template-contracts/dist/registry-facts.js";
|
|
3
|
+
import { readLadder } from "./store.js";
|
|
4
|
+
|
|
5
|
+
//#region ../../internal/media-resolution/dist/video.js
|
|
6
|
+
const DEFAULT = {
|
|
7
|
+
video_id: "",
|
|
8
|
+
url: "",
|
|
9
|
+
poster: "",
|
|
10
|
+
alt: ""
|
|
11
|
+
};
|
|
12
|
+
async function attachPosterResponsive(out, previewKey, store) {
|
|
13
|
+
if (!previewKey || !out.poster) return out;
|
|
14
|
+
const responsive = await (await readLadder(store, [previewKey])).responsiveFor(previewKey);
|
|
15
|
+
if (responsive) out.poster_responsive = responsive;
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
18
|
+
async function resolveVideoSlot(value, assets, store) {
|
|
19
|
+
if (value === null) return null;
|
|
20
|
+
if (typeof value !== "object") return DEFAULT;
|
|
21
|
+
const v = value;
|
|
22
|
+
const videoId = typeof v.asset_id === "string" ? v.asset_id : "";
|
|
23
|
+
if (!videoId) return DEFAULT;
|
|
24
|
+
const asset = assets.get(videoId);
|
|
25
|
+
if (asset === void 0) {
|
|
26
|
+
store.log?.warn({ video_id: videoId }, "resolve-video-slot: no video asset the render may reach");
|
|
27
|
+
return DEFAULT;
|
|
28
|
+
}
|
|
29
|
+
if (asset.kind !== "video") {
|
|
30
|
+
store.log?.warn({
|
|
31
|
+
video_id: videoId,
|
|
32
|
+
kind: asset.kind
|
|
33
|
+
}, "resolve-video-slot: asset is not a video");
|
|
34
|
+
return DEFAULT;
|
|
35
|
+
}
|
|
36
|
+
const posterKey = asset.renditions.poster?.key ?? null;
|
|
37
|
+
const alt = typeof v.alt === "string" ? v.alt : "";
|
|
38
|
+
try {
|
|
39
|
+
if (videoSourceOf(asset) === "link") {
|
|
40
|
+
const url = asset.url;
|
|
41
|
+
const embed = videoEmbedUrl(url);
|
|
42
|
+
if (!embed) {
|
|
43
|
+
store.log?.warn({ video_id: videoId }, "resolve-video-slot: link upload embeds nowhere");
|
|
44
|
+
return DEFAULT;
|
|
45
|
+
}
|
|
46
|
+
const out = {
|
|
47
|
+
video_id: videoId,
|
|
48
|
+
url: embed,
|
|
49
|
+
poster: posterKey ? await store.fileUrl(posterKey) : "",
|
|
50
|
+
alt,
|
|
51
|
+
source: "link"
|
|
52
|
+
};
|
|
53
|
+
if (asset.provider !== null) out.provider = asset.provider;
|
|
54
|
+
return attachPosterResponsive(out, posterKey, store);
|
|
55
|
+
}
|
|
56
|
+
const poster = posterKey ? await store.fileUrl(posterKey) : "";
|
|
57
|
+
const encode = asset.renditions.encode;
|
|
58
|
+
if (encode === null) {
|
|
59
|
+
store.log?.warn({
|
|
60
|
+
video_id: videoId,
|
|
61
|
+
state: asset.state
|
|
62
|
+
}, "resolve-video-slot: no encode; poster-only");
|
|
63
|
+
if (asset.state !== "failed") store.notePending?.({
|
|
64
|
+
kind: "video",
|
|
65
|
+
id: videoId
|
|
66
|
+
});
|
|
67
|
+
return attachPosterResponsive({
|
|
68
|
+
video_id: videoId,
|
|
69
|
+
url: "",
|
|
70
|
+
poster,
|
|
71
|
+
alt
|
|
72
|
+
}, posterKey, store);
|
|
73
|
+
}
|
|
74
|
+
const out = {
|
|
75
|
+
video_id: videoId,
|
|
76
|
+
url: await store.fileUrl(encode.key),
|
|
77
|
+
poster,
|
|
78
|
+
alt
|
|
79
|
+
};
|
|
80
|
+
if (encode.width !== null) out.width = encode.width;
|
|
81
|
+
if (encode.height !== null) out.height = encode.height;
|
|
82
|
+
return attachPosterResponsive(out, posterKey, store);
|
|
83
|
+
} catch (err) {
|
|
84
|
+
store.log?.error({
|
|
85
|
+
video_id: videoId,
|
|
86
|
+
err: err.message
|
|
87
|
+
}, "resolve-video-slot: presign failed; soft-empty video");
|
|
88
|
+
return DEFAULT;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
//#endregion
|
|
93
|
+
export { resolveVideoSlot };
|