@vectoriox/iox-ui 5.156.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/fesm2022/vectoriox-iox-ui-generation-core.mjs +1088 -104
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/generation-core/index.d.ts +401 -3
- package/package.json +1 -1
- package/src/generation-core/check-free.ts +375 -0
- package/src/generation-core/free-fallback.ts +139 -0
- package/src/generation-core/free-wire.ts +432 -0
- package/src/generation-core/plan-words.ts +50 -3
- package/src/generation-core/prompt-limits.ts +96 -0
- package/src/generation-core/public-api.ts +4 -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
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { checkFree, FreeIssue, FreeIssueCode, FreeJudgeContext } from './check-free';
|
|
2
|
+
import { FreeNode, FreeNodeType, FreePage, walkFree } from './free-wire';
|
|
3
|
+
import { LayoutIssue, LayoutIssueCode, LayoutLayer, LayoutLayerKind, LayoutPage, LayoutSection } from './layout-language';
|
|
4
|
+
import { fallBackBySection, SectionFallback, SectionSwap } from './layout-section-fallback';
|
|
5
|
+
import { followedAfter, PromptLimit, sectionBreaks } from './prompt-limits';
|
|
6
|
+
import { PageSectionPlan } from './site-plan.model';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* THE FREE PAGE'S SILENT FALL BACK (award plan §11.4 gate 6, R-H7): a free section that still breaks a rule after the
|
|
10
|
+
* one repair is given to the plan's ready-made section for its place — through the ONE `fallBackBySection` (never a copy
|
|
11
|
+
* of its rules: the opening and the close always swap, a middle section takes the best fit by list, form and words or is
|
|
12
|
+
* dropped, a ready-made section that repeats a kept one is never a fit, and a page that still fails falls back whole).
|
|
13
|
+
* This file only ADAPTS: a free section is read as the layout language's section (its words as layers, a list slot as
|
|
14
|
+
* its gallery source, a form slot as a form) so the fit is scored the same way, and the judge it hands over re-runs
|
|
15
|
+
* `checkFree` on the free page the swaps leave. Pure.
|
|
16
|
+
*
|
|
17
|
+
* FS-D47 / R-H20: given the owner's limits (`promptLimitsOf` the reading), the ready-made section is chosen against them
|
|
18
|
+
* and the followed line is rewritten when one had to be used anyway.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** A free judge's issue code, in the layout language's codes (the fall back reads only paths and messages). */
|
|
22
|
+
export const FREE_TO_LAYOUT_CODE: Readonly<Record<FreeIssueCode, LayoutIssueCode>> = {
|
|
23
|
+
[FreeIssueCode.Structure]: LayoutIssueCode.Structure,
|
|
24
|
+
[FreeIssueCode.Words]: LayoutIssueCode.Content,
|
|
25
|
+
[FreeIssueCode.Style]: LayoutIssueCode.Look,
|
|
26
|
+
[FreeIssueCode.Token]: LayoutIssueCode.Look,
|
|
27
|
+
[FreeIssueCode.Phone]: LayoutIssueCode.Structure,
|
|
28
|
+
[FreeIssueCode.Motion]: LayoutIssueCode.Motion,
|
|
29
|
+
[FreeIssueCode.Content]: LayoutIssueCode.Content,
|
|
30
|
+
[FreeIssueCode.Contrast]: LayoutIssueCode.Reading,
|
|
31
|
+
[FreeIssueCode.Prompt]: LayoutIssueCode.Content,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const asLayoutIssue = (i: FreeIssue): LayoutIssue => ({ code: FREE_TO_LAYOUT_CODE[i.code], path: i.path, message: i.message });
|
|
35
|
+
|
|
36
|
+
const WORD_LAYER: Readonly<Partial<Record<FreeNodeType, LayoutLayerKind>>> = {
|
|
37
|
+
[FreeNodeType.Heading]: LayoutLayerKind.Heading,
|
|
38
|
+
[FreeNodeType.Text]: LayoutLayerKind.Text,
|
|
39
|
+
[FreeNodeType.Button]: LayoutLayerKind.Button,
|
|
40
|
+
};
|
|
41
|
+
const AT: Pick<LayoutLayer, 'col' | 'row'> = { col: [1, 1], row: [1, 1] };
|
|
42
|
+
|
|
43
|
+
/** One free node as the layer the fall back's fit reads (words, a list's source, a form), or none. */
|
|
44
|
+
function layerOf(node: FreeNode): LayoutLayer | null {
|
|
45
|
+
const word = WORD_LAYER[node.type];
|
|
46
|
+
if (word) return { kind: word, text: node.text ?? '', ...AT };
|
|
47
|
+
if (node.type === FreeNodeType.Image) return { kind: LayoutLayerKind.Photo, photo: { id: node.src ?? '' }, ...AT };
|
|
48
|
+
if (node.type !== FreeNodeType.Slot) return null;
|
|
49
|
+
const [kind, ref] = String(node.slot ?? '').split(':');
|
|
50
|
+
if (kind === 'list') return { kind: LayoutLayerKind.Gallery, gallery: { slides: [], source: ref }, ...AT };
|
|
51
|
+
if (kind === 'form') return { kind: LayoutLayerKind.Form, form: { preset: ref } as LayoutLayer['form'], ...AT };
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** A free section read as a layout section (for the fit only — never stamped). */
|
|
56
|
+
export function freeSectionAsLayout(section: FreeNode): LayoutSection {
|
|
57
|
+
const layers = walkFree([section]).map(w => layerOf(w.node)).filter((l): l is LayoutLayer => !!l);
|
|
58
|
+
return { id: section.id, screens: 1, rows: 1, layers, ...(section.readyMade ? { readyMade: section.readyMade } : {}) };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface FreeFallback {
|
|
62
|
+
/** The page as it now stands: kept free sections, ready-made places (`readyMade`), dropped ones gone. */
|
|
63
|
+
page: FreePage;
|
|
64
|
+
swaps: SectionSwap[];
|
|
65
|
+
/** What is left: empty — the page composes. */
|
|
66
|
+
left: FreeIssue[];
|
|
67
|
+
/** Set when the page must be made from sections after all (the shipped last resort, counted). */
|
|
68
|
+
lastResort?: SectionFallback['lastResort'];
|
|
69
|
+
/** FS-D47: the owner's limits a ready-made section on the page breaks (said in the followed line), by count. */
|
|
70
|
+
unfollowed?: Partial<Record<PromptLimit, number>>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** What the owner's prompt ruled out, and the site's language for the followed line (FS-D47, R-H20). */
|
|
74
|
+
export interface FreeFallbackPrompt {
|
|
75
|
+
limits: ReadonlyArray<PromptLimit>;
|
|
76
|
+
language?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Give each free section the issues name to the plan's ready-made section, then judge once more. `plan` is the page's
|
|
81
|
+
* ready-made sections (`PagePlan.sections`), in order; `issues` what `checkFree` still finds after the one repair.
|
|
82
|
+
* With the owner's limits (FS-D47), the fall back first chooses only among sections that honour them — a middle place
|
|
83
|
+
* nothing honest fits is dropped where the page's minimums allow; only when that fails is the closest section used, and
|
|
84
|
+
* the followed line then says which of the owner's words the page no longer follows.
|
|
85
|
+
*/
|
|
86
|
+
export function fallBackFree(page: FreePage, plan: ReadonlyArray<PageSectionPlan>, issues: ReadonlyArray<FreeIssue>, ctx: FreeJudgeContext, prompt?: FreeFallbackPrompt): FreeFallback {
|
|
87
|
+
const limits = prompt?.limits ?? [];
|
|
88
|
+
const lastAt = plan.length - 1;
|
|
89
|
+
const honest = plan.map((_, i) => i).filter(i => i === 0 || i === lastAt || !sectionBreaks(plan[i], limits).length);
|
|
90
|
+
const first = limits.length && honest.length < plan.length ? fallBackOn(page, plan, honest, issues, ctx) : null;
|
|
91
|
+
const done = first && !first.lastResort ? first : fallBackOn(page, plan, plan.map((_, i) => i), issues, ctx);
|
|
92
|
+
if (done.lastResort || !limits.length) return done;
|
|
93
|
+
const broken = new Map<PromptLimit, number>();
|
|
94
|
+
for (const s of done.page.sections) {
|
|
95
|
+
if (s.readyMade) for (const l of sectionBreaks(plan[s.readyMade.at], limits)) broken.set(l, (broken.get(l) ?? 0) + 1);
|
|
96
|
+
}
|
|
97
|
+
if (!broken.size) return done;
|
|
98
|
+
return {
|
|
99
|
+
...done,
|
|
100
|
+
page: { ...done.page, read: { ...done.page.read, followed: followedAfter(done.page.read.followed, broken, prompt?.language) } },
|
|
101
|
+
unfollowed: Object.fromEntries(broken),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** The ONE fall back over the plan sections `use` (by their index in `plan`); ready-made places name the FULL plan. */
|
|
106
|
+
function fallBackOn(page: FreePage, plan: ReadonlyArray<PageSectionPlan>, use: ReadonlyArray<number>, issues: ReadonlyArray<FreeIssue>, ctx: FreeJudgeContext): FreeFallback {
|
|
107
|
+
const byId = new Map(page.sections.map(s => [s.id, s]));
|
|
108
|
+
const real = (at: number) => use[at] ?? at;
|
|
109
|
+
const toFree = (layout: LayoutPage): FreePage => ({
|
|
110
|
+
...page,
|
|
111
|
+
sections: layout.sections.map(s => {
|
|
112
|
+
const was = byId.get(s.id)!;
|
|
113
|
+
return s.readyMade && !was.readyMade
|
|
114
|
+
? { id: s.id, type: FreeNodeType.Section, styleProps: {}, readyMade: { at: real(s.readyMade.at), pattern: s.readyMade.pattern } }
|
|
115
|
+
: was;
|
|
116
|
+
}),
|
|
117
|
+
});
|
|
118
|
+
// A place already ready-made names the FULL plan; the fall back reads it against the plan it is given.
|
|
119
|
+
const asGiven = (section: FreeNode): LayoutSection => {
|
|
120
|
+
const layout = freeSectionAsLayout(section);
|
|
121
|
+
return layout.readyMade ? { ...layout, readyMade: { ...layout.readyMade, at: use.indexOf(layout.readyMade.at) } } : layout;
|
|
122
|
+
};
|
|
123
|
+
let last: FreeIssue[] = [...issues];
|
|
124
|
+
const judged = fallBackBySection(
|
|
125
|
+
{ dial: 'distinct', sections: page.sections.map(asGiven) },
|
|
126
|
+
use.map(i => plan[i]),
|
|
127
|
+
issues.map(asLayoutIssue),
|
|
128
|
+
layout => {
|
|
129
|
+
last = checkFree(toFree(layout), ctx);
|
|
130
|
+
return { page: layout, issues: last.map(asLayoutIssue) };
|
|
131
|
+
},
|
|
132
|
+
);
|
|
133
|
+
return {
|
|
134
|
+
page: toFree(judged.page),
|
|
135
|
+
swaps: judged.swaps.map(w => (w.readyMade ? { ...w, readyMade: { ...w.readyMade, at: real(w.readyMade.at) } } : w)),
|
|
136
|
+
left: judged.left.length ? last : [],
|
|
137
|
+
...(judged.lastResort ? { lastResort: judged.lastResort } : {}),
|
|
138
|
+
};
|
|
139
|
+
}
|