@vectoriox/iox-ui 5.155.0 → 5.157.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectoriox/iox-ui",
3
- "version": "5.155.0",
3
+ "version": "5.157.0",
4
4
  "peerDependencies": {
5
5
  "@angular/common": ">=20.0.0",
6
6
  "@angular/core": ">=20.0.0",
@@ -0,0 +1,375 @@
1
+ import {
2
+ DesignTokenLike, elementStyleById, parseHexColor, ResolvedMode, resolveTokenValues, wcagContrastRatio,
3
+ } from '@vectoriox/iox-ui/design-core';
4
+ import {
5
+ FREE_ELEMENT_STYLES, FREE_HOLDERS, FREE_LEAD_ROLE, FREE_MOVES, FREE_PHONE_LAYERS, FREE_WORD_TYPES, FreeLayer, FreeNode,
6
+ FreeNodeType, FreePage, FreePictures, FreePurpose, FreeStyle, FreeTrigger, walkFree,
7
+ } from './free-wire';
8
+ import { factIssues, PlanWordContext, WrittenText } from './plan-words';
9
+ import { PageSectionPlan } from './site-plan.model';
10
+ import { PathIssue } from './shape-check';
11
+
12
+ /**
13
+ * THE FREE PAGE'S JUDGE (award plan §11.4 gates 1 + 2, FS3): every reason a free page may not be stamped, path first,
14
+ * in words the model can act on in its one repair. It judges SAFETY, LAW and TRUTH — never taste (R-H18): what is the
15
+ * look's stays a token (R-H1), a phone layer exists where a phone needs one (R-H4), no fact is invented (R-H6, the ONE
16
+ * `factIssues`), only what exists is named (R-H2), the words read on their ground (R-H12), and the answer says which of
17
+ * the owner's words it followed (R-H17). A place the fall back gave to a ready-made section (`readyMade`) is the plan's,
18
+ * not the model's: it is skipped, and the page rules that section would answer are relaxed. Pure.
19
+ */
20
+
21
+ export enum FreeIssueCode {
22
+ /** The page's structure: section count, ids, nesting, h1, lead, a closing action, a phone layout. */
23
+ Structure = 'structure',
24
+ /** A word node's words or element style. */
25
+ Words = 'words',
26
+ /** A style: a property outside the list, a value that is not one plain value, a side that is not start / end. */
27
+ Style = 'style',
28
+ /** A value the look owns written as something other than its token. */
29
+ Token = 'token',
30
+ /** A node a phone cannot hold as written, with no phone layer. */
31
+ Phone = 'phone',
32
+ /** A move: not the product's, two on a node, on the wrong node. */
33
+ Motion = 'motion',
34
+ /** A fact the owner never gave, a material id, a slot or a link that does not exist. */
35
+ Content = 'content',
36
+ /** Words that do not read on their ground (AA). */
37
+ Contrast = 'contrast',
38
+ /** The followed line is missing or quotes none of the owner's words. */
39
+ Prompt = 'prompt',
40
+ }
41
+
42
+ export type FreeIssue = PathIssue<FreeIssueCode>;
43
+
44
+ /** What a placed slot is, and the options it may carry (a list's mix words). */
45
+ export interface FreeSlotOffer {
46
+ kind: 'list' | 'form';
47
+ /** The list alias (`list:<alias>`) or the forms-core preset (`form:<preset>`). */
48
+ ref: string;
49
+ opts?: ReadonlyArray<string>;
50
+ }
51
+
52
+ export interface FreeJudgeContext {
53
+ /** The studio's token rows (with their types) — what a token reference may name and what it resolves to. */
54
+ tokens: ReadonlyArray<DesignTokenLike>;
55
+ /** The modes the site shows (the look's mode, or both under `auto`). */
56
+ modes?: ReadonlyArray<ResolvedMode>;
57
+ /** The material the page may place, by id. */
58
+ material: Readonly<Record<string, { kind: 'image' | 'video' }>>;
59
+ /** The slots this page was offered, by slot word (`list:projects`). */
60
+ slots?: Readonly<Record<string, FreeSlotOffer>>;
61
+ /** The site's page routes a Button may go to. */
62
+ pages: ReadonlyArray<string>;
63
+ /** Facts: the owner's own, and the owner's texts (the prompt, the material's words) — what a number may come from. */
64
+ facts: PlanWordContext['facts'];
65
+ known?: ReadonlyArray<string>;
66
+ avoidWords?: ReadonlyArray<string>;
67
+ /** The words the reading took from the owner's prompt — the followed line quotes one (R-H17). */
68
+ said?: ReadonlyArray<string>;
69
+ /** Home: a business with videos plays one there. */
70
+ home?: boolean;
71
+ }
72
+
73
+ /** A free page is this many sections. */
74
+ export const FREE_SECTIONS = { min: 4, max: 9 } as const;
75
+ /** Above this, a node needs its own phone layer. */
76
+ export const FREE_PHONE_LIMITS = { width: 340, fontSize: 44, turn: 8 } as const;
77
+ /** WCAG AA: words, and large words (display, h1, h2). */
78
+ export const FREE_CONTRAST = { text: 4.5, large: 3 } as const;
79
+ const LARGE_STYLES: ReadonlyArray<string> = ['display', 'h1', 'h2'];
80
+
81
+ /** The style properties whose value is the LOOK's: a token of this type, or one of the listed plain words. */
82
+ export const FREE_TOKEN_PROPS: Readonly<Record<string, string>> = {
83
+ color: 'color', backgroundColor: 'color', borderColor: 'color', outlineColor: 'color', textDecorationColor: 'color',
84
+ fontFamily: 'font', borderRadius: 'radius', boxShadow: 'shadow', transitionDuration: 'duration', transitionTimingFunction: 'easing',
85
+ };
86
+ const TOKEN_PLAIN: Readonly<Record<string, ReadonlyArray<string>>> = {
87
+ color: ['transparent', 'currentColor', 'inherit'], font: ['inherit'], radius: ['0', '0px', '50%'], shadow: ['none'], duration: [], easing: [],
88
+ };
89
+ /** A colour token may be either of these token types. */
90
+ const COLOUR_TYPES: ReadonlyArray<string> = ['color', 'paint'];
91
+ /** The free properties: geometry, arrangement, type scale and rhythm, clipping, blending. */
92
+ export const FREE_STYLE_PROPS: ReadonlyArray<string> = [
93
+ 'display', 'position', 'top', 'bottom', 'insetInlineStart', 'insetInlineEnd', 'zIndex', 'order',
94
+ 'width', 'minWidth', 'maxWidth', 'height', 'minHeight', 'maxHeight', 'aspectRatio', 'overflow',
95
+ 'margin', 'marginTop', 'marginBottom', 'marginInlineStart', 'marginInlineEnd', 'marginInline', 'marginBlock',
96
+ 'padding', 'paddingTop', 'paddingBottom', 'paddingInlineStart', 'paddingInlineEnd', 'paddingInline', 'paddingBlock',
97
+ 'gridTemplateColumns', 'gridTemplateRows', 'gridColumn', 'gridRow', 'gap', 'rowGap', 'columnGap',
98
+ 'flexDirection', 'flexWrap', 'flex', 'alignItems', 'alignContent', 'justifyContent', 'alignSelf', 'justifySelf', 'placeItems', 'placeSelf',
99
+ 'fontSize', 'fontWeight', 'lineHeight', 'letterSpacing', 'textTransform', 'textAlign', 'fontStyle', 'textWrap', 'whiteSpace',
100
+ 'translateX', 'translateY', 'rotate', 'scaleX', 'scaleY', 'transformOrigin',
101
+ 'clipPath', 'opacity', 'mixBlendMode', 'objectFit', 'objectPosition', 'borderWidth', 'borderStyle', 'filter', 'backdropFilter',
102
+ ];
103
+ /** A hover changes position, scale, turn, opacity or a colour token — never layout (Emil: transform / opacity only). */
104
+ export const FREE_HOVER_PROPS: ReadonlyArray<string> = ['translateX', 'translateY', 'scaleX', 'scaleY', 'rotate', 'opacity', 'color', 'backgroundColor', 'borderColor', 'boxShadow'];
105
+
106
+ const PHYSICAL = /^(left|right|marginLeft|marginRight|paddingLeft|paddingRight|borderLeft.*|borderRight.*|insetLeft|insetRight)$/;
107
+ const UNSAFE = /[;{}<>\\]|!important|url\s*\(|expression|@import|javascript:/i;
108
+ const LITERAL_COLOUR = /#[0-9a-f]{3,8}\b|\b(rgb|rgba|hsl|hsla|oklch|oklab|lab|lch|hwb)\s*\(/i;
109
+ const NAMED_COLOUR = /\b(white|black|red|blue|green|yellow|orange|purple|pink|gray|grey|gold|navy|teal|beige|ivory|cream)\b/i;
110
+ const TOKEN_REF = /var\(\s*--iox-([a-z0-9-]+)\s*(?:,[^)]*)?\)/g;
111
+ const ONE_TOKEN = /^var\(--iox-([a-z0-9-]+)\)$/;
112
+ const COLOUR_MIX = /^color-mix\(in (oklab|srgb), var\(--iox-[a-z0-9-]+\) \d{1,3}%, transparent\)$/;
113
+ const ANCHOR = /^#[a-z][\w-]*$/;
114
+ /** FS-T5: a size relative to the WINDOW's width (vw and its kin) — on the canvas, a transformed frame, the window is not
115
+ * the page. A size relative to the width is `cqi` (the page's / section's inline size), and only `cqi`. */
116
+ const WINDOW_WIDTH_UNIT = /(-?\d*\.?\d+)(?:[dsl]?vw|[dsl]?vi|[dsl]?vmin|[dsl]?vmax)(?![a-z])/i;
117
+ const OTHER_CQ_UNIT = /(-?\d*\.?\d+)(?:cqw|cqh|cqb|cqmin|cqmax)(?![a-z])/i;
118
+ const A_NUMBER = /^\D{0,3}\d[\d,.]*\D{0,3}$/;
119
+ /** The ground a page paints when no node does. */
120
+ const PAGE_GROUND = 'page-bg';
121
+
122
+ const tokensIn = (v: string) => [...v.matchAll(TOKEN_REF)].map(m => m[1]);
123
+ const oneToken = (v: unknown) => ONE_TOKEN.exec(String(v ?? '').trim())?.[1];
124
+ const px = (v: unknown) => { const m = /^(-?[\d.]+)px$/.exec(String(v ?? '').trim()); return m ? Number(m[1]) : null; };
125
+ const columnsOf = (v: unknown) => {
126
+ const s = String(v ?? '').trim();
127
+ const rep = /repeat\(\s*(\d+)/.exec(s);
128
+ return rep ? Number(rep[1]) : s.split(/\s+(?![^(]*\))/).filter(Boolean).length;
129
+ };
130
+ const hasPhoneLayer = (n: FreeNode) => FREE_PHONE_LAYERS.some(bp => Object.keys(n.responsive?.[bp as FreeLayer] ?? {}).length > 0);
131
+
132
+ /** One style map against the rules: a known property, one clean value, the look's token where the look owns it. */
133
+ export function freeStyleIssues(style: FreeStyle | undefined, path: string, ctx: Pick<FreeJudgeContext, 'tokens'>): FreeIssue[] {
134
+ const out: FreeIssue[] = [];
135
+ const types = new Map(ctx.tokens.map(t => [t.name, t.type]));
136
+ const say = (code: FreeIssueCode, prop: string, message: string) => out.push({ code, path: `${path}.${prop}`, message });
137
+ for (const [prop, raw] of Object.entries(style ?? {})) {
138
+ const v = String(raw).trim();
139
+ const kind = FREE_TOKEN_PROPS[prop];
140
+ if (PHYSICAL.test(prop)) { say(FreeIssueCode.Style, prop, 'write sides as start / end (insetInlineStart, marginInlineEnd …) — the site also runs right to left'); continue; }
141
+ if (!kind && !FREE_STYLE_PROPS.includes(prop)) { say(FreeIssueCode.Style, prop, 'not a style property this language has'); continue; }
142
+ if (!v || UNSAFE.test(v)) { say(FreeIssueCode.Style, prop, 'a value is one plain value — no url(), no ; { } !important'); continue; }
143
+ if (prop === 'textAlign' && /^(left|right)$/.test(v)) { say(FreeIssueCode.Style, prop, 'start | end | center'); continue; }
144
+ const win = WINDOW_WIDTH_UNIT.exec(v);
145
+ if (win) { say(FreeIssueCode.Style, prop, `"${win[0]}" follows the window, not the page — a size relative to the width is cqi: ${win[1]}cqi`); continue; }
146
+ const cq = OTHER_CQ_UNIT.exec(v);
147
+ if (cq) { say(FreeIssueCode.Style, prop, `"${cq[0]}" — a size relative to the width is cqi only: ${cq[1]}cqi`); continue; }
148
+ if (LITERAL_COLOUR.test(v) || (kind === 'color' && NAMED_COLOUR.test(v))) { say(FreeIssueCode.Token, prop, 'a literal colour — colours are the look\'s tokens: var(--iox-<colour token>)'); continue; }
149
+ if (!kind) continue;
150
+ const named = tokensIn(v);
151
+ const plain = TOKEN_PLAIN[kind].includes(v);
152
+ const mixed = kind === 'color' && COLOUR_MIX.test(v);
153
+ if (!plain && !mixed && !(named.length === 1 && v === `var(--iox-${named[0]})`)) {
154
+ const words = TOKEN_PLAIN[kind].length ? ` or ${TOKEN_PLAIN[kind].join(' / ')}` : '';
155
+ say(FreeIssueCode.Token, prop, `the look owns this — var(--iox-<${kind} token>)${words}${kind === 'color' ? ', or color-mix(in oklab, var(--iox-…) N%, transparent)' : ''}`);
156
+ continue;
157
+ }
158
+ for (const name of named) {
159
+ const type = types.get(name);
160
+ const fits = kind === 'color' ? COLOUR_TYPES.includes(type ?? '') : type === kind;
161
+ if (!fits) say(FreeIssueCode.Token, prop, `--iox-${name} is ${type ? `a ${type} token` : 'not a token of this look'} — a ${kind} token belongs here`);
162
+ }
163
+ }
164
+ return out;
165
+ }
166
+
167
+ /** Every reason a free page may not be stamped (gate 1), contrast included (gate 2's tree half). */
168
+ export function checkFree(page: FreePage, ctx: FreeJudgeContext): FreeIssue[] {
169
+ return judgeFree(page, ctx, false);
170
+ }
171
+
172
+ /**
173
+ * FS-D19 Basic: ONE free signature section on a page otherwise made of the plan's ready-made sections. The answer is a
174
+ * free page holding one Section; it is judged in its place (`at`) among the plan's sections — so the page rules hold
175
+ * for the page as the visitor sees it (a ready-made opening carries the h1 and the lead, a ready-made close the action;
176
+ * the section count is the plan's) — and every issue is said against the answer (`sections[0]…`), for its one repair.
177
+ */
178
+ export function checkFreeSection(answer: FreePage, ctx: FreeJudgeContext, place: { plan: ReadonlyArray<PageSectionPlan>; at: number }): FreeIssue[] {
179
+ const sections = Array.isArray(answer?.sections) ? answer.sections : [];
180
+ if (sections.length !== 1 || place.at < 0 || place.at >= place.plan.length) {
181
+ return [{ code: FreeIssueCode.Structure, path: 'sections', message: `a signature section is ONE Section (this answer has ${sections.length})` }];
182
+ }
183
+ const page = freeSignaturePage(answer, place.plan, place.at);
184
+ const here = `sections[${place.at}]`;
185
+ return judgeFree(page, ctx, true).map(i => ({ ...i, path: i.path === here || i.path.startsWith(`${here}.`) ? `sections[0]${i.path.slice(here.length)}` : i.path }));
186
+ }
187
+
188
+ /** The page a signature section stands in: the plan's ready-made sections, the free one at `at` in place of that one. */
189
+ export function freeSignaturePage(answer: FreePage, plan: ReadonlyArray<PageSectionPlan>, at: number): FreePage {
190
+ return {
191
+ ...answer,
192
+ sections: plan.map((p, i) => (i === at ? answer.sections[0] : { id: `ready-${i}`, type: FreeNodeType.Section, styleProps: {}, readyMade: { at: i, pattern: p.pattern } })),
193
+ };
194
+ }
195
+
196
+ function judgeFree(page: FreePage, ctx: FreeJudgeContext, signature: boolean): FreeIssue[] {
197
+ const issues: FreeIssue[] = [];
198
+ const say = (code: FreeIssueCode, path: string, message: string) => issues.push({ code, path, message });
199
+ const sections = Array.isArray(page?.sections) ? page.sections : [];
200
+ if (!signature && (sections.length < FREE_SECTIONS.min || sections.length > FREE_SECTIONS.max)) say(FreeIssueCode.Structure, 'sections', `a page is ${FREE_SECTIONS.min} to ${FREE_SECTIONS.max} sections (this one has ${sections.length})`);
201
+ const ready = (i: number) => !!sections[i]?.readyMade;
202
+ const walked = walkFree(sections).filter(w => !ready(w.section));
203
+ const ids = new Set(walkFree(sections).map(w => w.node.id));
204
+ const seen = new Set<string>();
205
+ const texts: WrittenText[] = [];
206
+ let h1 = 0;
207
+ for (const { node, path, up } of walked) {
208
+ if (!Object.values(FreeNodeType).includes(node.type)) { say(FreeIssueCode.Structure, path, `"${node.type}" is not a node type — ${Object.values(FreeNodeType).join(', ')}`); continue; }
209
+ if (!node.id || seen.has(node.id)) say(FreeIssueCode.Structure, path, node.id ? `the id "${node.id}" is used twice` : 'every node needs its own id');
210
+ seen.add(node.id);
211
+ if ((node.type === FreeNodeType.Section) !== (up.length === 0)) say(FreeIssueCode.Structure, path, up.length ? 'a Section sits at the top of the page only — use a Container inside' : 'the top of the page holds Sections only');
212
+ if (node.type === FreeNodeType.Section && !Object.values(FreePurpose).includes(node.purpose as FreePurpose)) say(FreeIssueCode.Structure, path, `a section says what it is for — purpose: ${Object.values(FreePurpose).join(' | ')}`);
213
+ if (node.children?.length && !FREE_HOLDERS.includes(node.type)) say(FreeIssueCode.Structure, path, `a ${node.type} holds no children`);
214
+ const styles = FREE_ELEMENT_STYLES[node.type] ?? [];
215
+ if (node.elementStyle && !styles.includes(node.elementStyle)) say(FreeIssueCode.Words, `${path}.elementStyle`, styles.length ? `"${node.elementStyle}" is not a style a ${node.type} wears — ${styles.join(', ')}` : `a ${node.type} wears no element style`);
216
+
217
+ if (FREE_WORD_TYPES.includes(node.type)) {
218
+ if (!String(node.text ?? '').trim()) say(FreeIssueCode.Words, `${path}.text`, 'its words are missing');
219
+ else texts.push({ path: `${path}.text`, text: String(node.text) });
220
+ if (!node.elementStyle) say(FreeIssueCode.Words, `${path}.elementStyle`, `a ${node.type} wears one of the look's element styles (${styles.join(', ')}) and changes what it needs on top`);
221
+ if (node.type === FreeNodeType.Heading) {
222
+ if (!Number.isInteger(node.level) || node.level! < 1 || node.level! > 4) say(FreeIssueCode.Words, `${path}.level`, 'a Heading is level 1 to 4');
223
+ if (node.level === 1) h1++;
224
+ }
225
+ if (node.type === FreeNodeType.Button && !ctx.pages.includes(node.href ?? '') && !(ANCHOR.test(node.href ?? '') && ids.has(node.href!.slice(1)))) {
226
+ say(FreeIssueCode.Content, `${path}.href`, `a button goes to a page of this site (${ctx.pages.join(', ')}) or to a section of this page (#id)`);
227
+ }
228
+ }
229
+ if (node.role && (node.role !== FREE_LEAD_ROLE || node.type !== FreeNodeType.Heading)) say(FreeIssueCode.Structure, `${path}.role`, 'role "lead" is for the heading a visitor reads first');
230
+ if (node.type === FreeNodeType.Image || node.type === FreeNodeType.Video) {
231
+ const m = ctx.material[node.src ?? ''];
232
+ if (!m) say(FreeIssueCode.Content, `${path}.src`, `"${node.src ?? ''}" is not in the material — use an id from the list`);
233
+ else if ((node.type === FreeNodeType.Video) !== (m.kind === 'video')) say(FreeIssueCode.Content, `${path}.src`, `"${node.src}" is a${m.kind === 'image' ? 'n image' : ' video'} — ${node.type === FreeNodeType.Video ? 'a Video plays a video' : 'an Image shows a picture'}`);
234
+ }
235
+ if (node.type === FreeNodeType.Slot) {
236
+ const offer = ctx.slots?.[node.slot ?? ''];
237
+ if (!offer) say(FreeIssueCode.Content, `${path}.slot`, `"${node.slot ?? ''}" is not a part this page may place — ${Object.keys(ctx.slots ?? {}).join(', ') || 'none'}`);
238
+ else for (const [k, o] of (node.opts ?? []).entries()) if (!(offer.opts ?? []).includes(o)) say(FreeIssueCode.Content, `${path}.opts[${k}]`, `"${o}" is not how this part may show — ${(offer.opts ?? []).join(', ') || 'no options'}`);
239
+ } else if (node.slot || node.opts?.length) say(FreeIssueCode.Structure, path, 'only a Slot places a part');
240
+
241
+ // styles, layer by layer
242
+ issues.push(...freeStyleIssues(node.styleProps, `${path}.styleProps`, ctx));
243
+ for (const [bp, style] of Object.entries(node.responsive ?? {})) {
244
+ if (!(Object.values(FreeLayer) as string[]).includes(bp)) { say(FreeIssueCode.Style, `${path}.responsive.${bp}`, `not a width — ${Object.values(FreeLayer).join(', ')}`); continue; }
245
+ issues.push(...freeStyleIssues(style, `${path}.responsive.${bp}`, ctx));
246
+ }
247
+ for (const prop of Object.keys(node.hover ?? {})) if (!FREE_HOVER_PROPS.includes(prop)) say(FreeIssueCode.Style, `${path}.hover.${prop}`, `a hover changes position, scale, turn, opacity or a colour token only (${FREE_HOVER_PROPS.join(', ')}) — never layout`);
248
+ issues.push(...freeStyleIssues(Object.fromEntries(Object.entries(node.hover ?? {}).filter(([p]) => FREE_HOVER_PROPS.includes(p))), `${path}.hover`, ctx));
249
+
250
+ // the one move
251
+ if (node.move) {
252
+ const spec = FREE_MOVES[node.move.trigger]?.[node.move.action];
253
+ if (!spec) say(FreeIssueCode.Motion, `${path}.move`, `under ${node.move.trigger} one of: ${Object.keys(FREE_MOVES[node.move.trigger] ?? {}).join(', ')}`);
254
+ else {
255
+ const value = spec.param ? node.move.params?.[spec.param] : undefined;
256
+ if (spec.param && value !== undefined && !spec.values?.includes(value)) say(FreeIssueCode.Motion, `${path}.move`, `${spec.param} is one of ${spec.values?.join(', ')}`);
257
+ if (node.move.action === 'revealText' && node.type !== FreeNodeType.Heading && node.type !== FreeNodeType.Text) say(FreeIssueCode.Motion, `${path}.move`, 'revealText lights words — on a Heading or a Text');
258
+ if (node.move.action === 'countUp' && !A_NUMBER.test(String(node.text ?? '').trim())) say(FreeIssueCode.Motion, `${path}.move`, 'countUp counts a number — on a Heading or Text whose words ARE a number the owner gave');
259
+ if (node.move.trigger === FreeTrigger.Scroll && up.length === 0) say(FreeIssueCode.Motion, `${path}.move`, 'a whole section never travels with the scroll — move a layer inside it');
260
+ }
261
+ }
262
+
263
+ // the phone: anything a 390px screen cannot hold as written needs its own layer
264
+ const base = node.styleProps ?? {};
265
+ const needs: string[] = [];
266
+ if (base['gridTemplateColumns'] && columnsOf(base['gridTemplateColumns']) >= 2) needs.push('its columns');
267
+ if (base['position'] === 'absolute') needs.push('its absolute place');
268
+ if ((px(base['width']) ?? 0) > FREE_PHONE_LIMITS.width || (px(base['minWidth']) ?? 0) > FREE_PHONE_LIMITS.width) needs.push('its fixed width');
269
+ if ((px(base['fontSize']) ?? 0) > FREE_PHONE_LIMITS.fontSize) needs.push('its type size (or write it as clamp(min, cqi, max))');
270
+ if (base['rotate'] && FREE_WORD_TYPES.includes(node.type) && Math.abs(parseFloat(base['rotate'])) > FREE_PHONE_LIMITS.turn) needs.push('its turn');
271
+ if (needs.length && !hasPhoneLayer(node)) say(FreeIssueCode.Phone, `${path}.responsive`, `needs a phone layer for ${needs.join(', ')}`);
272
+ }
273
+
274
+ // facts: the ONE judge, numbers included (R-H6)
275
+ for (const i of factIssues(texts, { avoidWords: ctx.avoidWords ?? [], facts: ctx.facts, known: ctx.known, numbers: true, quotes: true })) say(FreeIssueCode.Content, i.path, i.message);
276
+
277
+ // the page
278
+ const openingReady = ready(0);
279
+ if (openingReady ? h1 !== 0 : h1 !== 1) say(FreeIssueCode.Structure, 'sections', openingReady ? 'the opening carries the page\'s level-1 heading — use level 2 or lower' : `a page has exactly one Heading of level 1 (this one has ${h1})`);
280
+ if (sections[0] && !openingReady && !walkFree([sections[0]]).some(w => w.node.role === FREE_LEAD_ROLE)) say(FreeIssueCode.Structure, 'sections[0]', 'the first section names its lead — role "lead" on the heading a visitor reads first');
281
+ sections.forEach((s, i) => {
282
+ if (!ready(i) && !walkFree([s]).some(w => hasPhoneLayer(w.node))) say(FreeIssueCode.Phone, `sections[${i}]`, 'a phone layout is required — at least one node of every section carries a phone layer');
283
+ });
284
+ const last = sections.length - 1;
285
+ if (last >= 0 && !ready(last) && !walkFree([sections[last]]).some(w => w.node.type === FreeNodeType.Button)) say(FreeIssueCode.Structure, `sections[${last}]`, 'the page ends on something to do — a Button in the last section');
286
+ const hasVideos = Object.values(ctx.material).some(m => m.kind === 'video');
287
+ if (ctx.home && hasVideos && !sections.some(s => s.readyMade) && !walked.some(w => w.node.type === FreeNodeType.Video)) say(FreeIssueCode.Content, 'sections', 'this business has videos — the home page plays at least one (a Video node)');
288
+ if (!(Object.values(FreePictures) as string[]).includes(page?.pictures)) say(FreeIssueCode.Structure, 'pictures', `one word: ${Object.values(FreePictures).join(', ')}`);
289
+ issues.push(...followedIssues(page, ctx));
290
+ issues.push(...freeContrastIssues(page, ctx));
291
+ return issues;
292
+ }
293
+
294
+ /**
295
+ * THE OWNER'S PROMPT LEADS (§11.4a, R-H17): the followed line is there, and — when the reading took words from the prompt
296
+ * — it quotes at least one AS WRITTEN. Never a judgement of taste.
297
+ */
298
+ export function followedIssues(page: Pick<FreePage, 'read'>, ctx: Pick<FreeJudgeContext, 'said'>): FreeIssue[] {
299
+ const line = String(page?.read?.followed ?? '').trim();
300
+ if (!line) return [{ code: FreeIssueCode.Prompt, path: 'read.followed', message: 'say in one line the owner can read which of their words this page followed' }];
301
+ const said = (ctx.said ?? []).map(w => String(w).trim()).filter(Boolean);
302
+ const lower = line.toLowerCase();
303
+ if (said.length && !said.some(w => lower.includes(w.toLowerCase()))) {
304
+ return [{ code: FreeIssueCode.Prompt, path: 'read.followed', message: `the line names none of the owner's own words — quote at least one as they wrote it (${said.slice(0, 6).join(', ')})` }];
305
+ }
306
+ return [];
307
+ }
308
+
309
+ /** The token a node's words are painted in: its own colour, else its element style's; `inherit` reads up the tree. */
310
+ function inkOf(node: FreeNode, up: ReadonlyArray<FreeNode>): string | undefined {
311
+ for (const n of [node, ...[...up].reverse()]) {
312
+ const v = n.styleProps?.['color'] ?? elementStyleById(n.elementStyle)?.base['color'];
313
+ if (v === undefined || v === 'inherit' || v === 'currentColor') continue;
314
+ return oneToken(v);
315
+ }
316
+ return 'text';
317
+ }
318
+
319
+ /**
320
+ * The tokens a node's words may sit on, nearest first: its own ground, then each ancestor's, then the page's. `null` in
321
+ * the list is a ground that is no single token (a colour-mix): nothing past it can be judged from tokens.
322
+ */
323
+ function groundsOf(node: FreeNode, up: ReadonlyArray<FreeNode>): Array<string | null> {
324
+ const out: Array<string | null> = [];
325
+ for (const n of [node, ...[...up].reverse()]) {
326
+ const v = n.styleProps?.['backgroundColor'] ?? elementStyleById(n.elementStyle)?.base['backgroundColor'];
327
+ if (v === undefined || v === 'transparent') continue;
328
+ out.push(oneToken(v) ?? null);
329
+ }
330
+ return [...out, PAGE_GROUND];
331
+ }
332
+
333
+ /** A resolved ground that paints nothing (`transparent`, an alpha of 0) lets the one behind it show. */
334
+ const CLEAR = /^(transparent|rgba?\([^)]*,\s*0(\.0+)?\s*\)|#[0-9a-f]{6}00)$/i;
335
+
336
+ /** The hex the words sit on in one mode, or null when it cannot be told from tokens (left to the real pixels). */
337
+ function groundHex(grounds: ReadonlyArray<string | null>, values: Readonly<Record<string, string>>): { token: string; hex: string } | null {
338
+ for (const token of grounds) {
339
+ if (token === null) return null;
340
+ const value = String(values[token] ?? '').trim();
341
+ if (CLEAR.test(value)) continue;
342
+ return parseHexColor(value) ? { token, hex: value } : null;
343
+ }
344
+ return null;
345
+ }
346
+
347
+ /**
348
+ * THE TREE PAIR CHECK (R-H12, gate 2's tree half — `auditDesignContrast` judges the look, not a tree): each Heading's and
349
+ * Text's ink token against the ground token of the nearest painted node, resolved in every mode the site shows, AA
350
+ * (4.5, 3 for display / h1 / h2). A pair that is not two hex tokens (a colour-mix, a picture behind) is left to the
351
+ * real-pixel check. A Button paints its own pair through its element style, which the look's audit already covers.
352
+ */
353
+ export function freeContrastIssues(page: FreePage, ctx: Pick<FreeJudgeContext, 'tokens' | 'modes'>): FreeIssue[] {
354
+ const out: FreeIssue[] = [];
355
+ const resolved = (ctx.modes?.length ? ctx.modes : (['light'] as ResolvedMode[])).map(mode => ({ mode, values: resolveTokenValues(ctx.tokens, mode) }));
356
+ for (const { node, path, up, section } of walkFree(page?.sections ?? [])) {
357
+ if (page.sections[section]?.readyMade) continue;
358
+ if (node.type !== FreeNodeType.Heading && node.type !== FreeNodeType.Text) continue;
359
+ const ink = inkOf(node, up);
360
+ if (!ink) continue;
361
+ const grounds = groundsOf(node, up);
362
+ const need = LARGE_STYLES.includes(node.elementStyle ?? '') ? FREE_CONTRAST.large : FREE_CONTRAST.text;
363
+ for (const { mode, values } of resolved) {
364
+ const a = values[ink];
365
+ const ground = groundHex(grounds, values);
366
+ if (!a || !ground || !parseHexColor(a)) continue;
367
+ const ratio = wcagContrastRatio(a, ground.hex);
368
+ if (ratio < need) {
369
+ out.push({ code: FreeIssueCode.Contrast, path: `${path}.styleProps.color`, message: `--iox-${ink} on --iox-${ground.token} is ${ratio.toFixed(1)}:1 in ${mode} (needs ${need}) — another colour token for the words or the ground` });
370
+ break;
371
+ }
372
+ }
373
+ }
374
+ return out;
375
+ }
@@ -24,7 +24,10 @@ import {
24
24
  countryLegalFacts, FOOTER_LEGAL_ROLE, FORM_LEGAL_ROLE, formAsksPersonalData, formLegalFacts, LEGAL_PAGE_SETTING, LegalContext, LegalFact, LegalFacts,
25
25
  legalFormLine, LegalKind, legalKindsFor, legalLabel, legalRoute, legalTitle,
26
26
  } from './legal';
27
- import { checkOpening, drawnOpeningMix, OpeningContext, openingMix, OpeningMix, openingMixOfPlan, openingRecipe, OpeningRole, stampOpeningMix, stampOpeningMotion } from './opening-mix';
27
+ import {
28
+ checkOpening, drawnOpeningMix, OpeningContext, openingIsTypeLed, openingMix, OpeningMix, openingMixOfPlan, openingRecipe, OpeningRole, stampOpeningMix,
29
+ stampOpeningMotion, TYPE_LED_OPTIONAL_PARTS, typeLedOpeningSection,
30
+ } from './opening-mix';
28
31
  import { checkHeader, drawnHeaderMix, HeaderContext, headerContextOfPlan, HeaderIngredient, headerMix, HeaderMix, headerRecipe, HeaderRecipe, stampHeaderMix, wornHeaderOfPlan } from './header-mix';
29
32
  import { bodyMixOfPlan, checkBody, drawnBodyMix, wearBodyMix } from './body-mix';
30
33
  import { NODE_BASELINES } from './node-baselines.generated';
@@ -42,6 +45,7 @@ import { SitePlanSourceKind, ContentFieldControl, ContentFieldPlan,
42
45
  PlanDataSourceType, RelativeOp, roleField, SiteLocale, SitePlan, SitePlanSource, siteFactLabel, SiteBusiness, GenerationTier,
43
46
  } from './site-plan.model';
44
47
  import { assertValidSitePlan, nextSourceOf, routeParams } from './validate-site-plan';
48
+ import { PictureSupply, TypeLed, TypeLedChange, TypeLedChangeKind, typeLedRound } from './type-led';
45
49
  import { MenuSide, NavRole, NavShape, planNavShape } from './nav-shape';
46
50
  import { composeLayout, LayoutColourMode, layoutBandScheme, LayoutListBinding } from './compose-layout';
47
51
  import { LayoutGalleryList, LayoutListShape, LayoutPage, LayoutPhotoShape, LayoutPhotoSource, LayoutSite, parseLayoutPhotoId } from './layout-language';
@@ -164,6 +168,9 @@ export interface ComposeContext {
164
168
  /** A redesign (site-redesign RD1): each composed page's carry by page key (`harvestPage`) — its layout's layers and
165
169
  * sections naming a handle show the owner's part. */
166
170
  carry?: Readonly<Record<string, PageCarry>>;
171
+ /** #129: which picture slots a picture fills (the owner's, a made one, a stock one). Given, a section whose picture
172
+ * nothing fills is composed type-led (`type-led.ts`); absent, the plan composes exactly as it says. */
173
+ pictures?: PictureSupply;
167
174
  }
168
175
 
169
176
  /** Where a composed layout's photos are, as the server keeps them and the screens read them (M8 gate 2): id → address. */
@@ -240,6 +247,8 @@ export interface ComposedSite {
240
247
  issues: ComposeIssue[];
241
248
  /** Commerce C-D21: what the build writes into the studio's SHOP (never a content type) — null when it sells nothing. */
242
249
  shop: ComposedShop | null;
250
+ /** #129: set when the caller said what fills the pictures — what the composition wore instead of empty pictures. */
251
+ typeLed?: TypeLed;
243
252
  }
244
253
 
245
254
  /** A sample product as the build writes it through the shop's own write path (its slug made there, from its title). */
@@ -387,6 +396,8 @@ interface Ctx {
387
396
  keepButtons?: boolean;
388
397
  /** M1-6b: the pattern's entrance parts as stamped, for `planEntrances` once the pattern is whole. */
389
398
  entrances?: Array<Omit<EntranceMark, 'index'>>;
399
+ /** #129: the content types whose items have no picture at all — an optional `@image?` of theirs is left out. */
400
+ pictureless?: ReadonlySet<string>;
390
401
  }
391
402
 
392
403
  interface ShownWhen {
@@ -476,7 +487,10 @@ function resolveScopedPath(path: string, repeater: RepeaterScope | null, ctx: Ct
476
487
  const parsed = parsePatternPath(path);
477
488
  const { source, typeSource } = scopeOf(parsed.scope, path, repeater, ctx, nodeId);
478
489
  if (!parsed.role) return { source, path: parsed.field || ITEM_VALUE_PATH };
479
- const field = roleField(typeSource ? contentTypeOfSource(typeSource, ctx.plan) : undefined, parsed.role);
490
+ const type = typeSource ? contentTypeOfSource(typeSource, ctx.plan) : undefined;
491
+ // #129: a list whose items have no picture shows its cards without one, never an empty box per card.
492
+ if (parsed.optional && parsed.role === ContentRole.Image && type && ctx.pictureless?.has(type.name)) return null;
493
+ const field = roleField(type, parsed.role);
480
494
  if (field) return { source, path: field };
481
495
  if (parsed.optional) return null;
482
496
  throw new ComposeError(`${nodeId}: "${path}" — the item's content type names no ${parsed.role} field`);
@@ -1643,7 +1657,7 @@ const LAYOUT_TEXT_PROPS: ReadonlyArray<string> = ['content', 'caption', 'alt', '
1643
1657
  */
1644
1658
  function composeLayoutPage(
1645
1659
  page: PagePlan, layout: LayoutPage, plan: SitePlan, context: ComposeContext, design: DesignChoices, placeholders: ComposedPlaceholder[],
1646
- readyMade: (section: PageSectionPlan, id: string) => SerializedNode,
1660
+ readyMade: (section: PageSectionPlan, id: string) => SerializedNode, pictureless: ReadonlySet<string>,
1647
1661
  ): SerializedNode[] {
1648
1662
  const preset = layoutPresetOf(plan.design);
1649
1663
  const site: LayoutSite = {
@@ -1673,10 +1687,17 @@ function composeLayoutPage(
1673
1687
  photoShape: id => boxShape(id) ?? context.photoShape?.(id),
1674
1688
  sourceFields: alias => {
1675
1689
  const type = contentTypeOfSource(alias, plan);
1676
- const image = roleField(type, 'image');
1690
+ const image = type && pictureless.has(type.name) ? undefined : roleField(type, 'image');
1677
1691
  return image ? { image, ...(roleField(type, 'title') ? { title: roleField(type, 'title')! } : {}) } : null;
1678
1692
  },
1679
- listOf: alias => layoutListBinding(alias, plan),
1693
+ listOf: alias => {
1694
+ const binding = layoutListBinding(alias, plan);
1695
+ const type = contentTypeOfSource(alias, plan);
1696
+ // #129: a list whose items have no picture is read as a list without one (its cards draw no picture part).
1697
+ if (!binding || !type || !pictureless.has(type.name) || !binding.roles[ContentRole.Image]) return binding;
1698
+ const { [ContentRole.Image]: _none, ...roles } = binding.roles;
1699
+ return { ...binding, roles };
1700
+ },
1680
1701
  ...(context.carry?.[page.key] ? { carry: context.carry[page.key] } : {}),
1681
1702
  });
1682
1703
  const facts = plan.business.facts ?? {};
@@ -1716,6 +1737,36 @@ function stampLayoutSections(page: PagePlan, layout: LayoutPage, nodes: Serializ
1716
1737
  * composer never repairs a plan. `context` carries what the composer may not read for itself (the year).
1717
1738
  */
1718
1739
  export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSite {
1740
+ if (!context?.pictures) return composeSiteOnce(plan, context, NO_TYPES);
1741
+ // #129: compose, find the pictures nothing fills, compose again type-led — until a round changes nothing (an opening
1742
+ // left out shows its first section's own picture, judged in the next round). Monotone: a type-led section has no
1743
+ // picture to lose, so it ends.
1744
+ const filled = new Set(context.pictures.filled);
1745
+ const changes: TypeLedChange[] = [];
1746
+ let current = plan;
1747
+ let pictureless: ReadonlySet<string> = NO_TYPES;
1748
+ let site = composeSiteOnce(current, context, pictureless);
1749
+ let opening: TypeLed['opening'];
1750
+ const roundContext = { tier: context.tier, studio: context.pictures.studio };
1751
+ for (let round = 0; round < TYPE_LED_ROUNDS; round++) {
1752
+ const next = typeLedRound(current, site, filled, roundContext);
1753
+ if (next.opening) opening = next.opening;
1754
+ const newly = next.pictureless.filter(t => !pictureless.has(t));
1755
+ if (!next.changes.length && !newly.length) break;
1756
+ changes.push(...next.changes);
1757
+ for (const type of newly) changes.push({ kind: TypeLedChangeKind.List, contentType: type, said: `the ${type} have no pictures yet — their cards show their words` });
1758
+ current = next.plan;
1759
+ pictureless = new Set([...pictureless, ...newly]);
1760
+ site = composeSiteOnce(current, context, pictureless);
1761
+ }
1762
+ return { ...site, typeLed: { plan: current, changes, pictureless: [...pictureless], ...(opening ? { opening } : {}) } };
1763
+ }
1764
+
1765
+ const NO_TYPES: ReadonlySet<string> = new Set();
1766
+ /** The most rounds a composition takes to wear no empty picture: the opening, then its first section, then a margin. */
1767
+ const TYPE_LED_ROUNDS = 4;
1768
+
1769
+ function composeSiteOnce(plan: SitePlan, context: ComposeContext, pictureless: ReadonlySet<string>): ComposedSite {
1719
1770
  assertValidSitePlan(plan, context?.tier ? { tier: context.tier } : {});
1720
1771
  if (!Number.isInteger(context?.year)) throw new ComposeError('composeSite needs the year (ComposeContext.year) — the composer reads no clock');
1721
1772
  const placeholders: ComposedPlaceholder[] = [];
@@ -1723,7 +1774,7 @@ export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSi
1723
1774
  const routes = new Set(plan.pages.map(p => p.route));
1724
1775
  const relatives = new Map(plan.dataSources.map(d => [d.alias, d.type === PlanDataSourceType.Relative ? { type: d.type, of: d.of, op: d.op } : { type: d.type }]));
1725
1776
  const email = nonEmpty(plan.business.facts?.email) ? plan.business.facts!.email!.trim() : null;
1726
- const base = { plan, placeholders, issues, routes, year: context.year, email, navPage: null };
1777
+ const base = { plan, placeholders, issues, routes, year: context.year, email, navPage: null, pictureless };
1727
1778
 
1728
1779
  // AW-D23 / MB-D6: a lower plan wears its own words of the look's motion language (a Pro Feel arrives on today's
1729
1780
  // curve, a Pro move fades) — in the tokens the build applies AND the entrances it stamps.
@@ -1742,10 +1793,11 @@ export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSi
1742
1793
  const layout = withShownList(page.layout, layoutListsContext(page, plan)) ?? page.layout;
1743
1794
  const stamped = stampLayoutSections(page, layout, composeLayoutPage(page, layout, plan, context, design, placeholders, (section, id) =>
1744
1795
  composePattern(patternById(section.pattern) as SitePattern, id, { ...base, owner: page.key, page, section, nextAlias },
1745
- { level: section.enter ?? design.animate ?? null, rtl, move: design.headings ?? null })));
1796
+ { level: section.enter ?? design.animate ?? null, rtl, move: design.headings ?? null }), pictureless));
1746
1797
  // AW8: the plan's opening is the home page's first screen; a pinned or kept first place is never replaced.
1747
1798
  const first = layout.sections[0];
1748
- const worn = wearPlanOpening(page, stamped, plan, context, design, placeholders, issues, !!(first?.pin || first?.carry));
1799
+ const worn = wearPlanOpening(page, stamped, plan, context, design, placeholders, issues, !!(first?.pin || first?.carry),
1800
+ first?.readyMade ? page.sections[first.readyMade.at] : undefined);
1749
1801
  const opening = worn === stamped ? layoutBandScheme(first?.ground) : schemeOfFirst(worn);
1750
1802
  // Award §0c CW2 (AW-D34): the column the model chose for this page is the page's own word (absent: the site's).
1751
1803
  const column = columnWordOf(layout.column);
@@ -1759,7 +1811,7 @@ export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSi
1759
1811
  const pattern = patternById(section.pattern) as SitePattern;
1760
1812
  const motion: SectionMotion = { level: section.enter ?? design.animate ?? null, rtl, move: design.headings ?? null, scrub: design.scrub ?? null, opening: i === 0 };
1761
1813
  return stampSection(composePattern(pattern, `${page.key}-${i}`, { ...base, owner: page.key, page, section, nextAlias }, motion), { pattern: section.pattern });
1762
- }), plan, context, design, placeholders, issues, false);
1814
+ }), plan, context, design, placeholders, issues, false, page.sections[0]);
1763
1815
  const opening = schemeOfFirst(layout);
1764
1816
  return {
1765
1817
  key: page.key,
@@ -2300,20 +2352,22 @@ function shownWords(root: SerializedNode | undefined): string {
2300
2352
  */
2301
2353
  function wearPlanOpening(
2302
2354
  page: PagePlan, layout: SerializedNode[], plan: SitePlan, context: ComposeContext, design: DesignChoices,
2303
- placeholders: ComposedPlaceholder[], issues: ComposeIssue[], keep: boolean,
2355
+ placeholders: ComposedPlaceholder[], issues: ComposeIssue[], keep: boolean, source?: PageSectionPlan,
2304
2356
  ): SerializedNode[] {
2305
2357
  const mix = openingMixOfPlan(plan);
2306
2358
  if (!mix || !(page.isHome === true || page.route === HOME_PATH)) return layout;
2307
2359
  const first = layout[0];
2308
2360
  const replace = !!first && !keep && openingMayReplace(first);
2309
2361
  const id = replace ? first.id : `${page.key}-opening`;
2310
- const heading = replace ? swapParts(first)['heading'][0] : undefined;
2362
+ const tier = context.tier ?? GenerationTier.Basic;
2363
+ const site = { pages: plan.pages.map(p => ({ name: p.name, route: p.route, isHome: p.isHome === true })), locale: plan.locale, design, badge: null, cutOut: false, tier };
2364
+ // #129: a type-led first screen takes the type-led hero's words slot by slot (nothing it said is lost); the name is
2365
+ // the business's, as every display-size opening's is.
2366
+ const checked = replace && source ? checkOpening(drawnOpeningMix(mix).drawn, openingContextOf({ ...site, business: plan.business })).mix : null;
2367
+ const parts = checked && source ? typeLedOpeningSection(checked, source) : null;
2368
+ const heading = replace && !parts ? swapParts(first)['heading'][0] : undefined;
2311
2369
  const title = shownWords(heading);
2312
- const composed = composeOpening({
2313
- business: { ...plan.business, name: title || plan.business.name },
2314
- pages: plan.pages.map(p => ({ name: p.name, route: p.route, isHome: p.isHome === true })),
2315
- mix, locale: plan.locale, design, badge: null, cutOut: false, tier: context.tier ?? GenerationTier.Basic,
2316
- }, { id });
2370
+ const composed = composeOpening({ ...site, business: { ...plan.business, name: title || plan.business.name }, mix, ...(parts ? { parts } : {}) }, { id });
2317
2371
  const section = composed.section;
2318
2372
  const said = composed.issues.map(i => i.detail);
2319
2373
  let own: ComposedPlaceholder[] = composed.placeholders.map(p => ({ ...p, owner: page.key }));
@@ -2322,6 +2376,13 @@ function wearPlanOpening(
2322
2376
  walkSerialized([first], n => { gone.add(n.id); });
2323
2377
  const carried = placeholders.filter(p => gone.has(p.nodeId));
2324
2378
  for (let i = placeholders.length - 1; i >= 0; i--) if (gone.has(placeholders[i].nodeId)) placeholders.splice(i, 1);
2379
+ if (parts) {
2380
+ // The words came slot by slot: nothing to carry, the composer's placeholders stand.
2381
+ placeholders.push(...own);
2382
+ for (const detail of said) issues.push({ code: ComposeIssueCode.OpeningMended, nodeId: id, owner: page.key, detail });
2383
+ stampSection(section, first.composed?.pattern ? { pattern: first.composed.pattern } : { layout: first.composed?.layout ?? OPENING_ORIGIN });
2384
+ return [section, ...layout.slice(1)];
2385
+ }
2325
2386
  // The hero's title is already the opening's display words (composed above — split apart, set as a wordmark); the
2326
2387
  // carry places everything else, never over those words.
2327
2388
  const fromRest = withoutNodes(first, n => n === heading);
@@ -2383,6 +2444,10 @@ export interface OpeningInput extends SectionInput {
2383
2444
  readonly tier?: OpeningContext['tier'];
2384
2445
  /** Draw the mix as asked, never mended — the Opening studio (it ADVISES the check's mends, OB-2). */
2385
2446
  readonly asAsked?: boolean;
2447
+ /** #129: a type-led first screen's words, slot by slot, from the hero it takes the place of (`typeLedOpeningSection`).
2448
+ * Absent on a type-led mix: its optional parts (the line above, the line beside the name, a second action) are left
2449
+ * out, so nothing is invented. */
2450
+ readonly parts?: { readonly slots: Readonly<Record<string, string>>; readonly links: Readonly<Record<string, string>>; readonly without: ReadonlyArray<string> };
2386
2451
  }
2387
2452
 
2388
2453
  export interface ComposedOpening extends ComposedSection {
@@ -2422,17 +2487,19 @@ export function composeOpening(input: OpeningInput, options: SectionOptions): Co
2422
2487
  for (const said of [...gaps.map(g => `the opening's ${g.ingredient} "${g.word}" is drawn as ${g.drawnAs ? `"${g.drawnAs}"` : 'nothing'} until ${g.phase}`), ...checked.repairs.map(r => r.said)]) {
2423
2488
  issues.push({ code: ComposeIssueCode.OpeningMended, nodeId: options.id, owner: options.id, detail: said });
2424
2489
  }
2490
+ const parts = input.parts ?? (openingIsTypeLed(checked.mix) ? { slots: {}, links: {}, without: TYPE_LED_OPTIONAL_PARTS } : null);
2491
+ const section = parts ? { pattern: OPENING_ORIGIN, slots: parts.slots, links: parts.links, without: [...parts.without] } as PageSectionPlan : null;
2425
2492
  const ctx: Ctx = {
2426
- owner: options.id, page: null, section: null, plan, year: 0, email, navPage: null, nextAlias: null,
2493
+ owner: options.id, page: null, section, plan, year: 0, email, navPage: null, nextAlias: null,
2427
2494
  placeholders, issues, routes: new Set(pages.map(p => p.route)), keepButtons: true,
2428
2495
  };
2429
2496
  const recipe = openingRecipe(checked.mix, context);
2430
- const section = composePattern(recipe.pattern, options.id, ctx);
2431
- stampOpeningMix(section, recipe.mix);
2432
- stampOpeningMotion(section, recipe.mix);
2497
+ const root = composePattern(recipe.pattern, options.id, ctx);
2498
+ stampOpeningMix(root, recipe.mix);
2499
+ stampOpeningMotion(root, recipe.mix);
2433
2500
  const badge = typeof input.badge === 'string' && input.badge.trim() ? input.badge.trim() : null;
2434
2501
  if (badge) {
2435
- walkSerialized([section], n => {
2502
+ walkSerialized([root], n => {
2436
2503
  const holder = n.role === OpeningRole.Badge ? n : null;
2437
2504
  for (const words of holder?.children ?? []) {
2438
2505
  words.props = { ...words.props, content: badge };
@@ -2441,6 +2508,6 @@ export function composeOpening(input: OpeningInput, options: SectionOptions): Co
2441
2508
  }
2442
2509
  });
2443
2510
  }
2444
- return { section, placeholders, issues, mix: recipe.mix };
2511
+ return { section: root, placeholders, issues, mix: recipe.mix };
2445
2512
  }
2446
2513