@homepages/concrete 9.0.0 → 10.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 +69 -0
- package/README.md +3 -3
- package/codemods/manifest.json +14 -0
- package/codemods/registry-keys-only.mjs +113 -0
- package/codemods/steps/list-object-form.mjs +2 -3
- package/codemods/steps/registry-key-reads.mjs +276 -0
- package/dist/artifact/playground/client/assets/index-BFNHB7VM.css +1 -0
- package/dist/artifact/playground/client/assets/index-Div1yo6s.js +1259 -0
- package/dist/artifact/playground/client/index.html +2 -2
- package/dist/artifact/playground/host.mjs +42 -42
- package/dist/cli/build/artifact.js +2 -1
- package/dist/cli/build/fixtures.js +2 -1
- package/dist/cli/check/render/inputs.js +3 -3
- package/dist/cli/check/stages/sections.js +5 -6
- package/dist/cli/check/stages/workspace.js +2 -0
- package/dist/cli/check/template-key.js +16 -0
- package/dist/cli/dev/workspace-reader.js +9 -2
- package/dist/fixtures/media-store.js +3 -3
- package/dist/fixtures/resolve.js +28 -23
- package/dist/fixtures/synthesize-empties.js +3 -1
- package/dist/fixtures.d.ts +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/capture-settle/dist/island-markers.d.ts +1 -1
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +15 -27
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +12 -12
- package/dist/packages/internal/fill-bake/dist/derive-source.js +7 -14
- package/dist/packages/internal/fill-bake/dist/index.js +4 -3
- package/dist/packages/internal/fill-bake/dist/item-merge.js +36 -16
- package/dist/packages/internal/fill-bake/dist/item-overrides.js +1 -28
- package/dist/packages/internal/fill-bake/dist/linked-merge.js +5 -7
- package/dist/packages/internal/fill-bake/dist/list-grammar.js +11 -34
- package/dist/packages/internal/fill-bake/dist/stored-row-reader.js +1 -0
- package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +12 -39
- package/dist/packages/internal/fill-vocabulary/dist/verbs.js +2 -17
- package/dist/packages/internal/media-resolution/dist/document.js +16 -15
- package/dist/packages/internal/media-resolution/dist/image.js +38 -94
- package/dist/packages/internal/media-resolution/dist/index.js +1 -1
- package/dist/packages/internal/media-resolution/dist/list.js +12 -12
- package/dist/packages/internal/media-resolution/dist/media.js +17 -16
- package/dist/packages/internal/media-resolution/dist/records.js +4 -2
- package/dist/packages/internal/media-resolution/dist/slot.js +9 -6
- package/dist/packages/internal/media-resolution/dist/tour.js +12 -11
- package/dist/packages/internal/media-resolution/dist/video.js +16 -16
- package/dist/packages/internal/property-facts/dist/registry-facts.js +10 -2
- package/dist/packages/internal/section-contracts/dist/catalog.js +2 -10
- package/dist/packages/internal/section-contracts/dist/directly-linked-list-contract.js +5 -12
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +1 -5
- package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +7 -5
- package/dist/packages/internal/section-contracts/dist/grammar-scope.js +1 -1
- package/dist/packages/internal/section-contracts/dist/index.js +0 -2
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +0 -29
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +2 -16
- package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +6 -6
- package/dist/packages/internal/section-contracts/dist/object-contract.js +4 -2
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +6 -2
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +1 -15
- package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +6 -7
- package/dist/packages/internal/section-contracts/dist/row-source-contract.js +7 -8
- package/dist/packages/internal/section-contracts/dist/runners.js +5 -17
- package/dist/packages/internal/section-contracts/dist/select-contract.js +7 -1
- package/dist/packages/internal/section-contracts/dist/source-contract.js +20 -79
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +1 -1
- package/dist/packages/internal/section-contracts/dist/table-member.js +5 -8
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +5 -10
- package/dist/packages/internal/source-resolution/dist/index.js +21 -189
- package/dist/packages/internal/template-artifact/dist/index.js +2 -2
- package/dist/packages/internal/template-artifact/dist/layout.js +3 -1
- package/dist/packages/internal/template-artifact/dist/verify.js +32 -16
- package/dist/packages/internal/template-contracts/dist/content-pick.js +24 -1
- package/dist/packages/internal/template-contracts/dist/decision-fills.js +2 -6
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +2 -2
- package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +3 -2
- package/dist/packages/internal/template-contracts/dist/fact-keys.js +19 -43
- package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +24 -3
- package/dist/packages/internal/template-contracts/dist/fact-registry.js +14 -7
- package/dist/packages/internal/template-contracts/dist/fill-builders.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/fill-spec-schema.js +3 -68
- package/dist/packages/internal/template-contracts/dist/fill-spec.js +7 -6
- package/dist/packages/internal/template-contracts/dist/list-editing.js +0 -1
- package/dist/packages/internal/template-contracts/dist/list.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/list.js +7 -15
- package/dist/packages/internal/template-contracts/dist/media-candidates.js +1 -1
- package/dist/packages/internal/template-contracts/dist/mirror-kind.js +2 -2
- package/dist/packages/internal/template-contracts/dist/object.js +3 -2
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +2 -2
- package/dist/packages/internal/template-contracts/dist/process-builders.d.ts +2 -2
- package/dist/packages/internal/template-contracts/dist/read-graph.js +14 -51
- package/dist/packages/internal/template-contracts/dist/ref-locate.js +15 -27
- package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +3 -1
- package/dist/packages/internal/template-contracts/dist/registry-facts.js +13 -24
- package/dist/packages/internal/template-contracts/dist/registry-shape.d.ts +20 -4
- package/dist/packages/internal/template-contracts/dist/registry-shape.js +69 -11
- package/dist/packages/internal/template-contracts/dist/row-planners.js +1 -1
- package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +5 -14
- package/dist/packages/internal/template-contracts/dist/row-ref.js +7 -23
- package/dist/packages/internal/template-contracts/dist/row-sources.js +6 -16
- package/dist/packages/internal/template-contracts/dist/row.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/row.js +6 -7
- package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +5 -20
- package/dist/packages/internal/template-contracts/dist/section-schema-types.d.ts +1 -0
- package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +29 -37
- package/dist/packages/internal/template-contracts/dist/slot-builders.js +4 -7
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +2 -733
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +2 -502
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +4 -1
- package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +4 -4
- package/dist/packages/internal/template-contracts/dist/slot-types.js +1 -2
- package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +9 -10
- package/dist/packages/internal/template-contracts/dist/table-members.d.ts +5 -12
- package/dist/packages/internal/template-contracts/dist/table-members.js +7 -37
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +2 -2
- package/dist/primitives/Image.d.ts +3 -3
- package/dist/primitives/slot-bindings.js +2 -2
- package/dist/primitives/slot-download.d.ts +1 -1
- package/dist/primitives/slot-media.d.ts +1 -1
- package/dist/rules/registry.js +6 -0
- package/dist/schema/fact.d.ts +19 -52
- package/dist/schema/fact.js +6 -25
- package/dist/schema/facts-view.d.ts +1 -2
- package/dist/schema/property-facts.d.ts +1 -62
- package/dist/schema/section-schema.d.ts +2 -2
- package/dist/schema/section-schema.js +1 -1
- package/dist/section/section.d.ts +2 -2
- 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 +1 -1
- package/guide/reference/cli/publish.md +1 -1
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +4 -5
- package/package.json +1 -1
- package/dist/artifact/playground/client/assets/index-BUmdDDX5.js +0 -1259
- package/dist/artifact/playground/client/assets/index-DDOcM0zA.css +0 -1
- package/dist/packages/internal/fill-vocabulary/dist/row-reads.js +0 -15
- package/dist/packages/internal/section-contracts/dist/group-contract.js +0 -19
- package/dist/packages/internal/section-contracts/dist/option-source-contract.js +0 -22
- package/dist/packages/internal/template-contracts/dist/comparable-address.js +0 -19
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +0 -62
- package/dist/packages/internal/template-contracts/dist/legacy-facts.js +0 -167
- package/dist/packages/internal/template-contracts/dist/registry-aliases.js +0 -77
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { stampTableBounds } from "../../packages/internal/template-contracts/dist/
|
|
1
|
+
import { stampTableBounds } from "../../packages/internal/template-contracts/dist/registry-shape.js";
|
|
2
2
|
import { orgsForScope } from "../../template/define-template.js";
|
|
3
|
+
import "../../packages/internal/template-contracts/dist/table-members.js";
|
|
3
4
|
import { qualify } from "../../rules/registry.js";
|
|
4
5
|
import { isInsideRoot } from "../../platform/paths.js";
|
|
5
6
|
import { CONCRETE_CLI_VERSION } from "../version.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ASSET_URL_PREFIX, FIXTURE_FILES, fixturePath, isFixtureId } from "../../packages/internal/template-artifact/dist/layout.js";
|
|
1
|
+
import { ASSET_URL_PREFIX, FIXTURE_FILES, FIXTURE_OPTIONAL_FILES, fixturePath, isFixtureId } from "../../packages/internal/template-artifact/dist/layout.js";
|
|
2
2
|
import "../../packages/internal/template-artifact/dist/index.js";
|
|
3
3
|
import { assetContentType } from "../../packages/internal/template-artifact/dist/asset-mime.js";
|
|
4
4
|
import { mediaUrl } from "../../fixtures/property.js";
|
|
@@ -70,6 +70,7 @@ async function fixtureFiles(input) {
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
files.set(fixturePath(fixture.id, FIXTURE_FILES.contentDoc), json(fixture.contentDoc));
|
|
73
|
+
if (fixture.settled !== void 0) files.set(fixturePath(fixture.id, FIXTURE_OPTIONAL_FILES.settledDoc), json({ instances: fixture.settled }));
|
|
73
74
|
files.set(fixturePath(fixture.id, FIXTURE_FILES.property), json({
|
|
74
75
|
facts: rewriteUrls(fixture.facts, urls),
|
|
75
76
|
media
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fixtureMediaRecords, fixtureMediaStore, resolveFixtureSlots } from "../../../fixtures/media-store.js";
|
|
2
2
|
import { resolveNav } from "./nav.js";
|
|
3
3
|
|
|
4
4
|
//#region src/cli/check/render/inputs.ts
|
|
@@ -8,7 +8,7 @@ async function* renderInputs(composition, sections, corpus, assets) {
|
|
|
8
8
|
for (const entry of corpus) {
|
|
9
9
|
const { fixture } = entry;
|
|
10
10
|
const store = fixtureMediaStore(fixture.media);
|
|
11
|
-
const records =
|
|
11
|
+
const records = fixtureMediaRecords(fixture.facts, fixture.media, (path) => assets?.get(path)?.bytes);
|
|
12
12
|
const enabled = (instanceId) => fixture.contentDoc.instances.find((i) => i.instance_id === instanceId)?.enabled === true;
|
|
13
13
|
const navPages = manifest.pages.map((page) => ({
|
|
14
14
|
id: page.id,
|
|
@@ -39,7 +39,7 @@ async function* renderInputs(composition, sections, corpus, assets) {
|
|
|
39
39
|
slots: await resolveFixtureSlots({
|
|
40
40
|
slots: instance.slots,
|
|
41
41
|
declared: section.section.schema.slots,
|
|
42
|
-
|
|
42
|
+
records,
|
|
43
43
|
store
|
|
44
44
|
}),
|
|
45
45
|
nav: {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { tableColumnOfKey } from "../../../packages/internal/template-contracts/dist/registry-shape.js";
|
|
1
|
+
import { tableColumnOfKey, tableKey, tableOf } from "../../../packages/internal/template-contracts/dist/registry-shape.js";
|
|
3
2
|
import { declaringModule } from "../../../section/section.js";
|
|
4
3
|
import "../../../packages/internal/template-contracts/dist/table-members.js";
|
|
5
4
|
import { isInsideRoot, workspacePath } from "../../../platform/paths.js";
|
|
@@ -29,7 +28,7 @@ function stampItemOrder(object) {
|
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
function heldTables(slot) {
|
|
32
|
-
const rowTables = (row) => row?.type === "row" ? [row.from].flat().flatMap((key) =>
|
|
31
|
+
const rowTables = (row) => row?.type === "row" ? [row.from].flat().flatMap((key) => tableOf(key) ?? []) : [];
|
|
33
32
|
if (slot.type === "row") return new Set(rowTables(slot));
|
|
34
33
|
if (slot.type !== "list") return /* @__PURE__ */ new Set();
|
|
35
34
|
return /* @__PURE__ */ new Set([...rowTables(slot.element), ...Object.values(slot.element?.fields ?? {}).flatMap(rowTables)]);
|
|
@@ -41,11 +40,11 @@ function wholeTableReads(schema) {
|
|
|
41
40
|
if (slot.source?.kind === "derived") {
|
|
42
41
|
const held = heldTables(slot);
|
|
43
42
|
for (const read of slot.source.reads ?? []) {
|
|
44
|
-
const table = read.kind === "home" ?
|
|
45
|
-
if (table !== null && !held.has(table
|
|
43
|
+
const table = read.kind === "home" ? tableOf(read.key) : null;
|
|
44
|
+
if (table !== null && !held.has(table)) found.push([
|
|
46
45
|
path,
|
|
47
46
|
String(read.key),
|
|
48
|
-
|
|
47
|
+
tableKey(table)
|
|
49
48
|
]);
|
|
50
49
|
}
|
|
51
50
|
}
|
|
@@ -4,6 +4,7 @@ import { loadFixtures } from "../../../fixtures/load.js";
|
|
|
4
4
|
import { listSourcePaths } from "../../build/source.js";
|
|
5
5
|
import { crlfTextViolations } from "../line-endings.js";
|
|
6
6
|
import { unportableNameViolations } from "../portable-names.js";
|
|
7
|
+
import { templateKeyViolations } from "../template-key.js";
|
|
7
8
|
|
|
8
9
|
//#region src/cli/check/stages/workspace.ts
|
|
9
10
|
async function workspaceStage(ctx) {
|
|
@@ -11,6 +12,7 @@ async function workspaceStage(ctx) {
|
|
|
11
12
|
ctx.workspace = workspace;
|
|
12
13
|
const violations = [...workspace.violations, ...await crlfTextViolations(ctx.root)];
|
|
13
14
|
if (workspace.template !== null) {
|
|
15
|
+
violations.push(...templateKeyViolations(workspace.template, TEMPLATE_FILE));
|
|
14
16
|
try {
|
|
15
17
|
ctx.discovered = await discoverSections({
|
|
16
18
|
root: ctx.root,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/cli/check/template-key.ts
|
|
2
|
+
function templateKeyForName(name) {
|
|
3
|
+
return name.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean).join("-");
|
|
4
|
+
}
|
|
5
|
+
function templateKeyViolations(template, module) {
|
|
6
|
+
const expected = templateKeyForName(template.name);
|
|
7
|
+
if (template.key === expected) return [];
|
|
8
|
+
return [{
|
|
9
|
+
rule: "workspace/key-not-name",
|
|
10
|
+
file: module,
|
|
11
|
+
message: `The template key "${template.key}" does not spell its name "${template.name}"; the key is the name in lowercase kebab-case, "${expected}". Renaming a published template's key makes it a different template in the catalog: rename the stored key with it, or pick a name that spells the key.`
|
|
12
|
+
}];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { templateKeyForName, templateKeyViolations };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { stampTableBounds } from "../../packages/internal/template-contracts/dist/
|
|
1
|
+
import { stampTableBounds } from "../../packages/internal/template-contracts/dist/registry-shape.js";
|
|
2
2
|
import { isTemplate } from "../../template/define-template.js";
|
|
3
|
+
import "../../packages/internal/template-contracts/dist/table-members.js";
|
|
3
4
|
import { compileTemplateCss } from "../../css/compile.js";
|
|
4
5
|
import { materializeTemplate } from "../../template/materialize.js";
|
|
5
6
|
import { loadFixtures } from "../../fixtures/load.js";
|
|
6
|
-
import { resolveFixture } from "../../fixtures/resolve.js";
|
|
7
|
+
import { computeReadsSectionOf, resolveFixture } from "../../fixtures/resolve.js";
|
|
7
8
|
import { materializeSection } from "../../section/materialize.js";
|
|
8
9
|
import { loadTemplateModule } from "./load-template.js";
|
|
9
10
|
import { createElement } from "react";
|
|
@@ -51,6 +52,7 @@ function hostFixture(fixture, sizeOf) {
|
|
|
51
52
|
facts: fixture.facts,
|
|
52
53
|
media,
|
|
53
54
|
instances: fixture.contentDoc.instances,
|
|
55
|
+
...fixture.settled === void 0 ? {} : { settled: fixture.settled },
|
|
54
56
|
provenance: fixture.provenance
|
|
55
57
|
};
|
|
56
58
|
}
|
|
@@ -188,6 +190,11 @@ var DevWorkspace = class {
|
|
|
188
190
|
}
|
|
189
191
|
});
|
|
190
192
|
}
|
|
193
|
+
async computes(key) {
|
|
194
|
+
const section = (await this.loadComposition()).materialized.sections.get(key);
|
|
195
|
+
if (section === void 0) throw new Error(`The composition places no section "${key}".`);
|
|
196
|
+
return computeReadsSectionOf(section);
|
|
197
|
+
}
|
|
191
198
|
renderer() {
|
|
192
199
|
return {
|
|
193
200
|
section: async (key) => {
|
|
@@ -82,7 +82,7 @@ function serveSrcset(srcset, serve) {
|
|
|
82
82
|
return [serve(url), ...descriptors].join(" ");
|
|
83
83
|
}).join(", ");
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function fixtureMediaRecords(facts, media, sizeOf) {
|
|
86
86
|
const records = recordsOf(facts === null ? null : mediaRecords(facts));
|
|
87
87
|
const sized = /* @__PURE__ */ new Map();
|
|
88
88
|
for (const entry of media.values()) {
|
|
@@ -100,7 +100,7 @@ function fixtureAssetRecords(facts, media, sizeOf) {
|
|
|
100
100
|
async function resolveFixtureSlots(input) {
|
|
101
101
|
const ctx = {
|
|
102
102
|
store: input.store,
|
|
103
|
-
|
|
103
|
+
records: input.records,
|
|
104
104
|
resolvePoi: (value) => value
|
|
105
105
|
};
|
|
106
106
|
const out = {};
|
|
@@ -112,4 +112,4 @@ async function resolveFixtureSlots(input) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
//#endregion
|
|
115
|
-
export { cropRectOf,
|
|
115
|
+
export { cropRectOf, fixtureMediaRecords, fixtureMediaStore, resolveFixtureSlots };
|
package/dist/fixtures/resolve.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { normalizeAddressValue } from "../packages/internal/template-contracts/dist/address-value.js";
|
|
2
|
-
import {
|
|
2
|
+
import { declaredKinds, isEmailValue, isIsoDateValue, isMediaType, isPhoneValue } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
3
3
|
import { getComputed } from "../packages/internal/template-contracts/dist/compute.js";
|
|
4
|
-
import {
|
|
4
|
+
import { tableKey } from "../packages/internal/template-contracts/dist/registry-shape.js";
|
|
5
|
+
import { heldRowTableOf, listTableOf, placementOf, rowTablesOf } from "../packages/internal/template-contracts/dist/ref-locate.js";
|
|
6
|
+
import "../packages/internal/template-contracts/dist/table-members.js";
|
|
5
7
|
import { fillSpecFromSchema } from "../schema/extract-fill-spec.js";
|
|
6
8
|
import { elementRowKeys, listSourceOf, memberSourceOf } from "../packages/internal/template-contracts/dist/row-sources.js";
|
|
7
9
|
import { objectFieldSlotId } from "../packages/internal/template-contracts/dist/slot-overrides.js";
|
|
@@ -95,10 +97,10 @@ function resolveFixture(loaded, options) {
|
|
|
95
97
|
const slots = {};
|
|
96
98
|
const provenanceOf = {};
|
|
97
99
|
for (const [id, def] of Object.entries(schemaSlots)) {
|
|
100
|
+
provenanceOf[id] = provenanceFor(def, id, values[id], instance.slots[id], facts);
|
|
98
101
|
const cases = def.variant?.cases;
|
|
99
102
|
if (cases !== void 0 && (instance.variant === void 0 || !cases.includes(instance.variant))) continue;
|
|
100
103
|
slots[id] = instance.slots[id];
|
|
101
|
-
provenanceOf[id] = provenanceFor(def, id, values[id], slots[id], facts);
|
|
102
104
|
}
|
|
103
105
|
instances.push({
|
|
104
106
|
instance_id: instance.instance_id,
|
|
@@ -118,11 +120,27 @@ function resolveFixture(loaded, options) {
|
|
|
118
120
|
facts,
|
|
119
121
|
media,
|
|
120
122
|
contentDoc: { instances },
|
|
123
|
+
settled: settled.instances,
|
|
121
124
|
provenance
|
|
122
125
|
},
|
|
123
126
|
violations
|
|
124
127
|
};
|
|
125
128
|
}
|
|
129
|
+
function computeReadsSectionOf(section, log) {
|
|
130
|
+
const { schema } = section;
|
|
131
|
+
return {
|
|
132
|
+
localKey: section.key,
|
|
133
|
+
schema: {
|
|
134
|
+
slots: schema.slots,
|
|
135
|
+
display: schema.meta.display ?? {}
|
|
136
|
+
},
|
|
137
|
+
bakeContext: {
|
|
138
|
+
computed: getComputed(schema),
|
|
139
|
+
section_key: section.key,
|
|
140
|
+
log
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
126
144
|
function pickDecisions(schema) {
|
|
127
145
|
try {
|
|
128
146
|
return fillSpecFromSchema(schema).decisions;
|
|
@@ -186,14 +204,7 @@ function fillInstance(placement, entry, ctx) {
|
|
|
186
204
|
slots,
|
|
187
205
|
...Object.keys(overrides).length === 0 ? {} : { display_overrides: overrides }
|
|
188
206
|
},
|
|
189
|
-
section:
|
|
190
|
-
localKey: section.key,
|
|
191
|
-
schema: {
|
|
192
|
-
slots: schema.slots,
|
|
193
|
-
display
|
|
194
|
-
},
|
|
195
|
-
bakeContext
|
|
196
|
-
},
|
|
207
|
+
section: computeReadsSectionOf(section, ctx.log),
|
|
197
208
|
values
|
|
198
209
|
};
|
|
199
210
|
}
|
|
@@ -212,15 +223,13 @@ function statedValue(fill, def, path, value, holds) {
|
|
|
212
223
|
if (!Array.isArray(value)) return void 0;
|
|
213
224
|
const fields = def.element.fields;
|
|
214
225
|
const table = filledListTable(def);
|
|
215
|
-
const identityKey = elementIdentityKey(table?.table ?? null);
|
|
216
226
|
const elementRows = elementRowKeys(fields);
|
|
217
227
|
return value.map((item, i) => {
|
|
218
228
|
const record = isRecord(item) ? item : {};
|
|
219
229
|
const out = statedFields(fill, fields, path, record, false);
|
|
220
230
|
const held = elementRows.map((key) => record[key]).find((id) => typeof id === "string" && id !== "");
|
|
221
|
-
const id = table === null ? record["id"] ?? `${path}-${String(i + 1)}` : held ?? record[identityKey] ?? record["id"];
|
|
222
231
|
return {
|
|
223
|
-
[
|
|
232
|
+
id: table === null ? record["id"] ?? `${path}-${String(i + 1)}` : held ?? record["id"],
|
|
224
233
|
...out
|
|
225
234
|
};
|
|
226
235
|
});
|
|
@@ -277,20 +286,16 @@ function fieldValue(def, path, baked, stated, decisions) {
|
|
|
277
286
|
}
|
|
278
287
|
function itemsValue(def, path, items, stated, decisions) {
|
|
279
288
|
const fields = def.element?.fields ?? {};
|
|
280
|
-
const identityKey = elementIdentityKey(listTableOf({ slots: {} }, def)?.table ?? null);
|
|
281
289
|
const statedItems = Array.isArray(stated) ? stated.filter(isRecord) : [];
|
|
282
290
|
const byIdentity = listSourceOf(def).kind === "none" && memberSourceOf(def.source) === null;
|
|
283
291
|
return items.map((item, i) => {
|
|
284
292
|
const baked = isRecord(item) ? item : {};
|
|
285
|
-
const statedItem = byIdentity ? statedItems.find((candidate) => candidate[
|
|
286
|
-
const out = {
|
|
293
|
+
const statedItem = byIdentity ? statedItems.find((candidate) => candidate["id"] === baked["id"]) : statedItems[i];
|
|
294
|
+
const out = { id: baked["id"] };
|
|
287
295
|
for (const [key, field] of Object.entries(fields)) out[key] = fieldValue(field, `${path}.${key}`, Object.hasOwn(baked, key) ? { value: baked[key] } : void 0, statedItem?.[key], decisions);
|
|
288
296
|
return out;
|
|
289
297
|
});
|
|
290
298
|
}
|
|
291
|
-
function storedTableKey(key) {
|
|
292
|
-
return key.reading === "legacy" ? key.table : REGISTRY_TABLE_KEYS[key.table];
|
|
293
|
-
}
|
|
294
299
|
function provenanceFor(def, id, stated, value, facts) {
|
|
295
300
|
const source = def.source;
|
|
296
301
|
if (def.type === "object") return { kind: "authored" };
|
|
@@ -299,7 +304,7 @@ function provenanceFor(def, id, stated, value, facts) {
|
|
|
299
304
|
const table = heldRowTableOf(facts, rowTablesOf(def), typeof value === "string" ? value : null);
|
|
300
305
|
return table !== null ? {
|
|
301
306
|
kind: "fact",
|
|
302
|
-
ref:
|
|
307
|
+
ref: tableKey(table)
|
|
303
308
|
} : { kind: "empty" };
|
|
304
309
|
}
|
|
305
310
|
if (source?.kind === "home") return {
|
|
@@ -376,8 +381,8 @@ function mediaRef(def, value, ctx) {
|
|
|
376
381
|
});
|
|
377
382
|
return null;
|
|
378
383
|
}
|
|
379
|
-
return {
|
|
384
|
+
return { media: carried.id };
|
|
380
385
|
}
|
|
381
386
|
|
|
382
387
|
//#endregion
|
|
383
|
-
export { emptyValueFor, isEmptyValue, resolveFixture, uniquePlacements };
|
|
388
|
+
export { computeReadsSectionOf, emptyValueFor, isEmptyValue, resolveFixture, uniquePlacements };
|
|
@@ -3,6 +3,8 @@ import { emptyValueFor, isEmptyValue, uniquePlacements } from "./resolve.js";
|
|
|
3
3
|
//#region src/fixtures/synthesize-empties.ts
|
|
4
4
|
function synthesizeEmptyFixtures(resolved, placements) {
|
|
5
5
|
const out = [];
|
|
6
|
+
const base = { ...resolved };
|
|
7
|
+
delete base.settled;
|
|
6
8
|
for (const placement of uniquePlacements(placements)) {
|
|
7
9
|
const instance = resolved.contentDoc.instances.find((i) => i.instance_id === placement.instance);
|
|
8
10
|
if (instance === void 0) continue;
|
|
@@ -10,7 +12,7 @@ function synthesizeEmptyFixtures(resolved, placements) {
|
|
|
10
12
|
if (!(slot in instance.slots) || isEmptyValue(instance.slots[slot], def.type)) continue;
|
|
11
13
|
const empty = emptyValueFor(def.type);
|
|
12
14
|
out.push({
|
|
13
|
-
...
|
|
15
|
+
...base,
|
|
14
16
|
id: `${resolved.id}/empty/${placement.instance}/${slot}`,
|
|
15
17
|
label: `${resolved.label}: ${placement.instance}.${slot} = ${Array.isArray(empty) ? "empty" : "null"}`,
|
|
16
18
|
synthesized: true,
|
package/dist/fixtures.d.ts
CHANGED
|
@@ -318,7 +318,7 @@ type ContentItem<F> = {
|
|
|
318
318
|
* `{ contact: listingAgent, field: "logo_dark" }`. A contact's headshot and logos are image
|
|
319
319
|
* media like any other, but the platform holds them on the card rather than in a pool, so
|
|
320
320
|
* they have no entry of their own to state — this names the same image the resolver
|
|
321
|
-
* registers, and it resolves to the `{
|
|
321
|
+
* registers, and it resolves to the `{ media }` reference the platform bakes for that field. A contact the property does not carry, or a field it holds `null`, is a check
|
|
322
322
|
* error like any other media the property lacks.
|
|
323
323
|
*/
|
|
324
324
|
interface ContactImageEntry {
|
package/dist/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ import { ObjectLabelField, ObjectLabelSource, ObjectSlotDef, object } from "./pa
|
|
|
21
21
|
import { RowFill, RowSlotDef, RowSourceInput, TableSource, row } from "./packages/internal/template-contracts/dist/row.js";
|
|
22
22
|
import { ListFill, ListSlotDef, ListSourceInput, list } from "./packages/internal/template-contracts/dist/list.js";
|
|
23
23
|
import { DocumentMedia, ImageMedia, Media, TourMedia, VideoMedia } from "./packages/internal/template-contracts/dist/registry-facts.js";
|
|
24
|
-
import {
|
|
24
|
+
import { Coordinates } from "./schema/property-facts.js";
|
|
25
25
|
import "./schema/section-schema.js";
|
|
26
26
|
import { UseEditorResult, useEditor } from "./packages/internal/island-runtime/dist/use-editor.js";
|
|
27
27
|
import { useCaptureReady } from "./packages/internal/island-runtime/dist/use-capture-ready.js";
|
|
@@ -43,9 +43,8 @@ import { Video } from "./primitives/Video.js";
|
|
|
43
43
|
import { Slot } from "./primitives/slot.js";
|
|
44
44
|
import "./primitives/index.js";
|
|
45
45
|
import { ATTR_SECTION_INSTANCE_ID, ATTR_SLOT_FIELD, ATTR_SLOT_GROUP, ATTR_SLOT_ID, ATTR_SLOT_ITEM, ATTR_SLOT_TEXT_LEAF, ATTR_SLOT_UNSELECTABLE, ATTR_TR_ENHANCE } from "./packages/internal/template-contracts/dist/markers.js";
|
|
46
|
-
import {
|
|
46
|
+
import { DerivedFactRef, FactNamespace, RegistryFactRef, fact } from "./schema/fact.js";
|
|
47
47
|
import { FactsCommercialSpace, FactsComparable, FactsContact, FactsUnit } from "./schema/facts-view.js";
|
|
48
|
-
import { DerivedFactRef, DirectFactRef, FactNamespace, RegistryFactRef, fact } from "./schema/fact.js";
|
|
49
48
|
import { presets } from "./schema/format-presets.js";
|
|
50
49
|
import { a4Landscape, a4Portrait, deck16x9, facebookPost, halfLetterFlyer, instagramPortrait, instagramSquare, instagramStory, letterLandscape, letterPortrait, linkedinPost, postcard6x4, postcard7x5, website, xPost } from "./schema/formats.js";
|
|
51
50
|
//#region src/index.d.ts
|
|
@@ -59,4 +58,4 @@ import { a4Landscape, a4Portrait, deck16x9, facebookPost, halfLetterFlyer, insta
|
|
|
59
58
|
*/
|
|
60
59
|
declare const CONCRETE_VERSION: string;
|
|
61
60
|
//#endregion
|
|
62
|
-
export { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, ATTR_SECTION_INSTANCE_ID, ATTR_SLOT_FIELD, ATTR_SLOT_GROUP, ATTR_SLOT_ID, ATTR_SLOT_ITEM, ATTR_SLOT_TEXT_LEAF, ATTR_SLOT_UNSELECTABLE, ATTR_TR_ENHANCE, type AddressMembers, type AddressSlot, type AddressSlotDef, type AddressValue, type AuthorImage, type AutocropInput, type AutocropProcess, type BoundSlotValue, CONCRETE_VERSION, type CanvasInput, type CanvasesInput, type
|
|
61
|
+
export { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, ATTR_SECTION_INSTANCE_ID, ATTR_SLOT_FIELD, ATTR_SLOT_GROUP, ATTR_SLOT_ID, ATTR_SLOT_ITEM, ATTR_SLOT_TEXT_LEAF, ATTR_SLOT_UNSELECTABLE, ATTR_TR_ENHANCE, type AddressMembers, type AddressSlot, type AddressSlotDef, type AddressValue, type AuthorImage, type AutocropInput, type AutocropProcess, type BoundSlotValue, CONCRETE_VERSION, type CanvasInput, type CanvasesInput, type ComputeBinding, type Coordinates, type CropConfig, type CutoutProcess, type DateSlot, type DateSlotDef, type DefineTemplateInput, type DerivedFactRef, type DisplayEntryInput, type DisplayFill, type DocumentCollectionValue, type DocumentFormat, type DocumentMedia, type DocumentSlot, type DocumentSlotDef, type DocumentValue, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, EditorBridge, EditorBridgeSelection, EditorSelection, type ElementOf, type ElementRef, type EmailSlot, type EmailSlotDef, type FactNamespace, type FactsCommercialSpace, type FactsComparable, type FactsContact, type FactsUnit, type FieldBinding, type FieldBindings, type FillBinding, type FillVerb, type FindFill, type FindInput, type FormatIdentity, FrameShell, type HolderProcess, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, type IconName, Image, type ImageCollectionValue, type ImageFormat, type ImageMedia, type ImageSlot, type ImageSlotDef, type ImageValue, IslandComponent, IslandEditor, IslandEditorOptions, IslandMarker, type IslandMarkerProps, IslandModule, IslandProps, IslandPropsError, IslandServerFrame, type ItemBinding, type ItemIdentity, type ListFill, type ListItemSlot, type ListSlot, type ListSlotDef, type ListSourceInput, type Media, type MediaSlot, type MediaSlotDef, type MediaValue, type NumberSlot, type NumberSlotDef, type ObjectBinding, type ObjectFieldSlot, type ObjectLabelField, type ObjectLabelSource, type ObjectSlot, type ObjectSlotDef, type ObjectValue, type OutputClass, type PageComponent, type PhoneSlot, type PhoneSlotDef, type PhysicalLength, type PickFill, type PickInput, type PicturePlan, type PictureSourceSpec, type PlaybackConfig, type PoiPhoto, type PoiRow, type PoiSlot, type PoiSlotDef, type RegistryFactRef, type RenderedPage, type ResponsiveImage, type ResponsiveSource, type RowFill, type RowId, type RowRef, type RowSlot, type RowSlotDef, type RowSourceInput, Section, type SectionContractProps, type SectionOptions, type SectionPlacementProps, type SectionRenderBindings, type SectionValue, type SelectOptionInput, type SelectOptionObject, type SelectSlot, type SelectSlotDef, Slot, type SlotBinding, type SlotBindingMap, type SlotRef, type SlotSource, type SlotValue, type TableRow, type TableSource, type TemplateCanvas, type TemplatePage, type TemplatePreview, type TemplateScope, type TemplateValue, type TextSlot, type TextSlotDef, Tour, type TourCollectionValue, type TourMedia, type TourSlot, type TourSlotDef, type TourValue, type UrlSlot, type UrlSlotDef, type UseEditorResult, type ValueBinding, type ValueSlot, Video, type VideoCollectionValue, type VideoMedia, type VideoSlot, type VideoSlotDef, type VideoValue, type WebsiteFormat, type WebsitePage, type WriteFill, type WriteInput, a4Landscape, a4Portrait, address, bindItems, compute, date, deck16x9, defineTemplate, deserializeIslandProps, document, email, facebookPost, fact, fill, halfLetterFlyer, image, instagramPortrait, instagramSquare, instagramStory, islandId, letterLandscape, letterPortrait, linkedinPost, list, media, number, object, phone, poi, postcard6x4, postcard7x5, presets, holderProcess as process, row, section, select, serializeIslandProps, text, tour, url, useCaptureReady, useEditor, useIslandId, video, website, xPost };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region ../../internal/capture-settle/dist/island-markers.d.ts
|
|
2
|
-
/** Island key on the marker: `<section-key>:<ComponentName>`, e.g. `
|
|
2
|
+
/** Island key on the marker: `<section-key>:<ComponentName>`, e.g. `legacy-website/floorplan:UnitFilter`. */
|
|
3
3
|
declare const ATTR_ISLAND_KEY = "data-tr-island";
|
|
4
4
|
/**
|
|
5
5
|
* The window property holding the page's OPEN capture holds, as a
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { normalizeAddressValue } from "../../template-contracts/dist/address-value.js";
|
|
2
|
-
import { DISPLAY_ENTRIES
|
|
2
|
+
import { DISPLAY_ENTRIES } from "../../template-contracts/dist/slot-catalog.js";
|
|
3
3
|
import { storedAsRefs } from "../../template-contracts/dist/registry-facts.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { tableOf } from "../../template-contracts/dist/registry-shape.js";
|
|
5
|
+
import { attributedRows, heldRowTableOf, holderOf, isHolderKind, listTableOf, rowTablesOf } from "../../template-contracts/dist/ref-locate.js";
|
|
6
|
+
import "../../template-contracts/dist/table-members.js";
|
|
7
|
+
import { elementRowKeys, listSourceOf, memberSourceOf } from "../../template-contracts/dist/row-sources.js";
|
|
6
8
|
import { objectFieldOf, objectFieldSlotId } from "../../template-contracts/dist/slot-overrides.js";
|
|
7
|
-
import { projectTableRows,
|
|
9
|
+
import { projectTableRows, readFactRef, tableRowIds } from "../../source-resolution/dist/index.js";
|
|
8
10
|
import { callDerived, readsAnySlot } from "./derive-source.js";
|
|
9
11
|
import { declaredDisplay } from "./display.js";
|
|
10
|
-
import { computedRow, contentIdentities, decisionProducing, isGrammarList, nestedItemOf, objectElementFields, projectElements, projectNestedList,
|
|
12
|
+
import { computedRow, contentIdentities, decisionProducing, isGrammarList, nestedItemOf, objectElementFields, projectElements, projectNestedList, readResolvedRowMember, rowIdentity, storedElements } from "./list-grammar.js";
|
|
11
13
|
|
|
12
14
|
//#region ../../internal/fill-bake/dist/bake-property-ref.js
|
|
13
15
|
function boundFactKey(def) {
|
|
@@ -17,9 +19,9 @@ function boundFactKey(def) {
|
|
|
17
19
|
return typeof src["key"] === "string" ? src["key"] : null;
|
|
18
20
|
}
|
|
19
21
|
function resolveDirectField(field, facts, fields, rowComputes) {
|
|
20
|
-
const table =
|
|
22
|
+
const table = tableOf(field);
|
|
21
23
|
if (table !== null) return storedAsRefs(projectTableRows(table, facts, fields, rowComputes));
|
|
22
|
-
return storedAsRefs(
|
|
24
|
+
return storedAsRefs(readFactRef(facts, field) ?? null);
|
|
23
25
|
}
|
|
24
26
|
function derivedSource(def) {
|
|
25
27
|
if (def.source === null || def.source === void 0 || typeof def.source !== "object") return null;
|
|
@@ -79,7 +81,7 @@ function bakeValueSlot(path, def, facts, ctx, bakeRows) {
|
|
|
79
81
|
}
|
|
80
82
|
const dField = boundFactKey(def);
|
|
81
83
|
if (dField !== null) try {
|
|
82
|
-
return { value: resolveDirectField(dField, facts
|
|
84
|
+
return { value: resolveDirectField(dField, facts) };
|
|
83
85
|
} catch {
|
|
84
86
|
return { value: null };
|
|
85
87
|
}
|
|
@@ -87,12 +89,11 @@ function bakeValueSlot(path, def, facts, ctx, bakeRows) {
|
|
|
87
89
|
if (derived !== null) {
|
|
88
90
|
if (readsAnySlot(def.source)) return void 0;
|
|
89
91
|
const resolved = resolveDerivedHandle(derived.transform, def.source, facts, ctx, { slot_id: path }, void 0, rowReaderOf(rowInScope, facts));
|
|
90
|
-
return { value: resolved === null ? null :
|
|
92
|
+
return { value: resolved === null ? null : resolved.value };
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
function rowReaderOf(rowInScope, facts) {
|
|
94
96
|
return (member, slot) => {
|
|
95
|
-
if (slot === void 0) throw new Error(`reads the row member "${member}" outside a record list's row`);
|
|
96
97
|
const row = rowInScope(slot);
|
|
97
98
|
return row === void 0 ? void 0 : readResolvedRowMember(row, member, facts);
|
|
98
99
|
};
|
|
@@ -176,7 +177,7 @@ function bakeObjectFields(name, def, bakeRows, facts, ctx, scope) {
|
|
|
176
177
|
if (nested !== void 0 && member !== null) {
|
|
177
178
|
const row = rowInScopeAt(bakeRows, path)(member.slot);
|
|
178
179
|
if (row === void 0) continue;
|
|
179
|
-
out[key] = projectNestedList(
|
|
180
|
+
out[key] = projectNestedList(readResolvedRowMember(row, member.field, facts), nested, facts);
|
|
180
181
|
continue;
|
|
181
182
|
}
|
|
182
183
|
const baked = bakeValueSlot(path, field, facts, ctx, bakeRows);
|
|
@@ -221,7 +222,7 @@ function bakeGrammarList(path, def, facts, ctx, scope, bakeRows) {
|
|
|
221
222
|
function identifiedElements(value, table) {
|
|
222
223
|
const elements = Array.isArray(value) ? value : [];
|
|
223
224
|
if (table !== null) return elements.flatMap((element) => {
|
|
224
|
-
const id =
|
|
225
|
+
const id = rowIdentity(element, table);
|
|
225
226
|
return id === null ? [] : [{
|
|
226
227
|
element: id,
|
|
227
228
|
id
|
|
@@ -263,7 +264,7 @@ function rowComputesOf(listKey, fields, facts, ctx, around) {
|
|
|
263
264
|
if (derived === null) continue;
|
|
264
265
|
computes[fieldKey] = (readItemRow, element) => {
|
|
265
266
|
const readRow = (member, slot) => {
|
|
266
|
-
if (
|
|
267
|
+
if (elementRows.has(slot)) return readItemRow(member);
|
|
267
268
|
const row = rowInScope(slot);
|
|
268
269
|
return row === void 0 ? void 0 : readResolvedRowMember(row, member, facts);
|
|
269
270
|
};
|
|
@@ -272,19 +273,6 @@ function rowComputesOf(listKey, fields, facts, ctx, around) {
|
|
|
272
273
|
}
|
|
273
274
|
return computes;
|
|
274
275
|
}
|
|
275
|
-
function projectComputedRows(value, fields, rowComputes) {
|
|
276
|
-
if (!Array.isArray(value) || fields === void 0) return value;
|
|
277
|
-
const members = rowMemberSources(fields);
|
|
278
|
-
return value.map((computed) => {
|
|
279
|
-
const computedRow = computed !== null && typeof computed === "object" ? computed : {};
|
|
280
|
-
const readMember = (member) => computedRow[member] ?? null;
|
|
281
|
-
const out = {};
|
|
282
|
-
if (typeof computedRow["id"] === "string") out["id"] = computedRow["id"];
|
|
283
|
-
for (const [key, member] of Object.entries(members)) out[key] = readMember(member);
|
|
284
|
-
for (const [key, compute] of Object.entries(rowComputes)) out[key] = compute(readMember);
|
|
285
|
-
return out;
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
276
|
function resolveDerivedHandle(derivedHandle, source, facts, ctx, target, readSlot, readRow, readElement) {
|
|
289
277
|
const authored = ctx?.computed[derivedHandle];
|
|
290
278
|
try {
|
|
@@ -334,4 +322,4 @@ function inDeclaredCases(def, entry, value, ctx) {
|
|
|
334
322
|
}
|
|
335
323
|
|
|
336
324
|
//#endregion
|
|
337
|
-
export { bakeDisplayEntries, bakePropertyRefSlots, boundFactKey, derivedSource, identifiedElements, inDeclaredCases,
|
|
325
|
+
export { bakeDisplayEntries, bakePropertyRefSlots, boundFactKey, derivedSource, identifiedElements, inDeclaredCases, resolveDerivedHandle, resolveDirectField, rowComputesOf, topLevelRowReader };
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { normalizeAddressValue } from "../../template-contracts/dist/address-value.js";
|
|
2
2
|
import { DISPLAY_ENTRIES } from "../../template-contracts/dist/slot-catalog.js";
|
|
3
|
-
import {
|
|
3
|
+
import { heldRowTableOf, holderOf, mirrorRefOf, rowTablesOf, sectionSlotAt, slotTableOf } from "../../template-contracts/dist/ref-locate.js";
|
|
4
4
|
import { memberSourceOf } from "../../template-contracts/dist/row-sources.js";
|
|
5
|
-
import { isSlotOverridden, itemOverridesForSlot, objectFieldOf, objectFieldSlotId } from "../../template-contracts/dist/slot-overrides.js";
|
|
5
|
+
import { isOrderOverridden, isSlotOverridden, itemOverridesForSlot, objectFieldOf, objectFieldSlotId } from "../../template-contracts/dist/slot-overrides.js";
|
|
6
6
|
import { declaredSlotRefs } from "./derive-source.js";
|
|
7
7
|
import { declaredDisplay } from "./display.js";
|
|
8
8
|
import { computedRow, isGrammarList, objectElementFields, projectElements, readResolvedRowMember } from "./list-grammar.js";
|
|
9
|
-
import { identifiedElements, inDeclaredCases,
|
|
9
|
+
import { identifiedElements, inDeclaredCases, resolveDerivedHandle, rowComputesOf } from "./bake-property-ref.js";
|
|
10
10
|
import { isDisplayOverridden } from "../../template-contracts/dist/display-overrides.js";
|
|
11
11
|
import { mergeLinkedValue } from "./linked-merge.js";
|
|
12
12
|
import { mergeSourcedItems } from "./item-merge.js";
|
|
13
|
-
import { keepOverriddenItemFields } from "./item-overrides.js";
|
|
14
13
|
|
|
15
14
|
//#region ../../internal/fill-bake/dist/compute-reads.js
|
|
16
15
|
const DISPLAY_PREFIX = "display.";
|
|
@@ -96,8 +95,8 @@ function applyComputeReads(input) {
|
|
|
96
95
|
freshSource: items,
|
|
97
96
|
overrides: itemOverridesForSlot(inst.slot_overrides, decl.key),
|
|
98
97
|
generatedFields: [],
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
membership: "source",
|
|
99
|
+
ordered: isOrderOverridden(inst.slot_overrides, decl.key)
|
|
101
100
|
});
|
|
102
101
|
};
|
|
103
102
|
const memberAt = (instanceId, rowPath, field) => {
|
|
@@ -129,12 +128,14 @@ function applyComputeReads(input) {
|
|
|
129
128
|
}, slot)?.path;
|
|
130
129
|
};
|
|
131
130
|
const rowReaderOf = (decl) => (member, slot) => {
|
|
132
|
-
if (slot === void 0) throw new Error(`reads the row member "${member}" outside a list's item`);
|
|
133
131
|
const path = holderPath(decl, slot);
|
|
134
132
|
return path === void 0 ? void 0 : memberAt(decl.instanceId, path, member)?.value;
|
|
135
133
|
};
|
|
136
134
|
const valueOf = (inst, decl) => {
|
|
137
|
-
if (decl.kind === "reader")
|
|
135
|
+
if (decl.kind === "reader") {
|
|
136
|
+
const member = memberAt(decl.instanceId, decl.rowPath, decl.field);
|
|
137
|
+
return member === void 0 ? void 0 : { value: mergeLinkedValue(storedRefValue(inst, decl.key), member.value) };
|
|
138
|
+
}
|
|
138
139
|
if (decl.kind === "mirror") {
|
|
139
140
|
const upstreamInstance = targetOf(decl, decl.ref);
|
|
140
141
|
const upstream = readStored(upstreamInstance, decl.ref.slot);
|
|
@@ -147,7 +148,7 @@ function applyComputeReads(input) {
|
|
|
147
148
|
});
|
|
148
149
|
return { value: row.id };
|
|
149
150
|
}
|
|
150
|
-
if (decl.def.type !== "list") return { value: upstream ?? null };
|
|
151
|
+
if (decl.def.type !== "list") return { value: mergeLinkedValue(storedRefValue(inst, decl.key), upstream ?? null) };
|
|
151
152
|
const items = projectElements(identifiedElements(Array.isArray(upstream) ? upstream : [], table), projectionOf(decl, table));
|
|
152
153
|
return { value: listValue(inst, decl, table, items) };
|
|
153
154
|
}
|
|
@@ -163,9 +164,8 @@ function applyComputeReads(input) {
|
|
|
163
164
|
return { value: listValue(inst, decl, table, items) };
|
|
164
165
|
}
|
|
165
166
|
const isList = decl.def.type === "list";
|
|
166
|
-
const fresh = resolved === null ? isList ? [] : null :
|
|
167
|
-
|
|
168
|
-
return { value: keepOverriddenItemFields(mergeLinkedValue(stored, fresh), stored, itemOverridesForSlot(inst.slot_overrides, decl.key)) };
|
|
167
|
+
const fresh = resolved === null ? isList ? [] : null : resolved.value ?? (isList ? [] : null);
|
|
168
|
+
return { value: mergeLinkedValue(storedRefValue(inst, decl.key), fresh) };
|
|
169
169
|
};
|
|
170
170
|
const write = (decl) => {
|
|
171
171
|
const inst = working.get(decl.instanceId);
|
|
@@ -17,23 +17,16 @@ function sectionRefOf(entry) {
|
|
|
17
17
|
}
|
|
18
18
|
function declaredReads(source) {
|
|
19
19
|
return readsOf(source).map((entry, i) => {
|
|
20
|
-
const
|
|
21
|
-
const { kind, key, field } = record;
|
|
20
|
+
const { kind, key, slot, field } = entry ?? {};
|
|
22
21
|
if (kind === "home" && typeof key === "string") return {
|
|
23
22
|
kind: "home",
|
|
24
23
|
key
|
|
25
24
|
};
|
|
26
|
-
if (kind === "row" && typeof field === "string") {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
field
|
|
32
|
-
} : {
|
|
33
|
-
kind: "row",
|
|
34
|
-
field
|
|
35
|
-
};
|
|
36
|
-
}
|
|
25
|
+
if (kind === "row" && typeof slot === "string" && slot !== "" && typeof field === "string") return {
|
|
26
|
+
kind: "row",
|
|
27
|
+
slot,
|
|
28
|
+
field
|
|
29
|
+
};
|
|
37
30
|
if (kind === "element") return { kind: "element" };
|
|
38
31
|
const sectionRef = sectionRefOf(entry);
|
|
39
32
|
if (sectionRef !== null) return sectionRef;
|
|
@@ -51,7 +44,7 @@ function callDerived(fn, source, facts, readSlot, readRow, readElement) {
|
|
|
51
44
|
if (ref.kind === "home") return readFactRef(facts, ref.key);
|
|
52
45
|
if (ref.kind === "row") {
|
|
53
46
|
if (readRow === void 0) throw new Error(`reads the row member "${ref.field}" with no row in scope`);
|
|
54
|
-
return
|
|
47
|
+
return readRow(ref.field, ref.slot);
|
|
55
48
|
}
|
|
56
49
|
if (ref.kind === "element") {
|
|
57
50
|
if (readElement === void 0) throw new Error("reads the element outside a list's item");
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { projectTableRows, readFactRef, readRowMember } from "../../source-resolution/dist/index.js";
|
|
2
2
|
import { callDerived, declaredReads, declaredSlotRefs, readsAnySlot } from "./derive-source.js";
|
|
3
3
|
import { declaredDisplay } from "./display.js";
|
|
4
|
-
import { decisionProducing, isGrammarList, objectElementFields, readResolvedRowMember,
|
|
5
|
-
import { bakeDisplayEntries, bakePropertyRefSlots, boundFactKey, derivedSource, identifiedElements,
|
|
4
|
+
import { decisionProducing, isGrammarList, objectElementFields, readResolvedRowMember, rowIdentity } from "./list-grammar.js";
|
|
5
|
+
import { bakeDisplayEntries, bakePropertyRefSlots, boundFactKey, derivedSource, identifiedElements, resolveDerivedHandle, resolveDirectField, rowComputesOf, topLevelRowReader } from "./bake-property-ref.js";
|
|
6
6
|
import { mergeLinkedValue } from "./linked-merge.js";
|
|
7
7
|
import { mergeSourcedItems } from "./item-merge.js";
|
|
8
|
-
import { keepOverriddenItemFields } from "./item-overrides.js";
|
|
9
8
|
import { applyComputeReads, storedRefValue } from "./compute-reads.js";
|
|
9
|
+
import "./item-overrides.js";
|
|
10
|
+
import "./stored-row-reader.js";
|
|
10
11
|
|
|
11
12
|
export { applyComputeReads, bakeDisplayEntries, bakePropertyRefSlots };
|