@homepages/concrete 7.0.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1007 -0
- package/README.md +20 -9
- package/codemods/list-grammar.mjs +923 -0
- package/codemods/manifest.json +66 -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-BUmdDDX5.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/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 +263 -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 +252 -35
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +365 -4
- package/dist/packages/internal/fill-bake/dist/derive-source.js +35 -21
- package/dist/packages/internal/fill-bake/dist/index.js +8 -3
- package/dist/packages/internal/fill-bake/dist/item-merge.js +119 -0
- package/dist/packages/internal/fill-bake/dist/item-overrides.js +28 -0
- package/dist/packages/internal/fill-bake/dist/linked-merge.js +40 -0
- package/dist/packages/internal/fill-bake/dist/list-grammar.js +175 -0
- package/dist/packages/internal/fill-vocabulary/dist/holder.js +51 -0
- package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +390 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -23
- package/dist/packages/internal/fill-vocabulary/dist/row-reads.js +1 -1
- package/dist/packages/internal/fill-vocabulary/dist/verbs.js +75 -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 +228 -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 +34 -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 +244 -0
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +8 -17
- package/dist/packages/internal/section-contracts/dist/catalog.js +35 -27
- 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 +27 -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 -0
- 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 -5
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +23 -19
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +12 -7
- 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 +5 -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 +7 -4
- package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +83 -0
- package/dist/packages/internal/section-contracts/dist/row-source-contract.js +67 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +77 -33
- package/dist/packages/internal/section-contracts/dist/select-contract.js +0 -8
- package/dist/packages/internal/section-contracts/dist/source-contract.js +120 -66
- 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 +43 -18
- package/dist/packages/internal/source-resolution/dist/index.js +113 -118
- 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 +85 -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 +12 -36
- 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 +158 -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 +94 -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 +250 -0
- package/dist/packages/internal/template-contracts/dist/ref-locate.js +192 -0
- package/dist/packages/internal/template-contracts/dist/registry-aliases.js +77 -0
- package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +268 -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 +133 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.js +101 -0
- package/dist/packages/internal/template-contracts/dist/row-sources.js +48 -8
- 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 +243 -384
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +334 -230
- 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 +140 -0
- package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +97 -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 +19 -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 -158
- 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 -11
- 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 -29
- package/package.json +9 -8
- package/dist/artifact/playground/client/assets/index-CckS2ONm.css +0 -1
- package/dist/artifact/playground/client/assets/index-D8eepVr-.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 -111
- 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/choose-select-contract.js +0 -20
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +0 -20
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +0 -22
- package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +0 -24
- package/dist/packages/internal/section-contracts/dist/source-filter-contract.js +0 -15
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +0 -22
- package/dist/packages/internal/template-contracts/dist/facts-view.js +0 -111
- 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 -89
- 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 -613
- 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,268 @@
|
|
|
1
|
+
import { AddressView } from "./address-value.js";
|
|
2
|
+
import { MediaKind } from "./slot-catalog.js";
|
|
3
|
+
import { FactHome, LibraryFactRegistry, PropertyFactRegistry } from "./fact-registry.js";
|
|
4
|
+
//#region ../../internal/template-contracts/dist/registry-facts.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* What a home picking place holds — a media declaration with `from`: the id of the owning
|
|
7
|
+
* item at the root of its `from` chain (P3) and, beside it, the framing the place reads as
|
|
8
|
+
* where any place of its chain carries its own (place framing F1, F2). It reads as that
|
|
9
|
+
* item's value merged with its file, its crop and place renditions this framing's.
|
|
10
|
+
*/
|
|
11
|
+
interface MediaReference {
|
|
12
|
+
media: string;
|
|
13
|
+
/** The place's own crop (place framing F1): present — null included, the whole frame — is own; absent is none, read down the chain. */
|
|
14
|
+
crop?: MediaCrop | null;
|
|
15
|
+
/** The place renditions the place's own processes wrote, by name; a name absent is none. */
|
|
16
|
+
renditions?: Partial<PlaceRenditions>;
|
|
17
|
+
}
|
|
18
|
+
/** A media value as the facts document holds it: an owning place's value in place, or a picking place's reference. */
|
|
19
|
+
type DocumentMediaValue = HomeMediaValue | MediaReference;
|
|
20
|
+
/** Whether a file's gating processing has finished — a record's `state` is its file's. */
|
|
21
|
+
type FileState = "processing" | "ready" | "failed";
|
|
22
|
+
/** The file renditions: derived from the file alone, so every place over the file shares them. */
|
|
23
|
+
declare const FILE_RENDITION_NAMES: readonly ["master", "poster", "encode"];
|
|
24
|
+
/**
|
|
25
|
+
* The place renditions: derived from a place's crop, so each place's are its own — the
|
|
26
|
+
* `crop` cut (the original under the crop), and the cut-out and its masks.
|
|
27
|
+
*/
|
|
28
|
+
declare const PLACE_RENDITION_NAMES: readonly ["crop", "cutout", "mask_white", "mask_black"];
|
|
29
|
+
/** A file rendition's name — one of `FILE_RENDITION_NAMES`. */
|
|
30
|
+
type FileRenditionName = (typeof FILE_RENDITION_NAMES)[number];
|
|
31
|
+
/** A place rendition's name — one of `PLACE_RENDITION_NAMES`. */
|
|
32
|
+
type PlaceRenditionName = (typeof PLACE_RENDITION_NAMES)[number];
|
|
33
|
+
/** One rendition: its storage key — never a URL — and what is known of its bytes. */
|
|
34
|
+
interface Rendition {
|
|
35
|
+
key: string;
|
|
36
|
+
mime: string | null;
|
|
37
|
+
width: number | null;
|
|
38
|
+
height: number | null;
|
|
39
|
+
bytes: number | null;
|
|
40
|
+
}
|
|
41
|
+
/** A file's renditions by name, each `null` where the kind has none or its bytes do not exist yet. */
|
|
42
|
+
type FileRenditions = { [N in FileRenditionName]: Rendition | null; };
|
|
43
|
+
/** A place's renditions by name, each with the inputs it was cut at; `null` where the kind has none or its bytes do not exist yet. */
|
|
44
|
+
type PlaceRenditions = { [N in PlaceRenditionName]: PlaceRendition | null; };
|
|
45
|
+
/** A place's framing: a rect normalized 0–1 over the original's oriented frame. */
|
|
46
|
+
interface MediaCrop {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
}
|
|
52
|
+
/** The members every file carries, before its kind narrows them — what is true of the bytes, never of a place. */
|
|
53
|
+
interface FileMembers {
|
|
54
|
+
/** The file's id. */
|
|
55
|
+
id: string;
|
|
56
|
+
kind: MediaKind;
|
|
57
|
+
/** The original's storage key — never a URL; null on a pasted link, which has no stored bytes. */
|
|
58
|
+
key: string | null;
|
|
59
|
+
/** The original's MIME type. */
|
|
60
|
+
mime: string | null;
|
|
61
|
+
/** The original's size in bytes. */
|
|
62
|
+
bytes: number | null;
|
|
63
|
+
/** A pasted link's URL, as pasted. */
|
|
64
|
+
url: string | null;
|
|
65
|
+
/** The link provider that claims `url`. */
|
|
66
|
+
provider: string | null;
|
|
67
|
+
/** When the file was born, ISO 8601. */
|
|
68
|
+
added_at: string;
|
|
69
|
+
/**
|
|
70
|
+
* What understand wrote of the file for a reader who cannot see it: plain-language
|
|
71
|
+
* statements, one fact each — what it is and how it was made, what it shows, every word
|
|
72
|
+
* printed on it verbatim, how it looks. Never shown to a person. Null means not yet
|
|
73
|
+
* understood: unknown, never empty.
|
|
74
|
+
*/
|
|
75
|
+
account: string | null;
|
|
76
|
+
/** A document's page count. Null means uncounted: not yet, or an office file, which nothing pages. */
|
|
77
|
+
page_count: number | null;
|
|
78
|
+
/** The file's own running time. Null means unknown, never short. */
|
|
79
|
+
duration_ms: number | null;
|
|
80
|
+
/** The original's intrinsic width. */
|
|
81
|
+
width: number | null;
|
|
82
|
+
/** The original's intrinsic height. */
|
|
83
|
+
height: number | null;
|
|
84
|
+
/** When the provider says it was captured, ISO 8601. */
|
|
85
|
+
captured_at: string | null;
|
|
86
|
+
/** A tour's scan count, as its provider reports it. */
|
|
87
|
+
scan_count: number | null;
|
|
88
|
+
/**
|
|
89
|
+
* A video's poster hint: the instant, in milliseconds, of the frame a model chose as
|
|
90
|
+
* its poster. Null means no choice yet, and the poster is the representative frame.
|
|
91
|
+
*/
|
|
92
|
+
poster_at_ms: number | null;
|
|
93
|
+
/** The file's renditions. */
|
|
94
|
+
renditions: FileRenditions;
|
|
95
|
+
/** Whether its gating processing has finished. */
|
|
96
|
+
state: FileState;
|
|
97
|
+
}
|
|
98
|
+
/** An image file: a photo, a floor plan, a logo, a headshot. */
|
|
99
|
+
interface ImageFile extends FileMembers {
|
|
100
|
+
kind: "image";
|
|
101
|
+
key: string;
|
|
102
|
+
url: null;
|
|
103
|
+
provider: null;
|
|
104
|
+
page_count: null;
|
|
105
|
+
duration_ms: null;
|
|
106
|
+
poster_at_ms: null;
|
|
107
|
+
captured_at: null;
|
|
108
|
+
scan_count: null;
|
|
109
|
+
renditions: FileRenditions & {
|
|
110
|
+
poster: null;
|
|
111
|
+
encode: null;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/** A video file: a hosted file (`url` null), or a pasted provider link. */
|
|
115
|
+
interface VideoFile extends FileMembers {
|
|
116
|
+
kind: "video";
|
|
117
|
+
page_count: null;
|
|
118
|
+
scan_count: null;
|
|
119
|
+
renditions: FileRenditions & {
|
|
120
|
+
master: null;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/** A 3D tour link. */
|
|
124
|
+
interface TourFile extends FileMembers {
|
|
125
|
+
kind: "tour";
|
|
126
|
+
key: null;
|
|
127
|
+
mime: null;
|
|
128
|
+
bytes: null;
|
|
129
|
+
url: string;
|
|
130
|
+
provider: string;
|
|
131
|
+
page_count: null;
|
|
132
|
+
duration_ms: null;
|
|
133
|
+
poster_at_ms: null;
|
|
134
|
+
width: null;
|
|
135
|
+
height: null;
|
|
136
|
+
renditions: FileRenditions & {
|
|
137
|
+
master: null;
|
|
138
|
+
encode: null;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/** An attachable document. */
|
|
142
|
+
interface DocumentFile extends FileMembers {
|
|
143
|
+
kind: "document";
|
|
144
|
+
key: string;
|
|
145
|
+
url: null;
|
|
146
|
+
provider: null;
|
|
147
|
+
duration_ms: null;
|
|
148
|
+
poster_at_ms: null;
|
|
149
|
+
width: null;
|
|
150
|
+
height: null;
|
|
151
|
+
captured_at: null;
|
|
152
|
+
scan_count: null;
|
|
153
|
+
renditions: FileRenditions & {
|
|
154
|
+
master: null;
|
|
155
|
+
encode: null;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/** One file, narrowed by its kind. Named `MediaFile`, not `File`, so it never shadows the DOM's `File` where a browser imports it. */
|
|
159
|
+
type MediaFile = ImageFile | VideoFile | TourFile | DocumentFile;
|
|
160
|
+
/** The value a home owning place holds — an `uploads` item, a contact's `headshot`. */
|
|
161
|
+
interface HomeMediaValue {
|
|
162
|
+
/** The media id, minted at birth: the owning item's identity, what a reference names. */
|
|
163
|
+
id: string;
|
|
164
|
+
/** The file id. */
|
|
165
|
+
file: string;
|
|
166
|
+
/** The place's framing over the original; null is the whole frame. Only an image's place crops. */
|
|
167
|
+
crop: MediaCrop | null;
|
|
168
|
+
/** What a person called it; null reads as the file's own name (`fileNameOf`). */
|
|
169
|
+
name: string | null;
|
|
170
|
+
/** The renditions this place's processing cut over its `crop`. */
|
|
171
|
+
renditions: PlaceRenditions;
|
|
172
|
+
}
|
|
173
|
+
/** What a place rendition was cut at: the place's crop and the process entry's options, in the clear (P5). */
|
|
174
|
+
interface RenditionInputs {
|
|
175
|
+
crop: MediaCrop | null;
|
|
176
|
+
options: Record<string, unknown>;
|
|
177
|
+
}
|
|
178
|
+
/** A rendition a place's own processing cut, with the inputs it was cut at. */
|
|
179
|
+
interface PlaceRendition extends Rendition {
|
|
180
|
+
over: RenditionInputs;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The place members a record carries: a home value's, `name` resolved. `id` is the media
|
|
184
|
+
* id and `file` the file's — one id while an `intake.upload` row is both.
|
|
185
|
+
*/
|
|
186
|
+
interface PlaceMembers {
|
|
187
|
+
id: string;
|
|
188
|
+
file: string;
|
|
189
|
+
crop: MediaCrop | null;
|
|
190
|
+
/** The display name: what a person called it, else the file's own name (`fileNameOf`). */
|
|
191
|
+
name: string;
|
|
192
|
+
}
|
|
193
|
+
/** The place renditions of a kind nothing crops: no framing, so nothing is cut. */
|
|
194
|
+
type Uncut = {
|
|
195
|
+
crop: null;
|
|
196
|
+
cutout: null;
|
|
197
|
+
mask_white: null;
|
|
198
|
+
mask_black: null;
|
|
199
|
+
};
|
|
200
|
+
/** An image's record: its file, and its place's crop and cut. */
|
|
201
|
+
interface ImageMedia extends Omit<ImageFile, "id" | "renditions">, PlaceMembers {
|
|
202
|
+
renditions: ImageFile["renditions"] & PlaceRenditions;
|
|
203
|
+
}
|
|
204
|
+
/** A video's record. */
|
|
205
|
+
interface VideoMedia extends Omit<VideoFile, "id" | "renditions">, PlaceMembers {
|
|
206
|
+
crop: null;
|
|
207
|
+
renditions: VideoFile["renditions"] & Uncut;
|
|
208
|
+
}
|
|
209
|
+
/** A tour's record. */
|
|
210
|
+
interface TourMedia extends Omit<TourFile, "id" | "renditions">, PlaceMembers {
|
|
211
|
+
crop: null;
|
|
212
|
+
renditions: TourFile["renditions"] & Uncut;
|
|
213
|
+
}
|
|
214
|
+
/** A document's record. */
|
|
215
|
+
interface DocumentMedia extends Omit<DocumentFile, "id" | "renditions">, PlaceMembers {
|
|
216
|
+
crop: null;
|
|
217
|
+
renditions: DocumentFile["renditions"] & Uncut;
|
|
218
|
+
}
|
|
219
|
+
/** One media record — a place's value and its file read as one; what every reader of media receives. */
|
|
220
|
+
type Media = ImageMedia | VideoMedia | TourMedia | DocumentMedia;
|
|
221
|
+
type Registries = {
|
|
222
|
+
property: PropertyFactRegistry;
|
|
223
|
+
library: LibraryFactRegistry;
|
|
224
|
+
};
|
|
225
|
+
/** The element declaration of list fact `K` of home `H` — what a `row` from it holds. */
|
|
226
|
+
type ListElementOf<H extends FactHome, K> = K extends keyof Registries[H]["pages"] ? Registries[H]["pages"][K] extends {
|
|
227
|
+
readonly declaration: {
|
|
228
|
+
readonly element: infer E;
|
|
229
|
+
};
|
|
230
|
+
} ? E : never : never;
|
|
231
|
+
/** The value a fact declaration `D` holds in the document. */
|
|
232
|
+
type FactValue<D> = D extends {
|
|
233
|
+
readonly type: "list";
|
|
234
|
+
readonly element: infer E;
|
|
235
|
+
} ? FactItem<E>[] : D extends {
|
|
236
|
+
readonly type: "object";
|
|
237
|
+
readonly fields: infer F;
|
|
238
|
+
} ? { -readonly [K in keyof F]: FactValue<F[K]>; } : D extends {
|
|
239
|
+
readonly type: "row";
|
|
240
|
+
readonly from: `${infer H extends FactHome}.${infer K}`;
|
|
241
|
+
} ? FactItem<ListElementOf<H, K>> : D extends {
|
|
242
|
+
readonly type: "address";
|
|
243
|
+
} ? AddressView : D extends {
|
|
244
|
+
readonly type: MediaKind | "media";
|
|
245
|
+
} // Which of the two a place holds is its `from`'s (P3), which a builder's declaration
|
|
246
|
+
? DocumentMediaValue | null : D extends {
|
|
247
|
+
readonly type: "number";
|
|
248
|
+
} ? number | null : string | null;
|
|
249
|
+
/**
|
|
250
|
+
* One item of a list whose element is `E`: an object's carries its row `id`; a row is
|
|
251
|
+
* the row it picks, resolved — its `id` and members (`pickedRowOf`); a value is never
|
|
252
|
+
* null — an empty item is no item.
|
|
253
|
+
*/
|
|
254
|
+
type FactItem<E> = E extends {
|
|
255
|
+
readonly type: "object";
|
|
256
|
+
} ? {
|
|
257
|
+
id: string;
|
|
258
|
+
} & FactValue<E> : E extends {
|
|
259
|
+
readonly type: "row";
|
|
260
|
+
} ? FactValue<E> : NonNullable<FactValue<E>>;
|
|
261
|
+
type PropertyPages = PropertyFactRegistry["pages"];
|
|
262
|
+
/** One property's facts as `propertyFacts` declares them, and the files their media values are over. */
|
|
263
|
+
type RegistryFacts = { -readonly [K in keyof PropertyPages]: FactValue<PropertyPages[K]["declaration"]>; } & {
|
|
264
|
+
/** The file of every owning value the document holds, keyed by its id. */
|
|
265
|
+
files: Record<string, MediaFile>;
|
|
266
|
+
};
|
|
267
|
+
//#endregion
|
|
268
|
+
export { DocumentFile, DocumentMedia, DocumentMediaValue, FILE_RENDITION_NAMES, FactItem, FactValue, FileRenditionName, FileRenditions, FileState, HomeMediaValue, ImageFile, ImageMedia, Media, MediaCrop, MediaFile, MediaReference, PLACE_RENDITION_NAMES, PlaceMembers, PlaceRendition, PlaceRenditionName, PlaceRenditions, RegistryFacts, Rendition, RenditionInputs, TourFile, TourMedia, VideoFile, VideoMedia };
|
|
@@ -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 };
|