@vectoriox/iox-ui 5.203.0 → 5.205.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/actions-core/index.d.ts +8 -1
- package/design-core/index.d.ts +70 -2
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs +8 -1
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +131 -11
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +5294 -267
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +524 -112
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +2308 -6
- package/index.d.ts +159 -13
- package/package.json +1 -1
- package/src/actions-core/element-actions.ts +9 -0
- package/src/design-core/contrast-audit.ts +93 -11
- package/src/design-core/flavor-spec.generated.ts +19 -0
- package/src/design-core/image-alt.ts +27 -0
- package/src/design-core/node-links.ts +12 -0
- package/src/design-core/public-api.ts +1 -0
- package/src/generation-core/ai-run.ts +31 -0
- package/src/generation-core/audit-site.ts +17 -3
- package/src/generation-core/baseline-roles.ts +10 -6
- package/src/generation-core/check-free.ts +12 -2
- package/src/generation-core/check-layout.ts +3 -2
- package/src/generation-core/critic-calibration.ts +178 -0
- package/src/generation-core/critic-prompt.ts +174 -0
- package/src/generation-core/critic-rubric.generated.ts +24 -0
- package/src/generation-core/critic-sheet.ts +270 -0
- package/src/generation-core/critic.ts +189 -0
- package/src/generation-core/design-doc-index.ts +58 -0
- package/src/generation-core/design-motion.ts +247 -0
- package/src/generation-core/design-ops-check.ts +370 -0
- package/src/generation-core/design-ops-of.ts +200 -0
- package/src/generation-core/design-ops.model.ts +239 -0
- package/src/generation-core/design-ops.schema.ts +122 -0
- package/src/generation-core/design-ops.ts +361 -0
- package/src/generation-core/design-recipes.ts +58 -0
- package/src/generation-core/designer-brief.ts +82 -0
- package/src/generation-core/designer-direction.ts +248 -0
- package/src/generation-core/designer-estimate.ts +171 -0
- package/src/generation-core/designer-lessons.generated.ts +653 -0
- package/src/generation-core/designer-lessons.ts +153 -0
- package/src/generation-core/designer-stop.ts +94 -0
- package/src/generation-core/footer-mix.ts +3 -1
- package/src/generation-core/node-baselines.generated.ts +953 -10
- package/src/generation-core/public-api.ts +20 -0
- package/src/generation-core/site-spec.generated.ts +73 -11
- package/src/generation-core/social-links.ts +195 -2
- package/src/generation-core/structure-fingerprint.ts +565 -0
- package/src/generation-core/templates.ts +39 -3
- package/styles/iox-design.css +26 -1
- package/styles/iox-forms.css +22 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { DESIGN_ACT_VALUES, DESIGN_PARAM_PREFIX, DESIGN_PICTURE_PROPS, DESIGN_WORD_PROPS } from './design-ops-check';
|
|
2
|
+
import { placedDesignNode } from './design-ops';
|
|
3
|
+
import {
|
|
4
|
+
DESIGN_BASE_LAYER, DESIGN_END_INDEX, DESIGN_FONTS_CHOICE, DESIGN_NO_STYLE, DESIGN_PAGE_PARENT, DESIGN_TRIGGER_META, DesignLook, DesignMeta, DesignOp,
|
|
5
|
+
DesignSceneRow, DesignTool, DesignTrait, DesignValue, LookEditKind, PlaceOp,
|
|
6
|
+
} from './design-ops.model';
|
|
7
|
+
import type { SerializedNode } from './serialized-node';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A SAVED PAGE AS THE DESIGNER'S OPS (AD1, the replay — ai-designer-plan §2b, R-H2): each node as the one `place` that
|
|
11
|
+
* drops it, then what a person would do to it — type its words, choose its picture, its Style-panel values (base, widths,
|
|
12
|
+
* states), its Interactions rows, its Scene tracks — then its children. Only what differs from the palette's new node is
|
|
13
|
+
* written, so this is also the compact form a revise round speaks (§2e). Whatever a saved node holds that no tool can
|
|
14
|
+
* write is reported in `gaps` (never silently widened). Pure.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export interface DesignOpsOfOptions {
|
|
18
|
+
/** The page runs right to left (a `left` is its end side). */
|
|
19
|
+
rtl?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface DesignOpsOf {
|
|
23
|
+
ops: DesignOp[];
|
|
24
|
+
/** What the ops cannot say, each with the node's id — empty when the page replays byte for byte. */
|
|
25
|
+
gaps: string[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type Plain = Record<string, unknown>;
|
|
29
|
+
const isPlain = (v: unknown): v is Plain => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
30
|
+
const same = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.stringify(b);
|
|
31
|
+
const isScalar = (v: unknown): v is string | number | boolean => typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean';
|
|
32
|
+
/** An input's value as a `place` value: a scalar as itself, a list / object / null as its JSON text. */
|
|
33
|
+
const asValue = (v: unknown): DesignValue['value'] => (isScalar(v) ? v : JSON.stringify(v));
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A physical side, written as the start / end side it is on this page. The designer speaks start / end only (the check
|
|
37
|
+
* refuses a physical side), and since Batch C3 the builder HOLDS a start / end inset as its own control (Position ▸ Start /
|
|
38
|
+
* End, `insetInlineStart` / `insetInlineEnd` — it mirrors with the page), so a stored `left: 0px` comes back as
|
|
39
|
+
* `insetInlineStart: 0px` on an English page: the same box, held the way it mirrors.
|
|
40
|
+
*/
|
|
41
|
+
export function designSideName(name: string, rtl: boolean): string {
|
|
42
|
+
if (name === 'left') return rtl ? 'insetInlineEnd' : 'insetInlineStart';
|
|
43
|
+
if (name === 'right') return rtl ? 'insetInlineStart' : 'insetInlineEnd';
|
|
44
|
+
return name;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
class OpsWriter {
|
|
48
|
+
readonly ops: DesignOp[] = [];
|
|
49
|
+
readonly gaps: string[] = [];
|
|
50
|
+
|
|
51
|
+
constructor(private readonly rtl: boolean) {}
|
|
52
|
+
|
|
53
|
+
private gap(node: SerializedNode, what: string): void {
|
|
54
|
+
this.gaps.push(`${node.id}: ${what}`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private placeValues(node: SerializedNode, global: boolean): DesignValue[] {
|
|
58
|
+
const values: DesignValue[] = [];
|
|
59
|
+
const said = [DESIGN_WORD_PROPS[node.type], DESIGN_PICTURE_PROPS[node.type]];
|
|
60
|
+
const bare = placedDesignNode(node.id, node.type, []);
|
|
61
|
+
for (const [name, value] of Object.entries(node.props)) {
|
|
62
|
+
if (said.includes(name) && typeof value === 'string') continue;
|
|
63
|
+
if (!same(bare.props[name], value)) values.push({ name, value: asValue(value) });
|
|
64
|
+
}
|
|
65
|
+
// The element style: the type's default for these inputs is the palette's; anything else is said.
|
|
66
|
+
const plain = placedDesignNode(node.id, node.type, values);
|
|
67
|
+
if ((plain.elementStyle ?? '') !== (node.elementStyle ?? '')) values.push({ name: DesignMeta.Style, value: node.elementStyle ?? DESIGN_NO_STYLE });
|
|
68
|
+
if (node.label !== undefined) values.push({ name: DesignMeta.Label, value: node.label });
|
|
69
|
+
if (node.role !== undefined) values.push({ name: DesignMeta.Role, value: node.role });
|
|
70
|
+
if (node.itemKey !== undefined) values.push({ name: DesignMeta.ItemKey, value: node.itemKey });
|
|
71
|
+
if (global && node.globalPosition) values.push({ name: DesignMeta.Global, value: node.globalPosition });
|
|
72
|
+
for (const [state, by] of Object.entries(node.stateTriggers ?? {})) if (by) values.push({ name: `${DESIGN_TRIGGER_META}${state}`, value: by });
|
|
73
|
+
return values;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private layerTraits(node: SerializedNode, layer: string, held: Plain, want: Plain, base: boolean): DesignTrait[] {
|
|
77
|
+
const traits: DesignTrait[] = [];
|
|
78
|
+
for (const [name, value] of Object.entries(want)) {
|
|
79
|
+
if (typeof value !== 'string') { this.gap(node, `${layer}.${name} holds a ${typeof value}, not a CSS value`); continue; }
|
|
80
|
+
if (!base && value === '') { this.gap(node, `${layer}.${name} holds "" (the tool's "" forgets a value)`); continue; }
|
|
81
|
+
if (held[name] === value) continue;
|
|
82
|
+
const said = designSideName(name, this.rtl);
|
|
83
|
+
// A physical side and its own start / end side both set: the ops speak start / end only, so one would be lost.
|
|
84
|
+
if (traits.some(t => t.name === said)) { this.gap(node, `${layer}.${said} is set twice — by a physical side and by itself (the ops say start / end only)`); continue; }
|
|
85
|
+
traits.push({ name: said, value });
|
|
86
|
+
}
|
|
87
|
+
for (const name of Object.keys(held)) {
|
|
88
|
+
if (name in want) continue;
|
|
89
|
+
if (base) this.gap(node, `base has no "${name}" (a base value cannot be forgotten)`);
|
|
90
|
+
else traits.push({ name: designSideName(name, this.rtl), value: '' });
|
|
91
|
+
}
|
|
92
|
+
return traits;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private styles(node: SerializedNode, made: SerializedNode): void {
|
|
96
|
+
const push = (layer: string, traits: DesignTrait[]) => { if (traits.length) this.ops.push({ tool: DesignTool.Style, node: node.id, layer, traits }); };
|
|
97
|
+
push(DESIGN_BASE_LAYER, this.layerTraits(node, DESIGN_BASE_LAYER, made.styleProps, node.styleProps, true));
|
|
98
|
+
for (const [bp, layer] of Object.entries(node.responsive ?? {})) {
|
|
99
|
+
const extra = Object.keys(layer ?? {}).filter(k => k !== 'styleProps');
|
|
100
|
+
if (extra.length) this.gap(node, `responsive.${bp} holds ${extra.join(', ')} (a width's inputs)`);
|
|
101
|
+
if (!layer?.styleProps || !Object.keys(layer.styleProps).length) { this.gap(node, `responsive.${bp} is empty`); continue; }
|
|
102
|
+
push(bp, this.layerTraits(node, bp, made.responsive?.[bp]?.styleProps ?? {}, layer.styleProps, false));
|
|
103
|
+
}
|
|
104
|
+
for (const [state, values] of Object.entries(node.stateStyles ?? {})) {
|
|
105
|
+
if (!values || !Object.keys(values).length) { this.gap(node, `stateStyles.${state} is empty`); continue; }
|
|
106
|
+
push(state, this.layerTraits(node, state, made.stateStyles?.[state] ?? {}, values, false));
|
|
107
|
+
}
|
|
108
|
+
for (const [state, values] of Object.entries(made.stateStyles ?? {})) {
|
|
109
|
+
if (!(state in (node.stateStyles ?? {}))) push(state, Object.keys(values ?? {}).map(name => ({ name: designSideName(name, this.rtl), value: '' })));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private acts(node: SerializedNode): void {
|
|
114
|
+
for (const row of node.interactions as Plain[]) {
|
|
115
|
+
const known = ['id', 'trigger', 'range', 'actions'];
|
|
116
|
+
const extra = Object.keys(row).filter(k => !known.includes(k));
|
|
117
|
+
if (extra.length) this.gap(node, `interaction ${row['id']} holds ${extra.join(', ')}`);
|
|
118
|
+
const base = { tool: DesignTool.Act as const, node: node.id, id: String(row['id']), trigger: String(row['trigger']), range: String(row['range'] ?? '') };
|
|
119
|
+
const actions = (row['actions'] as Plain[] | undefined) ?? [];
|
|
120
|
+
if (!actions.length) this.ops.push({ ...base, type: '', values: [] });
|
|
121
|
+
for (const action of actions) {
|
|
122
|
+
const values: DesignValue[] = [];
|
|
123
|
+
for (const [name, value] of Object.entries(action)) {
|
|
124
|
+
if (name === 'type') continue;
|
|
125
|
+
if (name === 'params' && isPlain(value)) {
|
|
126
|
+
for (const [p, v] of Object.entries(value)) {
|
|
127
|
+
if (isScalar(v)) values.push({ name: `${DESIGN_PARAM_PREFIX}${p}`, value: v });
|
|
128
|
+
else this.gap(node, `interaction ${row['id']} params.${p} is not one value`);
|
|
129
|
+
}
|
|
130
|
+
} else if (DESIGN_ACT_VALUES.includes(name) && isScalar(value)) values.push({ name, value });
|
|
131
|
+
else this.gap(node, `interaction ${row['id']} action ${name} = ${JSON.stringify(value)}`);
|
|
132
|
+
}
|
|
133
|
+
this.ops.push({ ...base, type: String(action['type']), values });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private scenes(node: SerializedNode): void {
|
|
139
|
+
for (const [key, phone] of [['sceneTracks', false], ['scenePhoneTracks', true]] as const) {
|
|
140
|
+
const tracks = node[key];
|
|
141
|
+
if (!tracks) continue;
|
|
142
|
+
const rows: DesignSceneRow[] = [];
|
|
143
|
+
let last = '';
|
|
144
|
+
for (const t of tracks as Plain[]) {
|
|
145
|
+
const extra = Object.keys(t).filter(k => !['prop', 'from', 'keys'].includes(k));
|
|
146
|
+
if (extra.length) this.gap(node, `${key} ${t['prop']} holds ${extra.join(', ')}`);
|
|
147
|
+
const from = String(t['from'] ?? '');
|
|
148
|
+
const id = `${t['prop']}|${from}`;
|
|
149
|
+
if (id === last) this.gap(node, `${key} has two ${t['prop']} tracks in a row`);
|
|
150
|
+
last = id;
|
|
151
|
+
for (const k of (t['keys'] as unknown[][]) ?? []) rows.push({ prop: String(t['prop']), from, at: Number(k[0]), value: k[1] as string | number });
|
|
152
|
+
}
|
|
153
|
+
this.ops.push({ tool: DesignTool.Scene, node: node.id, phone, tracks: rows });
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
node(node: SerializedNode, parent: string, global: boolean): void {
|
|
158
|
+
if (node.bindings?.length) this.gap(node, 'holds bindings (the designer binds nothing)');
|
|
159
|
+
if (node.composed) this.gap(node, 'holds a composed stamp');
|
|
160
|
+
const values = this.placeValues(node, global);
|
|
161
|
+
this.ops.push({ tool: DesignTool.Place, op: PlaceOp.Place, node: node.id, type: node.type, parent, index: DESIGN_END_INDEX, values });
|
|
162
|
+
const made = placedDesignNode(node.id, node.type, values);
|
|
163
|
+
const word = DESIGN_WORD_PROPS[node.type];
|
|
164
|
+
if (word && typeof node.props[word] === 'string' && node.props[word] !== made.props[word]) this.ops.push({ tool: DesignTool.Words, node: node.id, text: node.props[word] as string });
|
|
165
|
+
const picture = DESIGN_PICTURE_PROPS[node.type];
|
|
166
|
+
if (picture && typeof node.props[picture] === 'string' && node.props[picture] !== made.props[picture]) this.ops.push({ tool: DesignTool.Picture, node: node.id, src: node.props[picture] as string });
|
|
167
|
+
this.styles(node, made);
|
|
168
|
+
this.acts(node);
|
|
169
|
+
this.scenes(node);
|
|
170
|
+
if (!!node.children !== !!made.children) this.gap(node, node.children ? 'holds children its type does not take' : 'a container without its children list');
|
|
171
|
+
for (const child of node.children ?? []) this.node(child, node.id, false);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
look(look: DesignLook): void {
|
|
175
|
+
for (const [name, value] of Object.entries(look.choices ?? {})) {
|
|
176
|
+
if (name === DESIGN_FONTS_CHOICE && isPlain(value)) {
|
|
177
|
+
for (const [role, font] of Object.entries(value)) this.ops.push({ tool: DesignTool.Look, kind: LookEditKind.Font, name: role, value: asValue(font) });
|
|
178
|
+
} else if (isScalar(value)) this.ops.push({ tool: DesignTool.Look, kind: LookEditKind.Choice, name, value });
|
|
179
|
+
else this.gap({ id: 'look' } as SerializedNode, `choice ${name} is not one value`);
|
|
180
|
+
}
|
|
181
|
+
for (const [name, value] of Object.entries(look.tokenEdits ?? {})) {
|
|
182
|
+
if (isScalar(value) && value !== '') this.ops.push({ tool: DesignTool.Look, kind: LookEditKind.Token, name, value });
|
|
183
|
+
else this.gap({ id: 'look' } as SerializedNode, `token ${name} = ${JSON.stringify(value)}`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** A page's layout (or the site's globals) as ops, parents first. */
|
|
189
|
+
export function designOpsOfLayout(nodes: ReadonlyArray<SerializedNode>, options: DesignOpsOfOptions & { globals?: boolean } = {}): DesignOpsOf {
|
|
190
|
+
const w = new OpsWriter(!!options.rtl);
|
|
191
|
+
for (const node of nodes) w.node(node, DESIGN_PAGE_PARENT, !!options.globals);
|
|
192
|
+
return { ops: w.ops, gaps: w.gaps };
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** The look as ops: Design ▸ Apply's choices (fonts in their place), then the token edits. */
|
|
196
|
+
export function designOpsOfLook(look: DesignLook): DesignOpsOf {
|
|
197
|
+
const w = new OpsWriter(false);
|
|
198
|
+
w.look(look);
|
|
199
|
+
return { ops: w.ops, gaps: w.gaps };
|
|
200
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { ElementStyleState } from '@vectoriox/iox-ui/design-core';
|
|
2
|
+
import type { MotionIssue } from './design-motion';
|
|
3
|
+
|
|
4
|
+
import type { PathIssue } from './shape-check';
|
|
5
|
+
import type { SerializedNode } from './serialized-node';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* THE AI DESIGNER'S TOOL LANGUAGE (ai-designer-plan §2b, AD1, AD-D2 (a)): the designer never writes CSS, HTML or a
|
|
9
|
+
* whole tree. It calls tools, and each tool is something a person does in the builder: drop a part from the palette,
|
|
10
|
+
* set a Style-panel value, add an Interactions-panel row, draw a Scene track, type words, choose a picture, edit the
|
|
11
|
+
* look's tokens, or drag, delete or wrap a node. ONE pure `applyDesignOps` applies them (design-ops.ts); the builder's
|
|
12
|
+
* right-click and the Ask panel are meant to call the same function (R-H1). What it writes is an ordinary saved page —
|
|
13
|
+
* the nodes the builder saves and the engine renders, unchanged.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** The eight tool families. A tool call's NAME is its family; its input is the family's strict schema
|
|
17
|
+
* (design-ops.schema.ts). */
|
|
18
|
+
export enum DesignTool {
|
|
19
|
+
/** Palette: drop a part, drop a recipe, or set a part's inputs (Inputs panel / Layers panel name). */
|
|
20
|
+
Place = 'place',
|
|
21
|
+
/** Style panel: values on the base, at a width, or in a state. */
|
|
22
|
+
Style = 'style',
|
|
23
|
+
/** Interactions panel: a trigger and what it does. */
|
|
24
|
+
Act = 'act',
|
|
25
|
+
/** The Scene timeline: a layer's tracks, laptop or phone. */
|
|
26
|
+
Scene = 'scene',
|
|
27
|
+
/** Typing on the canvas: a part's words. */
|
|
28
|
+
Words = 'words',
|
|
29
|
+
/** Files box / stock: a picture or a film. */
|
|
30
|
+
Picture = 'picture',
|
|
31
|
+
/** Design ▸ Apply choices, fonts and token edits. */
|
|
32
|
+
Look = 'look',
|
|
33
|
+
/** Drag, delete, Wrap in. */
|
|
34
|
+
Move = 'move',
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export enum PlaceOp {
|
|
38
|
+
/** A new part of `type` (the palette's drop: `createSerializedNode`, its empty-drop sizes released). */
|
|
39
|
+
Place = 'place',
|
|
40
|
+
/** A palette recipe (`DESIGN_RECIPES`): its parts are ordinary nodes, their ids `<node>-<part key>`. */
|
|
41
|
+
Recipe = 'recipe',
|
|
42
|
+
/** An existing part's inputs or its layer facts (`@label`, `@role`, `@itemKey`, `@trigger.<state>`). */
|
|
43
|
+
Set = 'set',
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export enum MoveOp {
|
|
47
|
+
Move = 'move',
|
|
48
|
+
Remove = 'remove',
|
|
49
|
+
/** Wrap `node` in a NEW part of `type` whose id is `parent` (Wrap in ▸). */
|
|
50
|
+
Wrap = 'wrap',
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export enum LookEditKind {
|
|
54
|
+
/** A token's value (Design ▸ Tokens). */
|
|
55
|
+
Token = 'token',
|
|
56
|
+
/** A Design ▸ Apply choice (flavor, seed, shape, density, motion …). */
|
|
57
|
+
Choice = 'choice',
|
|
58
|
+
/** A font role (Design ▸ Type): `font-display`, `font-body`, `font-label`. */
|
|
59
|
+
Font = 'font',
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** The Style panel's layers: the base, a narrower width (sparse `responsive[bp].styleProps`), or a state
|
|
63
|
+
* (`stateStyles[state]`). The widths are the style compiler's override breakpoints (pinned by a spec). */
|
|
64
|
+
export const DESIGN_WIDTHS: ReadonlyArray<string> = ['laptop', 'tablet', 'mobile', 'small'];
|
|
65
|
+
export const DESIGN_BASE_LAYER = 'base';
|
|
66
|
+
/** The targeted state a composite part wears when ANOTHER node is on (CC2 `trigger-on`). */
|
|
67
|
+
export const DESIGN_TRIGGER_ON_STATE = 'trigger-on';
|
|
68
|
+
export const DESIGN_STATES: ReadonlyArray<string> = [...(Object.values(ElementStyleState) as string[]), DESIGN_TRIGGER_ON_STATE];
|
|
69
|
+
export const DESIGN_LAYERS: ReadonlyArray<string> = [DESIGN_BASE_LAYER, ...DESIGN_WIDTHS, ...DESIGN_STATES];
|
|
70
|
+
|
|
71
|
+
/** The parent that means "the page itself" (a top-level section, or a global part). */
|
|
72
|
+
export const DESIGN_PAGE_PARENT = '';
|
|
73
|
+
/** An index that means "after the last child". */
|
|
74
|
+
export const DESIGN_END_INDEX = -1;
|
|
75
|
+
/** A value an Interactions-panel row writes as "no range" / "no from". */
|
|
76
|
+
export const DESIGN_NONE = '';
|
|
77
|
+
|
|
78
|
+
/** The layer facts a `place` / `set` op writes through its values (they are not inputs). */
|
|
79
|
+
export enum DesignMeta {
|
|
80
|
+
/** The element style id; `''` = the type's own default (the palette's), `none` = none at all. */
|
|
81
|
+
Style = '@style',
|
|
82
|
+
Label = '@label',
|
|
83
|
+
Role = '@role',
|
|
84
|
+
ItemKey = '@itemKey',
|
|
85
|
+
/** `@global` = `header` | `footer` | … : the part is a global element at that position. */
|
|
86
|
+
Global = '@global',
|
|
87
|
+
}
|
|
88
|
+
/** `@trigger.<state>` = the node id whose ON drives this node's `<state>` (stateTriggers). */
|
|
89
|
+
export const DESIGN_TRIGGER_META = '@trigger.';
|
|
90
|
+
export const DESIGN_NO_STYLE = 'none';
|
|
91
|
+
|
|
92
|
+
/** One named value. Inputs that hold a list or an object travel as their JSON text. */
|
|
93
|
+
export interface DesignValue {
|
|
94
|
+
name: string;
|
|
95
|
+
value: string | number | boolean;
|
|
96
|
+
}
|
|
97
|
+
/** One style trait; `''` in a width or state layer removes it from that layer. */
|
|
98
|
+
export interface DesignTrait {
|
|
99
|
+
name: string;
|
|
100
|
+
value: string;
|
|
101
|
+
}
|
|
102
|
+
/** One Scene key as a row: consecutive rows of one `prop` (and `from`) are one track. */
|
|
103
|
+
export interface DesignSceneRow {
|
|
104
|
+
prop: string;
|
|
105
|
+
/** A Clip track's direction, else `''`. */
|
|
106
|
+
from: string;
|
|
107
|
+
at: number;
|
|
108
|
+
value: string | number;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface PlaceDesignOp {
|
|
112
|
+
tool: DesignTool.Place | `${DesignTool.Place}`;
|
|
113
|
+
op: PlaceOp | `${PlaceOp}`;
|
|
114
|
+
node: string;
|
|
115
|
+
/** The part's type (place), the recipe's name (recipe), `''` (set). */
|
|
116
|
+
type: string;
|
|
117
|
+
parent: string;
|
|
118
|
+
index: number;
|
|
119
|
+
values: DesignValue[];
|
|
120
|
+
}
|
|
121
|
+
export interface StyleDesignOp {
|
|
122
|
+
tool: DesignTool.Style | `${DesignTool.Style}`;
|
|
123
|
+
node: string;
|
|
124
|
+
layer: string;
|
|
125
|
+
traits: DesignTrait[];
|
|
126
|
+
}
|
|
127
|
+
export interface ActDesignOp {
|
|
128
|
+
tool: DesignTool.Act | `${DesignTool.Act}`;
|
|
129
|
+
node: string;
|
|
130
|
+
/** The row's id; a second op with the same id adds an action to that row. */
|
|
131
|
+
id: string;
|
|
132
|
+
/** `''` removes the row. */
|
|
133
|
+
trigger: string;
|
|
134
|
+
/** A scroll-driven row's range, else `''`. */
|
|
135
|
+
range: string;
|
|
136
|
+
/** The action (actions-core catalog). */
|
|
137
|
+
type: string;
|
|
138
|
+
/** `target`, `duration`, `delay`, `easing`, `once`, and `params.<name>`. */
|
|
139
|
+
values: DesignValue[];
|
|
140
|
+
}
|
|
141
|
+
export interface SceneDesignOp {
|
|
142
|
+
tool: DesignTool.Scene | `${DesignTool.Scene}`;
|
|
143
|
+
node: string;
|
|
144
|
+
/** The phone's own tracks (`scenePhoneTracks`). */
|
|
145
|
+
phone: boolean;
|
|
146
|
+
/** Every track of the layer (replaces them); none = the layer stands still (`[]`). */
|
|
147
|
+
tracks: DesignSceneRow[];
|
|
148
|
+
}
|
|
149
|
+
export interface WordsDesignOp {
|
|
150
|
+
tool: DesignTool.Words | `${DesignTool.Words}`;
|
|
151
|
+
node: string;
|
|
152
|
+
text: string;
|
|
153
|
+
}
|
|
154
|
+
export interface PictureDesignOp {
|
|
155
|
+
tool: DesignTool.Picture | `${DesignTool.Picture}`;
|
|
156
|
+
node: string;
|
|
157
|
+
src: string;
|
|
158
|
+
}
|
|
159
|
+
export interface LookDesignOp {
|
|
160
|
+
tool: DesignTool.Look | `${DesignTool.Look}`;
|
|
161
|
+
kind: LookEditKind | `${LookEditKind}`;
|
|
162
|
+
name: string;
|
|
163
|
+
value: string | number | boolean;
|
|
164
|
+
}
|
|
165
|
+
export interface MoveDesignOp {
|
|
166
|
+
tool: DesignTool.Move | `${DesignTool.Move}`;
|
|
167
|
+
op: MoveOp | `${MoveOp}`;
|
|
168
|
+
node: string;
|
|
169
|
+
parent: string;
|
|
170
|
+
index: number;
|
|
171
|
+
/** The wrapper's type (wrap), else `''`. */
|
|
172
|
+
type: string;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export type DesignOp = PlaceDesignOp | StyleDesignOp | ActDesignOp | SceneDesignOp | WordsDesignOp | PictureDesignOp | LookDesignOp | MoveDesignOp;
|
|
176
|
+
|
|
177
|
+
/** The choice that holds the font roles (`look` op `font`). */
|
|
178
|
+
export const DESIGN_FONTS_CHOICE = 'fonts';
|
|
179
|
+
|
|
180
|
+
/** The look a design writes: Design ▸ Apply's choices (fonts inside) and the token edits. */
|
|
181
|
+
export interface DesignLook {
|
|
182
|
+
choices: Record<string, unknown>;
|
|
183
|
+
tokenEdits: Record<string, unknown>;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** What the ops work on: one page's layout, the site's global parts, the look. */
|
|
187
|
+
export interface DesignDoc {
|
|
188
|
+
layout: SerializedNode[];
|
|
189
|
+
globals: SerializedNode[];
|
|
190
|
+
look: DesignLook;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export enum DesignIssueCode {
|
|
194
|
+
/** The op's shape: a missing node, a parent that holds no children, an id taken, an unknown tool or layer. */
|
|
195
|
+
Shape = 'shape',
|
|
196
|
+
/** A trait the type has no slot for, or an input it does not have (the builder would drop it). */
|
|
197
|
+
Slot = 'slot',
|
|
198
|
+
/** A style value against the free tier's closed rules: start / end, one plain value, no window units. */
|
|
199
|
+
Style = 'style',
|
|
200
|
+
/** A value the look owns written as something other than its token. */
|
|
201
|
+
Token = 'token',
|
|
202
|
+
/** Words that hold a fact the owner never gave, or a word this site must not use (`factIssues`). */
|
|
203
|
+
Fact = 'fact',
|
|
204
|
+
/** Motion against Emil's rules (hover = transform / opacity / colour; one entrance per element; the catalog). */
|
|
205
|
+
Motion = 'motion',
|
|
206
|
+
/** A page invariant: one h1, a slide only in a slider, a picture with words. */
|
|
207
|
+
Layout = 'layout',
|
|
208
|
+
/** A recipe that does not exist or will not stamp with these options. */
|
|
209
|
+
Recipe = 'recipe',
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export type DesignIssue = PathIssue<DesignIssueCode>;
|
|
213
|
+
|
|
214
|
+
/** One refused op: its place in the stream, the op, and why (each reason with its path). */
|
|
215
|
+
export interface DesignOpRefusal {
|
|
216
|
+
index: number;
|
|
217
|
+
op: DesignOp;
|
|
218
|
+
issues: DesignIssue[];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** Which turn this is (ai-designer-plan §2e): the first answer's refusals go back once, with their paths; a refusal in
|
|
222
|
+
* the repair turn drops the op and is logged. */
|
|
223
|
+
export enum DesignTurn {
|
|
224
|
+
First = 'first',
|
|
225
|
+
Repair = 'repair',
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export interface DesignOpsResult {
|
|
229
|
+
doc: DesignDoc;
|
|
230
|
+
/** How many ops were applied. */
|
|
231
|
+
applied: number;
|
|
232
|
+
/** First turn: the ops to send back once, with their paths. */
|
|
233
|
+
refused: DesignOpRefusal[];
|
|
234
|
+
/** Repair turn: the ops dropped on their second refusal — the round's log. */
|
|
235
|
+
dropped: DesignOpRefusal[];
|
|
236
|
+
/** With a check context: Emil's rules on the page as the turn left it (`designMotionIssues`) — what no single op
|
|
237
|
+
* caused (a part moved into a container that enters) and what the page held before the turn. */
|
|
238
|
+
motion?: MotionIssue[];
|
|
239
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { jsonAnyOf, jsonBoolean, jsonClosedObject, jsonInteger, jsonListOf, JsonSchema, jsonText } from './json-schema';
|
|
2
|
+
import { DesignTool } from './design-ops.model';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The designer's tools as STRICT schemas (ai-designer-plan §2b, R-H4): one per family, every property required (no
|
|
6
|
+
* optional parameter), each a closed object. All eight together are ONE request's tools and stay inside
|
|
7
|
+
* `STRICT_SCHEMA_BUDGET` (≤ 40 properties, ≤ 12 optional, ≤ 8 unions) — the spec counts them with `strictSchemaComplexity`.
|
|
8
|
+
* A map the model writes (inputs, traits, a row's timing) travels as `[{ name, value }]`, because no strict mode can say
|
|
9
|
+
* "any key". The enums of names (types, traits, tokens) are NOT in the schema: they would blow the grammar; the static
|
|
10
|
+
* check (design-ops-check.ts) refuses an unknown name with its path, and the model repairs it once.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const scalar = (): JsonSchema => jsonAnyOf([{ type: 'string' }, { type: 'number' }, { type: 'boolean' }]);
|
|
14
|
+
const named = (value: JsonSchema, what: string): JsonSchema =>
|
|
15
|
+
jsonListOf(jsonClosedObject({ name: jsonText(), value }, ['name', 'value'], what));
|
|
16
|
+
const node = (what = 'The id of the part this works on.'): JsonSchema => ({ ...jsonText(), description: what });
|
|
17
|
+
const index = (): JsonSchema => ({ ...jsonInteger(), description: 'Its place among the parent\'s children, 0 first; -1 = after the last.' });
|
|
18
|
+
const parent = (): JsonSchema => ({ ...jsonText(), description: 'The id of the part it goes into; "" = the page itself.' });
|
|
19
|
+
const oneOf = (values: ReadonlyArray<string>, what: string): JsonSchema => ({ type: 'string', enum: [...values], description: what });
|
|
20
|
+
|
|
21
|
+
export interface DesignToolSchema {
|
|
22
|
+
name: DesignTool;
|
|
23
|
+
description: string;
|
|
24
|
+
input_schema: JsonSchema;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const object = (properties: Record<string, JsonSchema>, description: string): JsonSchema =>
|
|
28
|
+
jsonClosedObject(properties, Object.keys(properties), description);
|
|
29
|
+
|
|
30
|
+
/** The eight tool schemas, in the order the tools are offered. */
|
|
31
|
+
export const DESIGN_TOOL_SCHEMAS: ReadonlyArray<DesignToolSchema> = [
|
|
32
|
+
{
|
|
33
|
+
name: DesignTool.Place,
|
|
34
|
+
description: 'Drop a part from the palette (place), drop a palette recipe (recipe), or set an existing part\'s inputs (set). '
|
|
35
|
+
+ 'Values are the part\'s inputs by name; "@style" (element style), "@label", "@role", "@itemKey", "@global" and '
|
|
36
|
+
+ '"@trigger.<state>" are its layer facts. An input that holds a list or an object is written as its JSON text.',
|
|
37
|
+
input_schema: object({
|
|
38
|
+
op: oneOf(['place', 'recipe', 'set'], 'place | recipe | set'),
|
|
39
|
+
node: node('The new part\'s id (place), the recipe\'s id prefix (recipe), the part to change (set).'),
|
|
40
|
+
type: { ...jsonText(), description: 'The part\'s type (place), the recipe\'s name (recipe), "" (set).' },
|
|
41
|
+
parent: parent(),
|
|
42
|
+
index: index(),
|
|
43
|
+
values: named(scalar(), 'An input or a layer fact.'),
|
|
44
|
+
}, 'The palette and the Inputs panel.'),
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: DesignTool.Style,
|
|
48
|
+
description: 'Style-panel values on one layer: "base", a narrower width (laptop, tablet, mobile, small) or a state '
|
|
49
|
+
+ '(hover, active, focus, current, on, trigger-on …). Colours, fonts, radii, shadows and durations are the look\'s '
|
|
50
|
+
+ 'tokens (var(--iox-…)); sides are start / end, never left / right. "" in a width or a state removes the value there.',
|
|
51
|
+
input_schema: object({
|
|
52
|
+
node: node(),
|
|
53
|
+
layer: { ...jsonText(), description: 'base | laptop | tablet | mobile | small | hover | active | focus | current | on | trigger-on' },
|
|
54
|
+
traits: named(jsonText(), 'A style trait and its CSS value.'),
|
|
55
|
+
}, 'The Style panel.'),
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: DesignTool.Act,
|
|
59
|
+
description: 'An Interactions-panel row: when (trigger) and what (the action type). Values: "target" (a part id or '
|
|
60
|
+
+ '"self"), "duration" and "delay" (ms), "easing", "once", and "params.<name>". Hover and motion move transform '
|
|
61
|
+
+ 'and opacity only; one entrance per element. A trigger of "" removes the row with this id.',
|
|
62
|
+
input_schema: object({
|
|
63
|
+
node: node(),
|
|
64
|
+
id: { ...jsonText(), description: 'The row\'s id; the same id again adds an action to that row.' },
|
|
65
|
+
trigger: { ...jsonText(), description: 'viewportEnter | pageLoad | click | hover | scrollProgress | …, or "" to remove the row.' },
|
|
66
|
+
range: { ...jsonText(), description: 'A scroll-driven row\'s range (cover, contain …), else "".' },
|
|
67
|
+
type: { ...jsonText(), description: 'The action: blurIn, moveUp, fadeIn, zoomOut, parallax, scrollTo, openDialog …' },
|
|
68
|
+
values: named(scalar(), 'A timing value, the target, or params.<name>.'),
|
|
69
|
+
}, 'The Interactions panel.'),
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: DesignTool.Scene,
|
|
73
|
+
description: 'A Scene layer\'s tracks on the timeline (they replace the layer\'s tracks; none = the layer stands still). Each row is '
|
|
74
|
+
+ 'one key: at (0–1 of the scroll) and the value; consecutive rows of one prop are one track. "phone" = the phone\'s own tracks.',
|
|
75
|
+
input_schema: object({
|
|
76
|
+
node: node('The Scene layer.'),
|
|
77
|
+
phone: { ...jsonBoolean(), description: 'true = the phone\'s own tracks.' },
|
|
78
|
+
tracks: jsonListOf(jsonClosedObject({
|
|
79
|
+
prop: { ...jsonText(), description: 'x | y | scale | rotate | opacity | clip | words | play | ground | ink' },
|
|
80
|
+
from: { ...jsonText(), description: 'A clip track\'s direction (centre, bottom, top, start, end), else "".' },
|
|
81
|
+
at: { type: 'number', description: '0–1 of the scene\'s scroll.' },
|
|
82
|
+
value: jsonAnyOf([{ type: 'string' }, { type: 'number' }]),
|
|
83
|
+
}, ['prop', 'from', 'at', 'value'], 'One key.')),
|
|
84
|
+
}, 'The Scene timeline.'),
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: DesignTool.Words,
|
|
88
|
+
description: 'The words of a part, typed on the canvas: a Heading\'s or a Text\'s words, a Link\'s or a button\'s label, '
|
|
89
|
+
+ 'a picture\'s description. Only the owner\'s words and facts — a number, a price or a quote nobody gave is refused.',
|
|
90
|
+
input_schema: object({ node: node(), text: jsonText() }, 'Typing on the canvas.'),
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: DesignTool.Picture,
|
|
94
|
+
description: 'The picture (or film) a part shows: one of the site\'s own pictures, or a stock result the build found.',
|
|
95
|
+
input_schema: object({ node: node('An Image or a Video.'), src: { ...jsonText(), description: 'The picture\'s address.' } }, 'The Files box.'),
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: DesignTool.Look,
|
|
99
|
+
description: 'The look: a token\'s value (token), a Design ▸ Apply choice (choice), or a font role (font: font-display, '
|
|
100
|
+
+ 'font-body, font-label). Colours on parts are always these tokens, never literals.',
|
|
101
|
+
input_schema: object({
|
|
102
|
+
kind: oneOf(['token', 'choice', 'font'], 'token | choice | font'),
|
|
103
|
+
name: jsonText(),
|
|
104
|
+
value: scalar(),
|
|
105
|
+
}, 'Design ▸ Look, Type and Tokens.'),
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: DesignTool.Move,
|
|
109
|
+
description: 'Drag a part to another place (move), delete it (remove), or wrap it in a new part (wrap: "type" is the '
|
|
110
|
+
+ 'wrapper\'s type and "parent" its new id).',
|
|
111
|
+
input_schema: object({
|
|
112
|
+
op: oneOf(['move', 'remove', 'wrap'], 'move | remove | wrap'),
|
|
113
|
+
node: node(),
|
|
114
|
+
parent: parent(),
|
|
115
|
+
index: index(),
|
|
116
|
+
type: { ...jsonText(), description: 'The wrapper\'s type (wrap), else "".' },
|
|
117
|
+
}, 'Drag, delete, Wrap in.'),
|
|
118
|
+
},
|
|
119
|
+
];
|
|
120
|
+
|
|
121
|
+
/** A family's schema by its tool name. */
|
|
122
|
+
export const designToolSchema = (tool: DesignTool | string): DesignToolSchema | undefined => DESIGN_TOOL_SCHEMAS.find(s => s.name === tool);
|