@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,4 +1,4 @@
|
|
|
1
|
-
import { RegistryTableKey } from "./
|
|
1
|
+
import { RegistryTableKey } from "./registry-shape.js";
|
|
2
2
|
import { ComputeBinding } from "./compute.js";
|
|
3
3
|
import { MemberListItem, MemberListRow, OriginTableOf, TableRow } from "./row-ref.js";
|
|
4
4
|
import { ComputeRead, ElementRef, RowRef, SiblingSlot, SiblingSource, SlotRef } from "./slot-ref.js";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { tableKeyOf } from "./slot-catalog.js";
|
|
2
1
|
import { isElementRef, isFactRef, isSiblingSlot, isSlotRef, rowOfMember } from "./slot-ref.js";
|
|
3
2
|
import { isComputeBinding } from "./compute.js";
|
|
4
3
|
import { fillsOfSource } from "./fill-builders.js";
|
|
5
|
-
import { memberListOfKey } from "./registry-shape.js";
|
|
4
|
+
import { memberListOfKey, tableOf } from "./registry-shape.js";
|
|
6
5
|
import { carriedTable, rowDefinition, rowWithMembers, withTable } from "./row-ref.js";
|
|
7
6
|
import { headWith } from "./slot-builders.js";
|
|
8
7
|
|
|
@@ -26,7 +25,7 @@ function bakeRowSource(source, label) {
|
|
|
26
25
|
}
|
|
27
26
|
function fromKey(from, label) {
|
|
28
27
|
if (Array.isArray(from)) return fromTables(from, label);
|
|
29
|
-
const table = isFactRef(from) ?
|
|
28
|
+
const table = isFactRef(from) ? tableOf(from.key) : null;
|
|
30
29
|
if (table !== null) return {
|
|
31
30
|
key: from.key,
|
|
32
31
|
tables: [table]
|
|
@@ -46,9 +45,9 @@ function fromTables(from, label) {
|
|
|
46
45
|
const keys = [];
|
|
47
46
|
const tables = [];
|
|
48
47
|
for (const entry of from) {
|
|
49
|
-
const table = isFactRef(entry) ?
|
|
48
|
+
const table = isFactRef(entry) ? tableOf(entry.key) : null;
|
|
50
49
|
if (table === null) throw new Error(`row: "${label}"'s \`from\` lists ${isFactRef(entry) ? `the fact "${entry.key}", which is not a table` : "something that is no table"} — a row's list of \`from\` names tables (\`[fact.property.contacts, …]\`); a list-valued member is a row's only \`from\`.`);
|
|
51
|
-
if (tables.
|
|
50
|
+
if (tables.includes(table)) throw new Error(`row: "${label}" names the ${table} table twice in \`from\` — each table is named once.`);
|
|
52
51
|
keys.push(entry.key);
|
|
53
52
|
tables.push(table);
|
|
54
53
|
}
|
|
@@ -59,8 +58,8 @@ function fromTables(from, label) {
|
|
|
59
58
|
}
|
|
60
59
|
function assertSourceFits(source, tables, label) {
|
|
61
60
|
const held = carriedTable(isSiblingSlot(source) ? source : isElementRef(source) ? source : void 0);
|
|
62
|
-
if (held === null || tables.
|
|
63
|
-
throw new Error(`row: "${label}" is \`from\` the ${tables.
|
|
61
|
+
if (held === null || tables.includes(held)) return;
|
|
62
|
+
throw new Error(`row: "${label}" is \`from\` the ${tables.join(", ")} table${tables.length === 1 ? "" : "s"} but its source holds a row of ${held} — a row's source yields a row of its own \`from\`.`);
|
|
64
63
|
}
|
|
65
64
|
function row(opts) {
|
|
66
65
|
const { key, tables } = fromKey(opts.from, opts.label);
|
|
@@ -7,23 +7,15 @@ import { VideoCollectionValue, VideoValue } from "./video-value.js";
|
|
|
7
7
|
import { PoiPhoto, PoiRow } from "./poi-row.js";
|
|
8
8
|
//#region ../../internal/template-contracts/dist/runtime-values.d.ts
|
|
9
9
|
/**
|
|
10
|
-
* An image slot's runtime value after resolution: `url`/`alt`
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* `responsive`.
|
|
10
|
+
* An image slot's runtime value after resolution: `url`/`alt` and the served
|
|
11
|
+
* sources. The crop is cut into `url` itself — the kit reconstructs none of it at
|
|
12
|
+
* render time, and the crop a slot stores is the editor's, never resolved; a
|
|
13
|
+
* renderer reads only `url`, `alt`, `mobile`, and `responsive`.
|
|
15
14
|
*/
|
|
16
15
|
type ImageValue = {
|
|
17
16
|
photo_id: string;
|
|
18
17
|
url: string;
|
|
19
18
|
alt: string;
|
|
20
|
-
rect?: {
|
|
21
|
-
nx: number;
|
|
22
|
-
ny: number;
|
|
23
|
-
nw: number;
|
|
24
|
-
nh: number;
|
|
25
|
-
} | null;
|
|
26
|
-
ar?: number | null;
|
|
27
19
|
mobile?: {
|
|
28
20
|
url: string;
|
|
29
21
|
responsive?: ResponsiveImage | null;
|
|
@@ -34,13 +26,6 @@ type ImageValue = {
|
|
|
34
26
|
* serves a crop. Absent, the download is `url` itself.
|
|
35
27
|
*/
|
|
36
28
|
download_url?: string;
|
|
37
|
-
/**
|
|
38
|
-
* A unit's floor plan only, read whole as an image off a section published on the
|
|
39
|
-
* units table's legacy key: the plan's floor label ("Upper Level"), or `null` for an
|
|
40
|
-
* unlabelled plan. Absent on every other image. A section on `fact.property.units`
|
|
41
|
-
* reads each plan as its `{ id, image, floor }` item, through a row declared from it.
|
|
42
|
-
*/
|
|
43
|
-
floor_label?: string | null;
|
|
44
29
|
};
|
|
45
30
|
/** An image list slot's runtime value: an ordered array of `ImageValue`, possibly empty. */
|
|
46
31
|
type ImageCollectionValue = ImageValue[];
|
|
@@ -74,7 +59,7 @@ type PlaybackConfig = {
|
|
|
74
59
|
preload?: "none" | "metadata" | "auto";
|
|
75
60
|
};
|
|
76
61
|
/**
|
|
77
|
-
* An open-kind `media` slot's runtime value: the resolved value of the
|
|
62
|
+
* An open-kind `media` slot's runtime value: the resolved value of the media's own kind,
|
|
78
63
|
* carrying that `kind` beside it, narrowed to the kinds the slot declares. Narrow on
|
|
79
64
|
* `kind` before handing it to that kind's `Slot.*`; `Slot.Image` draws any of them — an
|
|
80
65
|
* image itself, a video's or tour's poster, a document's first page.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./slot-ref.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AddressValue } from "./address-value.js";
|
|
2
2
|
import { DocumentValue } from "./document-value.js";
|
|
3
|
-
import { LinkKind, LinkProviderId, MediaKind
|
|
3
|
+
import { LinkKind, LinkProviderId, MediaKind } from "./slot-catalog.js";
|
|
4
4
|
import { TourValue } from "./tour-value.js";
|
|
5
5
|
import { VideoValue } from "./video-value.js";
|
|
6
6
|
import { ImageValue, MediaValue, PlaybackConfig } from "./runtime-values.js";
|
|
@@ -21,15 +21,11 @@ type RegistryKeySpelling = `${FactHome}.${string}`;
|
|
|
21
21
|
type ScalarFactValue = string | number | null;
|
|
22
22
|
/**
|
|
23
23
|
* Where a slot's value comes from: the `home` ref a `fact.*` entry emits into a
|
|
24
|
-
* builder's `source` — a
|
|
25
|
-
* `derived` literal `defineSchema` rewrites a `compute()` binding to, whose `transform`
|
|
24
|
+
* builder's `source` — a registry fact holding a scalar — or the `derived` literal `defineSchema` rewrites a `compute()` binding to, whose `transform`
|
|
26
25
|
* is the slot's own path. A whole address is no value of these: only an `address` slot
|
|
27
26
|
* binds it ({@link AddressFactSource}).
|
|
28
27
|
*/
|
|
29
|
-
type SlotSource = {
|
|
30
|
-
kind: "home";
|
|
31
|
-
key: SourceFieldName;
|
|
32
|
-
} | FactRef<RegistryKeySpelling, ScalarFactValue> | {
|
|
28
|
+
type SlotSource = FactRef<RegistryKeySpelling, ScalarFactValue> | {
|
|
33
29
|
kind: "derived";
|
|
34
30
|
transform: string;
|
|
35
31
|
};
|
|
@@ -107,7 +103,7 @@ type HeldPickFill = PickFill<FillNodeShape & {
|
|
|
107
103
|
readonly none?: never;
|
|
108
104
|
}>;
|
|
109
105
|
/**
|
|
110
|
-
* An `image` slot's crop — the
|
|
106
|
+
* An `image` slot's crop — the MEDIA's contract: what the cropper cuts, and which cut
|
|
111
107
|
* a viewport is served. It paints no box; the rendered box is your own classes.
|
|
112
108
|
* `mode` picks the cropper behavior ("locked" keeps `aspect`, w/h; "free" resizes any
|
|
113
109
|
* edge), `aspectLabel` is the cropper's pill text. `mobile` declares a distinct second
|
|
@@ -250,17 +246,13 @@ interface SelectOptionObject {
|
|
|
250
246
|
description?: string;
|
|
251
247
|
}
|
|
252
248
|
/**
|
|
253
|
-
* The serialized shape a select slot emits — a `select`-kind slot. `values`
|
|
254
|
-
* authored `from`, stored under the wire's name
|
|
255
|
-
*
|
|
256
|
-
* was built with `select({ from })` or `select({ source: fact.… })`.
|
|
249
|
+
* The serialized shape a select slot emits — a `select`-kind slot. `values` is the
|
|
250
|
+
* authored `from`, stored under the wire's name; a select built with
|
|
251
|
+
* `select({ source: fact.… })` carries none, offering the choices its fact declares.
|
|
257
252
|
*/
|
|
258
253
|
interface SelectSlotDef extends Head {
|
|
259
254
|
type: "select";
|
|
260
255
|
values?: SelectOptionInput[];
|
|
261
|
-
options?: {
|
|
262
|
-
source: string;
|
|
263
|
-
};
|
|
264
256
|
creatable?: boolean;
|
|
265
257
|
}
|
|
266
258
|
/** The one source that supplies a select's vocabulary: a fact binding. */
|
|
@@ -328,7 +320,7 @@ interface DisplaySelectOptions<C extends readonly [string, ...string[]]> {
|
|
|
328
320
|
*
|
|
329
321
|
* select({ label: "Status", from: ["for_sale", "sold"] });
|
|
330
322
|
* select({ label: "Listing status", source: fact.property.listing_intent });
|
|
331
|
-
* select({ from: ["visible", "hidden"], source: compute({ reads: [fact.property.uploads] }, (uploads) => (uploads.some((
|
|
323
|
+
* select({ from: ["visible", "hidden"], source: compute({ reads: [fact.property.uploads] }, (uploads) => (uploads.some((upload) => upload.kind === "tour") ? "visible" : "hidden")) });
|
|
332
324
|
* const VARIANTS = ["classic", "editorial"] as const;
|
|
333
325
|
* select({ from: VARIANTS, source: fill.pick({ brief: "Prefer editorial for story-driven narratives." }) });
|
|
334
326
|
* ```
|
|
@@ -501,8 +493,8 @@ interface AddressSlotDef extends Head {
|
|
|
501
493
|
declare function address<const HasSource extends AddressOptions["source"] = undefined>(opts?: AddressOptions & {
|
|
502
494
|
source?: HasSource;
|
|
503
495
|
} & MirrorOption<HasSource, AddressValue | null>): AddressSlotDef & SourceMark<HasSource> & AddressMembers & FillMark;
|
|
504
|
-
/** The fill a single
|
|
505
|
-
type
|
|
496
|
+
/** The fill a single media slot takes: one pick, out of its candidate set. */
|
|
497
|
+
type MediaFill = HeldPickFill;
|
|
506
498
|
/** A home list of media, as declared: a list whose item is a media declaration. */
|
|
507
499
|
interface MediaListDeclaration {
|
|
508
500
|
readonly type: "list";
|
|
@@ -525,24 +517,24 @@ type MediaListFrom = FactRef<RegistryKeySpelling, readonly DocumentMediaValue[]>
|
|
|
525
517
|
/**
|
|
526
518
|
* A media declaration's `from`: one media list, or an ordered list of them. `from: a`
|
|
527
519
|
* and `from: [a]` are one declaration. The candidates are the union in declared order —
|
|
528
|
-
* list order first, each list's own order within it — and one
|
|
520
|
+
* list order first, each list's own order within it — and one media value in two lists is one
|
|
529
521
|
* candidate, attributed to the first.
|
|
530
522
|
*/
|
|
531
523
|
type MediaFromLists = MediaListFrom | readonly [MediaListFrom, ...MediaListFrom[]];
|
|
532
524
|
/** The keys a media declaration of `Kinds` takes, beside its kind's own options. */
|
|
533
525
|
interface MediaFilterOptions<Kinds extends MediaKind> {
|
|
534
526
|
/**
|
|
535
|
-
* The media list the declaration picks from: its candidates are the list's
|
|
527
|
+
* The media list the declaration picks from: its candidates are the list's media of
|
|
536
528
|
* its kinds, which a picker offers and a `fill.pick` chooses among. Absent, the
|
|
537
|
-
* declaration owns its
|
|
529
|
+
* declaration owns its media — a one-off the user uploads or pastes into it. An ordered
|
|
538
530
|
* list of lists picks from their union; each list must hold items of the declaration's
|
|
539
531
|
* kinds.
|
|
540
532
|
*/
|
|
541
533
|
from?: MediaFromLists;
|
|
542
534
|
/**
|
|
543
|
-
* The processes run on every
|
|
535
|
+
* The processes run on every media value that becomes the value — `process.cutout()`, the
|
|
544
536
|
* background removed; `process.autocrop({ brief })`, cropped to its subject (an
|
|
545
|
-
* image's). Declare it where
|
|
537
|
+
* image's). Declare it where a file first lands; a slot picking from a list that
|
|
546
538
|
* declares it reads the result and declares nothing.
|
|
547
539
|
*/
|
|
548
540
|
process?: readonly [HolderProcessOf<Kinds>, ...HolderProcessOf<Kinds>[]];
|
|
@@ -569,8 +561,8 @@ interface MediaFilterKeys<Kinds extends MediaKind> {
|
|
|
569
561
|
from?: string | MediaListPage | MediaListDeclaration | readonly (string | MediaListPage | MediaListDeclaration)[];
|
|
570
562
|
process?: HolderProcessOf<Kinds>[];
|
|
571
563
|
}
|
|
572
|
-
interface ImageOptions extends Omit<CommonOptions<ImageValue | ImageMedia | null,
|
|
573
|
-
source?: CommonOptions<ImageValue | ImageMedia | null,
|
|
564
|
+
interface ImageOptions extends Omit<CommonOptions<ImageValue | ImageMedia | null, MediaFill>, "source"> {
|
|
565
|
+
source?: CommonOptions<ImageValue | ImageMedia | null, MediaFill>["source"] | ImageFactSource;
|
|
574
566
|
crop?: CropConfig;
|
|
575
567
|
}
|
|
576
568
|
/** The serialized shape the `image` builder emits — an `image`-kind slot. */
|
|
@@ -580,7 +572,7 @@ interface ImageSlotDef extends Head, MediaFilterKeys<"image"> {
|
|
|
580
572
|
}
|
|
581
573
|
/**
|
|
582
574
|
* A single image slot — the resolved value is always one `ImageValue`, never a list,
|
|
583
|
-
* so it carries no count bounds (a list of them does). `crop` is the
|
|
575
|
+
* so it carries no count bounds (a list of them does). `crop` is the media's contract —
|
|
584
576
|
* the editor's cropper and `<Image>`'s mobile-crop switch read it; the box the image
|
|
585
577
|
* renders in is the section's own classes. `source: fill.pick({ brief })` picks one
|
|
586
578
|
* image out of its `from`.
|
|
@@ -606,7 +598,7 @@ interface ImageSlotDef extends Head, MediaFilterKeys<"image"> {
|
|
|
606
598
|
declare function image<const HasSource extends SourceBinding | ImageFactSource | undefined = undefined>(opts?: ImageOptions & {
|
|
607
599
|
source?: HasSource;
|
|
608
600
|
} & MirrorOption<HasSource, ImageValue | ImageMedia | null> & MediaFilterOption<HasSource, "image">): ImageSlotDef & SourceMark<HasSource> & FillMark;
|
|
609
|
-
interface VideoOptions extends CommonOptions<VideoValue | VideoMedia | null,
|
|
601
|
+
interface VideoOptions extends CommonOptions<VideoValue | VideoMedia | null, MediaFill> {
|
|
610
602
|
playback?: PlaybackConfig;
|
|
611
603
|
}
|
|
612
604
|
/** The serialized shape the `video` builder emits — a `video`-kind slot. */
|
|
@@ -631,7 +623,7 @@ interface VideoSlotDef extends Head, MediaFilterKeys<"video"> {
|
|
|
631
623
|
declare function video<const HasSource extends SourceBinding | undefined = undefined>(opts?: VideoOptions & {
|
|
632
624
|
source?: HasSource;
|
|
633
625
|
} & MirrorOption<HasSource, VideoValue | VideoMedia | null> & MediaFilterOption<HasSource, "video">): VideoSlotDef & SourceMark<HasSource> & FillMark;
|
|
634
|
-
type TourOptions = CommonOptions<TourValue | TourMedia | null,
|
|
626
|
+
type TourOptions = CommonOptions<TourValue | TourMedia | null, MediaFill>;
|
|
635
627
|
/** The serialized shape the `tour` builder emits — a `tour`-kind slot. */
|
|
636
628
|
interface TourSlotDef extends Head, MediaFilterKeys<"tour"> {
|
|
637
629
|
type: "tour";
|
|
@@ -702,7 +694,7 @@ interface DocumentOptions {
|
|
|
702
694
|
required?: boolean;
|
|
703
695
|
placeholder?: string;
|
|
704
696
|
when?: string | readonly string[];
|
|
705
|
-
source?:
|
|
697
|
+
source?: MediaFill | ElementRef<DocumentValue | DocumentMedia, null>;
|
|
706
698
|
}
|
|
707
699
|
/** The serialized shape the `document` builder emits — a `document`-kind slot. */
|
|
708
700
|
interface DocumentSlotDef extends Head, MediaFilterKeys<"document"> {
|
|
@@ -736,11 +728,11 @@ interface DocumentSlotDef extends Head, MediaFilterKeys<"document"> {
|
|
|
736
728
|
declare function document<const HasSource extends DocumentOptions["source"] = undefined>(opts?: DocumentOptions & {
|
|
737
729
|
source?: HasSource;
|
|
738
730
|
} & MediaFilterOption<HasSource, "document">): DocumentSlotDef & SourceMark<HasSource> & FillMark;
|
|
739
|
-
/** The
|
|
740
|
-
type
|
|
731
|
+
/** The media record of one of `Kinds` — what a `compute()` hands an open-kind media slot. */
|
|
732
|
+
type MediaOfKind<Kinds extends MediaKind> = Extract<ImageMedia | VideoMedia | TourMedia | DocumentMedia, {
|
|
741
733
|
kind: Kinds;
|
|
742
734
|
}>;
|
|
743
|
-
interface MediaOptions<Kinds extends MediaKind> extends CommonOptions<MediaValue<Kinds> |
|
|
735
|
+
interface MediaOptions<Kinds extends MediaKind> extends CommonOptions<MediaValue<Kinds> | MediaOfKind<Kinds> | null, MediaFill> {
|
|
744
736
|
/** The kinds the field may hold. Absent: all four — an image, a video, a tour or a document. */
|
|
745
737
|
kinds?: readonly [Kinds, ...Kinds[]];
|
|
746
738
|
}
|
|
@@ -752,10 +744,10 @@ interface MediaSlotDef<Kinds extends MediaKind = MediaKind> extends Head, MediaF
|
|
|
752
744
|
/**
|
|
753
745
|
* A media value whose kind is left open among `kinds` — an image, a video, a tour or a
|
|
754
746
|
* document, whichever is picked. `from` names the list it is picked from; its candidates
|
|
755
|
-
* are that list's
|
|
756
|
-
* them. Absent, the slot owns its
|
|
747
|
+
* are that list's media of `kinds`, and `source: fill.pick({ brief })` picks one of
|
|
748
|
+
* them. Absent, the slot owns its media: the user uploads or pastes one into it.
|
|
757
749
|
*
|
|
758
|
-
* Its value carries the
|
|
750
|
+
* Its value carries the media's `kind`. There is no `Slot.Media`: narrow on `kind` and
|
|
759
751
|
* render that kind's own `Slot.Video`, `Slot.Tour` or `Slot.Document`, handing it the
|
|
760
752
|
* narrowed value; `Slot.Image` takes any of them, drawing a video's or tour's poster and
|
|
761
753
|
* a document's first page.
|
|
@@ -767,7 +759,7 @@ interface MediaSlotDef<Kinds extends MediaKind = MediaKind> extends Head, MediaF
|
|
|
767
759
|
* label: "Photo or video",
|
|
768
760
|
* kinds: ["image", "video"],
|
|
769
761
|
* from: fact.property.property_media,
|
|
770
|
-
* source: fill.pick({ brief: "The one
|
|
762
|
+
* source: fill.pick({ brief: "The one photo or video that sells the kitchen." }),
|
|
771
763
|
* });
|
|
772
764
|
*
|
|
773
765
|
* // in the renderer
|
|
@@ -777,6 +769,6 @@ interface MediaSlotDef<Kinds extends MediaKind = MediaKind> extends Head, MediaF
|
|
|
777
769
|
*/
|
|
778
770
|
declare function media<const Kinds extends MediaKind = MediaKind, const HasSource extends SourceBinding | undefined = undefined>(opts?: MediaOptions<Kinds> & {
|
|
779
771
|
source?: HasSource;
|
|
780
|
-
} & MirrorOption<HasSource, MediaValue<Kinds> |
|
|
772
|
+
} & MirrorOption<HasSource, MediaValue<Kinds> | MediaOfKind<Kinds> | null> & MediaFilterOption<HasSource, Kinds>): MediaSlotDef<Kinds> & SourceMark<HasSource> & FillMark;
|
|
781
773
|
//#endregion
|
|
782
774
|
export { AddressFactSource, AddressSlotDef, CropConfig, DateSlotDef, DisplayEntryInput, DisplayFill, DocumentSlotDef, EmailSlotDef, FindFillFor, HeldPickFill, ImageFactSource, ImageSlotDef, MediaFilterOption, MediaFromLists, MediaListDeclaration, MediaListFrom, MediaListPage, MediaSlotDef, MirrorOption, MirrorSource, MirrorValueOption, NumberSlotDef, PhoneSlotDef, PoiSlotDef, RequiredOption, SelectBuilder, SelectOptionInput, SelectOptionObject, SelectSlotDef, SlotSource, SourceBinding, SourceMark, TextSlotDef, TourSlotDef, UrlSlotDef, VideoSlotDef, WriteFillFor, address, date, document, email, image, media, number, phone, poi, select, text, tour, url, video };
|
|
@@ -4,7 +4,6 @@ import { isComputeBinding } from "./compute.js";
|
|
|
4
4
|
import { fillsOfSource, isFillBinding } from "./fill-builders.js";
|
|
5
5
|
import { fillMark } from "./fill-declaration.js";
|
|
6
6
|
import { addressWithMembers } from "./row-ref.js";
|
|
7
|
-
import { legacyFactKey } from "./registry-aliases.js";
|
|
8
7
|
|
|
9
8
|
//#region ../../internal/template-contracts/dist/slot-builders.js
|
|
10
9
|
function refuseStatedOf(at, source) {
|
|
@@ -77,11 +76,9 @@ function number(opts) {
|
|
|
77
76
|
};
|
|
78
77
|
}
|
|
79
78
|
function selectFromFact(opts) {
|
|
80
|
-
const source = opts.source;
|
|
81
79
|
return {
|
|
82
80
|
type: "select",
|
|
83
81
|
...head(opts),
|
|
84
|
-
...isFactRef(source) ? { options: { source: legacyFactKey(source.key) } } : {},
|
|
85
82
|
...opts.creatable !== void 0 ? { creatable: opts.creatable } : {}
|
|
86
83
|
};
|
|
87
84
|
}
|
|
@@ -145,7 +142,7 @@ function address(opts = {}) {
|
|
|
145
142
|
function mediaFilterKeys(type, opts) {
|
|
146
143
|
const at = `${type}: "${opts.label ?? type}"`;
|
|
147
144
|
refuseStatedOf(at, opts.source);
|
|
148
|
-
if ("category" in opts) throw new Error(`${at} declares \`category\` — a media declaration names the list it picks from in \`from\` (\`from: fact.property.property_media\`, \`fact.property.floor_plans\`, \`fact.property.uploads\`), or owns its
|
|
145
|
+
if ("category" in opts) throw new Error(`${at} declares \`category\` — a media declaration names the list it picks from in \`from\` (\`from: fact.property.property_media\`, \`fact.property.floor_plans\`, \`fact.property.uploads\`), or owns its media without one.`);
|
|
149
146
|
if ("sources" in opts) throw new Error(`${at} declares \`sources\` — a media slot takes a pasted link wherever a link provider claims its kind (a video, a tour), and declares nothing for it. \`concrete upgrade\` removes it.`);
|
|
150
147
|
const problem = mediaDeclarationProblem({
|
|
151
148
|
type,
|
|
@@ -157,7 +154,7 @@ function mediaFilterKeys(type, opts) {
|
|
|
157
154
|
const bound = opts.source !== void 0 && fills === void 0 && !isComputeBinding(opts.source);
|
|
158
155
|
if (bound && opts.from !== void 0) throw new Error(`${at} picks \`from\` a media list and declares a \`source\` — a slot bound to a fact holds what that fact holds.`);
|
|
159
156
|
if ((bound || isComputeBinding(opts.source)) && opts.process !== void 0) throw new Error(`${at} declares \`process\` beside a \`source\` that derives its value — a derived slot holds what it derives from, processed where that is declared.`);
|
|
160
|
-
if (fills?.some((fill) => fill.verb === "pick") === true && opts.from === void 0) throw new Error(`${at} is picked by a \`fill.pick\` and names no \`from\` — a pick chooses from its holder's \`from\` (\`from: fact.property.property_media\`); a media declaration without one owns its
|
|
157
|
+
if (fills?.some((fill) => fill.verb === "pick") === true && opts.from === void 0) throw new Error(`${at} is picked by a \`fill.pick\` and names no \`from\` — a pick chooses from its holder's \`from\` (\`from: fact.property.property_media\`); a media declaration without one owns its media.`);
|
|
161
158
|
const emitted = fromLists(at, type, opts.kinds, opts.from)?.map((list) => isFactRef(list) ? list.key : list);
|
|
162
159
|
return {
|
|
163
160
|
...emitted !== void 0 ? { from: emitted.length === 1 ? emitted[0] : emitted } : {},
|
|
@@ -167,7 +164,7 @@ function mediaFilterKeys(type, opts) {
|
|
|
167
164
|
function fromLists(at, type, kinds, from) {
|
|
168
165
|
if (from === void 0) return void 0;
|
|
169
166
|
const lists = Array.isArray(from) ? from : [from];
|
|
170
|
-
if (lists.length === 0) throw new Error(`${at} declares \`from: []\` — name the media list it picks from, or omit \`from\` and the declaration owns its
|
|
167
|
+
if (lists.length === 0) throw new Error(`${at} declares \`from: []\` — name the media list it picks from, or omit \`from\` and the declaration owns its media.`);
|
|
171
168
|
const holds = declaredKinds({
|
|
172
169
|
type,
|
|
173
170
|
kinds
|
|
@@ -176,7 +173,7 @@ function fromLists(at, type, kinds, from) {
|
|
|
176
173
|
for (const list of lists) {
|
|
177
174
|
const declared = typeof list === "object" && list !== null && !isFactRef(list);
|
|
178
175
|
const identity = isFactRef(list) ? list.key : declared && "declaration" in list ? list.declaration : list;
|
|
179
|
-
if (seen.has(identity)) throw new Error(`${at} picks \`from\` one media list twice — each list is named once;
|
|
176
|
+
if (seen.has(identity)) throw new Error(`${at} picks \`from\` one media list twice — each list is named once; a media value two lists hold is one candidate, attributed to the first.`);
|
|
180
177
|
seen.add(identity);
|
|
181
178
|
if (!declared) continue;
|
|
182
179
|
const listed = declaredKinds(identity.element);
|