craftdriver 1.5.0 → 1.7.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/CHANGELOG.md +24 -0
- package/README.md +7 -3
- package/dist/cli/daemon.d.ts.map +1 -1
- package/dist/cli/daemon.js +4 -0
- package/dist/cli/daemon.js.map +1 -1
- package/dist/cli/mcp/server.d.ts.map +1 -1
- package/dist/cli/mcp/server.js +4 -0
- package/dist/cli/mcp/server.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/browser.d.ts +73 -22
- package/dist/lib/browser.d.ts.map +1 -1
- package/dist/lib/browser.js +155 -41
- package/dist/lib/browser.js.map +1 -1
- package/dist/lib/browserContext.d.ts +1 -1
- package/dist/lib/browserContext.d.ts.map +1 -1
- package/dist/lib/builder.d.ts +12 -1
- package/dist/lib/builder.d.ts.map +1 -1
- package/dist/lib/builder.js +26 -0
- package/dist/lib/builder.js.map +1 -1
- package/dist/lib/capabilities.d.ts +8 -0
- package/dist/lib/capabilities.d.ts.map +1 -1
- package/dist/lib/capabilities.js +26 -10
- package/dist/lib/capabilities.js.map +1 -1
- package/dist/lib/driver.d.ts +17 -1
- package/dist/lib/driver.d.ts.map +1 -1
- package/dist/lib/driver.js +27 -2
- package/dist/lib/driver.js.map +1 -1
- package/dist/lib/elementHandle.d.ts.map +1 -1
- package/dist/lib/elementHandle.js +34 -0
- package/dist/lib/elementHandle.js.map +1 -1
- package/dist/lib/errors.d.ts +7 -0
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +7 -0
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/http.d.ts.map +1 -1
- package/dist/lib/http.js +31 -10
- package/dist/lib/http.js.map +1 -1
- package/dist/lib/launchTarget.d.ts +21 -2
- package/dist/lib/launchTarget.d.ts.map +1 -1
- package/dist/lib/launchTarget.js +105 -17
- package/dist/lib/launchTarget.js.map +1 -1
- package/dist/lib/remote.d.ts +55 -0
- package/dist/lib/remote.d.ts.map +1 -0
- package/dist/lib/remote.js +127 -0
- package/dist/lib/remote.js.map +1 -0
- package/dist/lib/timing.d.ts +8 -0
- package/dist/lib/timing.d.ts.map +1 -1
- package/dist/lib/timing.js +8 -0
- package/dist/lib/timing.js.map +1 -1
- package/dist/lib/tracing.d.ts +1 -1
- package/dist/lib/tracing.d.ts.map +1 -1
- package/dist/lib/tracing.js.map +1 -1
- package/dist/lib/types.d.ts +22 -0
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/vibiumTrace.d.ts +1 -1
- package/dist/lib/vibiumTrace.d.ts.map +1 -1
- package/dist/lib/visual/antialias.d.ts +41 -0
- package/dist/lib/visual/antialias.d.ts.map +1 -0
- package/dist/lib/visual/antialias.js +126 -0
- package/dist/lib/visual/antialias.js.map +1 -0
- package/dist/lib/visual/codec.d.ts +24 -0
- package/dist/lib/visual/codec.d.ts.map +1 -0
- package/dist/lib/visual/codec.js +11 -0
- package/dist/lib/visual/codec.js.map +1 -0
- package/dist/lib/visual/compare.d.ts +38 -0
- package/dist/lib/visual/compare.d.ts.map +1 -0
- package/dist/lib/visual/compare.js +209 -0
- package/dist/lib/visual/compare.js.map +1 -0
- package/dist/lib/visual/diff.d.ts +18 -0
- package/dist/lib/visual/diff.d.ts.map +1 -0
- package/dist/lib/visual/diff.js +23 -0
- package/dist/lib/visual/diff.js.map +1 -0
- package/dist/lib/visual/expectScreenshot.d.ts +65 -0
- package/dist/lib/visual/expectScreenshot.d.ts.map +1 -0
- package/dist/lib/visual/expectScreenshot.js +287 -0
- package/dist/lib/visual/expectScreenshot.js.map +1 -0
- package/dist/lib/visual/index.d.ts +10 -0
- package/dist/lib/visual/index.d.ts.map +1 -0
- package/dist/lib/visual/index.js +9 -0
- package/dist/lib/visual/index.js.map +1 -0
- package/dist/lib/visual/pixelMath.d.ts +32 -0
- package/dist/lib/visual/pixelMath.d.ts.map +1 -0
- package/dist/lib/visual/pixelMath.js +70 -0
- package/dist/lib/visual/pixelMath.js.map +1 -0
- package/dist/lib/visual/pngHeader.d.ts +27 -0
- package/dist/lib/visual/pngHeader.d.ts.map +1 -0
- package/dist/lib/visual/pngHeader.js +63 -0
- package/dist/lib/visual/pngHeader.js.map +1 -0
- package/dist/lib/visual/pngjsCodec.d.ts +22 -0
- package/dist/lib/visual/pngjsCodec.d.ts.map +1 -0
- package/dist/lib/visual/pngjsCodec.js +70 -0
- package/dist/lib/visual/pngjsCodec.js.map +1 -0
- package/dist/lib/visual/types.d.ts +89 -0
- package/dist/lib/visual/types.d.ts.map +1 -0
- package/dist/lib/visual/types.js +20 -0
- package/dist/lib/visual/types.js.map +1 -0
- package/dist/lib/visual/visualError.d.ts +32 -0
- package/dist/lib/visual/visualError.d.ts.map +1 -0
- package/dist/lib/visual/visualError.js +59 -0
- package/dist/lib/visual/visualError.js.map +1 -0
- package/dist/lib/wait.d.ts.map +1 -1
- package/dist/lib/wait.js +7 -1
- package/dist/lib/wait.js.map +1 -1
- package/docs/api-reference.md +18 -2
- package/docs/browser-api.md +5 -4
- package/docs/driver-configuration.md +6 -0
- package/docs/error-codes.md +1 -0
- package/docs/index.md +1 -0
- package/docs/keyboard-mouse.md +7 -5
- package/docs/recipes/run-on-browserstack.md +265 -0
- package/docs/recipes.md +15 -1
- package/docs/remote-webdriver.md +308 -0
- package/docs/screenshots.md +15 -6
- package/docs/standards.md +15 -10
- package/docs/visual-testing.md +254 -0
- package/docs/why-craftdriver.md +5 -2
- package/package.json +5 -1
package/dist/lib/tracing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../src/lib/tracing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACnF,OAAO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C,CAAC;IAC5C,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC;IACnB,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC;IAClE,IAAI,CAAC,KAAK,UAAU;QAAE,OAAO,YAAY,CAAC;IAC1C,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACxD,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,GAAG;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC9C,OAAO,UAAU,CAAC;IACpB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,UAAU,CAAC;IACpB,CAAC;AACH,CAAC"}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -21,6 +21,28 @@ export interface WebDriverEndpoint {
|
|
|
21
21
|
hostname: string;
|
|
22
22
|
port: number;
|
|
23
23
|
path?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Basic auth credentials for this endpoint (remote WebDriver only — a
|
|
26
|
+
* local `DriverService` endpoint never sets this). Sent as an
|
|
27
|
+
* `Authorization` header by `HttpClient`, never logged.
|
|
28
|
+
*/
|
|
29
|
+
auth?: {
|
|
30
|
+
username: string;
|
|
31
|
+
password: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Unique key stamped on remote endpoints (`parseRemoteEndpoint`) so each
|
|
35
|
+
* remote session gets its own keep-alive agent instead of sharing one by
|
|
36
|
+
* `host:port` — many concurrent sessions legitimately share one grid/hub
|
|
37
|
+
* host. Local endpoints never set this; they keep sharing by `host:port`
|
|
38
|
+
* (every local `DriverService` picks its own free port anyway).
|
|
39
|
+
*/
|
|
40
|
+
poolKey?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Default per-command timeout (remote WebDriver only). Applied by
|
|
43
|
+
* `HttpClient.send()` when the caller doesn't pass its own `timeoutMs`.
|
|
44
|
+
*/
|
|
45
|
+
commandTimeoutMs?: number;
|
|
24
46
|
}
|
|
25
47
|
/**
|
|
26
48
|
* A cookie as serialized by the W3C WebDriver **Classic** cookie endpoints
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,GAAG;IACtC,KAAK,EAAE,CAAC,CAAC;CACV;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,uGAAuG;IACvG,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAA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,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;CACtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vibiumTrace.d.ts","sourceRoot":"","sources":["../../src/lib/vibiumTrace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,UAAU,mBAAmB;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"vibiumTrace.d.ts","sourceRoot":"","sources":["../../src/lib/vibiumTrace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,UAAU,mBAAmB;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA+CD,+EAA+E;AAC/E,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4KlF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional anti-aliasing detector.
|
|
3
|
+
*
|
|
4
|
+
* The `antialiased()` / `hasManySiblings()` neighbourhood heuristic below is
|
|
5
|
+
* adapted from Pixelmatch (https://github.com/mapbox/pixelmatch) by Vladimir
|
|
6
|
+
* Agafonkin, which itself implements the anti-aliasing detection from:
|
|
7
|
+
*
|
|
8
|
+
* V. Vysniauskas, "Anti-aliased pixel and intensity slope detector", 2009.
|
|
9
|
+
*
|
|
10
|
+
* Pixelmatch is distributed under the ISC License:
|
|
11
|
+
*
|
|
12
|
+
* Copyright (c) 2019, Mapbox
|
|
13
|
+
*
|
|
14
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
15
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
16
|
+
* copyright notice and this permission notice appear in all copies.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
19
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
20
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
21
|
+
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
22
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
23
|
+
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
24
|
+
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* Adaptations from the original: brightness deltas and sibling equality use
|
|
27
|
+
* white-composited visible colour (see `./pixelMath`) instead of Pixelmatch's
|
|
28
|
+
* checkerboard blend, and all neighbour reads are byte-indexed so no 4-byte
|
|
29
|
+
* `Uint32Array` alignment is assumed of the codec output.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Whether the pixel at (x, y) is anti-aliasing in either image (Pixelmatch's
|
|
33
|
+
* symmetric check). Callers should only invoke this for pixels that already
|
|
34
|
+
* failed the colour-tolerance test.
|
|
35
|
+
*
|
|
36
|
+
* `width`/`height` bound the compared region (the overlap); `actualWidth` and
|
|
37
|
+
* `expectedWidth` are each buffer's own row width for byte indexing, which
|
|
38
|
+
* differ from the overlap only on a dimension mismatch.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isAntialiased(actual: Uint8Array, expected: Uint8Array, x: number, y: number, actualWidth: number, expectedWidth: number, width: number, height: number): boolean;
|
|
41
|
+
//# sourceMappingURL=antialias.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"antialias.d.ts","sourceRoot":"","sources":["../../../src/lib/visual/antialias.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAyGH;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,UAAU,EACpB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAKT"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional anti-aliasing detector.
|
|
3
|
+
*
|
|
4
|
+
* The `antialiased()` / `hasManySiblings()` neighbourhood heuristic below is
|
|
5
|
+
* adapted from Pixelmatch (https://github.com/mapbox/pixelmatch) by Vladimir
|
|
6
|
+
* Agafonkin, which itself implements the anti-aliasing detection from:
|
|
7
|
+
*
|
|
8
|
+
* V. Vysniauskas, "Anti-aliased pixel and intensity slope detector", 2009.
|
|
9
|
+
*
|
|
10
|
+
* Pixelmatch is distributed under the ISC License:
|
|
11
|
+
*
|
|
12
|
+
* Copyright (c) 2019, Mapbox
|
|
13
|
+
*
|
|
14
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
15
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
16
|
+
* copyright notice and this permission notice appear in all copies.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
19
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
20
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
21
|
+
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
22
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
23
|
+
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
24
|
+
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* Adaptations from the original: brightness deltas and sibling equality use
|
|
27
|
+
* white-composited visible colour (see `./pixelMath`) instead of Pixelmatch's
|
|
28
|
+
* checkerboard blend, and all neighbour reads are byte-indexed so no 4-byte
|
|
29
|
+
* `Uint32Array` alignment is assumed of the codec output.
|
|
30
|
+
*/
|
|
31
|
+
import { brightnessDelta, visibleEqual } from './pixelMath.js';
|
|
32
|
+
/**
|
|
33
|
+
* Determine whether the pixel at (x1, y1) in `data` looks like anti-aliasing,
|
|
34
|
+
* cross-checked against `other`. A pixel is a candidate when it has a bright and
|
|
35
|
+
* a dark neighbour (an intensity slope) and the extreme neighbour has many
|
|
36
|
+
* identical siblings in both images.
|
|
37
|
+
*
|
|
38
|
+
* `width`/`height` bound the compared region (the overlap of the two images);
|
|
39
|
+
* `stride`/`otherStride` are the true row widths used to byte-index `data` and
|
|
40
|
+
* `other` respectively. These differ only on a dimension mismatch — indexing a
|
|
41
|
+
* buffer at anything but its own row width reads the wrong pixels. For equal
|
|
42
|
+
* dimensions all three widths coincide and behaviour is unchanged.
|
|
43
|
+
*/
|
|
44
|
+
function antialiased(data, x1, y1, width, height, stride, other, otherStride) {
|
|
45
|
+
const x0 = Math.max(x1 - 1, 0);
|
|
46
|
+
const y0 = Math.max(y1 - 1, 0);
|
|
47
|
+
const x2 = Math.min(x1 + 1, width - 1);
|
|
48
|
+
const y2 = Math.min(y1 + 1, height - 1);
|
|
49
|
+
const pos = (y1 * stride + x1) * 4;
|
|
50
|
+
let zeroes = x1 === x0 || x1 === x2 || y1 === y0 || y1 === y2 ? 1 : 0;
|
|
51
|
+
let min = 0;
|
|
52
|
+
let max = 0;
|
|
53
|
+
let minX = -1;
|
|
54
|
+
let minY = -1;
|
|
55
|
+
let maxX = -1;
|
|
56
|
+
let maxY = -1;
|
|
57
|
+
for (let x = x0; x <= x2; x++) {
|
|
58
|
+
for (let y = y0; y <= y2; y++) {
|
|
59
|
+
if (x === x1 && y === y1)
|
|
60
|
+
continue;
|
|
61
|
+
const delta = brightnessDelta(data, pos, (y * stride + x) * 4);
|
|
62
|
+
if (delta === 0) {
|
|
63
|
+
zeroes++;
|
|
64
|
+
// If a pixel has many equal-brightness siblings it is not an edge.
|
|
65
|
+
if (zeroes > 2)
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
else if (delta < min) {
|
|
69
|
+
min = delta;
|
|
70
|
+
minX = x;
|
|
71
|
+
minY = y;
|
|
72
|
+
}
|
|
73
|
+
else if (delta > max) {
|
|
74
|
+
max = delta;
|
|
75
|
+
maxX = x;
|
|
76
|
+
maxY = y;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Need both a darker and a brighter neighbour to form an intensity slope.
|
|
81
|
+
if (min === 0 || max === 0)
|
|
82
|
+
return false;
|
|
83
|
+
return ((hasManySiblings(data, minX, minY, width, height, stride) &&
|
|
84
|
+
hasManySiblings(other, minX, minY, width, height, otherStride)) ||
|
|
85
|
+
(hasManySiblings(data, maxX, maxY, width, height, stride) &&
|
|
86
|
+
hasManySiblings(other, maxX, maxY, width, height, otherStride)));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Whether the pixel at (x1, y1) shares its visible colour with ≥3 neighbours.
|
|
90
|
+
* `width`/`height` bound the compared region; `stride` is `data`'s true row
|
|
91
|
+
* width used for byte indexing (see {@link antialiased}).
|
|
92
|
+
*/
|
|
93
|
+
function hasManySiblings(data, x1, y1, width, height, stride) {
|
|
94
|
+
const x0 = Math.max(x1 - 1, 0);
|
|
95
|
+
const y0 = Math.max(y1 - 1, 0);
|
|
96
|
+
const x2 = Math.min(x1 + 1, width - 1);
|
|
97
|
+
const y2 = Math.min(y1 + 1, height - 1);
|
|
98
|
+
const pos = (y1 * stride + x1) * 4;
|
|
99
|
+
let zeroes = x1 === x0 || x1 === x2 || y1 === y0 || y1 === y2 ? 1 : 0;
|
|
100
|
+
for (let x = x0; x <= x2; x++) {
|
|
101
|
+
for (let y = y0; y <= y2; y++) {
|
|
102
|
+
if (x === x1 && y === y1)
|
|
103
|
+
continue;
|
|
104
|
+
if (visibleEqual(data, pos, (y * stride + x) * 4)) {
|
|
105
|
+
zeroes++;
|
|
106
|
+
if (zeroes > 2)
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Whether the pixel at (x, y) is anti-aliasing in either image (Pixelmatch's
|
|
115
|
+
* symmetric check). Callers should only invoke this for pixels that already
|
|
116
|
+
* failed the colour-tolerance test.
|
|
117
|
+
*
|
|
118
|
+
* `width`/`height` bound the compared region (the overlap); `actualWidth` and
|
|
119
|
+
* `expectedWidth` are each buffer's own row width for byte indexing, which
|
|
120
|
+
* differ from the overlap only on a dimension mismatch.
|
|
121
|
+
*/
|
|
122
|
+
export function isAntialiased(actual, expected, x, y, actualWidth, expectedWidth, width, height) {
|
|
123
|
+
return (antialiased(actual, x, y, width, height, actualWidth, expected, expectedWidth) ||
|
|
124
|
+
antialiased(expected, x, y, width, height, expectedWidth, actual, actualWidth));
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=antialias.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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T,IAAI,MAAM,GAAG,CAAC;oBAAE,OAAO,IAAI,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAkB,EAClB,QAAoB,EACpB,CAAS,EACT,CAAS,EACT,WAAmB,EACnB,aAAqB,EACrB,KAAa,EACb,MAAc;IAEd,OAAO,CACL,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,CAAC;QAC9E,WAAW,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,CAAC,CAC/E,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal codec boundary for visual testing.
|
|
3
|
+
*
|
|
4
|
+
* All PNG-library-specific code lives behind this interface so the rest of the
|
|
5
|
+
* visual pipeline works on normalized, decoded RGBA pixels and never sees the
|
|
6
|
+
* concrete codec (currently pngjs). Keeping the seam narrow means a future codec
|
|
7
|
+
* can be evaluated without touching the comparison, diff, or retry code, and no
|
|
8
|
+
* codec type is ever exposed on the public API.
|
|
9
|
+
*/
|
|
10
|
+
/** A decoded image normalized to a fresh 8-bit RGBA byte view. */
|
|
11
|
+
export interface DecodedImage {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
/** Row-major RGBA, exactly `width * height * 4` bytes. */
|
|
15
|
+
data: Uint8Array;
|
|
16
|
+
}
|
|
17
|
+
/** Minimal decode/encode contract implemented by {@link pngjsCodec}. */
|
|
18
|
+
export interface PngCodec {
|
|
19
|
+
/** Decode a compressed PNG to normalized 8-bit RGBA. */
|
|
20
|
+
decode(buffer: Uint8Array): Promise<DecodedImage>;
|
|
21
|
+
/** Encode normalized 8-bit RGBA back to a compressed PNG. */
|
|
22
|
+
encode(image: DecodedImage): Promise<Buffer>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../../src/lib/visual/codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,kEAAkE;AAClE,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,wEAAwE;AACxE,MAAM,WAAW,QAAQ;IACvB,wDAAwD;IACxD,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAClD,6DAA6D;IAC7D,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal codec boundary for visual testing.
|
|
3
|
+
*
|
|
4
|
+
* All PNG-library-specific code lives behind this interface so the rest of the
|
|
5
|
+
* visual pipeline works on normalized, decoded RGBA pixels and never sees the
|
|
6
|
+
* concrete codec (currently pngjs). Keeping the seam narrow means a future codec
|
|
7
|
+
* can be evaluated without touching the comparison, diff, or retry code, and no
|
|
8
|
+
* codec type is ever exposed on the public API.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=codec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../../../src/lib/visual/codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-channel comparison and threshold policy over decoded RGBA images.
|
|
3
|
+
*
|
|
4
|
+
* This is small, dependency-free code over fixed-length arrays — deliberately
|
|
5
|
+
* owned rather than delegated, unlike the PNG parser. The same loop both counts
|
|
6
|
+
* differences (normal retries) and, when handed an optional diff output buffer,
|
|
7
|
+
* paints the diagnostic image (final failure only), so the two can never
|
|
8
|
+
* disagree about which pixels differ.
|
|
9
|
+
*/
|
|
10
|
+
import type { DecodedImage } from './codec.js';
|
|
11
|
+
import { type ScreenshotCompareOptions, type VisualComparisonResult } from './types.js';
|
|
12
|
+
/** Options after validation and default resolution. */
|
|
13
|
+
export interface ResolvedCompareOptions {
|
|
14
|
+
pixelTolerance: number;
|
|
15
|
+
maxDiffPixels: number | undefined;
|
|
16
|
+
maxDiffPercentage: number | undefined;
|
|
17
|
+
ignoreAntialiasing: boolean;
|
|
18
|
+
maxImagePixels: number;
|
|
19
|
+
maxInputBytes: number;
|
|
20
|
+
}
|
|
21
|
+
/** Validate and default the comparison options. Never clamps — bad input throws. */
|
|
22
|
+
export declare function resolveCompareOptions(options?: ScreenshotCompareOptions): ResolvedCompareOptions;
|
|
23
|
+
/**
|
|
24
|
+
* Compare two decoded images. Counts `diffPixels` / `ignoredAntialiasPixels`
|
|
25
|
+
* and, when `output` (a union-sized RGBA buffer) is supplied, paints the diff.
|
|
26
|
+
*
|
|
27
|
+
* Argument order is `(actual, expected)` — see the note in `./types`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function compareDecoded(actual: DecodedImage, expected: DecodedImage, opts: ResolvedCompareOptions, output?: Uint8Array): VisualComparisonResult;
|
|
30
|
+
/**
|
|
31
|
+
* Compare two compressed PNG buffers without disk access, browser capture,
|
|
32
|
+
* retries, or throwing on a normal mismatch. Applies the same byte/pixel input
|
|
33
|
+
* limits as the retrying assertion.
|
|
34
|
+
*
|
|
35
|
+
* Argument order is `(actual, expected)` — see the note in `./types`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function compareScreenshots(actual: Buffer, expected: Buffer, options?: ScreenshotCompareOptions): Promise<VisualComparisonResult>;
|
|
38
|
+
//# sourceMappingURL=compare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../../src/lib/visual/compare.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAK/C,OAAO,EAGL,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC5B,MAAM,YAAY,CAAC;AASpB,uDAAuD;AACvD,MAAM,WAAW,sBAAsB;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;CACvB;AAUD,oFAAoF;AACpF,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,wBAA6B,GAAG,sBAAsB,CAgDpG;AAiBD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,YAAY,EACtB,IAAI,EAAE,sBAAsB,EAC5B,MAAM,CAAC,EAAE,UAAU,GAClB,sBAAsB,CA2FxB;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,sBAAsB,CAAC,CA2BjC"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-channel comparison and threshold policy over decoded RGBA images.
|
|
3
|
+
*
|
|
4
|
+
* This is small, dependency-free code over fixed-length arrays — deliberately
|
|
5
|
+
* owned rather than delegated, unlike the PNG parser. The same loop both counts
|
|
6
|
+
* differences (normal retries) and, when handed an optional diff output buffer,
|
|
7
|
+
* paints the diagnostic image (final failure only), so the two can never
|
|
8
|
+
* disagree about which pixels differ.
|
|
9
|
+
*/
|
|
10
|
+
import { CraftdriverError, ErrorCode } from '../errors.js';
|
|
11
|
+
import { pngjsCodec } from './pngjsCodec.js';
|
|
12
|
+
import { validatePngHeaderAndSize } from './pngHeader.js';
|
|
13
|
+
import { isAntialiased } from './antialias.js';
|
|
14
|
+
import { blendOverWhite, rgb2y, visibleRgb } from './pixelMath.js';
|
|
15
|
+
import { DEFAULT_MAX_IMAGE_PIXELS, DEFAULT_MAX_INPUT_BYTES, } from './types.js';
|
|
16
|
+
/** Diagnostic diff colours. */
|
|
17
|
+
const RED = [255, 0, 0, 255];
|
|
18
|
+
const YELLOW = [255, 255, 0, 255];
|
|
19
|
+
const MAGENTA = [255, 0, 255, 255];
|
|
20
|
+
/** How much of the actual image bleeds through as dimmed grayscale context. */
|
|
21
|
+
const GRAY_ALPHA = 0.1;
|
|
22
|
+
function invalid(message, detail) {
|
|
23
|
+
throw new CraftdriverError(ErrorCode.INVALID_ARGUMENT, message, detail ? { detail } : undefined);
|
|
24
|
+
}
|
|
25
|
+
function requireInteger(value, name) {
|
|
26
|
+
if (!Number.isInteger(value))
|
|
27
|
+
invalid(`${name} must be an integer, got ${value}.`, { [name]: value });
|
|
28
|
+
}
|
|
29
|
+
/** Validate and default the comparison options. Never clamps — bad input throws. */
|
|
30
|
+
export function resolveCompareOptions(options = {}) {
|
|
31
|
+
const pixelTolerance = options.pixelTolerance ?? 0;
|
|
32
|
+
requireInteger(pixelTolerance, 'pixelTolerance');
|
|
33
|
+
if (pixelTolerance < 0 || pixelTolerance > 255) {
|
|
34
|
+
invalid(`pixelTolerance must be within 0..255, got ${pixelTolerance}.`, { pixelTolerance });
|
|
35
|
+
}
|
|
36
|
+
let maxDiffPixels;
|
|
37
|
+
if (options.maxDiffPixels !== undefined) {
|
|
38
|
+
requireInteger(options.maxDiffPixels, 'maxDiffPixels');
|
|
39
|
+
if (options.maxDiffPixels < 0) {
|
|
40
|
+
invalid(`maxDiffPixels must be >= 0, got ${options.maxDiffPixels}.`, { maxDiffPixels: options.maxDiffPixels });
|
|
41
|
+
}
|
|
42
|
+
maxDiffPixels = options.maxDiffPixels;
|
|
43
|
+
}
|
|
44
|
+
let maxDiffPercentage;
|
|
45
|
+
if (options.maxDiffPercentage !== undefined) {
|
|
46
|
+
if (!Number.isFinite(options.maxDiffPercentage) || options.maxDiffPercentage < 0 || options.maxDiffPercentage > 100) {
|
|
47
|
+
invalid(`maxDiffPercentage must be within 0..100, got ${options.maxDiffPercentage}.`, {
|
|
48
|
+
maxDiffPercentage: options.maxDiffPercentage,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
maxDiffPercentage = options.maxDiffPercentage;
|
|
52
|
+
}
|
|
53
|
+
const maxImagePixels = options.maxImagePixels ?? DEFAULT_MAX_IMAGE_PIXELS;
|
|
54
|
+
requireInteger(maxImagePixels, 'maxImagePixels');
|
|
55
|
+
if (maxImagePixels < 1)
|
|
56
|
+
invalid(`maxImagePixels must be >= 1, got ${maxImagePixels}.`, { maxImagePixels });
|
|
57
|
+
const maxInputBytes = options.maxInputBytes ?? DEFAULT_MAX_INPUT_BYTES;
|
|
58
|
+
requireInteger(maxInputBytes, 'maxInputBytes');
|
|
59
|
+
if (maxInputBytes < 1)
|
|
60
|
+
invalid(`maxInputBytes must be >= 1, got ${maxInputBytes}.`, { maxInputBytes });
|
|
61
|
+
if (options.ignoreAntialiasing !== undefined && typeof options.ignoreAntialiasing !== 'boolean') {
|
|
62
|
+
// A JSON/JavaScript caller passing "false" (a truthy string) must not
|
|
63
|
+
// silently enable AA ignoring and hide regressions.
|
|
64
|
+
invalid(`ignoreAntialiasing must be a boolean, got ${typeof options.ignoreAntialiasing}.`);
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
pixelTolerance,
|
|
68
|
+
maxDiffPixels,
|
|
69
|
+
maxDiffPercentage,
|
|
70
|
+
ignoreAntialiasing: options.ignoreAntialiasing ?? false,
|
|
71
|
+
maxImagePixels,
|
|
72
|
+
maxInputBytes,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function draw(output, pos, rgba) {
|
|
76
|
+
output[pos] = rgba[0];
|
|
77
|
+
output[pos + 1] = rgba[1];
|
|
78
|
+
output[pos + 2] = rgba[2];
|
|
79
|
+
output[pos + 3] = rgba[3];
|
|
80
|
+
}
|
|
81
|
+
/** Dimmed grayscale of the actual pixel — context in the diff artifact. */
|
|
82
|
+
function drawContext(output, outPos, actual, srcPos) {
|
|
83
|
+
const a = actual[srcPos + 3];
|
|
84
|
+
const [r, g, b] = [0, 1, 2].map((i) => actual[srcPos + i]);
|
|
85
|
+
const val = blendOverWhite(rgb2y(r, g, b), GRAY_ALPHA * a);
|
|
86
|
+
draw(output, outPos, [val, val, val, 255]);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Compare two decoded images. Counts `diffPixels` / `ignoredAntialiasPixels`
|
|
90
|
+
* and, when `output` (a union-sized RGBA buffer) is supplied, paints the diff.
|
|
91
|
+
*
|
|
92
|
+
* Argument order is `(actual, expected)` — see the note in `./types`.
|
|
93
|
+
*/
|
|
94
|
+
export function compareDecoded(actual, expected, opts, output) {
|
|
95
|
+
const dimensionMismatch = actual.width !== expected.width || actual.height !== expected.height;
|
|
96
|
+
// Diff canvas is the bounding box; both images are anchored at (0, 0).
|
|
97
|
+
const canvasWidth = Math.max(actual.width, expected.width);
|
|
98
|
+
const canvasHeight = Math.max(actual.height, expected.height);
|
|
99
|
+
const overlapWidth = Math.min(actual.width, expected.width);
|
|
100
|
+
const overlapHeight = Math.min(actual.height, expected.height);
|
|
101
|
+
// Counts/percentage are over the *union* of the two top-left rectangles —
|
|
102
|
+
// the bounding-box corner present in neither image is excluded.
|
|
103
|
+
const totalPixels = actual.width * actual.height +
|
|
104
|
+
expected.width * expected.height -
|
|
105
|
+
overlapWidth * overlapHeight;
|
|
106
|
+
const va = [0, 0, 0];
|
|
107
|
+
const ve = [0, 0, 0];
|
|
108
|
+
const tol = opts.pixelTolerance;
|
|
109
|
+
let diffPixels = 0;
|
|
110
|
+
let ignoredAntialiasPixels = 0;
|
|
111
|
+
for (let y = 0; y < canvasHeight; y++) {
|
|
112
|
+
for (let x = 0; x < canvasWidth; x++) {
|
|
113
|
+
const outPos = (y * canvasWidth + x) * 4;
|
|
114
|
+
const inActual = x < actual.width && y < actual.height;
|
|
115
|
+
const inExpected = x < expected.width && y < expected.height;
|
|
116
|
+
// Present in neither image (the bounding-box corner): leave it
|
|
117
|
+
// transparent in the diff and don't count it.
|
|
118
|
+
if (!inActual && !inExpected)
|
|
119
|
+
continue;
|
|
120
|
+
if (!(inActual && inExpected)) {
|
|
121
|
+
// Present in only one image (dimension mismatch): always a difference.
|
|
122
|
+
diffPixels++;
|
|
123
|
+
if (output)
|
|
124
|
+
draw(output, outPos, MAGENTA);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const aPos = (y * actual.width + x) * 4;
|
|
128
|
+
const ePos = (y * expected.width + x) * 4;
|
|
129
|
+
visibleRgb(actual.data, aPos, va);
|
|
130
|
+
visibleRgb(expected.data, ePos, ve);
|
|
131
|
+
const equal = Math.abs(va[0] - ve[0]) <= tol &&
|
|
132
|
+
Math.abs(va[1] - ve[1]) <= tol &&
|
|
133
|
+
Math.abs(va[2] - ve[2]) <= tol;
|
|
134
|
+
if (equal) {
|
|
135
|
+
if (output)
|
|
136
|
+
drawContext(output, outPos, actual.data, aPos);
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (opts.ignoreAntialiasing &&
|
|
140
|
+
isAntialiased(actual.data, expected.data, x, y, actual.width, expected.width, overlapWidth, overlapHeight)) {
|
|
141
|
+
ignoredAntialiasPixels++;
|
|
142
|
+
if (output)
|
|
143
|
+
draw(output, outPos, YELLOW);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
diffPixels++;
|
|
147
|
+
if (output)
|
|
148
|
+
draw(output, outPos, RED);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const diffPercentage = totalPixels === 0 ? 0 : (diffPixels / totalPixels) * 100;
|
|
152
|
+
let matches;
|
|
153
|
+
if (dimensionMismatch) {
|
|
154
|
+
matches = false;
|
|
155
|
+
}
|
|
156
|
+
else if (opts.maxDiffPixels === undefined && opts.maxDiffPercentage === undefined) {
|
|
157
|
+
matches = diffPixels === 0;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
matches =
|
|
161
|
+
(opts.maxDiffPixels === undefined || diffPixels <= opts.maxDiffPixels) &&
|
|
162
|
+
(opts.maxDiffPercentage === undefined || diffPercentage <= opts.maxDiffPercentage);
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
matches,
|
|
166
|
+
diffPixels,
|
|
167
|
+
diffPercentage,
|
|
168
|
+
ignoredAntialiasPixels,
|
|
169
|
+
expectedWidth: expected.width,
|
|
170
|
+
expectedHeight: expected.height,
|
|
171
|
+
actualWidth: actual.width,
|
|
172
|
+
actualHeight: actual.height,
|
|
173
|
+
dimensionMismatch,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Compare two compressed PNG buffers without disk access, browser capture,
|
|
178
|
+
* retries, or throwing on a normal mismatch. Applies the same byte/pixel input
|
|
179
|
+
* limits as the retrying assertion.
|
|
180
|
+
*
|
|
181
|
+
* Argument order is `(actual, expected)` — see the note in `./types`.
|
|
182
|
+
*/
|
|
183
|
+
export async function compareScreenshots(actual, expected, options) {
|
|
184
|
+
const opts = resolveCompareOptions(options);
|
|
185
|
+
const limits = { maxImagePixels: opts.maxImagePixels, maxInputBytes: opts.maxInputBytes };
|
|
186
|
+
const { width, height } = validatePngHeaderAndSize(expected, limits, 'baseline');
|
|
187
|
+
validatePngHeaderAndSize(actual, limits, 'screenshot');
|
|
188
|
+
// Fast path: identical compressed bytes necessarily mean identical pixels, so
|
|
189
|
+
// there is nothing to decode. Mirrors the retrying assertion's fast path.
|
|
190
|
+
if (actual.length === expected.length && actual.equals(expected)) {
|
|
191
|
+
return {
|
|
192
|
+
matches: true,
|
|
193
|
+
diffPixels: 0,
|
|
194
|
+
diffPercentage: 0,
|
|
195
|
+
ignoredAntialiasPixels: 0,
|
|
196
|
+
expectedWidth: width,
|
|
197
|
+
expectedHeight: height,
|
|
198
|
+
actualWidth: width,
|
|
199
|
+
actualHeight: height,
|
|
200
|
+
dimensionMismatch: false,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
const [actualImage, expectedImage] = await Promise.all([
|
|
204
|
+
pngjsCodec.decode(actual),
|
|
205
|
+
pngjsCodec.decode(expected),
|
|
206
|
+
]);
|
|
207
|
+
return compareDecoded(actualImage, expectedImage, opts);
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=compare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare.js","sourceRoot":"","sources":["../../../src/lib/visual/compare.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EACL,wBAAwB,EACxB,uBAAuB,GAGxB,MAAM,YAAY,CAAC;AAEpB,+BAA+B;AAC/B,MAAM,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAU,CAAC;AACtC,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAU,CAAC;AAC3C,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC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AM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAc,EACd,QAAgB,EAChB,OAAkC;IAElC,MAAM,IAAI,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC;IAC1F,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IACjF,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IAEvD,8EAA8E;IAC9E,0EAA0E;IAC1E,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjE,OAAO;YACL,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,CAAC;YACb,cAAc,EAAE,CAAC;YACjB,sBAAsB,EAAE,CAAC;YACzB,aAAa,EAAE,KAAK;YACpB,cAAc,EAAE,MAAM;YACtB,WAAW,EAAE,KAAK;YAClB,YAAY,EAAE,MAAM;YACpB,iBAAiB,EAAE,KAAK;SACzB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACrD,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC;QACzB,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC;KAC5B,CAAC,CAAC;IACH,OAAO,cAAc,CAAC,WAAW,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy diff painting. Allocated and run exactly once, only after a visual
|
|
3
|
+
* assertion has finally failed — never during retries. Reuses the comparison
|
|
4
|
+
* loop in `./compare` with an output buffer so the painted diff and the counted
|
|
5
|
+
* result use identical pixel semantics.
|
|
6
|
+
*/
|
|
7
|
+
import type { DecodedImage } from './codec.js';
|
|
8
|
+
import { type ResolvedCompareOptions } from './compare.js';
|
|
9
|
+
/**
|
|
10
|
+
* Produce a diagnostic diff image sized to the union of both inputs (top-left
|
|
11
|
+
* aligned). Unchanged pixels appear as dimmed grayscale actual content,
|
|
12
|
+
* counted differences as red, ignored anti-aliased pixels as yellow, and areas
|
|
13
|
+
* present in only one image (dimension mismatch) as magenta.
|
|
14
|
+
*
|
|
15
|
+
* Argument order is `(actual, expected)` — see the note in `./types`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createDiff(actual: DecodedImage, expected: DecodedImage, opts: ResolvedCompareOptions): DecodedImage;
|
|
18
|
+
//# sourceMappingURL=diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/lib/visual/diff.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAkB,KAAK,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE3E;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,YAAY,EACtB,IAAI,EAAE,sBAAsB,GAC3B,YAAY,CAMd"}
|