@mizchi/vlmkit-capture 0.7.0 → 0.8.1
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/dist/batch-prescan.d.mts +51 -0
- package/dist/batch-prescan.mjs +66 -0
- package/dist/capture-config.d.mts +50 -0
- package/dist/capture-config.mjs +164 -0
- package/dist/capturer.d.mts +45 -0
- package/dist/capturer.mjs +94 -0
- package/dist/cloudflare-quick-actions.d.mts +114 -0
- package/dist/cloudflare-quick-actions.mjs +142 -0
- package/dist/crater-client.d.mts +159 -0
- package/dist/crater-client.mjs +362 -0
- package/dist/crater-smoke.d.mts +98 -0
- package/dist/crater-smoke.mjs +269 -0
- package/dist/crater-wasm.d.mts +65 -0
- package/dist/crater-wasm.mjs +132 -0
- package/{src/detection-types.ts → dist/detection-types.d.mts} +4 -2
- package/dist/detection-types.mjs +1 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.mjs +11 -0
- package/dist/playwright-analyzer.d.mts +38 -0
- package/dist/playwright-analyzer.mjs +117 -0
- package/dist/playwright-launch-error.d.mts +7 -0
- package/dist/playwright-launch-error.mjs +25 -0
- package/dist/prescanner.d.mts +39 -0
- package/dist/prescanner.mjs +61 -0
- package/dist/viewport-discovery.d.mts +114 -0
- package/dist/viewport-discovery.mjs +294 -0
- package/package.json +18 -6
- package/src/batch-prescan.ts +0 -115
- package/src/capture-config.ts +0 -219
- package/src/capturer.ts +0 -138
- package/src/cloudflare-quick-actions.ts +0 -304
- package/src/crater-client.ts +0 -537
- package/src/crater-smoke.ts +0 -336
- package/src/crater-wasm.ts +0 -260
- package/src/index.ts +0 -157
- package/src/playwright-analyzer.ts +0 -180
- package/src/playwright-launch-error.ts +0 -41
- package/src/prescanner.ts +0 -123
- package/src/viewport-discovery.ts +0 -455
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
//#region src/crater-smoke.d.ts
|
|
2
|
+
interface CraterSmokeClient {
|
|
3
|
+
connect(): Promise<void>;
|
|
4
|
+
close(): Promise<void>;
|
|
5
|
+
setViewport(width: number, height: number): Promise<void>;
|
|
6
|
+
setContent(html: string): Promise<void>;
|
|
7
|
+
capturePng(): Promise<{
|
|
8
|
+
png: Buffer;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}>;
|
|
12
|
+
capturePaintTree(): Promise<unknown>;
|
|
13
|
+
captureComputedStyles?(properties: string[]): Promise<Map<string, Record<string, string>>>;
|
|
14
|
+
getResponsiveBreakpoints?(options?: {
|
|
15
|
+
mode?: "live-inline" | "html-inline";
|
|
16
|
+
axis?: "width";
|
|
17
|
+
includeDiagnostics?: boolean;
|
|
18
|
+
}): Promise<{
|
|
19
|
+
breakpoints: unknown[];
|
|
20
|
+
}>;
|
|
21
|
+
getRequiredTestViewports?(): Promise<{
|
|
22
|
+
viewports: Array<{
|
|
23
|
+
width: number;
|
|
24
|
+
reason: string;
|
|
25
|
+
}>;
|
|
26
|
+
}>;
|
|
27
|
+
getCssRuleViewportMap?(viewportWidths?: number[]): Promise<{
|
|
28
|
+
rules: unknown[];
|
|
29
|
+
}>;
|
|
30
|
+
getComputedStylesWithState?(selector: string, forcedStates: string[], properties: string[]): Promise<{
|
|
31
|
+
normal: Record<string, string>;
|
|
32
|
+
forced: Record<string, string>;
|
|
33
|
+
diff: Array<{
|
|
34
|
+
property: string;
|
|
35
|
+
normal: string;
|
|
36
|
+
forced: string;
|
|
37
|
+
}>;
|
|
38
|
+
}>;
|
|
39
|
+
batchRender?(baseHtml: string, viewport: {
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
}, variants: Array<{
|
|
43
|
+
id: string;
|
|
44
|
+
mutations: Array<{
|
|
45
|
+
selector: string;
|
|
46
|
+
property: string;
|
|
47
|
+
action?: "remove" | {
|
|
48
|
+
override: string;
|
|
49
|
+
};
|
|
50
|
+
}>;
|
|
51
|
+
}>): Promise<{
|
|
52
|
+
results: Array<{
|
|
53
|
+
id: string;
|
|
54
|
+
paintTree?: unknown;
|
|
55
|
+
}>;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
type CraterSmokeStatus = "pass" | "skip" | "fail";
|
|
59
|
+
interface CraterSmokeCheck {
|
|
60
|
+
name: string;
|
|
61
|
+
status: CraterSmokeStatus;
|
|
62
|
+
elapsedMs: number;
|
|
63
|
+
message: string;
|
|
64
|
+
}
|
|
65
|
+
interface CraterSmokeReport {
|
|
66
|
+
status: CraterSmokeStatus;
|
|
67
|
+
url: string;
|
|
68
|
+
checks: CraterSmokeCheck[];
|
|
69
|
+
elapsedMs: number;
|
|
70
|
+
}
|
|
71
|
+
interface CraterSmokeOptions {
|
|
72
|
+
url?: string;
|
|
73
|
+
html?: string;
|
|
74
|
+
viewport?: {
|
|
75
|
+
width: number;
|
|
76
|
+
height: number;
|
|
77
|
+
};
|
|
78
|
+
requireAvailable?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* When true, also exercises rendering-heavy v0.18.0 APIs (batchRender).
|
|
81
|
+
* Metadata-only v0.18.0 checks (`getRequiredTestViewports`,
|
|
82
|
+
* `getCssRuleViewportMap`, `getComputedStylesWithState`) always run when the
|
|
83
|
+
* client exposes them — they are cheap RPC round-trips.
|
|
84
|
+
*/
|
|
85
|
+
deep?: boolean;
|
|
86
|
+
isAvailable?: (url: string) => Promise<boolean>;
|
|
87
|
+
createClient?: (url: string) => CraterSmokeClient;
|
|
88
|
+
}
|
|
89
|
+
declare function runCraterBidiSmoke(options?: CraterSmokeOptions): Promise<CraterSmokeReport>;
|
|
90
|
+
declare function formatCraterSmokeReport(report: CraterSmokeReport): string;
|
|
91
|
+
declare function parseCraterSmokeArgs(argv: string[], env?: NodeJS.ProcessEnv | Partial<NodeJS.ProcessEnv>): {
|
|
92
|
+
url: string;
|
|
93
|
+
requireAvailable: boolean;
|
|
94
|
+
deep: boolean;
|
|
95
|
+
json: boolean;
|
|
96
|
+
};
|
|
97
|
+
//#endregion
|
|
98
|
+
export { CraterSmokeCheck, CraterSmokeClient, CraterSmokeOptions, CraterSmokeReport, CraterSmokeStatus, formatCraterSmokeReport, parseCraterSmokeArgs, runCraterBidiSmoke };
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { CraterClient, isCraterAvailable, resolveCraterBidiUrl } from "./crater-client.mjs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { handleCliError } from "@mizchi/vlmkit-core/cli-error.ts";
|
|
6
|
+
import { BOLD, CYAN, DIM, GREEN, RED, RESET, YELLOW } from "@mizchi/vlmkit-core/terminal-colors.ts";
|
|
7
|
+
//#region src/crater-smoke.ts
|
|
8
|
+
/**
|
|
9
|
+
* Crater BiDi smoke check.
|
|
10
|
+
*
|
|
11
|
+
* Verifies the minimum backend contract used by vlmkit:
|
|
12
|
+
* connection, viewport/content load, PNG capture, paint tree capture,
|
|
13
|
+
* computed-style capture, and responsive breakpoint discovery.
|
|
14
|
+
*/
|
|
15
|
+
const DEFAULT_HTML = `<!doctype html>
|
|
16
|
+
<html>
|
|
17
|
+
<head>
|
|
18
|
+
<style>
|
|
19
|
+
body { margin: 0; font-family: system-ui; }
|
|
20
|
+
main { display: grid; grid-template-columns: 1fr auto; gap: 16px; padding: 24px; }
|
|
21
|
+
button { padding: 10px 14px; border-radius: 8px; background: #2563eb; color: white; border: 0; }
|
|
22
|
+
button:hover { background: #1d4ed8; text-decoration: underline; }
|
|
23
|
+
@media (min-width: 700px) { main { max-width: 680px; } }
|
|
24
|
+
</style>
|
|
25
|
+
</head>
|
|
26
|
+
<body>
|
|
27
|
+
<main><h1>Crater smoke</h1><button>OK</button></main>
|
|
28
|
+
</body>
|
|
29
|
+
</html>`;
|
|
30
|
+
function now() {
|
|
31
|
+
return Date.now();
|
|
32
|
+
}
|
|
33
|
+
function makeCheck(name, status, start, message) {
|
|
34
|
+
return {
|
|
35
|
+
name,
|
|
36
|
+
status,
|
|
37
|
+
elapsedMs: now() - start,
|
|
38
|
+
message
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function reportStatus(checks) {
|
|
42
|
+
if (checks.some((check) => check.status === "fail")) return "fail";
|
|
43
|
+
if (checks.some((check) => check.status === "skip")) return "skip";
|
|
44
|
+
return "pass";
|
|
45
|
+
}
|
|
46
|
+
function assertPaintTree(tree) {
|
|
47
|
+
if (!tree || typeof tree !== "object") throw new Error("paint tree is empty");
|
|
48
|
+
}
|
|
49
|
+
async function runCraterBidiSmoke(options = {}) {
|
|
50
|
+
const url = options.url ?? "ws://127.0.0.1:9222";
|
|
51
|
+
const requireAvailable = options.requireAvailable ?? false;
|
|
52
|
+
const start = now();
|
|
53
|
+
const checks = [];
|
|
54
|
+
if (!await (options.isAvailable ?? isCraterAvailable)(url)) {
|
|
55
|
+
checks.push(makeCheck("availability", requireAvailable ? "fail" : "skip", start, `Crater BiDi is not available at ${url}`));
|
|
56
|
+
return {
|
|
57
|
+
status: reportStatus(checks),
|
|
58
|
+
url,
|
|
59
|
+
checks,
|
|
60
|
+
elapsedMs: now() - start
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const client = (options.createClient ?? ((u) => new CraterClient(u)))(url);
|
|
64
|
+
let connected = false;
|
|
65
|
+
async function runCheck(name, fn) {
|
|
66
|
+
const checkStart = now();
|
|
67
|
+
try {
|
|
68
|
+
const message = await fn();
|
|
69
|
+
checks.push(makeCheck(name, "pass", checkStart, message));
|
|
70
|
+
return true;
|
|
71
|
+
} catch (error) {
|
|
72
|
+
checks.push(makeCheck(name, "fail", checkStart, String(error)));
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
connected = await runCheck("connect", async () => {
|
|
78
|
+
await client.connect();
|
|
79
|
+
return "connected";
|
|
80
|
+
});
|
|
81
|
+
if (!connected) return {
|
|
82
|
+
status: "fail",
|
|
83
|
+
url,
|
|
84
|
+
checks,
|
|
85
|
+
elapsedMs: now() - start
|
|
86
|
+
};
|
|
87
|
+
const viewport = options.viewport ?? {
|
|
88
|
+
width: 800,
|
|
89
|
+
height: 480
|
|
90
|
+
};
|
|
91
|
+
if (!await runCheck("load", async () => {
|
|
92
|
+
await client.setViewport(viewport.width, viewport.height);
|
|
93
|
+
await client.setContent(options.html ?? DEFAULT_HTML);
|
|
94
|
+
return `loaded ${viewport.width}x${viewport.height}`;
|
|
95
|
+
})) return {
|
|
96
|
+
status: "fail",
|
|
97
|
+
url,
|
|
98
|
+
checks,
|
|
99
|
+
elapsedMs: now() - start
|
|
100
|
+
};
|
|
101
|
+
if (!await runCheck("capture-png", async () => {
|
|
102
|
+
const result = await client.capturePng();
|
|
103
|
+
if (result.width <= 0 || result.height <= 0 || result.png.length === 0) throw new Error("PNG capture returned empty data");
|
|
104
|
+
return `captured ${result.width}x${result.height}, ${result.png.length} bytes`;
|
|
105
|
+
})) return {
|
|
106
|
+
status: "fail",
|
|
107
|
+
url,
|
|
108
|
+
checks,
|
|
109
|
+
elapsedMs: now() - start
|
|
110
|
+
};
|
|
111
|
+
if (!await runCheck("paint-tree", async () => {
|
|
112
|
+
assertPaintTree(await client.capturePaintTree());
|
|
113
|
+
return "paint tree captured";
|
|
114
|
+
})) return {
|
|
115
|
+
status: "fail",
|
|
116
|
+
url,
|
|
117
|
+
checks,
|
|
118
|
+
elapsedMs: now() - start
|
|
119
|
+
};
|
|
120
|
+
if (client.captureComputedStyles) {
|
|
121
|
+
if (!await runCheck("computed-styles", async () => {
|
|
122
|
+
return `computed styles captured (${(await client.captureComputedStyles([
|
|
123
|
+
"display",
|
|
124
|
+
"color",
|
|
125
|
+
"background-color"
|
|
126
|
+
])).size} selector(s))`;
|
|
127
|
+
})) return {
|
|
128
|
+
status: "fail",
|
|
129
|
+
url,
|
|
130
|
+
checks,
|
|
131
|
+
elapsedMs: now() - start
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
if (client.getResponsiveBreakpoints) {
|
|
135
|
+
if (!await runCheck("responsive-breakpoints", async () => {
|
|
136
|
+
return `breakpoint API returned ${(await client.getResponsiveBreakpoints({
|
|
137
|
+
mode: "live-inline",
|
|
138
|
+
axis: "width",
|
|
139
|
+
includeDiagnostics: true
|
|
140
|
+
})).breakpoints.length} breakpoint(s)`;
|
|
141
|
+
})) return {
|
|
142
|
+
status: "fail",
|
|
143
|
+
url,
|
|
144
|
+
checks,
|
|
145
|
+
elapsedMs: now() - start
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
if (client.getRequiredTestViewports) {
|
|
149
|
+
if (!await runCheck("required-test-viewports", async () => {
|
|
150
|
+
return `viewport intelligence returned ${(await client.getRequiredTestViewports()).viewports.length} viewport(s)`;
|
|
151
|
+
})) return {
|
|
152
|
+
status: "fail",
|
|
153
|
+
url,
|
|
154
|
+
checks,
|
|
155
|
+
elapsedMs: now() - start
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (client.getCssRuleViewportMap) {
|
|
159
|
+
if (!await runCheck("css-rule-viewport-map", async () => {
|
|
160
|
+
return `rule/viewport map returned ${(await client.getCssRuleViewportMap()).rules.length} rule(s)`;
|
|
161
|
+
})) return {
|
|
162
|
+
status: "fail",
|
|
163
|
+
url,
|
|
164
|
+
checks,
|
|
165
|
+
elapsedMs: now() - start
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
if (client.getComputedStylesWithState) {
|
|
169
|
+
if (!await runCheck("computed-styles-with-state", async () => {
|
|
170
|
+
return `forced-state API returned ${(await client.getComputedStylesWithState("button", ["hover"], ["background-color", "text-decoration"])).diff?.length ?? 0} diff(s)`;
|
|
171
|
+
})) return {
|
|
172
|
+
status: "fail",
|
|
173
|
+
url,
|
|
174
|
+
checks,
|
|
175
|
+
elapsedMs: now() - start
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
if (options.deep && client.batchRender) {
|
|
179
|
+
if (!await runCheck("batch-render", async () => {
|
|
180
|
+
return `batch render returned ${(await client.batchRender(options.html ?? DEFAULT_HTML, options.viewport ?? viewport, [{
|
|
181
|
+
id: "no-op",
|
|
182
|
+
mutations: [{
|
|
183
|
+
selector: "button",
|
|
184
|
+
property: "color",
|
|
185
|
+
action: { override: "white" }
|
|
186
|
+
}]
|
|
187
|
+
}])).results.length} variant(s)`;
|
|
188
|
+
})) return {
|
|
189
|
+
status: "fail",
|
|
190
|
+
url,
|
|
191
|
+
checks,
|
|
192
|
+
elapsedMs: now() - start
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
} finally {
|
|
196
|
+
if (connected) {
|
|
197
|
+
const closeStart = now();
|
|
198
|
+
try {
|
|
199
|
+
await client.close();
|
|
200
|
+
checks.push(makeCheck("close", "pass", closeStart, "closed"));
|
|
201
|
+
} catch (error) {
|
|
202
|
+
checks.push(makeCheck("close", "fail", closeStart, String(error)));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
status: reportStatus(checks),
|
|
208
|
+
url,
|
|
209
|
+
checks,
|
|
210
|
+
elapsedMs: now() - start
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function formatCraterSmokeReport(report) {
|
|
214
|
+
const lines = [];
|
|
215
|
+
const color = report.status === "pass" ? GREEN : report.status === "skip" ? YELLOW : RED;
|
|
216
|
+
lines.push(`${BOLD}${CYAN}vlmkit check crater${RESET}`);
|
|
217
|
+
lines.push(`${DIM}url: ${report.url}${RESET}`);
|
|
218
|
+
lines.push("");
|
|
219
|
+
lines.push(`status: ${color}${report.status}${RESET}`);
|
|
220
|
+
for (const check of report.checks) {
|
|
221
|
+
const icon = check.status === "pass" ? `${GREEN}PASS${RESET}` : check.status === "skip" ? `${YELLOW}SKIP${RESET}` : `${RED}FAIL${RESET}`;
|
|
222
|
+
lines.push(` ${icon} ${check.name.padEnd(22)} ${String(check.elapsedMs).padStart(5)}ms ${DIM}${check.message}${RESET}`);
|
|
223
|
+
}
|
|
224
|
+
lines.push(`${DIM}elapsed: ${report.elapsedMs}ms${RESET}`);
|
|
225
|
+
return lines.join("\n");
|
|
226
|
+
}
|
|
227
|
+
function printUsage(exitCode) {
|
|
228
|
+
console.log("Usage: vlmkit check crater [options]");
|
|
229
|
+
console.log("Options:");
|
|
230
|
+
console.log(" --url <ws-url> Crater BiDi URL (default: ws://127.0.0.1:9222)");
|
|
231
|
+
console.log(" --require Fail if Crater is unavailable");
|
|
232
|
+
console.log(" --deep Exercise heavier v0.18.0 APIs (batchRender)");
|
|
233
|
+
console.log(" --json Print JSON report");
|
|
234
|
+
process.exit(exitCode);
|
|
235
|
+
}
|
|
236
|
+
function parseCraterSmokeArgs(argv, env = process.env) {
|
|
237
|
+
let url = resolveCraterBidiUrl({ env });
|
|
238
|
+
let requireAvailable = false;
|
|
239
|
+
let deep = false;
|
|
240
|
+
let json = false;
|
|
241
|
+
for (let i = 0; i < argv.length; i++) {
|
|
242
|
+
const arg = argv[i];
|
|
243
|
+
if (arg === "--help" || arg === "-h" || arg === "help") printUsage(0);
|
|
244
|
+
else if (arg === "--url") url = argv[++i] ?? "ws://127.0.0.1:9222";
|
|
245
|
+
else if (arg === "--require") requireAvailable = true;
|
|
246
|
+
else if (arg === "--deep") deep = true;
|
|
247
|
+
else if (arg === "--json") json = true;
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
url,
|
|
251
|
+
requireAvailable,
|
|
252
|
+
deep,
|
|
253
|
+
json
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
async function main(argv = process.argv.slice(2)) {
|
|
257
|
+
const args = parseCraterSmokeArgs(argv);
|
|
258
|
+
const report = await runCraterBidiSmoke({
|
|
259
|
+
url: args.url,
|
|
260
|
+
requireAvailable: args.requireAvailable,
|
|
261
|
+
deep: args.deep
|
|
262
|
+
});
|
|
263
|
+
if (args.json) console.log(JSON.stringify(report, null, 2));
|
|
264
|
+
else console.log(formatCraterSmokeReport(report));
|
|
265
|
+
if (report.status === "fail" || args.requireAvailable && report.status === "skip") process.exit(1);
|
|
266
|
+
}
|
|
267
|
+
if (process.env.__VRT_DISPATCHER_LEAF__ === "crater-smoke" || (process.argv[1] ? resolve(process.argv[1]) === fileURLToPath(import.meta.url) : false)) main().catch(handleCliError);
|
|
268
|
+
//#endregion
|
|
269
|
+
export { formatCraterSmokeReport, parseCraterSmokeArgs, runCraterBidiSmoke };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//#region src/crater-wasm.d.ts
|
|
2
|
+
declare const CRATER_WASM_MODULE_ENV = "VLMKIT_CRATER_WASM_MODULE";
|
|
3
|
+
interface CraterWasmViewport {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
label?: string;
|
|
7
|
+
}
|
|
8
|
+
interface CraterBoxRect {
|
|
9
|
+
top: number;
|
|
10
|
+
right: number;
|
|
11
|
+
bottom: number;
|
|
12
|
+
left: number;
|
|
13
|
+
}
|
|
14
|
+
interface CraterLayoutNode {
|
|
15
|
+
id: string;
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
margin: CraterBoxRect;
|
|
21
|
+
padding: CraterBoxRect;
|
|
22
|
+
border: CraterBoxRect;
|
|
23
|
+
children: CraterLayoutNode[];
|
|
24
|
+
}
|
|
25
|
+
interface CraterLayoutRootBox {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
}
|
|
31
|
+
interface CraterLayoutDiagnostics {
|
|
32
|
+
nodeCount: number;
|
|
33
|
+
maxDepth: number;
|
|
34
|
+
rootBox: CraterLayoutRootBox;
|
|
35
|
+
}
|
|
36
|
+
interface CraterWasmRenderRequest {
|
|
37
|
+
html: string;
|
|
38
|
+
viewport: CraterWasmViewport;
|
|
39
|
+
}
|
|
40
|
+
interface CraterWasmRenderResult {
|
|
41
|
+
backend: "crater-wasm";
|
|
42
|
+
viewport: CraterWasmViewport;
|
|
43
|
+
layout: CraterLayoutNode;
|
|
44
|
+
rawJson: string;
|
|
45
|
+
elapsedMs: number;
|
|
46
|
+
diagnostics: CraterLayoutDiagnostics;
|
|
47
|
+
}
|
|
48
|
+
interface CraterWasmModule {
|
|
49
|
+
renderHtmlToJsonForWpt(html: string, width: number, height: number): string | Promise<string>;
|
|
50
|
+
}
|
|
51
|
+
interface CraterWasmLayoutBackend {
|
|
52
|
+
kind: "crater-wasm-layout";
|
|
53
|
+
renderLayout(request: CraterWasmRenderRequest): Promise<CraterWasmRenderResult>;
|
|
54
|
+
}
|
|
55
|
+
interface LoadCraterWasmModuleOptions {
|
|
56
|
+
modulePath?: string;
|
|
57
|
+
env?: Partial<Record<typeof CRATER_WASM_MODULE_ENV | "CRATER_WASM_MODULE", string | undefined>>;
|
|
58
|
+
cwd?: string;
|
|
59
|
+
}
|
|
60
|
+
declare function createCraterWasmLayoutBackend(module: CraterWasmModule): CraterWasmLayoutBackend;
|
|
61
|
+
declare function loadCraterWasmModule(options?: LoadCraterWasmModuleOptions): Promise<CraterWasmModule>;
|
|
62
|
+
declare function normalizeCraterLayoutJson(raw: string | unknown): CraterLayoutNode;
|
|
63
|
+
declare function summarizeCraterLayout(layout: CraterLayoutNode): CraterLayoutDiagnostics;
|
|
64
|
+
//#endregion
|
|
65
|
+
export { CRATER_WASM_MODULE_ENV, CraterBoxRect, CraterLayoutDiagnostics, CraterLayoutNode, CraterLayoutRootBox, CraterWasmLayoutBackend, CraterWasmModule, CraterWasmRenderRequest, CraterWasmRenderResult, CraterWasmViewport, LoadCraterWasmModuleOptions, createCraterWasmLayoutBackend, loadCraterWasmModule, normalizeCraterLayoutJson, summarizeCraterLayout };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
//#region src/crater-wasm.ts
|
|
4
|
+
const CRATER_WASM_MODULE_ENV = "VLMKIT_CRATER_WASM_MODULE";
|
|
5
|
+
function createCraterWasmLayoutBackend(module) {
|
|
6
|
+
assertCraterWasmModule(module);
|
|
7
|
+
return {
|
|
8
|
+
kind: "crater-wasm-layout",
|
|
9
|
+
async renderLayout(request) {
|
|
10
|
+
if (typeof request.html !== "string") throw new Error("Crater WASM render request requires html");
|
|
11
|
+
const viewport = normalizeViewport(request.viewport);
|
|
12
|
+
const started = Date.now();
|
|
13
|
+
const rawJson = await module.renderHtmlToJsonForWpt(request.html, viewport.width, viewport.height);
|
|
14
|
+
if (typeof rawJson !== "string") throw new Error("Crater WASM renderHtmlToJsonForWpt must return a JSON string");
|
|
15
|
+
const layout = normalizeCraterLayoutJson(rawJson);
|
|
16
|
+
return {
|
|
17
|
+
backend: "crater-wasm",
|
|
18
|
+
viewport,
|
|
19
|
+
layout,
|
|
20
|
+
rawJson,
|
|
21
|
+
elapsedMs: Date.now() - started,
|
|
22
|
+
diagnostics: summarizeCraterLayout(layout)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
async function loadCraterWasmModule(options = {}) {
|
|
28
|
+
const modulePath = options.modulePath ?? options.env?.["VLMKIT_CRATER_WASM_MODULE"] ?? options.env?.CRATER_WASM_MODULE;
|
|
29
|
+
if (!modulePath) throw new Error(`${CRATER_WASM_MODULE_ENV} is required to load the Crater WASM backend`);
|
|
30
|
+
return assertCraterWasmModule(await import(toImportSpecifier(modulePath, options.cwd)));
|
|
31
|
+
}
|
|
32
|
+
function normalizeCraterLayoutJson(raw) {
|
|
33
|
+
return normalizeCraterLayoutNode(typeof raw === "string" ? parseLayoutJson(raw) : raw, "$");
|
|
34
|
+
}
|
|
35
|
+
function summarizeCraterLayout(layout) {
|
|
36
|
+
let nodeCount = 0;
|
|
37
|
+
let maxDepth = 0;
|
|
38
|
+
function visit(node, depth) {
|
|
39
|
+
nodeCount += 1;
|
|
40
|
+
maxDepth = Math.max(maxDepth, depth);
|
|
41
|
+
for (const child of node.children) visit(child, depth + 1);
|
|
42
|
+
}
|
|
43
|
+
visit(layout, 1);
|
|
44
|
+
return {
|
|
45
|
+
nodeCount,
|
|
46
|
+
maxDepth,
|
|
47
|
+
rootBox: {
|
|
48
|
+
x: layout.x,
|
|
49
|
+
y: layout.y,
|
|
50
|
+
width: layout.width,
|
|
51
|
+
height: layout.height
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function parseLayoutJson(raw) {
|
|
56
|
+
try {
|
|
57
|
+
return JSON.parse(raw);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
throw new Error(`Invalid Crater layout JSON: ${errorMessage(error)}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function normalizeCraterLayoutNode(value, path) {
|
|
63
|
+
const record = asRecord(value, path);
|
|
64
|
+
const children = record.children;
|
|
65
|
+
if (!Array.isArray(children)) throw new Error(`${path} missing children array`);
|
|
66
|
+
return {
|
|
67
|
+
id: readString(record, "id", path),
|
|
68
|
+
x: readNumber(record, "x", path),
|
|
69
|
+
y: readNumber(record, "y", path),
|
|
70
|
+
width: readNumber(record, "width", path),
|
|
71
|
+
height: readNumber(record, "height", path),
|
|
72
|
+
margin: normalizeBoxRect(record.margin, `${path}.margin`),
|
|
73
|
+
padding: normalizeBoxRect(record.padding, `${path}.padding`),
|
|
74
|
+
border: normalizeBoxRect(record.border, `${path}.border`),
|
|
75
|
+
children: children.map((child, index) => normalizeCraterLayoutNode(child, `${path}.children[${index}]`))
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function normalizeBoxRect(value, path) {
|
|
79
|
+
const record = asRecord(value, path);
|
|
80
|
+
return {
|
|
81
|
+
top: readNumber(record, "top", path),
|
|
82
|
+
right: readNumber(record, "right", path),
|
|
83
|
+
bottom: readNumber(record, "bottom", path),
|
|
84
|
+
left: readNumber(record, "left", path)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function normalizeViewport(viewport) {
|
|
88
|
+
if (!viewport || typeof viewport !== "object") throw new Error("Crater WASM render request requires viewport");
|
|
89
|
+
const width = Number(viewport.width);
|
|
90
|
+
const height = Number(viewport.height);
|
|
91
|
+
if (!Number.isFinite(width) || width <= 0) throw new Error("Crater WASM viewport.width must be a positive number");
|
|
92
|
+
if (!Number.isFinite(height) || height <= 0) throw new Error("Crater WASM viewport.height must be a positive number");
|
|
93
|
+
return {
|
|
94
|
+
width,
|
|
95
|
+
height,
|
|
96
|
+
...typeof viewport.label === "string" ? { label: viewport.label } : {}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function readString(record, key, path) {
|
|
100
|
+
const value = record[key];
|
|
101
|
+
if (typeof value !== "string") throw new Error(`${path} missing string ${key}`);
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
104
|
+
function readNumber(record, key, path) {
|
|
105
|
+
const value = record[key];
|
|
106
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new Error(`${path} missing numeric ${key}`);
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
109
|
+
function asRecord(value, path) {
|
|
110
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${path} must be an object`);
|
|
111
|
+
return value;
|
|
112
|
+
}
|
|
113
|
+
function assertCraterWasmModule(value) {
|
|
114
|
+
const render = asRecord(value, "Crater WASM module").renderHtmlToJsonForWpt;
|
|
115
|
+
if (typeof render !== "function") throw new Error("Crater WASM module must export renderHtmlToJsonForWpt(html, width, height)");
|
|
116
|
+
return { renderHtmlToJsonForWpt: render };
|
|
117
|
+
}
|
|
118
|
+
function toImportSpecifier(modulePath, cwd = process.cwd()) {
|
|
119
|
+
if (isUrlSpecifier(modulePath) || isBareSpecifier(modulePath)) return modulePath;
|
|
120
|
+
return pathToFileURL(resolve(cwd, modulePath)).href;
|
|
121
|
+
}
|
|
122
|
+
function isUrlSpecifier(value) {
|
|
123
|
+
return /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(value);
|
|
124
|
+
}
|
|
125
|
+
function isBareSpecifier(value) {
|
|
126
|
+
return !value.startsWith(".") && !value.startsWith("/") && !value.startsWith("~");
|
|
127
|
+
}
|
|
128
|
+
function errorMessage(error) {
|
|
129
|
+
return error instanceof Error ? error.message : String(error);
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
export { CRATER_WASM_MODULE_ENV, createCraterWasmLayoutBackend, loadCraterWasmModule, normalizeCraterLayoutJson, summarizeCraterLayout };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
//#region src/detection-types.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Capture-level detection result shared across capture backends
|
|
3
4
|
* (Playwright, Crater BiDi) and downstream detection classifiers.
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
-
export interface ViewportDetectionResult {
|
|
6
|
+
interface ViewportDetectionResult {
|
|
7
7
|
width: number;
|
|
8
8
|
height: number;
|
|
9
9
|
visualDiffDetected: boolean;
|
|
@@ -21,3 +21,5 @@ export interface ViewportDetectionResult {
|
|
|
21
21
|
*/
|
|
22
22
|
visualCaptureSkipped?: boolean;
|
|
23
23
|
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { ViewportDetectionResult };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CRATER_BIDI_URL_ENV, CRATER_ROOT_ENV, CraterBatchRenderResult, CraterBreakpointDiscoveryDiagnostics, CraterBreakpointDiscoveryResult, CraterClient, CraterComputedStyleWithState, CraterCssMutation, CraterCssMutationAction, CraterRenderVariant, CraterResponsiveBreakpoint, CraterRuleViewportMap, CraterRuleViewportMapEntry, DEFAULT_BIDI_URL, PaintNode, PaintProps, VLMKIT_CRATER_BIDI_URL_ENV, VLMKIT_CRATER_ROOT_ENV, diffPaintTrees, isCraterAvailable, resolveCraterBidiUrl } from "./crater-client.mjs";
|
|
2
|
+
import { BatchPrescanOptions, BatchPrescanRequest, BatchPrescanResult, hasAnyBatchPrescanSignal, mutationsForPropertyRemoval, mutationsForSelectorBlockRemoval, runBatchPrescan } from "./batch-prescan.mjs";
|
|
3
|
+
import { CaptureConfig, CaptureRoute, CaptureRouteSet, DEFAULT_CAPTURE_BASE_URL, DEFAULT_CAPTURE_CONFIG_FILE, DEFAULT_CAPTURE_ROUTES, LoadCaptureConfigOptions, captureConfigDir, loadCaptureConfigFromFile, parseCaptureConfig, resolveCaptureRoutes, routeNameFromPath } from "./capture-config.mjs";
|
|
4
|
+
import { CloudflareCrawlRecord, CloudflareCrawlRecordStatus, CloudflareCrawlRequest, CloudflareCrawlResult, CloudflareCrawlRoute, CloudflareCrawlStartResult, CloudflareQuickAction, CloudflareQuickActionEndpointInput, CloudflareQuickActionsConfig, CloudflareQuickActionsEnv, CloudflareScreenshotRequest, CloudflareScreenshotResult, buildCloudflareQuickActionEndpoint, createCloudflareQuickActionsClient, extractCloudflareCrawlRoutes, resolveCloudflareQuickActionsConfig } from "./cloudflare-quick-actions.mjs";
|
|
5
|
+
import { CraterSmokeCheck, CraterSmokeClient, CraterSmokeReport, CraterSmokeStatus, formatCraterSmokeReport, runCraterBidiSmoke } from "./crater-smoke.mjs";
|
|
6
|
+
import { CRATER_WASM_MODULE_ENV, CraterBoxRect, CraterLayoutDiagnostics, CraterLayoutNode, CraterLayoutRootBox, CraterWasmLayoutBackend, CraterWasmModule, CraterWasmRenderRequest, CraterWasmRenderResult, CraterWasmViewport, LoadCraterWasmModuleOptions, createCraterWasmLayoutBackend, loadCraterWasmModule, normalizeCraterLayoutJson, summarizeCraterLayout } from "./crater-wasm.mjs";
|
|
7
|
+
import { ViewportDetectionResult } from "./detection-types.mjs";
|
|
8
|
+
import { Breakpoint, CraterViewportSource, DiscoveryResult, ResponsiveBreakpoint, ViewportOptions, ViewportSource, ViewportSpec, discoverViewports, discoverViewportsViaCrater, discoverViewportsWithBackend, extractBreakpoints, extractBreakpointsFromHtml, extractBreakpointsFromHtmlWithStylesheets, extractResponsiveBreakpointsFromHtml, extractResponsiveBreakpointsFromHtmlWithStylesheets, extractStylesheetHrefsFromHtml, generateViewports, mergeResponsiveBreakpoints, toResponsiveBreakpoints } from "./viewport-discovery.mjs";
|
|
9
|
+
import { formatPlaywrightLaunchError, isPlaywrightSandboxRestrictionError } from "./playwright-launch-error.mjs";
|
|
10
|
+
import { AnalyzedReport, FailedTest, ReportStats, analyzeReport, collectScreenshots, formatStats } from "./playwright-analyzer.mjs";
|
|
11
|
+
import { PrescannerResolvedBy, PrescannerTrialResolution, PrescannerTrialSummary, hasAnyDetectionSignal, hasCraterPrescanSignal, resolvePrescannerTrial, summarizePrescannerTrials } from "./prescanner.mjs";
|
|
12
|
+
export { type AnalyzedReport, type BatchPrescanOptions, type BatchPrescanRequest, type BatchPrescanResult, type Breakpoint, CRATER_BIDI_URL_ENV, CRATER_ROOT_ENV, CRATER_WASM_MODULE_ENV, type CaptureConfig, type CaptureRoute, type CaptureRouteSet, type CloudflareCrawlRecord, type CloudflareCrawlRecordStatus, type CloudflareCrawlRequest, type CloudflareCrawlResult, type CloudflareCrawlRoute, type CloudflareCrawlStartResult, type CloudflareQuickAction, type CloudflareQuickActionEndpointInput, type CloudflareQuickActionsConfig, type CloudflareQuickActionsEnv, type CloudflareScreenshotRequest, type CloudflareScreenshotResult, type CraterBatchRenderResult, type CraterBoxRect, type CraterBreakpointDiscoveryDiagnostics, type CraterBreakpointDiscoveryResult, CraterClient, type CraterComputedStyleWithState, type CraterCssMutation, type CraterCssMutationAction, type CraterLayoutDiagnostics, type CraterLayoutNode, type CraterLayoutRootBox, type CraterRenderVariant, type CraterResponsiveBreakpoint, type CraterRuleViewportMap, type CraterRuleViewportMapEntry, type CraterSmokeCheck, type CraterSmokeClient, type CraterSmokeReport, type CraterSmokeStatus, type CraterViewportSource, type CraterWasmLayoutBackend, type CraterWasmModule, type CraterWasmRenderRequest, type CraterWasmRenderResult, type CraterWasmViewport, DEFAULT_BIDI_URL, DEFAULT_CAPTURE_BASE_URL, DEFAULT_CAPTURE_CONFIG_FILE, DEFAULT_CAPTURE_ROUTES, type DiscoveryResult, type FailedTest, type LoadCaptureConfigOptions, type LoadCraterWasmModuleOptions, type PaintNode, type PaintProps, type PrescannerResolvedBy, type PrescannerTrialResolution, type PrescannerTrialSummary, type ReportStats, type ResponsiveBreakpoint, VLMKIT_CRATER_BIDI_URL_ENV, VLMKIT_CRATER_ROOT_ENV, ViewportDetectionResult, type ViewportOptions, type ViewportSource, type ViewportSpec, analyzeReport, buildCloudflareQuickActionEndpoint, captureConfigDir, collectScreenshots, createCloudflareQuickActionsClient, createCraterWasmLayoutBackend, diffPaintTrees, discoverViewports, discoverViewportsViaCrater, discoverViewportsWithBackend, extractBreakpoints, extractBreakpointsFromHtml, extractBreakpointsFromHtmlWithStylesheets, extractCloudflareCrawlRoutes, extractResponsiveBreakpointsFromHtml, extractResponsiveBreakpointsFromHtmlWithStylesheets, extractStylesheetHrefsFromHtml, formatCraterSmokeReport, formatPlaywrightLaunchError, formatStats, generateViewports, hasAnyBatchPrescanSignal, hasAnyDetectionSignal, hasCraterPrescanSignal, isCraterAvailable, isPlaywrightSandboxRestrictionError, loadCaptureConfigFromFile, loadCraterWasmModule, mergeResponsiveBreakpoints, mutationsForPropertyRemoval, mutationsForSelectorBlockRemoval, normalizeCraterLayoutJson, parseCaptureConfig, resolveCaptureRoutes, resolveCloudflareQuickActionsConfig, resolveCraterBidiUrl, resolvePrescannerTrial, routeNameFromPath, runBatchPrescan, runCraterBidiSmoke, summarizeCraterLayout, summarizePrescannerTrials, toResponsiveBreakpoints };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CRATER_BIDI_URL_ENV, CRATER_ROOT_ENV, CraterClient, DEFAULT_BIDI_URL, VLMKIT_CRATER_BIDI_URL_ENV, VLMKIT_CRATER_ROOT_ENV, diffPaintTrees, isCraterAvailable, resolveCraterBidiUrl } from "./crater-client.mjs";
|
|
2
|
+
import { hasAnyBatchPrescanSignal, mutationsForPropertyRemoval, mutationsForSelectorBlockRemoval, runBatchPrescan } from "./batch-prescan.mjs";
|
|
3
|
+
import { DEFAULT_CAPTURE_BASE_URL, DEFAULT_CAPTURE_CONFIG_FILE, DEFAULT_CAPTURE_ROUTES, captureConfigDir, loadCaptureConfigFromFile, parseCaptureConfig, resolveCaptureRoutes, routeNameFromPath } from "./capture-config.mjs";
|
|
4
|
+
import { buildCloudflareQuickActionEndpoint, createCloudflareQuickActionsClient, extractCloudflareCrawlRoutes, resolveCloudflareQuickActionsConfig } from "./cloudflare-quick-actions.mjs";
|
|
5
|
+
import { formatCraterSmokeReport, runCraterBidiSmoke } from "./crater-smoke.mjs";
|
|
6
|
+
import { CRATER_WASM_MODULE_ENV, createCraterWasmLayoutBackend, loadCraterWasmModule, normalizeCraterLayoutJson, summarizeCraterLayout } from "./crater-wasm.mjs";
|
|
7
|
+
import { discoverViewports, discoverViewportsViaCrater, discoverViewportsWithBackend, extractBreakpoints, extractBreakpointsFromHtml, extractBreakpointsFromHtmlWithStylesheets, extractResponsiveBreakpointsFromHtml, extractResponsiveBreakpointsFromHtmlWithStylesheets, extractStylesheetHrefsFromHtml, generateViewports, mergeResponsiveBreakpoints, toResponsiveBreakpoints } from "./viewport-discovery.mjs";
|
|
8
|
+
import { formatPlaywrightLaunchError, isPlaywrightSandboxRestrictionError } from "./playwright-launch-error.mjs";
|
|
9
|
+
import { analyzeReport, collectScreenshots, formatStats } from "./playwright-analyzer.mjs";
|
|
10
|
+
import { hasAnyDetectionSignal, hasCraterPrescanSignal, resolvePrescannerTrial, summarizePrescannerTrials } from "./prescanner.mjs";
|
|
11
|
+
export { CRATER_BIDI_URL_ENV, CRATER_ROOT_ENV, CRATER_WASM_MODULE_ENV, CraterClient, DEFAULT_BIDI_URL, DEFAULT_CAPTURE_BASE_URL, DEFAULT_CAPTURE_CONFIG_FILE, DEFAULT_CAPTURE_ROUTES, VLMKIT_CRATER_BIDI_URL_ENV, VLMKIT_CRATER_ROOT_ENV, analyzeReport, buildCloudflareQuickActionEndpoint, captureConfigDir, collectScreenshots, createCloudflareQuickActionsClient, createCraterWasmLayoutBackend, diffPaintTrees, discoverViewports, discoverViewportsViaCrater, discoverViewportsWithBackend, extractBreakpoints, extractBreakpointsFromHtml, extractBreakpointsFromHtmlWithStylesheets, extractCloudflareCrawlRoutes, extractResponsiveBreakpointsFromHtml, extractResponsiveBreakpointsFromHtmlWithStylesheets, extractStylesheetHrefsFromHtml, formatCraterSmokeReport, formatPlaywrightLaunchError, formatStats, generateViewports, hasAnyBatchPrescanSignal, hasAnyDetectionSignal, hasCraterPrescanSignal, isCraterAvailable, isPlaywrightSandboxRestrictionError, loadCaptureConfigFromFile, loadCraterWasmModule, mergeResponsiveBreakpoints, mutationsForPropertyRemoval, mutationsForSelectorBlockRemoval, normalizeCraterLayoutJson, parseCaptureConfig, resolveCaptureRoutes, resolveCloudflareQuickActionsConfig, resolveCraterBidiUrl, resolvePrescannerTrial, routeNameFromPath, runBatchPrescan, runCraterBidiSmoke, summarizeCraterLayout, summarizePrescannerTrials, toResponsiveBreakpoints };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Attachment, VrtSnapshot } from "@mizchi/vlmkit-core/types.ts";
|
|
2
|
+
|
|
3
|
+
//#region src/playwright-analyzer.d.ts
|
|
4
|
+
interface AnalyzedReport {
|
|
5
|
+
snapshots: VrtSnapshot[];
|
|
6
|
+
failedTests: FailedTest[];
|
|
7
|
+
stats: ReportStats;
|
|
8
|
+
}
|
|
9
|
+
interface FailedTest {
|
|
10
|
+
testId: string;
|
|
11
|
+
title: string;
|
|
12
|
+
project: string;
|
|
13
|
+
errors: string[];
|
|
14
|
+
attachments: Attachment[];
|
|
15
|
+
}
|
|
16
|
+
interface ReportStats {
|
|
17
|
+
total: number;
|
|
18
|
+
passed: number;
|
|
19
|
+
failed: number;
|
|
20
|
+
skipped: number;
|
|
21
|
+
flaky: number;
|
|
22
|
+
duration: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Playwright JSON レポートを読み込み、構造化された VRT データに変換する
|
|
26
|
+
*/
|
|
27
|
+
declare function analyzeReport(reportPath: string): Promise<AnalyzedReport>;
|
|
28
|
+
/**
|
|
29
|
+
* test-results ディレクトリからスクリーンショットファイルを収集し、
|
|
30
|
+
* ベースラインとの対応関係を構築する
|
|
31
|
+
*/
|
|
32
|
+
declare function collectScreenshots(resultsDir: string, baselineDir: string): Promise<VrtSnapshot[]>;
|
|
33
|
+
/**
|
|
34
|
+
* レポートの統計サマリを人間可読な文字列にする
|
|
35
|
+
*/
|
|
36
|
+
declare function formatStats(stats: ReportStats): string;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { AnalyzedReport, FailedTest, ReportStats, analyzeReport, collectScreenshots, formatStats };
|