@vectoriox/iox-ui 5.157.0 → 5.159.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.
Files changed (30) hide show
  1. package/design-core/index.d.ts +18 -2
  2. package/fesm2022/vectoriox-iox-ui-design-core.mjs +41 -1
  3. package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
  4. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +3292 -2477
  5. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  6. package/fesm2022/vectoriox-iox-ui.mjs +5 -33
  7. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  8. package/generation-core/index.d.ts +616 -414
  9. package/package.json +1 -1
  10. package/src/design-core/css-functions.ts +48 -0
  11. package/src/design-core/public-api.ts +1 -0
  12. package/src/generation-core/check-free.ts +31 -5
  13. package/src/generation-core/check-layout.ts +123 -14
  14. package/src/generation-core/compose-free.ts +205 -0
  15. package/src/generation-core/compose-layout.ts +3 -1
  16. package/src/generation-core/compose-site.ts +74 -9
  17. package/src/generation-core/free-fallback.ts +11 -3
  18. package/src/generation-core/free-slots.ts +125 -0
  19. package/src/generation-core/free-wire.ts +5 -0
  20. package/src/generation-core/layout-fingerprint.ts +28 -3
  21. package/src/generation-core/layout-language.ts +11 -2
  22. package/src/generation-core/layout-section-fallback.ts +38 -1
  23. package/src/generation-core/opening-edit.ts +2 -0
  24. package/src/generation-core/opening-mix.ts +39 -8
  25. package/src/generation-core/plan-wire.ts +5 -0
  26. package/src/generation-core/public-api.ts +2 -0
  27. package/src/generation-core/site-plan.model.ts +12 -0
  28. package/src/generation-core/site-spec.generated.ts +58 -7
  29. package/src/generation-core/type-led.ts +31 -9
  30. package/src/generation-core/validate-site-plan.ts +124 -0
@@ -63,6 +63,8 @@ export * from './layout-section-fallback';
63
63
  export * from './free-wire';
64
64
  export * from './check-free';
65
65
  export * from './free-fallback';
66
+ export * from './free-slots';
67
+ export * from './compose-free';
66
68
  export * from './prompt-limits';
67
69
  export * from './layout-photos';
68
70
  export * from './photo-inventory';
@@ -2,6 +2,7 @@ import type { FrameSequence } from '@vectoriox/iox-ui/media-core';
2
2
  import type { AnimateId, DesignChoices } from '@vectoriox/iox-ui/design-core';
3
3
  import { LocaleDirection, localeDirection } from '@vectoriox/iox-ui/design-core';
4
4
  import type { ArtDirection } from './art-direction';
5
+ import type { FreeNode, FreePage } from './free-wire';
5
6
  import type { LayoutPage } from './layout-language';
6
7
 
7
8
  import { SPEC_SITE_ARCHETYPES, SPEC_SITE_FACTS, SPEC_SITE_LOCALES, SPEC_SITE_NEED_IDS, SPEC_SITE_REQUIRED_ROLES, SPEC_SITE_ROLES } from './site-spec.generated';
@@ -241,6 +242,11 @@ export interface PageSectionPlan {
241
242
  readonly form?: string;
242
243
  /** How this section moves in, instead of the look's How animated (M1-6b; M2's "make the hero calmer"). */
243
244
  readonly enter?: AnimateId;
245
+ /**
246
+ * FS3 (award plan §11, FS-D19): ONE signature section the model wrote free — ordinary nodes, the look's tokens — stamped
247
+ * in this section's place (`composeFreeSection`); `pattern` stays its fall back. Set by the server, never by a model.
248
+ */
249
+ readonly free?: FreeNode;
244
250
  }
245
251
 
246
252
  /** A page's search-result words, when the plan writes them (each within the seo-core limits). */
@@ -291,6 +297,12 @@ export interface PagePlan {
291
297
  readonly compose?: boolean;
292
298
  /** M8 gate 2: the composed page — when present it is stamped (`composeLayout`) instead of `sections`. */
293
299
  readonly layout?: LayoutPage;
300
+ /**
301
+ * FS3 (award plan §11, FS-D19): the page the model wrote free — when present it is stamped (`composeFreePage`) instead of
302
+ * `sections`, a place the fall back gave away standing as its ready-made section (`readyMade.at` names `sections`).
303
+ * Set by the server, never by a model; never beside `layout`.
304
+ */
305
+ readonly free?: FreePage;
294
306
  }
295
307
 
296
308
  /**
@@ -168,7 +168,38 @@ export const SPEC_SITE_PLAN_SHAPE = {
168
168
  "seo?": "pageSeo",
169
169
  "sections": "section[] — the page from patterns; a composed page keeps them as its fallback",
170
170
  "compose?": "boolean — the page is composed in the layout language (M8 gate 2): which pages is the generation’s tier (AW-D23/24) — Basic the home page and at most one other, Award every page that is no per-item or legal page; written with the pages, the layout step fills `layout`",
171
- "layout?": "layoutPage — the composed page (the layout step's, never the Pages request's): when present the page is stamped from it and `sections` is not"
171
+ "layout?": "layoutPage — the composed page (the layout step's, never the Pages request's): when present the page is stamped from it and `sections` is not",
172
+ "free?": "freePage — FS3 (award plan §11, FS-D19): the page the model wrote free (the free step's, set by the server, never a model's): when present the page is stamped from it (generation-core composeFreePage) and `sections` is not, but a place the fall back gave away stands as its ready-made section (readyMade.at names `sections`); never beside `layout`"
173
+ },
174
+ "freePage": {
175
+ "read": "freeRead — what the answer says about itself",
176
+ "pictures": "string — generation-core FreePictures: how the page treats its pictures (information, never a gate)",
177
+ "sections": "freeNode[] — the page: Sections only at the top (4–9, FREE_SECTIONS)",
178
+ "givenAway?": "integer — the model's sections the fall back dropped (the page's minimum forgives them, iox-ui#134). Set by the fall back, never by a model"
179
+ },
180
+ "freeRead": {
181
+ "idea": "string — one sentence: the page's idea",
182
+ "why": "string — one sentence: why it suits this business",
183
+ "followed": "string — which of the owner's words the page followed, quoting them as written (R-H17)"
184
+ },
185
+ "freeNode": {
186
+ "id": "string — unique on the page (a #id link scrolls to it)",
187
+ "type": "string — generation-core FreeNodeType: Section · Container · Heading · Text · Button · Image · Video · Slot (stamped as FREE_BUILDER_TYPE)",
188
+ "purpose?": "string — a Section: generation-core FreePurpose (what it is for; the fall back reads it)",
189
+ "elementStyle?": "string — one of the look's element styles the type wears (FREE_ELEMENT_STYLES)",
190
+ "level?": "integer — a Heading: 1–4",
191
+ "role?": "'lead' — the heading a visitor reads first",
192
+ "text?": "string — a Heading, Text or Button: its words, in the site's language",
193
+ "src?": "string — an Image or Video: a material id (the owner's photo or video)",
194
+ "href?": "string — a Button: a page route of the plan, or #<id> of a section of this page",
195
+ "slot?": "string — a Slot: what stands there — list:<a query source alias> (composeList) or form:<a forms-core preset> (the preset's form)",
196
+ "opts?": "string[] — a Slot's options: a list's mix words <ingredient>:<word> (site.layout.list)",
197
+ "styleProps": "{ [style trait]: string } — the node's styles (generation-core FREE_STYLE_PROPS + FREE_TOKEN_PROPS; a value the look owns is its token)",
198
+ "responsive?": "{ mobile?, tablet? } — the styles a width overrides (a phone layer: `mobile` reaches `small`)",
199
+ "hover?": "{ [style trait]: string } — a hover: transform, opacity or a colour token only (FREE_HOVER_PROPS)",
200
+ "move?": "{ trigger, action, params? } — ONE move: generation-core FREE_MOVES (viewportEnter · scrollProgress)",
201
+ "children?": "freeNode[] — a Section or Container only",
202
+ "readyMade?": "{ at, pattern } — set by the fall back: the plan section `sections[at]` (its pattern) stands here instead"
172
203
  },
173
204
  "pageSeo": {
174
205
  "title?": "string ≤ 60 — the page title in search results (absent = the page name · the business)",
@@ -181,7 +212,8 @@ export const SPEC_SITE_PLAN_SHAPE = {
181
212
  "binding?": "string — the list source a pattern's $binding repeater iterates (exactly when it has one); a $binding? pattern (faq.accordion) MAY take one — then its items come from that content",
182
213
  "without?": "string[] — the pattern's optional parts to leave out",
183
214
  "form?": "string — a forms-core preset for the pattern's form (contact · newsletter · application · booking)",
184
- "enter?": "string — axes.animations: how this section moves in, instead of the look's (M2: 'make the hero calmer')"
215
+ "enter?": "string — axes.animations: how this section moves in, instead of the look's (M2: 'make the hero calmer')",
216
+ "free?": "freeNode — FS3 (award plan §11, FS-D19): ONE signature Section the model wrote free (set by the server, never a model's), stamped in this section's place (generation-core composeFreeSection); `pattern` stays its fall back. Never on a section with a binding or a form, never on a per-item page"
185
217
  },
186
218
  "globals": {
187
219
  "header": "string — a header pattern (global: before)",
@@ -9003,11 +9035,16 @@ export const SPEC_SITE_LAYOUT = {
9003
9035
  "slow-zoom",
9004
9036
  "copy-out",
9005
9037
  "pinned-covered"
9038
+ ],
9039
+ "ground": [
9040
+ "accent",
9041
+ "subtle"
9006
9042
  ]
9007
9043
  },
9008
9044
  "many": [
9009
9045
  "extras",
9010
- "motion"
9046
+ "motion",
9047
+ "ground"
9011
9048
  ],
9012
9049
  "meanings": {
9013
9050
  "frame.full": "edge to edge",
@@ -9033,7 +9070,9 @@ export const SPEC_SITE_LAYOUT = {
9033
9070
  "extras.cue": "a quiet scroll cue",
9034
9071
  "motion.slow-zoom": "the picture slowly zooms (15 s or longer), still under reduced motion",
9035
9072
  "motion.copy-out": "the first screen's words fade as the page leaves it, following the scroll",
9036
- "motion.pinned-covered": "the first screen holds while the next section slides over it"
9073
+ "motion.pinned-covered": "the first screen holds while the next section slides over it",
9074
+ "ground.accent": "a type-led first screen on the look's accent",
9075
+ "ground.subtle": "a type-led first screen on the look's quiet tint"
9037
9076
  },
9038
9077
  "meaningsHe": {
9039
9078
  "frame.full": "מקצה לקצה",
@@ -9059,7 +9098,9 @@ export const SPEC_SITE_LAYOUT = {
9059
9098
  "extras.cue": "סימן גלילה שקט",
9060
9099
  "motion.slow-zoom": "התמונה מתקרבת לאט (15 שניות ויותר), ונשארת דוממת כשמבקשים פחות תנועה",
9061
9100
  "motion.copy-out": "המילים של המסך הראשון נמוגות כשהדף עוזב אותו, עם הגלילה",
9062
- "motion.pinned-covered": "המסך הראשון נשאר במקומו והחלק הבא מחליק מעליו"
9101
+ "motion.pinned-covered": "המסך הראשון נשאר במקומו והחלק הבא מחליק מעליו",
9102
+ "ground.accent": "מסך ראשון של מילים, על צבע ההדגשה של המראה",
9103
+ "ground.subtle": "מסך ראשון של מילים, על הגוון השקט של המראה"
9063
9104
  },
9064
9105
  "waits": {
9065
9106
  "frame.grows": {
@@ -9080,10 +9121,13 @@ export const SPEC_SITE_LAYOUT = {
9080
9121
  "media": "photo",
9081
9122
  "words": "headline",
9082
9123
  "extras": [],
9083
- "motion": []
9124
+ "motion": [],
9125
+ "ground": []
9084
9126
  },
9085
9127
  "harness": [
9086
- "media.none"
9128
+ "media.none",
9129
+ "ground.accent",
9130
+ "ground.subtle"
9087
9131
  ],
9088
9132
  "typeLed": [
9089
9133
  {
@@ -9124,6 +9168,11 @@ export const SPEC_SITE_LAYOUT = {
9124
9168
  }
9125
9169
  ],
9126
9170
  "typeLedEveryTier": true,
9171
+ "typeLedGrounds": [
9172
+ "inverse",
9173
+ "subtle",
9174
+ "accent"
9175
+ ],
9127
9176
  "named": {
9128
9177
  "hero.split": {},
9129
9178
  "hero.full-bleed-media": {
@@ -9261,6 +9310,8 @@ export const SPEC_SITE_LAYOUT = {
9261
9310
  "media.object": "all",
9262
9311
  "media.none": "all",
9263
9312
  "words.headline": "all",
9313
+ "ground.accent": "all",
9314
+ "ground.subtle": "all",
9264
9315
  "rules.wordsNeverCut": "all",
9265
9316
  "rules.badgeOwnersOnly": "all",
9266
9317
  "rules.neverHoldsScroll": "all",
@@ -3,8 +3,8 @@ import { FingerprintedPage, wornOpenings } from './layout-fingerprint';
3
3
  import { LayoutIssue, LayoutIssueCode, LayoutLayerKind, LayoutPage, LayoutSection } from './layout-language';
4
4
  import { fallBackBySection, SectionFallbackLastResort, SectionSwapAction } from './layout-section-fallback';
5
5
  import {
6
- checkOpening, drawnOpeningMix, OPENING_MIX_PROP, OpeningMedia, OpeningMix, OpeningMotion, openingMixOfPlan, openingMixWords, openingTokenOf, typeLedOpeningSection,
7
- typeLedOpeningWays,
6
+ checkOpening, drawnOpeningMix, OPENING_MIX_PROP, OpeningGround, OpeningMedia, OpeningMix, openingMixOfPlan, openingMixWords, OpeningMotion,
7
+ openingTokenOf, openingTokenParts, typeLedGrounds, typeLedOpeningSection, typeLedOpeningWays,
8
8
  } from './opening-mix';
9
9
  import type { GenerationTier } from './site-plan.model';
10
10
  import { patternById, patternLinkSlots, patternOptionalParts, patternSlots, slotBudget } from './patterns';
@@ -107,8 +107,10 @@ export interface TypeLedChange {
107
107
  export interface TypeLedOpening {
108
108
  /** The mix's words, as `plan.mixes.opening` holds them. */
109
109
  words: string[];
110
- /** `opening:<frame>/none/<words>` — what the memory records and compares (`openingTokenOf`). */
110
+ /** `opening:<frame>/none/<words>[+<ground>]` — what the memory records and compares (`openingTokenOf`). */
111
111
  token: string;
112
+ /** iox-ui#131: what the first screen stands on (`inverse` when the token names none). */
113
+ ground: `${OpeningGround}`;
112
114
  /** Set when every way the site can carry is already another site's: it opens on the first of them anyway. */
113
115
  worn?: true;
114
116
  }
@@ -291,18 +293,38 @@ const isHome = (page: PagePlan) => page.isHome === true || page.route === '/';
291
293
  * (`typeLedOpeningWays`), the first the site carries unmended (its tier, the business name's fit) that no OTHER site of
292
294
  * the studio opens on — else the first it carries, said as worn. Pure.
293
295
  */
294
- export function chooseTypeLedOpening(plan: SitePlan, context: TypeLedRoundContext = {}): { mix: OpeningMix; token: string; worn: boolean } {
296
+ export function chooseTypeLedOpening(plan: SitePlan, context: TypeLedRoundContext = {}): { mix: OpeningMix; token: string; worn: boolean; ground: OpeningGround } {
295
297
  const own = openingMixOfPlan(plan);
296
298
  // The plan's own frame and words, on no picture (a slow zoom has nothing to move: it goes with the picture).
297
299
  const mine = own ? [{ ...own, media: OpeningMedia.None, extras: [...own.extras], motion: own.motion.filter(m => m !== OpeningMotion.SlowZoom) }] : [];
298
300
  const ways = [...mine, ...typeLedOpeningWays()];
299
301
  const site = openingContextOf({ business: plan.business, design: plan.design, tier: context.tier ?? BASIC, badge: null, cutOut: false });
300
302
  const carried = ways.map(m => drawnOpeningMix(m).drawn).filter(m => !checkOpening(m, site).repairs.length);
301
- const worn = wornOpenings(context.studio ?? []);
302
- const free = carried.find(m => !worn.has(openingTokenOf(m)));
303
+ const worn = [...wornOpenings(context.studio ?? [])].map(openingTokenParts);
304
+ const wornWays = new Set(worn.map(w => w.way));
305
+ const wayOf = (m: OpeningMix) => openingTokenOf({ ...m, ground: [] });
306
+ const free = carried.find(m => !wornWays.has(wayOf(m)));
303
307
  // The contract's last way is every tier's and fits any name (a heading): there is always one.
304
- const mix = free ?? carried[0] ?? checkOpening(ways[ways.length - 1], site).mix;
305
- return { mix, token: openingTokenOf(mix), worn: !free };
308
+ const way = free ?? carried[0] ?? checkOpening(ways[ways.length - 1], site).mix;
309
+ const ground = typeLedGroundFor(worn.filter(w => w.way.includes(TYPE_LED_MEDIA)), plan);
310
+ const mix: OpeningMix = { ...way, ground: ground === OpeningGround.Inverse ? [] : [ground] };
311
+ return { mix, token: openingTokenOf(mix), worn: !free, ground };
312
+ }
313
+
314
+ /** A token's media part when the first screen holds no picture (`opening:<frame>/none/<words>`). */
315
+ const TYPE_LED_MEDIA = `/${OpeningMedia.None}/`;
316
+ /** How animated, at which a look is calm: its type-led first screen never stands on the accent. */
317
+ const CALM_ANIMATE: ReadonlySet<string> = new Set(['still', 'subtle']);
318
+
319
+ /**
320
+ * iox-ui#131: what a type-led first screen stands on — the ground the studio's OTHER type-led sites wear least (the
321
+ * contract's `typeLedGrounds` order breaks a tie, `inverse` first), so six type-led Homes do not all open dark. A calm
322
+ * look never takes the accent. Pure.
323
+ */
324
+ export function typeLedGroundFor(others: ReadonlyArray<{ ground: string }>, plan: Pick<SitePlan, 'design'>): OpeningGround {
325
+ const grounds = typeLedGrounds(CALM_ANIMATE.has(String(plan.design?.animate ?? '')));
326
+ const count = (g: string) => others.filter(o => o.ground === g).length;
327
+ return grounds.reduce((best, g) => (count(g) < count(best) ? g : best), grounds[0]);
306
328
  }
307
329
 
308
330
  /**
@@ -417,7 +439,7 @@ export function typeLedRound(
417
439
  if (takes) {
418
440
  const words = openingMixWords(chosen.mix);
419
441
  next = { ...next, mixes: { ...next.mixes, opening: words } };
420
- opening = { words, token: chosen.token, ...(chosen.worn ? { worn: true as const } : {}) };
442
+ opening = { words, token: chosen.token, ground: chosen.ground, ...(chosen.worn ? { worn: true as const } : {}) };
421
443
  const was = plan.mixes?.opening?.join(' ');
422
444
  if (was !== words.join(' ')) {
423
445
  changes.push({
@@ -20,6 +20,8 @@ import { headerMixFromWords } from './header-mix';
20
20
  import { openingMixFromWords } from './opening-mix';
21
21
  import { bodyMixFromWords } from './body-mix';
22
22
  import { patternListGap } from './recipe-fields';
23
+ import { freeSlotIssues } from './check-free';
24
+ import { FREE_ELEMENT_STYLES, FREE_HOLDERS, FREE_MOVES, FREE_WORD_TYPES, FreeLayer, FreeNode, FreeNodeType, FreeTrigger } from './free-wire';
23
25
  import { SPEC_SITE_LAYOUT, SPEC_SITE_PLAN_SHAPE } from './site-spec.generated';
24
26
  import {
25
27
  isNonEmptyString, isPlainObject as isObject, PathIssue, PathIssueCollector, pathAt as at, PlainObject as Obj, requiredShapeKeys, ShapeEntry, shapeKeys,
@@ -95,6 +97,9 @@ export enum SitePlanIssueCode {
95
97
  Compose = 'compose',
96
98
  /** M8 gate 2: a composed page's layout (`checkLayout`'s issues, each at its path under `layout`). */
97
99
  Layout = 'layout',
100
+ /** FS3: a free page or a free signature section the stamp could not make as written — its shape, a node type, a slot,
101
+ * a link, a ready-made place, a style the node's type has no control for (the rest is `checkFree`'s). */
102
+ Free = 'free',
98
103
  /** Commerce C-D21: what the business sells — a selling business without its products, one that sells nothing with a
99
104
  * shop, a product past the sixth, a shop source with no shop, or a content type named after a shop list. */
100
105
  Shop = 'shop',
@@ -160,6 +165,9 @@ const FILM_KEYS = shapeKeys(SHAPE['film']);
160
165
  const ART_DIRECTION_KEYS = shapeKeys(SHAPE['artDirection']);
161
166
  const DIRECTION_KEYS = shapeKeys(SHAPE['direction']);
162
167
  const LAYOUT_PAGE_KEYS = shapeKeys(SHAPE['layoutPage']);
168
+ const FREE_PAGE_KEYS = shapeKeys(SHAPE['freePage']);
169
+ const FREE_READ_KEYS = shapeKeys(SHAPE['freeRead']);
170
+ const FREE_NODE_KEYS = shapeKeys(SHAPE['freeNode']);
163
171
  const LAYOUT_DIALS: ReadonlyArray<string> = SPEC_SITE_LAYOUT.vocab.dials;
164
172
  const COMPOSED_PAGES_MAX: number = SPEC_SITE_LAYOUT.limits.composedPages;
165
173
  const DIRECTION_RULES_MAX = 3;
@@ -790,6 +798,7 @@ export function validateSitePlan(plan: unknown, ctx: SitePlanContext = {}): Site
790
798
  validateArtDirection(c, plan['artDirection']);
791
799
  validateDirection(c, plan['direction']);
792
800
  validateComposed(c, c.array(plan, 'pages', ''), ctx.tier);
801
+ validateFree(c, c.array(plan, 'pages', ''), sources);
793
802
  return { valid: c.issues.length === 0, issues: c.issues };
794
803
  }
795
804
 
@@ -836,6 +845,121 @@ function validateComposed(c: Collector, pages: unknown[], tier: `${GenerationTie
836
845
  if (composed > composedPagesMax(tier ?? GenerationTier.Basic)) c.add(SitePlanIssueCode.Compose, 'pages', `${composed} composed pages — the home page and at most ${COMPOSED_PAGES_MAX - 1} other`);
837
846
  }
838
847
 
848
+ /**
849
+ * FS3: the free pages and the free signature sections — what the stamp (`composeFree`) needs to make them as written: a
850
+ * free page only on a page marked `compose` and never beside a layout; its shape; node types where they may stand; ids
851
+ * unique; element styles a type wears; a move the product has; a list slot a list source of the plan, a form slot a
852
+ * forms-core preset; a button to a page of the plan or a section of the same page; a ready-made place one of the page's
853
+ * own; a style its type has a control for. A signature section stands on a page stamped from patterns. Taste, words,
854
+ * contrast and the phone are `checkFree`'s.
855
+ */
856
+ function validateFree(c: Collector, pages: unknown[], sources: Map<string, SourceInfo>): void {
857
+ const routes = new Set(pages.map(p => (isObject(p) && typeof p['route'] === 'string' && !routeParams(p['route']).length ? p['route'] : null)).filter((r): r is string => !!r));
858
+ pages.forEach((raw, i) => {
859
+ if (!isObject(raw)) return;
860
+ const path = `pages[${i}]`;
861
+ const plan = Array.isArray(raw['sections']) ? raw['sections'] : [];
862
+ const free = raw['free'];
863
+ if (free !== undefined) {
864
+ if (raw['compose'] !== true) c.add(SitePlanIssueCode.Compose, `${path}.free`, 'a free page only on a page marked compose');
865
+ if (raw['layout'] !== undefined) c.add(SitePlanIssueCode.Free, `${path}.free`, 'a page is laid out or free — never both');
866
+ if (!isObject(free)) c.add(SitePlanIssueCode.Shape, `${path}.free`, 'must be an object');
867
+ else {
868
+ const fp = `${path}.free`;
869
+ c.keys(free, FREE_PAGE_KEYS, fp);
870
+ if (!isObject(free['read'])) c.add(SitePlanIssueCode.Shape, `${fp}.read`, 'must be an object');
871
+ else c.keys(free['read'], FREE_READ_KEYS, `${fp}.read`);
872
+ c.string(free, 'pictures', fp);
873
+ if (free['givenAway'] !== undefined && !(Number.isInteger(free['givenAway']) && (free['givenAway'] as number) >= 0)) c.add(SitePlanIssueCode.Shape, `${fp}.givenAway`, 'a count');
874
+ const sections = c.array(free, 'sections', fp);
875
+ if (!sections.length) c.add(SitePlanIssueCode.Free, `${fp}.sections`, 'a free page has its sections');
876
+ validateFreeTree(c, sections, `${fp}.sections`, { routes, sources, plan, readyMade: true });
877
+ }
878
+ }
879
+ plan.forEach((s, j) => {
880
+ if (!isObject(s) || s['free'] === undefined) return;
881
+ const sp = `${path}.sections[${j}].free`;
882
+ if (raw['layout'] !== undefined || free !== undefined) c.add(SitePlanIssueCode.Free, sp, 'a free section stands on a page stamped from its sections — not on a laid-out or free page');
883
+ if (isPerItemPage(raw)) c.add(SitePlanIssueCode.Free, sp, 'a per-item page shows its item from patterns');
884
+ if (s['binding'] !== undefined || s['form'] !== undefined) c.add(SitePlanIssueCode.Free, sp, 'a free section never stands where the section binds content or holds a form — it places them as slots');
885
+ if (!isObject(s['free'])) return c.add(SitePlanIssueCode.Shape, sp, 'must be an object');
886
+ validateFreeTree(c, [s['free']], sp, { routes, sources, plan, readyMade: false }, true);
887
+ });
888
+ });
889
+ }
890
+
891
+ interface FreeTreeContext {
892
+ routes: ReadonlySet<string>;
893
+ sources: Map<string, SourceInfo>;
894
+ /** The page's plan sections (a ready-made place names one). */
895
+ plan: ReadonlyArray<unknown>;
896
+ readyMade: boolean;
897
+ }
898
+
899
+ const FREE_LIST_SLOT = 'list:';
900
+ const FREE_FORM_SLOT = 'form:';
901
+
902
+ function validateFreeTree(c: Collector, roots: unknown[], path: string, ctx: FreeTreeContext, single = false): void {
903
+ const ids = new Set<string>();
904
+ const seen = (n: unknown) => {
905
+ if (!isObject(n)) return;
906
+ if (typeof n['id'] === 'string') ids.add(n['id']);
907
+ if (Array.isArray(n['children'])) n['children'].forEach(seen);
908
+ };
909
+ roots.forEach(seen);
910
+ const used = new Set<string>();
911
+ const node = (raw: unknown, p: string, top: boolean) => {
912
+ if (!isObject(raw)) return c.add(SitePlanIssueCode.Shape, p, 'must be an object');
913
+ c.keys(raw, FREE_NODE_KEYS, p);
914
+ const id = c.string(raw, 'id', p);
915
+ if (id && used.has(id)) c.add(SitePlanIssueCode.Duplicate, `${p}.id`, `the id "${id}" is used twice`);
916
+ if (id) used.add(id);
917
+ const type = raw['type'] as FreeNodeType;
918
+ if (!Object.values(FreeNodeType).includes(type)) return c.add(SitePlanIssueCode.Free, `${p}.type`, `"${String(type)}" is not a free node type (${Object.values(FreeNodeType).join(', ')})`);
919
+ if ((type === FreeNodeType.Section) !== top) c.add(SitePlanIssueCode.Free, p, top ? 'the top holds Sections only' : 'a Section stands at the top only');
920
+ const ready = raw['readyMade'];
921
+ if (ready !== undefined) {
922
+ const at = isObject(ready) ? ready['at'] : undefined;
923
+ const section = Number.isInteger(at) ? ctx.plan[at as number] : undefined;
924
+ if (!ctx.readyMade || !top) c.add(SitePlanIssueCode.Free, `${p}.readyMade`, 'a ready-made place only stands for a section of a free page');
925
+ else if (!isObject(section) || !isObject(ready) || section['pattern'] !== ready['pattern']) c.add(SitePlanIssueCode.Free, `${p}.readyMade`, 'names a section of this page, with its pattern');
926
+ return;
927
+ }
928
+ const styles = FREE_ELEMENT_STYLES[type] ?? [];
929
+ const style = raw['elementStyle'];
930
+ if (style !== undefined && !styles.includes(String(style))) c.add(SitePlanIssueCode.Free, `${p}.elementStyle`, `a ${type} wears ${styles.join(', ') || 'no element style'}`);
931
+ if (FREE_WORD_TYPES.includes(type) && !isNonEmptyString(raw['text'])) c.add(SitePlanIssueCode.Free, `${p}.text`, 'its words are missing');
932
+ if (type === FreeNodeType.Heading && !(Number.isInteger(raw['level']) && (raw['level'] as number) >= 1 && (raw['level'] as number) <= 4)) c.add(SitePlanIssueCode.Free, `${p}.level`, 'a Heading is level 1 to 4');
933
+ if (type === FreeNodeType.Button) {
934
+ const href = String(raw['href'] ?? '');
935
+ if (!(ctx.routes.has(href) || (href.startsWith('#') && ids.has(href.slice(1))))) c.add(SitePlanIssueCode.Free, `${p}.href`, 'a button goes to a page of the plan or to a section of this page (#id)');
936
+ }
937
+ if (type === FreeNodeType.Slot) {
938
+ const slot = String(raw['slot'] ?? '');
939
+ const ok = slot.startsWith(FREE_LIST_SLOT) ? isListSource(ctx.sources.get(slot.slice(FREE_LIST_SLOT.length)))
940
+ : slot.startsWith(FREE_FORM_SLOT) ? !!formPresetById(slot.slice(FREE_FORM_SLOT.length)) : false;
941
+ if (!ok) c.add(SitePlanIssueCode.Free, `${p}.slot`, `"${slot}" — list:<a list source of the plan> or form:<a form preset>`);
942
+ }
943
+ const move = raw['move'];
944
+ if (move !== undefined && !(isObject(move) && FREE_MOVES[move['trigger'] as FreeTrigger]?.[String(move['action'])])) c.add(SitePlanIssueCode.Free, `${p}.move`, 'a move the product has (FREE_MOVES)');
945
+ if (!isObject(raw['styleProps'])) c.add(SitePlanIssueCode.Shape, `${p}.styleProps`, 'must be an object');
946
+ const responsive = raw['responsive'];
947
+ if (responsive !== undefined) {
948
+ if (!isObject(responsive)) c.add(SitePlanIssueCode.Shape, `${p}.responsive`, 'must be an object');
949
+ else for (const bp of Object.keys(responsive)) if (!(Object.values(FreeLayer) as string[]).includes(bp)) c.add(SitePlanIssueCode.Free, `${p}.responsive.${bp}`, `a width is ${Object.values(FreeLayer).join(' or ')}`);
950
+ }
951
+ for (const i of freeSlotIssues(raw as unknown as FreeNode, p)) c.add(SitePlanIssueCode.Free, i.path, i.message);
952
+ const children = raw['children'];
953
+ if (children !== undefined) {
954
+ if (!Array.isArray(children)) return c.add(SitePlanIssueCode.Shape, `${p}.children`, 'must be an array');
955
+ if (children.length && !FREE_HOLDERS.includes(type)) c.add(SitePlanIssueCode.Free, `${p}.children`, `a ${type} holds no children`);
956
+ children.forEach((child, k) => node(child, `${p}.children[${k}]`, false));
957
+ }
958
+ };
959
+ if (single && roots.length !== 1) c.add(SitePlanIssueCode.Free, path, 'a free section is ONE Section');
960
+ roots.forEach((r, k) => node(r, single ? path : `${path}[${k}]`, true));
961
+ }
962
+
839
963
  /** The plan's content types and, for each shop list a source reads, the shop's own (fixed fields and roles). */
840
964
  function withShopTypes(types: Map<string, ContentTypeInfo>, sources: Map<string, SourceInfo>): Map<string, ContentTypeInfo> {
841
965
  const out = new Map(types);