@vectoriox/iox-ui 5.204.0 → 5.206.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 (56) hide show
  1. package/data-core/index.d.ts +13 -4
  2. package/design-core/index.d.ts +277 -6
  3. package/fesm2022/vectoriox-iox-ui-data-core.mjs +23 -4
  4. package/fesm2022/vectoriox-iox-ui-data-core.mjs.map +1 -1
  5. package/fesm2022/vectoriox-iox-ui-design-core.mjs +3065 -2673
  6. package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
  7. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +1313 -197
  8. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  9. package/fesm2022/vectoriox-iox-ui-harness-core.mjs +71 -19
  10. package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
  11. package/fesm2022/vectoriox-iox-ui-scene-core.mjs +32 -4
  12. package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
  13. package/fesm2022/vectoriox-iox-ui.mjs +145 -82
  14. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  15. package/generation-core/index.d.ts +462 -41
  16. package/harness-core/index.d.ts +52 -12
  17. package/index.d.ts +44 -3
  18. package/package.json +1 -1
  19. package/scene-core/index.d.ts +16 -2
  20. package/src/data-core/placeholder-rows.ts +24 -3
  21. package/src/design-core/colour-eval.ts +22 -0
  22. package/src/design-core/contrast-audit.ts +96 -2
  23. package/src/design-core/design-token.model.ts +2 -0
  24. package/src/design-core/flavor-spec.generated.ts +184 -0
  25. package/src/design-core/font-metrics.ts +14 -1
  26. package/src/design-core/font-vertical.ts +80 -0
  27. package/src/design-core/node-links.ts +12 -0
  28. package/src/design-core/public-api.ts +1 -0
  29. package/src/design-core/style-presets.ts +20 -1
  30. package/src/design-core/token-css.ts +3 -1
  31. package/src/generation-core/ai-run.ts +31 -0
  32. package/src/generation-core/audit-site.ts +5 -3
  33. package/src/generation-core/compose-free.ts +1 -1
  34. package/src/generation-core/compose-layout.ts +172 -22
  35. package/src/generation-core/critic-calibration.ts +30 -10
  36. package/src/generation-core/critic-numbers.ts +259 -0
  37. package/src/generation-core/critic-prompt.ts +74 -6
  38. package/src/generation-core/critic-rubric.generated.ts +7 -7
  39. package/src/generation-core/critic-sheet.ts +184 -6
  40. package/src/generation-core/critic.ts +27 -13
  41. package/src/generation-core/designer-brief.ts +4 -3
  42. package/src/generation-core/designer-estimate.ts +3 -3
  43. package/src/generation-core/layout-render-check.ts +35 -2
  44. package/src/generation-core/nav-shape.ts +67 -8
  45. package/src/generation-core/opening-mix.ts +61 -17
  46. package/src/generation-core/public-api.ts +2 -0
  47. package/src/generation-core/social-links.ts +47 -8
  48. package/src/generation-core/stock-photos.ts +149 -14
  49. package/src/generation-core/stock-search.ts +108 -19
  50. package/src/generation-core/stock-subjects.ts +204 -0
  51. package/src/harness-core/business-types.ts +3 -0
  52. package/src/harness-core/harness-spec.generated.ts +54 -15
  53. package/src/harness-core/intake.ts +18 -5
  54. package/src/scene-core/scene.ts +34 -3
  55. package/styles/iox-design.css +41 -2
  56. package/styles/iox-forms.css +7 -6
@@ -7,6 +7,9 @@
7
7
  * Pure.
8
8
  */
9
9
 
10
+ import { CriticDimension } from './critic';
11
+ import { CARD_NUMBER_ROWS, cardNumbers, VisitNumbers, visitNumbersOf } from './critic-numbers';
12
+
10
13
  export enum CaptureWidth {
11
14
  Laptop = 'laptop',
12
15
  Phone = 'phone',
@@ -54,12 +57,48 @@ export interface CaptureBox {
54
57
  h: number;
55
58
  }
56
59
 
60
+ /**
61
+ * What moves on a live page, counted at its first screen — iox-render's `MOTION` measure (`measures/visitor.mjs`), the
62
+ * one a reference visit and a round both run, so the two sides are counted the same way (AD-D27). A still cannot show
63
+ * motion: this is what the critic reads beside the Scene views. The reference card's Motion row prints the same counts.
64
+ */
65
+ export interface CaptureMotion {
66
+ lenis?: boolean;
67
+ gsap?: boolean;
68
+ swiper?: boolean;
69
+ videos?: number;
70
+ canvases?: number;
71
+ stickyEls?: number;
72
+ animationsRunning?: number | null;
73
+ transitionsDeclared?: number;
74
+ /** A round only: how many Scenes the page holds (a reference is not an IOX site). */
75
+ scenes?: number;
76
+ }
77
+
57
78
  /** The measures a capture knows (a subset of the tester's `metrics.json`; AD2's measures add to it). */
58
79
  export interface CaptureMetrics {
59
80
  /** The header's box at load. */
60
81
  header?: CaptureBox;
61
82
  /** Boxes a measure flagged (an overlap, a lone word, a clipped line) — each one is cropped first. */
62
83
  flagged?: Array<{ box: CaptureBox; view: CaptureView; why: string }>;
84
+ /** What moves on the live page (AD-D27). */
85
+ motion?: CaptureMotion;
86
+ /** The visitor measures the reference card's Numbers column prints (AD-D29): type, layout, picture area per screen,
87
+ * header, footer, colours — taken the same way on both live pages. */
88
+ numbers?: VisitNumbers;
89
+ }
90
+
91
+ /**
92
+ * A motion measure in the reference card's words (`team/reference-cards/*.md`, row 7's numbers):
93
+ * `lenis true gsap false swiper false videos 3 canvas 0 sticky 0 anims 21 transitions 33`, then `scenes N` when known.
94
+ * A count the measure did not take is left out, never printed as 0.
95
+ */
96
+ export function motionLine(m: CaptureMotion): string {
97
+ const parts: Array<[string, unknown]> = [
98
+ ['lenis', m.lenis], ['gsap', m.gsap], ['swiper', m.swiper], ['videos', m.videos], ['canvas', m.canvases],
99
+ ['sticky', m.stickyEls], ['anims', m.animationsRunning], ['transitions', m.transitionsDeclared], ['scenes', m.scenes],
100
+ ];
101
+ return parts.filter(([, v]) => typeof v === 'boolean' || (typeof v === 'number' && Number.isFinite(v))).map(([k, v]) => `${k} ${v}`).join(' ');
63
102
  }
64
103
 
65
104
  export interface CaptureSet {
@@ -91,14 +130,19 @@ export function visionImageTokens(w: number, h: number): number {
91
130
  return Math.min(Math.ceil(w / VISION_TOKEN_TILE) * Math.ceil(h / VISION_TOKEN_TILE), VISION_TOKEN_CAP);
92
131
  }
93
132
 
94
- /** A view of the sheet: the reference's shot and ours, at one width. */
133
+ /** One view on the sheet: the reference's and ours. A Scene stop may be OURS ALONE (`reference` absent): a reference is not
134
+ * an IOX site, so its capture has no Scene stills, and without ours the critic judged motion from a whole-page view where a
135
+ * Scene is a blank runway (AD3 calibration; the lead, 2026-12-01). */
95
136
  export interface SheetPair {
96
137
  width: CaptureWidth;
97
138
  view: CaptureView;
98
- reference: CaptureShot;
139
+ reference?: CaptureShot;
99
140
  ours: CaptureShot;
100
141
  }
101
142
 
143
+ /** The views the sheet shows of ours even when the reference has none: the Scene stops, where motion is judged. */
144
+ export const OURS_ALONE_VIEWS: ReadonlyArray<CaptureView> = [CaptureView.Scene25, CaptureView.Scene50, CaptureView.Scene90];
145
+
102
146
  /** A zoomed crop: the box on a shot, how much it is enlarged, and why it was chosen. `reference` crops the same place on
103
147
  * the reference's shot, for a side by side (a flagged defect of ours has none). */
104
148
  export interface SheetCrop {
@@ -110,11 +154,66 @@ export interface SheetCrop {
110
154
  zoom: number;
111
155
  }
112
156
 
157
+ /** The motion counts out of a measure's raw object (iox-render `MOTION`), each kept only when it has its type. */
158
+ export function captureMotionOf(raw: unknown): CaptureMotion | undefined {
159
+ if (!raw || typeof raw !== 'object') return undefined;
160
+ const r = raw as Record<string, unknown>;
161
+ const out: CaptureMotion = {};
162
+ for (const k of ['lenis', 'gsap', 'swiper'] as const) if (typeof r[k] === 'boolean') out[k] = r[k] as boolean;
163
+ for (const k of ['videos', 'canvases', 'stickyEls', 'animationsRunning', 'transitionsDeclared', 'scenes'] as const) {
164
+ if (typeof r[k] === 'number' && Number.isFinite(r[k])) out[k] = r[k] as number;
165
+ }
166
+ return Object.keys(out).length ? out : undefined;
167
+ }
168
+
169
+ /**
170
+ * The measures the sheet uses, from one width's `metrics.json` of a visit (iox-render `visit.mjs`, the reference captures
171
+ * and the tester's): the header at load, the polish findings boxed on the whole page, what moves, the card's numbers
172
+ * (AD-D29). A malformed box is skipped; nothing found is `{}`.
173
+ */
174
+ export function visitMetricsOf(metrics: unknown): CaptureMetrics {
175
+ const m = metrics as { headerAtLoad?: { left?: number; top?: number; w?: number; h?: number }; polish?: Array<{ kind?: string; text?: string; box?: number[] }>; motion?: unknown } | null;
176
+ const out: CaptureMetrics = {};
177
+ const h = m?.headerAtLoad;
178
+ if (h && [h.left, h.top, h.w, h.h].every(Number.isFinite) && h.h! > 0) out.header = { x: h.left!, y: h.top!, w: h.w!, h: h.h! };
179
+ const flagged = (m?.polish ?? [])
180
+ .filter(p => Array.isArray(p.box) && p.box.length === 4 && p.box.every(Number.isFinite))
181
+ .map(p => ({ view: CaptureView.Full, box: { x: p.box![0], y: p.box![1], w: p.box![2], h: p.box![3] }, why: `${p.kind}: "${String(p.text ?? '').slice(0, 60)}"` }));
182
+ if (flagged.length) out.flagged = flagged;
183
+ const motion = captureMotionOf(m?.motion);
184
+ if (motion) out.motion = motion;
185
+ const numbers = visitNumbersOf(m);
186
+ if (numbers) out.numbers = numbers;
187
+ return out;
188
+ }
189
+
190
+ /** One width's motion, measured on both live pages (AD-D27): the reference's and ours, in the card's words. */
191
+ export interface SheetMotion {
192
+ width: CaptureWidth;
193
+ reference?: string;
194
+ ours?: string;
195
+ }
196
+
197
+ /** One row of the card's numbers at one width (AD-D29): the reference's and ours, each in the card's words (`cardNumbers`). */
198
+ export interface SheetNumbers {
199
+ dimension: CriticDimension;
200
+ width: CaptureWidth;
201
+ reference?: string;
202
+ ours?: string;
203
+ }
204
+
113
205
  export interface CritiqueSheet {
114
206
  pairs: SheetPair[];
115
207
  crops: SheetCrop[];
208
+ /** Per width, what moves on each live page — words, not pictures, so they cost no image token. */
209
+ motion: SheetMotion[];
210
+ /** Row by row (the card's order), then per width: the card's numbers measured on both live pages (AD-D29) — words, so
211
+ * sizes and shares are read as numbers, never off a scaled-down still. */
212
+ numbers: SheetNumbers[];
116
213
  /** The views one side has and the other has not (`phone/footer: no reference shot`). */
117
214
  missing: string[];
215
+ /** What left the sheet to keep it inside `CRITIC_SHEET_MAX_IMAGES` (`phone/first`, `crop: the phone footer`), in order. */
216
+ dropped: string[];
118
217
  /** The image tokens the sheet costs a vision model (pairs, then each crop at its zoom). */
119
218
  imageTokens: number;
120
219
  /** Of those, the reference's views — the share read from the cache from round 2 (`CriticSheetLayout.Cached`). */
@@ -158,11 +257,69 @@ function zoomOf(box: CaptureBox): number {
158
257
  }
159
258
 
160
259
  /**
161
- * The sheet for one page against one reference: every view both sides have, laptop first, in `CAPTURE_VIEW_ORDER`; then
260
+ * The most pictures one sheet sends (the lead, 2026-12-01, after AD3's first live call): the Claude API holds every picture
261
+ * of a request with more than 20 to 2000 px a side, which leaves a full-page overview ≈ 290 px wide. At ≤ 20 a picture may
262
+ * be 8000 px a side, so the full page stays readable.
263
+ */
264
+ export const CRITIC_SHEET_MAX_IMAGES = 20;
265
+
266
+ /**
267
+ * The order views leave a sheet that is over the limit: first the phone views the sheet already shows another way — the
268
+ * opening and the footer (the phone crops enlarge them), then the rest of the phone's screens, which the laptop's views
269
+ * and the phone's full page cover — then the menu open, phone and laptop. The full pages and the laptop's own screens stay.
270
+ */
271
+ export const CRITIC_SHEET_DROP_ORDER: ReadonlyArray<readonly [CaptureWidth, CaptureView]> = [
272
+ ...[CaptureView.First, CaptureView.Footer, CaptureView.HeaderScrolled, CaptureView.Down1, CaptureView.Down2, CaptureView.List,
273
+ CaptureView.Scene25, CaptureView.Scene50, CaptureView.Scene90, CaptureView.Reduced].map(v => [CaptureWidth.Phone, v] as const),
274
+ [CaptureWidth.Phone, CaptureView.HeaderOpen],
275
+ [CaptureWidth.Laptop, CaptureView.HeaderOpen],
276
+ // the laptop Scene's ends; its middle (50 %) stays as long as any crop beyond the fewest can go
277
+ [CaptureWidth.Laptop, CaptureView.Scene25],
278
+ [CaptureWidth.Laptop, CaptureView.Scene90],
279
+ ];
280
+
281
+ /** The pairs no sheet drops, however full: the laptop's opening and both full pages. */
282
+ const SHEET_KEEPS: ReadonlyArray<readonly [CaptureWidth, CaptureView]> = [
283
+ [CaptureWidth.Laptop, CaptureView.First], [CaptureWidth.Laptop, CaptureView.Full], [CaptureWidth.Phone, CaptureView.Full],
284
+ ];
285
+
286
+ /** The pictures a sheet sends: ours of every pair and crop, and the reference's where it has one. */
287
+ export function sheetImageCount(sheet: Pick<CritiqueSheet, 'pairs' | 'crops'>): number {
288
+ return sheet.pairs.reduce((n, p) => n + (p.reference ? 2 : 1), 0) + sheet.crops.reduce((n, c) => n + (c.reference ? 2 : 1), 0);
289
+ }
290
+
291
+ /**
292
+ * Bring a sheet to at most `max` pictures: the views in `CRITIC_SHEET_DROP_ORDER`, one at a time; then the crops from the
293
+ * last down to the fewest (`CRITIC_CROPS.min`); then, only if still over, the remaining pairs from the last, never the
294
+ * opening or a full page. Every step is recorded in `dropped`.
295
+ */
296
+ function fitSheet(pairs: SheetPair[], crops: SheetCrop[], max: number): string[] {
297
+ const dropped: string[] = [];
298
+ const over = () => sheetImageCount({ pairs, crops }) > max;
299
+ const dropPair = (width: CaptureWidth, view: CaptureView) => {
300
+ const i = pairs.findIndex(p => p.width === width && p.view === view);
301
+ if (i < 0) return;
302
+ pairs.splice(i, 1);
303
+ dropped.push(`${width}/${view}`);
304
+ };
305
+ for (const [width, view] of CRITIC_SHEET_DROP_ORDER) {
306
+ if (!over()) return dropped;
307
+ dropPair(width, view);
308
+ }
309
+ while (over() && crops.length > CRITIC_CROPS.min) dropped.push(`crop: ${crops.pop()!.why}`);
310
+ const kept = (p: SheetPair) => SHEET_KEEPS.some(([w, v]) => p.width === w && p.view === v);
311
+ for (let i = pairs.length - 1; i >= 0 && over(); i--) if (!kept(pairs[i])) dropPair(pairs[i].width, pairs[i].view);
312
+ return dropped;
313
+ }
314
+
315
+ /**
316
+ * The sheet for one page against one reference: every view both sides have, laptop first, in `CAPTURE_VIEW_ORDER` — and
317
+ * ours alone at a Scene stop the reference lacks (`OURS_ALONE_VIEWS`); then
162
318
  * the crops — ours' flagged boxes first (distinct findings, at most `CRITIC_FLAGGED_CROPS`), then the recipes on both
163
319
  * sides, up to the most (the recipes alone give the fewest). The header recipe uses the measured header box when ours has one.
320
+ * Then the sheet is brought to `maxImages` pictures (`CRITIC_SHEET_MAX_IMAGES`; `fitSheet`'s order).
164
321
  */
165
- export function planCritiqueSheet(ours: CaptureSet, reference: CaptureSet): CritiqueSheet {
322
+ export function planCritiqueSheet(ours: CaptureSet, reference: CaptureSet, maxImages: number = CRITIC_SHEET_MAX_IMAGES): CritiqueSheet {
166
323
  const pairs: SheetPair[] = [];
167
324
  const missing: string[] = [];
168
325
  for (const width of Object.values(CaptureWidth)) {
@@ -170,6 +327,7 @@ export function planCritiqueSheet(ours: CaptureSet, reference: CaptureSet): Crit
170
327
  const o = shotOf(ours, width, view);
171
328
  const r = shotOf(reference, width, view);
172
329
  if (o && r) pairs.push({ width, view, reference: r, ours: o });
330
+ else if (o && OURS_ALONE_VIEWS.includes(view)) pairs.push({ width, view, ours: o });
173
331
  else if (o || r) missing.push(`${width}/${view}: no ${o ? 'reference' : 'page'} shot`);
174
332
  }
175
333
  }
@@ -195,9 +353,29 @@ export function planCritiqueSheet(ours: CaptureSet, reference: CaptureSet): Crit
195
353
  : fraction(o, recipe.box));
196
354
  crops.push({ width: recipe.width, view: recipe.view, why: recipe.why, ours: { ref: o.ref, box }, reference: { ref: r.ref, box: clip(r, fraction(r, recipe.box)) }, zoom: zoomOf(box) });
197
355
  }
198
- const referenceImageTokens = pairs.reduce((n, p) => n + visionImageTokens(p.reference.w, p.reference.h), 0);
356
+ const motion: SheetMotion[] = [];
357
+ for (const width of Object.values(CaptureWidth)) {
358
+ const o = ours.metrics?.[width]?.motion;
359
+ const r = reference.metrics?.[width]?.motion;
360
+ const line = (m?: CaptureMotion) => (m ? motionLine(m) : '');
361
+ if (line(o) || line(r)) motion.push({ width, ...(line(r) ? { reference: line(r) } : {}), ...(line(o) ? { ours: line(o) } : {}) });
362
+ }
363
+ const numbers: SheetNumbers[] = [];
364
+ // re-read on the way in (idempotent): a capture source may hand its measures over as they were written
365
+ const rowsOf = (set: CaptureSet) => Object.fromEntries(Object.values(CaptureWidth).map(w => [w, cardNumbers(visitNumbersOf(set.metrics?.[w]?.numbers))]));
366
+ const ourRows = rowsOf(ours);
367
+ const theirRows = rowsOf(reference);
368
+ for (const dimension of CARD_NUMBER_ROWS) {
369
+ for (const width of Object.values(CaptureWidth)) {
370
+ const o = ourRows[width][dimension];
371
+ const r = theirRows[width][dimension];
372
+ if (o || r) numbers.push({ dimension, width, ...(r ? { reference: r } : {}), ...(o ? { ours: o } : {}) });
373
+ }
374
+ }
375
+ const dropped = fitSheet(pairs, crops, maxImages);
376
+ const referenceImageTokens = pairs.reduce((n, p) => n + (p.reference ? visionImageTokens(p.reference.w, p.reference.h) : 0), 0);
199
377
  const pairTokens = referenceImageTokens + pairs.reduce((n, p) => n + visionImageTokens(p.ours.w, p.ours.h), 0);
200
378
  const cropTokens = crops.reduce((n, c) => n + visionImageTokens(c.ours.box.w * c.zoom, c.ours.box.h * c.zoom)
201
379
  + (c.reference ? visionImageTokens(c.reference.box.w * c.zoom, c.reference.box.h * c.zoom) : 0), 0);
202
- return { pairs, crops, missing, imageTokens: pairTokens + cropTokens, referenceImageTokens };
380
+ return { pairs, crops, motion, numbers, missing, dropped, imageTokens: pairTokens + cropTokens, referenceImageTokens };
203
381
  }
@@ -75,12 +75,10 @@ export enum CriticIssueCode {
75
75
  Shape = 'shape',
76
76
  /** A score outside 0–10 or not in half points. */
77
77
  Range = 'range',
78
- /** Evidence that is not one line read off the sheet (no position, size or colour in it). */
78
+ /** Evidence that is not one line read off the sheet: no number where the rubric measures in numbers, else not ours. */
79
79
  Evidence = 'evidence',
80
80
  /** Not 1–3 changes, or none aimed at the lowest score. */
81
81
  Changes = 'changes',
82
- /** A polish score above what its bugs leave. */
83
- Polish = 'polish',
84
82
  /** A brief that asks for resemblance (AD-D18): the reference's name, "copy", "look like". */
85
83
  Likeness = 'likeness',
86
84
  }
@@ -93,7 +91,13 @@ export interface CriticContext {
93
91
 
94
92
  /** A measurement: a number (a size, a position, a share) or a hex colour. */
95
93
  const MEASURED = /\d/;
96
- const LIKENESS_WORDS = /\b(copy|copies|copying|mimic|replicate|imitate|clone|look(?:s|ing)? like|same as|just like)\b/i;
94
+ /** The comparison named: the line says what OURS does (the critic answers in English, as its instructions are). */
95
+ const COMPARED = /\bours?\b/i;
96
+ /** The dimensions the rubric measures in numbers (their row says "Numbers: …"): their evidence must hold one. The rest —
97
+ * the header, the footer, motion, polish — are read as behaviour; a line naming ours (or a number) is evidence. */
98
+ const MEASURED_DIMENSIONS: ReadonlySet<string> = new Set(CRITIC_RUBRIC_DIMENSIONS.filter(d => /\bNumbers:/.test(d.compares)).map(d => d.key));
99
+ /** Asking for likeness. "copy" alone is text (the hero copy, body copy) — only copying a thing is likeness. */
100
+ const LIKENESS_WORDS = /\b(cop(?:y|ies|ying) (?:it|its|them|their|the|this|that)\b|mimic|replicate|imitate|clone|look(?:s|ing)? like|same as|just like)/i;
97
101
  const MIN_NAME_PART = 4;
98
102
 
99
103
  /** The words of a reference's name a brief may not say (`graya-institute` → graya, institute). */
@@ -115,7 +119,8 @@ export function criticAnswerIssues(answer: unknown, ctx: CriticContext): CriticI
115
119
  const v = s['score'];
116
120
  if (v < CRITIC_SCORE.min || v > CRITIC_SCORE.max || !Number.isInteger(v / CRITIC_SCORE.step)) say(CriticIssueCode.Range, `${path}.score`, `0–10 in half points, not ${v}`);
117
121
  const evidence = s['evidence'].trim();
118
- if (!evidence || /\n/.test(evidence) || !MEASURED.test(evidence)) {
122
+ const read = MEASURED.test(evidence) || (!MEASURED_DIMENSIONS.has(d) && COMPARED.test(evidence));
123
+ if (!evidence || /\n/.test(evidence) || !read) {
119
124
  say(CriticIssueCode.Evidence, `${path}.evidence`, 'one line read off the sheet — a position, a size or a colour, the reference\'s and ours');
120
125
  }
121
126
  }
@@ -123,9 +128,6 @@ export function criticAnswerIssues(answer: unknown, ctx: CriticContext): CriticI
123
128
  bugs.forEach((b, i) => {
124
129
  if (!isPlainObject(b) || typeof b['what'] !== 'string' || typeof b['broken'] !== 'boolean') say(CriticIssueCode.Shape, `bugs[${i}]`, 'a bug is { what, broken }');
125
130
  });
126
- const polish = (scores[CriticDimension.Polish] as { score?: unknown } | undefined)?.score;
127
- const allowed = CRITIC_SCORE.max - CRITIC_RUBRIC_POLISH.bugPenalty * bugs.length;
128
- if (typeof polish === 'number' && polish > allowed) say(CriticIssueCode.Polish, `scores.${CriticDimension.Polish}.score`, `${bugs.length} bug(s) leave at most ${allowed}`);
129
131
  const changes = answer['changes'] as unknown[];
130
132
  if (changes.length < CRITIC_CHANGES.min || changes.length > CRITIC_CHANGES.max) say(CriticIssueCode.Changes, 'changes', `${CRITIC_CHANGES.min}–${CRITIC_CHANGES.max} changes, not ${changes.length}`);
131
133
  const names = nameParts(ctx.reference);
@@ -143,16 +145,28 @@ export function criticAnswerIssues(answer: unknown, ctx: CriticContext): CriticI
143
145
  });
144
146
  if (out.length) return out;
145
147
  const lowest = lowestDimensions(answer as unknown as CriticAnswer);
146
- if (!(changes as CriticChange[]).some(c => lowest.includes(c.dimension))) {
148
+ // Every bug travels to the revise step on its own line (`roundBrief`), so a listed bug is a change aimed at polish.
149
+ const aimed = new Set((changes as CriticChange[]).map(c => c.dimension));
150
+ if (bugs.length) aimed.add(CriticDimension.Polish);
151
+ if (!lowest.some(d => aimed.has(d))) {
147
152
  say(CriticIssueCode.Changes, 'changes', `no change is aimed at the lowest score (${lowest.join(', ')})`);
148
153
  }
149
154
  return out;
150
155
  }
151
156
 
152
- /** The dimensions holding the lowest score (ties together). */
157
+ /** The dimensions holding the lowest score (ties together), polish as the rubric's arithmetic leaves it. */
153
158
  export function lowestDimensions(answer: CriticAnswer): CriticDimension[] {
154
- const low = Math.min(...CRITIC_DIMENSIONS.map(d => answer.scores[d].score));
155
- return CRITIC_DIMENSIONS.filter(d => answer.scores[d].score === low);
159
+ const score = (d: CriticDimension) => (d === CriticDimension.Polish ? polishOf(answer) : answer.scores[d].score);
160
+ const low = Math.min(...CRITIC_DIMENSIONS.map(score));
161
+ return CRITIC_DIMENSIONS.filter(d => score(d) === low);
162
+ }
163
+
164
+ /** Polish by the rubric's arithmetic: the critic's score, never above what its bugs leave (each costs
165
+ * `CRITIC_RUBRIC_POLISH.bugPenalty`), never below 0. The model's count is not refused for a slip of arithmetic — the
166
+ * file does the sum (AD3 calibration: 6 of 48 answers were refused for a polish above it). */
167
+ export function polishOf(answer: CriticAnswer): number {
168
+ const allowed = CRITIC_SCORE.max - CRITIC_RUBRIC_POLISH.bugPenalty * answer.bugs.length;
169
+ return Math.max(CRITIC_SCORE.min, Math.min(answer.scores[CriticDimension.Polish].score, allowed));
156
170
  }
157
171
 
158
172
  export interface CriticVerdict {
@@ -171,5 +185,5 @@ export function criticVerdict(answer: CriticAnswer): CriticVerdict {
171
185
  const designMean = CRITIC_DESIGN_DIMENSIONS.reduce((sum, d) => sum + answer.scores[d].score, 0) / CRITIC_DESIGN_DIMENSIONS.length;
172
186
  const broken = answer.bugs.filter(b => b.broken).length;
173
187
  const capped = broken > 0 && designMean > CRITIC_RUBRIC_POLISH.brokenCap;
174
- return { designMean, polish: answer.scores[CriticDimension.Polish].score, broken, headline: capped ? CRITIC_RUBRIC_POLISH.brokenCap : designMean, capped };
188
+ return { designMean, polish: polishOf(answer), broken, headline: capped ? CRITIC_RUBRIC_POLISH.brokenCap : designMean, capped };
175
189
  }
@@ -1,4 +1,4 @@
1
- import { CRITIC_DIMENSIONS, CriticAnswer, CriticDimension } from './critic';
1
+ import { CriticAnswer, CriticDimension, lowestDimensions, polishOf } from './critic';
2
2
  import { FreedomIssue, FreedomIssueCode } from './structure-fingerprint';
3
3
 
4
4
  /**
@@ -72,8 +72,9 @@ export function roundBrief(input: RoundBriefInput): RoundBrief {
72
72
  const score = critique.scores[c.dimension as CriticDimension]?.score;
73
73
  lines.push(`${i + 1}. [${c.dimension}${typeof score === 'number' ? ` ${score}` : ''}] ${c.brief}`);
74
74
  });
75
- const lowest = CRITIC_DIMENSIONS.reduce((low, d) => (critique.scores[d].score < critique.scores[low].score ? d : low), CRITIC_DIMENSIONS[0]);
76
- lines.push(`Lowest: ${lowest} ${critique.scores[lowest].score} — ${critique.scores[lowest].evidence}`);
75
+ const lowest = lowestDimensions(critique)[0];
76
+ const lowScore = lowest === CriticDimension.Polish ? polishOf(critique) : critique.scores[lowest].score;
77
+ lines.push(`Lowest: ${lowest} ${lowScore} — ${critique.scores[lowest].evidence}`);
77
78
  for (const bug of critique.bugs.filter(b => !b.broken)) lines.push(`Bug: ${bug.what}`);
78
79
  lines.push('Every round:');
79
80
  for (const r of DESIGNER_ROUND_RULES) lines.push(`- ${r.rule}`);
@@ -1,4 +1,4 @@
1
- import { AiKeyMode, AiTokenCounts, costUsd, creditsOfUsd } from './ai-run';
1
+ import { AI_STEP_TYPICAL_TOKENS, AiKeyMode, AiStep, AiTokenCounts, costUsd, creditsOfUsd } from './ai-run';
2
2
  import { DESIGNER_ROUND_CAPS, DesignerPageRole } from './designer-stop';
3
3
  import { outwardCredits, QuoteRoute } from './start-quote';
4
4
 
@@ -20,8 +20,8 @@ import { outwardCredits, QuoteRoute } from './start-quote';
20
20
 
21
21
  /** §6b: one critique (≈ 20 pictures, the reference's cached) and one revise (the page as compact ops), per round. */
22
22
  export const DESIGNER_ROUND_TOKENS: Readonly<{ critique: AiTokenCounts; revise: AiTokenCounts }> = {
23
- critique: { input: 35_500, output: 4_000, cacheWrite: 0, cacheRead: 35_000 },
24
- revise: { input: 14_000, output: 10_000, cacheWrite: 0, cacheRead: 15_000 },
23
+ critique: AI_STEP_TYPICAL_TOKENS[AiStep.DesignCritique],
24
+ revise: AI_STEP_TYPICAL_TOKENS[AiStep.DesignRevise],
25
25
  };
26
26
  /** §6c: the rounds a page takes at today's proof rates, with the batch A/B fixes and the seeded lessons. */
27
27
  export const DESIGNER_ROUNDS_EXPECTED: Readonly<Record<DesignerPageRole, number>> = {
@@ -38,6 +38,9 @@ export interface MeasuredLayer {
38
38
  box: LayoutRect;
39
39
  /** Where its words are (a text's line boxes, a button's box); null when it carries none. */
40
40
  words: LayoutRect | null;
41
+ /** Where what it HOLDS stands, when that is not its box: a list's rows inside the cell it stretches over (iox-ui#207).
42
+ * Absent: its box. */
43
+ content?: LayoutRect;
41
44
  /** On a laptop, in a held section: the stretches of its play its opacity tracks show it (`layerShownSpans`); absent,
42
45
  * it shows throughout. Measured at rest every layer shows, so words that take turns would read as overlapping. */
43
46
  shown?: Array<[number, number]>;
@@ -76,9 +79,15 @@ export interface LayerMetrics {
76
79
  /** An element's box in the root's coordinates. */
77
80
  box(el: Element): LayoutRect;
78
81
  /** A node's box, its words (a text's line boxes, a button's box — when it carries words of a word `kind`), z and type. */
79
- layer(el: Element, kind: string): Pick<MeasuredLayer, 'kind' | 'z' | 'box' | 'words' | 'size' | 'weight' | 'color'>;
82
+ layer(el: Element, kind: string): Pick<MeasuredLayer, 'kind' | 'z' | 'box' | 'words' | 'content' | 'size' | 'weight' | 'color'>;
80
83
  }
81
84
 
85
+ /** The kinds whose box is a cell they stretch over, not what they hold (a list's frame): their content is measured. */
86
+ const HOLDER_KINDS: ReadonlySet<string> = new Set(['gallery']);
87
+ const union = (rects: ReadonlyArray<LayoutRect>): LayoutRect | null => (rects.length ? {
88
+ l: Math.min(...rects.map(r => r.l)), t: Math.min(...rects.map(r => r.t)), r: Math.max(...rects.map(r => r.r)), b: Math.max(...rects.map(r => r.b)),
89
+ } : null);
90
+
82
91
  /** In the browser: the reader of the nodes rendered under `root`, in the root's own coordinates. */
83
92
  export function layerMetricsOf(root: Element): LayerMetrics {
84
93
  const origin = root.getBoundingClientRect();
@@ -102,8 +111,11 @@ export function layerMetricsOf(root: Element): LayerMetrics {
102
111
  words = tight && tight.width > 0 ? rel(tight) : box;
103
112
  }
104
113
  }
114
+ const held = HOLDER_KINDS.has(kind)
115
+ ? union(Array.from(el.children).map(c => rel(c.getBoundingClientRect())).filter(r => r.r > r.l && r.b > r.t))
116
+ : null;
105
117
  return {
106
- kind, z: Number(style?.zIndex) || 0, box, words,
118
+ kind, z: Number(style?.zIndex) || 0, box, words, ...(held ? { content: held } : {}),
107
119
  size: parseFloat(style?.fontSize ?? '') || 16, weight: Number(style?.fontWeight) || 400, color: style?.color ?? '',
108
120
  };
109
121
  },
@@ -230,8 +242,20 @@ export const RENDER_CHECK = {
230
242
  contrastBody: 4.5,
231
243
  /** The light's spread over which a part of a photo is busy. */
232
244
  busy: 0.11,
245
+ /** iox-ui#207: a laid section's content may end at most this share of a screen above its bottom — more reads as an
246
+ * empty screen at rest (the café's dish grid ended 1105 px above its section's bottom; one line held a whole screen). */
247
+ emptyBelow: 0.5,
233
248
  } as const;
234
249
 
250
+ /** Kinds that decorate, never hold: a shape over a whole section does not make it full. */
251
+ const DECORATION_KINDS: ReadonlySet<string> = new Set(['shape']);
252
+
253
+ /** Where a section's content ends, by the bottoms of its layers' words, held content or boxes; null with none measured. */
254
+ function contentEnd(layers: ReadonlyArray<MeasuredLayer>): number | null {
255
+ const ends = layers.filter(l => !DECORATION_KINDS.has(l.kind)).map(l => (l.words ?? l.content ?? l.box).b);
256
+ return ends.length ? Math.max(...ends) : null;
257
+ }
258
+
235
259
  const ratio = (a: number, b: number) => (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05);
236
260
 
237
261
  /** Measured boxes (each viewport) + the pixels under the words on photos → the render issues, by path, said once each. */
@@ -285,6 +309,15 @@ export function judgeLayoutRender(measured: ReadonlyArray<MeasuredLayout>, pixel
285
309
  }
286
310
  }
287
311
  if (on === LayoutViewport.Phone && m.scrollWidth > m.width + 1) say('sideways', 'sections', `the page scrolls sideways on a phone (${m.scrollWidth - m.width}px too wide)`);
312
+ // iox-ui#207: no resting screen of flat ground — a section (not a held stage: its runway scrolls under it) whose
313
+ // content ends more than half a screen above its bottom.
314
+ m.sections.forEach((sec, i) => {
315
+ const end = sec.held || sec.height <= 0 ? null : contentEnd(m.layers.filter(l => l.section === i));
316
+ const empty = end === null ? 0 : sec.top + sec.height - end;
317
+ if (empty > RENDER_CHECK.emptyBelow * m.height) {
318
+ say(`empty:${i}:${on}`, `sections[${i}]`, `sections[${i}]: its content ends ${Math.round(empty)}px (${(empty / m.height).toFixed(1)} of a screen) above its bottom on the ${on} — fewer screens or rows, or something in the empty rows`);
319
+ }
320
+ });
288
321
  }
289
322
  const layerAt = new Map(measured.flatMap(m => m.layers.map(l => [`${m.viewport}:${l.path}`, l] as const)));
290
323
  for (const px of pixels) {
@@ -1,6 +1,6 @@
1
1
  import { AccountRole, ShopRole } from '@vectoriox/iox-ui/composite-core';
2
2
  import { commerceLanguage } from '@vectoriox/iox-ui/commerce-core';
3
- import { LinkType, MenuButtonKind, menuButtonOf, menuButtonProps, menuDialogProps, MenuLook, MenuShows, menuShowsOf, MenuTrait } from '@vectoriox/iox-ui/design-core';
3
+ import { LinkType, MenuButtonKind, menuButtonOf, menuButtonProps, menuDialogProps, MenuLook, MenuShows, menuShowsOf, MenuTrait, textWidthEm } from '@vectoriox/iox-ui/design-core';
4
4
 
5
5
  import { PatternGlobalPosition } from './patterns';
6
6
  import { createSerializedNode, SerializedNode, walkSerialized } from './serialized-node';
@@ -244,6 +244,60 @@ export function barIconForRoute(route: string): string {
244
244
  return ROUTE_ICONS.find(([re]) => re.test(route))?.[1] ?? FALLBACK_ICON;
245
245
  }
246
246
 
247
+ /** iox-ui#196: the narrowest phone a bar is drawn for, and its label's size (`tabbar-label-size`: the live bars measured
248
+ * 11–11.7 px) — the bar's `6px 8px` padding, its 4 px gaps and an item's 2 px sides are the bar's own (`bar`,
249
+ * `BAR_ITEM_LAY`). A label is measured in Poppins at 500, a wide sans of the looks, so a narrower face fits too. */
250
+ const BAR_PHONE_PX = 360;
251
+ const BAR_LABEL_PX = 12;
252
+ const BAR_SIDES_PX = 16;
253
+ const BAR_GAP_PX = 4;
254
+ const BAR_ITEM_SIDES_PX = 4;
255
+ const BAR_LABEL_FACE = { stack: 'Poppins', weight: 500, tracking: 0 } as const;
256
+ /** The short word a page is said by in a bar, by its address (its page name aside) — only where its name does not fit. */
257
+ const BAR_SHORT_WORDS: ReadonlyArray<[RegExp, Readonly<Record<'en' | 'he', string>>]> = [
258
+ // first match wins — "workshops" holds both "work" and "shop"
259
+ [/workshop|class|course/i, { en: 'Classes', he: 'סדנאות' }],
260
+ [/menu/i, { en: 'Menu', he: 'תפריט' }],
261
+ [/book|reserv/i, { en: 'Booking', he: 'הזמנה' }],
262
+ [/contact/i, { en: 'Contact', he: 'צור קשר' }],
263
+ [/visit|find|location|directions/i, { en: 'Visit', he: 'הגעה' }],
264
+ [/about|story/i, { en: 'About', he: 'אודות' }],
265
+ [/team/i, { en: 'Team', he: 'צוות' }],
266
+ [/shop|store|product/i, { en: 'Shop', he: 'חנות' }],
267
+ [/work|project|portfolio/i, { en: 'Work', he: 'עבודות' }],
268
+ [/journal|blog|news/i, { en: 'Journal', he: 'בלוג' }],
269
+ [/service|treatment/i, { en: 'Services', he: 'שירותים' }],
270
+ [/room|stay/i, { en: 'Rooms', he: 'חדרים' }],
271
+ [/galler/i, { en: 'Gallery', he: 'גלריה' }],
272
+ [/faq|question/i, { en: 'FAQ', he: 'שאלות' }],
273
+ [/pric/i, { en: 'Prices', he: 'מחירים' }],
274
+ [/event/i, { en: 'Events', he: 'אירועים' }],
275
+ ];
276
+
277
+ /** True when `words` stand on one line inside one of `items` bar items on the narrowest phone (iox-ui#196). */
278
+ export function barLabelFits(words: string, items: number): boolean {
279
+ const n = Math.max(1, items);
280
+ const room = (BAR_PHONE_PX - BAR_SIDES_PX - BAR_GAP_PX * (n - 1)) / n - BAR_ITEM_SIDES_PX;
281
+ return textWidthEm(words, BAR_LABEL_FACE) * BAR_LABEL_PX <= room;
282
+ }
283
+
284
+ /**
285
+ * What a bar item says (iox-ui#196): the page's name where it fits its item on the narrowest phone, else the short word
286
+ * its address is said by in the site's language ("Request a booking" → Booking, "יצירת קשר והגעה" → צור קשר) unless
287
+ * another item already says it; a page no short word names keeps its name (the shared CSS ends it with …). The item's
288
+ * layer name stays the page's name. Pure.
289
+ */
290
+ export function barLabels(pages: ReadonlyArray<NavPage>, items: number, locale?: string): string[] {
291
+ const lang = commerceLanguage(locale) === 'he' ? 'he' : 'en';
292
+ const out = pages.map(p => p.label);
293
+ pages.forEach((page, i) => {
294
+ if (barLabelFits(page.label, items)) return;
295
+ const word = BAR_SHORT_WORDS.find(([re]) => re.test(page.route))?.[1][lang];
296
+ if (word && barLabelFits(word, items) && !out.some(l => navWordKey(l, lang) === navWordKey(word, lang))) out[i] = word;
297
+ });
298
+ return out;
299
+ }
300
+
247
301
  /** One page the navigation links to, read off its links. */
248
302
  export interface NavPage {
249
303
  label: string;
@@ -647,10 +701,10 @@ function dressMenu(kit: Kit, dr: SerializedNode | null, menu: SerializedNode | n
647
701
  if (close) dressButton(kit, close, 'drawer-close', look.button, true, words);
648
702
  }
649
703
 
650
- function barItem(kit: Kit, i: number, page: NavPage): SerializedNode {
704
+ function barItem(kit: Kit, i: number, page: NavPage, says: string): SerializedNode {
651
705
  const item = part(kit, `bar-item-${i}`, LINKED, { linkType: LinkType.Page, pageRoute: page.route, target: '_self' }, 'bottom-bar-item', NavRole.BarItem, BAR_ITEM_LAY);
652
706
  item.label = page.label;
653
- item.children = [iconNode(kit, `bar-item-${i}-icon`, barIconForRoute(page.route)), labelText(kit, `bar-item-${i}-label`, page.label)];
707
+ item.children = [iconNode(kit, `bar-item-${i}-icon`, barIconForRoute(page.route)), labelText(kit, `bar-item-${i}-label`, says)];
654
708
  return item;
655
709
  }
656
710
 
@@ -679,14 +733,16 @@ function barPages(root: SerializedNode, pages: NavPage[], count: number, words:
679
733
  return withHome(root, pages, words).slice(0, count);
680
734
  }
681
735
 
682
- function bar(kit: Kit, root: SerializedNode, pages: NavPage[], shape: NavShape, count: number, drawerId: string | null, at: string, words: MenuWords): SerializedNode {
736
+ function bar(kit: Kit, root: SerializedNode, pages: NavPage[], shape: NavShape, count: number, drawerId: string | null, at: string, words: MenuWords, locale?: string): SerializedNode {
683
737
  // The node IS fixed (not only its element style): the builder canvas forces a node's own `position`
684
738
  // with !important, so a stored `static` default would pin the bar into the flow there.
685
739
  const b = part(kit, 'bar', CONTAINER, { htmlTag: 'nav' }, 'bottom-bar', NavRole.Bar,
686
740
  { position: 'fixed', justifyContent: 'space-around', alignItems: 'stretch', gap: '4px', padding: '6px 8px', width: 'auto' });
687
741
  phoneOnly(b, at, 'flex');
688
742
  const itemCount = shape === NavShape.Both ? count - 1 : count;
689
- b.children = barPages(root, pages, itemCount, words).map((p, i) => barItem(kit, i, p));
743
+ const shown = barPages(root, pages, itemCount, words);
744
+ const says = barLabels(shown, shown.length + (shape === NavShape.Both && drawerId ? 1 : 0), locale);
745
+ b.children = shown.map((p, i) => barItem(kit, i, p, says[i]));
690
746
  if (shape === NavShape.Both && drawerId) b.children.push(moreItem(kit, drawerId, words));
691
747
  b.isGlobal = true;
692
748
  b.globalPosition = PatternGlobalPosition.After;
@@ -869,7 +925,7 @@ export function planNavShape(globals: ReadonlyArray<SerializedNode>, shape: NavS
869
925
  let more: SerializedNode | null = null;
870
926
  if (wantBar) {
871
927
  const count = clampBarCount(options.barItems, shape);
872
- if (!b) b = bar(kit, root, pages, shape, count, dr?.id ?? null, at, words);
928
+ if (!b) b = bar(kit, root, pages, shape, count, dr?.id ?? null, at, words, options.locale);
873
929
  else {
874
930
  moveDisplayOverride(b, at);
875
931
  more = (b.children ?? []).find(c => c.role === NavRole.More) ?? null;
@@ -879,7 +935,10 @@ export function planNavShape(globals: ReadonlyArray<SerializedNode>, shape: NavS
879
935
  const want = shape === NavShape.Both ? count - 1 : count;
880
936
  const extra = barPages(root, pages, BAR_ITEMS_MAX, words).filter(p => !items.some(c => prop(c, 'pageRoute') === p.route));
881
937
  while (items.length > want) items.pop();
882
- while (items.length < want && extra.length) items.push(barItem(kit, items.length, extra.shift()!));
938
+ while (items.length < want && extra.length) {
939
+ const page = extra.shift()!;
940
+ items.push(barItem(kit, items.length, page, barLabels([page], want + (shape === NavShape.Both ? 1 : 0), options.locale)[0]));
941
+ }
883
942
  }
884
943
  if (shape === NavShape.Both && dr) b.children.push(retarget(more ?? moreItem(kit, dr.id, words), dr.id));
885
944
  }
@@ -944,7 +1003,7 @@ export function addBarItem(globals: ReadonlyArray<SerializedNode>, options: Pick
944
1003
  const words = menuWords(options.locale, sitePages.map(p => p.label));
945
1004
  const page = barPages(root, sitePages, BAR_ITEMS_MAX + 1, words).find(p => !linked.has(p.route))
946
1005
  ?? { label: words.home, route: HOME_ROUTE };
947
- const item = barItem(makeKit(out, root.id, options.newId), kids.length, page);
1006
+ const item = barItem(makeKit(out, root.id, options.newId), kids.length, page, barLabels([page], kids.length + 1, options.locale)[0]);
948
1007
  const more = kids.findIndex(c => c.role === NavRole.More);
949
1008
  if (more >= 0) kids.splice(more, 0, item); else kids.push(item);
950
1009
  return { globals: out, added: true };