@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
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { mirror } from "./compute.js";
|
|
2
|
-
import { isFillBinding } from "./fill-builders.js";
|
|
3
|
-
import { fillMark, getFill } from "./fill-declaration.js";
|
|
4
|
-
import { isFactRef, isRowRef, isSiblingSlot, isSlotRef } from "./slot-ref.js";
|
|
5
|
-
import { rowReference } from "./row-ref.js";
|
|
6
|
-
import { resolveRowFields } from "./row-fields.js";
|
|
7
|
-
|
|
8
|
-
//#region src/schema/slot-builders.ts
|
|
9
|
-
function bakedSource(source) {
|
|
10
|
-
if (isSlotRef(source) || isSiblingSlot(source)) return mirror(source);
|
|
11
|
-
if (isRowRef(source)) return {
|
|
12
|
-
kind: "row",
|
|
13
|
-
field: source.field
|
|
14
|
-
};
|
|
15
|
-
return source;
|
|
16
|
-
}
|
|
17
|
-
function head(opts) {
|
|
18
|
-
const source = opts.source;
|
|
19
|
-
const baked = source !== void 0 && !isFillBinding(source);
|
|
20
|
-
return {
|
|
21
|
-
...opts.locked === true ? { locked: true } : {},
|
|
22
|
-
...baked ? { source: bakedSource(source) } : {},
|
|
23
|
-
...fillMark(source),
|
|
24
|
-
...opts.writeback !== void 0 ? { writeback: opts.writeback } : {},
|
|
25
|
-
label: opts.label,
|
|
26
|
-
...opts.placeholder !== void 0 ? { placeholder: opts.placeholder } : {},
|
|
27
|
-
...opts.when !== void 0 ? { when: opts.when } : {}
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function textOfSize(size) {
|
|
31
|
-
return (opts) => ({
|
|
32
|
-
type: "text",
|
|
33
|
-
size,
|
|
34
|
-
...head(opts),
|
|
35
|
-
...opts.cap !== void 0 ? { cap: opts.cap } : {}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
const text = {
|
|
39
|
-
short: textOfSize("short"),
|
|
40
|
-
medium: textOfSize("medium"),
|
|
41
|
-
long: textOfSize("long")
|
|
42
|
-
};
|
|
43
|
-
function number(opts) {
|
|
44
|
-
return {
|
|
45
|
-
type: "number",
|
|
46
|
-
...head(opts),
|
|
47
|
-
...opts.prefix !== void 0 ? { prefix: opts.prefix } : {},
|
|
48
|
-
...opts.suffix !== void 0 ? { suffix: opts.suffix } : {},
|
|
49
|
-
...opts.thousandsSep !== void 0 ? { thousandsSep: opts.thousandsSep } : {},
|
|
50
|
-
...opts.decimals !== void 0 ? { decimals: opts.decimals } : {},
|
|
51
|
-
...opts.maxDigits !== void 0 ? { maxDigits: opts.maxDigits } : {}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function selectFromFact(opts) {
|
|
55
|
-
const source = opts.source;
|
|
56
|
-
return {
|
|
57
|
-
type: "select",
|
|
58
|
-
...head(opts),
|
|
59
|
-
...isFactRef(source) ? { options: { source: source.field } } : {},
|
|
60
|
-
...opts.creatable !== void 0 ? { creatable: opts.creatable } : {}
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
function selectFromOptions(opts) {
|
|
64
|
-
if (isFactRef(opts.source)) throw new Error(`select: "${opts.label}" declares both \`options\` and a fact \`source\` — a select takes exactly one set of choices.`);
|
|
65
|
-
return {
|
|
66
|
-
type: "select",
|
|
67
|
-
...head(opts),
|
|
68
|
-
values: [...opts.options],
|
|
69
|
-
...opts.creatable !== void 0 ? { creatable: opts.creatable } : {},
|
|
70
|
-
...opts.unique === true ? { unique: true } : {}
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function displaySelect(cases, opts) {
|
|
74
|
-
return {
|
|
75
|
-
cases: [...cases],
|
|
76
|
-
...opts.locked === true ? { locked: true } : {},
|
|
77
|
-
...opts.source !== void 0 ? { source: opts.source } : {}
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
function selectDispatch(opts) {
|
|
81
|
-
if (Array.isArray(opts)) throw new Error("select: takes one options object — write the choices as `options`: `select({ options: [...], … })`.");
|
|
82
|
-
if (opts.label === void 0 && Array.isArray(opts.options)) return displaySelect(opts.options, opts);
|
|
83
|
-
return opts.options !== void 0 ? selectFromOptions(opts) : selectFromFact(opts);
|
|
84
|
-
}
|
|
85
|
-
const select = selectDispatch;
|
|
86
|
-
function url(opts) {
|
|
87
|
-
return {
|
|
88
|
-
type: "url",
|
|
89
|
-
...head(opts),
|
|
90
|
-
...opts.accepts !== void 0 ? { accepts: opts.accepts } : {}
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
function image(opts) {
|
|
94
|
-
return {
|
|
95
|
-
type: "image",
|
|
96
|
-
...head(opts),
|
|
97
|
-
...opts.crop !== void 0 ? { crop: opts.crop } : {},
|
|
98
|
-
...uniqueOf(opts)
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
function uniqueOf(opts) {
|
|
102
|
-
return opts.unique === true ? { unique: true } : {};
|
|
103
|
-
}
|
|
104
|
-
function video(opts) {
|
|
105
|
-
return {
|
|
106
|
-
type: "video",
|
|
107
|
-
...head(opts),
|
|
108
|
-
...opts.playback !== void 0 ? { playback: opts.playback } : {},
|
|
109
|
-
...opts.sources !== void 0 ? { sources: opts.sources } : {},
|
|
110
|
-
...uniqueOf(opts)
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
function tour(opts) {
|
|
114
|
-
return {
|
|
115
|
-
type: "tour",
|
|
116
|
-
...head(opts),
|
|
117
|
-
...uniqueOf(opts)
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
const ITEM_ONLY_KEYS = ["locked", "unique"];
|
|
121
|
-
function stripElementHead(element) {
|
|
122
|
-
const bare = {};
|
|
123
|
-
for (const [key, value] of Object.entries(element)) if (!ITEM_ONLY_KEYS.includes(key)) bare[key] = value;
|
|
124
|
-
return bare;
|
|
125
|
-
}
|
|
126
|
-
function itemList(label, element, opts, unique) {
|
|
127
|
-
if (getFill(element) !== void 0) throw new Error(`list: the element of "${label}" declares a fill — one decision produces the whole list, so \`source: fill(…)\` belongs on the list slot.`);
|
|
128
|
-
return {
|
|
129
|
-
element: stripElementHead(element),
|
|
130
|
-
...opts.min !== void 0 ? { min: opts.min } : {},
|
|
131
|
-
...opts.max !== void 0 ? { max: opts.max } : {},
|
|
132
|
-
...unique !== void 0 ? { unique } : {}
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
function listFromItem(opts) {
|
|
136
|
-
if (opts.unique !== void 0) throw new Error(`list: "${opts.label}" declares \`unique\` on the list — write it on the item, \`item: select({ …, unique: true })\`.`);
|
|
137
|
-
const element = opts.item;
|
|
138
|
-
const unique = element.unique === true ? true : void 0;
|
|
139
|
-
return {
|
|
140
|
-
type: "list",
|
|
141
|
-
...head(opts),
|
|
142
|
-
...itemList(opts.label, element, opts, unique)
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
function listFromFields(opts) {
|
|
146
|
-
const declared = opts.fields(rowReference(opts.source));
|
|
147
|
-
return {
|
|
148
|
-
type: "list",
|
|
149
|
-
...head(opts),
|
|
150
|
-
fields: resolveRowFields(opts.label, opts.source, declared),
|
|
151
|
-
...opts.title !== void 0 ? { title: opts.title } : {},
|
|
152
|
-
...opts.min !== void 0 ? { min: opts.min } : {},
|
|
153
|
-
...opts.max !== void 0 ? { max: opts.max } : {}
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
function listDispatch(opts) {
|
|
157
|
-
const hasItem = opts.item !== void 0;
|
|
158
|
-
if (hasItem === (opts.fields !== void 0)) throw new Error(`list: "${String(opts.label)}" declares ${hasItem ? "both `item` and `fields`" : "neither `item` nor `fields`"} — a list declares exactly one: \`item\` for one slot per entry, \`fields\` for a record.`);
|
|
159
|
-
return hasItem ? listFromItem(opts) : listFromFields(opts);
|
|
160
|
-
}
|
|
161
|
-
const list = listDispatch;
|
|
162
|
-
function poi(opts) {
|
|
163
|
-
return {
|
|
164
|
-
type: "poi",
|
|
165
|
-
...head(opts)
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
function document(opts) {
|
|
169
|
-
return {
|
|
170
|
-
type: "document",
|
|
171
|
-
...head(opts),
|
|
172
|
-
...uniqueOf(opts)
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
//#endregion
|
|
177
|
-
export { document, image, list, number, poi, select, text, tour, url, video };
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { Slot } from "./slot-types.js";
|
|
2
|
-
import { SlotValue } from "./section-props.js";
|
|
3
|
-
//#region src/schema/slot-ref.d.ts
|
|
4
|
-
/** The reserved `slot` prefix a display entry's ref is addressed by. */
|
|
5
|
-
declare const DISPLAY_REF_PREFIX = "display.";
|
|
6
|
-
/** The two `meta.display` entries a section may declare, and so may be read. */
|
|
7
|
-
type DisplayEntryName = "visibility" | "variant";
|
|
8
|
-
/**
|
|
9
|
-
* A slot of a section, or one of its two display entries, by name — what a
|
|
10
|
-
* declaration `reads`. Both string halves are literal on a section value
|
|
11
|
-
* (`Hero.slots.hero_image` is `SlotRef<"hero", "hero_image", ImageValue | null>`),
|
|
12
|
-
* which is what types the positional value a compute callback receives.
|
|
13
|
-
*/
|
|
14
|
-
interface SlotRef<Section extends string = string, SlotId extends string = string, Value = unknown> {
|
|
15
|
-
readonly section: Section;
|
|
16
|
-
readonly slot: SlotId;
|
|
17
|
-
/**
|
|
18
|
-
* Phantom: the referent's own value type. Never present at runtime —
|
|
19
|
-
* `declareSection` builds `{ section, slot }` — and never serialized.
|
|
20
|
-
*/
|
|
21
|
-
readonly __value?: Value;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* One fact of the property, by its `FACT_GRAPH` key — what every `fact.*` entry
|
|
25
|
-
* IS. The runtime members are the `direct` source literal (see the module header);
|
|
26
|
-
* `Key` is the registry key and `Value` the phantom type the entry reads at.
|
|
27
|
-
*/
|
|
28
|
-
interface FactRef<Key extends string = string, Value = unknown> {
|
|
29
|
-
readonly kind: "direct";
|
|
30
|
-
readonly field: Key;
|
|
31
|
-
/** Phantom: the value a `compute()` callback receives for this ref. Never present at runtime. */
|
|
32
|
-
readonly __value?: Value;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* One member of the row a record list hands each row — what `row.<member>` IS
|
|
36
|
-
* inside `list({ fields: (row) => … })`, and what an earlier field of the same row
|
|
37
|
-
* becomes once the list resolves it. Its runtime shape is its wire shape, as a fact
|
|
38
|
-
* ref's is: `{kind:"row", field}`, which the row field's `source:` emits verbatim.
|
|
39
|
-
* It resolves against the current row, never the primary one — that is what
|
|
40
|
-
* `fact.unit.*` / `fact.contact.*` name.
|
|
41
|
-
*/
|
|
42
|
-
interface RowRef<Field extends string = string, Value = unknown, Writable extends boolean = boolean> {
|
|
43
|
-
readonly kind: "row";
|
|
44
|
-
readonly field: Field;
|
|
45
|
-
/** Phantom: the member's value type. Never present at runtime. */
|
|
46
|
-
readonly __value?: Value;
|
|
47
|
-
/** Phantom: whether the member writes back, which decides a row field's `writeback`. Never present at runtime. */
|
|
48
|
-
readonly __writable?: Writable;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* A typed handle on one value the platform can resolve — what `source:`, a
|
|
52
|
-
* `compute`'s `reads` and a fill decision's `reads` all take. A new kind is
|
|
53
|
-
* additive: it answers where its value comes from and when it settles, and
|
|
54
|
-
* changes no consumer.
|
|
55
|
-
*/
|
|
56
|
-
type Ref = FactRef | SlotRef | RowRef;
|
|
57
|
-
/** A slot of the declaring section, named by its own const — see the module header. */
|
|
58
|
-
type SiblingSlot = Slot;
|
|
59
|
-
/** What a `compute`'s or a fill's `reads` (and a mirror's `source:`) may name: any ref, or a sibling slot. */
|
|
60
|
-
type ComputeRead = Ref | SiblingSlot;
|
|
61
|
-
/** The value a ref refers to, read off the phantom member. */
|
|
62
|
-
type RefValue<R> = R extends {
|
|
63
|
-
readonly __value?: infer V;
|
|
64
|
-
} ? V : unknown;
|
|
65
|
-
/**
|
|
66
|
-
* The value ONE ref hands a declaration that reads it. A slot read is always
|
|
67
|
-
* `| undefined` — the upstream section's page may be disabled, the section
|
|
68
|
-
* unplaced on a given composition, the slot empty — so a body must say what it
|
|
69
|
-
* does with nothing. A fact settles at intake and carries its own null.
|
|
70
|
-
*/
|
|
71
|
-
type ReadValue<R> = R extends SlotRef ? RefValue<R> | undefined : R extends SiblingSlot ? SlotValue<R> | undefined : RefValue<R>;
|
|
72
|
-
/**
|
|
73
|
-
* The positional arguments a reads-declaring callback receives: one value per ref,
|
|
74
|
-
* in `reads` order, each at that ref's own value type. Mutable so the tuple is
|
|
75
|
-
* legal in a rest parameter; the list it maps is the author's `const` one.
|
|
76
|
-
*/
|
|
77
|
-
type RefValues<Reads extends readonly ComputeRead[]> = { -readonly [I in keyof Reads]: ReadValue<Reads[I]>; };
|
|
78
|
-
//#endregion
|
|
79
|
-
export { ComputeRead, DISPLAY_REF_PREFIX, DisplayEntryName, FactRef, ReadValue, Ref, RefValue, RefValues, RowRef, SiblingSlot, SlotRef };
|
package/dist/schema/slot-ref.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
//#region src/schema/slot-ref.ts
|
|
2
|
-
const DISPLAY_REF_PREFIX = "display.";
|
|
3
|
-
function isSlotRef(x) {
|
|
4
|
-
return typeof x === "object" && x !== null && "section" in x && typeof x.section === "string" && "slot" in x && typeof x.slot === "string";
|
|
5
|
-
}
|
|
6
|
-
function isRowRef(x) {
|
|
7
|
-
return typeof x === "object" && x !== null && "kind" in x && x.kind === "row" && "field" in x && typeof x.field === "string";
|
|
8
|
-
}
|
|
9
|
-
function isFactRef(x) {
|
|
10
|
-
return typeof x === "object" && x !== null && "kind" in x && x.kind === "direct" && "field" in x && typeof x.field === "string";
|
|
11
|
-
}
|
|
12
|
-
function isSiblingSlot(x) {
|
|
13
|
-
return typeof x === "object" && x !== null && "type" in x && typeof x.type === "string" && "label" in x && typeof x.label === "string";
|
|
14
|
-
}
|
|
15
|
-
function serializeSlotRef(ref) {
|
|
16
|
-
return {
|
|
17
|
-
kind: "slot",
|
|
18
|
-
section: ref.section,
|
|
19
|
-
slot: ref.slot
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
function serializeRef(ref) {
|
|
23
|
-
if (isSlotRef(ref)) return serializeSlotRef(ref);
|
|
24
|
-
if (isRowRef(ref)) return {
|
|
25
|
-
kind: "row",
|
|
26
|
-
field: ref.field
|
|
27
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
kind: "fact",
|
|
30
|
-
key: ref.field
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function isSerializedSlotRef(ref) {
|
|
34
|
-
return ref.kind !== "fact" && ref.kind !== "row";
|
|
35
|
-
}
|
|
36
|
-
function serializedSlotRefs(reads) {
|
|
37
|
-
return reads.filter(isSerializedSlotRef);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
|
-
export { DISPLAY_REF_PREFIX, isFactRef, isRowRef, isSerializedSlotRef, isSiblingSlot, isSlotRef, serializeRef, serializeSlotRef, serializedSlotRefs };
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { FillBinding } from "./fill-builders.js";
|
|
2
|
-
import { FILL } from "./fill-declaration.js";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
//#region src/schema/slot-types.d.ts
|
|
5
|
-
type SlotBase = {
|
|
6
|
-
[FILL]?: FillBinding;
|
|
7
|
-
locked?: boolean;
|
|
8
|
-
source?: {
|
|
9
|
-
kind: string;
|
|
10
|
-
field?: string;
|
|
11
|
-
transform?: string;
|
|
12
|
-
};
|
|
13
|
-
writeback?: boolean;
|
|
14
|
-
label: string;
|
|
15
|
-
placeholder?: string;
|
|
16
|
-
variant?: {
|
|
17
|
-
cases: readonly string[];
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
/** Kind-level def type for a `text` slot — `SlotBinding<TextSlot>` accepts any text slot. */
|
|
21
|
-
type TextSlot = SlotBase & {
|
|
22
|
-
type: "text";
|
|
23
|
-
size?: string;
|
|
24
|
-
cap?: number;
|
|
25
|
-
};
|
|
26
|
-
/** Kind-level def type for a `number` slot — `SlotBinding<NumberSlot>` accepts any number slot. */
|
|
27
|
-
type NumberSlot = SlotBase & {
|
|
28
|
-
type: "number";
|
|
29
|
-
prefix?: string;
|
|
30
|
-
suffix?: string;
|
|
31
|
-
thousandsSep?: boolean;
|
|
32
|
-
decimals?: boolean;
|
|
33
|
-
maxDigits?: number;
|
|
34
|
-
};
|
|
35
|
-
/** Kind-level def type for a `select` slot — `SlotBinding<SelectSlot>` accepts any select slot. */
|
|
36
|
-
type SelectSlot = SlotBase & {
|
|
37
|
-
type: "select";
|
|
38
|
-
values?: (string | {
|
|
39
|
-
value: string;
|
|
40
|
-
label: string;
|
|
41
|
-
})[];
|
|
42
|
-
options?: {
|
|
43
|
-
source: string;
|
|
44
|
-
};
|
|
45
|
-
creatable?: boolean;
|
|
46
|
-
/** A record field's cross-row distinctness — stored on a record's select or media field only. */
|
|
47
|
-
unique?: boolean;
|
|
48
|
-
};
|
|
49
|
-
/** Kind-level def type for an `image` slot — `SlotBinding<ImageSlot>` accepts any image slot. */
|
|
50
|
-
type ImageSlot = SlotBase & {
|
|
51
|
-
type: "image";
|
|
52
|
-
crop?: unknown;
|
|
53
|
-
unique?: boolean;
|
|
54
|
-
};
|
|
55
|
-
/** Kind-level def type for a `video` slot — `SlotBinding<VideoSlot>` accepts any video slot. */
|
|
56
|
-
type VideoSlot = SlotBase & {
|
|
57
|
-
type: "video";
|
|
58
|
-
playback?: unknown;
|
|
59
|
-
sources?: unknown;
|
|
60
|
-
unique?: boolean;
|
|
61
|
-
};
|
|
62
|
-
/** Kind-level def type for a `tour` slot — `SlotBinding<TourSlot>` accepts any tour slot. */
|
|
63
|
-
type TourSlot = SlotBase & {
|
|
64
|
-
type: "tour";
|
|
65
|
-
unique?: boolean;
|
|
66
|
-
};
|
|
67
|
-
/** Kind-level def type for a `list` slot — the item is `element` (a single primitive) XOR `fields` (a record of slots). */
|
|
68
|
-
type ListSlot = SlotBase & {
|
|
69
|
-
type: "list";
|
|
70
|
-
min?: number;
|
|
71
|
-
max?: number;
|
|
72
|
-
unique?: boolean;
|
|
73
|
-
element?: Slot;
|
|
74
|
-
fields?: Record<string, ListFieldSlot>;
|
|
75
|
-
title?: string;
|
|
76
|
-
/** CI-stamped record-item field order — the declaration order, which JSONB would drop. */
|
|
77
|
-
item_order?: string[];
|
|
78
|
-
};
|
|
79
|
-
/** Kind-level def type for a `poi` slot — one platform-built place; `SlotBinding<PoiSlot>` accepts any poi slot. */
|
|
80
|
-
type PoiSlot = SlotBase & {
|
|
81
|
-
type: "poi";
|
|
82
|
-
};
|
|
83
|
-
/** Kind-level def type for a `url` slot — `SlotBinding<UrlSlot>` accepts any url slot. */
|
|
84
|
-
type UrlSlot = SlotBase & {
|
|
85
|
-
type: "url";
|
|
86
|
-
accepts?: string;
|
|
87
|
-
};
|
|
88
|
-
/** Kind-level def type for a `document` slot — `SlotBinding<DocumentSlot>` accepts any document slot. */
|
|
89
|
-
type DocumentSlot = SlotBase & {
|
|
90
|
-
type: "document";
|
|
91
|
-
unique?: boolean;
|
|
92
|
-
};
|
|
93
|
-
/** Every slot kind an author may declare at a section's top level. */
|
|
94
|
-
type Slot = ListItemSlot | ListSlot;
|
|
95
|
-
/**
|
|
96
|
-
* The slot kinds legal as a list's single item — any value primitive, never a
|
|
97
|
-
* list and never a record. The type half of the depth rules; the slot Zod
|
|
98
|
-
* union enforces the same rules at parse time.
|
|
99
|
-
*/
|
|
100
|
-
type ListItemSlot = TextSlot | NumberSlot | SelectSlot | ImageSlot | VideoSlot | TourSlot | PoiSlot | UrlSlot | DocumentSlot;
|
|
101
|
-
/**
|
|
102
|
-
* The slot kinds legal as a record item's field — any value primitive, or a
|
|
103
|
-
* field-level list whose own item is a single non-record slot. A record (a
|
|
104
|
-
* `fields`-carrying list) is never a field: identity is a flat 4-tuple, and
|
|
105
|
-
* there is no fifth element to address through.
|
|
106
|
-
*/
|
|
107
|
-
type ListFieldSlot = ListItemSlot | (ListSlot & {
|
|
108
|
-
fields?: never;
|
|
109
|
-
});
|
|
110
|
-
//#endregion
|
|
111
|
-
export { DocumentSlot, ImageSlot, ListFieldSlot, ListItemSlot, ListSlot, NumberSlot, PoiSlot, SelectSlot, Slot, TextSlot, TourSlot, UrlSlot, VideoSlot };
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import { SLOT_TYPES, VIDEO_SOURCES } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
//#region src/schema/slot-types.ts
|
|
5
|
-
const slotHeadShape = { locked: z.boolean().optional() };
|
|
6
|
-
const cropConfigShape = { crop: z.object({
|
|
7
|
-
mode: z.enum(["locked", "free"]),
|
|
8
|
-
aspect: z.number().positive().optional(),
|
|
9
|
-
aspectLabel: z.string().optional(),
|
|
10
|
-
mobile: z.object({
|
|
11
|
-
aspect: z.number().positive(),
|
|
12
|
-
breakpoint: z.number().int().positive()
|
|
13
|
-
}).strict().optional()
|
|
14
|
-
}).strict().refine((c) => c.mode !== "locked" || c.aspect != null, { message: "locked crop requires an aspect" }).refine((c) => c.mobile == null || c.aspect != null, { message: "a mobile crop needs a desktop aspect to differ from" }).refine((c) => c.mobile == null || c.aspect == null || Math.abs(c.mobile.aspect - c.aspect) > 1e-4, { message: "a mobile crop equal to the desktop aspect declares nothing — omit it" }).optional() };
|
|
15
|
-
const playbackConfigShape = { playback: z.object({
|
|
16
|
-
autoplay: z.boolean().optional(),
|
|
17
|
-
loop: z.boolean().optional(),
|
|
18
|
-
muted: z.boolean().optional(),
|
|
19
|
-
controls: z.boolean().optional(),
|
|
20
|
-
playsinline: z.boolean().optional(),
|
|
21
|
-
preload: z.enum([
|
|
22
|
-
"none",
|
|
23
|
-
"metadata",
|
|
24
|
-
"auto"
|
|
25
|
-
]).optional()
|
|
26
|
-
}).strict().refine((p) => p.autoplay !== true || p.muted === true, { message: "autoplay requires muted (browsers block unmuted autoplay)" }).optional() };
|
|
27
|
-
const videoSourcesShape = { sources: z.array(z.enum(VIDEO_SOURCES)).nonempty().optional() };
|
|
28
|
-
const SerializedReads = z.array(z.union([
|
|
29
|
-
z.object({
|
|
30
|
-
kind: z.literal("fact"),
|
|
31
|
-
key: z.string().min(1)
|
|
32
|
-
}).strict(),
|
|
33
|
-
z.object({
|
|
34
|
-
kind: z.literal("row"),
|
|
35
|
-
field: z.string().min(1)
|
|
36
|
-
}).strict(),
|
|
37
|
-
z.object({
|
|
38
|
-
kind: z.literal("slot").default("slot"),
|
|
39
|
-
section: z.string().min(1),
|
|
40
|
-
slot: z.string().min(1)
|
|
41
|
-
}).strict()
|
|
42
|
-
])).min(1).optional();
|
|
43
|
-
const slotMetadataShape = {
|
|
44
|
-
label: z.string().min(1),
|
|
45
|
-
placeholder: z.string().optional(),
|
|
46
|
-
variant: z.object({ cases: z.array(z.string().min(1)).min(1) }).strict().optional(),
|
|
47
|
-
source: z.discriminatedUnion("kind", [
|
|
48
|
-
z.object({ kind: z.literal("authored") }),
|
|
49
|
-
z.object({
|
|
50
|
-
kind: z.literal("direct"),
|
|
51
|
-
field: z.string()
|
|
52
|
-
}).strict(),
|
|
53
|
-
z.object({
|
|
54
|
-
kind: z.literal("row"),
|
|
55
|
-
field: z.string().min(1)
|
|
56
|
-
}).strict(),
|
|
57
|
-
z.object({
|
|
58
|
-
kind: z.literal("derived"),
|
|
59
|
-
transform: z.string(),
|
|
60
|
-
reads: SerializedReads
|
|
61
|
-
}).strict()
|
|
62
|
-
]).optional(),
|
|
63
|
-
writeback: z.boolean().optional()
|
|
64
|
-
};
|
|
65
|
-
const SLOT_TYPE_DESCRIPTORS = {
|
|
66
|
-
text: {
|
|
67
|
-
shape: {
|
|
68
|
-
size: z.enum([
|
|
69
|
-
"short",
|
|
70
|
-
"medium",
|
|
71
|
-
"long"
|
|
72
|
-
]).optional(),
|
|
73
|
-
cap: z.number().int().positive().optional()
|
|
74
|
-
},
|
|
75
|
-
default: () => ""
|
|
76
|
-
},
|
|
77
|
-
number: {
|
|
78
|
-
shape: {
|
|
79
|
-
prefix: z.string().optional(),
|
|
80
|
-
suffix: z.string().optional(),
|
|
81
|
-
thousandsSep: z.boolean().optional(),
|
|
82
|
-
decimals: z.boolean().optional(),
|
|
83
|
-
maxDigits: z.number().int().positive().optional()
|
|
84
|
-
},
|
|
85
|
-
default: () => null
|
|
86
|
-
},
|
|
87
|
-
select: {
|
|
88
|
-
shape: {
|
|
89
|
-
values: z.array(z.union([z.string(), z.object({
|
|
90
|
-
value: z.string(),
|
|
91
|
-
label: z.string()
|
|
92
|
-
}).strict()])).optional(),
|
|
93
|
-
options: z.object({ source: z.string() }).strict().optional(),
|
|
94
|
-
creatable: z.boolean().optional()
|
|
95
|
-
},
|
|
96
|
-
default: () => null
|
|
97
|
-
},
|
|
98
|
-
image: {
|
|
99
|
-
shape: { ...cropConfigShape },
|
|
100
|
-
default: () => ({
|
|
101
|
-
url: "",
|
|
102
|
-
alt: ""
|
|
103
|
-
})
|
|
104
|
-
},
|
|
105
|
-
video: {
|
|
106
|
-
shape: {
|
|
107
|
-
...playbackConfigShape,
|
|
108
|
-
...videoSourcesShape
|
|
109
|
-
},
|
|
110
|
-
default: () => ({
|
|
111
|
-
url: "",
|
|
112
|
-
poster: "",
|
|
113
|
-
alt: ""
|
|
114
|
-
})
|
|
115
|
-
},
|
|
116
|
-
tour: {
|
|
117
|
-
shape: {},
|
|
118
|
-
default: () => ({
|
|
119
|
-
tour_id: "",
|
|
120
|
-
url: "",
|
|
121
|
-
poster: "",
|
|
122
|
-
alt: ""
|
|
123
|
-
})
|
|
124
|
-
},
|
|
125
|
-
list: {
|
|
126
|
-
shape: {
|
|
127
|
-
min: z.number().int().nonnegative().optional(),
|
|
128
|
-
max: z.number().int().positive().optional(),
|
|
129
|
-
unique: z.boolean().optional(),
|
|
130
|
-
element: z.lazy(() => ListItemDef).optional(),
|
|
131
|
-
fields: z.record(z.string(), z.lazy(() => ListFieldDef)).optional(),
|
|
132
|
-
title: z.string().optional(),
|
|
133
|
-
item_order: z.array(z.string()).optional()
|
|
134
|
-
},
|
|
135
|
-
default: () => []
|
|
136
|
-
},
|
|
137
|
-
poi: {
|
|
138
|
-
shape: {},
|
|
139
|
-
default: () => null
|
|
140
|
-
},
|
|
141
|
-
url: {
|
|
142
|
-
shape: { accepts: z.string().optional() },
|
|
143
|
-
default: () => ""
|
|
144
|
-
},
|
|
145
|
-
document: {
|
|
146
|
-
shape: {},
|
|
147
|
-
default: () => null
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
function slotMember(type, shape) {
|
|
151
|
-
return z.object({
|
|
152
|
-
type: z.literal(type),
|
|
153
|
-
...slotHeadShape,
|
|
154
|
-
...shape,
|
|
155
|
-
...slotMetadataShape
|
|
156
|
-
}).strict();
|
|
157
|
-
}
|
|
158
|
-
const SCALAR_DEF_MEMBERS = [slotMember("text", SLOT_TYPE_DESCRIPTORS.text.shape), slotMember("number", SLOT_TYPE_DESCRIPTORS.number.shape)];
|
|
159
|
-
const MEDIA_AND_LINK_DEF_MEMBERS = [
|
|
160
|
-
slotMember("image", SLOT_TYPE_DESCRIPTORS.image.shape),
|
|
161
|
-
slotMember("video", SLOT_TYPE_DESCRIPTORS.video.shape),
|
|
162
|
-
slotMember("tour", SLOT_TYPE_DESCRIPTORS.tour.shape),
|
|
163
|
-
slotMember("poi", SLOT_TYPE_DESCRIPTORS.poi.shape),
|
|
164
|
-
slotMember("url", SLOT_TYPE_DESCRIPTORS.url.shape),
|
|
165
|
-
slotMember("document", SLOT_TYPE_DESCRIPTORS.document.shape)
|
|
166
|
-
];
|
|
167
|
-
const LIST_ITEM_DEF_MEMBERS = [
|
|
168
|
-
...SCALAR_DEF_MEMBERS,
|
|
169
|
-
slotMember("select", SLOT_TYPE_DESCRIPTORS.select.shape),
|
|
170
|
-
...MEDIA_AND_LINK_DEF_MEMBERS
|
|
171
|
-
];
|
|
172
|
-
const ListItemDef = z.discriminatedUnion("type", [...LIST_ITEM_DEF_MEMBERS]);
|
|
173
|
-
const FIELD_LIST_DEF_MEMBER = slotMember("list", {
|
|
174
|
-
min: z.number().int().nonnegative().optional(),
|
|
175
|
-
max: z.number().int().positive().optional(),
|
|
176
|
-
unique: z.boolean().optional(),
|
|
177
|
-
element: z.lazy(() => ListItemDef).optional()
|
|
178
|
-
});
|
|
179
|
-
const ROW_UNIQUE = { unique: z.boolean().optional() };
|
|
180
|
-
const ListFieldDef = z.discriminatedUnion("type", [
|
|
181
|
-
...SCALAR_DEF_MEMBERS,
|
|
182
|
-
slotMember("select", {
|
|
183
|
-
...SLOT_TYPE_DESCRIPTORS.select.shape,
|
|
184
|
-
...ROW_UNIQUE
|
|
185
|
-
}),
|
|
186
|
-
slotMember("image", {
|
|
187
|
-
...SLOT_TYPE_DESCRIPTORS.image.shape,
|
|
188
|
-
...ROW_UNIQUE
|
|
189
|
-
}),
|
|
190
|
-
slotMember("video", {
|
|
191
|
-
...SLOT_TYPE_DESCRIPTORS.video.shape,
|
|
192
|
-
...ROW_UNIQUE
|
|
193
|
-
}),
|
|
194
|
-
slotMember("tour", {
|
|
195
|
-
...SLOT_TYPE_DESCRIPTORS.tour.shape,
|
|
196
|
-
...ROW_UNIQUE
|
|
197
|
-
}),
|
|
198
|
-
slotMember("poi", SLOT_TYPE_DESCRIPTORS.poi.shape),
|
|
199
|
-
slotMember("url", SLOT_TYPE_DESCRIPTORS.url.shape),
|
|
200
|
-
slotMember("document", {
|
|
201
|
-
...SLOT_TYPE_DESCRIPTORS.document.shape,
|
|
202
|
-
...ROW_UNIQUE
|
|
203
|
-
}),
|
|
204
|
-
FIELD_LIST_DEF_MEMBER
|
|
205
|
-
]);
|
|
206
|
-
const SLOT_DEF_MEMBERS = [...LIST_ITEM_DEF_MEMBERS, slotMember("list", SLOT_TYPE_DESCRIPTORS.list.shape)];
|
|
207
|
-
const SlotDef = z.discriminatedUnion("type", [...SLOT_DEF_MEMBERS]);
|
|
208
|
-
function defaultForSlotType(type) {
|
|
209
|
-
if (!SLOT_TYPES.includes(type)) return null;
|
|
210
|
-
return SLOT_TYPE_DESCRIPTORS[type].default();
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
//#endregion
|
|
214
|
-
export { ListFieldDef, ListItemDef, SLOT_TYPE_DESCRIPTORS, SerializedReads, SlotDef, defaultForSlotType };
|
package/dist/section/groups.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { ProbeContext } from "../primitives/probe-context.js";
|
|
2
|
-
import { defaultForSlotType } from "../schema/slot-types.js";
|
|
3
|
-
import { previewAnchors, previewPages } from "../schema/section-nav.js";
|
|
4
|
-
import { createElement } from "react";
|
|
5
|
-
import { renderToStaticMarkup } from "react-dom/server";
|
|
6
|
-
|
|
7
|
-
//#region src/section/groups.ts
|
|
8
|
-
var GroupDerivationError = class extends Error {
|
|
9
|
-
fault;
|
|
10
|
-
constructor(fault, message) {
|
|
11
|
-
super(message);
|
|
12
|
-
this.fault = fault;
|
|
13
|
-
this.name = "GroupDerivationError";
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
function deriveGroups(section, states = []) {
|
|
17
|
-
const { key, schema } = section;
|
|
18
|
-
const slotIds = Object.keys(schema.slots);
|
|
19
|
-
const blank = {};
|
|
20
|
-
for (const [id, def] of Object.entries(schema.slots)) blank[id] = defaultForSlotType(def.type);
|
|
21
|
-
const cases = schema.meta.display?.variant?.cases ?? [""];
|
|
22
|
-
const labels = /* @__PURE__ */ new Map();
|
|
23
|
-
const cardsOf = /* @__PURE__ */ new Map();
|
|
24
|
-
const probe = {
|
|
25
|
-
kind: "groups",
|
|
26
|
-
group(id, label) {
|
|
27
|
-
const prior = labels.get(id);
|
|
28
|
-
if (prior !== void 0 && prior !== label) throw new GroupDerivationError("label-conflict", `Section "${key}": group "${id}" is labeled both "${prior}" and "${label}".`);
|
|
29
|
-
labels.set(id, label);
|
|
30
|
-
},
|
|
31
|
-
member(slotId, groupId) {
|
|
32
|
-
let cards = cardsOf.get(slotId);
|
|
33
|
-
if (cards === void 0) cardsOf.set(slotId, cards = /* @__PURE__ */ new Set());
|
|
34
|
-
cards.add(groupId);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
const nav = {
|
|
38
|
-
selfAnchor: key,
|
|
39
|
-
anchors: previewAnchors(),
|
|
40
|
-
pages: previewPages()
|
|
41
|
-
};
|
|
42
|
-
const Component = section;
|
|
43
|
-
for (const state of [blank, ...states]) for (const variant of cases) renderToStaticMarkup(createElement(ProbeContext.Provider, { value: probe }, createElement(Component, {
|
|
44
|
-
slots: state,
|
|
45
|
-
nav,
|
|
46
|
-
variant
|
|
47
|
-
})));
|
|
48
|
-
for (const [slotId, cards] of cardsOf) if (cards.size > 1) {
|
|
49
|
-
const [a, b] = [...cards].sort();
|
|
50
|
-
throw new GroupDerivationError("slot-in-two-groups", `Section "${key}": slot "${slotId}" is rendered in two groups, "${a}" and "${b}".`);
|
|
51
|
-
}
|
|
52
|
-
const groups = [];
|
|
53
|
-
for (const [id, label] of labels) {
|
|
54
|
-
const members = slotIds.filter((slotId) => cardsOf.get(slotId)?.has(id) === true);
|
|
55
|
-
if (members.length === 0) throw new GroupDerivationError("empty", `Section "${key}": group "${id}" holds no slot in any state — a card with nothing in it.`);
|
|
56
|
-
groups.push({
|
|
57
|
-
id,
|
|
58
|
-
label,
|
|
59
|
-
members
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
const position = (group) => slotIds.indexOf(group.members[0]);
|
|
63
|
-
groups.sort((a, b) => position(a) - position(b));
|
|
64
|
-
return groups;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
//#endregion
|
|
68
|
-
export { GroupDerivationError, deriveGroups };
|