@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,202 @@
|
|
|
1
|
+
import { isMediaKind } from "./slot-catalog.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../internal/template-contracts/dist/registry-facts.js
|
|
4
|
+
const FILE_RENDITION_NAMES = [
|
|
5
|
+
"master",
|
|
6
|
+
"poster",
|
|
7
|
+
"encode"
|
|
8
|
+
];
|
|
9
|
+
const PLACE_RENDITION_NAMES = [
|
|
10
|
+
"crop",
|
|
11
|
+
"cutout",
|
|
12
|
+
"mask_white",
|
|
13
|
+
"mask_black"
|
|
14
|
+
];
|
|
15
|
+
const RENDITION_NAMES = [
|
|
16
|
+
"master",
|
|
17
|
+
"crop",
|
|
18
|
+
"cutout",
|
|
19
|
+
"mask_white",
|
|
20
|
+
"mask_black",
|
|
21
|
+
"poster",
|
|
22
|
+
"encode"
|
|
23
|
+
];
|
|
24
|
+
function cropsPart(crop) {
|
|
25
|
+
return crop !== null && !(crop.x <= 0 && crop.y <= 0 && crop.width >= 1 && crop.height >= 1);
|
|
26
|
+
}
|
|
27
|
+
function fileNameOf(file) {
|
|
28
|
+
if (file.url !== null) return file.url.replace(/^[a-z][a-z0-9+.-]*:\/\//i, "");
|
|
29
|
+
return file.key?.split("/").pop() ?? file.id;
|
|
30
|
+
}
|
|
31
|
+
function mergeMedia(file, value) {
|
|
32
|
+
const { id: _fileId, renditions, ...members } = file;
|
|
33
|
+
const crops = file.kind === "image";
|
|
34
|
+
return {
|
|
35
|
+
...members,
|
|
36
|
+
id: value.id,
|
|
37
|
+
file: value.file,
|
|
38
|
+
crop: crops ? value.crop : null,
|
|
39
|
+
name: value.name !== null && value.name !== "" ? value.name : fileNameOf(file),
|
|
40
|
+
renditions: {
|
|
41
|
+
...renditions,
|
|
42
|
+
crop: crops ? value.renditions.crop : null,
|
|
43
|
+
cutout: crops ? value.renditions.cutout : null,
|
|
44
|
+
mask_white: crops ? value.renditions.mask_white : null,
|
|
45
|
+
mask_black: crops ? value.renditions.mask_black : null
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function splitMedia(record) {
|
|
50
|
+
const { id, file, crop, name, renditions, ...members } = record;
|
|
51
|
+
const { crop: cut, cutout, mask_white, mask_black, ...fileRenditions } = renditions;
|
|
52
|
+
return {
|
|
53
|
+
file: {
|
|
54
|
+
...members,
|
|
55
|
+
id: file,
|
|
56
|
+
renditions: fileRenditions
|
|
57
|
+
},
|
|
58
|
+
value: {
|
|
59
|
+
id,
|
|
60
|
+
file,
|
|
61
|
+
crop,
|
|
62
|
+
name,
|
|
63
|
+
renditions: {
|
|
64
|
+
crop: cut,
|
|
65
|
+
cutout,
|
|
66
|
+
mask_white,
|
|
67
|
+
mask_black
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function videoSourceOf(video) {
|
|
73
|
+
return video.url === null ? "upload" : "link";
|
|
74
|
+
}
|
|
75
|
+
function isObject(value) {
|
|
76
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
77
|
+
}
|
|
78
|
+
function isMediaRecord(value) {
|
|
79
|
+
if (!isObject(value)) return false;
|
|
80
|
+
const { id, kind, renditions } = value;
|
|
81
|
+
return typeof id === "string" && typeof kind === "string" && isMediaKind(kind) && isObject(renditions);
|
|
82
|
+
}
|
|
83
|
+
function isHomeMediaValue(value) {
|
|
84
|
+
return isObject(value) && typeof value["id"] === "string" && typeof value["file"] === "string" && isObject(value["renditions"]) && !("kind" in value);
|
|
85
|
+
}
|
|
86
|
+
function isContentMediaValue(value) {
|
|
87
|
+
return isObject(value) && typeof value["file"] === "string" && "picked" in value && isObject(value["renditions"]) && !("id" in value);
|
|
88
|
+
}
|
|
89
|
+
function isMediaReference(value) {
|
|
90
|
+
return isObject(value) && typeof value["media"] === "string" && value["media"] !== "";
|
|
91
|
+
}
|
|
92
|
+
function storedReferenceOf(value) {
|
|
93
|
+
const id = value["asset_id"];
|
|
94
|
+
return typeof id === "string" && id !== "" ? id : void 0;
|
|
95
|
+
}
|
|
96
|
+
function mediaIdOf(value) {
|
|
97
|
+
if (!isObject(value)) return void 0;
|
|
98
|
+
if (isMediaReference(value)) return value.media;
|
|
99
|
+
if (isHomeMediaValue(value) || isMediaRecord(value)) return value.id;
|
|
100
|
+
if (isContentMediaValue(value)) return value.picked ?? value.file;
|
|
101
|
+
return storedReferenceOf(value);
|
|
102
|
+
}
|
|
103
|
+
function collectOwning(value, into) {
|
|
104
|
+
if (Array.isArray(value)) for (const item of value) collectOwning(item, into);
|
|
105
|
+
else if (isHomeMediaValue(value)) {
|
|
106
|
+
if (!into.has(value.id)) into.set(value.id, value);
|
|
107
|
+
} else if (isObject(value) && !isMediaRecord(value)) for (const member of Object.values(value)) collectOwning(member, into);
|
|
108
|
+
}
|
|
109
|
+
function owningValues(document) {
|
|
110
|
+
const out = /* @__PURE__ */ new Map();
|
|
111
|
+
for (const [key, value] of Object.entries(document)) if (key !== "files") collectOwning(value, out);
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
114
|
+
function fileIn(document, id) {
|
|
115
|
+
return Object.hasOwn(document.files, id) ? document.files[id] : void 0;
|
|
116
|
+
}
|
|
117
|
+
function recordOf(value, document) {
|
|
118
|
+
const file = fileIn(document, value.file);
|
|
119
|
+
return file === void 0 ? null : mergeMedia(file, value);
|
|
120
|
+
}
|
|
121
|
+
function mediaRecords(document) {
|
|
122
|
+
const out = {};
|
|
123
|
+
for (const [id, value] of owningValues(document)) {
|
|
124
|
+
const record = recordOf(value, document);
|
|
125
|
+
if (record !== null) out[id] = record;
|
|
126
|
+
}
|
|
127
|
+
return out;
|
|
128
|
+
}
|
|
129
|
+
function copyRecordOf(value, document) {
|
|
130
|
+
const file = fileIn(document, value.file);
|
|
131
|
+
if (file === void 0) return null;
|
|
132
|
+
return mergeMedia(file, {
|
|
133
|
+
id: value.picked ?? value.file,
|
|
134
|
+
file: value.file,
|
|
135
|
+
crop: value.crop,
|
|
136
|
+
name: value.name,
|
|
137
|
+
renditions: value.renditions
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function hasOwnFraming(own) {
|
|
141
|
+
return Object.hasOwn(own, "crop") || own.renditions !== void 0;
|
|
142
|
+
}
|
|
143
|
+
function framingOver(inherited, own) {
|
|
144
|
+
const ownCrop = Object.hasOwn(own, "crop");
|
|
145
|
+
const renditions = own.renditions ?? {};
|
|
146
|
+
const base = ownCrop ? null : inherited.renditions;
|
|
147
|
+
const place = Object.fromEntries(PLACE_RENDITION_NAMES.map((name) => [name, Object.hasOwn(renditions, name) ? renditions[name] ?? null : base?.[name] ?? null]));
|
|
148
|
+
return {
|
|
149
|
+
crop: ownCrop ? own.crop ?? null : inherited.crop,
|
|
150
|
+
renditions: place
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function framedAt(record, reference) {
|
|
154
|
+
if (record === null || record.kind !== "image" || !hasOwnFraming(reference)) return record;
|
|
155
|
+
const framing = framingOver({
|
|
156
|
+
crop: record.crop,
|
|
157
|
+
renditions: record.renditions
|
|
158
|
+
}, reference);
|
|
159
|
+
return {
|
|
160
|
+
...record,
|
|
161
|
+
crop: framing.crop,
|
|
162
|
+
renditions: {
|
|
163
|
+
...record.renditions,
|
|
164
|
+
...framing.renditions
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function readAsRecords(value, document) {
|
|
169
|
+
let records;
|
|
170
|
+
const resolve = (id) => {
|
|
171
|
+
records ??= mediaRecords(document);
|
|
172
|
+
return Object.hasOwn(records, id) ? records[id] : null;
|
|
173
|
+
};
|
|
174
|
+
const read = (at) => {
|
|
175
|
+
if (Array.isArray(at)) return at.flatMap((item) => {
|
|
176
|
+
const out = read(item);
|
|
177
|
+
return out === null && item !== null ? [] : [out];
|
|
178
|
+
});
|
|
179
|
+
if (!isObject(at) || isMediaRecord(at)) return at;
|
|
180
|
+
if (isHomeMediaValue(at)) return recordOf(at, document);
|
|
181
|
+
if (isContentMediaValue(at)) return copyRecordOf(at, document);
|
|
182
|
+
if (isMediaReference(at)) return framedAt(resolve(at.media), at);
|
|
183
|
+
const stored = storedReferenceOf(at);
|
|
184
|
+
if (stored !== void 0) return resolve(stored);
|
|
185
|
+
const out = {};
|
|
186
|
+
for (const [key, member] of Object.entries(at)) out[key] = read(member);
|
|
187
|
+
return out;
|
|
188
|
+
};
|
|
189
|
+
return read(value);
|
|
190
|
+
}
|
|
191
|
+
function storedAsRefs(value) {
|
|
192
|
+
if (Array.isArray(value)) return value.map(storedAsRefs);
|
|
193
|
+
if (!isObject(value)) return value;
|
|
194
|
+
if (isMediaRecord(value) || isHomeMediaValue(value)) return { asset_id: value.id };
|
|
195
|
+
if (isMediaReference(value)) return { asset_id: value.media };
|
|
196
|
+
const out = {};
|
|
197
|
+
for (const [key, member] of Object.entries(value)) out[key] = storedAsRefs(member);
|
|
198
|
+
return out;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
//#endregion
|
|
202
|
+
export { FILE_RENDITION_NAMES, PLACE_RENDITION_NAMES, RENDITION_NAMES, cropsPart, fileNameOf, framedAt, framingOver, hasOwnFraming, isContentMediaValue, isHomeMediaValue, isMediaRecord, isMediaReference, mediaIdOf, mediaRecords, mergeMedia, owningValues, readAsRecords, recordOf, splitMedia, storedAsRefs, videoSourceOf };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { LIBRARY_TABLE_KEYS, RegistryTable } from "./slot-catalog.js";
|
|
2
|
+
import { LibraryFactRegistry, PropertyTablePages } from "./fact-registry.js";
|
|
3
|
+
//#region ../../internal/template-contracts/dist/registry-shape.d.ts
|
|
4
|
+
type ItemFieldsOf<Page> = Page extends {
|
|
5
|
+
readonly declaration: {
|
|
6
|
+
readonly element: {
|
|
7
|
+
readonly fields: infer F;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
} ? F : never;
|
|
11
|
+
/**
|
|
12
|
+
* The declarations of a table's members, as the registry types them — the library's
|
|
13
|
+
* contacts, the property's other lists. A property table is read off its own page
|
|
14
|
+
* (`PropertyTablePages`), never off `propertyFacts`: the registry declares the property's
|
|
15
|
+
* contacts from a row's members, which are typed here, so it cannot be read while it is
|
|
16
|
+
* being typed.
|
|
17
|
+
*/
|
|
18
|
+
type TableFieldsOf<T extends RegistryTable> = T extends keyof typeof LIBRARY_TABLE_KEYS ? ItemFieldsOf<LibraryFactRegistry["pages"][T]> : T extends keyof PropertyTablePages ? ItemFieldsOf<PropertyTablePages[T]> : never;
|
|
19
|
+
/** {@link memberValueType}, at the type level. */
|
|
20
|
+
type MemberValueTypeOf<D> = D extends {
|
|
21
|
+
readonly type: "list";
|
|
22
|
+
readonly element: infer E;
|
|
23
|
+
} ? E extends {
|
|
24
|
+
readonly type: "object";
|
|
25
|
+
} ? "row_list" : E extends {
|
|
26
|
+
readonly type: "image";
|
|
27
|
+
} ? "image_list" : E extends {
|
|
28
|
+
readonly type: "number";
|
|
29
|
+
} ? "number_list" : E extends {
|
|
30
|
+
readonly type: "text" | "select" | "email" | "phone" | "url" | "date";
|
|
31
|
+
} ? "text_list" : never : D extends {
|
|
32
|
+
readonly type: "number";
|
|
33
|
+
} ? "number" : D extends {
|
|
34
|
+
readonly type: "image";
|
|
35
|
+
} ? "image" : D extends {
|
|
36
|
+
readonly type: "address";
|
|
37
|
+
} ? "address" : D extends {
|
|
38
|
+
readonly type: "text" | "select" | "email" | "phone" | "url" | "date";
|
|
39
|
+
} ? "text" : never;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { MemberValueTypeOf, TableFieldsOf };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { ADDRESS_MEMBERS } from "./address-value.js";
|
|
2
|
+
import { LIBRARY_TABLE_KEYS, isMediaKind, tableKeyOf } from "./slot-catalog.js";
|
|
3
|
+
import { isFactCompute } from "./fact-compute.js";
|
|
4
|
+
import "./media-candidates.js";
|
|
5
|
+
|
|
6
|
+
//#region ../../internal/template-contracts/dist/registry-shape.js
|
|
7
|
+
const LINKED = /* @__PURE__ */ new Map();
|
|
8
|
+
function linkRegistry(registry) {
|
|
9
|
+
LINKED.set(registry.home, registry);
|
|
10
|
+
}
|
|
11
|
+
function linkedRegistry(home) {
|
|
12
|
+
const registry = LINKED.get(home);
|
|
13
|
+
if (registry === void 0) throw new Error(`fact registry: the ${home} registry is not declared yet — import @homepages/template-contracts/fact-registry (or ./fact-keys, ./table-members) before reading it.`);
|
|
14
|
+
return registry;
|
|
15
|
+
}
|
|
16
|
+
const TEXT_TYPES = /* @__PURE__ */ new Set([
|
|
17
|
+
"text",
|
|
18
|
+
"select",
|
|
19
|
+
"email",
|
|
20
|
+
"phone",
|
|
21
|
+
"url",
|
|
22
|
+
"date"
|
|
23
|
+
]);
|
|
24
|
+
function memberValueType(declaration) {
|
|
25
|
+
switch (declaration.type) {
|
|
26
|
+
case "number":
|
|
27
|
+
case "image":
|
|
28
|
+
case "address": return declaration.type;
|
|
29
|
+
case "list": return listValueType(declaration.element);
|
|
30
|
+
default: return TEXT_TYPES.has(declaration.type) ? "text" : null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function listValueType(element) {
|
|
34
|
+
if (element.type === "object") return "row_list";
|
|
35
|
+
if (element.type === "image") return "image_list";
|
|
36
|
+
if (element.type === "number") return "number_list";
|
|
37
|
+
return TEXT_TYPES.has(element.type) ? "text_list" : null;
|
|
38
|
+
}
|
|
39
|
+
function isMediaListDeclaration(declaration) {
|
|
40
|
+
if (declaration.type !== "list") return false;
|
|
41
|
+
const element = declaration.element.type;
|
|
42
|
+
return isMediaKind(element) || element === "media";
|
|
43
|
+
}
|
|
44
|
+
function mediaListKeysOf(registry) {
|
|
45
|
+
return Object.entries(registry.pages).flatMap(([name, page]) => isMediaListDeclaration(page.declaration) ? [`${registry.home}.${name}`] : []);
|
|
46
|
+
}
|
|
47
|
+
function isDerived(declaration) {
|
|
48
|
+
return isFactCompute(declaration.source);
|
|
49
|
+
}
|
|
50
|
+
const FACTS_READ = /* @__PURE__ */ new WeakMap();
|
|
51
|
+
function registryFactsOf(property) {
|
|
52
|
+
let facts = FACTS_READ.get(property);
|
|
53
|
+
if (facts === void 0) {
|
|
54
|
+
facts = readFacts(property);
|
|
55
|
+
FACTS_READ.set(property, facts);
|
|
56
|
+
}
|
|
57
|
+
return facts;
|
|
58
|
+
}
|
|
59
|
+
function readFacts(registry) {
|
|
60
|
+
const facts = /* @__PURE__ */ new Map();
|
|
61
|
+
for (const [name, page] of Object.entries(registry.pages)) {
|
|
62
|
+
const declaration = page.declaration;
|
|
63
|
+
if (declaration.type === "list") continue;
|
|
64
|
+
const key = `${registry.home}.${name}`;
|
|
65
|
+
if (declaration.type === "address") {
|
|
66
|
+
facts.set(key, {
|
|
67
|
+
declaration,
|
|
68
|
+
value_type: "address"
|
|
69
|
+
});
|
|
70
|
+
for (const part of ADDRESS_MEMBERS) facts.set(`${key}.${part}`, {
|
|
71
|
+
declaration,
|
|
72
|
+
value_type: addressPartValueType(part)
|
|
73
|
+
});
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
facts.set(key, {
|
|
77
|
+
declaration,
|
|
78
|
+
value_type: factValueType(key, declaration)
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return facts;
|
|
82
|
+
}
|
|
83
|
+
function factValueType(key, declaration) {
|
|
84
|
+
if (declaration.type === "image") return "image";
|
|
85
|
+
if (isMediaKind(declaration.type) || declaration.type === "media") throw new Error(`fact registry: ${key} is a single ${declaration.type} — a top-level media fact is an image, the one media value a slot binds.`);
|
|
86
|
+
return declaration.type === "number" ? "number" : "text";
|
|
87
|
+
}
|
|
88
|
+
function addressPartValueType(part) {
|
|
89
|
+
return part === "latitude" || part === "longitude" ? "number" : "text";
|
|
90
|
+
}
|
|
91
|
+
function tableHome(table) {
|
|
92
|
+
return Object.hasOwn(LIBRARY_TABLE_KEYS, table) ? "library" : "property";
|
|
93
|
+
}
|
|
94
|
+
function tableFieldsIn(registry, table) {
|
|
95
|
+
const page = registry.pages[table];
|
|
96
|
+
const element = page?.declaration.type === "list" ? page.declaration.element : void 0;
|
|
97
|
+
if (element?.type !== "object") throw new Error(`fact registry: the ${registry.home} registry declares no list of objects "${table}"`);
|
|
98
|
+
return element.fields;
|
|
99
|
+
}
|
|
100
|
+
function linkedTableFields(table) {
|
|
101
|
+
return tableFieldsIn(linkedRegistry(tableHome(table)), table);
|
|
102
|
+
}
|
|
103
|
+
function fieldOf(fields, member) {
|
|
104
|
+
return Object.hasOwn(fields, member) ? fields[member] : void 0;
|
|
105
|
+
}
|
|
106
|
+
function memberListOfKey(key) {
|
|
107
|
+
if (typeof key !== "string") return null;
|
|
108
|
+
const dot = key.lastIndexOf(".");
|
|
109
|
+
if (dot <= 0) return null;
|
|
110
|
+
const table = tableKeyOf(key.slice(0, dot));
|
|
111
|
+
if (table?.reading !== "registry") return null;
|
|
112
|
+
const member = key.slice(dot + 1);
|
|
113
|
+
const declaration = fieldOf(linkedTableFields(table.table), member);
|
|
114
|
+
return declaration !== void 0 && memberValueType(declaration) === "row_list" ? {
|
|
115
|
+
table,
|
|
116
|
+
member
|
|
117
|
+
} : null;
|
|
118
|
+
}
|
|
119
|
+
function tableColumnOfKey(key) {
|
|
120
|
+
if (typeof key !== "string") return null;
|
|
121
|
+
const dot = key.lastIndexOf(".");
|
|
122
|
+
if (dot <= 0) return null;
|
|
123
|
+
const tableKey = key.slice(0, dot);
|
|
124
|
+
const table = tableKeyOf(tableKey);
|
|
125
|
+
if (table?.reading !== "registry") return null;
|
|
126
|
+
const member = key.slice(dot + 1);
|
|
127
|
+
return fieldOf(linkedTableFields(table.table), member) === void 0 ? null : {
|
|
128
|
+
table: table.table,
|
|
129
|
+
tableKey,
|
|
130
|
+
member
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
//#endregion
|
|
135
|
+
export { addressPartValueType, fieldOf, isDerived, isMediaListDeclaration, linkRegistry, linkedRegistry, linkedTableFields, mediaListKeysOf, memberListOfKey, memberValueType, registryFactsOf, tableColumnOfKey, tableFieldsIn, tableHome };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { rowOfMember } from "./slot-ref.js";
|
|
2
|
+
import { isComputeBinding } from "./compute.js";
|
|
3
|
+
import { FILL, getFills } from "./fill-declaration.js";
|
|
4
|
+
import { ROW_OWN_KEYS, rowDefinition } from "./row-ref.js";
|
|
5
|
+
|
|
6
|
+
//#region ../../internal/template-contracts/dist/resolve-scope.js
|
|
7
|
+
function mapReads(reads, map) {
|
|
8
|
+
const mapped = reads.map(map);
|
|
9
|
+
return mapped.some((ref, i) => ref !== reads[i]) ? mapped : void 0;
|
|
10
|
+
}
|
|
11
|
+
function mapFunctionRefs(binding, map) {
|
|
12
|
+
const reads = binding.reads === void 0 ? void 0 : mapReads(binding.reads, map);
|
|
13
|
+
const requires = binding.requires === void 0 ? void 0 : mapReads(binding.requires, map);
|
|
14
|
+
if (reads === void 0 && requires === void 0) return binding;
|
|
15
|
+
return {
|
|
16
|
+
...binding,
|
|
17
|
+
...reads === void 0 ? {} : { reads },
|
|
18
|
+
...requires === void 0 ? {} : { requires }
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function mapSlotRefs(value, map) {
|
|
22
|
+
const slot = rowDefinition(value);
|
|
23
|
+
let out;
|
|
24
|
+
const source = slot.source;
|
|
25
|
+
if (source !== void 0) if (isComputeBinding(source)) {
|
|
26
|
+
const mapped = mapFunctionRefs(source, map);
|
|
27
|
+
if (mapped !== source) out = {
|
|
28
|
+
...slot,
|
|
29
|
+
source: mapped
|
|
30
|
+
};
|
|
31
|
+
} else {
|
|
32
|
+
const mapped = map(source);
|
|
33
|
+
if (mapped !== source) out = {
|
|
34
|
+
...slot,
|
|
35
|
+
source: mapped
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const fills = getFills(slot);
|
|
39
|
+
if (fills !== void 0) {
|
|
40
|
+
let changed = false;
|
|
41
|
+
const mapped = fills.map((binding) => {
|
|
42
|
+
const resolved = mapFunctionRefs(binding, map);
|
|
43
|
+
if (resolved !== binding) changed = true;
|
|
44
|
+
return resolved;
|
|
45
|
+
});
|
|
46
|
+
if (changed) out = {
|
|
47
|
+
...out ?? slot,
|
|
48
|
+
[FILL]: mapped
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return out ?? slot;
|
|
52
|
+
}
|
|
53
|
+
function memberResolver(rows) {
|
|
54
|
+
return (ref) => {
|
|
55
|
+
const row = rowOfMember(ref);
|
|
56
|
+
if (row === void 0) return ref;
|
|
57
|
+
const key = rows.get(row);
|
|
58
|
+
if (key === void 0) return ref;
|
|
59
|
+
return {
|
|
60
|
+
kind: "row",
|
|
61
|
+
slot: key,
|
|
62
|
+
field: ref.field
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const MEMBER_HOLDERS = /* @__PURE__ */ new Set(["row", "address"]);
|
|
67
|
+
function rowScope(slots) {
|
|
68
|
+
const rows = /* @__PURE__ */ new Map();
|
|
69
|
+
for (const [key, slot] of Object.entries(slots)) if (typeof slot === "object" && slot !== null && MEMBER_HOLDERS.has(slot.type)) rows.set(slot, key);
|
|
70
|
+
return rows;
|
|
71
|
+
}
|
|
72
|
+
function ownKeyRead(slot, rows, at) {
|
|
73
|
+
const refs = [slot.source];
|
|
74
|
+
mapSlotRefs(slot, (ref) => {
|
|
75
|
+
refs.push(ref);
|
|
76
|
+
return ref;
|
|
77
|
+
});
|
|
78
|
+
for (const [row, rowKey] of rows) {
|
|
79
|
+
if (row === slot || rowKey === at) continue;
|
|
80
|
+
for (const key of ROW_OWN_KEYS) {
|
|
81
|
+
const own = row[key];
|
|
82
|
+
if (own !== void 0 && refs.includes(own)) return `${rowKey}.${key}`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function ownKeyRefusal(read) {
|
|
87
|
+
const key = read.slice(read.indexOf(".") + 1);
|
|
88
|
+
return `reads \`${read}\`, which is the row's own \`${key}\`, not a member — a row's ${ROW_OWN_KEYS.map((k) => `\`${k}\``).join(", ")} are its slot definition's, and its table has no member named \`${key}\`.`;
|
|
89
|
+
}
|
|
90
|
+
function unresolvedMember(slot) {
|
|
91
|
+
let found;
|
|
92
|
+
mapSlotRefs(slot, (ref) => {
|
|
93
|
+
if (found === void 0 && rowOfMember(ref) !== void 0) found = ref.field;
|
|
94
|
+
return ref;
|
|
95
|
+
});
|
|
96
|
+
return found;
|
|
97
|
+
}
|
|
98
|
+
function plainSlot(slot) {
|
|
99
|
+
return MEMBER_HOLDERS.has(slot.type) ? { ...rowDefinition(slot) } : slot;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//#endregion
|
|
103
|
+
export { mapSlotRefs, memberResolver, ownKeyRead, ownKeyRefusal, plainSlot, rowScope, unresolvedMember };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { isFindableKind } from "./findable.js";
|
|
2
|
+
import { isValueKind } from "./value-contracts.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../internal/template-contracts/dist/row-planners.js
|
|
5
|
+
const POOLING_PRIMITIVES = [
|
|
6
|
+
"image",
|
|
7
|
+
"video",
|
|
8
|
+
"tour",
|
|
9
|
+
"document",
|
|
10
|
+
"media"
|
|
11
|
+
];
|
|
12
|
+
function poolingPrimitiveOf(field) {
|
|
13
|
+
return POOLING_PRIMITIVES.includes(field.type ?? "") ? field.type : void 0;
|
|
14
|
+
}
|
|
15
|
+
function plannerForField(field) {
|
|
16
|
+
if (field.type === "list") {
|
|
17
|
+
const element = field.element?.type;
|
|
18
|
+
if (element === "select") return "select";
|
|
19
|
+
if (isFindableKind(element) || element === "object" || element === "row") return void 0;
|
|
20
|
+
if (poolingPrimitiveOf({ type: element }) !== void 0) return "assets";
|
|
21
|
+
return "list";
|
|
22
|
+
}
|
|
23
|
+
if (field.type === "text" || isValueKind(field.type)) return "text";
|
|
24
|
+
if (field.type === "select") return "choice";
|
|
25
|
+
return poolingPrimitiveOf(field);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { POOLING_PRIMITIVES, plannerForField, poolingPrimitiveOf };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { AddressMember, AddressValue } from "./address-value.js";
|
|
2
|
+
import { LIBRARY_TABLE_KEYS, REGISTRY_TABLE_KEYS, RegistryTable, RegistryTableKey } from "./slot-catalog.js";
|
|
3
|
+
import { PoiRow } from "./poi-row.js";
|
|
4
|
+
import { ImageValue } from "./runtime-values.js";
|
|
5
|
+
import { MemberValueTypeOf, TableFieldsOf } from "./registry-shape.js";
|
|
6
|
+
import { RegistryTableRow } from "./table-members.js";
|
|
7
|
+
import { ComputeBinding } from "./compute.js";
|
|
8
|
+
import { SlotValue } from "./slot-value.js";
|
|
9
|
+
import { ElementRef, RowRef, SiblingSlot, SlotRef } from "./slot-ref.js";
|
|
10
|
+
import { DocumentMediaValue } from "./registry-facts.js";
|
|
11
|
+
//#region ../../internal/template-contracts/dist/row-ref.d.ts
|
|
12
|
+
/** The library key naming table `T`, where the library holds its rows. */
|
|
13
|
+
type LibraryKeyOf<T extends RegistryTable> = T extends keyof typeof LIBRARY_TABLE_KEYS ? (typeof LIBRARY_TABLE_KEYS)[T] : never;
|
|
14
|
+
/** The table a registry table key names — `units` for `property.units`, `contacts` for `library.contacts`. */
|
|
15
|
+
type TableOfKey<K extends RegistryTableKey> = { [T in RegistryTable]: K extends (typeof REGISTRY_TABLE_KEYS)[T] | LibraryKeyOf<T> ? T : never; }[RegistryTable];
|
|
16
|
+
/**
|
|
17
|
+
* The keys a row slot's definition owns (`RowSlotDef`'s, ./row.ts). A row answers each
|
|
18
|
+
* from its definition — present or not — and never as a member, but where its table has
|
|
19
|
+
* a member of the same name (a unit's `label`), which the row answers instead.
|
|
20
|
+
*/
|
|
21
|
+
declare const ROW_OWN_KEYS: readonly ["type", "label", "from", "source", "locked", "when"];
|
|
22
|
+
/** A key a row slot's definition owns — see {@link ROW_OWN_KEYS}. */
|
|
23
|
+
type RowOwnKey = (typeof ROW_OWN_KEYS)[number];
|
|
24
|
+
/**
|
|
25
|
+
* A row's identity — a fact row's id, or a content item's minted `id` — as a row slot
|
|
26
|
+
* and a selection hold it. `Table` rides a phantom, so a row read off another section's
|
|
27
|
+
* row or selection still offers its table's members.
|
|
28
|
+
*/
|
|
29
|
+
type RowId<Table extends RegistryTableKey | null = RegistryTableKey | null> = string & {
|
|
30
|
+
readonly __row_table?: Table;
|
|
31
|
+
};
|
|
32
|
+
/** The table a row identity names, or `null`. */
|
|
33
|
+
type TableOfId<E> = E extends {
|
|
34
|
+
readonly __row_table?: infer C;
|
|
35
|
+
} ? (C extends RegistryTableKey ? C : null) : null;
|
|
36
|
+
type Members<T extends RegistryTable> = { [M in keyof TableFieldsOf<T>]: {
|
|
37
|
+
readonly value_type: MemberValueTypeOf<TableFieldsOf<T>[M]>;
|
|
38
|
+
}; };
|
|
39
|
+
/** What member `M` of a table's registry row holds, as the facts document holds it. */
|
|
40
|
+
type MemberRead<T extends RegistryTable, M> = M extends keyof RegistryTableRow<T> ? RegistryTableRow<T>[M] : never;
|
|
41
|
+
/** An item of a list-valued member, each media reference resolved to the image a slot renders. */
|
|
42
|
+
type ResolvedItem<I> = { [K in keyof I]: I[K] extends DocumentMediaValue | null ? ImageValue | Extract<I[K], null> : I[K]; };
|
|
43
|
+
/**
|
|
44
|
+
* The value a member resolves to in a slot sourced by it: a scalar may be absent, an
|
|
45
|
+
* image member resolves to the image value a slot renders, an image list to the list of
|
|
46
|
+
* them, a list of objects to its items with their images resolved, a list of scalars to
|
|
47
|
+
* its values, an address to the address value.
|
|
48
|
+
*/
|
|
49
|
+
type MemberValue<D, Read> = D extends {
|
|
50
|
+
value_type: "text";
|
|
51
|
+
} ? string | null : D extends {
|
|
52
|
+
value_type: "number";
|
|
53
|
+
} ? number | null : D extends {
|
|
54
|
+
value_type: "image";
|
|
55
|
+
} ? ImageValue | null : D extends {
|
|
56
|
+
value_type: "image_list";
|
|
57
|
+
} ? ImageValue[] : D extends {
|
|
58
|
+
value_type: "text_list";
|
|
59
|
+
} ? string[] : D extends {
|
|
60
|
+
value_type: "number_list";
|
|
61
|
+
} ? number[] : D extends {
|
|
62
|
+
value_type: "row_list";
|
|
63
|
+
} ? Read extends readonly (infer I)[] ? ResolvedItem<I>[] : never : D extends {
|
|
64
|
+
value_type: "address";
|
|
65
|
+
} ? AddressValue | null : unknown;
|
|
66
|
+
/** The member refs an address-valued member answers, one per part, each a dotted path. */
|
|
67
|
+
type AddressPartRefs<M extends string> = { readonly [P in AddressMember]: RowRef<`${M}.${P}`, AddressValue[P]>; };
|
|
68
|
+
type MemberRef<T extends RegistryTable, M extends keyof Members<T> & string> = RowRef<M, MemberValue<Members<T>[M], MemberRead<T, M>>, MemberRead<T, M>> & (Members<T>[M] extends {
|
|
69
|
+
value_type: "address";
|
|
70
|
+
} ? AddressPartRefs<M> : unknown);
|
|
71
|
+
/**
|
|
72
|
+
* What a row of table `K` offers: one member ref per member of the table's registry row
|
|
73
|
+
* (`linkedTableFields`). A slot sourced by one fits its value (`MemberValue`); a
|
|
74
|
+
* `compute()` reading one receives what the facts document holds — an image's
|
|
75
|
+
* `{ asset_id }`, `null` for an unanswered member. The mapping only FILTERS the table's
|
|
76
|
+
* keys, so each member's doc comment is what an author reads hovering `unit.beds`.
|
|
77
|
+
*/
|
|
78
|
+
type TableRow<K extends RegistryTableKey> = { readonly [M in keyof Members<TableOfKey<K>> & string]: MemberRef<TableOfKey<K>, M>; };
|
|
79
|
+
/**
|
|
80
|
+
* What a row `from` a table's list-valued member offers (`row({ from: unit.floor_plans,
|
|
81
|
+
* source: entry })`): one read-only member ref per key of the member's items, the row's
|
|
82
|
+
* own keys aside — an item has no table to write back to.
|
|
83
|
+
*/
|
|
84
|
+
type MemberListRow<Item> = { readonly [M in Exclude<keyof Item & string, RowOwnKey>]-?: RowRef<M, Item[M]>; };
|
|
85
|
+
/** The item a list-valued member ref holds, its images resolved — or `never` for any other ref. */
|
|
86
|
+
type MemberListItem<From> = From extends RowRef<string, infer V, unknown> ? NonNullable<V> extends readonly (infer I)[] ? I extends object ? I : never : never : never;
|
|
87
|
+
/** The element of a list-valued value: a table row's identity keeps its table. */
|
|
88
|
+
type ValueElement<V> = NonNullable<V> extends readonly (infer E)[] ? ElementRef<E, TableOfId<E>> : ElementRef<never, null>;
|
|
89
|
+
/**
|
|
90
|
+
* The element an item function receives for a list sourced by `Source`: a table's row
|
|
91
|
+
* (typed by the table), a list-valued member's element, a written value,
|
|
92
|
+
* a found place, or a compute's or a slot's element. A written value's kind is declared
|
|
93
|
+
* by the item field that binds it — after the element is handed over — so its value
|
|
94
|
+
* type is left open, and that field's own kind holds it. A picked list and a list with
|
|
95
|
+
* no source have no element: their item holds the pick in its `from` field.
|
|
96
|
+
*/
|
|
97
|
+
type ElementOf<Source> = Source extends {
|
|
98
|
+
readonly kind: "home";
|
|
99
|
+
readonly key: infer F;
|
|
100
|
+
} ? F extends RegistryTableKey ? ElementRef<RowId<F>, F> : ElementRef<never, null> : Source extends RowRef<string, infer V, unknown> ? ValueElement<V> : Source extends {
|
|
101
|
+
readonly kind: "fill";
|
|
102
|
+
readonly verb: "write";
|
|
103
|
+
} ? ElementRef<never, null> : Source extends {
|
|
104
|
+
readonly kind: "fill";
|
|
105
|
+
readonly verb: "find";
|
|
106
|
+
} ? ElementRef<PoiRow, null> : Source extends ComputeBinding<infer V> ? ValueElement<V> : Source extends SlotRef<string, string, infer V> ? ValueElement<V> : Source extends SiblingSlot ? ValueElement<SlotValue<Source>> : ElementRef<never, null>;
|
|
107
|
+
/** The table whose rows a list's elements are, or `null` — what a list's items are identified by. */
|
|
108
|
+
type ElementTableOf<Source> = ElementOf<Source> extends ElementRef<unknown, infer T> ? T : null;
|
|
109
|
+
/** The table a row identity value names, through a list or a nullable single value. */
|
|
110
|
+
type TableOfRowValue<V> = NonNullable<V> extends readonly (infer E)[] ? TableOfId<E> : TableOfId<NonNullable<V>>;
|
|
111
|
+
/**
|
|
112
|
+
* The fact table a row's origin holds a row of, where its type says one — an element of
|
|
113
|
+
* a table's rows, another section's row or list holding table rows, a sibling's, or a
|
|
114
|
+
* compute returning a row identity — or `null` where it says none (a pick, which
|
|
115
|
+
* chooses out of the row's own `from`). A row's `source` must name `from`'s table or
|
|
116
|
+
* none (./row.ts).
|
|
117
|
+
*/
|
|
118
|
+
type OriginTableOf<Source> = Source extends ElementRef<infer V, infer T> ? T extends RegistryTableKey ? T : TableOfId<V> : Source extends ComputeBinding<infer V> ? TableOfRowValue<V> : Source extends SlotRef<string, string, infer V> ? TableOfRowValue<V> : Source extends SiblingSlot ? TableOfRowValue<SlotValue<Source>> : null;
|
|
119
|
+
/**
|
|
120
|
+
* What an address slot offers: one member ref per part and per coordinate
|
|
121
|
+
* (`ADDRESS_MEMBERS`), typed by the address's value and never writable — a part edited
|
|
122
|
+
* alone would describe a door its coordinates are not on. On the wire a member ref
|
|
123
|
+
* reads `{kind:"row", slot, field}` exactly as a row's does, `slot` naming the address.
|
|
124
|
+
*/
|
|
125
|
+
type AddressMembers = { readonly [M in AddressMember]: RowRef<M, AddressValue[M]>; };
|
|
126
|
+
//#endregion
|
|
127
|
+
export { AddressMembers, AddressPartRefs, ElementOf, ElementTableOf, MemberListItem, MemberListRow, OriginTableOf, ROW_OWN_KEYS, RowId, RowOwnKey, TableOfKey, TableRow };
|