@mizchi/vlmkit-capture 0.23.2 → 0.28.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/dist/batch-prescan.d.mts +7 -11
- package/dist/batch-prescan.mjs +1 -2
- package/dist/capture-config.d.mts +12 -15
- package/dist/capture-config.mjs +1 -2
- package/dist/capturer.d.mts +9 -13
- package/dist/capturer.mjs +1 -2
- package/dist/cloudflare-quick-actions.d.mts +17 -20
- package/dist/cloudflare-quick-actions.mjs +1 -2
- package/dist/crater-client.d.mts +23 -26
- package/dist/crater-client.mjs +5 -4
- package/dist/crater-smoke.d.mts +14 -12
- package/dist/crater-smoke.mjs +1 -2
- package/dist/crater-wasm.d.mts +15 -18
- package/dist/crater-wasm.mjs +1 -2
- package/dist/detection-types.d.mts +2 -5
- package/dist/gates/crater.gate.d.mts +4 -8
- package/dist/gates/crater.gate.mjs +1 -2
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +5 -5
- package/dist/playwright-analyzer.d.mts +6 -10
- package/dist/playwright-analyzer.mjs +1 -2
- package/dist/playwright-launch-error.d.mts +4 -7
- package/dist/playwright-launch-error.mjs +4 -3
- package/dist/prescanner.d.mts +8 -12
- package/dist/prescanner.mjs +1 -2
- package/dist/route-capture.d.mts +8 -11
- package/dist/route-capture.mjs +1 -2
- package/dist/viewport-discovery.d.mts +20 -22
- package/dist/viewport-discovery.mjs +1 -2
- package/package.json +5 -5
package/dist/batch-prescan.d.mts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { CraterClient, CraterCssMutation, PaintNode, PaintTreeChange } from "./crater-client.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/batch-prescan.d.ts
|
|
4
|
-
interface BatchPrescanRequest {
|
|
2
|
+
export interface BatchPrescanRequest {
|
|
5
3
|
/** Stable id (echoed back in the result). */
|
|
6
4
|
id: string;
|
|
7
5
|
/** CSS mutations describing how this variant diverges from the baseline. */
|
|
8
6
|
mutations: CraterCssMutation[];
|
|
9
7
|
}
|
|
10
|
-
interface BatchPrescanResult {
|
|
8
|
+
export interface BatchPrescanResult {
|
|
11
9
|
id: string;
|
|
12
10
|
/** Paint-tree changes vs. the baseline tree. Empty when the variant looks identical. */
|
|
13
11
|
changes: PaintTreeChange[];
|
|
@@ -16,7 +14,7 @@ interface BatchPrescanResult {
|
|
|
16
14
|
/** True when Crater silently dropped the variant (no `paintTree` in the response). */
|
|
17
15
|
missing: boolean;
|
|
18
16
|
}
|
|
19
|
-
interface BatchPrescanOptions {
|
|
17
|
+
export interface BatchPrescanOptions {
|
|
20
18
|
/** Skip variants whose `mutations` array is empty — Crater would no-op them anyway. */
|
|
21
19
|
skipEmptyMutations?: boolean;
|
|
22
20
|
}
|
|
@@ -28,7 +26,7 @@ interface BatchPrescanOptions {
|
|
|
28
26
|
* The caller is responsible for collecting `baselinePaintTree` (e.g. via
|
|
29
27
|
* the existing `capturePageStateCrater` flow at the same viewport).
|
|
30
28
|
*/
|
|
31
|
-
declare function runBatchPrescan(client: Pick<CraterClient, "batchRender">, baseHtml: string, viewport: {
|
|
29
|
+
export declare function runBatchPrescan(client: Pick<CraterClient, "batchRender">, baseHtml: string, viewport: {
|
|
32
30
|
width: number;
|
|
33
31
|
height: number;
|
|
34
32
|
}, baselinePaintTree: PaintNode, requests: BatchPrescanRequest[], options?: BatchPrescanOptions): Promise<BatchPrescanResult[]>;
|
|
@@ -36,16 +34,14 @@ declare function runBatchPrescan(client: Pick<CraterClient, "batchRender">, base
|
|
|
36
34
|
* Build a Crater `mutations` payload for "remove a single CSS declaration"
|
|
37
35
|
* — the css-challenge property-mode trial shape.
|
|
38
36
|
*/
|
|
39
|
-
declare function mutationsForPropertyRemoval(selector: string, property: string): CraterCssMutation[];
|
|
37
|
+
export declare function mutationsForPropertyRemoval(selector: string, property: string): CraterCssMutation[];
|
|
40
38
|
/**
|
|
41
39
|
* Build a Crater `mutations` payload for "remove every declaration in a
|
|
42
40
|
* selector block" — the css-challenge selector-mode trial shape.
|
|
43
41
|
*/
|
|
44
|
-
declare function mutationsForSelectorBlockRemoval(selector: string, properties: string[]): CraterCssMutation[];
|
|
42
|
+
export declare function mutationsForSelectorBlockRemoval(selector: string, properties: string[]): CraterCssMutation[];
|
|
45
43
|
/**
|
|
46
44
|
* True when at least one of the batch-prescan results found a paint-tree
|
|
47
45
|
* signal. Used to short-circuit follow-up per-viewport captures.
|
|
48
46
|
*/
|
|
49
|
-
declare function hasAnyBatchPrescanSignal(results: BatchPrescanResult[]): boolean;
|
|
50
|
-
//#endregion
|
|
51
|
-
export { BatchPrescanOptions, BatchPrescanRequest, BatchPrescanResult, hasAnyBatchPrescanSignal, mutationsForPropertyRemoval, mutationsForSelectorBlockRemoval, runBatchPrescan };
|
|
47
|
+
export declare function hasAnyBatchPrescanSignal(results: BatchPrescanResult[]): boolean;
|
package/dist/batch-prescan.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { diffPaintTrees } from "./crater-client.mjs";
|
|
2
|
-
|
|
2
|
+
// src/batch-prescan.ts
|
|
3
3
|
/**
|
|
4
4
|
* Drive `batchRender` and return per-variant paint-tree diffs against a
|
|
5
5
|
* caller-supplied baseline tree. The baseline tree must come from a render
|
|
@@ -62,5 +62,4 @@ function mutationsForSelectorBlockRemoval(selector, properties) {
|
|
|
62
62
|
function hasAnyBatchPrescanSignal(results) {
|
|
63
63
|
return results.some((result) => !result.missing && result.changes.length > 0);
|
|
64
64
|
}
|
|
65
|
-
//#endregion
|
|
66
65
|
export { hasAnyBatchPrescanSignal, mutationsForPropertyRemoval, mutationsForSelectorBlockRemoval, runBatchPrescan };
|
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
interface CaptureRoute {
|
|
1
|
+
export interface CaptureRoute {
|
|
3
2
|
name: string;
|
|
4
3
|
path: string;
|
|
5
4
|
waitFor?: string;
|
|
6
5
|
}
|
|
7
|
-
interface CaptureConfig {
|
|
6
|
+
export interface CaptureConfig {
|
|
8
7
|
baseUrl?: string;
|
|
9
8
|
routes?: CaptureRoute[];
|
|
10
9
|
}
|
|
11
|
-
interface CaptureRouteSet {
|
|
10
|
+
export interface CaptureRouteSet {
|
|
12
11
|
baseUrl: string;
|
|
13
12
|
routes: CaptureRoute[];
|
|
14
13
|
source: "env" | "config" | "default";
|
|
15
14
|
configPath?: string;
|
|
16
15
|
}
|
|
17
|
-
declare const DEFAULT_CAPTURE_BASE_URL = "http://127.0.0.1:4174";
|
|
16
|
+
export declare const DEFAULT_CAPTURE_BASE_URL = "http://127.0.0.1:4174";
|
|
18
17
|
/**
|
|
19
18
|
* Built-in fallback used when no config or env override is provided.
|
|
20
19
|
* Kept for vlmkit's own development workflow; external projects should
|
|
21
20
|
* supply their own routes via `vlmkit.config.json`.
|
|
22
21
|
*/
|
|
23
|
-
declare const DEFAULT_CAPTURE_ROUTES: CaptureRoute[];
|
|
24
|
-
declare const DEFAULT_CAPTURE_CONFIG_FILE = "vlmkit.config.json";
|
|
25
|
-
declare function parseCaptureConfig(raw: string): CaptureConfig;
|
|
26
|
-
declare function routeNameFromPath(path: string): string;
|
|
27
|
-
interface LoadCaptureConfigOptions {
|
|
22
|
+
export declare const DEFAULT_CAPTURE_ROUTES: CaptureRoute[];
|
|
23
|
+
export declare const DEFAULT_CAPTURE_CONFIG_FILE = "vlmkit.config.json";
|
|
24
|
+
export declare function parseCaptureConfig(raw: string): CaptureConfig;
|
|
25
|
+
export declare function routeNameFromPath(path: string): string;
|
|
26
|
+
export interface LoadCaptureConfigOptions {
|
|
28
27
|
configPath?: string;
|
|
29
28
|
cwd?: string;
|
|
30
29
|
envRoutes?: string;
|
|
@@ -40,11 +39,9 @@ interface LoadCaptureConfigOptions {
|
|
|
40
39
|
* 3. `vlmkit.config.json` discovered in `cwd`
|
|
41
40
|
* 4. Built-in defaults
|
|
42
41
|
*/
|
|
43
|
-
declare function resolveCaptureRoutes(options?: LoadCaptureConfigOptions): CaptureRouteSet;
|
|
42
|
+
export declare function resolveCaptureRoutes(options?: LoadCaptureConfigOptions): CaptureRouteSet;
|
|
44
43
|
/**
|
|
45
44
|
* Helper for unit tests / non-Playwright callers: read & normalize a file.
|
|
46
45
|
*/
|
|
47
|
-
declare function loadCaptureConfigFromFile(configPath: string): CaptureConfig;
|
|
48
|
-
declare function captureConfigDir(configPath: string): string;
|
|
49
|
-
//#endregion
|
|
50
|
-
export { CaptureConfig, CaptureRoute, CaptureRouteSet, DEFAULT_CAPTURE_BASE_URL, DEFAULT_CAPTURE_CONFIG_FILE, DEFAULT_CAPTURE_ROUTES, LoadCaptureConfigOptions, captureConfigDir, loadCaptureConfigFromFile, parseCaptureConfig, resolveCaptureRoutes, routeNameFromPath };
|
|
46
|
+
export declare function loadCaptureConfigFromFile(configPath: string): CaptureConfig;
|
|
47
|
+
export declare function captureConfigDir(configPath: string): string;
|
package/dist/capture-config.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { dirname, isAbsolute, resolve } from "node:path";
|
|
3
|
-
|
|
3
|
+
// src/capture-config.ts
|
|
4
4
|
/**
|
|
5
5
|
* Capture configuration loader for `vlmkit workflow init|capture`.
|
|
6
6
|
*
|
|
@@ -174,5 +174,4 @@ function loadCaptureConfigFromFile(configPath) {
|
|
|
174
174
|
function captureConfigDir(configPath) {
|
|
175
175
|
return dirname(configPath);
|
|
176
176
|
}
|
|
177
|
-
//#endregion
|
|
178
177
|
export { DEFAULT_CAPTURE_BASE_URL, DEFAULT_CAPTURE_CONFIG_FILE, DEFAULT_CAPTURE_ROUTES, captureConfigDir, loadCaptureConfigFromFile, parseCaptureConfig, resolveCaptureRoutes, routeNameFromPath };
|
package/dist/capturer.d.mts
CHANGED
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
import { Browser } from "playwright";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type CaptureBackendKind = "local" | "cloudflare-cdp";
|
|
5
|
-
interface CaptureBackend {
|
|
2
|
+
export type CaptureBackendKind = "local" | "cloudflare-cdp";
|
|
3
|
+
export interface CaptureBackend {
|
|
6
4
|
readonly kind: CaptureBackendKind;
|
|
7
5
|
/** Human-readable label used in logs. */
|
|
8
6
|
readonly label: string;
|
|
9
7
|
launch(): Promise<Browser>;
|
|
10
8
|
close(browser: Browser): Promise<void>;
|
|
11
9
|
}
|
|
12
|
-
interface CloudflareCdpOptions {
|
|
10
|
+
export interface CloudflareCdpOptions {
|
|
13
11
|
accountId: string;
|
|
14
12
|
apiToken: string;
|
|
15
13
|
/** Override the default CF CDP URL (useful for tests / private deployments). */
|
|
16
14
|
endpoint?: string;
|
|
17
15
|
}
|
|
18
|
-
declare function buildCloudflareCdpUrl(opts: {
|
|
16
|
+
export declare function buildCloudflareCdpUrl(opts: {
|
|
19
17
|
accountId: string;
|
|
20
18
|
endpoint?: string;
|
|
21
19
|
}): string;
|
|
22
|
-
declare function createLocalCapturer(): CaptureBackend;
|
|
23
|
-
declare function createCloudflareCdpCapturer(opts: CloudflareCdpOptions): CaptureBackend;
|
|
24
|
-
interface ResolveCaptureBackendOptions {
|
|
20
|
+
export declare function createLocalCapturer(): CaptureBackend;
|
|
21
|
+
export declare function createCloudflareCdpCapturer(opts: CloudflareCdpOptions): CaptureBackend;
|
|
22
|
+
export interface ResolveCaptureBackendOptions {
|
|
25
23
|
/** Value from `--backend` CLI flag (e.g. "local", "cloudflare"). */
|
|
26
24
|
backendFlag?: string;
|
|
27
25
|
env?: NodeJS.ProcessEnv;
|
|
28
26
|
}
|
|
29
|
-
interface ResolvedCaptureBackend {
|
|
27
|
+
export interface ResolvedCaptureBackend {
|
|
30
28
|
backend: CaptureBackend;
|
|
31
29
|
source: "flag" | "env" | "default";
|
|
32
30
|
}
|
|
@@ -40,6 +38,4 @@ interface ResolvedCaptureBackend {
|
|
|
40
38
|
* + `CLOUDFLARE_API_TOKEN`) regardless of how the backend was selected, so
|
|
41
39
|
* CI configs can stay declarative.
|
|
42
40
|
*/
|
|
43
|
-
declare function resolveCaptureBackend(options?: ResolveCaptureBackendOptions): ResolvedCaptureBackend;
|
|
44
|
-
//#endregion
|
|
45
|
-
export { CaptureBackend, CaptureBackendKind, CloudflareCdpOptions, ResolveCaptureBackendOptions, ResolvedCaptureBackend, buildCloudflareCdpUrl, createCloudflareCdpCapturer, createLocalCapturer, resolveCaptureBackend };
|
|
41
|
+
export declare function resolveCaptureBackend(options?: ResolveCaptureBackendOptions): ResolvedCaptureBackend;
|
package/dist/capturer.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { chromium } from "playwright";
|
|
2
2
|
import { launchBrowser } from "@mizchi/vlmkit-core/browser-launch.ts";
|
|
3
|
-
|
|
3
|
+
// src/capturer.ts
|
|
4
4
|
/**
|
|
5
5
|
* Browser launch abstraction.
|
|
6
6
|
*
|
|
@@ -91,5 +91,4 @@ function resolveCaptureBackend(options = {}) {
|
|
|
91
91
|
default: throw new Error(`Unknown capture backend: ${choice}`);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
//#endregion
|
|
95
94
|
export { buildCloudflareCdpUrl, createCloudflareCdpCapturer, createLocalCapturer, resolveCaptureBackend };
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
interface CloudflareQuickActionsConfig {
|
|
1
|
+
export type CloudflareQuickAction = "screenshot" | "crawl";
|
|
2
|
+
export interface CloudflareQuickActionsConfig {
|
|
4
3
|
accountId: string;
|
|
5
4
|
apiToken: string;
|
|
6
5
|
apiBase?: string;
|
|
7
6
|
fetch?: typeof fetch;
|
|
8
7
|
}
|
|
9
|
-
interface CloudflareQuickActionsEnv {
|
|
8
|
+
export interface CloudflareQuickActionsEnv {
|
|
10
9
|
CLOUDFLARE_ACCOUNT_ID?: string;
|
|
11
10
|
CLOUDFLARE_API_TOKEN?: string;
|
|
12
11
|
CLOUDFLARE_BROWSER_RENDERING_API_BASE?: string;
|
|
13
12
|
}
|
|
14
|
-
interface CloudflareQuickActionEndpointInput {
|
|
13
|
+
export interface CloudflareQuickActionEndpointInput {
|
|
15
14
|
accountId: string;
|
|
16
15
|
action: CloudflareQuickAction;
|
|
17
16
|
jobId?: string;
|
|
18
17
|
apiBase?: string;
|
|
19
18
|
}
|
|
20
|
-
interface CloudflareScreenshotRequest {
|
|
19
|
+
export interface CloudflareScreenshotRequest {
|
|
21
20
|
url?: string;
|
|
22
21
|
html?: string;
|
|
23
22
|
viewport?: {
|
|
@@ -46,12 +45,12 @@ interface CloudflareScreenshotRequest {
|
|
|
46
45
|
addStyleTag?: Array<Record<string, unknown>>;
|
|
47
46
|
userAgent?: string;
|
|
48
47
|
}
|
|
49
|
-
interface CloudflareScreenshotResult {
|
|
48
|
+
export interface CloudflareScreenshotResult {
|
|
50
49
|
bytes: ArrayBuffer;
|
|
51
50
|
contentType: string;
|
|
52
51
|
browserMsUsed?: number;
|
|
53
52
|
}
|
|
54
|
-
interface CloudflareCrawlRequest {
|
|
53
|
+
export interface CloudflareCrawlRequest {
|
|
55
54
|
url: string;
|
|
56
55
|
limit?: number;
|
|
57
56
|
depth?: number;
|
|
@@ -70,11 +69,11 @@ interface CloudflareCrawlRequest {
|
|
|
70
69
|
setExtraHTTPHeaders?: Record<string, string>;
|
|
71
70
|
rejectResourceTypes?: string[];
|
|
72
71
|
}
|
|
73
|
-
interface CloudflareCrawlStartResult {
|
|
72
|
+
export interface CloudflareCrawlStartResult {
|
|
74
73
|
jobId: string;
|
|
75
74
|
}
|
|
76
|
-
type CloudflareCrawlRecordStatus = "queued" | "errored" | "completed" | "disallowed" | "skipped" | "cancelled";
|
|
77
|
-
interface CloudflareCrawlRecord {
|
|
75
|
+
export type CloudflareCrawlRecordStatus = "queued" | "errored" | "completed" | "disallowed" | "skipped" | "cancelled";
|
|
76
|
+
export interface CloudflareCrawlRecord {
|
|
78
77
|
url: string;
|
|
79
78
|
status: CloudflareCrawlRecordStatus;
|
|
80
79
|
metadata?: {
|
|
@@ -86,7 +85,7 @@ interface CloudflareCrawlRecord {
|
|
|
86
85
|
markdown?: string;
|
|
87
86
|
json?: unknown;
|
|
88
87
|
}
|
|
89
|
-
interface CloudflareCrawlResult {
|
|
88
|
+
export interface CloudflareCrawlResult {
|
|
90
89
|
id: string;
|
|
91
90
|
status: string;
|
|
92
91
|
browserSecondsUsed?: number;
|
|
@@ -94,21 +93,19 @@ interface CloudflareCrawlResult {
|
|
|
94
93
|
finished?: number;
|
|
95
94
|
records: CloudflareCrawlRecord[];
|
|
96
95
|
}
|
|
97
|
-
interface CloudflareCrawlRoute {
|
|
96
|
+
export interface CloudflareCrawlRoute {
|
|
98
97
|
url: string;
|
|
99
98
|
path: string;
|
|
100
99
|
title?: string;
|
|
101
100
|
}
|
|
102
|
-
interface ExtractCloudflareCrawlRoutesOptions {
|
|
101
|
+
export interface ExtractCloudflareCrawlRoutesOptions {
|
|
103
102
|
baseUrl?: string;
|
|
104
103
|
}
|
|
105
|
-
declare function buildCloudflareQuickActionEndpoint(input: CloudflareQuickActionEndpointInput): string;
|
|
106
|
-
declare function resolveCloudflareQuickActionsConfig(env?: CloudflareQuickActionsEnv): CloudflareQuickActionsConfig;
|
|
107
|
-
declare function createCloudflareQuickActionsClient(config: CloudflareQuickActionsConfig): {
|
|
104
|
+
export declare function buildCloudflareQuickActionEndpoint(input: CloudflareQuickActionEndpointInput): string;
|
|
105
|
+
export declare function resolveCloudflareQuickActionsConfig(env?: CloudflareQuickActionsEnv): CloudflareQuickActionsConfig;
|
|
106
|
+
export declare function createCloudflareQuickActionsClient(config: CloudflareQuickActionsConfig): {
|
|
108
107
|
screenshot(input: CloudflareScreenshotRequest): Promise<CloudflareScreenshotResult>;
|
|
109
108
|
startCrawl(input: CloudflareCrawlRequest): Promise<CloudflareCrawlStartResult>;
|
|
110
109
|
getCrawlResult(jobId: string): Promise<CloudflareCrawlResult>;
|
|
111
110
|
};
|
|
112
|
-
declare function extractCloudflareCrawlRoutes(result: CloudflareCrawlResult, options?: ExtractCloudflareCrawlRoutesOptions): CloudflareCrawlRoute[];
|
|
113
|
-
//#endregion
|
|
114
|
-
export { CloudflareCrawlRecord, CloudflareCrawlRecordStatus, CloudflareCrawlRequest, CloudflareCrawlResult, CloudflareCrawlRoute, CloudflareCrawlStartResult, CloudflareQuickAction, CloudflareQuickActionEndpointInput, CloudflareQuickActionsConfig, CloudflareQuickActionsEnv, CloudflareScreenshotRequest, CloudflareScreenshotResult, ExtractCloudflareCrawlRoutesOptions, buildCloudflareQuickActionEndpoint, createCloudflareQuickActionsClient, extractCloudflareCrawlRoutes, resolveCloudflareQuickActionsConfig };
|
|
111
|
+
export declare function extractCloudflareCrawlRoutes(result: CloudflareCrawlResult, options?: ExtractCloudflareCrawlRoutesOptions): CloudflareCrawlRoute[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cloudflare-quick-actions.ts
|
|
2
2
|
function buildCloudflareQuickActionEndpoint(input) {
|
|
3
3
|
const base = `${(input.apiBase ?? "https://api.cloudflare.com/client/v4").replace(/\/$/u, "")}/accounts/${encodeURIComponent(input.accountId)}/browser-rendering/${input.action}`;
|
|
4
4
|
return input.jobId ? `${base}/${encodeURIComponent(input.jobId)}` : base;
|
|
@@ -138,5 +138,4 @@ function readNumber(record, key) {
|
|
|
138
138
|
const value = record[key];
|
|
139
139
|
return typeof value === "number" ? value : void 0;
|
|
140
140
|
}
|
|
141
|
-
//#endregion
|
|
142
141
|
export { buildCloudflareQuickActionEndpoint, createCloudflareQuickActionsClient, extractCloudflareCrawlRoutes, resolveCloudflareQuickActionsConfig };
|
package/dist/crater-client.d.mts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
declare const
|
|
3
|
-
declare const
|
|
4
|
-
declare const
|
|
5
|
-
declare const
|
|
6
|
-
|
|
7
|
-
interface ResolveCraterBidiUrlOptions {
|
|
1
|
+
export declare const DEFAULT_BIDI_URL = "ws://127.0.0.1:9222";
|
|
2
|
+
export declare const VLMKIT_CRATER_BIDI_URL_ENV = "VLMKIT_CRATER_BIDI_URL";
|
|
3
|
+
export declare const CRATER_BIDI_URL_ENV = "CRATER_BIDI_URL";
|
|
4
|
+
export declare const VLMKIT_CRATER_ROOT_ENV = "VLMKIT_CRATER_ROOT";
|
|
5
|
+
export declare const CRATER_ROOT_ENV = "CRATER_ROOT";
|
|
6
|
+
export interface ResolveCraterBidiUrlOptions {
|
|
8
7
|
env?: Partial<Record<typeof VLMKIT_CRATER_BIDI_URL_ENV | typeof CRATER_BIDI_URL_ENV | typeof VLMKIT_CRATER_ROOT_ENV | typeof CRATER_ROOT_ENV, string | undefined>>;
|
|
9
8
|
craterRoot?: string;
|
|
10
9
|
urlFile?: string;
|
|
11
10
|
}
|
|
12
|
-
declare function resolveCraterBidiUrl(options?: ResolveCraterBidiUrlOptions): string;
|
|
13
|
-
interface CraterResponsiveBreakpoint {
|
|
11
|
+
export declare function resolveCraterBidiUrl(options?: ResolveCraterBidiUrlOptions): string;
|
|
12
|
+
export interface CraterResponsiveBreakpoint {
|
|
14
13
|
axis: "width";
|
|
15
14
|
op: "ge" | "gt" | "le" | "lt";
|
|
16
15
|
valuePx: number;
|
|
@@ -19,24 +18,24 @@ interface CraterResponsiveBreakpoint {
|
|
|
19
18
|
guards: string[];
|
|
20
19
|
ruleCount: number;
|
|
21
20
|
}
|
|
22
|
-
interface CraterBreakpointDiscoveryDiagnostics {
|
|
21
|
+
export interface CraterBreakpointDiscoveryDiagnostics {
|
|
23
22
|
stylesheetCount: number;
|
|
24
23
|
ruleCount: number;
|
|
25
24
|
externalStylesheetLinks: string[];
|
|
26
25
|
ignoredQueries: string[];
|
|
27
26
|
unsupportedQueries: string[];
|
|
28
27
|
}
|
|
29
|
-
interface CraterRuleViewportMapEntry {
|
|
28
|
+
export interface CraterRuleViewportMapEntry {
|
|
30
29
|
selector: string;
|
|
31
30
|
properties: string[];
|
|
32
31
|
mediaCondition: string;
|
|
33
32
|
activeAtWidths: number[];
|
|
34
33
|
inactiveAtWidths: number[];
|
|
35
34
|
}
|
|
36
|
-
interface CraterRuleViewportMap {
|
|
35
|
+
export interface CraterRuleViewportMap {
|
|
37
36
|
rules: CraterRuleViewportMapEntry[];
|
|
38
37
|
}
|
|
39
|
-
interface CraterComputedStyleWithState {
|
|
38
|
+
export interface CraterComputedStyleWithState {
|
|
40
39
|
normal: Record<string, string>;
|
|
41
40
|
forced: Record<string, string>;
|
|
42
41
|
diff: Array<{
|
|
@@ -45,29 +44,29 @@ interface CraterComputedStyleWithState {
|
|
|
45
44
|
forced: string;
|
|
46
45
|
}>;
|
|
47
46
|
}
|
|
48
|
-
type CraterCssMutationAction = "remove" | {
|
|
47
|
+
export type CraterCssMutationAction = "remove" | {
|
|
49
48
|
override: string;
|
|
50
49
|
};
|
|
51
|
-
interface CraterCssMutation {
|
|
50
|
+
export interface CraterCssMutation {
|
|
52
51
|
selector: string;
|
|
53
52
|
property: string;
|
|
54
53
|
action?: CraterCssMutationAction;
|
|
55
54
|
}
|
|
56
|
-
interface CraterRenderVariant {
|
|
55
|
+
export interface CraterRenderVariant {
|
|
57
56
|
id: string;
|
|
58
57
|
mutations: CraterCssMutation[];
|
|
59
58
|
}
|
|
60
|
-
interface CraterBatchRenderResult {
|
|
59
|
+
export interface CraterBatchRenderResult {
|
|
61
60
|
results: Array<{
|
|
62
61
|
id: string;
|
|
63
62
|
paintTree?: PaintNode | null;
|
|
64
63
|
}>;
|
|
65
64
|
}
|
|
66
|
-
interface CraterBreakpointDiscoveryResult {
|
|
65
|
+
export interface CraterBreakpointDiscoveryResult {
|
|
67
66
|
breakpoints: CraterResponsiveBreakpoint[];
|
|
68
67
|
diagnostics?: CraterBreakpointDiscoveryDiagnostics;
|
|
69
68
|
}
|
|
70
|
-
declare class CraterClient {
|
|
69
|
+
export declare class CraterClient {
|
|
71
70
|
private ws;
|
|
72
71
|
private commandId;
|
|
73
72
|
private pendingCommands;
|
|
@@ -122,7 +121,7 @@ declare class CraterClient {
|
|
|
122
121
|
/** Paint tree (render tree JSON) */
|
|
123
122
|
capturePaintTree(): Promise<PaintNode>;
|
|
124
123
|
}
|
|
125
|
-
interface PaintNode {
|
|
124
|
+
export interface PaintNode {
|
|
126
125
|
id?: string;
|
|
127
126
|
tag?: string;
|
|
128
127
|
x: number;
|
|
@@ -135,7 +134,7 @@ interface PaintNode {
|
|
|
135
134
|
text?: string;
|
|
136
135
|
ch?: PaintNode[];
|
|
137
136
|
}
|
|
138
|
-
interface PaintProps {
|
|
137
|
+
export interface PaintProps {
|
|
139
138
|
op?: number;
|
|
140
139
|
c?: number[];
|
|
141
140
|
bg?: number[];
|
|
@@ -144,7 +143,7 @@ interface PaintProps {
|
|
|
144
143
|
vis?: string;
|
|
145
144
|
br?: number[];
|
|
146
145
|
}
|
|
147
|
-
interface PaintTreeChange {
|
|
146
|
+
export interface PaintTreeChange {
|
|
148
147
|
path: string;
|
|
149
148
|
type: "geometry" | "paint" | "text" | "added" | "removed";
|
|
150
149
|
property?: string;
|
|
@@ -152,8 +151,6 @@ interface PaintTreeChange {
|
|
|
152
151
|
after?: string;
|
|
153
152
|
}
|
|
154
153
|
/** Compare two paint trees and return the diff */
|
|
155
|
-
declare function diffPaintTrees(baseline: PaintNode, current: PaintNode, path?: string): PaintTreeChange[];
|
|
154
|
+
export declare function diffPaintTrees(baseline: PaintNode, current: PaintNode, path?: string): PaintTreeChange[];
|
|
156
155
|
/** Check if crater server is running */
|
|
157
|
-
declare function isCraterAvailable(url?: string): Promise<boolean>;
|
|
158
|
-
//#endregion
|
|
159
|
-
export { CRATER_BIDI_URL_ENV, CRATER_ROOT_ENV, CraterBatchRenderResult, CraterBreakpointDiscoveryDiagnostics, CraterBreakpointDiscoveryResult, CraterClient, CraterComputedStyleWithState, CraterCssMutation, CraterCssMutationAction, CraterRenderVariant, CraterResponsiveBreakpoint, CraterRuleViewportMap, CraterRuleViewportMapEntry, DEFAULT_BIDI_URL, PaintNode, PaintProps, PaintTreeChange, ResolveCraterBidiUrlOptions, VLMKIT_CRATER_BIDI_URL_ENV, VLMKIT_CRATER_ROOT_ENV, diffPaintTrees, isCraterAvailable, resolveCraterBidiUrl };
|
|
156
|
+
export declare function isCraterAvailable(url?: string): Promise<boolean>;
|
package/dist/crater-client.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { PNG } from "pngjs";
|
|
|
3
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
4
4
|
import { resolve } from "node:path";
|
|
5
5
|
import { buildComputedStyleCaptureJsonExpression, computedStyleSnapshotToMap, hasMeaningfulComputedStyleSnapshot, parseComputedStyleSnapshot } from "@mizchi/vlmkit-core/computed-style-capture.ts";
|
|
6
|
-
|
|
6
|
+
// src/crater-client.ts
|
|
7
7
|
/**
|
|
8
8
|
* Crater BiDi client
|
|
9
9
|
*
|
|
@@ -48,7 +48,8 @@ var CraterClient = class {
|
|
|
48
48
|
this.ws = new WebSocket(this.url);
|
|
49
49
|
this.ws.on("open", async () => {
|
|
50
50
|
try {
|
|
51
|
-
|
|
51
|
+
const resp = await this.sendBidi("browsingContext.create", { type: "tab" });
|
|
52
|
+
this.contextId = resp.result.context;
|
|
52
53
|
resolve();
|
|
53
54
|
} catch (error) {
|
|
54
55
|
reject(error);
|
|
@@ -138,7 +139,8 @@ var CraterClient = class {
|
|
|
138
139
|
async captureComputedStyles(properties) {
|
|
139
140
|
const nativeSnapshot = await this.captureNativeComputedStyles(properties);
|
|
140
141
|
if (nativeSnapshot) return nativeSnapshot;
|
|
141
|
-
const
|
|
142
|
+
const rawSnapshot = await this.evaluate(buildComputedStyleCaptureJsonExpression(properties));
|
|
143
|
+
const snapshot = parseComputedStyleSnapshot(rawSnapshot);
|
|
142
144
|
if (!hasMeaningfulComputedStyleSnapshot(snapshot)) return /* @__PURE__ */ new Map();
|
|
143
145
|
return computedStyleSnapshotToMap(snapshot);
|
|
144
146
|
}
|
|
@@ -358,5 +360,4 @@ async function isCraterAvailable(url = resolveCraterBidiUrl()) {
|
|
|
358
360
|
return false;
|
|
359
361
|
}
|
|
360
362
|
}
|
|
361
|
-
//#endregion
|
|
362
363
|
export { CRATER_BIDI_URL_ENV, CRATER_ROOT_ENV, CraterClient, DEFAULT_BIDI_URL, VLMKIT_CRATER_BIDI_URL_ENV, VLMKIT_CRATER_ROOT_ENV, diffPaintTrees, isCraterAvailable, resolveCraterBidiUrl };
|
package/dist/crater-smoke.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { RuleView } from "@mizchi/vlmkit-core/plugin/contract.ts";
|
|
2
|
-
|
|
3
|
-
//#region src/crater-smoke.d.ts
|
|
4
|
-
interface CraterSmokeClient {
|
|
2
|
+
export interface CraterSmokeClient {
|
|
5
3
|
connect(): Promise<void>;
|
|
6
4
|
close(): Promise<void>;
|
|
7
5
|
setViewport(width: number, height: number): Promise<void>;
|
|
@@ -57,20 +55,20 @@ interface CraterSmokeClient {
|
|
|
57
55
|
}>;
|
|
58
56
|
}>;
|
|
59
57
|
}
|
|
60
|
-
type CraterSmokeStatus = "pass" | "skip" | "fail";
|
|
61
|
-
interface CraterSmokeCheck {
|
|
58
|
+
export type CraterSmokeStatus = "pass" | "skip" | "fail";
|
|
59
|
+
export interface CraterSmokeCheck {
|
|
62
60
|
name: string;
|
|
63
61
|
status: CraterSmokeStatus;
|
|
64
62
|
elapsedMs: number;
|
|
65
63
|
message: string;
|
|
66
64
|
}
|
|
67
|
-
interface CraterSmokeReport {
|
|
65
|
+
export interface CraterSmokeReport {
|
|
68
66
|
status: CraterSmokeStatus;
|
|
69
67
|
url: string;
|
|
70
68
|
checks: CraterSmokeCheck[];
|
|
71
69
|
elapsedMs: number;
|
|
72
70
|
}
|
|
73
|
-
interface CraterSmokeOptions {
|
|
71
|
+
export interface CraterSmokeOptions {
|
|
74
72
|
url?: string;
|
|
75
73
|
html?: string;
|
|
76
74
|
viewport?: {
|
|
@@ -88,17 +86,21 @@ interface CraterSmokeOptions {
|
|
|
88
86
|
isAvailable?: (url: string) => Promise<boolean>;
|
|
89
87
|
createClient?: (url: string) => CraterSmokeClient;
|
|
90
88
|
}
|
|
91
|
-
declare function runCraterBidiSmoke(options?: CraterSmokeOptions): Promise<CraterSmokeReport>;
|
|
92
|
-
declare function formatCraterSmokeReport(report: CraterSmokeReport, rules?: RuleView): string;
|
|
89
|
+
export declare function runCraterBidiSmoke(options?: CraterSmokeOptions): Promise<CraterSmokeReport>;
|
|
90
|
+
export declare function formatCraterSmokeReport(report: CraterSmokeReport, rules?: RuleView): string;
|
|
93
91
|
/**
|
|
94
92
|
* Read this gate's own flags. `--help` and `--json` are no longer handled
|
|
95
93
|
* here: the core gate runner owns both, and a parser that called
|
|
96
94
|
* `process.exit(0)` for help could not be used by anything but a CLI.
|
|
97
95
|
*/
|
|
98
|
-
declare function parseCraterSmokeArgs(argv: readonly string[], env?: NodeJS.ProcessEnv | Partial<NodeJS.ProcessEnv>): {
|
|
96
|
+
export declare function parseCraterSmokeArgs(argv: readonly string[], env?: NodeJS.ProcessEnv | Partial<NodeJS.ProcessEnv>): {
|
|
99
97
|
url: string;
|
|
100
98
|
requireAvailable: boolean;
|
|
101
99
|
deep: boolean;
|
|
102
100
|
};
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
/**
|
|
102
|
+
* CLI entry removed: this module is measurement code now, not a command.
|
|
103
|
+
* `check crater` is declared in `./gates/crater.gate.ts` and driven by the core runner
|
|
104
|
+
* (`@mizchi/vlmkit-core/plugin/runner.ts`), which owns argument parsing,
|
|
105
|
+
* `--json`, `--advisory`, the run ledger and the exit code.
|
|
106
|
+
*/
|
package/dist/crater-smoke.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { CraterClient, isCraterAvailable, resolveCraterBidiUrl } from "./crater-
|
|
|
3
3
|
import "node:path";
|
|
4
4
|
import { BOLD, CYAN, DIM, GREEN, RED, RESET, YELLOW } from "@mizchi/vlmkit-core/terminal-colors.ts";
|
|
5
5
|
import { ruleTier } from "@mizchi/vlmkit-core/plugin/rule-tier.ts";
|
|
6
|
-
|
|
6
|
+
// src/crater-smoke.ts
|
|
7
7
|
const DEFAULT_HTML = `<!doctype html>
|
|
8
8
|
<html>
|
|
9
9
|
<head>
|
|
@@ -246,5 +246,4 @@ function parseCraterSmokeArgs(argv, env = process.env) {
|
|
|
246
246
|
* (`@mizchi/vlmkit-core/plugin/runner.ts`), which owns argument parsing,
|
|
247
247
|
* `--json`, `--advisory`, the run ledger and the exit code.
|
|
248
248
|
*/
|
|
249
|
-
//#endregion
|
|
250
249
|
export { formatCraterSmokeReport, parseCraterSmokeArgs, runCraterBidiSmoke };
|
package/dist/crater-wasm.d.mts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
interface CraterWasmViewport {
|
|
1
|
+
export declare const CRATER_WASM_MODULE_ENV = "VLMKIT_CRATER_WASM_MODULE";
|
|
2
|
+
export interface CraterWasmViewport {
|
|
4
3
|
width: number;
|
|
5
4
|
height: number;
|
|
6
5
|
label?: string;
|
|
7
6
|
}
|
|
8
|
-
interface CraterBoxRect {
|
|
7
|
+
export interface CraterBoxRect {
|
|
9
8
|
top: number;
|
|
10
9
|
right: number;
|
|
11
10
|
bottom: number;
|
|
12
11
|
left: number;
|
|
13
12
|
}
|
|
14
|
-
interface CraterLayoutNode {
|
|
13
|
+
export interface CraterLayoutNode {
|
|
15
14
|
id: string;
|
|
16
15
|
x: number;
|
|
17
16
|
y: number;
|
|
@@ -22,22 +21,22 @@ interface CraterLayoutNode {
|
|
|
22
21
|
border: CraterBoxRect;
|
|
23
22
|
children: CraterLayoutNode[];
|
|
24
23
|
}
|
|
25
|
-
interface CraterLayoutRootBox {
|
|
24
|
+
export interface CraterLayoutRootBox {
|
|
26
25
|
x: number;
|
|
27
26
|
y: number;
|
|
28
27
|
width: number;
|
|
29
28
|
height: number;
|
|
30
29
|
}
|
|
31
|
-
interface CraterLayoutDiagnostics {
|
|
30
|
+
export interface CraterLayoutDiagnostics {
|
|
32
31
|
nodeCount: number;
|
|
33
32
|
maxDepth: number;
|
|
34
33
|
rootBox: CraterLayoutRootBox;
|
|
35
34
|
}
|
|
36
|
-
interface CraterWasmRenderRequest {
|
|
35
|
+
export interface CraterWasmRenderRequest {
|
|
37
36
|
html: string;
|
|
38
37
|
viewport: CraterWasmViewport;
|
|
39
38
|
}
|
|
40
|
-
interface CraterWasmRenderResult {
|
|
39
|
+
export interface CraterWasmRenderResult {
|
|
41
40
|
backend: "crater-wasm";
|
|
42
41
|
viewport: CraterWasmViewport;
|
|
43
42
|
layout: CraterLayoutNode;
|
|
@@ -45,21 +44,19 @@ interface CraterWasmRenderResult {
|
|
|
45
44
|
elapsedMs: number;
|
|
46
45
|
diagnostics: CraterLayoutDiagnostics;
|
|
47
46
|
}
|
|
48
|
-
interface CraterWasmModule {
|
|
47
|
+
export interface CraterWasmModule {
|
|
49
48
|
renderHtmlToJsonForWpt(html: string, width: number, height: number): string | Promise<string>;
|
|
50
49
|
}
|
|
51
|
-
interface CraterWasmLayoutBackend {
|
|
50
|
+
export interface CraterWasmLayoutBackend {
|
|
52
51
|
kind: "crater-wasm-layout";
|
|
53
52
|
renderLayout(request: CraterWasmRenderRequest): Promise<CraterWasmRenderResult>;
|
|
54
53
|
}
|
|
55
|
-
interface LoadCraterWasmModuleOptions {
|
|
54
|
+
export interface LoadCraterWasmModuleOptions {
|
|
56
55
|
modulePath?: string;
|
|
57
56
|
env?: Partial<Record<typeof CRATER_WASM_MODULE_ENV | "CRATER_WASM_MODULE", string | undefined>>;
|
|
58
57
|
cwd?: string;
|
|
59
58
|
}
|
|
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 };
|
|
59
|
+
export declare function createCraterWasmLayoutBackend(module: CraterWasmModule): CraterWasmLayoutBackend;
|
|
60
|
+
export declare function loadCraterWasmModule(options?: LoadCraterWasmModuleOptions): Promise<CraterWasmModule>;
|
|
61
|
+
export declare function normalizeCraterLayoutJson(raw: string | unknown): CraterLayoutNode;
|
|
62
|
+
export declare function summarizeCraterLayout(layout: CraterLayoutNode): CraterLayoutDiagnostics;
|
package/dist/crater-wasm.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
|
-
|
|
3
|
+
// src/crater-wasm.ts
|
|
4
4
|
const CRATER_WASM_MODULE_ENV = "VLMKIT_CRATER_WASM_MODULE";
|
|
5
5
|
function createCraterWasmLayoutBackend(module) {
|
|
6
6
|
assertCraterWasmModule(module);
|
|
@@ -128,5 +128,4 @@ function isBareSpecifier(value) {
|
|
|
128
128
|
function errorMessage(error) {
|
|
129
129
|
return error instanceof Error ? error.message : String(error);
|
|
130
130
|
}
|
|
131
|
-
//#endregion
|
|
132
131
|
export { CRATER_WASM_MODULE_ENV, createCraterWasmLayoutBackend, loadCraterWasmModule, normalizeCraterLayoutJson, summarizeCraterLayout };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
//#region src/detection-types.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Capture-level detection result shared across capture backends
|
|
4
3
|
* (Playwright, Crater BiDi) and downstream detection classifiers.
|
|
5
4
|
*/
|
|
6
|
-
interface ViewportDetectionResult {
|
|
5
|
+
export interface ViewportDetectionResult {
|
|
7
6
|
width: number;
|
|
8
7
|
height: number;
|
|
9
8
|
visualDiffDetected: boolean;
|
|
@@ -20,6 +19,4 @@ interface ViewportDetectionResult {
|
|
|
20
19
|
* silent false-negative.
|
|
21
20
|
*/
|
|
22
21
|
visualCaptureSkipped?: boolean;
|
|
23
|
-
}
|
|
24
|
-
//#endregion
|
|
25
|
-
export { ViewportDetectionResult };
|
|
22
|
+
}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { CraterSmokeOptions, CraterSmokeReport } from "../crater-smoke.mjs";
|
|
2
|
-
import * as _$_mizchi_vlmkit_core_plugin_contract_ts0 from "@mizchi/vlmkit-core/plugin/contract.ts";
|
|
3
|
-
|
|
4
|
-
//#region src/gates/crater.gate.d.ts
|
|
5
2
|
/** The gate needs `requireAvailable` at verdict time, not just at run time. */
|
|
6
|
-
interface CraterGateOptions extends CraterSmokeOptions {
|
|
3
|
+
export interface CraterGateOptions extends CraterSmokeOptions {
|
|
7
4
|
requireAvailable: boolean;
|
|
8
5
|
}
|
|
9
|
-
declare const craterGate:
|
|
10
|
-
declare const captureGatesPlugin:
|
|
11
|
-
|
|
12
|
-
export { CraterGateOptions, captureGatesPlugin, captureGatesPlugin as default, craterGate };
|
|
6
|
+
export declare const craterGate: import("@mizchi/vlmkit-core/plugin/contract.ts").GateDefinition<CraterSmokeReport, CraterGateOptions>;
|
|
7
|
+
export declare const captureGatesPlugin: import("@mizchi/vlmkit-core/plugin/contract.ts").VlmkitPlugin;
|
|
8
|
+
export { captureGatesPlugin as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { formatCraterSmokeReport, parseCraterSmokeArgs, runCraterBidiSmoke } from "../crater-smoke.mjs";
|
|
2
2
|
import { defineGate, definePlugin } from "@mizchi/vlmkit-core/plugin/contract.ts";
|
|
3
|
-
|
|
3
|
+
// src/gates/crater.gate.ts
|
|
4
4
|
/**
|
|
5
5
|
* `check crater` as a gate definition, owned by the package that owns the
|
|
6
6
|
* Crater client.
|
|
@@ -99,5 +99,4 @@ const captureGatesPlugin = definePlugin({
|
|
|
99
99
|
name: "@mizchi/vlmkit-capture",
|
|
100
100
|
gates: [craterGate]
|
|
101
101
|
});
|
|
102
|
-
//#endregion
|
|
103
102
|
export { captureGatesPlugin, captureGatesPlugin as default, craterGate };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +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
1
|
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
2
|
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
3
|
import { diagnoseSandboxLaunchFailure, formatPlaywrightLaunchError, isPlaywrightSandboxRestrictionError } from "./playwright-launch-error.mjs";
|
|
4
|
+
import { CloudflareCrawlRecord, CloudflareCrawlRecordStatus, CloudflareCrawlRequest, CloudflareCrawlResult, CloudflareCrawlRoute, CloudflareCrawlStartResult, CloudflareQuickAction, CloudflareQuickActionEndpointInput, CloudflareQuickActionsConfig, CloudflareQuickActionsEnv, CloudflareScreenshotRequest, CloudflareScreenshotResult, buildCloudflareQuickActionEndpoint, createCloudflareQuickActionsClient, extractCloudflareCrawlRoutes, resolveCloudflareQuickActionsConfig } from "./cloudflare-quick-actions.mjs";
|
|
10
5
|
import { AnalyzedReport, FailedTest, ReportStats, analyzeReport, collectScreenshots, formatStats } from "./playwright-analyzer.mjs";
|
|
11
6
|
import { PrescannerResolvedBy, PrescannerTrialResolution, PrescannerTrialSummary, hasAnyDetectionSignal, hasCraterPrescanSignal, resolvePrescannerTrial, summarizePrescannerTrials } from "./prescanner.mjs";
|
|
7
|
+
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";
|
|
8
|
+
import { CRATER_WASM_MODULE_ENV, CraterBoxRect, CraterLayoutDiagnostics, CraterLayoutNode, CraterLayoutRootBox, CraterWasmLayoutBackend, CraterWasmModule, CraterWasmRenderRequest, CraterWasmRenderResult, CraterWasmViewport, LoadCraterWasmModuleOptions, createCraterWasmLayoutBackend, loadCraterWasmModule, normalizeCraterLayoutJson, summarizeCraterLayout } from "./crater-wasm.mjs";
|
|
9
|
+
import { CraterSmokeCheck, CraterSmokeClient, CraterSmokeReport, CraterSmokeStatus, formatCraterSmokeReport, runCraterBidiSmoke } from "./crater-smoke.mjs";
|
|
10
|
+
import { ViewportDetectionResult } from "./detection-types.mjs";
|
|
11
|
+
import { BatchPrescanOptions, BatchPrescanRequest, BatchPrescanResult, hasAnyBatchPrescanSignal, mutationsForPropertyRemoval, mutationsForSelectorBlockRemoval, runBatchPrescan } from "./batch-prescan.mjs";
|
|
12
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, diagnoseSandboxLaunchFailure, 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
CHANGED
|
@@ -1,11 +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
1
|
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
2
|
import { discoverViewports, discoverViewportsViaCrater, discoverViewportsWithBackend, extractBreakpoints, extractBreakpointsFromHtml, extractBreakpointsFromHtmlWithStylesheets, extractResponsiveBreakpointsFromHtml, extractResponsiveBreakpointsFromHtmlWithStylesheets, extractStylesheetHrefsFromHtml, generateViewports, mergeResponsiveBreakpoints, toResponsiveBreakpoints } from "./viewport-discovery.mjs";
|
|
8
3
|
import { diagnoseSandboxLaunchFailure, formatPlaywrightLaunchError, isPlaywrightSandboxRestrictionError } from "./playwright-launch-error.mjs";
|
|
4
|
+
import { buildCloudflareQuickActionEndpoint, createCloudflareQuickActionsClient, extractCloudflareCrawlRoutes, resolveCloudflareQuickActionsConfig } from "./cloudflare-quick-actions.mjs";
|
|
9
5
|
import { analyzeReport, collectScreenshots, formatStats } from "./playwright-analyzer.mjs";
|
|
10
6
|
import { hasAnyDetectionSignal, hasCraterPrescanSignal, resolvePrescannerTrial, summarizePrescannerTrials } from "./prescanner.mjs";
|
|
7
|
+
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";
|
|
8
|
+
import { CRATER_WASM_MODULE_ENV, createCraterWasmLayoutBackend, loadCraterWasmModule, normalizeCraterLayoutJson, summarizeCraterLayout } from "./crater-wasm.mjs";
|
|
9
|
+
import { formatCraterSmokeReport, runCraterBidiSmoke } from "./crater-smoke.mjs";
|
|
10
|
+
import { hasAnyBatchPrescanSignal, mutationsForPropertyRemoval, mutationsForSelectorBlockRemoval, runBatchPrescan } from "./batch-prescan.mjs";
|
|
11
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, diagnoseSandboxLaunchFailure, 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 };
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { Attachment, VrtSnapshot } from "@mizchi/vlmkit-core/types.ts";
|
|
2
|
-
|
|
3
|
-
//#region src/playwright-analyzer.d.ts
|
|
4
|
-
interface AnalyzedReport {
|
|
2
|
+
export interface AnalyzedReport {
|
|
5
3
|
snapshots: VrtSnapshot[];
|
|
6
4
|
failedTests: FailedTest[];
|
|
7
5
|
stats: ReportStats;
|
|
8
6
|
}
|
|
9
|
-
interface FailedTest {
|
|
7
|
+
export interface FailedTest {
|
|
10
8
|
testId: string;
|
|
11
9
|
title: string;
|
|
12
10
|
project: string;
|
|
13
11
|
errors: string[];
|
|
14
12
|
attachments: Attachment[];
|
|
15
13
|
}
|
|
16
|
-
interface ReportStats {
|
|
14
|
+
export interface ReportStats {
|
|
17
15
|
total: number;
|
|
18
16
|
passed: number;
|
|
19
17
|
failed: number;
|
|
@@ -24,15 +22,13 @@ interface ReportStats {
|
|
|
24
22
|
/**
|
|
25
23
|
* Playwright JSON レポートを読み込み、構造化された VRT データに変換する
|
|
26
24
|
*/
|
|
27
|
-
declare function analyzeReport(reportPath: string): Promise<AnalyzedReport>;
|
|
25
|
+
export declare function analyzeReport(reportPath: string): Promise<AnalyzedReport>;
|
|
28
26
|
/**
|
|
29
27
|
* test-results ディレクトリからスクリーンショットファイルを収集し、
|
|
30
28
|
* ベースラインとの対応関係を構築する
|
|
31
29
|
*/
|
|
32
|
-
declare function collectScreenshots(resultsDir: string, baselineDir: string): Promise<VrtSnapshot[]>;
|
|
30
|
+
export declare function collectScreenshots(resultsDir: string, baselineDir: string): Promise<VrtSnapshot[]>;
|
|
33
31
|
/**
|
|
34
32
|
* レポートの統計サマリを人間可読な文字列にする
|
|
35
33
|
*/
|
|
36
|
-
declare function formatStats(stats: ReportStats): string;
|
|
37
|
-
//#endregion
|
|
38
|
-
export { AnalyzedReport, FailedTest, ReportStats, analyzeReport, collectScreenshots, formatStats };
|
|
34
|
+
export declare function formatStats(stats: ReportStats): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { basename, join, relative } from "node:path";
|
|
2
2
|
import { readFile, readdir, stat } from "node:fs/promises";
|
|
3
|
-
|
|
3
|
+
// src/playwright-analyzer.ts
|
|
4
4
|
/**
|
|
5
5
|
* Playwright JSON レポートを読み込み、構造化された VRT データに変換する
|
|
6
6
|
*/
|
|
@@ -113,5 +113,4 @@ function formatStats(stats) {
|
|
|
113
113
|
`Duration: ${(stats.duration / 1e3).toFixed(1)}s`
|
|
114
114
|
].join("\n");
|
|
115
115
|
}
|
|
116
|
-
//#endregion
|
|
117
116
|
export { analyzeReport, collectScreenshots, formatStats };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
declare function isPlaywrightSandboxRestrictionError(error: unknown): boolean;
|
|
1
|
+
export declare function isPlaywrightSandboxRestrictionError(error: unknown): boolean;
|
|
3
2
|
/**
|
|
4
3
|
* The `diagnose` hook for `launchBrowser` / `withBrowser`.
|
|
5
4
|
*
|
|
@@ -13,9 +12,7 @@ declare function isPlaywrightSandboxRestrictionError(error: unknown): boolean;
|
|
|
13
12
|
* throw new Error(formatPlaywrightLaunchError(e, …))` block that had been copied
|
|
14
13
|
* to 4 launch sites (css-challenge x2, css-challenge-core, migration-compare).
|
|
15
14
|
*/
|
|
16
|
-
declare function diagnoseSandboxLaunchFailure(error: unknown): string | null;
|
|
17
|
-
declare function formatPlaywrightLaunchError(error: unknown, options?: {
|
|
15
|
+
export declare function diagnoseSandboxLaunchFailure(error: unknown): string | null;
|
|
16
|
+
export declare function formatPlaywrightLaunchError(error: unknown, options?: {
|
|
18
17
|
commandHint?: string;
|
|
19
|
-
}): string;
|
|
20
|
-
//#endregion
|
|
21
|
-
export { diagnoseSandboxLaunchFailure, formatPlaywrightLaunchError, isPlaywrightSandboxRestrictionError };
|
|
18
|
+
}): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/playwright-launch-error.ts
|
|
2
2
|
const FORMATTED_SANDBOX_MARKER = "Codex/macOS sandbox restriction";
|
|
3
3
|
const RAW_SANDBOX_SIGNAL_PATTERNS = [
|
|
4
4
|
"Operation not permitted",
|
|
@@ -35,7 +35,8 @@ function formatPlaywrightLaunchError(error, options = {}) {
|
|
|
35
35
|
const message = normalizeErrorMessage(error);
|
|
36
36
|
if (!isPlaywrightSandboxRestrictionError(error)) return message;
|
|
37
37
|
if (message.includes(FORMATTED_SANDBOX_MARKER)) return message;
|
|
38
|
-
|
|
38
|
+
const hint = ` ${!options.commandHint ? "Re-run outside the Codex sandbox or in CI" : /re-?run outside the codex sandbox/i.test(options.commandHint) ? options.commandHint : `Re-run outside the Codex sandbox or ${options.commandHint}`}.`;
|
|
39
|
+
const originalLine = message.split("\n").find((line) => line.trim().length > 0) ?? message;
|
|
40
|
+
return `Playwright browser launch is blocked by a ${FORMATTED_SANDBOX_MARKER}. Chromium itself is likely fine.${hint}\nOriginal error: ${originalLine}`;
|
|
39
41
|
}
|
|
40
|
-
//#endregion
|
|
41
42
|
export { diagnoseSandboxLaunchFailure, formatPlaywrightLaunchError, isPlaywrightSandboxRestrictionError };
|
package/dist/prescanner.d.mts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { ViewportDetectionResult } from "./detection-types.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/prescanner.d.ts
|
|
4
|
-
type PrescannerResolvedBy = "crater" | "chromium" | "none";
|
|
2
|
+
export type PrescannerResolvedBy = "crater" | "chromium" | "none";
|
|
5
3
|
/** Which Crater metadata signal first fired for a trial resolved by crater. */
|
|
6
|
-
type PrescannerCraterSignal = "paint-tree" | "computed-style" | "forced-state" | "visual" | "none";
|
|
7
|
-
interface PrescannerTrialResolution {
|
|
4
|
+
export type PrescannerCraterSignal = "paint-tree" | "computed-style" | "forced-state" | "visual" | "none";
|
|
5
|
+
export interface PrescannerTrialResolution {
|
|
8
6
|
craterDetected: boolean;
|
|
9
7
|
fallbackUsed: boolean;
|
|
10
8
|
finalDetected: boolean;
|
|
@@ -14,7 +12,7 @@ interface PrescannerTrialResolution {
|
|
|
14
12
|
/** First crater signal type that fired (paint-tree wins over computed-style → forced-state → visual). */
|
|
15
13
|
craterSignal: PrescannerCraterSignal;
|
|
16
14
|
}
|
|
17
|
-
interface PrescannerTrialSummary {
|
|
15
|
+
export interface PrescannerTrialSummary {
|
|
18
16
|
total: number;
|
|
19
17
|
detected: number;
|
|
20
18
|
craterResolved: number;
|
|
@@ -31,9 +29,7 @@ interface PrescannerTrialSummary {
|
|
|
31
29
|
visual: number;
|
|
32
30
|
};
|
|
33
31
|
}
|
|
34
|
-
declare function hasCraterPrescanSignal(viewports: ViewportDetectionResult[]): boolean;
|
|
35
|
-
declare function hasAnyDetectionSignal(viewports: ViewportDetectionResult[]): boolean;
|
|
36
|
-
declare function resolvePrescannerTrial(craterViewports: ViewportDetectionResult[], chromiumViewports?: ViewportDetectionResult[]): PrescannerTrialResolution;
|
|
37
|
-
declare function summarizePrescannerTrials(resolutions: PrescannerTrialResolution[]): PrescannerTrialSummary;
|
|
38
|
-
//#endregion
|
|
39
|
-
export { PrescannerCraterSignal, PrescannerResolvedBy, PrescannerTrialResolution, PrescannerTrialSummary, hasAnyDetectionSignal, hasCraterPrescanSignal, resolvePrescannerTrial, summarizePrescannerTrials };
|
|
32
|
+
export declare function hasCraterPrescanSignal(viewports: ViewportDetectionResult[]): boolean;
|
|
33
|
+
export declare function hasAnyDetectionSignal(viewports: ViewportDetectionResult[]): boolean;
|
|
34
|
+
export declare function resolvePrescannerTrial(craterViewports: ViewportDetectionResult[], chromiumViewports?: ViewportDetectionResult[]): PrescannerTrialResolution;
|
|
35
|
+
export declare function summarizePrescannerTrials(resolutions: PrescannerTrialResolution[]): PrescannerTrialSummary;
|
package/dist/prescanner.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/prescanner.ts
|
|
2
2
|
function hasCraterPrescanSignal(viewports) {
|
|
3
3
|
return viewports.some((viewport) => viewport.visualDiffDetected || viewport.computedStyleDiffCount > 0 || viewport.hoverDiffDetected || viewport.paintTreeDiffCount > 0);
|
|
4
4
|
}
|
|
@@ -57,5 +57,4 @@ function summarizePrescannerTrials(resolutions) {
|
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
//#endregion
|
|
61
60
|
export { hasAnyDetectionSignal, hasCraterPrescanSignal, resolvePrescannerTrial, summarizePrescannerTrials };
|
package/dist/route-capture.d.mts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { CaptureRoute } from "./capture-config.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/route-capture.d.ts
|
|
4
2
|
/** The viewport the old `vrt-desktop` project used, and vlmkit's default elsewhere. */
|
|
5
|
-
declare const DEFAULT_CAPTURE_VIEWPORT: {
|
|
3
|
+
export declare const DEFAULT_CAPTURE_VIEWPORT: {
|
|
6
4
|
readonly width: 1280;
|
|
7
5
|
readonly height: 720;
|
|
8
6
|
};
|
|
9
|
-
interface RouteCaptureOptions {
|
|
7
|
+
export interface RouteCaptureOptions {
|
|
10
8
|
baseUrl: string;
|
|
11
9
|
routes: readonly CaptureRoute[];
|
|
12
10
|
/** Directory that receives `<name>.png` and `<name>.a11y.json`. */
|
|
@@ -18,7 +16,7 @@ interface RouteCaptureOptions {
|
|
|
18
16
|
/** Settling delay after load, matching the spec's `waitForTimeout(500)`. */
|
|
19
17
|
settleMs?: number;
|
|
20
18
|
}
|
|
21
|
-
interface RouteCaptureEntry {
|
|
19
|
+
export interface RouteCaptureEntry {
|
|
22
20
|
name: string;
|
|
23
21
|
url: string;
|
|
24
22
|
screenshotPath: string;
|
|
@@ -39,12 +37,12 @@ interface RouteCaptureEntry {
|
|
|
39
37
|
/** `waitFor` was given and never matched — the capture happened anyway, as before. */
|
|
40
38
|
waitForTimedOut?: boolean;
|
|
41
39
|
}
|
|
42
|
-
interface RouteCaptureFailure {
|
|
40
|
+
export interface RouteCaptureFailure {
|
|
43
41
|
name: string;
|
|
44
42
|
url: string;
|
|
45
43
|
error: string;
|
|
46
44
|
}
|
|
47
|
-
interface RouteCaptureResult {
|
|
45
|
+
export interface RouteCaptureResult {
|
|
48
46
|
viewport: {
|
|
49
47
|
width: number;
|
|
50
48
|
height: number;
|
|
@@ -56,7 +54,7 @@ interface RouteCaptureResult {
|
|
|
56
54
|
/** Captured, but the server did not return 2xx — an error page about to become a baseline. */
|
|
57
55
|
notOk: RouteCaptureEntry[];
|
|
58
56
|
}
|
|
59
|
-
declare function captureRoutes(options: RouteCaptureOptions): Promise<RouteCaptureResult>;
|
|
57
|
+
export declare function captureRoutes(options: RouteCaptureOptions): Promise<RouteCaptureResult>;
|
|
60
58
|
interface CdpAxNode {
|
|
61
59
|
nodeId: string;
|
|
62
60
|
parentId?: string;
|
|
@@ -82,6 +80,5 @@ interface CdpAxNode {
|
|
|
82
80
|
* are compared against baselines captured by the old path, so changing the shape here would
|
|
83
81
|
* report every baseline as a semantic diff.
|
|
84
82
|
*/
|
|
85
|
-
declare function cdpNodesToTree(nodes: readonly CdpAxNode[]): unknown;
|
|
86
|
-
|
|
87
|
-
export { DEFAULT_CAPTURE_VIEWPORT, RouteCaptureEntry, RouteCaptureFailure, RouteCaptureOptions, RouteCaptureResult, captureRoutes, cdpNodesToTree };
|
|
83
|
+
export declare function cdpNodesToTree(nodes: readonly CdpAxNode[]): unknown;
|
|
84
|
+
export {};
|
package/dist/route-capture.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { withBrowser } from "@mizchi/vlmkit-core/browser-launch.ts";
|
|
3
3
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
4
|
-
|
|
4
|
+
// src/route-capture.ts
|
|
5
5
|
/**
|
|
6
6
|
* Route capture — screenshots + a11y trees for `vlmkit workflow init` / `workflow capture`,
|
|
7
7
|
* in this process.
|
|
@@ -194,5 +194,4 @@ function cdpNodesToTree(nodes) {
|
|
|
194
194
|
children: []
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
|
-
//#endregion
|
|
198
197
|
export { DEFAULT_CAPTURE_VIEWPORT, captureRoutes, cdpNodesToTree };
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
//#region src/viewport-discovery.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Viewport Discovery -- discover breakpoints from CSS and generate boundary-check viewports
|
|
4
3
|
*
|
|
5
4
|
* Extracts breakpoints from @media queries and generates viewport lists
|
|
6
5
|
* at boundary +/-1px + random samples within ranges (quickcheck-style).
|
|
7
6
|
*/
|
|
8
|
-
interface Breakpoint {
|
|
7
|
+
export interface Breakpoint {
|
|
9
8
|
value: number;
|
|
10
9
|
type: "min-width" | "max-width";
|
|
11
10
|
raw: string;
|
|
12
11
|
}
|
|
13
|
-
interface ResponsiveBreakpoint {
|
|
12
|
+
export interface ResponsiveBreakpoint {
|
|
14
13
|
axis: "width";
|
|
15
14
|
op: "ge" | "gt" | "le" | "lt";
|
|
16
15
|
valuePx: number;
|
|
@@ -20,8 +19,8 @@ interface ResponsiveBreakpoint {
|
|
|
20
19
|
ruleCount: number;
|
|
21
20
|
}
|
|
22
21
|
/** Where a viewport candidate originated. */
|
|
23
|
-
type ViewportSource = "standard" | "regex-boundary" | "regex-sample" | "crater-required" | "crater-rule-map";
|
|
24
|
-
interface ViewportSpec {
|
|
22
|
+
export type ViewportSource = "standard" | "regex-boundary" | "regex-sample" | "crater-required" | "crater-rule-map";
|
|
23
|
+
export interface ViewportSpec {
|
|
25
24
|
width: number;
|
|
26
25
|
height: number;
|
|
27
26
|
label: string;
|
|
@@ -33,7 +32,7 @@ interface ViewportSpec {
|
|
|
33
32
|
*/
|
|
34
33
|
source?: ViewportSource;
|
|
35
34
|
}
|
|
36
|
-
interface DiscoveryResult {
|
|
35
|
+
export interface DiscoveryResult {
|
|
37
36
|
breakpoints: Breakpoint[];
|
|
38
37
|
responsiveBreakpoints: ResponsiveBreakpoint[];
|
|
39
38
|
viewports: ViewportSpec[];
|
|
@@ -48,16 +47,16 @@ interface DiscoveryResult {
|
|
|
48
47
|
}
|
|
49
48
|
type ViewportBreakpoint = Breakpoint | ResponsiveBreakpoint;
|
|
50
49
|
/** Extract all breakpoints from CSS text */
|
|
51
|
-
declare function extractBreakpoints(css: string): Breakpoint[];
|
|
50
|
+
export declare function extractBreakpoints(css: string): Breakpoint[];
|
|
52
51
|
/** Extract breakpoints from HTML <style> */
|
|
53
|
-
declare function extractBreakpointsFromHtml(html: string): Breakpoint[];
|
|
54
|
-
declare function extractStylesheetHrefsFromHtml(html: string): string[];
|
|
55
|
-
declare function extractBreakpointsFromHtmlWithStylesheets(html: string, stylesheetTexts: string[]): Breakpoint[];
|
|
56
|
-
declare function toResponsiveBreakpoints(breakpoints: ViewportBreakpoint[]): ResponsiveBreakpoint[];
|
|
57
|
-
declare function mergeResponsiveBreakpoints(...collections: ViewportBreakpoint[][]): ResponsiveBreakpoint[];
|
|
58
|
-
declare function extractResponsiveBreakpointsFromHtml(html: string): ResponsiveBreakpoint[];
|
|
59
|
-
declare function extractResponsiveBreakpointsFromHtmlWithStylesheets(html: string, stylesheetTexts: string[]): ResponsiveBreakpoint[];
|
|
60
|
-
interface ViewportOptions {
|
|
52
|
+
export declare function extractBreakpointsFromHtml(html: string): Breakpoint[];
|
|
53
|
+
export declare function extractStylesheetHrefsFromHtml(html: string): string[];
|
|
54
|
+
export declare function extractBreakpointsFromHtmlWithStylesheets(html: string, stylesheetTexts: string[]): Breakpoint[];
|
|
55
|
+
export declare function toResponsiveBreakpoints(breakpoints: ViewportBreakpoint[]): ResponsiveBreakpoint[];
|
|
56
|
+
export declare function mergeResponsiveBreakpoints(...collections: ViewportBreakpoint[][]): ResponsiveBreakpoint[];
|
|
57
|
+
export declare function extractResponsiveBreakpointsFromHtml(html: string): ResponsiveBreakpoint[];
|
|
58
|
+
export declare function extractResponsiveBreakpointsFromHtmlWithStylesheets(html: string, stylesheetTexts: string[]): ResponsiveBreakpoint[];
|
|
59
|
+
export interface ViewportOptions {
|
|
61
60
|
height?: number;
|
|
62
61
|
maxViewports?: number;
|
|
63
62
|
randomSamples?: number;
|
|
@@ -72,12 +71,12 @@ interface ViewportOptions {
|
|
|
72
71
|
* - boundary -1px: just before breakpoint activates
|
|
73
72
|
* - (optional) random samples within range
|
|
74
73
|
*/
|
|
75
|
-
declare function generateViewports(breakpoints: ViewportBreakpoint[], options?: ViewportOptions): ViewportSpec[];
|
|
74
|
+
export declare function generateViewports(breakpoints: ViewportBreakpoint[], options?: ViewportOptions): ViewportSpec[];
|
|
76
75
|
/**
|
|
77
76
|
* Discover breakpoints from HTML and generate boundary-check viewports.
|
|
78
77
|
*/
|
|
79
|
-
declare function discoverViewports(html: string, options?: ViewportOptions): DiscoveryResult;
|
|
80
|
-
interface CraterViewportSource {
|
|
78
|
+
export declare function discoverViewports(html: string, options?: ViewportOptions): DiscoveryResult;
|
|
79
|
+
export interface CraterViewportSource {
|
|
81
80
|
getRequiredTestViewports(): Promise<{
|
|
82
81
|
viewports: Array<{
|
|
83
82
|
width: number;
|
|
@@ -97,7 +96,7 @@ interface CraterViewportSource {
|
|
|
97
96
|
* breakpoints the renderer itself determined are load-bearing for the
|
|
98
97
|
* current document. Falls back gracefully when either RPC fails.
|
|
99
98
|
*/
|
|
100
|
-
declare function discoverViewportsViaCrater(client: CraterViewportSource, options?: ViewportOptions): Promise<{
|
|
99
|
+
export declare function discoverViewportsViaCrater(client: CraterViewportSource, options?: ViewportOptions): Promise<{
|
|
101
100
|
viewports: ViewportSpec[];
|
|
102
101
|
widthsSeen: Set<number>;
|
|
103
102
|
}>;
|
|
@@ -107,8 +106,7 @@ declare function discoverViewportsViaCrater(client: CraterViewportSource, option
|
|
|
107
106
|
* didn't surface, and tag each viewport with its `source`. The returned
|
|
108
107
|
* `backend` field tells downstream reports which path supplied the list.
|
|
109
108
|
*/
|
|
110
|
-
declare function discoverViewportsWithBackend(html: string, options?: ViewportOptions & {
|
|
109
|
+
export declare function discoverViewportsWithBackend(html: string, options?: ViewportOptions & {
|
|
111
110
|
craterClient?: CraterViewportSource | null;
|
|
112
111
|
}): Promise<DiscoveryResult>;
|
|
113
|
-
|
|
114
|
-
export { Breakpoint, CraterViewportSource, DiscoveryResult, ResponsiveBreakpoint, ViewportOptions, ViewportSource, ViewportSpec, discoverViewports, discoverViewportsViaCrater, discoverViewportsWithBackend, extractBreakpoints, extractBreakpointsFromHtml, extractBreakpointsFromHtmlWithStylesheets, extractResponsiveBreakpointsFromHtml, extractResponsiveBreakpointsFromHtmlWithStylesheets, extractStylesheetHrefsFromHtml, generateViewports, mergeResponsiveBreakpoints, toResponsiveBreakpoints };
|
|
112
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/viewport-discovery.ts
|
|
2
2
|
const MEDIA_PATTERN = /@media\s+([^{]+)\{/g;
|
|
3
3
|
const WIDTH_PATTERN = /\(\s*(min|max)-width\s*:\s*([\d.]+)(px|rem|em)\s*\)/g;
|
|
4
4
|
/** Extract all breakpoints from CSS text */
|
|
@@ -290,5 +290,4 @@ async function discoverViewportsWithBackend(html, options = {}) {
|
|
|
290
290
|
backend: usedFallback ? "hybrid" : "crater"
|
|
291
291
|
};
|
|
292
292
|
}
|
|
293
|
-
//#endregion
|
|
294
293
|
export { discoverViewports, discoverViewportsViaCrater, discoverViewportsWithBackend, extractBreakpoints, extractBreakpointsFromHtml, extractBreakpointsFromHtmlWithStylesheets, extractResponsiveBreakpointsFromHtml, extractResponsiveBreakpointsFromHtmlWithStylesheets, extractStylesheetHrefsFromHtml, generateViewports, mergeResponsiveBreakpoints, toResponsiveBreakpoints };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mizchi/vlmkit-capture",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "Playwright + Crater capture infrastructure for VRT — viewport discovery, multi-route capture, prescanner.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "mizchi",
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"pngjs": "^7.0.0",
|
|
40
|
-
"ws": "^8.
|
|
41
|
-
"@mizchi/vlmkit-core": "0.
|
|
40
|
+
"ws": "^8.23.0",
|
|
41
|
+
"@mizchi/vlmkit-core": "0.28.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"playwright": ">=1.61 <2"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
|
-
"build": "pnpm --dir ../.. exec
|
|
48
|
-
"test": "pnpm --dir ../.. exec
|
|
47
|
+
"build": "pnpm --dir ../.. exec vp pack --filter @mizchi/vlmkit-capture",
|
|
48
|
+
"test": "pnpm --dir ../.. exec vp test run packages/vlmkit-capture/src"
|
|
49
49
|
}
|
|
50
50
|
}
|