@vectoriox/iox-ui 5.89.0 → 5.90.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/design-core/index.d.ts +523 -2
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +581 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +8403 -4898
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +12 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs +33 -6
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +3 -2
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +1735 -507
- package/harness-core/index.d.ts +52 -3
- package/package.json +1 -1
- package/scene-core/index.d.ts +19 -2
- package/src/design-core/flavor-spec.generated.ts +500 -0
- package/src/design-core/font-metrics.ts +105 -0
- package/src/design-core/public-api.ts +1 -0
- package/src/generation-core/ai-run.ts +11 -0
- package/src/generation-core/audit-site.ts +5 -0
- package/src/generation-core/check-layout.ts +940 -0
- package/src/generation-core/compose-layout.ts +120 -34
- package/src/generation-core/compose-site.ts +122 -3
- package/src/generation-core/layout-drift.ts +78 -0
- package/src/generation-core/layout-edits.ts +122 -0
- package/src/generation-core/layout-fingerprint.ts +203 -0
- package/src/generation-core/layout-language.ts +195 -12
- package/src/generation-core/layout-look.ts +57 -0
- package/src/generation-core/layout-photos.ts +19 -0
- package/src/generation-core/layout-render-check.ts +275 -0
- package/src/generation-core/layout-section-fallback.ts +156 -0
- package/src/generation-core/layout-type.ts +48 -0
- package/src/generation-core/layout-wire.ts +282 -0
- package/src/generation-core/nav-shape.ts +23 -1
- package/src/generation-core/photo-inventory.ts +250 -0
- package/src/generation-core/plan-edits.ts +25 -2
- package/src/generation-core/plan-wire.ts +19 -2
- package/src/generation-core/public-api.ts +11 -0
- package/src/generation-core/site-plan.model.ts +16 -0
- package/src/generation-core/site-spec.generated.ts +759 -2
- package/src/generation-core/validate-site-plan.ts +55 -1
- package/src/harness-core/generation-view.ts +52 -1
- package/src/scene-core/scroll-driver.ts +14 -2
- package/src/scene-core/scroll-range.ts +23 -3
- package/styles/iox-forms.css +4 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { designTokenRows } from './design-apply';
|
|
2
|
+
import { DesignChoices } from './design-token.model';
|
|
3
|
+
import { ELEMENT_STYLES } from './element-styles';
|
|
4
|
+
import { SPEC_FONT_METRICS } from './flavor-spec.generated';
|
|
5
|
+
import { matchFontWeight, parseFontFamilies } from './fonts';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* How wide words are in a face, from the catalog fonts' own letters (iox-ui#46). The contract's `fontMetrics` holds each
|
|
9
|
+
* letter's advance in every catalog family and weight, measured from the files a page links (iox-ai-guidance
|
|
10
|
+
* measure-fonts.mjs). A letter is read the way a browser draws it: the first family in the stack that draws it, at the
|
|
11
|
+
* weight CSS font matching picks. A family the catalog does not hold (an uploaded font, system-ui) reads each letter at
|
|
12
|
+
* the widest any catalog face draws it — never narrower than what the page could wear. No kerning: a display face's
|
|
13
|
+
* kerning closes letters up, so the sum is the wider answer. Pure and deterministic: the composer and the check agree.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** A face as a style wears it: its font stack, weight and letter spacing (em). */
|
|
17
|
+
export interface TypeFace {
|
|
18
|
+
stack: string;
|
|
19
|
+
weight: number;
|
|
20
|
+
tracking: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
enum Script {
|
|
24
|
+
Latin = 'latin',
|
|
25
|
+
Hebrew = 'hebrew',
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const HEBREW = /[-יִ-ﭏ]/;
|
|
29
|
+
const MARK = /\p{M}/u;
|
|
30
|
+
const PER_EM = 1000;
|
|
31
|
+
|
|
32
|
+
type Row = ReadonlyArray<number>;
|
|
33
|
+
const ALPHABETS: Readonly<Record<Script, ReadonlyArray<string>>> = {
|
|
34
|
+
[Script.Latin]: Array.from(SPEC_FONT_METRICS.alphabets.latin),
|
|
35
|
+
[Script.Hebrew]: Array.from(SPEC_FONT_METRICS.alphabets.hebrew),
|
|
36
|
+
};
|
|
37
|
+
const FAMILIES = SPEC_FONT_METRICS.families as Readonly<Record<string, Readonly<Record<string, Partial<Record<Script, string>>>>>>;
|
|
38
|
+
const parsed = new Map<string, Row>();
|
|
39
|
+
|
|
40
|
+
function rowOf(key: string, csv: string): Row {
|
|
41
|
+
let row = parsed.get(key);
|
|
42
|
+
if (!row) parsed.set(key, (row = csv.split(',').map(Number)));
|
|
43
|
+
return row;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const widest = (row: Row) => Math.max(...row.filter(v => v >= 0));
|
|
47
|
+
const FALLBACK: Readonly<Record<Script, Row>> = {
|
|
48
|
+
[Script.Latin]: rowOf('fallback:latin', SPEC_FONT_METRICS.fallback.latin),
|
|
49
|
+
[Script.Hebrew]: rowOf('fallback:hebrew', SPEC_FONT_METRICS.fallback.hebrew),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** A measured family's row for a script at the weight CSS would pick, or null when that family does not draw it. */
|
|
53
|
+
function familyRow(family: string, weight: number, script: Script): Row | null {
|
|
54
|
+
const weights = FAMILIES[family];
|
|
55
|
+
const face = matchFontWeight(Object.keys(weights).map(w => ({ weight: Number(w) })), weight);
|
|
56
|
+
const csv = face ? weights[String(face.weight)]?.[script] : undefined;
|
|
57
|
+
return csv ? rowOf(`${family}:${face!.weight}:${script}`, csv) : null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** One letter's advance in thousandths of an em, as the stack draws it. */
|
|
61
|
+
function advanceOf(ch: string, families: ReadonlyArray<string>, weight: number): number {
|
|
62
|
+
const script = HEBREW.test(ch) ? Script.Hebrew : Script.Latin;
|
|
63
|
+
const at = ALPHABETS[script].indexOf(ch);
|
|
64
|
+
for (const family of families) {
|
|
65
|
+
if (!FAMILIES[family]) break;
|
|
66
|
+
const row = familyRow(family, weight, script);
|
|
67
|
+
if (!row) continue;
|
|
68
|
+
if (at < 0) return widest(row);
|
|
69
|
+
if (row[at] >= 0) return row[at];
|
|
70
|
+
}
|
|
71
|
+
const row = FALLBACK[script];
|
|
72
|
+
return at >= 0 && row[at] >= 0 ? row[at] : widest(row);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** How wide `text` stands in `face`, in em, on one line: every letter's advance plus the letter spacing after each. */
|
|
76
|
+
export function textWidthEm(text: string, face: TypeFace): number {
|
|
77
|
+
const families = parseFontFamilies(face.stack);
|
|
78
|
+
let width = 0;
|
|
79
|
+
for (const ch of Array.from(String(text ?? ''))) {
|
|
80
|
+
if (MARK.test(ch)) continue;
|
|
81
|
+
width += advanceOf(ch, families, face.weight) / PER_EM + face.tracking;
|
|
82
|
+
}
|
|
83
|
+
return Math.max(0, width);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const TOKEN = /^var\(--iox-([\w-]+)\)$/;
|
|
87
|
+
const DEFAULT_FACE: Readonly<Record<'fontFamily' | 'fontWeight' | 'letterSpacing', string>> = {
|
|
88
|
+
fontFamily: 'var(--iox-font-display)', fontWeight: 'var(--iox-weight-display)', letterSpacing: 'var(--iox-tracking-display)',
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The face an element style wears in a design: its font, weight and letter spacing as the design's tokens resolve them.
|
|
93
|
+
* An unknown style reads the display face; a letter spacing not in em reads none.
|
|
94
|
+
*/
|
|
95
|
+
export function elementStyleFace(choices: DesignChoices, styleId: string): TypeFace {
|
|
96
|
+
const rows = new Map(designTokenRows(choices).map(r => [r.name, r.value]));
|
|
97
|
+
const base = (ELEMENT_STYLES.find(s => s.id === styleId)?.base ?? DEFAULT_FACE) as Readonly<Record<string, string | undefined>>;
|
|
98
|
+
const read = (prop: keyof typeof DEFAULT_FACE): string => {
|
|
99
|
+
const value = base[prop] ?? '';
|
|
100
|
+
const token = TOKEN.exec(value)?.[1];
|
|
101
|
+
return token ? rows.get(token) ?? '' : value;
|
|
102
|
+
};
|
|
103
|
+
const spacing = /^(-?[\d.]+)em$/.exec(read('letterSpacing').trim());
|
|
104
|
+
return { stack: read('fontFamily'), weight: Number(read('fontWeight')) || 400, tracking: spacing ? Number(spacing[1]) : 0 };
|
|
105
|
+
}
|
|
@@ -29,6 +29,7 @@ export * from './flavor-seed';
|
|
|
29
29
|
export * from './spring';
|
|
30
30
|
export * from './entrance-timing';
|
|
31
31
|
export * from './fonts';
|
|
32
|
+
export * from './font-metrics';
|
|
32
33
|
export * from './token-names';
|
|
33
34
|
export * from './design-settings';
|
|
34
35
|
export * from './design-apply';
|
|
@@ -30,6 +30,8 @@ export enum AiStep {
|
|
|
30
30
|
/** M7: a small vision model looks at each made picture against its slot (one structured answer). */
|
|
31
31
|
CheckPictures = 'imageReview',
|
|
32
32
|
NameStructures = 'scanNaming',
|
|
33
|
+
/** M8 gate 2: each composed page's layout, one strict request a page, after the plan (M8-G2-D2). */
|
|
34
|
+
ComposePages = 'composePages',
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
export const AI_STEPS: ReadonlyArray<AiStep> = Object.values(AiStep);
|
|
@@ -42,6 +44,7 @@ export const AI_STEP_LABELS: Readonly<Record<AiStep, string>> = {
|
|
|
42
44
|
[AiStep.MakePictures]: 'Make pictures',
|
|
43
45
|
[AiStep.CheckPictures]: 'Check pictures',
|
|
44
46
|
[AiStep.NameStructures]: 'Name repeated structures',
|
|
47
|
+
[AiStep.ComposePages]: 'Compose your pages',
|
|
45
48
|
};
|
|
46
49
|
|
|
47
50
|
/** What a model must be able to do for a step to run on it. */
|
|
@@ -58,6 +61,7 @@ export const AI_STEP_NEEDS: Readonly<Record<AiStep, ReadonlyArray<AiCapability>>
|
|
|
58
61
|
[AiStep.MakePictures]: [AiCapability.ImageOutput],
|
|
59
62
|
[AiStep.CheckPictures]: [AiCapability.StructuredOutput, AiCapability.ImageInput],
|
|
60
63
|
[AiStep.NameStructures]: [AiCapability.StructuredOutput],
|
|
64
|
+
[AiStep.ComposePages]: [AiCapability.StructuredOutput],
|
|
61
65
|
};
|
|
62
66
|
|
|
63
67
|
/**
|
|
@@ -105,6 +109,10 @@ export const AI_STEP_TYPICAL_TOKENS: Readonly<Record<AiStep, AiTokenCounts>> = {
|
|
|
105
109
|
// keep the estimate above it.
|
|
106
110
|
[AiStep.CheckPictures]: { input: 3_600, output: 300, cacheWrite: 0, cacheRead: 0 },
|
|
107
111
|
[AiStep.NameStructures]: { input: 80_000, output: 10_000, cacheWrite: 0, cacheRead: 0 },
|
|
112
|
+
// M8 gate 2: two composed pages (Home ≈ 10k in, the second ≈ 2k past the cached prefix) and one repair; each answer ≈
|
|
113
|
+
// 4.5k words + 2–4k thinking. Counted as plain input so the Start gate holds the whole cost (iox-cms#43); the live
|
|
114
|
+
// measurement of step 5 recalibrates it.
|
|
115
|
+
[AiStep.ComposePages]: { input: 14_000, output: 18_000, cacheWrite: 0, cacheRead: 0 },
|
|
108
116
|
};
|
|
109
117
|
|
|
110
118
|
/** Tokens by the class a provider prices them in. */
|
|
@@ -140,6 +148,9 @@ export interface AiModelEntry {
|
|
|
140
148
|
recommendedFor?: ReadonlyArray<`${AiStep}`>;
|
|
141
149
|
/** The steps it runs when the default is not available (the control plane's `fallbackModel`). */
|
|
142
150
|
fallbackFor?: ReadonlyArray<`${AiStep}`>;
|
|
151
|
+
/** The steps whose FOLLOWING requests it is the default for, when the studio chose no model: a page composed after
|
|
152
|
+
* Home (M8 gate 2 follow-up D4 — Opus composes Home, Sonnet the second page). None = the step's default runs them. */
|
|
153
|
+
followingFor?: ReadonlyArray<`${AiStep}`>;
|
|
143
154
|
capabilities: ReadonlyArray<`${AiCapability}`>;
|
|
144
155
|
/** Null when the provider reports each call's cost itself and the list carries no price. */
|
|
145
156
|
price: AiTokenPrice | null;
|
|
@@ -320,8 +320,13 @@ function checkAccessibility(ctx: Ctx, snapshot: SiteAuditSnapshot, pages: Readon
|
|
|
320
320
|
});
|
|
321
321
|
if (h1 > 1) add(ctx, SiteFindingCode.HeadingOrder, `"${page.name}" has ${h1} main headings (h1); one is clearer.`, { pageId: page.id });
|
|
322
322
|
}
|
|
323
|
+
const said = new Set((snapshot.missing ?? []).map(s => s.nodeId));
|
|
323
324
|
eachNode(snapshot, pages, (n, where) => {
|
|
324
325
|
if (n.type !== 'Image') return;
|
|
326
|
+
if (!nonEmpty(n.props['src']) && !n.bindings.some(b => b.prop === 'src')) {
|
|
327
|
+
if (!said.has(n.id)) add(ctx, SiteFindingCode.PictureMissing, 'A box on this page waits for a picture — add one of yours.', { ...where, nodeId: n.id });
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
325
330
|
const decorative = n.props['alt'] === '' && n.props['decorative'] === true;
|
|
326
331
|
const bound = n.bindings.some(b => b.prop === 'alt');
|
|
327
332
|
if (!decorative && !bound && !nonEmpty(n.props['alt'])) add(ctx, SiteFindingCode.ImageWithoutAlt, 'A picture has no description for people who cannot see it.', { ...where, nodeId: n.id });
|