@uselazuli/cli 0.0.0-stage → 1.0.2
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/CHANGELOG.md +120 -0
- package/LICENSE +21 -0
- package/README.md +202 -2
- package/agents/lazuli-design-reviewer.md +30 -0
- package/agents/lazuli-first-look.md +22 -0
- package/agents/lazuli-task-tester.md +25 -0
- package/bin/lazuli.mjs +747 -0
- package/package.json +11 -4
- package/rules/accessibility/HYPOTHESES.md +8 -0
- package/rules/accessibility/_area.yaml +7 -0
- package/rules/accessibility/operable.yaml +100 -0
- package/rules/accessibility/perceivable.yaml +153 -0
- package/rules/accessibility/robust.yaml +24 -0
- package/rules/accessibility/understandable.yaml +72 -0
- package/rules/color/HYPOTHESES.md +27 -0
- package/rules/color/_area.yaml +10 -0
- package/rules/color/adapt.yaml +183 -0
- package/rules/color/create.yaml +259 -0
- package/rules/color/review.yaml +215 -0
- package/rules/color/signal.yaml +196 -0
- package/rules/content/HYPOTHESES.md +19 -0
- package/rules/content/_area.yaml +8 -0
- package/rules/content/review.yaml +378 -0
- package/rules/content/voice.yaml +144 -0
- package/rules/content/writing.yaml +202 -0
- package/rules/data/HYPOTHESES.md +11 -0
- package/rules/data/_area.yaml +7 -0
- package/rules/data/charts.yaml +189 -0
- package/rules/data/dashboards.yaml +141 -0
- package/rules/data/review.yaml +159 -0
- package/rules/graphic/HYPOTHESES.md +18 -0
- package/rules/graphic/_area.yaml +8 -0
- package/rules/graphic/identity.yaml +141 -0
- package/rules/graphic/pieces.yaml +164 -0
- package/rules/graphic/review.yaml +271 -0
- package/rules/graphic/symbol.yaml +141 -0
- package/rules/motion/HYPOTHESES.md +19 -0
- package/rules/motion/_area.yaml +7 -0
- package/rules/motion/micro.yaml +143 -0
- package/rules/motion/review.yaml +347 -0
- package/rules/motion/transitions.yaml +169 -0
- package/rules/typography/HYPOTHESES.md +12 -0
- package/rules/typography/_area.yaml +8 -0
- package/rules/typography/adapt.yaml +45 -0
- package/rules/typography/create.yaml +126 -0
- package/rules/typography/review.yaml +127 -0
- package/rules/ui/HYPOTHESES.md +23 -0
- package/rules/ui/_area.yaml +9 -0
- package/rules/ui/compose.yaml +246 -0
- package/rules/ui/grid.yaml +75 -0
- package/rules/ui/review.yaml +400 -0
- package/rules/ui/states.yaml +257 -0
- package/rules/ux/HYPOTHESES.md +13 -0
- package/rules/ux/_area.yaml +8 -0
- package/rules/ux/flows.yaml +164 -0
- package/rules/ux/forms.yaml +142 -0
- package/rules/ux/review.yaml +186 -0
- package/skills/lazuli/SKILL.md +183 -0
- package/skills/lazuli/procedures/create.md +29 -0
- package/skills/lazuli/procedures/explain-decisions.md +22 -0
- package/skills/lazuli/procedures/improve.md +30 -0
- package/skills/lazuli/procedures/remember-this.md +41 -0
- package/skills/lazuli/procedures/review-design.md +36 -0
- package/skills/lazuli/procedures/show-options.md +33 -0
- package/skills/lazuli-accessibility-check/SKILL.md +68 -0
- package/skills/lazuli-color-context-and-culture/SKILL.md +53 -0
- package/skills/lazuli-color-context-and-culture/references/sectors.md +26 -0
- package/skills/lazuli-color-palette-by-intent/SKILL.md +54 -0
- package/skills/lazuli-color-palette-by-intent/references/intent-chords.md +51 -0
- package/skills/lazuli-color-screen-review/SKILL.md +51 -0
- package/skills/lazuli-color-states-and-signals/SKILL.md +53 -0
- package/skills/lazuli-content-interface-writing/SKILL.md +53 -0
- package/skills/lazuli-content-voice/SKILL.md +40 -0
- package/skills/lazuli-data-charts-and-dashboards/SKILL.md +59 -0
- package/skills/lazuli-graphic-derived-pieces/SKILL.md +40 -0
- package/skills/lazuli-graphic-derived-pieces/references/piece-template.html +24 -0
- package/skills/lazuli-graphic-identity/SKILL.md +45 -0
- package/skills/lazuli-motion-micro-and-transitions/SKILL.md +49 -0
- package/skills/lazuli-typography-choose-and-pair/SKILL.md +50 -0
- package/skills/lazuli-typography-screen-review/SKILL.md +51 -0
- package/skills/lazuli-ui-composition/SKILL.md +42 -0
- package/skills/lazuli-ui-composition/references/option-template.html +34 -0
- package/skills/lazuli-ui-layout-review/SKILL.md +47 -0
- package/skills/lazuli-ui-states-and-system/SKILL.md +54 -0
- package/skills/lazuli-ux-flows-and-forms/SKILL.md +51 -0
- package/skills/lazuli-ux-task-test/SKILL.md +44 -0
- package/src/browser.mjs +162 -0
- package/src/commands/capture.mjs +313 -0
- package/src/commands/catalog.mjs +37 -0
- package/src/commands/check-design.mjs +463 -0
- package/src/commands/check-goals.mjs +57 -0
- package/src/commands/compare-designs.mjs +160 -0
- package/src/commands/draft-memo.mjs +162 -0
- package/src/commands/hooks.mjs +345 -0
- package/src/commands/install-hooks.mjs +120 -0
- package/src/commands/install.mjs +132 -0
- package/src/commands/list-rules.mjs +49 -0
- package/src/commands/map-page.mjs +594 -0
- package/src/commands/record-answers.mjs +79 -0
- package/src/commands/record-log.mjs +325 -0
- package/src/commands/record-task.mjs +250 -0
- package/src/commands/render-options.mjs +227 -0
- package/src/commands/start-project.mjs +32 -0
- package/src/measure/a11y.mjs +391 -0
- package/src/measure/asset.mjs +206 -0
- package/src/measure/at-rest.mjs +49 -0
- package/src/measure/cases.mjs +566 -0
- package/src/measure/chart-read.mjs +401 -0
- package/src/measure/chart.mjs +264 -0
- package/src/measure/coherence.mjs +145 -0
- package/src/measure/color.mjs +86 -0
- package/src/measure/content.mjs +82 -0
- package/src/measure/cvd.mjs +24 -0
- package/src/measure/extreme.mjs +241 -0
- package/src/measure/forms.mjs +150 -0
- package/src/measure/in-page/a11y.js +522 -0
- package/src/measure/in-page/color.js +348 -0
- package/src/measure/in-page/composition.js +1496 -0
- package/src/measure/in-page/contrast.js +15 -0
- package/src/measure/in-page/cvd.js +173 -0
- package/src/measure/in-page/extreme.js +377 -0
- package/src/measure/in-page/frames.js +781 -0
- package/src/measure/in-page/look.js +28 -0
- package/src/measure/in-page/motion-probe.js +171 -0
- package/src/measure/in-page/style.js +107 -0
- package/src/measure/in-page/svg-strokes.js +112 -0
- package/src/measure/in-page/svg-uses.js +50 -0
- package/src/measure/in-page/symbol.js +123 -0
- package/src/measure/in-page/type.js +269 -0
- package/src/measure/in-page/weight.js +207 -0
- package/src/measure/layout.mjs +100 -0
- package/src/measure/motion.mjs +509 -0
- package/src/measure/piece.mjs +195 -0
- package/src/measure/registry.mjs +253 -0
- package/src/measure/rhythm.mjs +81 -0
- package/src/measure/signature.mjs +65 -0
- package/src/measure/states.mjs +240 -0
- package/src/measure/style.mjs +13 -0
- package/src/measure/symbol.mjs +268 -0
- package/src/measure/terms.mjs +153 -0
- package/src/measure/tiles.mjs +20 -0
- package/src/measure/timeline.mjs +621 -0
- package/src/measure/type.mjs +167 -0
- package/src/measure/weight.mjs +18 -0
- package/src/private-strings.mjs +81 -0
- package/src/project/blind.mjs +70 -0
- package/src/project/edits.mjs +154 -0
- package/src/project/gate.mjs +168 -0
- package/src/project/lazuli-md.mjs +521 -0
- package/src/project/log.mjs +335 -0
- package/src/project/match.mjs +200 -0
- package/src/project/records.mjs +380 -0
- package/src/project/tasks.mjs +153 -0
- package/src/report/evaluate.mjs +27 -0
- package/src/report/evaluators/a11y.mjs +227 -0
- package/src/report/evaluators/chart.mjs +151 -0
- package/src/report/evaluators/coherence.mjs +103 -0
- package/src/report/evaluators/color.mjs +133 -0
- package/src/report/evaluators/content.mjs +112 -0
- package/src/report/evaluators/extreme.mjs +87 -0
- package/src/report/evaluators/forms.mjs +116 -0
- package/src/report/evaluators/layout.mjs +103 -0
- package/src/report/evaluators/motion.mjs +280 -0
- package/src/report/evaluators/piece.mjs +69 -0
- package/src/report/evaluators/rhythm.mjs +99 -0
- package/src/report/evaluators/states.mjs +39 -0
- package/src/report/evaluators/style.mjs +35 -0
- package/src/report/evaluators/symbol.mjs +110 -0
- package/src/report/evaluators/terms.mjs +49 -0
- package/src/report/evaluators/type.mjs +166 -0
- package/src/report/evaluators/weight.mjs +51 -0
- package/src/report/evidence.mjs +4 -0
- package/src/report/finding.mjs +11 -0
- package/src/report/format.mjs +215 -0
- package/src/rules/hypotheses.mjs +28 -0
- package/src/rules/load.mjs +274 -0
- package/src/rules/public-text.mjs +56 -0
- package/src/rules/schema.mjs +220 -0
- package/templates/LAZULI.md +88 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { waitForAnimations } from "../browser.mjs";
|
|
4
|
+
import { ASSET_RUN_CAP_MS, loadAssetBytes, withinCap } from "./asset.mjs";
|
|
5
|
+
import { restOff, restOn } from "./at-rest.mjs";
|
|
6
|
+
import { FONT_WAIT_MS, measureType, nameMatches } from "./type.mjs";
|
|
7
|
+
import { sameTarget } from "../project/match.mjs";
|
|
8
|
+
|
|
9
|
+
let compositionScript;
|
|
10
|
+
|
|
11
|
+
const TYPE_OF_EXT = { ".png": "image/png", ".ico": "image/x-icon", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp" };
|
|
12
|
+
// The sizes a favicon.ico holds, in order, when the piece was rendered at them (16 and 32 required).
|
|
13
|
+
const ICO_SIZES = [16, 32, 48];
|
|
14
|
+
|
|
15
|
+
const noBrand = (label, what, example) =>
|
|
16
|
+
`LAZULI.md has no Brand ${label} lines, so ${what} not checked; add lines such as "${example}" under ## Brand.`;
|
|
17
|
+
const plural = (n, one, many) => (n === 1 ? one : many);
|
|
18
|
+
const RASTER_NOTE = "A raster piece is read for its size only; colors, fonts and the symbol are read from its HTML template.";
|
|
19
|
+
|
|
20
|
+
// Renders a piece at one declared size (ctx.size). An HTML piece is opened as a page in its own context at that
|
|
21
|
+
// canvas, device scale 1, read at rest (finite animations waited for and finished, endless ones stopped) and
|
|
22
|
+
// written to <dir>/<w>x<h>.png; its colors, rendered font families and symbol references are compared with the
|
|
23
|
+
// Brand tokens by exact match. A raster piece is read for its size only.
|
|
24
|
+
export async function measurePiece(asset, ctx) {
|
|
25
|
+
const { browser, size } = ctx;
|
|
26
|
+
const { width, height } = size;
|
|
27
|
+
const base = { width, height, raster: asset.raster === true };
|
|
28
|
+
const cap = ctx.capMs ?? ASSET_RUN_CAP_MS;
|
|
29
|
+
const what = `The piece measure at ${width}x${height}`;
|
|
30
|
+
if (base.raster) {
|
|
31
|
+
const { bytes, type } = await loadAssetBytes(asset, browser);
|
|
32
|
+
const context = await browser.newContext({ viewport: { width, height }, deviceScaleFactor: 1 });
|
|
33
|
+
return withinCap(context, cap, what, () => measureRaster(asset, context, base, bytes, type));
|
|
34
|
+
}
|
|
35
|
+
compositionScript ??= await fs.readFile(new URL("./in-page/composition.js", import.meta.url), "utf8");
|
|
36
|
+
const context = await browser.newContext({ viewport: { width, height }, deviceScaleFactor: 1 });
|
|
37
|
+
return withinCap(context, cap, what, () => readPiece(asset, ctx, base, context));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// The HTML piece read in its own context (closed by the caller).
|
|
41
|
+
async function readPiece(asset, ctx, base, context) {
|
|
42
|
+
const { cwd = process.cwd(), brand, dir } = ctx;
|
|
43
|
+
const { width, height } = base;
|
|
44
|
+
const notes = [];
|
|
45
|
+
let page = null;
|
|
46
|
+
let rested = false;
|
|
47
|
+
try {
|
|
48
|
+
page = await context.newPage();
|
|
49
|
+
await page.goto(asset.url, { waitUntil: "load" });
|
|
50
|
+
await page.evaluate(
|
|
51
|
+
(cap) => Promise.race([document.fonts.ready, new Promise((resolve) => setTimeout(resolve, cap))]),
|
|
52
|
+
FONT_WAIT_MS,
|
|
53
|
+
);
|
|
54
|
+
await waitForAnimations(page);
|
|
55
|
+
await page.evaluate(restOn());
|
|
56
|
+
rested = true;
|
|
57
|
+
const read = await page.evaluate(`(${compositionScript})(${JSON.stringify({ read: "piece", keepPinned: true })}, null)`);
|
|
58
|
+
const type = await measureType(page);
|
|
59
|
+
await fs.mkdir(dir, { recursive: true });
|
|
60
|
+
const file = path.join(dir, `${width}x${height}.png`);
|
|
61
|
+
await page.screenshot({ type: "png", path: file, clip: { x: 0, y: 0, width, height } });
|
|
62
|
+
|
|
63
|
+
const colors = read.colors;
|
|
64
|
+
const brandHexes = new Set((brand?.colors ?? []).map((c) => c.hex));
|
|
65
|
+
let offBrand = null;
|
|
66
|
+
if (brandHexes.size === 0) notes.push(noBrand("Color", "the palette was", "- Color: ink #1a1a1a"));
|
|
67
|
+
else offBrand = colors.filter((c) => !brandHexes.has(c.hex));
|
|
68
|
+
if (colors.length === 0) notes.push("No color was read from the piece.");
|
|
69
|
+
if (read.unread > 0) {
|
|
70
|
+
notes.push(`${read.unread} paint ${plural(read.unread, "value was", "values were")} not read: not a color (such as a url() paint server).`);
|
|
71
|
+
}
|
|
72
|
+
if (read.images > 0) notes.push(`${read.images} ${plural(read.images, "image was", "images were")} not read for color.`);
|
|
73
|
+
|
|
74
|
+
const families = type.families.map((f) => f.family);
|
|
75
|
+
const fonts = brand?.fonts ?? [];
|
|
76
|
+
let offBrandFonts = null;
|
|
77
|
+
if (fonts.length === 0) notes.push(noBrand("Font", "the fonts were", "- Font: Inter"));
|
|
78
|
+
else offBrandFonts = families.filter((f) => !fonts.some((b) => nameMatches(b, [f])));
|
|
79
|
+
if (families.length === 0) notes.push("The piece renders no text, so its fonts were not checked.");
|
|
80
|
+
notes.push(...type.notes);
|
|
81
|
+
|
|
82
|
+
// null: no Brand symbol to look for; file null: the Brand has symbols and none is shown.
|
|
83
|
+
const symbols = brand?.symbols ?? [];
|
|
84
|
+
let symbol = null;
|
|
85
|
+
if (symbols.length === 0) {
|
|
86
|
+
notes.push(noBrand("Symbol", "the symbol was", "- Symbol: brand/symbol.svg"));
|
|
87
|
+
} else {
|
|
88
|
+
symbol = { file: null, url: null, selector: null, px: null };
|
|
89
|
+
for (const r of read.symbolRefs.filter((x) => /^(https?|file):/i.test(x.url))) {
|
|
90
|
+
const s = symbols.find((x) => sameTarget(x.file, r.url, cwd));
|
|
91
|
+
if (s) {
|
|
92
|
+
symbol = { file: s.file, url: r.url, selector: r.selector, px: +r.px.toFixed(1) };
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
...base,
|
|
100
|
+
natural: null,
|
|
101
|
+
overflow: read.overflow,
|
|
102
|
+
colors,
|
|
103
|
+
offBrand,
|
|
104
|
+
families,
|
|
105
|
+
offBrandFonts,
|
|
106
|
+
symbol,
|
|
107
|
+
images: read.images,
|
|
108
|
+
written: [file],
|
|
109
|
+
notes,
|
|
110
|
+
};
|
|
111
|
+
} finally {
|
|
112
|
+
if (rested) await page.evaluate(restOff()).catch(() => {});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// A raster piece: its bytes drawn in an <img> on a blank page (every request aborted) for the natural size, in
|
|
117
|
+
// its own context (closed by the caller).
|
|
118
|
+
async function measureRaster(asset, context, base, bytes, type) {
|
|
119
|
+
const mime = String(type ?? "").split(";")[0].trim().toLowerCase() || TYPE_OF_EXT[asset.ext] || "";
|
|
120
|
+
const url = `data:${mime};base64,${bytes.toString("base64")}`;
|
|
121
|
+
await context.route("**/*", (route) => route.abort());
|
|
122
|
+
const page = await context.newPage();
|
|
123
|
+
await page.setContent("<!doctype html><html><body></body></html>");
|
|
124
|
+
const natural = await page.evaluate(async (src) => {
|
|
125
|
+
const img = new Image();
|
|
126
|
+
img.src = src;
|
|
127
|
+
await img.decode();
|
|
128
|
+
return { width: img.naturalWidth, height: img.naturalHeight };
|
|
129
|
+
}, url);
|
|
130
|
+
return {
|
|
131
|
+
...base,
|
|
132
|
+
natural,
|
|
133
|
+
overflow: null,
|
|
134
|
+
colors: null,
|
|
135
|
+
offBrand: null,
|
|
136
|
+
families: null,
|
|
137
|
+
offBrandFonts: null,
|
|
138
|
+
symbol: null,
|
|
139
|
+
images: null,
|
|
140
|
+
written: [],
|
|
141
|
+
notes: [RASTER_NOTE],
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Bits per pixel of a PNG from its IHDR (bit depth at byte 24 times the channels of the color type at byte
|
|
146
|
+
// 25): a screenshot without alpha is 8-bit RGB, 24.
|
|
147
|
+
const PNG_CHANNELS = { 0: 1, 2: 3, 3: 1, 4: 2, 6: 4 };
|
|
148
|
+
export function pngBits(png) {
|
|
149
|
+
return png.readUInt8(24) * (PNG_CHANNELS[png.readUInt8(25)] ?? 0);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// An ICO file holding PNG images: ICONDIR (reserved 0, type 1, count), one 16-byte entry per image (width
|
|
153
|
+
// and height, 0 for 256; color count 0; reserved 0; planes 1; bit count of the embedded PNG; byte size;
|
|
154
|
+
// offset), then the PNG bytes in the same order. All numbers little-endian.
|
|
155
|
+
export function writeIco(images) {
|
|
156
|
+
const head = Buffer.alloc(6 + 16 * images.length);
|
|
157
|
+
head.writeUInt16LE(0, 0);
|
|
158
|
+
head.writeUInt16LE(1, 2);
|
|
159
|
+
head.writeUInt16LE(images.length, 4);
|
|
160
|
+
let offset = head.length;
|
|
161
|
+
images.forEach(({ size, png }, i) => {
|
|
162
|
+
const o = 6 + 16 * i;
|
|
163
|
+
head.writeUInt8(size >= 256 ? 0 : size, o);
|
|
164
|
+
head.writeUInt8(size >= 256 ? 0 : size, o + 1);
|
|
165
|
+
head.writeUInt8(0, o + 2);
|
|
166
|
+
head.writeUInt8(0, o + 3);
|
|
167
|
+
head.writeUInt16LE(1, o + 4);
|
|
168
|
+
head.writeUInt16LE(pngBits(png), o + 6);
|
|
169
|
+
head.writeUInt32LE(png.length, o + 8);
|
|
170
|
+
head.writeUInt32LE(offset, o + 12);
|
|
171
|
+
offset += png.length;
|
|
172
|
+
});
|
|
173
|
+
return Buffer.concat([head, ...images.map((x) => x.png)]);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// After every size: when the piece was rendered at 16x16 and 32x32 (and 48x48 if asked) in this run (ctx.written),
|
|
177
|
+
// favicon.ico in ctx.dir from those PNGs. Returns { written, notes }: nothing for a raster piece, and a note when
|
|
178
|
+
// a size the icon needs was not rendered in this run.
|
|
179
|
+
export async function finishPiece(asset, ctx) {
|
|
180
|
+
const none = { written: [], notes: [] };
|
|
181
|
+
if (asset.raster) return none;
|
|
182
|
+
const has = (s) => (asset.sizes ?? []).some((x) => x.width === s && x.height === s);
|
|
183
|
+
if (!has(16) || !has(32)) return none;
|
|
184
|
+
// Only PNGs this run wrote (ctx.written): a file an earlier run left in the folder is never used.
|
|
185
|
+
const thisRun = new Set((ctx.written ?? []).map((f) => path.resolve(f)));
|
|
186
|
+
const images = [];
|
|
187
|
+
for (const s of ICO_SIZES.filter(has)) {
|
|
188
|
+
const png = path.join(ctx.dir, `${s}x${s}.png`);
|
|
189
|
+
if (!thisRun.has(path.resolve(png))) return { written: [], notes: [`favicon.ico was not written: ${s}x${s}.png was not rendered in this run.`] };
|
|
190
|
+
images.push({ size: s, png: await fs.readFile(png) });
|
|
191
|
+
}
|
|
192
|
+
const file = path.join(ctx.dir, "favicon.ico");
|
|
193
|
+
await fs.writeFile(file, writeIco(images));
|
|
194
|
+
return { written: [file], notes: [] };
|
|
195
|
+
}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { measureColor } from "./color.mjs";
|
|
2
|
+
import { measureWeight } from "./weight.mjs";
|
|
3
|
+
import { measureType } from "./type.mjs";
|
|
4
|
+
import { measureA11y } from "./a11y.mjs";
|
|
5
|
+
import { measureStyle } from "./style.mjs";
|
|
6
|
+
import { measureLayout } from "./layout.mjs";
|
|
7
|
+
import { a11yEvaluators } from "../report/evaluators/a11y.mjs";
|
|
8
|
+
import { colorEvaluators } from "../report/evaluators/color.mjs";
|
|
9
|
+
import { weightEvaluators } from "../report/evaluators/weight.mjs";
|
|
10
|
+
import { typeEvaluators } from "../report/evaluators/type.mjs";
|
|
11
|
+
import { styleEvaluators } from "../report/evaluators/style.mjs";
|
|
12
|
+
import { layoutEvaluators } from "../report/evaluators/layout.mjs";
|
|
13
|
+
import { measureRhythm } from "./rhythm.mjs";
|
|
14
|
+
import { rhythmEvaluators } from "../report/evaluators/rhythm.mjs";
|
|
15
|
+
import { measureStates } from "./states.mjs";
|
|
16
|
+
import { statesEvaluators } from "../report/evaluators/states.mjs";
|
|
17
|
+
import { measureCoherence } from "./coherence.mjs";
|
|
18
|
+
import { coherenceEvaluators } from "../report/evaluators/coherence.mjs";
|
|
19
|
+
import { measureForms } from "./forms.mjs";
|
|
20
|
+
import { formsEvaluators } from "../report/evaluators/forms.mjs";
|
|
21
|
+
import { measureSymbol } from "./symbol.mjs";
|
|
22
|
+
import { symbolEvaluators } from "../report/evaluators/symbol.mjs";
|
|
23
|
+
import { finishPiece, measurePiece } from "./piece.mjs";
|
|
24
|
+
import { pieceEvaluators } from "../report/evaluators/piece.mjs";
|
|
25
|
+
import { measureMotion } from "./motion.mjs";
|
|
26
|
+
import { motionEvaluators } from "../report/evaluators/motion.mjs";
|
|
27
|
+
import { measureContent } from "./content.mjs";
|
|
28
|
+
import { contentEvaluators } from "../report/evaluators/content.mjs";
|
|
29
|
+
import { measureTerms } from "./terms.mjs";
|
|
30
|
+
import { termsEvaluators } from "../report/evaluators/terms.mjs";
|
|
31
|
+
import { measureExtreme } from "./extreme.mjs";
|
|
32
|
+
import { extremeEvaluators } from "../report/evaluators/extreme.mjs";
|
|
33
|
+
// chart measurer
|
|
34
|
+
import { measureChart } from "./chart.mjs";
|
|
35
|
+
import { chartEvaluators } from "../report/evaluators/chart.mjs";
|
|
36
|
+
|
|
37
|
+
// scope "page": run(page, ctx) on one page per width. scope "site": run(pages, ctx) once per width on every
|
|
38
|
+
// screen ({ target, page }[], ctx.screens lists them all); evaluators still take (rule, m) with
|
|
39
|
+
// m = { width, <name>: report }.
|
|
40
|
+
// scope "asset" (check-design --asset only, never on a page run): kind "symbol" or "piece", run(asset, ctx) with
|
|
41
|
+
// ctx = { browser, cwd, brand, goals, rules, size, dir }; size is one { width, height } for a piece (run once per
|
|
42
|
+
// size) and null for a symbol (run once); dir is assetDir. The report carries written (file paths) and notes;
|
|
43
|
+
// a symbol report also carries sizes (the ladder it read). An optional finish(asset, ctx) runs after every size
|
|
44
|
+
// with ctx.written (the files this run wrote) and returns { written, notes }: more files and notes for the
|
|
45
|
+
// asset. Each run is capped by ASSET_RUN_CAP_MS (ctx.capMs in tests). The width of an asset measure entry is a size label: "<w>x<h>" for a piece,
|
|
46
|
+
// "<largest> to <smallest>" for a symbol. Each asset measurer opens and closes its own contexts.
|
|
47
|
+
// thresholdIds lists the ids whose rules need a threshold; without it, every id needs one.
|
|
48
|
+
export const MEASURERS = [
|
|
49
|
+
{
|
|
50
|
+
name: "color",
|
|
51
|
+
scope: "page",
|
|
52
|
+
ids: ["color.area", "color.contrast", "color.text-chroma", "color.brand"],
|
|
53
|
+
run: (page, ctx) => measureColor(page, ctx),
|
|
54
|
+
evaluators: colorEvaluators,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "weight",
|
|
58
|
+
scope: "page",
|
|
59
|
+
thresholdIds: [],
|
|
60
|
+
ids: ["weight.order"],
|
|
61
|
+
run: (page) => measureWeight(page),
|
|
62
|
+
evaluators: weightEvaluators,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "type",
|
|
66
|
+
scope: "page",
|
|
67
|
+
ids: [
|
|
68
|
+
"type.families",
|
|
69
|
+
"type.fallback",
|
|
70
|
+
"type.line-length",
|
|
71
|
+
"type.body-size",
|
|
72
|
+
"type.line-height",
|
|
73
|
+
"type.scale",
|
|
74
|
+
"type.hierarchy",
|
|
75
|
+
"type.heading-rag",
|
|
76
|
+
],
|
|
77
|
+
thresholdIds: ["type.families", "type.line-length", "type.body-size", "type.line-height", "type.scale"],
|
|
78
|
+
run: (page, ctx) => measureType(page, ctx),
|
|
79
|
+
evaluators: typeEvaluators,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "a11y",
|
|
83
|
+
scope: "page",
|
|
84
|
+
ids: [
|
|
85
|
+
"a11y.names",
|
|
86
|
+
"a11y.alt",
|
|
87
|
+
"a11y.lang",
|
|
88
|
+
"a11y.title",
|
|
89
|
+
"a11y.headings",
|
|
90
|
+
"a11y.generic-links",
|
|
91
|
+
"a11y.target-size",
|
|
92
|
+
"a11y.focus-visible",
|
|
93
|
+
"a11y.focus-obscured",
|
|
94
|
+
"a11y.reflow",
|
|
95
|
+
"a11y.text-spacing",
|
|
96
|
+
"a11y.decorative-images",
|
|
97
|
+
"a11y.image-treatment",
|
|
98
|
+
],
|
|
99
|
+
thresholdIds: ["a11y.generic-links", "a11y.target-size", "a11y.reflow", "a11y.text-spacing", "a11y.decorative-images", "a11y.image-treatment"],
|
|
100
|
+
run: (page, ctx) => measureA11y(page, ctx),
|
|
101
|
+
evaluators: a11yEvaluators,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "style",
|
|
105
|
+
scope: "page",
|
|
106
|
+
ids: ["style.value"],
|
|
107
|
+
thresholdIds: ["style.value"],
|
|
108
|
+
run: (page, ctx) => measureStyle(page, ctx),
|
|
109
|
+
evaluators: styleEvaluators,
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: "layout",
|
|
113
|
+
scope: "page",
|
|
114
|
+
ids: ["layout.scale-contrast", "layout.empty-space", "layout.focal-point", "layout.grid", "layout.sideways"],
|
|
115
|
+
thresholdIds: ["layout.scale-contrast", "layout.empty-space", "layout.focal-point", "layout.grid"],
|
|
116
|
+
run: (page, ctx) => measureLayout(page, ctx),
|
|
117
|
+
evaluators: layoutEvaluators,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "rhythm",
|
|
121
|
+
scope: "page",
|
|
122
|
+
ids: ["rhythm.pace", "rhythm.map", "rhythm.climax"],
|
|
123
|
+
thresholdIds: ["rhythm.pace", "rhythm.climax"],
|
|
124
|
+
run: (page, ctx) => measureRhythm(page, ctx),
|
|
125
|
+
evaluators: rhythmEvaluators,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "states",
|
|
129
|
+
scope: "page",
|
|
130
|
+
ids: ["states.hover", "states.active", "states.disabled", "states.invalid"],
|
|
131
|
+
thresholdIds: [],
|
|
132
|
+
run: (page, ctx) => measureStates(page, ctx),
|
|
133
|
+
evaluators: statesEvaluators,
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: "forms",
|
|
137
|
+
scope: "page",
|
|
138
|
+
ids: ["forms.labels", "forms.autocomplete", "forms.input-mode", "forms.required", "forms.errors", "forms.field-count"],
|
|
139
|
+
thresholdIds: ["forms.field-count"],
|
|
140
|
+
run: (page, ctx) => measureForms(page, ctx),
|
|
141
|
+
evaluators: formsEvaluators,
|
|
142
|
+
},
|
|
143
|
+
// ---- chart measurer (the page measurer right before motion) ----
|
|
144
|
+
{
|
|
145
|
+
// Reads the shared page at every width (charts reflow) and never acts on it.
|
|
146
|
+
name: "chart",
|
|
147
|
+
scope: "page",
|
|
148
|
+
ids: ["chart.baseline", "chart.label-size", "chart.direct-labels", "chart.categories", "chart.cvd"],
|
|
149
|
+
thresholdIds: ["chart.label-size", "chart.categories", "chart.cvd"],
|
|
150
|
+
run: (page, ctx) => measureChart(page, ctx),
|
|
151
|
+
evaluators: chartEvaluators,
|
|
152
|
+
},
|
|
153
|
+
// ---- end chart measurer ----
|
|
154
|
+
{
|
|
155
|
+
// Records at the first width of a run only (null at the others); opens its own pages, never the given one.
|
|
156
|
+
name: "motion",
|
|
157
|
+
scope: "page",
|
|
158
|
+
ids: [
|
|
159
|
+
"motion.micro-duration",
|
|
160
|
+
"motion.transition-duration",
|
|
161
|
+
"motion.easing",
|
|
162
|
+
"motion.properties",
|
|
163
|
+
"motion.sameness",
|
|
164
|
+
"motion.reduced",
|
|
165
|
+
"motion.long-frames",
|
|
166
|
+
"motion.layout-shift",
|
|
167
|
+
"motion.settle",
|
|
168
|
+
"motion.banding",
|
|
169
|
+
"motion.flashes",
|
|
170
|
+
"motion.moving",
|
|
171
|
+
],
|
|
172
|
+
thresholdIds: [
|
|
173
|
+
"motion.micro-duration",
|
|
174
|
+
"motion.transition-duration",
|
|
175
|
+
"motion.sameness",
|
|
176
|
+
"motion.long-frames",
|
|
177
|
+
"motion.layout-shift",
|
|
178
|
+
"motion.settle",
|
|
179
|
+
"motion.banding",
|
|
180
|
+
"motion.flashes",
|
|
181
|
+
"motion.moving",
|
|
182
|
+
],
|
|
183
|
+
run: (page, ctx) => measureMotion(page, ctx),
|
|
184
|
+
evaluators: motionEvaluators,
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
// Reads the shared page at rest (as coherence does) and never changes it.
|
|
188
|
+
name: "content",
|
|
189
|
+
scope: "page",
|
|
190
|
+
ids: ["content.generic-labels", "content.label-length", "content.label-case", "content.errors"],
|
|
191
|
+
thresholdIds: ["content.generic-labels", "content.label-length", "content.errors"],
|
|
192
|
+
run: (page, ctx) => measureContent(page, ctx),
|
|
193
|
+
evaluators: contentEvaluators,
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
// Opens its own pages (a source open, then one script-free guarded context per width); never the given one.
|
|
197
|
+
name: "extreme",
|
|
198
|
+
scope: "page",
|
|
199
|
+
ids: ["extreme.growth", "extreme.long-text", "extreme.empty", "extreme.one", "extreme.many"],
|
|
200
|
+
thresholdIds: ["extreme.growth"],
|
|
201
|
+
run: (page, ctx) => measureExtreme(page, ctx),
|
|
202
|
+
evaluators: extremeEvaluators,
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: "coherence",
|
|
206
|
+
scope: "site",
|
|
207
|
+
ids: ["coherence.same-component", "coherence.variants"],
|
|
208
|
+
thresholdIds: ["coherence.variants"],
|
|
209
|
+
run: (pages, ctx) => measureCoherence(pages, ctx),
|
|
210
|
+
evaluators: coherenceEvaluators,
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
// Reads every screen at rest with the content reader (as coherence does) and never changes it.
|
|
214
|
+
name: "terms",
|
|
215
|
+
scope: "site",
|
|
216
|
+
ids: ["terms.same-target", "terms.spelling"],
|
|
217
|
+
thresholdIds: [],
|
|
218
|
+
run: (pages, ctx) => measureTerms(pages, ctx),
|
|
219
|
+
evaluators: termsEvaluators,
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
name: "symbol",
|
|
223
|
+
scope: "asset",
|
|
224
|
+
kind: "symbol",
|
|
225
|
+
ids: ["symbol.silhouette", "symbol.detail", "symbol.stroke", "symbol.contrast"],
|
|
226
|
+
thresholdIds: ["symbol.silhouette", "symbol.detail", "symbol.stroke", "symbol.contrast"],
|
|
227
|
+
run: (asset, ctx) => measureSymbol(asset, ctx),
|
|
228
|
+
evaluators: symbolEvaluators,
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: "piece",
|
|
232
|
+
scope: "asset",
|
|
233
|
+
kind: "piece",
|
|
234
|
+
ids: ["piece.fit", "piece.palette", "piece.fonts", "piece.symbol"],
|
|
235
|
+
thresholdIds: [],
|
|
236
|
+
run: (asset, ctx) => measurePiece(asset, ctx),
|
|
237
|
+
finish: (asset, ctx) => finishPiece(asset, ctx),
|
|
238
|
+
evaluators: pieceEvaluators,
|
|
239
|
+
},
|
|
240
|
+
];
|
|
241
|
+
|
|
242
|
+
export function needsThreshold(id, measurers = MEASURERS) {
|
|
243
|
+
const m = measurers.find((x) => x.ids.includes(id));
|
|
244
|
+
if (!m || !Array.isArray(m.thresholdIds)) return true;
|
|
245
|
+
return m.thresholdIds.includes(id);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export const measureIds = () => MEASURERS.flatMap((m) => m.ids);
|
|
249
|
+
|
|
250
|
+
export function measurersFor(rules, measurers = MEASURERS) {
|
|
251
|
+
const used = new Set(rules.map((r) => r.measure).filter(Boolean));
|
|
252
|
+
return measurers.filter((m) => m.ids.some((id) => used.has(id)));
|
|
253
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
|
|
3
|
+
let script;
|
|
4
|
+
|
|
5
|
+
const round = (n, places = 2) => (n === null ? null : Math.round(n * 10 ** places) / 10 ** places);
|
|
6
|
+
// Density keeps three places: a nearly empty section stays above 0 instead of rounding to it.
|
|
7
|
+
const roundDensity = (n) => round(n, 3);
|
|
8
|
+
const sameMap = (a, b) => a.join(",") === b.join(",");
|
|
9
|
+
|
|
10
|
+
export const NO_SCROLL_NOTE = "The page does not scroll; rhythm was read on one viewport.";
|
|
11
|
+
const UNREAD_START = "The page is taller than ";
|
|
12
|
+
const UNREAD_END = ", so the rhythm was not compared with the map.";
|
|
13
|
+
// The note for sections left out below a cap; the map and climax evaluators read it to stay silent. Since 1.0.1
|
|
14
|
+
// the whole page is read and the note is no longer written; it stays for reports made before.
|
|
15
|
+
export const isUnreadNote = (n) => n.startsWith(UNREAD_START) && n.endsWith(UNREAD_END);
|
|
16
|
+
|
|
17
|
+
// Scroll as a sequence: sections and viewport steps (height, density, scale), the climax, and the
|
|
18
|
+
// rhythm map declared for this page in ctx.goals (read-only; shared with every measurer).
|
|
19
|
+
// The whole page is read, to the end of its scroll.
|
|
20
|
+
export async function measureRhythm(page, ctx = {}) {
|
|
21
|
+
script ??= await fs.readFile(new URL("./in-page/composition.js", import.meta.url), "utf8");
|
|
22
|
+
// Infinity is written into the expression itself: JSON would turn it into null.
|
|
23
|
+
const raw = await page.evaluate(`(${script})({ read: "rhythm", capPx: Infinity, options: ${ctx?.options === true} })`);
|
|
24
|
+
const vh = raw.viewportPx;
|
|
25
|
+
const scale = (px) => (px === null || !raw.bodyPx ? null : px / raw.bodyPx);
|
|
26
|
+
const notes = [];
|
|
27
|
+
|
|
28
|
+
const sections = raw.sections.map((s) => ({
|
|
29
|
+
selector: s.selector,
|
|
30
|
+
top: round(s.top),
|
|
31
|
+
height: round(s.height),
|
|
32
|
+
heightVh: vh > 0 ? round(s.height / vh) : null,
|
|
33
|
+
density: roundDensity(s.density),
|
|
34
|
+
// One row of the coverage grid over the section's measured height; four places so a tall section keeps it above 0.
|
|
35
|
+
densityStep: round(s.densityStep ?? null, 4),
|
|
36
|
+
scale: round(scale(s.maxPx)),
|
|
37
|
+
}));
|
|
38
|
+
const steps = raw.steps.map((s, index) => ({ index, top: round(s.top), density: roundDensity(s.density), scale: round(scale(s.maxPx)) }));
|
|
39
|
+
|
|
40
|
+
// Climax: the section with the largest scale; ties go to the taller, then to the first.
|
|
41
|
+
let climax = null;
|
|
42
|
+
let best = null;
|
|
43
|
+
raw.sections.forEach((s, index) => {
|
|
44
|
+
const v = scale(s.maxPx);
|
|
45
|
+
if (v === null) return;
|
|
46
|
+
if (best === null || v > best.v || (v === best.v && s.height > raw.sections[best.index].height)) best = { v, index };
|
|
47
|
+
});
|
|
48
|
+
if (best !== null && raw.measuredPx > 0) {
|
|
49
|
+
const s = raw.sections[best.index];
|
|
50
|
+
const center = s.top + Math.min(s.height, raw.measuredPx - s.top) / 2;
|
|
51
|
+
climax = { index: best.index, position: round(center / raw.measuredPx) };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const goals = ctx?.goals ?? [];
|
|
55
|
+
const first = goals.find((g) => Array.isArray(g.rhythm) && g.rhythm.length > 0);
|
|
56
|
+
const declared = first ? { piece: first.piece, beats: [...first.rhythm] } : null;
|
|
57
|
+
if (first) {
|
|
58
|
+
for (const g of goals) {
|
|
59
|
+
if (g !== first && Array.isArray(g.rhythm) && g.rhythm.length > 0 && !sameMap(g.rhythm, first.rhythm)) {
|
|
60
|
+
notes.push(`Goals ${first.piece} and ${g.piece} declare different rhythm maps for this page; ${first.piece} was used.`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!raw.scrolls) notes.push(NO_SCROLL_NOTE);
|
|
66
|
+
if (raw.noSections && raw.pinnedContent) notes.push("Content sits in a fixed container and was not measured.");
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
viewportPx: vh,
|
|
70
|
+
pageHeightPx: raw.pageHeightPx,
|
|
71
|
+
measuredPx: raw.measuredPx,
|
|
72
|
+
sections,
|
|
73
|
+
// Unrounded, in section order: rhythm.pace decides "is 0" and its ratio on these; section.density is for display.
|
|
74
|
+
densityRaw: raw.sections.map((s) => s.density),
|
|
75
|
+
steps,
|
|
76
|
+
climax,
|
|
77
|
+
declared,
|
|
78
|
+
hasGoal: goals.length > 0,
|
|
79
|
+
notes,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// A page's structural signature (first view, grid and scroll sequence) and the distance between two.
|
|
2
|
+
// The distance is hypothesis H1 of the ui area (rules/ui/HYPOTHESES.md): every component weighs the same,
|
|
3
|
+
// which is our claim, and no cutoff says what distance is "different enough".
|
|
4
|
+
|
|
5
|
+
const num = (v) => (typeof v === "number" && Number.isFinite(v) ? v : null);
|
|
6
|
+
const round = (n) => Math.round(n * 100) / 100;
|
|
7
|
+
const mean = (xs) => xs.reduce((s, x) => s + x, 0) / xs.length;
|
|
8
|
+
|
|
9
|
+
export function signatureOf(layout, rhythm) {
|
|
10
|
+
// Sections with no blocks have null edges and are skipped, as uniformGrid skips them.
|
|
11
|
+
const edged = (layout.sections ?? []).filter((s) => s.left !== null && s.left !== undefined && s.right !== null && s.right !== undefined);
|
|
12
|
+
const f = layout.focal;
|
|
13
|
+
return {
|
|
14
|
+
sections: (rhythm.sections ?? []).map((s) => ({ heightVh: num(s.heightVh), density: num(s.density), scale: num(s.scale) })),
|
|
15
|
+
centered: edged.length > 0 && edged.every((s) => s.centered === true),
|
|
16
|
+
uniformGrid: layout.uniformGrid === true,
|
|
17
|
+
textRatio: num(layout.textRatio),
|
|
18
|
+
areaRatio: num(layout.areaRatio),
|
|
19
|
+
emptyShare: num(layout.emptyShare),
|
|
20
|
+
emptySpread: num(layout.emptySpread),
|
|
21
|
+
focal: f && num(f.x) !== null && num(f.y) !== null ? { x: f.x, y: f.y } : null,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 0 when both are 0 or both null, 1 when only one is null, else |a - b| / max(|a|, |b|).
|
|
26
|
+
function scalarDiff(a, b) {
|
|
27
|
+
if (a === null && b === null) return 0;
|
|
28
|
+
if (a === null || b === null) return 1;
|
|
29
|
+
const top = Math.max(Math.abs(a), Math.abs(b));
|
|
30
|
+
return top === 0 ? 0 : Math.abs(a - b) / top;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// The item at the same relative position when a sequence is stretched to `longer` items (nearest).
|
|
34
|
+
const resample = (seq, longer) =>
|
|
35
|
+
Array.from({ length: longer }, (_, i) => seq[longer === 1 ? 0 : Math.round((i * (seq.length - 1)) / (longer - 1))]);
|
|
36
|
+
|
|
37
|
+
function sectionsDiff(a, b) {
|
|
38
|
+
if (a.length === 0 && b.length === 0) return 0;
|
|
39
|
+
if (a.length === 0 || b.length === 0) return 1;
|
|
40
|
+
const longer = Math.max(a.length, b.length);
|
|
41
|
+
const ra = resample(a, longer);
|
|
42
|
+
const rb = resample(b, longer);
|
|
43
|
+
return mean(ra.map((x, i) => mean(["heightVh", "density", "scale"].map((k) => scalarDiff(x[k], rb[i][k])))));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function focalDiff(a, b) {
|
|
47
|
+
if (a === null && b === null) return 0;
|
|
48
|
+
if (a === null || b === null) return 1;
|
|
49
|
+
return Math.hypot(a.x - b.x, a.y - b.y) / Math.SQRT2;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Diffs are rounded for the report; value is the mean of the unrounded diffs, then rounded.
|
|
53
|
+
export function distance(a, b) {
|
|
54
|
+
const na = a.sections.length;
|
|
55
|
+
const nb = b.sections.length;
|
|
56
|
+
const parts = [
|
|
57
|
+
{ name: "sections", a: a.sections, b: b.sections, diff: sectionsDiff(a.sections, b.sections) },
|
|
58
|
+
{ name: "section count", a: na, b: nb, diff: Math.max(na, nb) === 0 ? 0 : Math.abs(na - nb) / Math.max(na, nb) },
|
|
59
|
+
{ name: "centered", a: a.centered, b: b.centered, diff: a.centered === b.centered ? 0 : 1 },
|
|
60
|
+
{ name: "uniformGrid", a: a.uniformGrid, b: b.uniformGrid, diff: a.uniformGrid === b.uniformGrid ? 0 : 1 },
|
|
61
|
+
...["textRatio", "areaRatio", "emptyShare", "emptySpread"].map((k) => ({ name: k, a: a[k], b: b[k], diff: scalarDiff(a[k], b[k]) })),
|
|
62
|
+
{ name: "focal", a: a.focal, b: b.focal, diff: focalDiff(a.focal, b.focal) },
|
|
63
|
+
];
|
|
64
|
+
return { value: round(mean(parts.map((p) => p.diff))), components: parts.map((p) => ({ ...p, diff: round(p.diff) })) };
|
|
65
|
+
}
|