medesign 1.4.0 → 1.6.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/bin/mebolder.js +4 -0
- package/bin/medesign.js +331 -30
- package/bin/melint.js +4 -0
- package/bin/mepolish.js +4 -0
- package/bin/mequiet.js +4 -0
- package/bin/mesearch.js +4 -0
- package/bin/mesnapshot.js +4 -0
- package/examples/cadastral-qaqc-slide.html +577 -0
- package/examples/executive-summary-report.html +597 -0
- package/examples/executive-summary-report.pdf +0 -0
- package/examples/geospatial-banner-1200x630.html +370 -0
- package/examples/geospatial-banner-1200x630.svg +149 -0
- package/examples/linear-issue-board.html +1273 -0
- package/examples/snapshots/cadastral-qaqc-slide-desktop-1440x900.png +0 -0
- package/examples/snapshots/cadastral-qaqc-slide-mobile-390x844.png +0 -0
- package/examples/snapshots/cadastral-qaqc-slide-tablet-820x1180.png +0 -0
- package/examples/snapshots/executive-summary-report-desktop-1440x900.png +0 -0
- package/examples/snapshots/executive-summary-report-mobile-390x844.png +0 -0
- package/examples/snapshots/executive-summary-report-tablet-820x1180.png +0 -0
- package/examples/snapshots/geospatial-banner-1200x630-og-banner-1200x630.png +0 -0
- package/examples/snapshots/linear-issue-board-desktop-1440x900.png +0 -0
- package/examples/snapshots/linear-issue-board-mobile-390x844.png +0 -0
- package/examples/snapshots/linear-issue-board-tablet-820x1180.png +0 -0
- package/examples/snapshots/spotify-web-player-desktop-1440x900.png +0 -0
- package/examples/snapshots/spotify-web-player-mobile-390x844.png +0 -0
- package/examples/snapshots/spotify-web-player-tablet-820x1180.png +0 -0
- package/examples/spotify-web-player.html +1446 -0
- package/package.json +81 -69
- package/presets/metha/guidelines.md +26 -17
- package/presets/metha/preset.json +16 -16
- package/references/ai-tells.md +9 -2
- package/references/brand-design-tokens.md +27 -28
- package/references/brief-intake.md +90 -0
- package/references/catalog.json +1031 -1023
- package/references/cli-architecture.md +1 -1
- package/references/compositor-smoothness.md +161 -0
- package/references/design-core.md +11 -4
- package/references/executive-reports.md +234 -0
- package/references/image-mockup-direction.md +53 -53
- package/references/image-to-code.md +46 -46
- package/references/modern-craft-invariants.md +55 -9
- package/references/prompt-templates.md +49 -0
- package/references/quality-gate.md +42 -12
- package/references/typography-thai-latin.md +206 -0
- package/references/view-transitions-engine.md +89 -0
- package/references/web-retrofit-protocol.md +103 -0
- package/scripts/export-tokens.js +419 -403
- package/tests/browser-audit.js +463 -442
- package/tests/linter.js +49 -4
- package/tests/snapshot.js +263 -0
package/tests/linter.js
CHANGED
|
@@ -8,8 +8,26 @@
|
|
|
8
8
|
|
|
9
9
|
const fs = require('fs');
|
|
10
10
|
const path = require('path');
|
|
11
|
+
const pkg = require('../package.json');
|
|
11
12
|
|
|
12
13
|
const args = process.argv.slice(2);
|
|
14
|
+
|
|
15
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
16
|
+
console.log(`
|
|
17
|
+
\x1b[1mME-DESIGN Linter (v${pkg.version})\x1b[0m
|
|
18
|
+
\x1b[90mStatic AST & semantic rule auditing for HTML/CSS/JSX\x1b[0m
|
|
19
|
+
|
|
20
|
+
\x1b[1mUsage:\x1b[0m
|
|
21
|
+
medesign lint <file> [options]
|
|
22
|
+
melint <file> [options]
|
|
23
|
+
|
|
24
|
+
\x1b[1mOptions:\x1b[0m
|
|
25
|
+
--format <text|json|sarif> Output format (default: text)
|
|
26
|
+
--preset <apple|tesla|metha> Target design preset
|
|
27
|
+
--config <path> Custom medesign.config.js path
|
|
28
|
+
`);
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
13
31
|
let targetFile = null;
|
|
14
32
|
let presetName = 'default';
|
|
15
33
|
let format = 'text'; // 'text' | 'json' | 'sarif'
|
|
@@ -181,7 +199,7 @@ if (hasDenseGrid) {
|
|
|
181
199
|
|
|
182
200
|
// 7. RULE MD102: Color Gamut Interpolation Space - Soft Heuristic (Warning)
|
|
183
201
|
const hasGradient = /linear-gradient\(/i.test(cleanCode);
|
|
184
|
-
const hasOklchOklab = /linear-gradient\(\s
|
|
202
|
+
const hasOklchOklab = /linear-gradient\([^)]*\bin\s+(oklch|oklab)/i.test(cleanCode);
|
|
185
203
|
if (hasGradient && !hasOklchOklab) {
|
|
186
204
|
diagnostics.push({
|
|
187
205
|
ruleId: 'MD102',
|
|
@@ -238,7 +256,33 @@ if (hasOrderReverse) {
|
|
|
238
256
|
});
|
|
239
257
|
}
|
|
240
258
|
|
|
241
|
-
// 11. RULE
|
|
259
|
+
// 11. RULE MD106: Container Optical Padding & Slider Boundary Clearance - Soft Heuristic (Warning)
|
|
260
|
+
// When an interactive slider or pill container has a rounded background, inner tracks must maintain >= 8px optical clearance.
|
|
261
|
+
const sliderPillBlocks = cleanCode.match(/(?:[a-zA-Z0-9_\-\.\#\:\*\,\[\]\="'>\s]+)?(?:slider|progress|scrubber|pill-track)\s*\{[^}]+\}/gi) || [];
|
|
262
|
+
let hasBoundaryCollision = false;
|
|
263
|
+
for (const block of sliderPillBlocks) {
|
|
264
|
+
const hasPillRadius = /border-radius\s*:\s*(?:var\(--radius-full\)|9999px|50%|[1-9]\d{1,}px)/i.test(block);
|
|
265
|
+
const hasVisibleBg = /background(?:-color)?\s*:\s*(?!none|transparent\b|rgba\(\s*0\s*,\s*0\s*,\s*0\s*,\s*0\s*\))/i.test(block);
|
|
266
|
+
const hasMinHeightTarget = /(?:min-)?height\s*:\s*(?:[3-9]\dpx|44px)/i.test(block);
|
|
267
|
+
const hasOpticalPadding = /padding(?:-inline|-left|-right)?\s*:\s*(?:[^;}]*?(?:[8-9]px|[1-9]\d+px|var\(--padding))/i.test(block);
|
|
268
|
+
if (hasPillRadius && hasVisibleBg && hasMinHeightTarget && !hasOpticalPadding) {
|
|
269
|
+
hasBoundaryCollision = true;
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (hasBoundaryCollision) {
|
|
274
|
+
diagnostics.push({
|
|
275
|
+
ruleId: 'MD106',
|
|
276
|
+
ruleName: 'ContainerBoundaryClearance',
|
|
277
|
+
category: 'G',
|
|
278
|
+
severity: config.rules.MD106 || 'warning',
|
|
279
|
+
hardInvariant: false,
|
|
280
|
+
message: 'Detected full-width slider/progress track inside a rounded container with background but zero optical padding, causing visual boundary collision.',
|
|
281
|
+
remediation: 'Isolate outer 44px hit-target with transparent background, or provide horizontal optical padding (padding: 0 12px) to prevent the track from slamming into the curved border.'
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// 12. RULE MD201: Editorial Style: Em-Dash Punctuation - Soft Heuristic (Info)
|
|
242
286
|
const visibleTextMatch = content.replace(/<script[\s\S]*?<\/script>/gi, '').replace(/<style[\s\S]*?<\/style>/gi, '');
|
|
243
287
|
const hasEmDash = /[—–]/.test(visibleTextMatch);
|
|
244
288
|
if (hasEmDash) {
|
|
@@ -296,6 +340,7 @@ if (format === 'sarif') {
|
|
|
296
340
|
{ id: 'MD103', name: 'ConcentricRadiusMath', desc: 'Concentric radius geometry', level: 'note' },
|
|
297
341
|
{ id: 'MD104', name: 'MobileViewportStability', desc: 'Mobile viewport dynamic unit stability (100dvh)', level: 'warning' },
|
|
298
342
|
{ id: 'MD105', name: 'VisualDomSequenceScramble', desc: 'Visual/DOM sequence synchronization (order / flex reverse)', level: 'warning' },
|
|
343
|
+
{ id: 'MD106', name: 'ContainerBoundaryClearance', desc: 'Container boundary clearance and optical padding', level: 'warning' },
|
|
299
344
|
{ id: 'MD201', name: 'EditorialPunctuationHyphen', desc: 'Editorial style punctuation (hyphen vs em-dash)', level: 'note' }
|
|
300
345
|
];
|
|
301
346
|
|
|
@@ -309,7 +354,7 @@ if (format === 'sarif') {
|
|
|
309
354
|
tool: {
|
|
310
355
|
driver: {
|
|
311
356
|
name: 'medesign',
|
|
312
|
-
version:
|
|
357
|
+
version: pkg.version,
|
|
313
358
|
informationUri: 'https://github.com/methastrategy/medesign',
|
|
314
359
|
rules: allRules.map(r => ({
|
|
315
360
|
id: r.id,
|
|
@@ -371,7 +416,7 @@ console.log(`${ANSI_GRAY}──────────────────
|
|
|
371
416
|
console.log(`Target ${path.basename(targetFile)}`);
|
|
372
417
|
console.log(`Preset ${presetName.toUpperCase()}`);
|
|
373
418
|
console.log(`Analysis Static AST & Semantic Rules`);
|
|
374
|
-
console.log(`Ruleset medesign-standard
|
|
419
|
+
console.log(`Ruleset medesign-standard@${pkg.version}\n`);
|
|
375
420
|
|
|
376
421
|
console.log(`${ANSI_BOLD}QUALITY SCORE (Q = ${w.H}H + ${w.I}I + ${w.G}G + ${w.R}R + ${w.V}V)${ANSI_RESET}`);
|
|
377
422
|
console.log(` Hierarchy (H) ${H.toFixed(1)} / 100`);
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ME-DESIGN Visual Regression & Snapshot Engine
|
|
5
|
+
* Headless Chromium Chrome DevTools Protocol (CDP) client over native WebSocket.
|
|
6
|
+
* Zero external npm dependencies.
|
|
7
|
+
*
|
|
8
|
+
* Captures pixel-accurate high-DPI rendered screenshots across viewports:
|
|
9
|
+
* - Mobile (390x844, 2x DPR)
|
|
10
|
+
* - Tablet (820x1180, 2x DPR)
|
|
11
|
+
* - Desktop (1440x900, 2x DPR)
|
|
12
|
+
* - Custom / OG Banner (1200x630)
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* node tests/snapshot.js <file> [--out <dir>] [--og] [--viewports mobile,tablet,desktop]
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const fs = require('fs');
|
|
19
|
+
const path = require('path');
|
|
20
|
+
const { spawn } = require('child_process');
|
|
21
|
+
|
|
22
|
+
const ANSI_RESET = '\x1b[0m';
|
|
23
|
+
const ANSI_BOLD = '\x1b[1m';
|
|
24
|
+
const ANSI_GREEN = '\x1b[32m';
|
|
25
|
+
const ANSI_RED = '\x1b[31m';
|
|
26
|
+
const ANSI_YELLOW = '\x1b[33m';
|
|
27
|
+
const ANSI_CYAN = '\x1b[36m';
|
|
28
|
+
const ANSI_GRAY = '\x1b[90m';
|
|
29
|
+
|
|
30
|
+
const args = process.argv.slice(2);
|
|
31
|
+
let targetFile = null;
|
|
32
|
+
let outDir = null;
|
|
33
|
+
let isOgOnly = false;
|
|
34
|
+
let customViewports = null;
|
|
35
|
+
|
|
36
|
+
for (let i = 0; i < args.length; i++) {
|
|
37
|
+
if (args[i] === '--out' && args[i + 1]) {
|
|
38
|
+
outDir = args[++i];
|
|
39
|
+
} else if (args[i] === '--og') {
|
|
40
|
+
isOgOnly = true;
|
|
41
|
+
} else if (args[i] === '--viewports' && args[i + 1]) {
|
|
42
|
+
customViewports = args[++i].toLowerCase().split(',');
|
|
43
|
+
} else if (!targetFile && !args[i].startsWith('--')) {
|
|
44
|
+
targetFile = args[i];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!targetFile) {
|
|
49
|
+
console.log(`
|
|
50
|
+
${ANSI_BOLD}ME-DESIGN Snapshot Engine${ANSI_RESET}
|
|
51
|
+
${ANSI_GRAY}Capture pixel-accurate rendered snapshots across responsive breakpoints${ANSI_RESET}
|
|
52
|
+
|
|
53
|
+
${ANSI_BOLD}Usage:${ANSI_RESET}
|
|
54
|
+
node tests/snapshot.js <file> [options]
|
|
55
|
+
|
|
56
|
+
${ANSI_BOLD}Options:${ANSI_RESET}
|
|
57
|
+
--out <dir> Output directory for PNG images (default: ./snapshots)
|
|
58
|
+
--og Capture at 1200x630 (OpenGraph / Social Banner)
|
|
59
|
+
--viewports <list> Comma-separated list (mobile,tablet,desktop)
|
|
60
|
+
`);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const resolvedPath = path.resolve(process.cwd(), targetFile);
|
|
65
|
+
if (!fs.existsSync(resolvedPath)) {
|
|
66
|
+
console.error(`${ANSI_RED}Error:${ANSI_RESET} File not found: ${resolvedPath}`);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const targetName = path.basename(resolvedPath, path.extname(resolvedPath));
|
|
71
|
+
const finalOutDir = path.resolve(process.cwd(), outDir || path.join(path.dirname(resolvedPath), 'snapshots'));
|
|
72
|
+
if (!fs.existsSync(finalOutDir)) {
|
|
73
|
+
fs.mkdirSync(finalOutDir, { recursive: true });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function findChromium() {
|
|
77
|
+
const envPath = process.env.CHROME_PATH || process.env.CHROME_BIN;
|
|
78
|
+
if (envPath && fs.existsSync(envPath)) return envPath;
|
|
79
|
+
|
|
80
|
+
const localApp = process.env.LOCALAPPDATA || '';
|
|
81
|
+
const pwDir = path.join(localApp, 'ms-playwright');
|
|
82
|
+
if (fs.existsSync(pwDir)) {
|
|
83
|
+
try {
|
|
84
|
+
const entries = fs.readdirSync(pwDir);
|
|
85
|
+
const chromiumDirs = entries.filter(e => e.startsWith('chromium-')).sort().reverse();
|
|
86
|
+
for (const cDir of chromiumDirs) {
|
|
87
|
+
const p = path.join(pwDir, cDir, 'chrome-win64', 'chrome.exe');
|
|
88
|
+
if (fs.existsSync(p)) return p;
|
|
89
|
+
}
|
|
90
|
+
} catch (e) {}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const programFiles = process.env['ProgramFiles'] || 'C:\\Program Files';
|
|
94
|
+
const programFilesX86 = process.env['ProgramFiles(x86)'] || 'C:\\Program Files (x86)';
|
|
95
|
+
|
|
96
|
+
const alternatives = [
|
|
97
|
+
path.join(programFiles, 'Google', 'Chrome', 'Application', 'chrome.exe'),
|
|
98
|
+
path.join(programFilesX86, 'Google', 'Chrome', 'Application', 'chrome.exe'),
|
|
99
|
+
path.join(programFiles, 'Microsoft', 'Edge', 'Application', 'msedge.exe'),
|
|
100
|
+
path.join(programFilesX86, 'Microsoft', 'Edge', 'Application', 'msedge.exe'),
|
|
101
|
+
'/usr/bin/google-chrome',
|
|
102
|
+
'/usr/bin/google-chrome-stable',
|
|
103
|
+
'/usr/bin/chromium',
|
|
104
|
+
'/usr/bin/chromium-browser',
|
|
105
|
+
'/snap/bin/chromium',
|
|
106
|
+
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
|
107
|
+
'/Applications/Chromium.app/Contents/MacOS/Chromium'
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
for (const p of alternatives) {
|
|
111
|
+
if (fs.existsSync(p)) return p;
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const chromePath = findChromium();
|
|
117
|
+
if (!chromePath) {
|
|
118
|
+
console.error(`${ANSI_RED}Error:${ANSI_RESET} Chromium/Chrome binary not found on system.`);
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
class CDPClient {
|
|
123
|
+
constructor(port) {
|
|
124
|
+
this.port = port;
|
|
125
|
+
this.ws = null;
|
|
126
|
+
this.msgId = 0;
|
|
127
|
+
this.callbacks = new Map();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async connect() {
|
|
131
|
+
for (let i = 0; i < 30; i++) {
|
|
132
|
+
try {
|
|
133
|
+
const r = await fetch(`http://127.0.0.1:${this.port}/json/version`);
|
|
134
|
+
if (r.ok) break;
|
|
135
|
+
} catch (e) {}
|
|
136
|
+
await new Promise(res => setTimeout(res, 100));
|
|
137
|
+
}
|
|
138
|
+
const res = await fetch(`http://127.0.0.1:${this.port}/json/new`, { method: 'PUT' });
|
|
139
|
+
const target = await res.json();
|
|
140
|
+
this.targetId = target.id;
|
|
141
|
+
this.ws = new WebSocket(target.webSocketDebuggerUrl);
|
|
142
|
+
|
|
143
|
+
await new Promise((resolve, reject) => {
|
|
144
|
+
this.ws.onopen = resolve;
|
|
145
|
+
this.ws.onerror = reject;
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
this.ws.onmessage = (event) => {
|
|
149
|
+
const msg = JSON.parse(event.data);
|
|
150
|
+
if (msg.id && this.callbacks.has(msg.id)) {
|
|
151
|
+
const { resolve, reject } = this.callbacks.get(msg.id);
|
|
152
|
+
this.callbacks.delete(msg.id);
|
|
153
|
+
if (msg.error) reject(msg.error);
|
|
154
|
+
else resolve(msg.result);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
send(method, params = {}) {
|
|
160
|
+
return new Promise((resolve, reject) => {
|
|
161
|
+
const id = ++this.msgId;
|
|
162
|
+
this.callbacks.set(id, { resolve, reject });
|
|
163
|
+
this.ws.send(JSON.stringify({ id, method, params }));
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async close() {
|
|
168
|
+
if (this.ws) {
|
|
169
|
+
try { this.ws.close(); } catch (e) {}
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
await fetch(`http://127.0.0.1:${this.port}/json/close/${this.targetId}`, { method: 'PUT' });
|
|
173
|
+
} catch (e) {}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
async function captureSnapshots() {
|
|
178
|
+
const cdpPort = 9555 + Math.floor(Math.random() * 200);
|
|
179
|
+
const chromeProcess = spawn(chromePath, [
|
|
180
|
+
'--headless=new',
|
|
181
|
+
`--remote-debugging-port=${cdpPort}`,
|
|
182
|
+
'--no-first-run',
|
|
183
|
+
'--disable-gpu',
|
|
184
|
+
'--no-sandbox',
|
|
185
|
+
'--disable-extensions',
|
|
186
|
+
'--mute-audio',
|
|
187
|
+
'--hide-scrollbars'
|
|
188
|
+
]);
|
|
189
|
+
|
|
190
|
+
const allPresets = isOgOnly
|
|
191
|
+
? [{ name: 'og-banner', width: 1200, height: 630, dpr: 2, isMobile: false }]
|
|
192
|
+
: [
|
|
193
|
+
{ name: 'mobile', width: 390, height: 844, dpr: 2, isMobile: true },
|
|
194
|
+
{ name: 'tablet', width: 820, height: 1180, dpr: 2, isMobile: true },
|
|
195
|
+
{ name: 'desktop', width: 1440, height: 900, dpr: 2, isMobile: false }
|
|
196
|
+
];
|
|
197
|
+
|
|
198
|
+
const viewports = customViewports
|
|
199
|
+
? allPresets.filter(p => customViewports.includes(p.name))
|
|
200
|
+
: allPresets;
|
|
201
|
+
|
|
202
|
+
const fileUrl = 'file:///' + resolvedPath.replace(/\\/g, '/');
|
|
203
|
+
const captured = [];
|
|
204
|
+
|
|
205
|
+
console.log(`\n${ANSI_BOLD}ME-DESIGN Snapshot Engine${ANSI_RESET}`);
|
|
206
|
+
console.log(`${ANSI_CYAN}Renderer: Headless Chromium CDP (${path.basename(chromePath)})${ANSI_RESET}`);
|
|
207
|
+
console.log(`${ANSI_GRAY}────────────────────────────────────────────────────────────────────────${ANSI_RESET}`);
|
|
208
|
+
console.log(`Target: ${ANSI_BOLD}${path.basename(resolvedPath)}${ANSI_RESET}`);
|
|
209
|
+
console.log(`Output: ${ANSI_GRAY}${finalOutDir}${ANSI_RESET}\n`);
|
|
210
|
+
|
|
211
|
+
try {
|
|
212
|
+
const client = new CDPClient(cdpPort);
|
|
213
|
+
await client.connect();
|
|
214
|
+
await client.send('Page.enable');
|
|
215
|
+
await client.send('DOM.enable');
|
|
216
|
+
|
|
217
|
+
for (const vp of viewports) {
|
|
218
|
+
await client.send('Emulation.setDeviceMetricsOverride', {
|
|
219
|
+
width: vp.width,
|
|
220
|
+
height: vp.height,
|
|
221
|
+
deviceScaleFactor: vp.dpr,
|
|
222
|
+
mobile: vp.isMobile
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
await client.send('Page.navigate', { url: fileUrl });
|
|
226
|
+
await new Promise(r => setTimeout(r, 450)); // Allow CSS rendering & Chart.js animations to complete
|
|
227
|
+
|
|
228
|
+
const snap = await client.send('Page.captureScreenshot', {
|
|
229
|
+
format: 'png',
|
|
230
|
+
captureBeyondViewport: false
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
const fileName = `${targetName}-${vp.name}-${vp.width}x${vp.height}.png`;
|
|
234
|
+
const filePath = path.join(finalOutDir, fileName);
|
|
235
|
+
const buf = Buffer.from(snap.data, 'base64');
|
|
236
|
+
fs.writeFileSync(filePath, buf);
|
|
237
|
+
|
|
238
|
+
captured.push({
|
|
239
|
+
name: vp.name,
|
|
240
|
+
dimensions: `${vp.width}x${vp.height} @${vp.dpr}x`,
|
|
241
|
+
size: `${Math.round(buf.length / 1024)} KB`,
|
|
242
|
+
file: fileName
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
await client.close();
|
|
247
|
+
} finally {
|
|
248
|
+
chromeProcess.kill();
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
console.log(`${'VIEWPORT'.padEnd(12)} | ${'DIMENSIONS'.padEnd(18)} | ${'FILE SIZE'.padEnd(12)} | ${'ARTIFACT'}`);
|
|
252
|
+
console.log(`${ANSI_GRAY}------------------------------------------------------------------------${ANSI_RESET}`);
|
|
253
|
+
captured.forEach(c => {
|
|
254
|
+
console.log(`${ANSI_GREEN}${c.name.padEnd(12)}${ANSI_RESET} | ${c.dimensions.padEnd(18)} | ${c.size.padEnd(12)} | ${ANSI_BOLD}${c.file}${ANSI_RESET}`);
|
|
255
|
+
});
|
|
256
|
+
console.log(`${ANSI_GRAY}────────────────────────────────────────────────────────────────────────${ANSI_RESET}`);
|
|
257
|
+
console.log(`${ANSI_GREEN}SUCCESS:${ANSI_RESET} ${captured.length} snapshots saved to ${finalOutDir}\n`);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
captureSnapshots().catch(err => {
|
|
261
|
+
console.error(`${ANSI_RED}Snapshot Failed:${ANSI_RESET}`, err);
|
|
262
|
+
process.exit(1);
|
|
263
|
+
});
|