@vectoriox/iox-ui 5.90.2 → 5.91.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.
@@ -8,12 +8,16 @@ import {
8
8
  } from './layout-language';
9
9
  import { DriftBox, driftOverlap, layoutGlideDepth } from './layout-drift';
10
10
  import { layoutLookOf } from './layout-look';
11
- import { patternById } from './patterns';
11
+ import { patternById, SCENE_LEVEL } from './patterns';
12
12
  import { layoutDesignOf, screenWordMisfit } from './layout-type';
13
13
  import { sectionEntrances } from './entrances';
14
14
  import { calmParts, calmUnder, FrameRegion, PhotoInventory, PHOTO_LIGHT_LUMINANCE } from './photo-inventory';
15
15
  import { SerializedNode, walkSerialized } from './serialized-node';
16
16
  import { SPEC_SITE_FACTS, SPEC_SITE_LAYOUT } from './site-spec.generated';
17
+ import {
18
+ LAYOUT_CHECK_VIEWPORT, LAYOUT_DRIFT, LAYOUT_KINETIC_KINDS, LAYOUT_LINE_HEIGHT, layoutBoxPx, layoutDriftPhoto, layoutHeldStill, layoutOpeningDisplayMend, layoutOpeningDisplays, layoutShapeHasPurpose,
19
+ layoutStillLine, layoutTextFits, layoutVoidScreens, layoutVoids,
20
+ } from './layout-space';
17
21
 
18
22
  /**
19
23
  * THE STATIC LAYOUT GATE (premium components M8 gate 2, M8-G2-D6; the prototype's `check` + `check21`, `code/cl2.mjs` and
@@ -108,22 +112,17 @@ export function layoutPresetColours(presetId: string, mode: 'light' | 'dark'): L
108
112
 
109
113
  // ── Geometry ────────────────────────────────────────────────────────────────────────────────────────────
110
114
 
111
- /**
112
- * The laptop the estimates are made on (the render check's 1440 × 900). A grid column is taken as 1440 / 12 px and a row
113
- * as its section's screens × 900 / rows (a held section's grid is its one-screen stage): the gutter and the column gaps
114
- * are left out, so a box reads about a fifth wider than it renders — the render check measures the real one.
115
- */
116
- export const LAYOUT_CHECK_VIEWPORT = { width: 1440, height: 900 } as const;
117
115
  const GRID = 12;
118
116
  const COLUMN_PX = LAYOUT_CHECK_VIEWPORT.width / GRID;
119
- /** A line of words stands its size × this tall. */
120
- const LINE_HEIGHT = 1.2;
121
117
  /** WCAG's large text (≥ 24 px): 3:1 is enough. */
122
118
  const LARGE_TEXT_PX = 24;
123
119
  const CONTRAST_LARGE = 3;
124
120
  const CONTRAST_BODY = 4.5;
125
121
  /** The prototype's numbers the contract does not carry yet. */
126
122
  const TRACK_SCALE_MAX = 1.3;
123
+
124
+ /** A section that holds the page: held two screens or more, or sideways. */
125
+ const isHold = (s: LayoutSection) => !!s.pin && (s.screens >= 2 || (s.track ?? 1) > 1);
127
126
  const INNER_MAX = 3;
128
127
  const BEAT_MAX = 5;
129
128
  const POP_WORDS = 3;
@@ -135,7 +134,6 @@ const START_CLIP_MIN = 40;
135
134
  const HIDDEN_CLIP = 30;
136
135
  /** A button or section that reads as a way to reach the business (the prototype's words, English and Hebrew). */
137
136
  const CONTACT_WORDS = /contact|book|reserve|visit|table|sign.?up|enquir|צור|הזמ|קשר|שולחן|ביקור|הרשמ/i;
138
- const HEBREW = /[֐-׿]/;
139
137
  const LATIN_SENTENCE = /[A-Za-z]{3,}(\s+[A-Za-z]{3,}){2,}/;
140
138
  const NUMBER_GIVEN = /\d[\d:.,]{2,}|[$₪€£]\s?\d+/g;
141
139
  const CHIP_NUMBER = /\d{2,}|[$₪€£]/;
@@ -160,11 +158,7 @@ const isText = (l: LayoutLayer) => LAYOUT_TEXT_KINDS.has(l.kind);
160
158
  const isPictured = (l: LayoutLayer) => l.kind === LayoutLayerKind.Photo || l.kind === LayoutLayerKind.Gallery;
161
159
  const contrastOf = (a: number, b: number) => (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05);
162
160
 
163
- /** A grid box's size in px on the laptop. */
164
- function boxPx(col: readonly number[], row: readonly number[], s: LayoutSection): { w: number; h: number } {
165
- const height = (s.pin ? 1 : s.screens) * LAYOUT_CHECK_VIEWPORT.height;
166
- return { w: span(col) * COLUMN_PX, h: (span(row) * height) / Math.max(1, s.rows) };
167
- }
161
+ const boxPx = layoutBoxPx;
168
162
 
169
163
  /** A section of one photo on one side and words on the other: 'start' | 'end' | null (the prototype's `splitSide`). */
170
164
  export function splitSide(s: LayoutSection): 'start' | 'end' | null {
@@ -346,6 +340,7 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
346
340
  let screenWords = 0;
347
341
  let wordsOnPhoto = 0;
348
342
  let holds = 0;
343
+ const allHolds = sections.filter(isHold).length;
349
344
  let pinned = 0;
350
345
  let marquees = 0;
351
346
  let boxes = 0;
@@ -383,7 +378,7 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
383
378
  const layers = Array.isArray(s.layers) ? s.layers : [];
384
379
  if (!layers.length) add(LayoutIssueCode.Structure, `${at}.layers`, 'at least one layer');
385
380
  if (s.pin) pinned++;
386
- if (s.pin && (s.screens >= 2 || track > 1)) holds++;
381
+ if (isHold(s)) holds++;
387
382
  if (i === 0 && daring && splitSide(s)) add(LayoutIssueCode.Daring, at, 'a daring page never opens on a split (photo one side, words the other) — break it');
388
383
  const phone = Array.isArray(s.phone) ? s.phone : [];
389
384
  if (phone.length !== layers.length || new Set(phone).size !== layers.length || phone.some(n => !(Number.isInteger(n) && n >= 0 && n < layers.length))) {
@@ -445,14 +440,9 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
445
440
  if ((l.size === 'm' || l.size === 's') && text.length > LIM.longTextChars && span(l.col) > LIM.longTextColumns) {
446
441
  add(LayoutIssueCode.Reading, `${lp}.col`, `long text is never wider than ${LIM.longTextColumns} columns`);
447
442
  }
448
- if (placed && isText(l) && l.size && l.size !== 'screen' && text) {
449
- const px = L.sizePx[l.size];
450
- const box = boxPx(l.col, l.row, s);
451
- const lines = Math.floor(box.h / (px * LINE_HEIGHT));
452
- const advance = HEBREW.test(text) ? LIM.advance.hebrew : LIM.advance.latin;
453
- const items = l.kind === LayoutLayerKind.List ? Math.max(1, l.items?.length ?? 1) : 1;
454
- const fits = lines >= items && (text.length * px * advance) / Math.max(1, lines) <= box.w * LIM.textFitSlack;
455
- if (!fits) add(LayoutIssueCode.Reading, `${lp}.row`, `${text.length} characters at ${l.size} do not fit a box of ${span(l.col)} columns × ${span(l.row)} rows (about ${Math.max(0, lines)} line${lines === 1 ? '' : 's'}) — give it more rows or columns, or fewer words`);
443
+ if (placed && isText(l) && l.size && l.size !== 'screen' && text && !layoutTextFits(l, s)) {
444
+ const lines = Math.floor(boxPx(l.col, l.row, s).h / (L.sizePx[l.size] * LAYOUT_LINE_HEIGHT));
445
+ add(LayoutIssueCode.Reading, `${lp}.row`, `${text.length} characters at ${l.size} do not fit a box of ${span(l.col)} columns × ${span(l.row)} rows (about ${Math.max(0, lines)} line${lines === 1 ? '' : 's'}) — give it more rows or columns, or fewer words`);
456
446
  }
457
447
  if (l.size === 'screen' || l.size === 'xxl') huge++;
458
448
  if (l.size === 'screen') {
@@ -484,6 +474,10 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
484
474
  if ((l.motion ?? []).some(m => m.prop !== LayoutTrackProp.Opacity)) add(LayoutIssueCode.Motion, `${lp}.motion`, 'decoration only fades — opacity tracks only');
485
475
  if (l.depth === 'front') add(LayoutIssueCode.Motion, `${lp}.depth`, 'decoration never runs ahead — back or mid');
486
476
  }
477
+ if (l.kind === LayoutLayerKind.Shape && !layoutShapeHasPurpose(s, j)) {
478
+ add(LayoutIssueCode.Look, lp, 'a shape that is there for nothing — not a rule (one row high), a band, a frame for a picture or a ground for words, and it does not move: an empty box on the page',
479
+ { kind: LayoutMendKind.Drop, layer: lp });
480
+ }
487
481
  if (l.role === LayoutRole.Static && ((l.enter && l.enter !== LayoutEnter.None) || l.motion?.length || deep)) add(LayoutIssueCode.Motion, `${lp}.role`, 'a static layer has no enter, motion or depth');
488
482
 
489
483
  if (l.rotate) {
@@ -518,7 +512,7 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
518
512
  });
519
513
  if (shows.length && hides.length && Math.max(...hides) > Math.max(...shows)) add(LayoutIssueCode.Motion, `${lp}.motion`, 'it leaves more slowly than it arrived — an exit is shorter than the entrance');
520
514
  if (l.kinetic) {
521
- if (l.kind !== LayoutLayerKind.Word && l.kind !== LayoutLayerKind.Heading) add(LayoutIssueCode.Value, `${lp}.kinetic`, 'only a word or heading');
515
+ if (!LAYOUT_KINETIC_KINDS.has(l.kind)) add(LayoutIssueCode.Value, `${lp}.kinetic`, 'only a word, a heading or a line of text');
522
516
  if (wordsOf(l.text) > LIM.kineticWords) add(LayoutIssueCode.Look, `${lp}.kinetic`, `${wordsOf(l.text)} words — kinetic words hold at most ${LIM.kineticWords}`);
523
517
  if (!s.pin) add(LayoutIssueCode.Motion, `${lp}.kinetic`, 'kinetic words light by the scroll of a HELD section');
524
518
  }
@@ -663,6 +657,16 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
663
657
  if (ctx.locale === 'he' && LATIN_SENTENCE.test(plain)) add(LayoutIssueCode.Content, `${lp}.text`, 'the site is Hebrew — write it in Hebrew');
664
658
  }
665
659
  });
660
+ if (layoutHeldStill(s)) {
661
+ const line = layoutStillLine(s);
662
+ const photo = layoutDriftPhoto(s);
663
+ // A daring page needs its holds: letting this one flow would trade the still screen for a page that holds too little.
664
+ const spare = !daring || allHolds - Number(isHold(s)) >= LIM.daring.holds - carried.holds;
665
+ add(LayoutIssueCode.Motion, at, 'it holds the page and nothing in it moves by the scroll — a held section plays: light its line word by word (kinetic), give a layer a track, or let it flow',
666
+ line >= 0 ? { kind: LayoutMendKind.Words, layer: `${at}.layers[${line}]` }
667
+ : spare ? { kind: LayoutMendKind.Unpin, section: i }
668
+ : photo >= 0 ? { kind: LayoutMendKind.Drift, layer: `${at}.layers[${photo}]` } : undefined);
669
+ }
666
670
  if (limits.rotatedPerSectionMax !== undefined && rotated > limits.rotatedPerSectionMax) add(LayoutIssueCode.Look, at, `${rotated} rotated layers — at most ${limits.rotatedPerSectionMax}`);
667
671
  if (i === 0 && limits.firstButtonsMax !== undefined && layers.filter(l => l.kind === LayoutLayerKind.Button).length > limits.firstButtonsMax) {
668
672
  add(LayoutIssueCode.Look, at, `at most ${limits.firstButtonsMax} button in the first section`);
@@ -678,6 +682,22 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
678
682
  }
679
683
  }
680
684
  });
685
+ const voids = layoutVoids(sections);
686
+ const voidScreens = voids.length ? layoutVoidScreens(sections) : null;
687
+ for (const v of voids) {
688
+ add(LayoutIssueCode.Look, `sections[${v.sections[0]}]`, `${Math.round(v.to - v.from)}px of the laptop's screen with nothing on it (${v.sections.map(i => sections[i].id).join(' → ')}) — a section that flows fills its screens: fewer screens, or layers where the eye would land`,
689
+ voidScreens ? { kind: LayoutMendKind.Screens, sections: voidScreens } : undefined);
690
+ }
691
+ const opening = layoutOpeningDisplays(page);
692
+ if ((daring || ctx.design?.animate === SCENE_LEVEL) && sections[0] && !sections[0].readyMade) {
693
+ if (!opening.length) {
694
+ const display = layoutOpeningDisplayMend(page);
695
+ add(LayoutIssueCode.Daring, 'sections[0]', 'the opening has no display — a daring page opens on one thing set large: a word, or a heading at xxl or screen size',
696
+ display ? { kind: LayoutMendKind.Display, layer: `sections[0].layers[${display.layer}]`, ...(display.size ? { size: display.size } : {}) } : undefined);
697
+ } else if (opening.length > 1) {
698
+ add(LayoutIssueCode.Look, 'sections[0]', `${opening.length} displays in the opening — one moment: one word or one large heading`);
699
+ }
700
+ }
681
701
  if (ctx.first && !reachable) add(LayoutIssueCode.Content, 'sections', 'nothing lets people reach the business — a form, or a button to one');
682
702
  if (galleries < LIM.galleriesMin - carried.galleries) add(LayoutIssueCode.Structure, 'sections', `${galleries} galleries — at least ${LIM.galleriesMin}`);
683
703
  if (LIM.galleriesMin > 0 && galleries && !swappable && !carried.swappable) add(LayoutIssueCode.Structure, 'sections', 'no gallery can be dragged or swiped — at least one without "scroll"');
@@ -953,6 +973,7 @@ const MEND_ROLE_ORDER: ReadonlyArray<`${LayoutRole}` | undefined> = [LayoutRole.
953
973
  */
954
974
  export function mendLayout(page: LayoutPage, issues: ReadonlyArray<LayoutIssue>): { page: LayoutPage; mended: LayoutIssue[] } {
955
975
  const mended: LayoutIssue[] = [];
976
+ const drops: LayoutIssue[] = [];
956
977
  if (!issues.some(i => i.mend)) return { page, mended };
957
978
  const next = structuredClone(page) as LayoutPage;
958
979
  const layerAt = (path: string): LayoutLayer | undefined => {
@@ -988,7 +1009,45 @@ export function mendLayout(page: LayoutPage, issues: ReadonlyArray<LayoutIssue>)
988
1009
  if (!layer?.gallery) continue;
989
1010
  layer.gallery.source = mend.source;
990
1011
  mended.push(issue);
1012
+ } else if (mend?.kind === LayoutMendKind.Words) {
1013
+ const layer = layerAt(mend.layer);
1014
+ if (!layer) continue;
1015
+ layer.kinetic = true;
1016
+ mended.push(issue);
1017
+ } else if (mend?.kind === LayoutMendKind.Display) {
1018
+ const layer = layerAt(mend.layer);
1019
+ if (!layer) continue;
1020
+ layer.kind = LayoutLayerKind.Word;
1021
+ if (mend.size) layer.size = mend.size;
1022
+ mended.push(issue);
1023
+ } else if (mend?.kind === LayoutMendKind.Drift) {
1024
+ const layer = layerAt(mend.layer);
1025
+ if (!layer) continue;
1026
+ layer.motion = [...(layer.motion ?? []), { ...LAYOUT_DRIFT, at: [...LAYOUT_DRIFT.at] as [number, number] }];
1027
+ mended.push(issue);
1028
+ } else if (mend?.kind === LayoutMendKind.Unpin) {
1029
+ const section = next.sections?.[mend.section];
1030
+ if (!section) continue;
1031
+ section.pin = false;
1032
+ delete section.track;
1033
+ section.screens = 1;
1034
+ mended.push(issue);
1035
+ } else if (mend?.kind === LayoutMendKind.Screens) {
1036
+ if (mend.sections.some(m => !next.sections?.[m.section])) continue;
1037
+ for (const m of mend.sections) next.sections[m.section].screens = m.screens;
1038
+ mended.push(issue);
1039
+ } else if (mend?.kind === LayoutMendKind.Drop && layerAt(mend.layer)) {
1040
+ drops.push(issue);
991
1041
  }
992
1042
  }
1043
+ // Last, so every path above still names the layer it was found at: the empty shapes leave, the latest first.
1044
+ const dropAt = (i: LayoutIssue) => /^sections\[(\d+)\]\.layers\[(\d+)\]$/.exec((i.mend as { layer: string }).layer)!.slice(1).map(Number);
1045
+ for (const issue of [...drops].sort((a, b) => dropAt(b)[0] - dropAt(a)[0] || dropAt(b)[1] - dropAt(a)[1])) {
1046
+ const [si, li] = dropAt(issue);
1047
+ const section = next.sections[si];
1048
+ section.layers.splice(li, 1);
1049
+ if (Array.isArray(section.phone)) section.phone = section.phone.filter(n => n !== li).map(n => (n > li ? n - 1 : n));
1050
+ mended.push(issue);
1051
+ }
993
1052
  return { page: mended.length ? next : page, mended };
994
1053
  }
@@ -10,6 +10,7 @@ import {
10
10
  screenFontSize,
11
11
  } from './layout-language';
12
12
  import { layoutGlideDepth } from './layout-drift';
13
+ import { isLayoutRule, layoutRuleEdge } from './layout-space';
13
14
  import { layoutDesignOf, layoutElementStyle, layoutTextWidthEm, screenWordColumns } from './layout-type';
14
15
  import { ComposeError, createSerializedNode, SerializedNode, setStyleProps, assertStyleSlots, walkSerialized } from './serialized-node';
15
16
 
@@ -132,6 +133,8 @@ const GALLERY_SPEED = 900;
132
133
  const GALLERY_STACKED_ASPECT = '4 / 5';
133
134
  const FULL = '100%';
134
135
  const ZERO = '0px';
136
+ /** A rule's line: the looks' hairline. */
137
+ const RULE_PX = '1px';
135
138
  const PHONE_GROUND_BRIGHTNESS = '0.75';
136
139
  const GALLERY_BAR_TOP = '12px';
137
140
  const STRETCH_KINDS: ReadonlySet<string> = new Set([LayoutLayerKind.Photo, LayoutLayerKind.Shape, LayoutLayerKind.Gallery, LayoutLayerKind.Form]);
@@ -686,6 +689,10 @@ function composeLayer(l: LayoutLayer, lc: LayerCtx, ctx: Ctx): SerializedNode {
686
689
  }
687
690
  outer.label = `${lc.section.id} · ${l.kind}${l.role ? ` (${l.role})` : ''}`;
688
691
  place(outer, l, lc, ctx);
692
+ // A rule is a line against the words it belongs to, never its row's full height (the bar's grey boxes, M8 demo).
693
+ if (l.kind === LayoutLayerKind.Shape && isLayoutRule(lc.section, lc.li)) {
694
+ setStyleProps(outer, { height: RULE_PX, alignSelf: layoutRuleEdge(lc.section, lc.li), borderRadius: ZERO });
695
+ }
689
696
 
690
697
  // Held: the layer moves by tracks; a kinetic heading lights word by word as the section is read.
691
698
  const tracks: SceneTrackOut[] = [];
@@ -1,4 +1,6 @@
1
- import { AnimateId, COLOR_SCHEMES, DesignChoices, LinkType, resolveDesignChoices, setColorScheme } from '@vectoriox/iox-ui/design-core';
1
+ import {
2
+ AnimateId, COLOR_SCHEME_TRAIT, COLOR_SCHEMES, ColorScheme, colorSchemeClass, DesignChoices, LinkType, resolveDesignChoices, setColorScheme,
3
+ } from '@vectoriox/iox-ui/design-core';
2
4
  import { SEO_DESCRIPTION_MAX, SEO_TITLE_MAX, SeoRawDoc } from '@vectoriox/iox-ui/seo-core';
3
5
  import { channelOpensNewTab, FORM_ACTIONS_ROLE, FORM_CHANNEL_ROLE, FormPresetChannel, FormPresetDef, FormPresetField, formPresetById } from '@vectoriox/iox-ui/forms-core';
4
6
  import {
@@ -24,7 +26,7 @@ import { SitePlanSourceKind, ContentFieldControl, ContentFieldPlan,
24
26
  } from './site-plan.model';
25
27
  import { assertValidSitePlan, nextSourceOf, routeParams } from './validate-site-plan';
26
28
  import { NavShape, planNavShape } from './nav-shape';
27
- import { composeLayout, LayoutColourMode } from './compose-layout';
29
+ import { composeLayout, LayoutColourMode, layoutBandScheme } from './compose-layout';
28
30
  import { LayoutGalleryList, LayoutPage, LayoutPhotoShape, LayoutPhotoSource, LayoutSite, parseLayoutPhotoId } from './layout-language';
29
31
  import { layoutMotionOf, layoutPresetOf } from './layout-look';
30
32
 
@@ -148,7 +150,7 @@ export interface ComposedPage {
148
150
  locale: `${SiteLocale}`;
149
151
  /** DS3: every page the wizard creates follows the look (page-bg / text / font-body). M8 gate 2: a composed page names
150
152
  * the plan page its layout is (`layoutSource`; the build adds its run) — what Design ▸ Re-fit recomposes it from. */
151
- pageSettings: { designSystem: true; layoutSource?: { pageKey: string; runId?: string } };
153
+ pageSettings: { designSystem: true; layoutSource?: { pageKey: string; runId?: string }; opening?: `${ColorScheme}` };
152
154
  /** M1-6c: the page's search-result words — written (a static page) or bound to the route item (a template page),
153
155
  * in the seo-core document shape the shared `resolveSeo` reads. */
154
156
  seo: SeoRawDoc;
@@ -1308,9 +1310,10 @@ export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSi
1308
1310
  const pages: ComposedPage[] = plan.pages.map(page => {
1309
1311
  const nextAlias = page.routeSource ? nextSourceOf(relatives, page.routeSource) : null;
1310
1312
  if (page.layout) {
1313
+ const opening = layoutBandScheme(page.layout.sections[0]?.ground);
1311
1314
  return {
1312
1315
  key: page.key, name: page.name, route: { path: page.route }, isHome: page.isHome === true, status: STATUS_DRAFT, locale,
1313
- pageSettings: { designSystem: true, layoutSource: { pageKey: page.key } }, seo: composePageSeo(page, plan),
1316
+ pageSettings: { designSystem: true, layoutSource: { pageKey: page.key }, ...(opening ? { opening } : {}) }, seo: composePageSeo(page, plan),
1314
1317
  layout: composeLayoutPage(page, page.layout, plan, context, design, placeholders, (section, id) =>
1315
1318
  composePattern(patternById(section.pattern) as SitePattern, id, { ...base, owner: page.key, page, section, nextAlias },
1316
1319
  { level: section.enter ?? design.animate ?? null, rtl })),
@@ -1321,6 +1324,7 @@ export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSi
1321
1324
  const motion: SectionMotion = { level: section.enter ?? design.animate ?? null, rtl };
1322
1325
  return composePattern(pattern, `${page.key}-${i}`, { ...base, owner: page.key, page, section, nextAlias }, motion);
1323
1326
  });
1327
+ const opening = colorSchemeClass(layout[0]?.props?.[COLOR_SCHEME_TRAIT]) ? (layout[0].props[COLOR_SCHEME_TRAIT] as ColorScheme) : null;
1324
1328
  return {
1325
1329
  key: page.key,
1326
1330
  name: page.name,
@@ -1328,7 +1332,7 @@ export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSi
1328
1332
  isHome: page.isHome === true,
1329
1333
  status: STATUS_DRAFT,
1330
1334
  locale,
1331
- pageSettings: { designSystem: true },
1335
+ pageSettings: { designSystem: true, ...(opening ? { opening } : {}) },
1332
1336
  seo: composePageSeo(page, plan),
1333
1337
  layout,
1334
1338
  };
@@ -339,6 +339,20 @@ export enum LayoutMendKind {
339
339
  * the section's words name, else the first in plan order. None, or the section's words name the list it named
340
340
  * (iox-ui#66): left to the model. */
341
341
  Source = 'source',
342
+ /** A held section where nothing moves by the scroll (the page stops on a still screen, M8 demo): its line — a word,
343
+ * heading or text of at most the kinetic words — is lit word by word as the hold plays. */
344
+ Words = 'words',
345
+ /** A held section where nothing moves and no line can be lit: it flows, one screen tall — when the page can spare the hold. */
346
+ Unpin = 'unpin',
347
+ /** …and when it cannot (a daring page needs its holds): its largest photo drifts — a slow scale as the hold plays. */
348
+ Drift = 'drift',
349
+ /** A shape with no purpose — not a rule, a band, a frame, a backdrop to words, and it does not move: it is dropped. */
350
+ Drop = 'drop',
351
+ /** A section that leaves a stretch of the laptop's screen with nothing on it: its height comes down (its rows keep
352
+ * their share, the words still fit) until the stretch is gone. */
353
+ Screens = 'screens',
354
+ /** A daring or Expressive page whose opening has no display: the opening's lead line is set as one (a word). */
355
+ Display = 'display',
342
356
  }
343
357
 
344
358
  /** Which rule chose a mended gallery's list. */
@@ -369,7 +383,11 @@ export type LayoutMend =
369
383
  | { kind: LayoutMendKind.Scrim | LayoutMendKind.Ink | LayoutMendKind.Fade; layer: string }
370
384
  | { kind: LayoutMendKind.Accent; over: number; bands?: ReadonlyArray<LayoutBandMove> }
371
385
  | { kind: LayoutMendKind.Depth; layers: ReadonlyArray<string> }
372
- | { kind: LayoutMendKind.Source; layer: string; source: string; by: `${LayoutSourceChoice}` };
386
+ | { kind: LayoutMendKind.Source; layer: string; source: string; by: `${LayoutSourceChoice}` }
387
+ | { kind: LayoutMendKind.Words | LayoutMendKind.Drop | LayoutMendKind.Drift; layer: string }
388
+ | { kind: LayoutMendKind.Display; layer: string; size?: `${LayoutSize}` }
389
+ | { kind: LayoutMendKind.Unpin; section: number }
390
+ | { kind: LayoutMendKind.Screens; sections: ReadonlyArray<{ section: number; screens: number }> };
373
391
 
374
392
  export interface LayoutIssue {
375
393
  code: `${LayoutIssueCode}`;
@@ -0,0 +1,260 @@
1
+ import {
2
+ LAYOUT_TEXT_KINDS, LayoutDepth, LayoutLayer, LayoutLayerKind, LayoutPage, LayoutRole, LayoutSection, LayoutSectionKind, LayoutSize, LayoutTrack, LayoutTrackProp,
3
+ } from './layout-language';
4
+ import { SPEC_SITE_LAYOUT } from './site-spec.generated';
5
+
6
+ /**
7
+ * Space on a composed page (the M8 demo, the bar's live page 2026-11-10): what the static check can read off the grid
8
+ * about stillness and emptiness — a held section where nothing moves, a shape that is there for nothing, a stretch of the
9
+ * laptop's screen with nothing on it, an opening with no display. Estimates on the check's laptop (1440 × 900), the
10
+ * render check measures the real page. Pure.
11
+ */
12
+
13
+ const L = SPEC_SITE_LAYOUT;
14
+ const LIM = L.limits;
15
+
16
+ /**
17
+ * The laptop the estimates are made on (the render check's 1440 × 900). A grid column is taken as 1440 / 12 px and a row
18
+ * as its section's screens × 900 / rows (a held section's grid is its one-screen stage): the gutter and the column gaps
19
+ * are left out, so a box reads about a fifth wider than it renders — the render check measures the real one.
20
+ */
21
+ export const LAYOUT_CHECK_VIEWPORT = { width: 1440, height: 900 } as const;
22
+ const GRID = 12;
23
+ const COLUMN_PX = LAYOUT_CHECK_VIEWPORT.width / GRID;
24
+ /** A line of words stands its size × this tall. */
25
+ export const LAYOUT_LINE_HEIGHT = 1.2;
26
+ const HEBREW = /[֐-׿]/;
27
+ /** A button's ink, as tall as its padding and one line. */
28
+ const BUTTON_PX = 56;
29
+ /** How far the screens mend lowers a section at a time, and how often it tries. */
30
+ const SCREENS_STEP = 0.25;
31
+ const SCREENS_TRIES = 40;
32
+ /** The kinds the composer stretches over their whole cell (`place`); every other kind sits in its cell's middle. */
33
+ const FULL_CELL: ReadonlySet<string> = new Set([LayoutLayerKind.Photo, LayoutLayerKind.Shape, LayoutLayerKind.Gallery, LayoutLayerKind.Form, LayoutLayerKind.Marquee]);
34
+ /** The kinds a held section's line may be lit by the scroll (`kinetic`). */
35
+ export const LAYOUT_KINETIC_KINDS: ReadonlySet<string> = new Set([LayoutLayerKind.Word, LayoutLayerKind.Heading, LayoutLayerKind.Text]);
36
+
37
+ const span = (r: readonly number[] | undefined) => (r ? r[1] - r[0] : 0);
38
+ const isText = (l: LayoutLayer) => LAYOUT_TEXT_KINDS.has(l.kind);
39
+ const isPictured = (l: LayoutLayer) => l.kind === LayoutLayerKind.Photo || l.kind === LayoutLayerKind.Gallery;
40
+ const wordsOf = (t: string | undefined) => String(t ?? '').trim().split(/\s+/).filter(Boolean).length;
41
+ const meets = (a: LayoutLayer, b: LayoutLayer) => {
42
+ const ov = (p: readonly number[], q: readonly number[]) => p[0] < q[1] && q[0] < p[1];
43
+ return ov(a.col ?? [0, 0], b.col ?? [0, 0]) && ov(a.row ?? [0, 0], b.row ?? [0, 0]);
44
+ };
45
+ const textOf = (l: LayoutLayer) => String(l.text ?? (l.items ?? []).join(' '));
46
+ const advanceOf = (text: string) => (HEBREW.test(text) ? LIM.advance.hebrew : LIM.advance.latin);
47
+
48
+ /** A grid box's size in px on the laptop. */
49
+ export function layoutBoxPx(col: readonly number[], row: readonly number[], s: Pick<LayoutSection, 'pin' | 'screens' | 'rows'>): { w: number; h: number } {
50
+ const height = (s.pin ? 1 : s.screens) * LAYOUT_CHECK_VIEWPORT.height;
51
+ return { w: span(col) * COLUMN_PX, h: (span(row) * height) / Math.max(1, s.rows) };
52
+ }
53
+
54
+ /** Whether a sized text layer's words fit its box at its size (the check's estimate; a `screen` word is sized to fit). */
55
+ export function layoutTextFits(l: LayoutLayer, s: Pick<LayoutSection, 'pin' | 'screens' | 'rows'>, size: string | undefined = l.size): boolean {
56
+ const text = textOf(l);
57
+ if (!isText(l) || !size || size === LayoutSize.Screen || !text) return true;
58
+ const px = L.sizePx[size as keyof typeof L.sizePx];
59
+ const box = layoutBoxPx(l.col, l.row, s);
60
+ const lines = Math.floor(box.h / (px * LAYOUT_LINE_HEIGHT));
61
+ const items = l.kind === LayoutLayerKind.List ? Math.max(1, l.items?.length ?? 1) : 1;
62
+ return lines >= items && (text.length * px * advanceOf(text)) / Math.max(1, lines) <= box.w * LIM.textFitSlack;
63
+ }
64
+
65
+ /** Words or a button drawn over a layer (above it, meeting it). */
66
+ function wordsOver(s: LayoutSection, li: number): boolean {
67
+ const l = s.layers[li];
68
+ return s.layers.some((o, oi) => oi !== li && (isText(o) || o.kind === LayoutLayerKind.Button) && (o.z ?? 0) > (l.z ?? 0) && meets(o, l));
69
+ }
70
+
71
+ /**
72
+ * A rule: a shape one row high with no words on it — the looks' hairline ("a shape one row high"). The composer draws it
73
+ * as a line, never as the row's full height (the bar's grey boxes: a 150–180 px block where a hairline was meant).
74
+ */
75
+ export function isLayoutRule(s: LayoutSection, li: number): boolean {
76
+ const l = s.layers?.[li];
77
+ return !!l && l.kind === LayoutLayerKind.Shape && span(l.row) === 1 && !wordsOver(s, li);
78
+ }
79
+
80
+ /** Where a rule's line sits in its row: against the words it belongs to (above it → its top, below it → its bottom). */
81
+ export function layoutRuleEdge(s: LayoutSection, li: number): 'start' | 'end' | 'center' {
82
+ const l = s.layers[li];
83
+ const beside = (o: LayoutLayer) => isText(o) && (o.col?.[0] ?? 0) < (l.col?.[1] ?? 0) && (l.col?.[0] ?? 0) < (o.col?.[1] ?? 0);
84
+ if (s.layers.some((o, oi) => oi !== li && beside(o) && o.row?.[1] === l.row[0])) return 'start';
85
+ if (s.layers.some((o, oi) => oi !== li && beside(o) && o.row?.[0] === l.row[1])) return 'end';
86
+ return 'center';
87
+ }
88
+
89
+ /**
90
+ * A shape is there for something: a rule, a band of colour (wide, or off an edge), a backdrop to words, a frame meeting
91
+ * a picture, or it moves (tracks, a depth). Anything else is an empty box on the page.
92
+ */
93
+ export function layoutShapeHasPurpose(s: LayoutSection, li: number): boolean {
94
+ const l = s.layers?.[li];
95
+ if (!l || l.kind !== LayoutLayerKind.Shape) return true;
96
+ if (isLayoutRule(s, li) || wordsOver(s, li)) return true;
97
+ if (span(l.col) >= LIM.bandColumns || (l.bleed && l.bleed !== 'none')) return true;
98
+ if (s.layers.some((o, oi) => oi !== li && isPictured(o) && meets(o, l))) return true;
99
+ return !!l.motion?.length || (!!l.depth && l.depth !== LayoutDepth.Mid);
100
+ }
101
+
102
+ /** A held section where nothing moves by the scroll: no track, no kinetic line, no gallery the scroll turns. */
103
+ export function layoutHeldStill(s: LayoutSection): boolean {
104
+ if (!s.pin || (s.track ?? 1) > 1 || s.readyMade) return false;
105
+ return !(s.layers ?? []).some(l => !!l.motion?.length || !!l.kinetic || (l.kind === LayoutLayerKind.Gallery && !!l.gallery?.scroll));
106
+ }
107
+
108
+ /**
109
+ * The line a still hold can light word by word: a word, heading or text of 2 to the kinetic words, never over a picture —
110
+ * the lead first, then by size. -1: none.
111
+ */
112
+ export function layoutStillLine(s: LayoutSection): number {
113
+ const sizes = Object.keys(L.sizePx);
114
+ const found = (s.layers ?? [])
115
+ .map((l, li) => ({ l, li }))
116
+ .filter(({ l }) => LAYOUT_KINETIC_KINDS.has(l.kind) && wordsOf(l.text) >= 2 && wordsOf(l.text) <= LIM.kineticWords)
117
+ .filter(({ l }) => !(s.layers ?? []).some(o => o !== l && isPictured(o) && meets(o, l)))
118
+ .sort((a, b) => Number(b.l.role === LayoutRole.Lead) - Number(a.l.role === LayoutRole.Lead) || sizes.indexOf(b.l.size ?? 'm') - sizes.indexOf(a.l.size ?? 'm') || a.li - b.li);
119
+ return found[0]?.li ?? -1;
120
+ }
121
+
122
+ /** A held section's largest photo that may move (not decoration — decoration only fades), for a still hold that cannot
123
+ * let go of the page: -1, none. */
124
+ export function layoutDriftPhoto(s: LayoutSection): number {
125
+ const area = (l: LayoutLayer) => span(l.col) * span(l.row);
126
+ const found = (s.layers ?? []).map((l, li) => ({ l, li }))
127
+ .filter(({ l }) => l.kind === LayoutLayerKind.Photo && l.role !== LayoutRole.Decoration && Array.isArray(l.col) && Array.isArray(l.row))
128
+ .sort((a, b) => area(b.l) - area(a.l) || a.li - b.li);
129
+ return found[0]?.li ?? -1;
130
+ }
131
+
132
+ /** The drift a still hold's photo takes: a slow scale over the whole hold — transform only, inside the track's bounds. */
133
+ export const LAYOUT_DRIFT: Readonly<LayoutTrack> = { prop: LayoutTrackProp.Scale, from: 1, to: 1.08, at: [0, 1] };
134
+
135
+ /** A section whose screen is spoken for: what is on it never leaves it (held, sideways, a photo ground, ready-made), or
136
+ * its space is the point (an inhale — the page's one breath, a word in the quiet). */
137
+ const filled = (s: LayoutSection) => !!s.pin || (s.track ?? 1) > 1 || !!s.readyMade || String(s.ground ?? '').startsWith('photo:')
138
+ || s.kind === LayoutSectionKind.Inhale;
139
+
140
+ /** Where a layer's ink is in its section (px from the section's top): its cell for what stretches, its words' lines in the
141
+ * cell's middle for the rest, the line of a rule. */
142
+ function inkOf(s: LayoutSection, li: number, rowPx: number): [number, number] {
143
+ const l = s.layers[li];
144
+ const t = (l.row[0] - 1) * rowPx;
145
+ const b = (l.row[1] - 1) * rowPx;
146
+ const mid = (t + b) / 2;
147
+ if (l.kind === LayoutLayerKind.Shape && isLayoutRule(s, li)) {
148
+ const edge = layoutRuleEdge(s, li);
149
+ const at = edge === 'start' ? t : edge === 'end' ? b : mid;
150
+ return [at, at];
151
+ }
152
+ if (FULL_CELL.has(l.kind) || l.size === LayoutSize.Screen) return [t, b];
153
+ let h = BUTTON_PX;
154
+ if (isText(l)) {
155
+ const text = textOf(l);
156
+ const px = L.sizePx[(l.size ?? LayoutSize.M) as keyof typeof L.sizePx] ?? L.sizePx.m;
157
+ const w = Math.max(1, span(l.col) * COLUMN_PX);
158
+ const items = l.kind === LayoutLayerKind.List ? Math.max(1, l.items?.length ?? 1) : 1;
159
+ const lines = Math.max(items, Math.ceil((text.length * px * advanceOf(text)) / (w * LIM.textFitSlack)));
160
+ h = lines * px * LAYOUT_LINE_HEIGHT;
161
+ }
162
+ h = Math.min(b - t, h);
163
+ return [mid - h / 2, mid + h / 2];
164
+ }
165
+
166
+ /** A stretch of the laptop's page with nothing on it: where it is (px from the page's top) and the sections it lies in. */
167
+ export interface LayoutVoid {
168
+ from: number;
169
+ to: number;
170
+ sections: number[];
171
+ }
172
+
173
+ /**
174
+ * Every stretch more than `voidScreen` of a screen tall with nothing on it, top to bottom. A section that holds (or is a
175
+ * photo, or ready-made) fills its height; one that flows has its layers' ink (`inkOf`). Judged across the sections, as a
176
+ * visitor scrolls them; the end of the page counts (the footer is not the page's).
177
+ */
178
+ export function layoutVoids(sections: ReadonlyArray<LayoutSection>): LayoutVoid[] {
179
+ const ink: Array<[number, number]> = [];
180
+ const bounds: Array<[number, number]> = [];
181
+ let top = 0;
182
+ for (const s of sections) {
183
+ const height = Math.max(1, Number(s.screens) || 1) * LAYOUT_CHECK_VIEWPORT.height;
184
+ bounds.push([top, top + height]);
185
+ if (filled(s)) ink.push([top, top + height]);
186
+ else {
187
+ const rowPx = height / Math.max(1, s.rows);
188
+ (s.layers ?? []).forEach((l, li) => {
189
+ if (!Array.isArray(l.row) || !Array.isArray(l.col)) return;
190
+ const [a, b] = inkOf(s, li, rowPx);
191
+ ink.push([top + a, top + b]);
192
+ });
193
+ }
194
+ top += height;
195
+ }
196
+ ink.sort((a, b) => a[0] - b[0]);
197
+ const voids: LayoutVoid[] = [];
198
+ const least = LIM.voidScreen * LAYOUT_CHECK_VIEWPORT.height;
199
+ let end = 0;
200
+ const push = (from: number, to: number) => {
201
+ if (to - from <= least) return;
202
+ const within = bounds.map((b, i) => (b[0] < to && from < b[1] ? i : -1)).filter(i => i >= 0);
203
+ voids.push({ from: Math.round(from), to: Math.round(to), sections: within });
204
+ };
205
+ for (const [a, b] of ink) {
206
+ push(end, a);
207
+ end = Math.max(end, b);
208
+ }
209
+ push(end, top);
210
+ return voids;
211
+ }
212
+
213
+ /**
214
+ * The heights that close every void: the sections a void lies in that flow come down a quarter screen at a time (never
215
+ * under one screen; their rows keep their share, and each of their words still fits) until no void is left. Null when
216
+ * that cannot close them — then the model is asked.
217
+ */
218
+ export function layoutVoidScreens(sections: ReadonlyArray<LayoutSection>): Array<{ section: number; screens: number }> | null {
219
+ const next = sections.map(s => ({ ...s }));
220
+ const stuck = new Set<number>();
221
+ for (let tries = 0; tries < SCREENS_TRIES; tries++) {
222
+ const voids = layoutVoids(next);
223
+ if (!voids.length) {
224
+ return next.map((s, i) => ({ section: i, screens: s.screens })).filter(({ section, screens }) => screens !== sections[section].screens);
225
+ }
226
+ const free = [...new Set(voids.flatMap(v => v.sections))]
227
+ .filter(i => !filled(next[i]) && !stuck.has(i) && next[i].screens > 1)
228
+ .sort((a, b) => next[b].screens - next[a].screens || a - b);
229
+ if (!free.length) return null;
230
+ const i = free[0];
231
+ const lower = { ...next[i], screens: Math.max(1, Math.round((next[i].screens - SCREENS_STEP) * 100) / 100) };
232
+ if ((lower.layers ?? []).every(l => layoutTextFits(l, lower))) next[i] = lower;
233
+ else stuck.add(i);
234
+ }
235
+ return null;
236
+ }
237
+
238
+ /** The layers that make an opening's display: a word (set in the display face), or words at xxl or screen size. */
239
+ export function layoutOpeningDisplays(page: Pick<LayoutPage, 'sections'>): number[] {
240
+ const first = page.sections?.[0];
241
+ if (!first || first.readyMade) return [];
242
+ return (first.layers ?? []).map((l, li) => ({ l, li }))
243
+ .filter(({ l }) => isText(l) && (l.kind === LayoutLayerKind.Word || l.size === LayoutSize.Screen || l.size === LayoutSize.Xxl))
244
+ .map(({ li }) => li);
245
+ }
246
+
247
+ /**
248
+ * The opening's lead set as its display (a word) where it can be: a heading of at most `xl`'s characters. Its size goes
249
+ * up to xl where it still fits there. Null: no such lead.
250
+ */
251
+ export function layoutOpeningDisplayMend(page: Pick<LayoutPage, 'sections'>): { layer: number; size?: `${LayoutSize}` } | null {
252
+ const first = page.sections?.[0];
253
+ if (!first || first.readyMade) return null;
254
+ const li = (first.layers ?? []).findIndex(l => l.role === LayoutRole.Lead && l.kind === LayoutLayerKind.Heading);
255
+ if (li < 0) return null;
256
+ const lead = first.layers[li];
257
+ if (textOf(lead).length > L.maxChars.xl) return null;
258
+ const small = lead.size !== LayoutSize.Xl && lead.size !== LayoutSize.Xxl;
259
+ return small && layoutTextFits(lead, first, LayoutSize.Xl) ? { layer: li, size: LayoutSize.Xl } : { layer: li };
260
+ }
@@ -8,7 +8,7 @@ import { patternById } from './patterns';
8
8
  import { SerializedNode, walkSerialized } from './serialized-node';
9
9
  import { SitePlan } from './site-plan.model';
10
10
  import { STOCK_INTENT_ORDER, StockIntent } from './stock-match';
11
- import { OwnPhotoPlacement, planOwnPhotos, stockItemSlots, StockSlotKind, stockSlots, StockTarget } from './stock-photos';
11
+ import { OwnPhoto, OwnPhotoPlacement, planOwnPhotos, stockItemSlots, StockSlotKind, stockSlots, StockTarget } from './stock-photos';
12
12
 
13
13
  /**
14
14
  * Pictures MADE for a site (premium-components M7, AI plan I3, premium sites PS4) — pure and deterministic: which picture
@@ -96,8 +96,8 @@ export interface PicturePlan {
96
96
  }
97
97
 
98
98
  export interface PicturePlanOptions {
99
- /** The owner's own photos (urls), in order. */
100
- ownPhotos?: ReadonlyArray<string>;
99
+ /** The owner's own photos (urls, with what each shows), in order. */
100
+ ownPhotos?: ReadonlyArray<string | OwnPhoto>;
101
101
  /** The business type's rule (harness-core `BusinessType.stock`): where stock may not stand in for the work, no made
102
102
  * picture may either. */
103
103
  stockAllowed: boolean;
@@ -50,5 +50,6 @@ export * from './layout-section-fallback';
50
50
  export * from './layout-photos';
51
51
  export * from './photo-inventory';
52
52
  export * from './check-layout';
53
+ export * from './layout-space';
53
54
  export * from './layout-fingerprint';
54
55
  export * from './layout-edits';
@@ -6203,6 +6203,8 @@ export const SPEC_SITE_LAYOUT = {
6203
6203
  "distinct": {
6204
6204
  "holdsMax": 1
6205
6205
  },
6206
+ "voidScreen": 0.6,
6207
+ "bandColumns": 10,
6206
6208
  "composedPages": 2,
6207
6209
  "repairs": 1
6208
6210
  },