@homepages/concrete 1.0.2 → 2.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 +112 -0
- package/codemods/manifest.json +12 -0
- package/codemods/unlayer-author-css.mjs +194 -0
- package/dist/artifact/playground/client/assets/index-CW7co-u9.js +1101 -0
- package/dist/artifact/playground/client/assets/index-CckS2ONm.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 +24 -24
- package/dist/base.css +15 -2
- package/dist/cli/build/artifact.js +5 -2
- package/dist/cli/build/captures.js +15 -18
- package/dist/cli/build/fixtures.js +11 -3
- package/dist/cli/build/sections.js +13 -4
- package/dist/cli/build/static.js +1 -1
- package/dist/cli/check/load-workspace.js +6 -1
- package/dist/cli/check/stages/bundles.js +3 -1
- package/dist/cli/commands.js +1 -1
- package/dist/cli/dev/load-template.js +32 -25
- package/dist/cli/dev/server.js +11 -3
- package/dist/cli/dev/vite.js +78 -22
- package/dist/cli/dev/workspace-reader.js +2 -6
- package/dist/cli/media/derive.js +30 -3
- package/dist/cli/media/deriver-plugin.js +6 -2
- package/dist/cli/media/frame-rung-floor.js +18 -0
- package/dist/css/compile.js +26 -4
- package/dist/css/graph.js +2 -1
- package/dist/css/rules.js +72 -1
- package/dist/eslint/authoring.js +2 -0
- package/dist/eslint/rules/island-ids.js +39 -0
- package/dist/fixtures/load.js +6 -1
- package/dist/fixtures/media-plugin.js +32 -17
- package/dist/fixtures/media.js +41 -8
- package/dist/fixtures/package-stylesheets.js +59 -0
- package/dist/fixtures/property.js +40 -9
- package/dist/fixtures/resolve.js +58 -5
- package/dist/fixtures/rows.js +6 -1
- package/dist/fixtures.d.ts +80 -12
- package/dist/fixtures.js +7 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/islands/island-id.js +8 -0
- package/dist/islands/marker.d.ts +14 -4
- package/dist/islands/marker.js +18 -6
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/island-runtime/dist/index.js +4 -2
- package/dist/packages/internal/island-runtime/dist/island-id-context.js +15 -0
- package/dist/packages/internal/island-runtime/dist/use-island-id.d.ts +24 -0
- package/dist/packages/internal/island-runtime/dist/use-island-id.js +44 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +44 -2
- package/dist/primitives/slot-bindings.d.ts +19 -13
- package/dist/primitives/slot-bindings.js +7 -3
- package/dist/rules/registry.js +19 -0
- package/dist/section/section.d.ts +6 -1
- package/dist/template/logic-shim.d.ts +2 -1
- package/dist/template/logic-shim.js +2 -1
- package/guide/reference/cli/INDEX.md +2 -2
- package/guide/reference/cli/build.md +2 -2
- 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 -1
- package/package.json +1 -1
- package/dist/artifact/playground/client/assets/index-BSA1yutg.css +0 -1
- package/dist/artifact/playground/client/assets/index-JloQyj8h.js +0 -1101
package/dist/fixtures.d.ts
CHANGED
|
@@ -33,15 +33,31 @@ type FloorPlanEntry = Omit<CanonicalFloorPlan, "upload_id" | "page_index" | "pro
|
|
|
33
33
|
type UploadVideoEntry = Omit<CanonicalVideo, "source" | "url" | "provider"> & {
|
|
34
34
|
readonly source: "upload";
|
|
35
35
|
readonly file: MediaFile;
|
|
36
|
+
/**
|
|
37
|
+
* The poster frame the platform cuts from the upload, imported like any image and
|
|
38
|
+
* served with its ladder. Absent means the video resolves with no poster.
|
|
39
|
+
*/
|
|
40
|
+
readonly poster?: MediaFile;
|
|
36
41
|
};
|
|
37
42
|
/** A pasted provider link. Stays a URL, exactly as the platform stores it. */
|
|
38
43
|
type LinkVideoEntry = Omit<CanonicalVideo, "source"> & {
|
|
39
44
|
readonly source: "link";
|
|
45
|
+
/**
|
|
46
|
+
* The provider thumbnail the platform's link enrichment records, served as the
|
|
47
|
+
* video's poster. It stays a link: the fixture never hosts it. Absent means no poster.
|
|
48
|
+
*/
|
|
49
|
+
readonly thumbnail_source_url?: string;
|
|
40
50
|
};
|
|
41
51
|
/** One video candidate — a hosted upload or a pasted provider link. */
|
|
42
52
|
type VideoEntry = UploadVideoEntry | LinkVideoEntry;
|
|
43
53
|
/** One 3D tour link. Stays a URL, exactly as the platform stores it. */
|
|
44
|
-
type TourEntry = Canonical["tours"][number]
|
|
54
|
+
type TourEntry = Canonical["tours"][number] & {
|
|
55
|
+
/**
|
|
56
|
+
* The provider thumbnail the platform's link enrichment records, served as the
|
|
57
|
+
* tour's poster. It stays a link. Absent means no poster, as for a private tour.
|
|
58
|
+
*/
|
|
59
|
+
readonly thumbnail_source_url?: string;
|
|
60
|
+
};
|
|
45
61
|
/**
|
|
46
62
|
* An attachable document: its file imported, plus the notes distilled from it. The
|
|
47
63
|
* property's `document_notes` are derived from these entries and never stated.
|
|
@@ -64,10 +80,11 @@ type ContactEntry = Omit<CanonicalContact, "avatar_upload_id" | "logo_dark_uploa
|
|
|
64
80
|
* Facts only. Unit copy, points of interest, amenities and any other fill output are
|
|
65
81
|
* not on a property; a fixture states them in its content entries.
|
|
66
82
|
*/
|
|
67
|
-
type Property = Omit<Canonical, "photos" | "floor_plans" | "videos" | "documents" | "contacts" | "document_notes"> & {
|
|
83
|
+
type Property = Omit<Canonical, "photos" | "floor_plans" | "videos" | "tours" | "documents" | "contacts" | "document_notes"> & {
|
|
68
84
|
readonly photos: PhotoEntry[];
|
|
69
85
|
readonly floor_plans: FloorPlanEntry[];
|
|
70
86
|
readonly videos: VideoEntry[];
|
|
87
|
+
readonly tours: TourEntry[];
|
|
71
88
|
readonly documents: DocumentEntry[];
|
|
72
89
|
readonly contacts: ContactEntry[];
|
|
73
90
|
};
|
|
@@ -139,6 +156,40 @@ type SlotsOf<S> = S extends {
|
|
|
139
156
|
type ContentRow<I> = {
|
|
140
157
|
readonly id?: string;
|
|
141
158
|
} & { readonly [K in keyof I]?: ContentSlotValue<I[K]> | null; };
|
|
159
|
+
/** Which of a contact card's three images a {@link ContactImageEntry} names. */
|
|
160
|
+
type ContactImageField = "avatar" | "logo_dark" | "logo_light";
|
|
161
|
+
/**
|
|
162
|
+
* One of a contact's images, stated as the card of the fixture's property plus the field:
|
|
163
|
+
* `{ contact: listingAgent, field: "logo_dark" }`. A contact's avatar and logos are image
|
|
164
|
+
* media like any other, but the platform holds them on the card rather than in a pool, so
|
|
165
|
+
* they have no entry of their own to state — this names the same image the resolver
|
|
166
|
+
* registers, and it resolves to the `{ asset_id }` a `contactAssign` fill bakes for that
|
|
167
|
+
* field. A contact the property does not carry, or a field it holds `null`, is a check
|
|
168
|
+
* error like any other media the property lacks.
|
|
169
|
+
*/
|
|
170
|
+
interface ContactImageEntry {
|
|
171
|
+
readonly contact: ContactEntry;
|
|
172
|
+
readonly field: ContactImageField;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The fields of a record list a content entry may state: the ones carrying no `source:`
|
|
176
|
+
* of their own.
|
|
177
|
+
*
|
|
178
|
+
* @remarks
|
|
179
|
+
* On an unbound list every field qualifies, so this is the identity — a per-field
|
|
180
|
+
* source is only legal on a fact-bound list at all (`assertSourceContract`). On a
|
|
181
|
+
* COLLECTION-bound list it is the enriched half: the fields a `list-fill` writes onto
|
|
182
|
+
* rows the facts originate, which is exactly what a fixture states there
|
|
183
|
+
* ({@link ContentSlots}).
|
|
184
|
+
*/
|
|
185
|
+
type RowFillFields<I> = { [K in keyof I as I[K] extends {
|
|
186
|
+
source: unknown;
|
|
187
|
+
} ? never : K]: I[K]; };
|
|
188
|
+
/**
|
|
189
|
+
* An entry a content doc may state on an `image` slot: every property entry the resolver
|
|
190
|
+
* registers as image media — a photo, a floor plan, or one of a contact's images.
|
|
191
|
+
*/
|
|
192
|
+
type ImageEntry = PhotoEntry | FloorPlanEntry | ContactImageEntry;
|
|
142
193
|
/**
|
|
143
194
|
* The value one slot takes in a content entry: a media slot takes an entry of the
|
|
144
195
|
* fixture's property, a list of them an array, a record list its rows, a points-of-
|
|
@@ -147,7 +198,7 @@ type ContentRow<I> = {
|
|
|
147
198
|
*/
|
|
148
199
|
type ContentSlotValue<S> = S extends {
|
|
149
200
|
type: "image";
|
|
150
|
-
} ?
|
|
201
|
+
} ? ImageEntry : S extends {
|
|
151
202
|
type: "video";
|
|
152
203
|
} ? VideoEntry : S extends {
|
|
153
204
|
type: "tour";
|
|
@@ -158,18 +209,31 @@ type ContentSlotValue<S> = S extends {
|
|
|
158
209
|
} ? PoiRow : S extends {
|
|
159
210
|
type: "list";
|
|
160
211
|
fields: infer I;
|
|
161
|
-
} ? readonly ContentRow<I
|
|
212
|
+
} ? readonly ContentRow<RowFillFields<I>>[] : S extends {
|
|
162
213
|
type: "list";
|
|
163
214
|
element: infer E;
|
|
164
215
|
} ? readonly NonNullable<ContentSlotValue<E>>[] : SlotValue<S>;
|
|
165
216
|
/**
|
|
166
|
-
* The slots a content entry may state: every declared slot
|
|
167
|
-
* ones, each optional
|
|
168
|
-
*
|
|
217
|
+
* The slots a content entry may state: every declared slot except the source-bound
|
|
218
|
+
* ones, each optional — plus the one source-bound slot a fill does write, a record
|
|
219
|
+
* list bound to a collection.
|
|
220
|
+
*
|
|
221
|
+
* @remarks
|
|
222
|
+
* A fact-bound or computed slot resolves from the property and is never stated, so
|
|
223
|
+
* naming one is a compile error. A record list bound to a collection is the exception,
|
|
224
|
+
* and it is the platform's own shape rather than a loophole: the fill originates its
|
|
225
|
+
* rows from the facts (`mode: "facts"`) and then plans the fields that carry no
|
|
226
|
+
* `source:` onto them in one batched call, merging both halves into a single stored row
|
|
227
|
+
* (`enrichRef` in `@homepages/fill-bake`). A fixture states that enriched half and
|
|
228
|
+
* nothing else — {@link RowFillFields} drops the baked fields from the row type, and
|
|
229
|
+
* the resolver merges what is stated onto the baked rows by position.
|
|
169
230
|
*/
|
|
170
231
|
type ContentSlots<Slots> = { readonly [K in keyof Slots as Slots[K] extends {
|
|
171
232
|
source: unknown;
|
|
172
|
-
} ?
|
|
233
|
+
} ? Slots[K] extends {
|
|
234
|
+
type: "list";
|
|
235
|
+
fields: unknown;
|
|
236
|
+
} ? K : never : K]?: ContentSlotValue<Slots[K]> | null; };
|
|
173
237
|
type VariantOf<S> = S extends {
|
|
174
238
|
readonly schema: {
|
|
175
239
|
readonly meta: infer Meta;
|
|
@@ -200,14 +264,18 @@ type ExactContent<M, Allowed> = M & Allowed & { [K in Exclude<keyof M, keyof All
|
|
|
200
264
|
/**
|
|
201
265
|
* State the content a fill would generate for one placed instance of a section: its
|
|
202
266
|
* generative slots and its display state, typed by the section value. A fact-bound or
|
|
203
|
-
* computed slot is never stated here — derived information is taken from the property
|
|
267
|
+
* computed slot is never stated here — derived information is taken from the property —
|
|
268
|
+
* with one exception in the platform's own image: a record list bound to a collection
|
|
269
|
+
* takes the fields of each row a fill enriches, stated row by row in the property's own
|
|
270
|
+
* order, while the row's bound fields stay the bake's.
|
|
204
271
|
* Media is stated by value, as an entry of the fixture's property (`hero_image:
|
|
205
272
|
* deckShot`), of the slot's own kind; an entry the property does not carry is a check
|
|
206
|
-
* error. A
|
|
207
|
-
*
|
|
273
|
+
* error. A contact's image, which has no entry, is stated as the card plus the field
|
|
274
|
+
* ({@link ContactImageEntry}). A second placed instance names itself with `instance`,
|
|
275
|
+
* the same id the placement wrote.
|
|
208
276
|
*/
|
|
209
277
|
declare function content<S extends SectionRef, M extends object>(section: S, values: ExactContent<M, ContentValuesOf<S>>, options?: {
|
|
210
278
|
readonly instance?: string;
|
|
211
279
|
}): ContentEntry<S>;
|
|
212
280
|
//#endregion
|
|
213
|
-
export { ContactEntry, ContentDisplay, ContentEntry, ContentRow, ContentSlotValue, ContentSlots, ContentValues, ContentValuesOf, DocumentEntry, ExactContent, Fixture, FixtureSpec, FloorPlanEntry, LinkVideoEntry, MediaFile, PhotoEntry, Property, SectionRef, TourEntry, UploadVideoEntry, VideoEntry, content, defineFixture };
|
|
281
|
+
export { ContactEntry, ContactImageEntry, ContactImageField, ContentDisplay, ContentEntry, ContentRow, ContentSlotValue, ContentSlots, ContentValues, ContentValuesOf, DocumentEntry, ExactContent, Fixture, FixtureSpec, FloorPlanEntry, ImageEntry, LinkVideoEntry, MediaFile, PhotoEntry, Property, RowFillFields, SectionRef, TourEntry, UploadVideoEntry, VideoEntry, content, defineFixture };
|
package/dist/fixtures.js
CHANGED
|
@@ -15,11 +15,15 @@ function defineFixture(spec) {
|
|
|
15
15
|
/**
|
|
16
16
|
* State the content a fill would generate for one placed instance of a section: its
|
|
17
17
|
* generative slots and its display state, typed by the section value. A fact-bound or
|
|
18
|
-
* computed slot is never stated here — derived information is taken from the property
|
|
18
|
+
* computed slot is never stated here — derived information is taken from the property —
|
|
19
|
+
* with one exception in the platform's own image: a record list bound to a collection
|
|
20
|
+
* takes the fields of each row a fill enriches, stated row by row in the property's own
|
|
21
|
+
* order, while the row's bound fields stay the bake's.
|
|
19
22
|
* Media is stated by value, as an entry of the fixture's property (`hero_image:
|
|
20
23
|
* deckShot`), of the slot's own kind; an entry the property does not carry is a check
|
|
21
|
-
* error. A
|
|
22
|
-
*
|
|
24
|
+
* error. A contact's image, which has no entry, is stated as the card plus the field
|
|
25
|
+
* ({@link ContactImageEntry}). A second placed instance names itself with `instance`,
|
|
26
|
+
* the same id the placement wrote.
|
|
23
27
|
*/
|
|
24
28
|
function content(section, values, options = {}) {
|
|
25
29
|
const stated = values;
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ import "./schema/section-schema.js";
|
|
|
18
18
|
import { RowValue, SlotValue } from "./schema/section-props.js";
|
|
19
19
|
import { UseEditorResult, useEditor } from "./packages/internal/island-runtime/dist/use-editor.js";
|
|
20
20
|
import { useCaptureReady } from "./packages/internal/island-runtime/dist/use-capture-ready.js";
|
|
21
|
+
import { useIslandId } from "./packages/internal/island-runtime/dist/use-island-id.js";
|
|
21
22
|
import { IslandMarker, IslandMarkerProps } from "./islands/marker.js";
|
|
22
23
|
import { BoundSlotValue, FieldBinding, ItemBinding, RowBinding, SlotBinding, SlotBindingMap, bindItems } from "./primitives/slot-bindings.js";
|
|
23
24
|
import { SectionOptions, SlotRef } from "./section/declare.js";
|
|
@@ -50,4 +51,4 @@ import { a4Landscape, a4Portrait, deck16x9, facebookPost, halfLetterFlyer, insta
|
|
|
50
51
|
*/
|
|
51
52
|
declare const CONCRETE_VERSION: string;
|
|
52
53
|
//#endregion
|
|
53
|
-
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 AuthorImage, type BoundSlotValue, type BuiltDecision, CONCRETE_VERSION, type CanvasInput, type CanvasesInput, type ChosenRows, type CollectionRowValues, type ComparableRow, type ComputeBinding, type ContactRow, type Coordinates, type CropConfig, type DecisionKind, type DefineTemplateInput, type DerivedFactRef, type DirectFactRef, type DisplayChoice, type DisplayEntryInput, type DocumentCollectionValue, type DocumentFormat, type DocumentSlot, type DocumentSlotDef, type DocumentValue, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, type Edit, EditorBridge, EditorBridgeSelection, EditorSelection, type FactNamespace, type Facts, type FactsAddress, type FactsContact, type FactsDocument, type FactsDocumentNote, type FactsFloorPlan, type FactsNarrative, type FactsPhoto, type FactsTour, type FactsUnit, type FactsVideo, type FieldBinding, type FloorplanAssignment, type FormatIdentity, FrameShell, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, Image, type ImageCollectionValue, type ImageFormat, type ImageSlot, type ImageSlotDef, type ImageValue, IslandComponent, IslandEditor, IslandEditorOptions, IslandMarker, type IslandMarkerProps, IslandModule, IslandProps, IslandPropsError, IslandServerFrame, type ItemBinding, type ListFieldSlot, type ListItemSlot, type ListRecordSlotDef, type ListSlot, type ListSlotDef, type NamedRows, type Narrative, type NumberSlot, type NumberSlotDef, type OutputClass, type PageComponent, type PhysicalLength, type PicturePlan, type PictureSourceSpec, type PlaybackConfig, type PoiPhoto, type PoiRow, type PoiSlot, type PoiSlotDef, type ReconcileContext, type ReconcileRule, type ReconcileRuleOptions, type RenderedPage, type ResponsiveImage, type ResponsiveSource, type RowBinding, type RowOrigination, type RowValue, Section, type SectionContractProps, type SectionOptions, type SectionPlacementProps, type SectionRenderBindings, type SectionValue, type SelectSlot, type SelectSlotDef, type SetEdit, type SiteValues, type SiteViewOf, Slot, type SlotBinding, type SlotBindingMap, SlotGroup, type SlotRef, type SlotSource, type SlotValue, type TemplateCanvas, type TemplatePage, type TemplatePreview, type TemplateScope, type TemplateValue, type TextSlot, type TextSlotDef, type TextStructure, Tour, type TourCollectionValue, type TourSlot, type TourSlotDef, type TourValue, type UnitRow, type UrlSlot, type UrlSlotDef, type UseEditorResult, type ValueBinding, Video, type VideoCollectionValue, type VideoSlot, type VideoSlotDef, type VideoValue, type WebsiteFormat, type WebsitePage, a4Landscape, a4Portrait, bindItems, chooseFrom, compute, contactAssign, deck16x9, defineTemplate, deserializeIslandProps, document, documentAssign, facebookPost, fact, halfLetterFlyer, image, imageAssign, instagramPortrait, instagramSquare, instagramStory, islandId, letterLandscape, letterPortrait, linkedinPost, list, listFill, nameRows, number, poi, postcard6x4, postcard7x5, presets, rule, section, select, serializeIslandProps, set, text, textBlock, tour, tourAssign, url, useCaptureReady, useEditor, video, videoAssign, website, xPost };
|
|
54
|
+
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 AuthorImage, type BoundSlotValue, type BuiltDecision, CONCRETE_VERSION, type CanvasInput, type CanvasesInput, type ChosenRows, type CollectionRowValues, type ComparableRow, type ComputeBinding, type ContactRow, type Coordinates, type CropConfig, type DecisionKind, type DefineTemplateInput, type DerivedFactRef, type DirectFactRef, type DisplayChoice, type DisplayEntryInput, type DocumentCollectionValue, type DocumentFormat, type DocumentSlot, type DocumentSlotDef, type DocumentValue, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, type Edit, EditorBridge, EditorBridgeSelection, EditorSelection, type FactNamespace, type Facts, type FactsAddress, type FactsContact, type FactsDocument, type FactsDocumentNote, type FactsFloorPlan, type FactsNarrative, type FactsPhoto, type FactsTour, type FactsUnit, type FactsVideo, type FieldBinding, type FloorplanAssignment, type FormatIdentity, FrameShell, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, Image, type ImageCollectionValue, type ImageFormat, type ImageSlot, type ImageSlotDef, type ImageValue, IslandComponent, IslandEditor, IslandEditorOptions, IslandMarker, type IslandMarkerProps, IslandModule, IslandProps, IslandPropsError, IslandServerFrame, type ItemBinding, type ListFieldSlot, type ListItemSlot, type ListRecordSlotDef, type ListSlot, type ListSlotDef, type NamedRows, type Narrative, type NumberSlot, type NumberSlotDef, type OutputClass, type PageComponent, type PhysicalLength, type PicturePlan, type PictureSourceSpec, type PlaybackConfig, type PoiPhoto, type PoiRow, type PoiSlot, type PoiSlotDef, type ReconcileContext, type ReconcileRule, type ReconcileRuleOptions, type RenderedPage, type ResponsiveImage, type ResponsiveSource, type RowBinding, type RowOrigination, type RowValue, Section, type SectionContractProps, type SectionOptions, type SectionPlacementProps, type SectionRenderBindings, type SectionValue, type SelectSlot, type SelectSlotDef, type SetEdit, type SiteValues, type SiteViewOf, Slot, type SlotBinding, type SlotBindingMap, SlotGroup, type SlotRef, type SlotSource, type SlotValue, type TemplateCanvas, type TemplatePage, type TemplatePreview, type TemplateScope, type TemplateValue, type TextSlot, type TextSlotDef, type TextStructure, Tour, type TourCollectionValue, type TourSlot, type TourSlotDef, type TourValue, type UnitRow, type UrlSlot, type UrlSlotDef, type UseEditorResult, type ValueBinding, Video, type VideoCollectionValue, type VideoSlot, type VideoSlotDef, type VideoValue, type WebsiteFormat, type WebsitePage, a4Landscape, a4Portrait, bindItems, chooseFrom, compute, contactAssign, deck16x9, defineTemplate, deserializeIslandProps, document, documentAssign, facebookPost, fact, halfLetterFlyer, image, imageAssign, instagramPortrait, instagramSquare, instagramStory, islandId, letterLandscape, letterPortrait, linkedinPost, list, listFill, nameRows, number, poi, postcard6x4, postcard7x5, presets, rule, section, select, serializeIslandProps, set, text, textBlock, tour, tourAssign, url, useCaptureReady, useEditor, useIslandId, video, videoAssign, website, xPost };
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { version } from "./packages/external/concrete/package.js";
|
|
|
2
2
|
import { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, IslandPropsError, deserializeIslandProps, islandId, serializeIslandProps } from "./packages/internal/island-runtime/dist/contract.js";
|
|
3
3
|
import { useEditor } from "./packages/internal/island-runtime/dist/use-editor.js";
|
|
4
4
|
import { useCaptureReady } from "./packages/internal/island-runtime/dist/use-capture-ready.js";
|
|
5
|
+
import { useIslandId } from "./packages/internal/island-runtime/dist/use-island-id.js";
|
|
5
6
|
import { IslandMarker } from "./islands/marker.js";
|
|
6
7
|
import { bindItems } from "./primitives/slot-bindings.js";
|
|
7
8
|
import { compute } from "./schema/compute.js";
|
|
@@ -34,4 +35,4 @@ import { a4Landscape, a4Portrait, deck16x9, facebookPost, halfLetterFlyer, insta
|
|
|
34
35
|
const CONCRETE_VERSION = version;
|
|
35
36
|
|
|
36
37
|
//#endregion
|
|
37
|
-
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, CONCRETE_VERSION, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, FrameShell, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, Image, IslandMarker, IslandPropsError, Section, Slot, SlotGroup, Tour, Video, a4Landscape, a4Portrait, bindItems, chooseFrom, compute, contactAssign, deck16x9, defineTemplate, deserializeIslandProps, document, documentAssign, facebookPost, fact, halfLetterFlyer, image, imageAssign, instagramPortrait, instagramSquare, instagramStory, islandId, letterLandscape, letterPortrait, linkedinPost, list, listFill, nameRows, number, poi, postcard6x4, postcard7x5, presets, rule, section, select, serializeIslandProps, set, text, textBlock, tour, tourAssign, url, useCaptureReady, useEditor, video, videoAssign, website, xPost };
|
|
38
|
+
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, CONCRETE_VERSION, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, FrameShell, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, Image, IslandMarker, IslandPropsError, Section, Slot, SlotGroup, Tour, Video, a4Landscape, a4Portrait, bindItems, chooseFrom, compute, contactAssign, deck16x9, defineTemplate, deserializeIslandProps, document, documentAssign, facebookPost, fact, halfLetterFlyer, image, imageAssign, instagramPortrait, instagramSquare, instagramStory, islandId, letterLandscape, letterPortrait, linkedinPost, list, listFill, nameRows, number, poi, postcard6x4, postcard7x5, presets, rule, section, select, serializeIslandProps, set, text, textBlock, tour, tourAssign, url, useCaptureReady, useEditor, useIslandId, video, videoAssign, website, xPost };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { islandIdContext } from "../packages/internal/island-runtime/dist/island-id-context.js";
|
|
2
|
+
import { createContext } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/islands/island-id.ts
|
|
5
|
+
const IslandIdContext = islandIdContext({ createContext });
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { IslandIdContext };
|
package/dist/islands/marker.d.ts
CHANGED
|
@@ -29,10 +29,20 @@ interface IslandMarkerProps {
|
|
|
29
29
|
* from `useId`, which counts from the root of the tree being rendered. The server
|
|
30
30
|
* renders a whole section under an `identifierPrefix`; the client hydrates a subtree
|
|
31
31
|
* rooted at one marker, with no prefix. The two ids therefore diverge by construction
|
|
32
|
-
* and cannot be reconciled by passing a prefix. That divergence is inert
|
|
33
|
-
* the server's ids in the DOM, the marker and its payload come from
|
|
34
|
-
* in one render so they stay paired under either outcome, and a
|
|
35
|
-
* never read — `hydrateIslands` skips nested markers, leaving
|
|
32
|
+
* and cannot be reconciled by passing a prefix. That divergence is inert ON THESE TWO
|
|
33
|
+
* NODES: React leaves the server's ids in the DOM, the marker and its payload come from
|
|
34
|
+
* the same `islandId` in one render so they stay paired under either outcome, and a
|
|
35
|
+
* nested marker's id is never read — `hydrateIslands` skips nested markers, leaving
|
|
36
|
+
* them to their parent.
|
|
37
|
+
*
|
|
38
|
+
* It is NOT inert one node deeper, which is why this marker also opens the island-id
|
|
39
|
+
* context. An id the island component puts on its own markup carries no
|
|
40
|
+
* `suppressHydrationWarning` and would report the same divergence as a real mismatch,
|
|
41
|
+
* so an author composes one from `useIslandId()` instead of `useId` — and what that
|
|
42
|
+
* hook reads is the id provided here, or, once the browser has taken the island over,
|
|
43
|
+
* the identical string `hydrateIslands` read back off this marker's own attribute.
|
|
44
|
+
* Only the OUTERMOST marker provides: a nested one defers to the enclosing value,
|
|
45
|
+
* because its own id is exactly the one that diverges.
|
|
36
46
|
*
|
|
37
47
|
* No children means no server-rendered output, and the marker says so on itself with
|
|
38
48
|
* `data-tr-island-frameless` — the browser loader mounts such an island fresh rather
|
package/dist/islands/marker.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, ISLAND_ELEMENT, serializeIslandProps } from "../packages/internal/island-runtime/dist/contract.js";
|
|
2
|
-
import {
|
|
2
|
+
import { IslandIdContext } from "./island-id.js";
|
|
3
|
+
import { Fragment, createElement, useContext } from "react";
|
|
3
4
|
|
|
4
5
|
//#region src/islands/marker.tsx
|
|
5
6
|
/**
|
|
@@ -16,23 +17,34 @@ import { Fragment, createElement } from "react";
|
|
|
16
17
|
* from `useId`, which counts from the root of the tree being rendered. The server
|
|
17
18
|
* renders a whole section under an `identifierPrefix`; the client hydrates a subtree
|
|
18
19
|
* rooted at one marker, with no prefix. The two ids therefore diverge by construction
|
|
19
|
-
* and cannot be reconciled by passing a prefix. That divergence is inert
|
|
20
|
-
* the server's ids in the DOM, the marker and its payload come from
|
|
21
|
-
* in one render so they stay paired under either outcome, and a
|
|
22
|
-
* never read — `hydrateIslands` skips nested markers, leaving
|
|
20
|
+
* and cannot be reconciled by passing a prefix. That divergence is inert ON THESE TWO
|
|
21
|
+
* NODES: React leaves the server's ids in the DOM, the marker and its payload come from
|
|
22
|
+
* the same `islandId` in one render so they stay paired under either outcome, and a
|
|
23
|
+
* nested marker's id is never read — `hydrateIslands` skips nested markers, leaving
|
|
24
|
+
* them to their parent.
|
|
25
|
+
*
|
|
26
|
+
* It is NOT inert one node deeper, which is why this marker also opens the island-id
|
|
27
|
+
* context. An id the island component puts on its own markup carries no
|
|
28
|
+
* `suppressHydrationWarning` and would report the same divergence as a real mismatch,
|
|
29
|
+
* so an author composes one from `useIslandId()` instead of `useId` — and what that
|
|
30
|
+
* hook reads is the id provided here, or, once the browser has taken the island over,
|
|
31
|
+
* the identical string `hydrateIslands` read back off this marker's own attribute.
|
|
32
|
+
* Only the OUTERMOST marker provides: a nested one defers to the enclosing value,
|
|
33
|
+
* because its own id is exactly the one that diverges.
|
|
23
34
|
*
|
|
24
35
|
* No children means no server-rendered output, and the marker says so on itself with
|
|
25
36
|
* `data-tr-island-frameless` — the browser loader mounts such an island fresh rather
|
|
26
37
|
* than hydrating it against markup that was never emitted.
|
|
27
38
|
*/
|
|
28
39
|
function IslandMarker({ islandKey, islandId, props, children }) {
|
|
40
|
+
const enclosing = useContext(IslandIdContext);
|
|
29
41
|
return createElement(Fragment, null, createElement(ISLAND_ELEMENT, {
|
|
30
42
|
style: { display: "contents" },
|
|
31
43
|
[ATTR_ISLAND_KEY]: islandKey,
|
|
32
44
|
[ATTR_ISLAND_ID]: islandId,
|
|
33
45
|
[ATTR_ISLAND_FRAMELESS]: children == null ? "" : void 0,
|
|
34
46
|
suppressHydrationWarning: true
|
|
35
|
-
}, children), createElement("script", {
|
|
47
|
+
}, children == null ? children : createElement(IslandIdContext, { value: enclosing ?? islandId }, children)), createElement("script", {
|
|
36
48
|
type: "application/json",
|
|
37
49
|
[ATTR_ISLAND_PROPS]: islandId,
|
|
38
50
|
suppressHydrationWarning: true,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ATTR_ISLAND_FRAMELESS, ATTR_ISLAND_ID, ATTR_ISLAND_KEY, ATTR_ISLAND_PROPS, EDITOR_BRIDGE_PROP, EDITOR_BRIDGE_PROTOCOL, ISLAND_CAPTURE_HOLDS_GLOBAL, ISLAND_ELEMENT, IslandPropsError, deserializeIslandProps, islandId, serializeIslandProps } from "./contract.js";
|
|
2
2
|
import { editorInstanceContext } from "./editor-instance-context.js";
|
|
3
3
|
import { islandsCaptureReady, takeCaptureHold } from "./capture-holds.js";
|
|
4
|
+
import { islandIdContext } from "./island-id-context.js";
|
|
4
5
|
import { scheduleViewport } from "./viewport-schedule.js";
|
|
5
6
|
|
|
6
7
|
//#region ../../internal/island-runtime/dist/index.js
|
|
@@ -51,6 +52,7 @@ async function hydrateIslands(options) {
|
|
|
51
52
|
const [react, { createRoot, hydrateRoot }] = await Promise.all([import("react"), import("react-dom/client")]);
|
|
52
53
|
const { createElement } = react;
|
|
53
54
|
const InstanceContext = editorInstanceContext(react);
|
|
55
|
+
const IslandIdContext = islandIdContext(react);
|
|
54
56
|
const MountSignal = ({ onMounted, children }) => {
|
|
55
57
|
const [pass, setPass] = react.useState(0);
|
|
56
58
|
react.useEffect(() => {
|
|
@@ -102,10 +104,10 @@ async function hydrateIslands(options) {
|
|
|
102
104
|
return null;
|
|
103
105
|
}
|
|
104
106
|
const instanceId = element.closest(`[${"data-section-instance-id"}]`)?.getAttribute("data-section-instance-id") ?? null;
|
|
105
|
-
const tree = createElement(InstanceContext, { value: instanceId }, createElement(MountSignal, {
|
|
107
|
+
const tree = createElement(InstanceContext, { value: instanceId }, createElement(IslandIdContext, { value: id }, createElement(MountSignal, {
|
|
106
108
|
onMounted: signalMounted,
|
|
107
109
|
children: createElement(module.default, props)
|
|
108
|
-
}));
|
|
110
|
+
})));
|
|
109
111
|
const rootOptions = {
|
|
110
112
|
onUncaughtError: (renderError) => {
|
|
111
113
|
options.onError?.(renderError, ctx);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region ../../internal/island-runtime/dist/island-id-context.js
|
|
2
|
+
const CONTEXT_KEY = Symbol.for("homepages.tr-island-id");
|
|
3
|
+
/** The one shared island-id context, created by whichever copy asks first. */
|
|
4
|
+
function islandIdContext(react) {
|
|
5
|
+
const registry = globalThis;
|
|
6
|
+
let context = registry[CONTEXT_KEY];
|
|
7
|
+
if (!context) {
|
|
8
|
+
context = react.createContext(null);
|
|
9
|
+
registry[CONTEXT_KEY] = context;
|
|
10
|
+
}
|
|
11
|
+
return context;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { islandIdContext };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region ../../internal/island-runtime/dist/use-island-id.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The enclosing island's id: one string, identical in the server's render and in the
|
|
4
|
+
* client's hydration of the same island, and unique among the islands of a document.
|
|
5
|
+
* Compose an id from it rather than calling React's `useId`, which mints a different
|
|
6
|
+
* value in each of those two renders and hydrates into an attribute mismatch on
|
|
7
|
+
* whatever markup carries it (see {@link islandIdContext}):
|
|
8
|
+
*
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const bodyId = `${useIslandId()}-body`;
|
|
11
|
+
* <button aria-controls={bodyId} /><div id={bodyId} />
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* It is one value per island, not per call — the discriminator after it is the
|
|
15
|
+
* author's, and two call sites in one island that compose the same suffix collide
|
|
16
|
+
* deterministically, in both renders, where a test or a browser will say so.
|
|
17
|
+
*
|
|
18
|
+
* Outside an island it is {@link NO_ISLAND_ID}. Only a client module may call it
|
|
19
|
+
* (`concrete/islands/island-ids`); a section renders once and hydrates never, so it
|
|
20
|
+
* has no id to hand out and gives one to the island as a prop instead.
|
|
21
|
+
*/
|
|
22
|
+
declare function useIslandId(): string;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { useIslandId };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { islandIdContext } from "./island-id-context.js";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
|
|
4
|
+
//#region ../../internal/island-runtime/dist/use-island-id.js
|
|
5
|
+
const IslandIdContext = islandIdContext({ createContext });
|
|
6
|
+
/**
|
|
7
|
+
* What the hook returns where nothing opened the channel. The tooling venues that
|
|
8
|
+
* render a section's module graph directly — `concrete check`'s group and placement
|
|
9
|
+
* probes, its per-fixture render stage — reach an island as a plain component, with
|
|
10
|
+
* no marker around it, and each reads the markup for its slot markers and discards
|
|
11
|
+
* it. None of them hydrates, so no id in them is ever compared with anything.
|
|
12
|
+
*
|
|
13
|
+
* A fixed value rather than a throw, because those venues are normal and there is no
|
|
14
|
+
* end of them; what a throw was really guarding — a SECTION minting an island id, and
|
|
15
|
+
* so the same constant for every instance of itself on a page — is a question about
|
|
16
|
+
* source, which `concrete/islands/island-ids` answers before any of this runs.
|
|
17
|
+
*/
|
|
18
|
+
const NO_ISLAND_ID = "tr-no-island";
|
|
19
|
+
/**
|
|
20
|
+
* The enclosing island's id: one string, identical in the server's render and in the
|
|
21
|
+
* client's hydration of the same island, and unique among the islands of a document.
|
|
22
|
+
* Compose an id from it rather than calling React's `useId`, which mints a different
|
|
23
|
+
* value in each of those two renders and hydrates into an attribute mismatch on
|
|
24
|
+
* whatever markup carries it (see {@link islandIdContext}):
|
|
25
|
+
*
|
|
26
|
+
* ```tsx
|
|
27
|
+
* const bodyId = `${useIslandId()}-body`;
|
|
28
|
+
* <button aria-controls={bodyId} /><div id={bodyId} />
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* It is one value per island, not per call — the discriminator after it is the
|
|
32
|
+
* author's, and two call sites in one island that compose the same suffix collide
|
|
33
|
+
* deterministically, in both renders, where a test or a browser will say so.
|
|
34
|
+
*
|
|
35
|
+
* Outside an island it is {@link NO_ISLAND_ID}. Only a client module may call it
|
|
36
|
+
* (`concrete/islands/island-ids`); a section renders once and hydrates never, so it
|
|
37
|
+
* has no id to hand out and gives one to the island as a prop instead.
|
|
38
|
+
*/
|
|
39
|
+
function useIslandId() {
|
|
40
|
+
return useContext(IslandIdContext) ?? "tr-no-island";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { NO_ISLAND_ID, useIslandId };
|
|
@@ -741,7 +741,7 @@ declare const FACT_GRAPH: {
|
|
|
741
741
|
readonly path: "narrative";
|
|
742
742
|
readonly value_type: "object";
|
|
743
743
|
readonly input_group: "describe";
|
|
744
|
-
readonly strength: "
|
|
744
|
+
readonly strength: "optional";
|
|
745
745
|
readonly fields: {
|
|
746
746
|
/** The description itself. */
|
|
747
747
|
readonly description: {
|
|
@@ -677,7 +677,7 @@ const FACT_GRAPH = {
|
|
|
677
677
|
path: "narrative",
|
|
678
678
|
value_type: "object",
|
|
679
679
|
input_group: "describe",
|
|
680
|
-
strength: "
|
|
680
|
+
strength: "optional",
|
|
681
681
|
fields: {
|
|
682
682
|
/** The description itself. */
|
|
683
683
|
description: { value_type: "text" } }
|
|
@@ -1104,6 +1104,48 @@ function acceptsLink(accepts, url) {
|
|
|
1104
1104
|
* obtained, an orthogonal concern.
|
|
1105
1105
|
*/
|
|
1106
1106
|
const VIDEO_SOURCES = ["upload", "link"];
|
|
1107
|
+
const VIMEO_PARAMS = "badge=0&autopause=0&player_id=0&title=0&byline=0&portrait=0&sidedock=0&vimeo_logo=0&pip=0&chromecast=0&quality_selector=0&progress_bar=1";
|
|
1108
|
+
/**
|
|
1109
|
+
* The embeddable player URL for a pasted video link, or `null` when the value is
|
|
1110
|
+
* empty, names no provider, or names one that is not embeddable video.
|
|
1111
|
+
*
|
|
1112
|
+
* Only YouTube and Vimeo embed; every other provider returns `null`.
|
|
1113
|
+
*/
|
|
1114
|
+
function videoEmbedUrl(raw) {
|
|
1115
|
+
const url = raw.trim();
|
|
1116
|
+
if (!url) return null;
|
|
1117
|
+
const provider = matchLinkProvider(url);
|
|
1118
|
+
if (provider === "vimeo") {
|
|
1119
|
+
const vimeo = url.match(/vimeo\.com\/(?:.*\/)?(\d+)/);
|
|
1120
|
+
return vimeo ? `https://player.vimeo.com/video/${vimeo[1]}?${VIMEO_PARAMS}` : null;
|
|
1121
|
+
}
|
|
1122
|
+
if (provider === "youtube") {
|
|
1123
|
+
const yt = url.match(/youtu\.be\/([A-Za-z0-9_-]{11})/) ?? url.match(/[?&]v=([A-Za-z0-9_-]{11})/) ?? url.match(/youtube\.com\/(?:embed|shorts)\/([A-Za-z0-9_-]{11})/);
|
|
1124
|
+
return yt ? `https://www.youtube.com/embed/${yt[1]}?rel=0` : null;
|
|
1125
|
+
}
|
|
1126
|
+
return null;
|
|
1127
|
+
}
|
|
1128
|
+
/**
|
|
1129
|
+
* The embeddable player URL for a pasted 3D-tour link, or `null` when the value
|
|
1130
|
+
* is empty, names no provider, names one that is not a tour provider, or is a
|
|
1131
|
+
* tour URL the provider's embed form cannot be built from.
|
|
1132
|
+
*
|
|
1133
|
+
* @remarks
|
|
1134
|
+
* Covers every `kind: "tour"` member of `LINK_PROVIDERS`. A tour provider added
|
|
1135
|
+
* to that catalog without a branch here returns `null` — an unembeddable slot
|
|
1136
|
+
* rather than a wrong iframe — and `slot-catalog.test.ts` fails on the gap.
|
|
1137
|
+
*/
|
|
1138
|
+
function tourEmbedUrl(raw) {
|
|
1139
|
+
const url = raw.trim();
|
|
1140
|
+
if (!url) return null;
|
|
1141
|
+
const provider = matchLinkProvider(url);
|
|
1142
|
+
if (provider === "matterport") {
|
|
1143
|
+
const sid = new URL(url).searchParams.get("m");
|
|
1144
|
+
return sid !== null && /^[A-Za-z0-9]+$/.test(sid) ? `https://my.matterport.com/show/?m=${sid}&nt=1` : null;
|
|
1145
|
+
}
|
|
1146
|
+
if (provider === "biganto") return url;
|
|
1147
|
+
return null;
|
|
1148
|
+
}
|
|
1107
1149
|
|
|
1108
1150
|
//#endregion
|
|
1109
|
-
export { COLLECTIONS, COLLECTION_SLOT_TYPES, CONTENT_SLOT_TYPES, DISPLAY_ENTRIES, FACT_GRAPH, FACT_PROJECTIONS, INPUT_GROUPS, INPUT_GROUP_REQUIREMENT, LINK_KINDS, LINK_PROVIDERS, OPTION_SOURCES, REFERRAL_FIELDS, REFERRAL_IMAGE_FIELDS, REF_SLOT_TYPES, SLOT_TYPES, SOURCE_FIELDS, SOURCE_FILTERS, VIDEO_SOURCES, VISIBILITY_CASES, acceptsLink, collectionBounds, collectionForSlot, isCollectionSlotType, isLinkAccepts, isOptionSource, isSourceFilter, isWritableSourceField, matchLinkProvider, stampCollectionBounds };
|
|
1151
|
+
export { COLLECTIONS, COLLECTION_SLOT_TYPES, CONTENT_SLOT_TYPES, DISPLAY_ENTRIES, FACT_GRAPH, FACT_PROJECTIONS, INPUT_GROUPS, INPUT_GROUP_REQUIREMENT, LINK_KINDS, LINK_PROVIDERS, OPTION_SOURCES, REFERRAL_FIELDS, REFERRAL_IMAGE_FIELDS, REF_SLOT_TYPES, SLOT_TYPES, SOURCE_FIELDS, SOURCE_FILTERS, VIDEO_SOURCES, VISIBILITY_CASES, acceptsLink, collectionBounds, collectionForSlot, isCollectionSlotType, isLinkAccepts, isOptionSource, isSourceFilter, isWritableSourceField, matchLinkProvider, stampCollectionBounds, tourEmbedUrl, videoEmbedUrl };
|
|
@@ -5,18 +5,17 @@ import { RowValue, SlotValue } from "../schema/section-props.js";
|
|
|
5
5
|
//#region src/primitives/slot-bindings.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* The value shape a binding holds after bind-time normalization: `SlotValue`
|
|
8
|
-
* for every kind except a RECORD list, whose bound rows
|
|
9
|
-
*
|
|
10
|
-
* editor-stamped `id` plus each DECLARED field and drops everything else, so a
|
|
11
|
-
* whole-row-baked slot's projection-only fields (which `SlotValue` types on
|
|
12
|
-
* the raw slot value) never survive into a binding.
|
|
8
|
+
* for every kind except a RECORD list, whose bound rows carry the
|
|
9
|
+
* editor-stamped `id` plus each DECLARED field, normalized by its definition.
|
|
13
10
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
11
|
+
* A stored record list's row (`RowValue`) is closed: anything else on it is
|
|
12
|
+
* dropped. A record list bound whole-row to a collection
|
|
13
|
+
* (`source: fact.property.comparables`) is the other case, because a section's
|
|
14
|
+
* render receives bindings and nothing else: its bound row
|
|
15
|
+
* ({@link BoundBakedRow}) also keeps every member the platform bakes onto the
|
|
16
|
+
* row, so markup reads a comparable's `status` or `lat` off
|
|
17
|
+
* `slot.comps.value[n]` (or `bindItems(slot.comps)[n].value`) without
|
|
18
|
+
* declaring it as a row field.
|
|
20
19
|
*/
|
|
21
20
|
type BoundSlotValue<D> = D extends {
|
|
22
21
|
type: "list";
|
|
@@ -32,8 +31,15 @@ type BoundSlotValue<D> = D extends {
|
|
|
32
31
|
type ProjectedImageListKeys<F extends CollectionField, I> = { [K in keyof I & keyof CollectionRowValues[F]]: I[K] extends {
|
|
33
32
|
type: "image";
|
|
34
33
|
} ? CollectionRowValues[F][K] extends readonly unknown[] ? K : never : never; }[keyof I & keyof CollectionRowValues[F]];
|
|
35
|
-
/**
|
|
36
|
-
|
|
34
|
+
/**
|
|
35
|
+
* One bound row of a whole-row-baked record list: every member of the collection's
|
|
36
|
+
* projected row, with each DECLARED field at its normalized kind — except a declared
|
|
37
|
+
* `image` field the projection carries as a list (a unit's `floor_plans`, its ordered
|
|
38
|
+
* floor-plan assignments), which keeps the projection's list. That field's own
|
|
39
|
+
* `FieldBinding` still holds the `image` kind's value, so the primitives read it
|
|
40
|
+
* exactly as before.
|
|
41
|
+
*/
|
|
42
|
+
type BoundBakedRow<F extends CollectionField, I> = Omit<CollectionRowValues[F], keyof I | "id"> & Omit<RowValue<I>, ProjectedImageListKeys<F, I>> & { [K in ProjectedImageListKeys<F, I>]: CollectionRowValues[F][K]; };
|
|
37
43
|
/**
|
|
38
44
|
* One slot: its id, the definition the section declared for it, and its runtime value.
|
|
39
45
|
*
|
|
@@ -70,9 +70,12 @@ function normalizeTour(value) {
|
|
|
70
70
|
alt: stringField(value.alt)
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
function normalizeRow(fields, row) {
|
|
73
|
+
function normalizeRow(fields, row, baked) {
|
|
74
74
|
const source = isRecord(row) ? row : {};
|
|
75
|
-
const normalized = {
|
|
75
|
+
const normalized = {
|
|
76
|
+
...baked ? source : {},
|
|
77
|
+
id: stringField(source.id)
|
|
78
|
+
};
|
|
76
79
|
for (const [field, def] of Object.entries(fields)) {
|
|
77
80
|
const value = source[field];
|
|
78
81
|
normalized[field] = def.type === "image" && Array.isArray(value) ? value.filter(isRecord) : normalizeValue(def, value);
|
|
@@ -95,7 +98,8 @@ function normalizeValue(def, value) {
|
|
|
95
98
|
if (!Array.isArray(value)) return [];
|
|
96
99
|
if (isRecord(slot.fields)) {
|
|
97
100
|
const fields = slot.fields;
|
|
98
|
-
|
|
101
|
+
const baked = isRecord(slot.source) && slot.source.kind === "direct";
|
|
102
|
+
return value.map((row) => normalizeRow(fields, row, baked));
|
|
99
103
|
}
|
|
100
104
|
if (slot.element == null) return value;
|
|
101
105
|
const element = slot.element;
|
package/dist/rules/registry.js
CHANGED
|
@@ -197,6 +197,13 @@ const AUTHORED_RULES = [
|
|
|
197
197
|
engineId: "concrete/islands/no-editor-globals",
|
|
198
198
|
summary: "No code reads the editor canvas's internal `__tr` globals."
|
|
199
199
|
},
|
|
200
|
+
{
|
|
201
|
+
id: "islands/island-ids",
|
|
202
|
+
venue: "eslint",
|
|
203
|
+
stage: "lint",
|
|
204
|
+
engineId: "concrete/islands/island-ids",
|
|
205
|
+
summary: "An island composes its own ids from `useIslandId()`, never React's `useId`, and only an island calls it."
|
|
206
|
+
},
|
|
200
207
|
{
|
|
201
208
|
id: "slots/no-marker-literal",
|
|
202
209
|
venue: "eslint",
|
|
@@ -262,6 +269,12 @@ const AUTHORED_RULES = [
|
|
|
262
269
|
stage: "fixtures",
|
|
263
270
|
summary: "A content entry references a media entry its property does not carry."
|
|
264
271
|
},
|
|
272
|
+
{
|
|
273
|
+
id: "fixtures/rows-not-in-property",
|
|
274
|
+
venue: "tree",
|
|
275
|
+
stage: "fixtures",
|
|
276
|
+
summary: "A content entry states more rows for a collection-bound list than its property carries."
|
|
277
|
+
},
|
|
265
278
|
{
|
|
266
279
|
id: "fixtures/instance-not-placed",
|
|
267
280
|
venue: "tree",
|
|
@@ -441,6 +454,12 @@ const AUTHORED_RULES = [
|
|
|
441
454
|
venue: "tree",
|
|
442
455
|
stage: "stylesheet",
|
|
443
456
|
summary: "A stylesheet reachable from template.ts fails to resolve or compile, so no stylesheet rule could grade it."
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
id: "css/retired-layer",
|
|
460
|
+
venue: "tree",
|
|
461
|
+
stage: "stylesheet",
|
|
462
|
+
summary: "A stylesheet declares `@layer sections` or `@layer template`, the layers the framework retired; author CSS is unlayered."
|
|
444
463
|
}
|
|
445
464
|
];
|
|
446
465
|
/** The id a contract assertion is reported under. */
|
|
@@ -16,7 +16,12 @@ interface SectionPlacementProps {
|
|
|
16
16
|
}
|
|
17
17
|
/** What the render function receives: bindings, not raw values. */
|
|
18
18
|
interface SectionRenderBindings<Slots extends Record<string, Slot>, Display extends DisplayInput> {
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* One binding per declared slot, keyed by slot id — what `bindSlots` returned to a Renderer.
|
|
21
|
+
* There is no raw `slots` beside it: a record list bound whole-row to a collection keeps
|
|
22
|
+
* every member the platform bakes onto its rows on the bound row itself
|
|
23
|
+
* (`slot.comps.value[n].status`), declared as a row field or not.
|
|
24
|
+
*/
|
|
20
25
|
readonly slot: SlotBindingMap<SectionSchemaOf<Slots, Display>>;
|
|
21
26
|
/** The build-injected navigation input: this section's anchor, the anchor map, the pages. */
|
|
22
27
|
readonly nav: SectionNav;
|