@mizchi/vlmkit-core 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/a11y-semantic.d.mts +6 -10
- package/dist/a11y-semantic.mjs +3 -4
- package/dist/animated-image.d.mts +27 -0
- package/dist/animated-image.mjs +112 -0
- package/dist/apng.d.mts +5 -9
- package/dist/apng.mjs +6 -7
- package/dist/arg-reader.d.mts +9 -12
- package/dist/arg-reader.mjs +1 -2
- package/dist/auth-state.d.mts +6 -9
- package/dist/auth-state.mjs +1 -2
- package/dist/authored-style-capture.d.mts +7 -10
- package/dist/authored-style-capture.mjs +1 -2
- package/dist/authored-style-diff.d.mts +8 -12
- package/dist/authored-style-diff.mjs +1 -2
- package/dist/bitmap-font.d.mts +7 -10
- package/dist/bitmap-font.mjs +1 -2
- package/dist/browser-launch.d.mts +7 -11
- package/dist/browser-launch.mjs +1 -2
- package/dist/cli-args.d.mts +8 -11
- package/dist/cli-args.mjs +1 -2
- package/dist/cli-error.d.mts +10 -13
- package/dist/cli-error.mjs +2 -3
- package/dist/computed-style-capture.d.mts +20 -23
- package/dist/computed-style-capture.mjs +4 -5
- package/dist/computed-style-diff.d.mts +8 -11
- package/dist/computed-style-diff.mjs +2 -3
- package/dist/diff-regions.d.mts +3 -7
- package/dist/diff-regions.mjs +1 -2
- package/dist/dom-equivalence.d.mts +5 -8
- package/dist/dom-equivalence.mjs +1 -2
- package/dist/dom-position-styles.d.mts +14 -15
- package/dist/dom-position-styles.mjs +4 -5
- package/dist/element-compare.d.mts +8 -9
- package/dist/element-compare.mjs +5 -5
- package/dist/filmstrip.d.mts +60 -9
- package/dist/filmstrip.mjs +83 -12
- package/dist/gate-config.d.mts +18 -22
- package/dist/gate-config.mjs +8 -4
- package/dist/gate-exit.d.mts +5 -8
- package/dist/gate-exit.mjs +1 -2
- package/dist/gif.d.mts +41 -0
- package/dist/gif.mjs +73 -0
- package/dist/heatmap-regions.d.mts +4 -7
- package/dist/heatmap-regions.mjs +1 -2
- package/dist/heatmap.d.mts +21 -17
- package/dist/heatmap.mjs +23 -11
- package/dist/image-resize.d.mts +9 -12
- package/dist/image-resize.mjs +1 -2
- package/dist/image-timing.d.mts +57 -0
- package/dist/image-timing.mjs +166 -0
- package/dist/index.d.mts +14 -14
- package/dist/index.mjs +11 -11
- package/dist/mask.d.mts +5 -9
- package/dist/mask.mjs +1 -2
- package/dist/motion-spec.d.mts +97 -0
- package/dist/motion-spec.mjs +145 -0
- package/dist/navigation-redirect.d.mts +1 -4
- package/dist/navigation-redirect.mjs +1 -2
- package/dist/page-load.d.mts +40 -16
- package/dist/page-load.mjs +34 -5
- package/dist/page-open.d.mts +15 -15
- package/dist/page-open.mjs +4 -3
- package/dist/plugin/args.d.mts +16 -12
- package/dist/plugin/args.mjs +15 -4
- package/dist/plugin/browser.d.mts +3 -3
- package/dist/plugin/browser.mjs +2 -2
- package/dist/plugin/cli-entry.d.mts +1 -4
- package/dist/plugin/cli-entry.mjs +1 -2
- package/dist/plugin/contract.d.mts +17 -21
- package/dist/plugin/contract.mjs +1 -2
- package/dist/plugin/index.d.mts +6 -9
- package/dist/plugin/index.mjs +7 -8
- package/dist/plugin/load.d.mts +7 -11
- package/dist/plugin/load.mjs +1 -2
- package/dist/plugin/registry.d.mts +8 -12
- package/dist/plugin/registry.mjs +1 -2
- package/dist/plugin/rule-prose.d.mts +4 -8
- package/dist/plugin/rule-prose.mjs +1 -2
- package/dist/plugin/rule-tier.d.mts +7 -11
- package/dist/plugin/rule-tier.mjs +1 -2
- package/dist/plugin/rules.d.mts +18 -22
- package/dist/plugin/rules.mjs +1 -2
- package/dist/plugin/runner.d.mts +18 -21
- package/dist/plugin/runner.mjs +55 -6
- package/dist/png-decode.d.mts +17 -0
- package/dist/png-decode.mjs +160 -0
- package/dist/png-utils.d.mts +7 -10
- package/dist/png-utils.mjs +3 -3
- package/dist/project-config.d.mts +7 -10
- package/dist/project-config.mjs +1 -2
- package/dist/rect-overlap.d.mts +3 -6
- package/dist/rect-overlap.mjs +1 -2
- package/dist/region-shift.d.mts +3 -6
- package/dist/region-shift.mjs +1 -2
- package/dist/run-ledger.d.mts +10 -13
- package/dist/run-ledger.mjs +4 -4
- package/dist/stable-selector.d.mts +1 -4
- package/dist/stable-selector.mjs +1 -2
- package/dist/terminal-colors.d.mts +8 -11
- package/dist/terminal-colors.mjs +1 -2
- package/dist/text-rows.d.mts +10 -13
- package/dist/text-rows.mjs +1 -2
- package/dist/types.d.mts +87 -64
- package/dist/version.d.mts +1 -4
- package/dist/version.mjs +2 -3
- package/dist/video-decode.d.mts +144 -0
- package/dist/video-decode.mjs +939 -0
- package/dist/video-frames.d.mts +310 -0
- package/dist/video-frames.mjs +576 -0
- package/dist/webp.d.mts +7 -11
- package/dist/webp.mjs +3 -3
- package/package.json +7 -7
package/dist/heatmap.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { DiffIgnoreRegion, DiffRegionColorSample, DiffReport, ShiftRegion, VrtDiff, VrtSnapshot } from "./types.mjs";
|
|
1
|
+
import { DiffIgnoreRegion, DiffRegion, DiffRegionColorSample, DiffReport, ShiftRegion, VrtDiff, VrtSnapshot } from "./types.mjs";
|
|
2
2
|
import { PngData } from "./png-utils.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/heatmap.d.ts
|
|
5
3
|
/**
|
|
6
4
|
* Parse `"<x>,<y>,<w>x<h>"` (e.g. `"0,300,640x60"`) into an ignore rect.
|
|
7
5
|
*
|
|
@@ -13,14 +11,15 @@ import { PngData } from "./png-utils.mjs";
|
|
|
13
11
|
* Zero-area rects are rejected: `"0,0,0x0"` masks nothing, so accepting it
|
|
14
12
|
* would only ever mean the caller mistyped and got silence.
|
|
15
13
|
*/
|
|
16
|
-
declare function parseIgnoreRegionSpec(value: string): DiffIgnoreRegion;
|
|
14
|
+
export declare function parseIgnoreRegionSpec(value: string): DiffIgnoreRegion;
|
|
17
15
|
/**
|
|
18
16
|
* Compare two screenshots pixel-by-pixel and generate a diff heatmap.
|
|
19
17
|
*/
|
|
20
|
-
declare function compareScreenshots(snapshot: VrtSnapshot, opts?: {
|
|
18
|
+
export declare function compareScreenshots(snapshot: VrtSnapshot, opts?: {
|
|
21
19
|
threshold?: number;
|
|
22
20
|
outputDir?: string;
|
|
23
|
-
skipHeatmap?: boolean;
|
|
21
|
+
skipHeatmap?: boolean;
|
|
22
|
+
/** Override the adaptive grid. See `adaptiveRegionCellSize`. */
|
|
24
23
|
regionCellSize?: number;
|
|
25
24
|
/**
|
|
26
25
|
* Rectangles that are non-deterministic by construction (particles, a
|
|
@@ -51,7 +50,12 @@ declare function compareScreenshots(snapshot: VrtSnapshot, opts?: {
|
|
|
51
50
|
* continuous function would shift region geometry on nearly every existing image, and
|
|
52
51
|
* region bboxes appear in baselines, approvals and reports.
|
|
53
52
|
*/
|
|
54
|
-
declare function adaptiveRegionCellSize(width: number, height: number): number;
|
|
53
|
+
export declare function adaptiveRegionCellSize(width: number, height: number): number;
|
|
54
|
+
/** Edge-only test over a region: `@mizchi/vlmkit-judge/edge-noise.ts`. */
|
|
55
|
+
export declare function regionDelta(baseline: PngData, current: PngData, region: DiffRegion): {
|
|
56
|
+
max: number;
|
|
57
|
+
edgeOnly: boolean;
|
|
58
|
+
};
|
|
55
59
|
/**
|
|
56
60
|
* Sample a region's color pair from the pixels that actually differ.
|
|
57
61
|
*
|
|
@@ -66,7 +70,7 @@ declare function adaptiveRegionCellSize(width: number, height: number): number;
|
|
|
66
70
|
* antialiasing blends, so we additionally surface the single highest-delta
|
|
67
71
|
* pixel pair as `peak` (draft 11).
|
|
68
72
|
*/
|
|
69
|
-
declare function sampleRegionColorSample(baseline: PngData, current: PngData, region: {
|
|
73
|
+
export declare function sampleRegionColorSample(baseline: PngData, current: PngData, region: {
|
|
70
74
|
x: number;
|
|
71
75
|
y: number;
|
|
72
76
|
width: number;
|
|
@@ -83,7 +87,7 @@ declare function sampleRegionColorSample(baseline: PngData, current: PngData, re
|
|
|
83
87
|
*
|
|
84
88
|
* Exported for unit testing.
|
|
85
89
|
*/
|
|
86
|
-
declare function detectBandShifts(baseline: {
|
|
90
|
+
export declare function detectBandShifts(baseline: {
|
|
87
91
|
data: Uint8Array;
|
|
88
92
|
width: number;
|
|
89
93
|
height: number;
|
|
@@ -100,18 +104,20 @@ declare function detectBandShifts(baseline: {
|
|
|
100
104
|
* Generate a comprehensive diff report including clustering, shift detection,
|
|
101
105
|
* and region classification. Compatible with mizchi/pixelmatch 0.5.0 DiffReport format.
|
|
102
106
|
*/
|
|
103
|
-
declare function generateDiffReport(snapshot: VrtSnapshot, opts?: {
|
|
107
|
+
export declare function generateDiffReport(snapshot: VrtSnapshot, opts?: {
|
|
104
108
|
threshold?: number;
|
|
105
109
|
outputDir?: string;
|
|
106
110
|
skipHeatmap?: boolean;
|
|
107
|
-
detectShift?: boolean;
|
|
108
|
-
|
|
111
|
+
detectShift?: boolean;
|
|
112
|
+
/** Override the adaptive grid. See `adaptiveRegionCellSize`. */
|
|
113
|
+
regionCellSize?: number;
|
|
114
|
+
/** See `compareScreenshots`. Shift detection is NOT masked — see below. */
|
|
109
115
|
ignoreRegions?: DiffIgnoreRegion[];
|
|
110
116
|
}): Promise<DiffReport | null>;
|
|
111
117
|
/**
|
|
112
118
|
* Whiteout detection: checks if most of the image is white (or a single color).
|
|
113
119
|
*/
|
|
114
|
-
declare function detectWhiteout(data: PngData, opts?: {
|
|
120
|
+
export declare function detectWhiteout(data: PngData, opts?: {
|
|
115
121
|
threshold?: number;
|
|
116
122
|
}): {
|
|
117
123
|
isWhiteout: boolean;
|
|
@@ -120,11 +126,9 @@ declare function detectWhiteout(data: PngData, opts?: {
|
|
|
120
126
|
/**
|
|
121
127
|
* Empty content detection: checks if the image has low entropy.
|
|
122
128
|
*/
|
|
123
|
-
declare function detectEmptyContent(data: PngData, opts?: {
|
|
129
|
+
export declare function detectEmptyContent(data: PngData, opts?: {
|
|
124
130
|
threshold?: number;
|
|
125
131
|
}): {
|
|
126
132
|
isEmpty: boolean;
|
|
127
133
|
uniqueColors: number;
|
|
128
|
-
};
|
|
129
|
-
//#endregion
|
|
130
|
-
export { adaptiveRegionCellSize, compareScreenshots, detectBandShifts, detectEmptyContent, detectWhiteout, generateDiffReport, parseIgnoreRegionSpec, sampleRegionColorSample };
|
|
134
|
+
};
|
package/dist/heatmap.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { cropImage, decodePng, encodePng } from "./png-utils.mjs";
|
|
2
2
|
import { estimateRegionShift } from "./region-shift.mjs";
|
|
3
|
-
|
|
3
|
+
import { edgeOnlyDelta } from "@mizchi/vlmkit-judge/edge-noise.ts";
|
|
4
|
+
// src/heatmap.ts
|
|
4
5
|
/**
|
|
5
6
|
* Colour written into the heatmap over ignored pixels.
|
|
6
7
|
*
|
|
@@ -270,8 +271,15 @@ function attachRegionColorSamples(regions, baseline, current) {
|
|
|
270
271
|
for (const region of regions) {
|
|
271
272
|
const sample = sampleRegionColorSample(baseline, current, region);
|
|
272
273
|
if (sample) region.colorSample = sample;
|
|
274
|
+
const delta = regionDelta(baseline, current, region);
|
|
275
|
+
region.maxChannelDelta = delta.max;
|
|
276
|
+
if (delta.edgeOnly) region.edgeOnly = true;
|
|
273
277
|
}
|
|
274
278
|
}
|
|
279
|
+
/** Edge-only test over a region: `@mizchi/vlmkit-judge/edge-noise.ts`. */
|
|
280
|
+
function regionDelta(baseline, current, region) {
|
|
281
|
+
return edgeOnlyDelta(baseline, current, region);
|
|
282
|
+
}
|
|
275
283
|
function attachRegionShiftEstimates(regions, baseline, current) {
|
|
276
284
|
for (const region of regions) {
|
|
277
285
|
if (region.regionType === "edge") continue;
|
|
@@ -558,8 +566,8 @@ function generateCompact(diffData, width, height, diffPixels, totalPixels, regio
|
|
|
558
566
|
const cellH = Math.ceil(height / gridSize);
|
|
559
567
|
const grid = Array.from({ length: gridSize }, () => new Array(gridSize).fill(0));
|
|
560
568
|
for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) if (diffData[(y * width + x) * 4 + 1] < 128) {
|
|
561
|
-
const gx = Math.min(Math.floor(x / cellW),
|
|
562
|
-
const gy = Math.min(Math.floor(y / cellH),
|
|
569
|
+
const gx = Math.min(Math.floor(x / cellW), 9);
|
|
570
|
+
const gy = Math.min(Math.floor(y / cellH), 9);
|
|
563
571
|
grid[gy][gx]++;
|
|
564
572
|
}
|
|
565
573
|
const lines = [`diff:${diffPixels}/${totalPixels}(${((1 - safeDiffRatio(diffPixels, totalPixels)) * 100).toFixed(0)}%match)`];
|
|
@@ -586,12 +594,17 @@ async function generateDiffReport(snapshot, opts = {}) {
|
|
|
586
594
|
globalShift = detectGlobalShift(r.resizedBaseline, r.resizedCurrent);
|
|
587
595
|
if (globalShift !== 0) {
|
|
588
596
|
compensated = compensatedDiffCount(r.resizedBaseline.data, r.resizedCurrent.data, r.width, r.height, globalShift, r.threshold);
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
597
|
+
if (compensated >= r.diffPixels) {
|
|
598
|
+
globalShift = 0;
|
|
599
|
+
compensated = r.diffPixels;
|
|
600
|
+
} else {
|
|
601
|
+
const bands = detectBandShifts(r.resizedBaseline, r.resizedCurrent);
|
|
602
|
+
shiftRegions = bands.length > 0 ? bands : [{
|
|
603
|
+
yStart: 0,
|
|
604
|
+
yEnd: r.height,
|
|
605
|
+
shift: globalShift
|
|
606
|
+
}];
|
|
607
|
+
}
|
|
595
608
|
}
|
|
596
609
|
}
|
|
597
610
|
const shiftOnly = regions.length > 0 && regions.every((rg) => rg.regionType === "shift" || rg.regionType === "edge");
|
|
@@ -651,5 +664,4 @@ function detectEmptyContent(data, opts = {}) {
|
|
|
651
664
|
uniqueColors: colorSet.size
|
|
652
665
|
};
|
|
653
666
|
}
|
|
654
|
-
|
|
655
|
-
export { adaptiveRegionCellSize, compareScreenshots, detectBandShifts, detectEmptyContent, detectWhiteout, generateDiffReport, parseIgnoreRegionSpec, sampleRegionColorSample };
|
|
667
|
+
export { adaptiveRegionCellSize, compareScreenshots, detectBandShifts, detectEmptyContent, detectWhiteout, generateDiffReport, parseIgnoreRegionSpec, regionDelta, sampleRegionColorSample };
|
package/dist/image-resize.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare const RESOLUTION_PRESETS: Record<ResolutionPreset, {
|
|
1
|
+
export type ResolutionPreset = "low" | "medium" | "high" | "full";
|
|
2
|
+
export declare const RESOLUTION_PRESETS: Record<ResolutionPreset, {
|
|
4
3
|
maxWidth: number;
|
|
5
4
|
maxHeight: number;
|
|
6
5
|
}>;
|
|
@@ -8,8 +7,8 @@ declare const RESOLUTION_PRESETS: Record<ResolutionPreset, {
|
|
|
8
7
|
* Select the optimal resolution preset for a given viewport width.
|
|
9
8
|
* Returns the smallest preset with at least half the viewport width.
|
|
10
9
|
*/
|
|
11
|
-
declare function resolveResolutionForViewport(viewportWidth: number, maxPreset?: ResolutionPreset): ResolutionPreset;
|
|
12
|
-
interface ResizeOptions {
|
|
10
|
+
export declare function resolveResolutionForViewport(viewportWidth: number, maxPreset?: ResolutionPreset): ResolutionPreset;
|
|
11
|
+
export interface ResizeOptions {
|
|
13
12
|
/** Preset or custom size */
|
|
14
13
|
resolution?: ResolutionPreset | {
|
|
15
14
|
maxWidth: number;
|
|
@@ -17,18 +16,16 @@ interface ResizeOptions {
|
|
|
17
16
|
};
|
|
18
17
|
}
|
|
19
18
|
/** Resize PNG buffer to fit within the given size. Preserves aspect ratio. */
|
|
20
|
-
declare function resizePngBuffer(pngBuffer: Buffer, options?: ResizeOptions): Buffer;
|
|
19
|
+
export declare function resizePngBuffer(pngBuffer: Buffer, options?: ResizeOptions): Buffer;
|
|
21
20
|
/** Read dimensions from PNG IHDR chunk (no full decode needed) */
|
|
22
|
-
declare function readPngDimensions(buf: Buffer): {
|
|
21
|
+
export declare function readPngDimensions(buf: Buffer): {
|
|
23
22
|
width: number;
|
|
24
23
|
height: number;
|
|
25
24
|
};
|
|
26
25
|
/** Resize a base64 PNG to the specified resolution. Returns base64. */
|
|
27
|
-
declare function resizeBase64Png(base64: string, options?: ResizeOptions): string;
|
|
26
|
+
export declare function resizeBase64Png(base64: string, options?: ResizeOptions): string;
|
|
28
27
|
/** Get image dimensions */
|
|
29
|
-
declare function getImageDimensions(base64: string): {
|
|
28
|
+
export declare function getImageDimensions(base64: string): {
|
|
30
29
|
width: number;
|
|
31
30
|
height: number;
|
|
32
|
-
};
|
|
33
|
-
//#endregion
|
|
34
|
-
export { RESOLUTION_PRESETS, ResizeOptions, ResolutionPreset, getImageDimensions, readPngDimensions, resizeBase64Png, resizePngBuffer, resolveResolutionForViewport };
|
|
31
|
+
};
|
package/dist/image-resize.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PNG } from "pngjs";
|
|
2
|
-
|
|
2
|
+
// src/image-resize.ts
|
|
3
3
|
/**
|
|
4
4
|
* Image resize + VLM optimization
|
|
5
5
|
*
|
|
@@ -88,5 +88,4 @@ function resizeBase64Png(base64, options = {}) {
|
|
|
88
88
|
function getImageDimensions(base64) {
|
|
89
89
|
return readPngDimensions(Buffer.from(base64, "base64"));
|
|
90
90
|
}
|
|
91
|
-
//#endregion
|
|
92
91
|
export { RESOLUTION_PRESETS, getImageDimensions, readPngDimensions, resizeBase64Png, resizePngBuffer, resolveResolutionForViewport };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How an animated GIF or APNG plays in a browser: each frame's delay as stored, how many times
|
|
3
|
+
* the animation plays, and the delays a browser actually holds.
|
|
4
|
+
*
|
|
5
|
+
* Measured on Chromium 141 and 149 (`docs/reports/2026-10-13-scan-video-v1.md`): a frame of 10ms
|
|
6
|
+
* or less is held 100ms, in a GIF and an APNG alike; longer delays play as stored. ffmpeg times
|
|
7
|
+
* them otherwise — a GIF's 1cs frame plays for 10ms, an APNG's 0 delay for 1/15s — and decodes one
|
|
8
|
+
* pass, where a browser loops. A two-frame black/white GIF looping at 100ms a frame is five
|
|
9
|
+
* flashes a second on screen and one transition in a single decoded pass.
|
|
10
|
+
*
|
|
11
|
+
* Pure: bytes in, no I/O.
|
|
12
|
+
*/
|
|
13
|
+
export interface ImageTiming {
|
|
14
|
+
format: "gif" | "apng";
|
|
15
|
+
/** Each frame's delay as stored, in ms (a GIF's centiseconds x 10; an APNG's delay_num / delay_den). */
|
|
16
|
+
storedMs: number[];
|
|
17
|
+
/** How many times the animation plays; `null` is forever. */
|
|
18
|
+
plays: number | null;
|
|
19
|
+
/** An APNG's `acTL` num_frames: the frames a browser plays, whatever number of `fcTL` follow. */
|
|
20
|
+
declaredFrames?: number;
|
|
21
|
+
/** A GIF's logical screen and each image's place and compositing, which ffmpeg composites otherwise than a browser. */
|
|
22
|
+
gif?: {
|
|
23
|
+
screen: {
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
};
|
|
27
|
+
globalTable: boolean;
|
|
28
|
+
images: GifImage[];
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface GifImage {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
/** The graphic control extension's disposal method: 0-1 leave it, 2 restore to background, 3 restore to previous. */
|
|
37
|
+
disposal: number;
|
|
38
|
+
/** It has a transparent colour index. */
|
|
39
|
+
transparent: boolean;
|
|
40
|
+
}
|
|
41
|
+
/** What Chromium holds a frame for: 10ms or less is 100ms. */
|
|
42
|
+
export declare const browserDelayMs: (storedMs: number) => number;
|
|
43
|
+
/**
|
|
44
|
+
* Where ffmpeg 6.1's GIF decoder composites otherwise than Chromium (measured,
|
|
45
|
+
* `docs/reports/2026-10-13-scan-video-v1.md`), or null. ffmpeg's background is the global colour
|
|
46
|
+
* table's background entry, opaque, wherever a browser leaves the canvas transparent — but only
|
|
47
|
+
* when the GIF has a global table and the image it fills under has no transparent index; otherwise
|
|
48
|
+
* it fills with its transparent colour, as a browser does (measured: those decode pixel for pixel
|
|
49
|
+
* as Chromium shows them). So refused: a first image larger than the logical screen (a browser grows
|
|
50
|
+
* the canvas, ffmpeg crops); one that does not cover it, opaque, under a global table; a frame
|
|
51
|
+
* disposed to background, opaque, under a global table, that the next image does not paint over
|
|
52
|
+
* opaquely; and one restored to previous where what is restored holds that fill (ffmpeg saved it,
|
|
53
|
+
* a browser restores the cleared canvas). Frame 0 of every pass is drawn on a cleared canvas in both.
|
|
54
|
+
*/
|
|
55
|
+
export declare function gifCompositingProblem(timing: ImageTiming): string | null;
|
|
56
|
+
/** The timing of an animated GIF or APNG, or null for anything else (a still PNG, a video). */
|
|
57
|
+
export declare function imageTiming(bytes: Uint8Array): ImageTiming | null;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// src/image-timing.ts
|
|
2
|
+
/** What Chromium holds a frame for: 10ms or less is 100ms. */
|
|
3
|
+
const browserDelayMs = (storedMs) => storedMs <= 10 ? 100 : storedMs;
|
|
4
|
+
const ascii = (bytes, at, length) => String.fromCharCode(...bytes.subarray(at, at + length));
|
|
5
|
+
const u32 = (bytes, at) => (bytes[at] << 24 | bytes[at + 1] << 16 | bytes[at + 2] << 8 | bytes[at + 3]) >>> 0;
|
|
6
|
+
const u16 = (bytes, at) => bytes[at] << 8 | bytes[at + 1];
|
|
7
|
+
const u16le = (bytes, at) => bytes[at] | bytes[at + 1] << 8;
|
|
8
|
+
/**
|
|
9
|
+
* A GIF's frames: one per image descriptor, its delay from the graphic control extension before it
|
|
10
|
+
* (none: 0). Plays: once with no NETSCAPE2.0 (or ANIMEXTS1.0) block, forever when its loop count
|
|
11
|
+
* is 0, else loop count + 1 (the first play and the repeats).
|
|
12
|
+
*/
|
|
13
|
+
function gifTiming(bytes) {
|
|
14
|
+
let at = 13;
|
|
15
|
+
const lsd = bytes[10] ?? 0;
|
|
16
|
+
if (lsd & 128) at += 3 * (1 << (lsd & 7) + 1);
|
|
17
|
+
const screen = {
|
|
18
|
+
width: u16le(bytes, 6),
|
|
19
|
+
height: u16le(bytes, 8)
|
|
20
|
+
};
|
|
21
|
+
const images = [];
|
|
22
|
+
const storedMs = [];
|
|
23
|
+
let pendingDelay = 0;
|
|
24
|
+
let pendingDisposal = 0;
|
|
25
|
+
let pendingTransparent = false;
|
|
26
|
+
let plays = 1;
|
|
27
|
+
const subBlocks = () => {
|
|
28
|
+
const out = [];
|
|
29
|
+
while (at < bytes.length) {
|
|
30
|
+
const size = bytes[at];
|
|
31
|
+
at += 1;
|
|
32
|
+
if (size === 0) break;
|
|
33
|
+
out.push(bytes.subarray(at, at + size));
|
|
34
|
+
at += size;
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
};
|
|
38
|
+
while (at < bytes.length) {
|
|
39
|
+
const block = bytes[at];
|
|
40
|
+
if (block === 59) break;
|
|
41
|
+
if (block === 33) {
|
|
42
|
+
const label = bytes[at + 1];
|
|
43
|
+
at += 2;
|
|
44
|
+
const blocks = subBlocks();
|
|
45
|
+
if (label === 249 && blocks[0] && blocks[0].length >= 4) {
|
|
46
|
+
pendingDelay = u16le(blocks[0], 1) * 10;
|
|
47
|
+
pendingDisposal = blocks[0][0] >> 2 & 7;
|
|
48
|
+
pendingTransparent = (blocks[0][0] & 1) === 1;
|
|
49
|
+
} else if (label === 255 && blocks[0] && (ascii(blocks[0], 0, 11) === "NETSCAPE2.0" || ascii(blocks[0], 0, 11) === "ANIMEXTS1.0")) {
|
|
50
|
+
const data = blocks[1];
|
|
51
|
+
if (data && data.length >= 3 && data[0] === 1) {
|
|
52
|
+
const loops = u16le(data, 1);
|
|
53
|
+
plays = loops === 0 ? null : loops + 1;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} else if (block === 44) {
|
|
57
|
+
storedMs.push(pendingDelay);
|
|
58
|
+
images.push({
|
|
59
|
+
x: u16le(bytes, at + 1),
|
|
60
|
+
y: u16le(bytes, at + 3),
|
|
61
|
+
width: u16le(bytes, at + 5),
|
|
62
|
+
height: u16le(bytes, at + 7),
|
|
63
|
+
disposal: pendingDisposal,
|
|
64
|
+
transparent: pendingTransparent
|
|
65
|
+
});
|
|
66
|
+
pendingDelay = 0;
|
|
67
|
+
pendingDisposal = 0;
|
|
68
|
+
pendingTransparent = false;
|
|
69
|
+
const packed = bytes[at + 9] ?? 0;
|
|
70
|
+
at += 10;
|
|
71
|
+
if (packed & 128) at += 3 * (1 << (packed & 7) + 1);
|
|
72
|
+
at += 1;
|
|
73
|
+
subBlocks();
|
|
74
|
+
} else break;
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
format: "gif",
|
|
78
|
+
storedMs,
|
|
79
|
+
plays,
|
|
80
|
+
gif: {
|
|
81
|
+
screen,
|
|
82
|
+
globalTable: (lsd & 128) !== 0,
|
|
83
|
+
images
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Where ffmpeg 6.1's GIF decoder composites otherwise than Chromium (measured,
|
|
89
|
+
* `docs/reports/2026-10-13-scan-video-v1.md`), or null. ffmpeg's background is the global colour
|
|
90
|
+
* table's background entry, opaque, wherever a browser leaves the canvas transparent — but only
|
|
91
|
+
* when the GIF has a global table and the image it fills under has no transparent index; otherwise
|
|
92
|
+
* it fills with its transparent colour, as a browser does (measured: those decode pixel for pixel
|
|
93
|
+
* as Chromium shows them). So refused: a first image larger than the logical screen (a browser grows
|
|
94
|
+
* the canvas, ffmpeg crops); one that does not cover it, opaque, under a global table; a frame
|
|
95
|
+
* disposed to background, opaque, under a global table, that the next image does not paint over
|
|
96
|
+
* opaquely; and one restored to previous where what is restored holds that fill (ffmpeg saved it,
|
|
97
|
+
* a browser restores the cleared canvas). Frame 0 of every pass is drawn on a cleared canvas in both.
|
|
98
|
+
*/
|
|
99
|
+
function gifCompositingProblem(timing) {
|
|
100
|
+
const gif = timing.gif;
|
|
101
|
+
if (!gif || gif.images.length === 0) return null;
|
|
102
|
+
const { screen, images, globalTable } = gif;
|
|
103
|
+
const first = images[0];
|
|
104
|
+
if (first.x + first.width > screen.width || first.y + first.height > screen.height) return `its first image (${first.width}x${first.height} at ${first.x},${first.y}) reaches past the ${screen.width}x${screen.height} logical screen: a browser grows the canvas to it, ffmpeg crops it`;
|
|
105
|
+
if (!globalTable) return null;
|
|
106
|
+
if (!(first.x === 0 && first.y === 0 && first.width >= screen.width && first.height >= screen.height) && !first.transparent) return `its first image (${first.width}x${first.height} at ${first.x},${first.y}) does not cover the ${screen.width}x${screen.height} logical screen and has no transparent colour: a browser leaves the rest transparent, ffmpeg paints it the background colour`;
|
|
107
|
+
const paintsOver = (b, a) => !b.transparent && b.x <= a.x && b.y <= a.y && b.x + b.width >= a.x + a.width && b.y + b.height >= a.y + a.height;
|
|
108
|
+
const screenRect = {
|
|
109
|
+
x: 0,
|
|
110
|
+
y: 0,
|
|
111
|
+
...screen,
|
|
112
|
+
disposal: 0,
|
|
113
|
+
transparent: false
|
|
114
|
+
};
|
|
115
|
+
let fillBefore = !first.transparent;
|
|
116
|
+
for (let i = 0; i + 1 < images.length; i++) {
|
|
117
|
+
const a = images[i];
|
|
118
|
+
const b = images[i + 1];
|
|
119
|
+
if (a.disposal === 2 && !a.transparent && !paintsOver(b, a)) return `image ${i} is disposed to background with no transparent colour, and image ${i + 1} does not paint over all of it opaquely: a browser clears it to transparent, ffmpeg fills it with the background colour`;
|
|
120
|
+
if (a.disposal === 3 && fillBefore && !paintsOver(b, a)) return `image ${i} is restored to the canvas before it, which ffmpeg filled with the background colour, and image ${i + 1} does not paint over all of it opaquely: a browser restores a transparent canvas`;
|
|
121
|
+
const afterDraw = fillBefore && !paintsOver(a, screenRect);
|
|
122
|
+
fillBefore = a.disposal === 3 ? fillBefore : a.disposal === 2 && !a.transparent ? true : afterDraw;
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* An APNG's frames: one per `fcTL`, delay_num / delay_den seconds (a 0 denominator is 100) in
|
|
128
|
+
* whole ms, as Chromium holds it. Plays: `acTL`'s num_plays, 0 forever; its num_frames is how many
|
|
129
|
+
* of them a browser plays.
|
|
130
|
+
*/
|
|
131
|
+
function apngTiming(bytes) {
|
|
132
|
+
let at = 8;
|
|
133
|
+
let plays;
|
|
134
|
+
let declaredFrames = 0;
|
|
135
|
+
const storedMs = [];
|
|
136
|
+
while (at + 8 <= bytes.length) {
|
|
137
|
+
const length = u32(bytes, at);
|
|
138
|
+
const type = ascii(bytes, at + 4, 4);
|
|
139
|
+
const data = at + 8;
|
|
140
|
+
if (type === "IEND") break;
|
|
141
|
+
if (type === "acTL" && length >= 8 && plays === void 0) {
|
|
142
|
+
declaredFrames = u32(bytes, data);
|
|
143
|
+
const n = u32(bytes, data + 4);
|
|
144
|
+
plays = n === 0 ? null : n;
|
|
145
|
+
}
|
|
146
|
+
if (type === "fcTL" && length >= 26) {
|
|
147
|
+
const num = u16(bytes, data + 20);
|
|
148
|
+
const den = u16(bytes, data + 22) || 100;
|
|
149
|
+
storedMs.push(Math.floor(num * 1e3 / den));
|
|
150
|
+
}
|
|
151
|
+
at += 12 + length;
|
|
152
|
+
}
|
|
153
|
+
return plays === void 0 ? null : {
|
|
154
|
+
format: "apng",
|
|
155
|
+
storedMs,
|
|
156
|
+
plays,
|
|
157
|
+
declaredFrames
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/** The timing of an animated GIF or APNG, or null for anything else (a still PNG, a video). */
|
|
161
|
+
function imageTiming(bytes) {
|
|
162
|
+
if (bytes.length >= 13 && (ascii(bytes, 0, 6) === "GIF87a" || ascii(bytes, 0, 6) === "GIF89a")) return gifTiming(bytes);
|
|
163
|
+
if (bytes.length >= 8 && bytes[0] === 137 && ascii(bytes, 1, 3) === "PNG") return apngTiming(bytes);
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
export { browserDelayMs, gifCompositingProblem, imageTiming };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { A11yChange, A11yChangeType, A11yDiff, A11yExpectation, A11yNode, A11ySnapshot, AffectedComponent, AgentContext, Attachment, ChangeIntent, CrossValidationResult, DepEdge, DepGraph, DepNode, DiffHunk, DiffIgnoreRegion, DiffIgnoredRegionReport, DiffMaskSummary, DiffRegion, DiffRegionColor, DiffRegionColorPair, DiffRegionColorSample, DiffRegionSelectorCandidate, DiffRegionShift, DiffRegionType, DiffReport, DiffSemantics, ExpectedA11yChange, FileChange, HtmlSource, IntrospectResult, Language, LoopScore, NlAssertion, PageExpectation, PageIntrospection, PageSpec, PlaywrightReport, ProjectConfig, QualityCheckResult, QualityCheckType, ScoreDetail, ShiftRegion, SpecCheckType, SpecInvariant, TestAttempt, TestError, TestResult, TestSpec, TestSuite, UiSpec, UnifiedAgentContext, VisualChangeType, VisualExpectation, VisualSemanticChange, VisualSemanticDiff, VrtDiff, VrtExpectation, VrtSnapshot, VrtVerdict } from "./types.mjs";
|
|
2
|
-
import { INTERACTIVE_ROLES, LANDMARK_ROLES, diffA11yTrees, parsePlaywrightA11ySnapshot, verifyA11yTree } from "./a11y-semantic.mjs";
|
|
3
|
-
import { cropImage, decodePng, encodePng } from "./png-utils.mjs";
|
|
4
|
-
import { AUTHORED_PROPERTIES } from "./authored-style-capture.mjs";
|
|
5
|
-
import { TRACKED_PROPERTIES } from "./computed-style-capture.mjs";
|
|
6
|
-
import { diffComputedStyles } from "./computed-style-diff.mjs";
|
|
7
|
-
import { aggregateAuthoredStyleByViewport, diffAuthoredStyles } from "./authored-style-diff.mjs";
|
|
8
|
-
import { createScopedVrtDiff, normalizeVrtDiffRegionPixels, normalizeVrtDiffRegions } from "./diff-regions.mjs";
|
|
9
|
-
import { verifyDomEquivalence } from "./dom-equivalence.mjs";
|
|
10
|
-
import { diffDomPositionStyles, diffPositionStylesAcrossViewports } from "./dom-position-styles.mjs";
|
|
11
|
-
import { FilmstripLayout, FilmstripOptions, composeFilmstrip, filmstripLayout } from "./filmstrip.mjs";
|
|
12
|
-
import { findHeatmapRegionsFromFile, findHeatmapRegionsFromRgba } from "./heatmap-regions.mjs";
|
|
1
|
+
import { A11yChange, A11yChangeType, A11yDiff, A11yExpectation, A11yNode, A11ySnapshot, AffectedComponent, AgentContext, Attachment, ChangeIntent, CrossValidationResult, DepEdge, DepGraph, DepNode, DiffHunk, DiffIgnoreRegion, DiffIgnoredRegionReport, DiffMaskSummary, DiffRegion, DiffRegionColor, DiffRegionColorPair, DiffRegionColorSample, DiffRegionKind, DiffRegionSelectorCandidate, DiffRegionShift, DiffRegionType, DiffReport, DiffSemantics, ExpectedA11yChange, FileChange, HtmlSource, IntrospectResult, Language, LoopScore, NlAssertion, PageExpectation, PageIntrospection, PageSpec, PlaywrightReport, ProjectConfig, QualityCheckResult, QualityCheckType, ScoreDetail, ShiftRegion, SpecCheckType, SpecInvariant, TestAttempt, TestError, TestResult, TestSpec, TestSuite, UiSpec, UnifiedAgentContext, VisualChangeType, VisualExpectation, VisualSemanticChange, VisualSemanticDiff, VrtDiff, VrtExpectation, VrtSnapshot, VrtVerdict } from "./types.mjs";
|
|
13
2
|
import { compareScreenshots, detectBandShifts, detectEmptyContent, detectWhiteout, generateDiffReport, parseIgnoreRegionSpec } from "./heatmap.mjs";
|
|
14
|
-
import {
|
|
3
|
+
import { findHeatmapRegionsFromFile, findHeatmapRegionsFromRgba } from "./heatmap-regions.mjs";
|
|
4
|
+
import { FilmstripLayout, FilmstripOptions, composeFilmstrip, filmstripLayout } from "./filmstrip.mjs";
|
|
15
5
|
import { WebpEncodeOptions, encodeWebp, imageFormatForPath, webpEncoderAvailable } from "./webp.mjs";
|
|
6
|
+
import { createScopedVrtDiff, normalizeVrtDiffRegionPixels, normalizeVrtDiffRegions } from "./diff-regions.mjs";
|
|
16
7
|
import { compareRowTypography, computeRowGapDeltas, extractTextRowsFromFile, extractTextRowsFromRgba, matchTextRows } from "./text-rows.mjs";
|
|
17
|
-
|
|
8
|
+
import { cropImage, decodePng, encodePng } from "./png-utils.mjs";
|
|
9
|
+
import { RESOLUTION_PRESETS, getImageDimensions, resizePngBuffer, resolveResolutionForViewport } from "./image-resize.mjs";
|
|
10
|
+
import { verifyDomEquivalence } from "./dom-equivalence.mjs";
|
|
11
|
+
import { diffDomPositionStyles, diffPositionStylesAcrossViewports } from "./dom-position-styles.mjs";
|
|
12
|
+
import { diffComputedStyles } from "./computed-style-diff.mjs";
|
|
13
|
+
import { aggregateAuthoredStyleByViewport, diffAuthoredStyles } from "./authored-style-diff.mjs";
|
|
14
|
+
import { INTERACTIVE_ROLES, LANDMARK_ROLES, diffA11yTrees, parsePlaywrightA11ySnapshot, verifyA11yTree } from "./a11y-semantic.mjs";
|
|
15
|
+
import { TRACKED_PROPERTIES } from "./computed-style-capture.mjs";
|
|
16
|
+
import { AUTHORED_PROPERTIES } from "./authored-style-capture.mjs";
|
|
17
|
+
export { A11yChange, A11yChangeType, A11yDiff, A11yExpectation, A11yNode, A11ySnapshot, AUTHORED_PROPERTIES, AffectedComponent, AgentContext, Attachment, ChangeIntent, CrossValidationResult, DepEdge, DepGraph, DepNode, DiffHunk, DiffIgnoreRegion, DiffIgnoredRegionReport, DiffMaskSummary, DiffRegion, DiffRegionColor, DiffRegionColorPair, DiffRegionColorSample, DiffRegionKind, DiffRegionSelectorCandidate, DiffRegionShift, DiffRegionType, DiffReport, DiffSemantics, ExpectedA11yChange, FileChange, type FilmstripLayout, type FilmstripOptions, HtmlSource, INTERACTIVE_ROLES, IntrospectResult, LANDMARK_ROLES, Language, LoopScore, NlAssertion, PageExpectation, PageIntrospection, PageSpec, PlaywrightReport, ProjectConfig, QualityCheckResult, QualityCheckType, RESOLUTION_PRESETS, ScoreDetail, ShiftRegion, SpecCheckType, SpecInvariant, TRACKED_PROPERTIES, TestAttempt, TestError, TestResult, TestSpec, TestSuite, UiSpec, UnifiedAgentContext, VisualChangeType, VisualExpectation, VisualSemanticChange, VisualSemanticDiff, VrtDiff, VrtExpectation, VrtSnapshot, VrtVerdict, type WebpEncodeOptions, aggregateAuthoredStyleByViewport, compareRowTypography, compareScreenshots, composeFilmstrip, computeRowGapDeltas, createScopedVrtDiff, cropImage, decodePng, detectBandShifts, detectEmptyContent, detectWhiteout, diffA11yTrees, diffAuthoredStyles, diffComputedStyles, diffDomPositionStyles, diffPositionStylesAcrossViewports, encodePng, encodeWebp, extractTextRowsFromFile, extractTextRowsFromRgba, filmstripLayout, findHeatmapRegionsFromFile, findHeatmapRegionsFromRgba, generateDiffReport, getImageDimensions, imageFormatForPath, matchTextRows, normalizeVrtDiffRegionPixels, normalizeVrtDiffRegions, parseIgnoreRegionSpec, parsePlaywrightA11ySnapshot, resizePngBuffer, resolveResolutionForViewport, verifyA11yTree, verifyDomEquivalence, webpEncoderAvailable };
|
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { INTERACTIVE_ROLES, LANDMARK_ROLES, diffA11yTrees, parsePlaywrightA11ySnapshot, verifyA11yTree } from "./a11y-semantic.mjs";
|
|
2
|
-
import { AUTHORED_PROPERTIES } from "./authored-style-capture.mjs";
|
|
3
|
-
import { diffComputedStyles } from "./computed-style-diff.mjs";
|
|
4
|
-
import { aggregateAuthoredStyleByViewport, diffAuthoredStyles } from "./authored-style-diff.mjs";
|
|
5
|
-
import { TRACKED_PROPERTIES } from "./computed-style-capture.mjs";
|
|
6
|
-
import { createScopedVrtDiff, normalizeVrtDiffRegionPixels, normalizeVrtDiffRegions } from "./diff-regions.mjs";
|
|
7
|
-
import { verifyDomEquivalence } from "./dom-equivalence.mjs";
|
|
8
|
-
import { diffDomPositionStyles, diffPositionStylesAcrossViewports } from "./dom-position-styles.mjs";
|
|
9
|
-
import { cropImage, decodePng, encodePng } from "./png-utils.mjs";
|
|
10
1
|
import { compareScreenshots, detectBandShifts, detectEmptyContent, detectWhiteout, generateDiffReport, parseIgnoreRegionSpec } from "./heatmap.mjs";
|
|
11
|
-
import { composeFilmstrip, filmstripLayout } from "./filmstrip.mjs";
|
|
12
2
|
import { findHeatmapRegionsFromFile, findHeatmapRegionsFromRgba } from "./heatmap-regions.mjs";
|
|
13
|
-
import {
|
|
3
|
+
import { composeFilmstrip, filmstripLayout } from "./filmstrip.mjs";
|
|
14
4
|
import { encodeWebp, imageFormatForPath, webpEncoderAvailable } from "./webp.mjs";
|
|
5
|
+
import { createScopedVrtDiff, normalizeVrtDiffRegionPixels, normalizeVrtDiffRegions } from "./diff-regions.mjs";
|
|
15
6
|
import { compareRowTypography, computeRowGapDeltas, extractTextRowsFromFile, extractTextRowsFromRgba, matchTextRows } from "./text-rows.mjs";
|
|
7
|
+
import { cropImage, decodePng, encodePng } from "./png-utils.mjs";
|
|
8
|
+
import { RESOLUTION_PRESETS, getImageDimensions, resizePngBuffer, resolveResolutionForViewport } from "./image-resize.mjs";
|
|
9
|
+
import { verifyDomEquivalence } from "./dom-equivalence.mjs";
|
|
10
|
+
import { diffDomPositionStyles, diffPositionStylesAcrossViewports } from "./dom-position-styles.mjs";
|
|
11
|
+
import { diffComputedStyles } from "./computed-style-diff.mjs";
|
|
12
|
+
import { aggregateAuthoredStyleByViewport, diffAuthoredStyles } from "./authored-style-diff.mjs";
|
|
13
|
+
import { INTERACTIVE_ROLES, LANDMARK_ROLES, diffA11yTrees, parsePlaywrightA11ySnapshot, verifyA11yTree } from "./a11y-semantic.mjs";
|
|
14
|
+
import { TRACKED_PROPERTIES } from "./computed-style-capture.mjs";
|
|
15
|
+
import { AUTHORED_PROPERTIES } from "./authored-style-capture.mjs";
|
|
16
16
|
export { AUTHORED_PROPERTIES, INTERACTIVE_ROLES, LANDMARK_ROLES, RESOLUTION_PRESETS, TRACKED_PROPERTIES, aggregateAuthoredStyleByViewport, compareRowTypography, compareScreenshots, composeFilmstrip, computeRowGapDeltas, createScopedVrtDiff, cropImage, decodePng, detectBandShifts, detectEmptyContent, detectWhiteout, diffA11yTrees, diffAuthoredStyles, diffComputedStyles, diffDomPositionStyles, diffPositionStylesAcrossViewports, encodePng, encodeWebp, extractTextRowsFromFile, extractTextRowsFromRgba, filmstripLayout, findHeatmapRegionsFromFile, findHeatmapRegionsFromRgba, generateDiffReport, getImageDimensions, imageFormatForPath, matchTextRows, normalizeVrtDiffRegionPixels, normalizeVrtDiffRegions, parseIgnoreRegionSpec, parsePlaywrightA11ySnapshot, resizePngBuffer, resolveResolutionForViewport, verifyA11yTree, verifyDomEquivalence, webpEncoderAvailable };
|
package/dist/mask.d.mts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Page } from "playwright";
|
|
2
|
-
|
|
3
|
-
//#region src/mask.d.ts
|
|
4
2
|
/** What `applyMask` could and could not do, for the caller to report. */
|
|
5
|
-
interface MaskResult {
|
|
3
|
+
export interface MaskResult {
|
|
6
4
|
/** Selectors that matched at least one element and are now hidden. */
|
|
7
5
|
applied: string[];
|
|
8
6
|
/**
|
|
@@ -38,7 +36,7 @@ interface MaskResult {
|
|
|
38
36
|
* on exactly the thing we need to detect, and it is the same engine that will apply the
|
|
39
37
|
* CSS.
|
|
40
38
|
*/
|
|
41
|
-
declare function applyMask(page: Page, selectors: string[]): Promise<MaskResult>;
|
|
39
|
+
export declare function applyMask(page: Page, selectors: string[]): Promise<MaskResult>;
|
|
42
40
|
/**
|
|
43
41
|
* Accumulates mask outcomes across a run so the report is per-run, not per-page.
|
|
44
42
|
*
|
|
@@ -51,7 +49,7 @@ declare function applyMask(page: Page, selectors: string[]): Promise<MaskResult>
|
|
|
51
49
|
* exists on one route only — so it is worth reporting only for a selector that
|
|
52
50
|
* matched nothing *anywhere*, which is not knowable until the run ends.
|
|
53
51
|
*/
|
|
54
|
-
declare class MaskTally {
|
|
52
|
+
export declare class MaskTally {
|
|
55
53
|
private readonly invalid;
|
|
56
54
|
private readonly everMatched;
|
|
57
55
|
private readonly everTried;
|
|
@@ -69,7 +67,7 @@ declare class MaskTally {
|
|
|
69
67
|
* `Mask: <selectors>` line, which was a claim about state that a malformed selector made
|
|
70
68
|
* false.
|
|
71
69
|
*/
|
|
72
|
-
declare function formatMaskProblems(invalid: string[], neverMatched: string[]): string | null;
|
|
70
|
+
export declare function formatMaskProblems(invalid: string[], neverMatched: string[]): string | null;
|
|
73
71
|
/**
|
|
74
72
|
* Parse selector array from CLI --mask flags.
|
|
75
73
|
* Supports comma-separated or multiple --mask flags.
|
|
@@ -77,6 +75,4 @@ declare function formatMaskProblems(invalid: string[], neverMatched: string[]):
|
|
|
77
75
|
* --mask ".stars,.carousel"
|
|
78
76
|
* --mask ".stars" --mask ".carousel"
|
|
79
77
|
*/
|
|
80
|
-
declare function parseMaskSelectors(args: string[]): string[];
|
|
81
|
-
//#endregion
|
|
82
|
-
export { MaskResult, MaskTally, applyMask, formatMaskProblems, parseMaskSelectors };
|
|
78
|
+
export declare function parseMaskSelectors(args: string[]): string[];
|
package/dist/mask.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/mask.ts
|
|
2
2
|
/**
|
|
3
3
|
* Inject mask styles into the page.
|
|
4
4
|
* Sets visibility: hidden on target selectors including descendants.
|
|
@@ -110,5 +110,4 @@ function parseMaskSelectors(args) {
|
|
|
110
110
|
}
|
|
111
111
|
return selectors;
|
|
112
112
|
}
|
|
113
|
-
//#endregion
|
|
114
113
|
export { MaskTally, applyMask, formatMaskProblems, parseMaskSelectors };
|