@homepages/concrete 8.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 +988 -0
- package/README.md +20 -9
- package/codemods/list-grammar.mjs +923 -0
- package/codemods/manifest.json +60 -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 +251 -33
- 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 +34 -10
- 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-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 -1
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +15 -20
- 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 +74 -10
- package/dist/packages/internal/section-contracts/dist/select-contract.js +0 -8
- package/dist/packages/internal/section-contracts/dist/source-contract.js +103 -46
- 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 +42 -21
- package/dist/packages/internal/source-resolution/dist/index.js +113 -72
- 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 +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 +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 +49 -3
- 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 +335 -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 +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 -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 +28 -24
- 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/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/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,4 +1,365 @@
|
|
|
1
|
-
import "../../template-contracts/dist/
|
|
2
|
-
import "../../
|
|
3
|
-
import "
|
|
4
|
-
import "
|
|
1
|
+
import { normalizeAddressValue } from "../../template-contracts/dist/address-value.js";
|
|
2
|
+
import { DISPLAY_ENTRIES } from "../../template-contracts/dist/slot-catalog.js";
|
|
3
|
+
import { elementIdentityKey, heldRowTableOf, holderOf, mirrorRefOf, rowTablesOf, sectionSlotAt, slotTableOf } from "../../template-contracts/dist/ref-locate.js";
|
|
4
|
+
import { memberSourceOf } from "../../template-contracts/dist/row-sources.js";
|
|
5
|
+
import { isSlotOverridden, itemOverridesForSlot, objectFieldOf, objectFieldSlotId } from "../../template-contracts/dist/slot-overrides.js";
|
|
6
|
+
import { declaredSlotRefs } from "./derive-source.js";
|
|
7
|
+
import { declaredDisplay } from "./display.js";
|
|
8
|
+
import { computedRow, isGrammarList, objectElementFields, projectElements, readResolvedRowMember } from "./list-grammar.js";
|
|
9
|
+
import { identifiedElements, inDeclaredCases, projectComputedRows, resolveDerivedHandle, rowComputesOf } from "./bake-property-ref.js";
|
|
10
|
+
import { isDisplayOverridden } from "../../template-contracts/dist/display-overrides.js";
|
|
11
|
+
import { mergeLinkedValue } from "./linked-merge.js";
|
|
12
|
+
import { mergeSourcedItems } from "./item-merge.js";
|
|
13
|
+
import { keepOverriddenItemFields } from "./item-overrides.js";
|
|
14
|
+
|
|
15
|
+
//#region ../../internal/fill-bake/dist/compute-reads.js
|
|
16
|
+
const DISPLAY_PREFIX = "display.";
|
|
17
|
+
const nodeId = (instanceId, key) => `${instanceId} ${key}`;
|
|
18
|
+
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
19
|
+
function storedRefValue(instance, key) {
|
|
20
|
+
if (instance === void 0) return void 0;
|
|
21
|
+
if (key === `${DISPLAY_PREFIX}visibility`) return instance.enabled ? "visible" : "hidden";
|
|
22
|
+
if (key === `${DISPLAY_PREFIX}variant`) return instance.variant;
|
|
23
|
+
if (Object.hasOwn(instance.slots, key)) return instance.slots[key];
|
|
24
|
+
const field = objectFieldOf(key);
|
|
25
|
+
if (field === null) return void 0;
|
|
26
|
+
const object = instance.slots[field.object];
|
|
27
|
+
return isRecord(object) ? object[field.field] : void 0;
|
|
28
|
+
}
|
|
29
|
+
function applyComputeReads(input) {
|
|
30
|
+
const declarations = collectDeclarations(input.sections);
|
|
31
|
+
if (declarations.size === 0) return {
|
|
32
|
+
contentDoc: input.contentDoc,
|
|
33
|
+
changed: false,
|
|
34
|
+
changes: []
|
|
35
|
+
};
|
|
36
|
+
const working = new Map(input.contentDoc.instances.map((inst) => [inst.instance_id, { ...inst }]));
|
|
37
|
+
const cloned = /* @__PURE__ */ new Set();
|
|
38
|
+
const ownSlots = (inst) => {
|
|
39
|
+
if (!cloned.has(inst.instance_id)) {
|
|
40
|
+
inst.slots = { ...inst.slots };
|
|
41
|
+
cloned.add(inst.instance_id);
|
|
42
|
+
}
|
|
43
|
+
return inst.slots;
|
|
44
|
+
};
|
|
45
|
+
const writeSlot = (inst, key, value) => {
|
|
46
|
+
const field = objectFieldOf(key);
|
|
47
|
+
const slots = ownSlots(inst);
|
|
48
|
+
if (field === null || Object.hasOwn(slots, key)) {
|
|
49
|
+
slots[key] = value;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const object = slots[field.object];
|
|
53
|
+
slots[field.object] = {
|
|
54
|
+
...isRecord(object) ? object : {},
|
|
55
|
+
[field.field]: value
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
const { facts } = input;
|
|
59
|
+
const localKeyOf = (instanceId) => (input.typing?.get(instanceId) ?? input.sections.get(instanceId))?.localKey;
|
|
60
|
+
const targetFrom = (fromInstance, ref) => input.placement.locate({
|
|
61
|
+
kind: "section",
|
|
62
|
+
section: ref.section,
|
|
63
|
+
slot: ref.slot
|
|
64
|
+
}, {
|
|
65
|
+
instanceId: fromInstance,
|
|
66
|
+
section: localKeyOf(fromInstance) ?? ""
|
|
67
|
+
})?.instanceId;
|
|
68
|
+
const targetOf = (decl, ref) => targetFrom(decl.instanceId, ref);
|
|
69
|
+
const readStored = (instanceId, key) => storedRefValue(instanceId === void 0 ? void 0 : working.get(instanceId), key);
|
|
70
|
+
const typingOf = (instanceId) => input.typing?.get(instanceId) ?? input.sections.get(instanceId);
|
|
71
|
+
const sectionSlots = (localKey) => {
|
|
72
|
+
const instanceId = input.placement.readable(localKey);
|
|
73
|
+
return instanceId === void 0 ? void 0 : typingOf(instanceId)?.schema.slots;
|
|
74
|
+
};
|
|
75
|
+
const tableAt = (instanceId, slot) => {
|
|
76
|
+
const typing = instanceId === void 0 ? void 0 : typingOf(instanceId);
|
|
77
|
+
if (typing === void 0) return null;
|
|
78
|
+
return slotTableOf({
|
|
79
|
+
section: typing.localKey,
|
|
80
|
+
slots: typing.schema.slots ?? {},
|
|
81
|
+
sectionSlots
|
|
82
|
+
}, slot);
|
|
83
|
+
};
|
|
84
|
+
const settledRows = /* @__PURE__ */ new Map();
|
|
85
|
+
const projectionOf = (decl, table) => ({
|
|
86
|
+
element: decl.def.element ?? {},
|
|
87
|
+
table,
|
|
88
|
+
facts,
|
|
89
|
+
computes: rowComputesOf(decl.key, objectElementFields(decl.def), facts, decl.section.bakeContext)
|
|
90
|
+
});
|
|
91
|
+
const listValue = (inst, decl, table, items) => {
|
|
92
|
+
const current = inst.slots[decl.key];
|
|
93
|
+
if (objectElementFields(decl.def) === void 0) return mergeLinkedValue(current, items);
|
|
94
|
+
return mergeSourcedItems({
|
|
95
|
+
current: Array.isArray(current) ? current : [],
|
|
96
|
+
freshSource: items,
|
|
97
|
+
overrides: itemOverridesForSlot(inst.slot_overrides, decl.key),
|
|
98
|
+
generatedFields: [],
|
|
99
|
+
idKey: elementIdentityKey(table?.table ?? null),
|
|
100
|
+
membership: "source"
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
const memberAt = (instanceId, rowPath, field) => {
|
|
104
|
+
const typing = input.typing?.get(instanceId) ?? input.sections.get(instanceId);
|
|
105
|
+
const def = typing === void 0 ? void 0 : sectionSlotAt(typing.schema.slots ?? {}, rowPath);
|
|
106
|
+
const stored = readStored(instanceId, rowPath);
|
|
107
|
+
if (def?.type === "address") return { value: readResolvedRowMember({
|
|
108
|
+
table: null,
|
|
109
|
+
id: null,
|
|
110
|
+
element: normalizeAddressValue(stored)
|
|
111
|
+
}, field, facts) };
|
|
112
|
+
const rowId = typeof stored === "string" && stored !== "" ? stored : null;
|
|
113
|
+
const table = def === void 0 ? null : heldRowTableOf(facts, rowTablesOf(def), rowId);
|
|
114
|
+
const settled = settledRows.get(nodeId(instanceId, rowPath));
|
|
115
|
+
const row = settled !== void 0 && settled.id === rowId ? settled : {
|
|
116
|
+
table,
|
|
117
|
+
id: rowId
|
|
118
|
+
};
|
|
119
|
+
if (row.table === null && row.element === void 0 && row.id !== null) return void 0;
|
|
120
|
+
return { value: readResolvedRowMember(row, field, facts) };
|
|
121
|
+
};
|
|
122
|
+
const holderPath = (decl, slot) => {
|
|
123
|
+
const slots = decl.section.schema.slots ?? {};
|
|
124
|
+
const field = objectFieldOf(decl.key);
|
|
125
|
+
const siblings = field === null ? void 0 : slots[field.object]?.fields;
|
|
126
|
+
return holderOf(slots, field === null || siblings === void 0 ? {} : {
|
|
127
|
+
container: field.object,
|
|
128
|
+
siblings
|
|
129
|
+
}, slot)?.path;
|
|
130
|
+
};
|
|
131
|
+
const rowReaderOf = (decl) => (member, slot) => {
|
|
132
|
+
if (slot === void 0) throw new Error(`reads the row member "${member}" outside a list's item`);
|
|
133
|
+
const path = holderPath(decl, slot);
|
|
134
|
+
return path === void 0 ? void 0 : memberAt(decl.instanceId, path, member)?.value;
|
|
135
|
+
};
|
|
136
|
+
const valueOf = (inst, decl) => {
|
|
137
|
+
if (decl.kind === "reader") return memberAt(decl.instanceId, decl.rowPath, decl.field);
|
|
138
|
+
if (decl.kind === "mirror") {
|
|
139
|
+
const upstreamInstance = targetOf(decl, decl.ref);
|
|
140
|
+
const upstream = readStored(upstreamInstance, decl.ref.slot);
|
|
141
|
+
const table = tableAt(decl.instanceId, decl.key);
|
|
142
|
+
if (decl.def.type === "row") {
|
|
143
|
+
const row = computedRow(upstream, rowTablesOf(decl.def), facts);
|
|
144
|
+
settledRows.set(nodeId(decl.instanceId, decl.key), {
|
|
145
|
+
...row,
|
|
146
|
+
element: upstream
|
|
147
|
+
});
|
|
148
|
+
return { value: row.id };
|
|
149
|
+
}
|
|
150
|
+
if (decl.def.type !== "list") return { value: upstream ?? null };
|
|
151
|
+
const items = projectElements(identifiedElements(Array.isArray(upstream) ? upstream : [], table), projectionOf(decl, table));
|
|
152
|
+
return { value: listValue(inst, decl, table, items) };
|
|
153
|
+
}
|
|
154
|
+
const resolved = resolveDerivedHandle(decl.transform, decl.source, facts, decl.section.bakeContext, { slot_id: decl.key }, (ref) => readStored(targetOf(decl, ref), ref.slot), rowReaderOf(decl));
|
|
155
|
+
if (decl.def.type === "row") {
|
|
156
|
+
const row = computedRow(resolved?.value ?? null, rowTablesOf(decl.def), facts);
|
|
157
|
+
settledRows.set(nodeId(decl.instanceId, decl.key), row);
|
|
158
|
+
return { value: row.id };
|
|
159
|
+
}
|
|
160
|
+
if (isGrammarList(decl.def)) {
|
|
161
|
+
const table = tableAt(decl.instanceId, decl.key);
|
|
162
|
+
const items = projectElements(identifiedElements(resolved?.value ?? [], table), projectionOf(decl, table));
|
|
163
|
+
return { value: listValue(inst, decl, table, items) };
|
|
164
|
+
}
|
|
165
|
+
const isList = decl.def.type === "list";
|
|
166
|
+
const fresh = resolved === null ? isList ? [] : null : projectComputedRows(resolved.value ?? (isList ? [] : null), decl.def.fields, rowComputesOf(decl.key, decl.def.fields, facts, decl.section.bakeContext));
|
|
167
|
+
const stored = storedRefValue(inst, decl.key);
|
|
168
|
+
return { value: keepOverriddenItemFields(mergeLinkedValue(stored, fresh), stored, itemOverridesForSlot(inst.slot_overrides, decl.key)) };
|
|
169
|
+
};
|
|
170
|
+
const write = (decl) => {
|
|
171
|
+
const inst = working.get(decl.instanceId);
|
|
172
|
+
if (inst === void 0) return false;
|
|
173
|
+
if (decl.kind === "display") return writeDisplay(inst, decl, facts, (ref) => readStored(targetOf(decl, ref), ref.slot), rowReaderOf(decl));
|
|
174
|
+
if (isSlotOverridden(inst.slot_overrides, decl.key)) return false;
|
|
175
|
+
const settled = valueOf(inst, decl);
|
|
176
|
+
if (settled === void 0 || sameValue(storedRefValue(inst, decl.key), settled.value)) return false;
|
|
177
|
+
writeSlot(inst, decl.key, settled.value);
|
|
178
|
+
return true;
|
|
179
|
+
};
|
|
180
|
+
const changes = [];
|
|
181
|
+
const settled = /* @__PURE__ */ new Set();
|
|
182
|
+
const onWalk = /* @__PURE__ */ new Set();
|
|
183
|
+
const settle = (decl) => {
|
|
184
|
+
const id = nodeId(decl.instanceId, decl.key);
|
|
185
|
+
if (settled.has(id) || onWalk.has(id)) return;
|
|
186
|
+
onWalk.add(id);
|
|
187
|
+
for (const ref of decl.slotRefs) {
|
|
188
|
+
const target = targetOf(decl, ref);
|
|
189
|
+
const upstream = target === void 0 ? void 0 : declarations.get(nodeId(target, ref.slot));
|
|
190
|
+
if (upstream !== void 0) settle(upstream);
|
|
191
|
+
}
|
|
192
|
+
if (decl.kind === "derived" || decl.kind === "display") for (const slot of memberReadSlots(decl.source)) {
|
|
193
|
+
const path = holderPath(decl, slot);
|
|
194
|
+
const holder = path === void 0 ? void 0 : declarations.get(nodeId(decl.instanceId, path));
|
|
195
|
+
if (holder !== void 0) settle(holder);
|
|
196
|
+
}
|
|
197
|
+
onWalk.delete(id);
|
|
198
|
+
settled.add(id);
|
|
199
|
+
if (write(decl)) changes.push({
|
|
200
|
+
instance_id: decl.instanceId,
|
|
201
|
+
slot: decl.key
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
for (const decl of declarations.values()) settle(decl);
|
|
205
|
+
if (changes.length === 0) return {
|
|
206
|
+
contentDoc: input.contentDoc,
|
|
207
|
+
changed: false,
|
|
208
|
+
changes
|
|
209
|
+
};
|
|
210
|
+
const instances = input.contentDoc.instances.map((inst) => working.get(inst.instance_id) ?? inst);
|
|
211
|
+
return {
|
|
212
|
+
contentDoc: {
|
|
213
|
+
...input.contentDoc,
|
|
214
|
+
instances
|
|
215
|
+
},
|
|
216
|
+
changed: true,
|
|
217
|
+
changes
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
function writeDisplay(inst, decl, facts, readSlot, readRow) {
|
|
221
|
+
if (isDisplayOverridden(inst.display_overrides, decl.displayEntry)) return false;
|
|
222
|
+
const resolved = resolveDerivedHandle(decl.transform, decl.source, facts, decl.section.bakeContext, { display_entry: decl.displayEntry }, readSlot, readRow);
|
|
223
|
+
if (resolved === null) return false;
|
|
224
|
+
const def = declaredDisplay(decl.section.schema)[decl.displayEntry];
|
|
225
|
+
const answer = def === void 0 ? null : inDeclaredCases(def, decl.displayEntry, resolved.value, decl.section.bakeContext);
|
|
226
|
+
if (answer === null) return false;
|
|
227
|
+
if (decl.displayEntry === "visibility") {
|
|
228
|
+
const enabled = answer !== "hidden";
|
|
229
|
+
if (inst.enabled === enabled) return false;
|
|
230
|
+
inst.enabled = enabled;
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
if (inst.variant === answer) return false;
|
|
234
|
+
inst.variant = answer;
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
function collectDeclarations(sections) {
|
|
238
|
+
const out = /* @__PURE__ */ new Map();
|
|
239
|
+
for (const [instanceId, section] of sections) {
|
|
240
|
+
const slots = section.schema.slots ?? {};
|
|
241
|
+
const placed = [];
|
|
242
|
+
for (const [key, def] of Object.entries(slots)) {
|
|
243
|
+
placed.push({
|
|
244
|
+
path: key,
|
|
245
|
+
def,
|
|
246
|
+
reader: {}
|
|
247
|
+
});
|
|
248
|
+
if (def.type !== "object") continue;
|
|
249
|
+
const siblings = def.fields ?? {};
|
|
250
|
+
for (const [field, fieldDef] of Object.entries(siblings)) placed.push({
|
|
251
|
+
path: objectFieldSlotId(key, field),
|
|
252
|
+
def: fieldDef,
|
|
253
|
+
reader: {
|
|
254
|
+
container: key,
|
|
255
|
+
siblings
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
for (const { path, def } of placed) {
|
|
260
|
+
const mirror = mirrorRefOf(def);
|
|
261
|
+
if (mirror !== null) {
|
|
262
|
+
out.set(nodeId(instanceId, path), {
|
|
263
|
+
kind: "mirror",
|
|
264
|
+
instanceId,
|
|
265
|
+
key: path,
|
|
266
|
+
slotRefs: [mirror],
|
|
267
|
+
section,
|
|
268
|
+
ref: mirror,
|
|
269
|
+
def
|
|
270
|
+
});
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
const transform = transformOf(def.source);
|
|
274
|
+
const slotRefs = declaredSlotRefs(def.source);
|
|
275
|
+
if (transform === null || slotRefs.length === 0) continue;
|
|
276
|
+
out.set(nodeId(instanceId, path), {
|
|
277
|
+
kind: "derived",
|
|
278
|
+
instanceId,
|
|
279
|
+
key: path,
|
|
280
|
+
slotRefs,
|
|
281
|
+
section,
|
|
282
|
+
transform,
|
|
283
|
+
source: def.source,
|
|
284
|
+
def
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
const settledRowAt = (reader, slot) => {
|
|
288
|
+
const rowPath = holderOf(slots, reader, slot)?.path;
|
|
289
|
+
const row = rowPath === void 0 ? void 0 : out.get(nodeId(instanceId, rowPath));
|
|
290
|
+
return row !== void 0 && (row.kind === "mirror" || row.kind === "derived") && row.def.type === "row" ? rowPath : void 0;
|
|
291
|
+
};
|
|
292
|
+
for (let joined = true; joined;) {
|
|
293
|
+
joined = false;
|
|
294
|
+
for (const { path, def, reader } of placed) {
|
|
295
|
+
if (out.has(nodeId(instanceId, path))) continue;
|
|
296
|
+
const member = memberSourceOf(def.source);
|
|
297
|
+
const rowPath = member === null ? void 0 : settledRowAt(reader, member.slot);
|
|
298
|
+
if (member !== null && rowPath !== void 0) {
|
|
299
|
+
out.set(nodeId(instanceId, path), {
|
|
300
|
+
kind: "reader",
|
|
301
|
+
instanceId,
|
|
302
|
+
key: path,
|
|
303
|
+
slotRefs: [{
|
|
304
|
+
kind: "section",
|
|
305
|
+
section: section.localKey,
|
|
306
|
+
slot: rowPath
|
|
307
|
+
}],
|
|
308
|
+
section,
|
|
309
|
+
rowPath,
|
|
310
|
+
field: member.field
|
|
311
|
+
});
|
|
312
|
+
joined = true;
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
const transform = transformOf(def.source);
|
|
316
|
+
if (transform === null || !memberReadSlots(def.source).some((slot) => settledRowAt(reader, slot) !== void 0)) continue;
|
|
317
|
+
out.set(nodeId(instanceId, path), {
|
|
318
|
+
kind: "derived",
|
|
319
|
+
instanceId,
|
|
320
|
+
key: path,
|
|
321
|
+
slotRefs: [],
|
|
322
|
+
section,
|
|
323
|
+
transform,
|
|
324
|
+
source: def.source,
|
|
325
|
+
def
|
|
326
|
+
});
|
|
327
|
+
joined = true;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
const display = declaredDisplay(section.schema);
|
|
331
|
+
for (const entry of DISPLAY_ENTRIES) {
|
|
332
|
+
const source = display[entry]?.source;
|
|
333
|
+
const transform = transformOf(source);
|
|
334
|
+
const slotRefs = declaredSlotRefs(source);
|
|
335
|
+
if (transform === null) continue;
|
|
336
|
+
if (slotRefs.length === 0 && !memberReadSlots(source).some((slot) => settledRowAt({}, slot) !== void 0)) continue;
|
|
337
|
+
const key = `${DISPLAY_PREFIX}${entry}`;
|
|
338
|
+
out.set(nodeId(instanceId, key), {
|
|
339
|
+
kind: "display",
|
|
340
|
+
instanceId,
|
|
341
|
+
key,
|
|
342
|
+
transform,
|
|
343
|
+
source,
|
|
344
|
+
slotRefs,
|
|
345
|
+
section,
|
|
346
|
+
displayEntry: entry
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return out;
|
|
351
|
+
}
|
|
352
|
+
function memberReadSlots(source) {
|
|
353
|
+
return (isRecord(source) && Array.isArray(source["reads"]) ? source["reads"] : []).flatMap((entry) => isRecord(entry) && entry["kind"] === "row" && typeof entry["slot"] === "string" ? [entry["slot"]] : []);
|
|
354
|
+
}
|
|
355
|
+
function transformOf(source) {
|
|
356
|
+
if (source === null || typeof source !== "object") return null;
|
|
357
|
+
const { kind, transform } = source;
|
|
358
|
+
return kind === "derived" && typeof transform === "string" ? transform : null;
|
|
359
|
+
}
|
|
360
|
+
function sameValue(a, b) {
|
|
361
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
//#endregion
|
|
365
|
+
export { applyComputeReads, storedRefValue };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readAsRecords, storedAsRefs } from "../../template-contracts/dist/registry-facts.js";
|
|
2
|
+
import { readFactRef } from "../../source-resolution/dist/index.js";
|
|
2
3
|
|
|
3
4
|
//#region ../../internal/fill-bake/dist/derive-source.js
|
|
4
5
|
function readsOf(source) {
|
|
@@ -6,9 +7,9 @@ function readsOf(source) {
|
|
|
6
7
|
const reads = source.reads;
|
|
7
8
|
return Array.isArray(reads) ? reads : [];
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
+
function sectionRefOf(entry) {
|
|
10
11
|
const { kind, section, slot } = entry ?? {};
|
|
11
|
-
return kind === "
|
|
12
|
+
return kind === "section" && typeof section === "string" && typeof slot === "string" ? {
|
|
12
13
|
kind,
|
|
13
14
|
section,
|
|
14
15
|
slot
|
|
@@ -16,36 +17,49 @@ function slotRefOf(entry) {
|
|
|
16
17
|
}
|
|
17
18
|
function declaredReads(source) {
|
|
18
19
|
return readsOf(source).map((entry, i) => {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const record = entry ?? {};
|
|
21
|
+
const { kind, key, field } = record;
|
|
22
|
+
if (kind === "home" && typeof key === "string") return {
|
|
23
|
+
kind: "home",
|
|
22
24
|
key
|
|
23
25
|
};
|
|
24
|
-
if (kind === "row" && typeof field === "string")
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
if (kind === "row" && typeof field === "string") {
|
|
27
|
+
const { slot } = record;
|
|
28
|
+
return typeof slot === "string" && slot !== "" ? {
|
|
29
|
+
kind: "row",
|
|
30
|
+
slot,
|
|
31
|
+
field
|
|
32
|
+
} : {
|
|
33
|
+
kind: "row",
|
|
34
|
+
field
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (kind === "element") return { kind: "element" };
|
|
38
|
+
const sectionRef = sectionRefOf(entry);
|
|
39
|
+
if (sectionRef !== null) return sectionRef;
|
|
40
|
+
throw new Error(`reads[${String(i)}] is not a home, section, row or element ref: ${JSON.stringify(entry)}`);
|
|
31
41
|
});
|
|
32
42
|
}
|
|
33
43
|
function declaredSlotRefs(source) {
|
|
34
|
-
return readsOf(source).flatMap((entry) =>
|
|
44
|
+
return readsOf(source).flatMap((entry) => sectionRefOf(entry) ?? []);
|
|
35
45
|
}
|
|
36
46
|
function readsAnySlot(source) {
|
|
37
47
|
return declaredSlotRefs(source).length > 0;
|
|
38
48
|
}
|
|
39
|
-
function callDerived(fn, source, facts, readSlot, readRow) {
|
|
40
|
-
return fn(...declaredReads(source).map((ref) => {
|
|
41
|
-
if (ref.kind === "
|
|
49
|
+
function callDerived(fn, source, facts, readSlot, readRow, readElement) {
|
|
50
|
+
return storedAsRefs(fn(...declaredReads(source).map((ref) => {
|
|
51
|
+
if (ref.kind === "home") return readFactRef(facts, ref.key);
|
|
42
52
|
if (ref.kind === "row") {
|
|
43
|
-
if (readRow === void 0) throw new Error(`reads the row member "${ref.field}"
|
|
44
|
-
return readRow(ref.field);
|
|
53
|
+
if (readRow === void 0) throw new Error(`reads the row member "${ref.field}" with no row in scope`);
|
|
54
|
+
return "slot" in ref ? readRow(ref.field, ref.slot) : readRow(ref.field);
|
|
55
|
+
}
|
|
56
|
+
if (ref.kind === "element") {
|
|
57
|
+
if (readElement === void 0) throw new Error("reads the element outside a list's item");
|
|
58
|
+
return readElement();
|
|
45
59
|
}
|
|
46
60
|
return readSlot?.(ref);
|
|
47
|
-
}));
|
|
61
|
+
}).map((value) => readAsRecords(value, facts))));
|
|
48
62
|
}
|
|
49
63
|
|
|
50
64
|
//#endregion
|
|
51
|
-
export { callDerived, declaredReads, declaredSlotRefs, readsAnySlot };
|
|
65
|
+
export { callDerived, declaredReads, declaredSlotRefs, readFactRef, readsAnySlot };
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { projectTableRows, readFactRef, readRowMember } from "../../source-resolution/dist/index.js";
|
|
1
2
|
import { callDerived, declaredReads, declaredSlotRefs, readsAnySlot } from "./derive-source.js";
|
|
2
3
|
import { declaredDisplay } from "./display.js";
|
|
3
|
-
import {
|
|
4
|
-
import "./
|
|
4
|
+
import { decisionProducing, isGrammarList, objectElementFields, readResolvedRowMember, readsElementRows, rowIdentity } from "./list-grammar.js";
|
|
5
|
+
import { bakeDisplayEntries, bakePropertyRefSlots, boundFactKey, derivedSource, identifiedElements, projectComputedRows, resolveDerivedHandle, resolveDirectField, rowComputesOf, topLevelRowReader } from "./bake-property-ref.js";
|
|
6
|
+
import { mergeLinkedValue } from "./linked-merge.js";
|
|
7
|
+
import { mergeSourcedItems } from "./item-merge.js";
|
|
8
|
+
import { keepOverriddenItemFields } from "./item-overrides.js";
|
|
9
|
+
import { applyComputeReads, storedRefValue } from "./compute-reads.js";
|
|
5
10
|
|
|
6
|
-
export { bakeDisplayEntries, bakePropertyRefSlots
|
|
11
|
+
export { applyComputeReads, bakeDisplayEntries, bakePropertyRefSlots };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { mergeLinkedValue } from "./linked-merge.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../internal/fill-bake/dist/item-merge.js
|
|
4
|
+
const isTempId = (id) => typeof id === "string" && id.startsWith("tmp_");
|
|
5
|
+
function spelledUnder(idKey, cur) {
|
|
6
|
+
if (idKey === "id" || typeof cur[idKey] === "string" || typeof cur["id"] !== "string") return cur;
|
|
7
|
+
const { id, ...rest } = cur;
|
|
8
|
+
return {
|
|
9
|
+
[idKey]: id,
|
|
10
|
+
...rest
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function oneItemPerIdentity(idKey, current) {
|
|
14
|
+
const out = [];
|
|
15
|
+
const at = /* @__PURE__ */ new Map();
|
|
16
|
+
for (const cur of current) {
|
|
17
|
+
const id = cur[idKey];
|
|
18
|
+
const first = typeof id === "string" ? at.get(id) : void 0;
|
|
19
|
+
if (first === void 0) {
|
|
20
|
+
if (typeof id === "string") at.set(id, out.length);
|
|
21
|
+
out.push(cur);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
out[first] = {
|
|
25
|
+
...cur,
|
|
26
|
+
...out[first]
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
function mergeItem(cur, fresh, itemOverrides, generatedFields, idKey, keepUnbaked) {
|
|
32
|
+
const row = keepUnbaked ? { ...cur } : {};
|
|
33
|
+
for (const [field, freshValue] of Object.entries(fresh)) {
|
|
34
|
+
if (field === idKey) {
|
|
35
|
+
row[field] = freshValue;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
row[field] = itemOverrides?.[field] === true ? cur[field] : mergeLinkedValue(cur[field], freshValue);
|
|
39
|
+
}
|
|
40
|
+
for (const field of generatedFields) if (field in cur) row[field] = cur[field];
|
|
41
|
+
return row;
|
|
42
|
+
}
|
|
43
|
+
function mergeSourcedItems(input) {
|
|
44
|
+
const membership = input.membership ?? "table";
|
|
45
|
+
const current = oneItemPerIdentity(input.idKey, input.current.map((cur) => spelledUnder(input.idKey, cur)));
|
|
46
|
+
if (membership === "table") return mergeTableItems({
|
|
47
|
+
...input,
|
|
48
|
+
current
|
|
49
|
+
});
|
|
50
|
+
const { freshSource, overrides, generatedFields, idKey } = input;
|
|
51
|
+
const currentById = /* @__PURE__ */ new Map();
|
|
52
|
+
for (const cur of current) {
|
|
53
|
+
const id = cur[idKey];
|
|
54
|
+
if (typeof id === "string") currentById.set(id, cur);
|
|
55
|
+
}
|
|
56
|
+
if (membership === "source") return freshSource.map((fresh) => {
|
|
57
|
+
const id = fresh[idKey];
|
|
58
|
+
const cur = typeof id === "string" ? currentById.get(id) : void 0;
|
|
59
|
+
return cur === void 0 ? fresh : mergeItem(cur, fresh, overrides?.[id], generatedFields, idKey, true);
|
|
60
|
+
});
|
|
61
|
+
const freshById = /* @__PURE__ */ new Map();
|
|
62
|
+
for (const fresh of freshSource) {
|
|
63
|
+
const id = fresh[idKey];
|
|
64
|
+
if (typeof id === "string") freshById.set(id, fresh);
|
|
65
|
+
}
|
|
66
|
+
return current.map((cur) => {
|
|
67
|
+
const id = cur[idKey];
|
|
68
|
+
const fresh = typeof id === "string" ? freshById.get(id) : void 0;
|
|
69
|
+
return fresh === void 0 ? cur : mergeItem(cur, fresh, overrides?.[id], generatedFields, idKey, true);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function mergeTableItems(input) {
|
|
73
|
+
const { current, freshSource, overrides, removed, generatedFields, idKey } = input;
|
|
74
|
+
const freshById = /* @__PURE__ */ new Map();
|
|
75
|
+
for (const f of freshSource) {
|
|
76
|
+
const id = f[idKey];
|
|
77
|
+
if (typeof id === "string") freshById.set(id, f);
|
|
78
|
+
}
|
|
79
|
+
const out = [];
|
|
80
|
+
const emitted = /* @__PURE__ */ new Set();
|
|
81
|
+
for (const cur of current) {
|
|
82
|
+
const id = cur[idKey];
|
|
83
|
+
if (isTempId(id) || typeof id !== "string") {
|
|
84
|
+
out.push(cur);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const fresh = freshById.get(id);
|
|
88
|
+
if (fresh === void 0) continue;
|
|
89
|
+
out.push(mergeItem(cur, fresh, overrides?.[id], generatedFields, idKey, false));
|
|
90
|
+
emitted.add(id);
|
|
91
|
+
}
|
|
92
|
+
for (const fresh of freshSource) {
|
|
93
|
+
const id = fresh[idKey];
|
|
94
|
+
if (typeof id !== "string" || emitted.has(id)) continue;
|
|
95
|
+
if (removed?.[id] === true) continue;
|
|
96
|
+
out.push(fresh);
|
|
97
|
+
}
|
|
98
|
+
const freshIndex = /* @__PURE__ */ new Map();
|
|
99
|
+
freshSource.forEach((f, i) => {
|
|
100
|
+
const id = f[idKey];
|
|
101
|
+
if (typeof id === "string") freshIndex.set(id, i);
|
|
102
|
+
});
|
|
103
|
+
return out.map((row, i) => {
|
|
104
|
+
const id = row[idKey];
|
|
105
|
+
return {
|
|
106
|
+
row,
|
|
107
|
+
i,
|
|
108
|
+
idx: typeof id === "string" ? freshIndex.get(id) : void 0
|
|
109
|
+
};
|
|
110
|
+
}).sort((a, b) => {
|
|
111
|
+
if (a.idx === void 0 && b.idx === void 0) return a.i - b.i;
|
|
112
|
+
if (a.idx === void 0) return 1;
|
|
113
|
+
if (b.idx === void 0) return -1;
|
|
114
|
+
return a.idx - b.idx;
|
|
115
|
+
}).map((x) => x.row);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
export { mergeSourcedItems };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { elementIdentity } from "../../template-contracts/dist/ref-locate.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../internal/fill-bake/dist/item-overrides.js
|
|
4
|
+
function asEntry(value) {
|
|
5
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
6
|
+
}
|
|
7
|
+
function keepOverriddenItemFields(fresh, stored, marked) {
|
|
8
|
+
if (!Array.isArray(fresh) || !Array.isArray(stored) || Object.keys(marked).length === 0) return fresh;
|
|
9
|
+
const storedById = /* @__PURE__ */ new Map();
|
|
10
|
+
for (const value of stored) {
|
|
11
|
+
const entry = asEntry(value);
|
|
12
|
+
const id = elementIdentity(entry);
|
|
13
|
+
if (entry !== null && id !== null) storedById.set(id, entry);
|
|
14
|
+
}
|
|
15
|
+
return fresh.map((value) => {
|
|
16
|
+
const entry = asEntry(value);
|
|
17
|
+
const id = elementIdentity(entry);
|
|
18
|
+
const fields = id === null ? void 0 : marked[id];
|
|
19
|
+
const twin = id === null ? void 0 : storedById.get(id);
|
|
20
|
+
if (entry === null || fields === void 0 || twin === void 0) return value;
|
|
21
|
+
const kept = { ...entry };
|
|
22
|
+
for (const field of Object.keys(fields)) if (field in twin) kept[field] = twin[field];
|
|
23
|
+
return kept;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { keepOverriddenItemFields };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { elementIdentity } from "../../template-contracts/dist/ref-locate.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../internal/fill-bake/dist/linked-merge.js
|
|
4
|
+
const isFields = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5
|
+
function uploadOf(value) {
|
|
6
|
+
if (!isFields(value)) return null;
|
|
7
|
+
if (typeof value["asset_id"] === "string" && value["asset_id"] !== "") return value["asset_id"];
|
|
8
|
+
if (typeof value["photo_id"] === "string" && value["photo_id"] !== "") return value["photo_id"];
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
function mergeLinkedValue(current, fresh) {
|
|
12
|
+
const upload = uploadOf(fresh);
|
|
13
|
+
if (upload !== null) return uploadOf(current) === upload ? current : fresh;
|
|
14
|
+
if (Array.isArray(fresh)) return Array.isArray(current) ? mergeLinkedList(current, fresh) : fresh;
|
|
15
|
+
if (isFields(fresh)) return isFields(current) ? mergeLinkedFields(current, fresh) : fresh;
|
|
16
|
+
return fresh;
|
|
17
|
+
}
|
|
18
|
+
function mergeLinkedFields(current, fresh) {
|
|
19
|
+
const merged = {};
|
|
20
|
+
for (const [field, value] of Object.entries(fresh)) merged[field] = mergeLinkedValue(current[field], value);
|
|
21
|
+
return merged;
|
|
22
|
+
}
|
|
23
|
+
function mergeLinkedList(current, fresh) {
|
|
24
|
+
const twins = /* @__PURE__ */ new Map();
|
|
25
|
+
for (const entry of current) {
|
|
26
|
+
const identity = elementIdentity(entry);
|
|
27
|
+
if (identity === null) continue;
|
|
28
|
+
const queue = twins.get(identity);
|
|
29
|
+
if (queue === void 0) twins.set(identity, [entry]);
|
|
30
|
+
else queue.push(entry);
|
|
31
|
+
}
|
|
32
|
+
return fresh.map((entry) => {
|
|
33
|
+
const identity = elementIdentity(entry);
|
|
34
|
+
const queue = identity === null ? void 0 : twins.get(identity);
|
|
35
|
+
return queue === void 0 || queue.length === 0 ? entry : mergeLinkedValue(queue.shift(), entry);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { mergeLinkedValue };
|