sniff-qa 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +39 -0
- package/NOTICE +7 -4
- package/README.md +35 -7
- package/THIRD-PARTY-NOTICES.md +1800 -0
- package/dist/{accessibility-JXRMWF5Y.js → accessibility-42JOUOGH.js} +8 -2
- package/dist/{anthropic-api-7PHYF6PN.js → anthropic-api-VSG2X6FS.js} +7 -5
- package/dist/assert-budget-WG4BRCLX.js +10 -0
- package/dist/{caps-G3ZGJI7B.js → caps-YZPFNPIN.js} +3 -2
- package/dist/{chunk-VEI2O6AK.js → chunk-33JL2AB5.js} +14 -6
- package/dist/{chunk-64FUDSRY.js → chunk-3E4W4H6S.js} +8 -5
- package/dist/{chunk-T72SLMTY.js → chunk-3NR2K5B3.js} +2 -1
- package/dist/chunk-3ROWRVZE.js +422 -0
- package/dist/{chunk-MYWWSM3V.js → chunk-3YFE3H23.js} +2 -1
- package/dist/{chunk-MMISGY2Q.js → chunk-4F6ZXOPE.js} +2 -1
- package/dist/chunk-A4TTASVS.js +27862 -0
- package/dist/{chunk-IXDUD2UG.js → chunk-AA744N7E.js} +2 -1
- package/dist/chunk-DZMX3VT2.js +267 -0
- package/dist/{chunk-NG2IGCAK.js → chunk-FR5QCJLH.js} +2 -1
- package/dist/{chunk-GV27IOMC.js → chunk-GC47B6MM.js} +2 -1
- package/dist/chunk-HP4TY3UY.js +80 -0
- package/dist/chunk-LZAPYYNR.js +4595 -0
- package/dist/{chunk-ZM6MGWO4.js → chunk-NBJLMLDA.js} +2 -1
- package/dist/chunk-RAGYZ54R.js +15480 -0
- package/dist/{chunk-GX36BPK7.js → chunk-RSGFFRXQ.js} +2 -2
- package/dist/chunk-SOBWDC35.js +38 -0
- package/dist/{chunk-7BLJCICM.js → chunk-US4HFUCH.js} +3 -2
- package/dist/chunk-YM22FEIA.js +5807 -0
- package/dist/{ci-ISCWZJD3.js → ci-F6FUXT3O.js} +5 -3
- package/dist/{classifier-MWQMQ727.js → classifier-5FQ2FBTO.js} +3 -1
- package/dist/{claude-code-GJPWO6DN.js → claude-code-J43C22IR.js} +7 -5
- package/dist/{claude-exploration-provider-XOVJPJ23.js → claude-exploration-provider-EWQNNE7D.js} +3 -2
- package/dist/cli/index.js +69 -31
- package/dist/compiler-sfc.cjs-JX56AWNS.js +48568 -0
- package/dist/crawl-KN7SW753.js +26 -0
- package/dist/{crawl-command-JHZN4GK7.js → crawl-command-Y45FIXNK.js} +7 -6
- package/dist/{cross-reference-MHNPSLEN.js → cross-reference-XOOBW6UZ.js} +3 -1
- package/dist/{dev-server-detector-XQ5AYPDT.js → dev-server-detector-FMFVKDJR.js} +3 -1
- package/dist/{discover-QKGMYPHK.js → discover-HA63UA4K.js} +20 -18
- package/dist/dist-3CYER35S.js +8 -0
- package/dist/{domain-UQ34YE4B.js → domain-FU3WIW64.js} +45 -30
- package/dist/{edge-cases-ZADKDZHL.js → edge-cases-B6IV3IKK.js} +3 -1
- package/dist/{element-extractor-OZTFBVKZ.js → element-extractor-QAG4MRUO.js} +18 -6
- package/dist/engine-AXB5O4ZH.js +39 -0
- package/dist/{ensure-browsers-5NAQQMEC.js → ensure-browsers-TNMHMLRS.js} +59 -12
- package/dist/errors-NWB25P4K.js +8 -0
- package/dist/esm-IMWPYLSN.js +3469 -0
- package/dist/{fix-R33D34NP.js → fix-IXOEHAOS.js} +12 -5
- package/dist/{flakiness-OLJAY7CS.js → flakiness-7SSSM4SW.js} +3 -2
- package/dist/flakiness-CBKV4U54.js +12 -0
- package/dist/{formatter-4VI3ZX5Y.js → formatter-N4CC7SCM.js} +29 -22
- package/dist/{framework-detector-ISSM2Q2I.js → framework-detector-4ZVHNT7N.js} +3 -1
- package/dist/generator-GGJYWYI2.js +8 -0
- package/dist/index.js +9 -6
- package/dist/{init-IQKT4ANC.js → init-POX5ZJ6V.js} +4 -2
- package/dist/json-4VOVHDQG.js +10 -0
- package/dist/{junit-GL44ATRR.js → junit-V24COOSR.js} +3 -1
- package/dist/{llm-VJAI6H6G.js → llm-TZ2WZGRZ.js} +3 -1
- package/dist/{loader-Z2DUGG5Z.js → loader-AMM63AOJ.js} +12 -3
- package/dist/mcp/server.js +13035 -72
- package/dist/{model-SP6HJN6J.js → model-BL2AID5Q.js} +6 -5
- package/dist/page-hooks-SECSGZR6.js +14 -0
- package/dist/{page-state-extractor-GYYLYRFR.js → page-state-extractor-AP4FQVLY.js} +3 -1
- package/dist/{performance-7HWKY5O2.js → performance-JVEYVBTV.js} +9 -3
- package/dist/{persistence-XLFJ5EY4.js → persistence-SHKJVSIS.js} +5 -4
- package/dist/{persistence-KTCRIGHU.js → persistence-SQ6QT3HP.js} +3 -1
- package/dist/picocolors-3W2AX5TJ.js +6 -0
- package/dist/pixelmatch-GATIVDQX.js +188 -0
- package/dist/png-HTC2G4ZG.js +2093 -0
- package/dist/{prompt-builder-JT3GQBYP.js → prompt-builder-EI2BFKLZ.js} +3 -1
- package/dist/{provider-MMQ6EIBV.js → provider-O3UOALQH.js} +14 -12
- package/dist/{quality-run-KJMBBAQT.js → quality-run-CTLX5YA5.js} +12 -10
- package/dist/{redaction-CHAIVPCF.js → redaction-QNBV5QZ3.js} +4 -3
- package/dist/{registry-5XCXUAYJ.js → registry-JBBTSD7I.js} +3 -1
- package/dist/{repo-analyzer-4OURSITY.js → repo-analyzer-4XITIIAF.js} +6 -4
- package/dist/{report-SDZWX25B.js → report-4UVJL7QV.js} +3 -1
- package/dist/{report-XK2MCX2N.js → report-BOVSPRCR.js} +8 -6
- package/dist/{response-parser-PUGNWF7S.js → response-parser-GHVJSYXQ.js} +3 -2
- package/dist/{route-discoverer-QBZCRQLJ.js → route-discoverer-ZXYJQIYE.js} +15 -8
- package/dist/{runner-RDVVIGBU.js → runner-DOLCFA3S.js} +10 -5
- package/dist/{runner-QHSYX7J2.js → runner-MCSDHFLN.js} +12 -7
- package/dist/{runner-AXZXNWYH.js → runner-MUBXHOIG.js} +10 -4
- package/dist/{scenarios-I7YYVTD2.js → scenarios-T2U6ZDRL.js} +3 -1
- package/dist/sdk-FQKA5HSQ.js +7184 -0
- package/dist/{source-5LS2B7TN.js → source-T5MHBY5G.js} +14 -7
- package/dist/{tiebreak-L5UFNKU2.js → tiebreak-SXBXPT7B.js} +3 -1
- package/dist/{unified-OEGLPOGE.js → unified-NUR2X5JV.js} +23 -21
- package/dist/{update-baselines-JYKUUIZG.js → update-baselines-TMERPIDV.js} +4 -2
- package/dist/version-FEHABGAH.js +10 -0
- package/dist/{visual-EUZG2STF.js → visual-XHFPFQFX.js} +5 -3
- package/dist/{workflow-template-6DADGPHA.js → workflow-template-7C5CCK67.js} +13 -7
- package/dist/{write-report-Y4UPVXUO.js → write-report-6Q4MXBYD.js} +5 -4
- package/package.json +18 -9
- package/dist/accessibility-JXRMWF5Y.js.map +0 -1
- package/dist/anthropic-api-7PHYF6PN.js.map +0 -1
- package/dist/assert-budget-NBF3JYM7.js +0 -9
- package/dist/assert-budget-NBF3JYM7.js.map +0 -1
- package/dist/caps-G3ZGJI7B.js.map +0 -1
- package/dist/chunk-64FUDSRY.js.map +0 -1
- package/dist/chunk-7BLJCICM.js.map +0 -1
- package/dist/chunk-GV27IOMC.js.map +0 -1
- package/dist/chunk-GX36BPK7.js.map +0 -1
- package/dist/chunk-IXDUD2UG.js.map +0 -1
- package/dist/chunk-MMISGY2Q.js.map +0 -1
- package/dist/chunk-MYWWSM3V.js.map +0 -1
- package/dist/chunk-NG2IGCAK.js.map +0 -1
- package/dist/chunk-T72SLMTY.js.map +0 -1
- package/dist/chunk-VEI2O6AK.js.map +0 -1
- package/dist/chunk-ZM6MGWO4.js.map +0 -1
- package/dist/ci-ISCWZJD3.js.map +0 -1
- package/dist/classifier-MWQMQ727.js.map +0 -1
- package/dist/claude-code-GJPWO6DN.js.map +0 -1
- package/dist/claude-exploration-provider-XOVJPJ23.js.map +0 -1
- package/dist/cli/index.js.map +0 -1
- package/dist/crawl-XPHT3KIZ.js +0 -23
- package/dist/crawl-XPHT3KIZ.js.map +0 -1
- package/dist/crawl-command-JHZN4GK7.js.map +0 -1
- package/dist/cross-reference-MHNPSLEN.js.map +0 -1
- package/dist/dev-server-detector-XQ5AYPDT.js.map +0 -1
- package/dist/discover-QKGMYPHK.js.map +0 -1
- package/dist/domain-UQ34YE4B.js.map +0 -1
- package/dist/edge-cases-ZADKDZHL.js.map +0 -1
- package/dist/element-extractor-OZTFBVKZ.js.map +0 -1
- package/dist/ensure-browsers-5NAQQMEC.js.map +0 -1
- package/dist/errors-RFEOR527.js +0 -7
- package/dist/errors-RFEOR527.js.map +0 -1
- package/dist/fix-R33D34NP.js.map +0 -1
- package/dist/flakiness-OLJAY7CS.js.map +0 -1
- package/dist/flakiness-OVC7KGN2.js +0 -11
- package/dist/flakiness-OVC7KGN2.js.map +0 -1
- package/dist/formatter-4VI3ZX5Y.js.map +0 -1
- package/dist/framework-detector-ISSM2Q2I.js.map +0 -1
- package/dist/generator-AFHVMWC3.js +0 -7
- package/dist/generator-AFHVMWC3.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/init-IQKT4ANC.js.map +0 -1
- package/dist/json-YDWEB33Q.js +0 -8
- package/dist/json-YDWEB33Q.js.map +0 -1
- package/dist/junit-GL44ATRR.js.map +0 -1
- package/dist/llm-VJAI6H6G.js.map +0 -1
- package/dist/loader-Z2DUGG5Z.js.map +0 -1
- package/dist/mcp/server.js.map +0 -1
- package/dist/model-SP6HJN6J.js.map +0 -1
- package/dist/page-hooks-6RALVZB5.js +0 -13
- package/dist/page-hooks-6RALVZB5.js.map +0 -1
- package/dist/page-state-extractor-GYYLYRFR.js.map +0 -1
- package/dist/performance-7HWKY5O2.js.map +0 -1
- package/dist/persistence-KTCRIGHU.js.map +0 -1
- package/dist/persistence-XLFJ5EY4.js.map +0 -1
- package/dist/prompt-builder-JT3GQBYP.js.map +0 -1
- package/dist/provider-MMQ6EIBV.js.map +0 -1
- package/dist/quality-run-KJMBBAQT.js.map +0 -1
- package/dist/redaction-CHAIVPCF.js.map +0 -1
- package/dist/registry-5XCXUAYJ.js.map +0 -1
- package/dist/repo-analyzer-4OURSITY.js.map +0 -1
- package/dist/report-SDZWX25B.js.map +0 -1
- package/dist/report-XK2MCX2N.js.map +0 -1
- package/dist/response-parser-PUGNWF7S.js.map +0 -1
- package/dist/route-discoverer-QBZCRQLJ.js.map +0 -1
- package/dist/runner-AXZXNWYH.js.map +0 -1
- package/dist/runner-QHSYX7J2.js.map +0 -1
- package/dist/runner-RDVVIGBU.js.map +0 -1
- package/dist/scenarios-I7YYVTD2.js.map +0 -1
- package/dist/source-5LS2B7TN.js.map +0 -1
- package/dist/tiebreak-L5UFNKU2.js.map +0 -1
- package/dist/unified-OEGLPOGE.js.map +0 -1
- package/dist/update-baselines-JYKUUIZG.js.map +0 -1
- package/dist/version-FLE7ZHDX.js +0 -7
- package/dist/version-FLE7ZHDX.js.map +0 -1
- package/dist/visual-EUZG2STF.js.map +0 -1
- package/dist/workflow-template-6DADGPHA.js.map +0 -1
- package/dist/write-report-Y4UPVXUO.js.map +0 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { createRequire as __sniffCreateRequire } from 'node:module'; const require = __sniffCreateRequire(import.meta.url);
|
|
1
2
|
import {
|
|
2
3
|
getVersion
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-33JL2AB5.js";
|
|
5
|
+
import "./chunk-SOBWDC35.js";
|
|
4
6
|
|
|
5
7
|
// src/report/model.ts
|
|
6
8
|
import { mkdir, writeFile } from "fs/promises";
|
|
@@ -52,21 +54,21 @@ function buildReport(results, metadata, screenshots) {
|
|
|
52
54
|
async function saveReport(rootDir, rawReport, formats) {
|
|
53
55
|
const dir = join(rootDir, ".sniff", "reports");
|
|
54
56
|
await mkdir(dir, { recursive: true });
|
|
55
|
-
const { redactValue } = await import("./redaction-
|
|
57
|
+
const { redactValue } = await import("./redaction-QNBV5QZ3.js");
|
|
56
58
|
const report = redactValue(rawReport);
|
|
57
59
|
const slug = report.metadata.timestamp.replace(/[:.]/g, "-").slice(0, 19);
|
|
58
60
|
const savedPaths = [];
|
|
59
61
|
for (const format of formats) {
|
|
60
62
|
switch (format) {
|
|
61
63
|
case "json": {
|
|
62
|
-
const { generateJsonReport } = await import("./json-
|
|
64
|
+
const { generateJsonReport } = await import("./json-4VOVHDQG.js");
|
|
63
65
|
const jsonPath = join(dir, `report-${slug}.json`);
|
|
64
66
|
await writeFile(jsonPath, generateJsonReport(report), "utf-8");
|
|
65
67
|
savedPaths.push(jsonPath);
|
|
66
68
|
break;
|
|
67
69
|
}
|
|
68
70
|
case "junit": {
|
|
69
|
-
const { generateJunitReport } = await import("./junit-
|
|
71
|
+
const { generateJunitReport } = await import("./junit-V24COOSR.js");
|
|
70
72
|
const xmlPath = join(dir, `report-${slug}.xml`);
|
|
71
73
|
await writeFile(xmlPath, generateJunitReport(report), "utf-8");
|
|
72
74
|
savedPaths.push(xmlPath);
|
|
@@ -91,4 +93,3 @@ export {
|
|
|
91
93
|
buildReport,
|
|
92
94
|
saveReport
|
|
93
95
|
};
|
|
94
|
-
//# sourceMappingURL=model-SP6HJN6J.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createRequire as __sniffCreateRequire } from 'node:module'; const require = __sniffCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
ConsoleErrorHook,
|
|
4
|
+
NetworkFailureHook,
|
|
5
|
+
PageHookPipeline,
|
|
6
|
+
ScreenshotHook
|
|
7
|
+
} from "./chunk-3YFE3H23.js";
|
|
8
|
+
import "./chunk-SOBWDC35.js";
|
|
9
|
+
export {
|
|
10
|
+
ConsoleErrorHook,
|
|
11
|
+
NetworkFailureHook,
|
|
12
|
+
PageHookPipeline,
|
|
13
|
+
ScreenshotHook
|
|
14
|
+
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { createRequire as __sniffCreateRequire } from 'node:module'; const require = __sniffCreateRequire(import.meta.url);
|
|
2
|
+
import "./chunk-SOBWDC35.js";
|
|
3
|
+
|
|
1
4
|
// src/exploration/page-state-extractor.ts
|
|
2
5
|
async function extractPageState(page) {
|
|
3
6
|
const url = page.url();
|
|
@@ -72,4 +75,3 @@ async function extractPageState(page) {
|
|
|
72
75
|
export {
|
|
73
76
|
extractPageState
|
|
74
77
|
};
|
|
75
|
-
//# sourceMappingURL=page-state-extractor-GYYLYRFR.js.map
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { createRequire as __sniffCreateRequire } from 'node:module'; const require = __sniffCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
loadEngine
|
|
4
|
+
} from "./chunk-DZMX3VT2.js";
|
|
5
|
+
import "./chunk-33JL2AB5.js";
|
|
6
|
+
import "./chunk-SOBWDC35.js";
|
|
7
|
+
|
|
1
8
|
// src/scanners/performance/index.ts
|
|
2
9
|
import { performance as perf } from "perf_hooks";
|
|
3
10
|
var METRIC_DEFS = {
|
|
@@ -47,8 +54,8 @@ var PerformanceScanner = class {
|
|
|
47
54
|
return { scanner: this.name, findings: [], duration: perf.now() - start, metadata: { noUrls: true } };
|
|
48
55
|
}
|
|
49
56
|
const budgets = this.config?.performance?.budgets ?? DEFAULT_BUDGETS;
|
|
50
|
-
const lighthouse = (await import("lighthouse")).default;
|
|
51
|
-
const chromeLauncher = await import("chrome-launcher");
|
|
57
|
+
const lighthouse = (await loadEngine("lighthouse", () => import("lighthouse"))).default;
|
|
58
|
+
const chromeLauncher = await loadEngine("chrome-launcher", () => import("chrome-launcher"));
|
|
52
59
|
const chrome = await chromeLauncher.launch({
|
|
53
60
|
chromeFlags: ["--headless", "--no-sandbox"]
|
|
54
61
|
});
|
|
@@ -134,4 +141,3 @@ var PerformanceScanner = class {
|
|
|
134
141
|
export {
|
|
135
142
|
PerformanceScanner
|
|
136
143
|
};
|
|
137
|
-
//# sourceMappingURL=performance-7HWKY5O2.js.map
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { createRequire as __sniffCreateRequire } from 'node:module'; const require = __sniffCreateRequire(import.meta.url);
|
|
1
2
|
import {
|
|
2
3
|
computeFlakeStatus
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NBJLMLDA.js";
|
|
4
5
|
import {
|
|
5
6
|
redactValue
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-RSGFFRXQ.js";
|
|
8
|
+
import "./chunk-AA744N7E.js";
|
|
9
|
+
import "./chunk-SOBWDC35.js";
|
|
8
10
|
|
|
9
11
|
// src/core/persistence.ts
|
|
10
12
|
import { mkdir, writeFile, readFile } from "fs/promises";
|
|
@@ -87,4 +89,3 @@ export {
|
|
|
87
89
|
loadLastResults,
|
|
88
90
|
saveResults
|
|
89
91
|
};
|
|
90
|
-
//# sourceMappingURL=persistence-XLFJ5EY4.js.map
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { createRequire as __sniffCreateRequire } from 'node:module'; const require = __sniffCreateRequire(import.meta.url);
|
|
2
|
+
import "./chunk-SOBWDC35.js";
|
|
3
|
+
|
|
1
4
|
// src/discovery/persistence/frontmatter.ts
|
|
2
5
|
var FRONTMATTER_OPEN = "---json";
|
|
3
6
|
var FRONTMATTER_CLOSE = "---";
|
|
@@ -267,4 +270,3 @@ export {
|
|
|
267
270
|
scenarioToMarkdown,
|
|
268
271
|
serializeJsonFrontmatter
|
|
269
272
|
};
|
|
270
|
-
//# sourceMappingURL=persistence-KTCRIGHU.js.map
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { createRequire as __sniffCreateRequire } from 'node:module'; const require = __sniffCreateRequire(import.meta.url);
|
|
2
|
+
import "./chunk-SOBWDC35.js";
|
|
3
|
+
|
|
4
|
+
// node_modules/pixelmatch/index.js
|
|
5
|
+
function pixelmatch(img1, img2, output, width, height, options = {}) {
|
|
6
|
+
const {
|
|
7
|
+
threshold = 0.1,
|
|
8
|
+
alpha = 0.1,
|
|
9
|
+
aaColor = [255, 255, 0],
|
|
10
|
+
diffColor = [255, 0, 0],
|
|
11
|
+
checkerboard = true,
|
|
12
|
+
includeAA,
|
|
13
|
+
diffColorAlt,
|
|
14
|
+
diffMask
|
|
15
|
+
} = options;
|
|
16
|
+
if (!isPixelData(img1) || !isPixelData(img2) || output && !isPixelData(output))
|
|
17
|
+
throw new Error("Image data: Uint8Array, Uint8ClampedArray or Buffer expected.");
|
|
18
|
+
if (img1.length !== img2.length || output && output.length !== img1.length)
|
|
19
|
+
throw new Error(`Image sizes do not match. Image 1 size: ${img1.length}, image 2 size: ${img2.length}`);
|
|
20
|
+
if (img1.length !== width * height * 4) throw new Error(`Image data size does not match width/height. Expecting ${width * height * 4}. Got ${img1.length}`);
|
|
21
|
+
const len = width * height;
|
|
22
|
+
const a32 = new Uint32Array(img1.buffer, img1.byteOffset, len);
|
|
23
|
+
const b32 = new Uint32Array(img2.buffer, img2.byteOffset, len);
|
|
24
|
+
let identical = true;
|
|
25
|
+
for (let i = 0; i < len; i++) {
|
|
26
|
+
if (a32[i] !== b32[i]) {
|
|
27
|
+
identical = false;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (identical) {
|
|
32
|
+
if (output && !diffMask) {
|
|
33
|
+
for (let i = 0, pos = 0; i < len; i++, pos += 4) drawGrayPixel(img1, pos, alpha, output);
|
|
34
|
+
}
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
const maxDelta = 35215 * threshold * threshold;
|
|
38
|
+
const [aaR, aaG, aaB] = aaColor;
|
|
39
|
+
const [diffR, diffG, diffB] = diffColor;
|
|
40
|
+
const [altR, altG, altB] = diffColorAlt || diffColor;
|
|
41
|
+
let diff = 0;
|
|
42
|
+
for (let i = 0, pos = 0; i < len; i++, pos += 4) {
|
|
43
|
+
const delta = a32[i] === b32[i] ? 0 : colorDelta(img1, img2, pos, pos, checkerboard);
|
|
44
|
+
if (Math.abs(delta) > maxDelta) {
|
|
45
|
+
const x = i % width;
|
|
46
|
+
const y = i / width | 0;
|
|
47
|
+
const isExcludedAA = !includeAA && (antialiased(img1, x, y, width, height, a32, b32, checkerboard) || antialiased(img2, x, y, width, height, b32, a32, checkerboard));
|
|
48
|
+
if (isExcludedAA) {
|
|
49
|
+
if (output && !diffMask) drawPixel(output, pos, aaR, aaG, aaB);
|
|
50
|
+
} else {
|
|
51
|
+
if (output) {
|
|
52
|
+
if (delta < 0) {
|
|
53
|
+
drawPixel(output, pos, altR, altG, altB);
|
|
54
|
+
} else {
|
|
55
|
+
drawPixel(output, pos, diffR, diffG, diffB);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
diff++;
|
|
59
|
+
}
|
|
60
|
+
} else if (output && !diffMask) {
|
|
61
|
+
drawGrayPixel(img1, pos, alpha, output);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return diff;
|
|
65
|
+
}
|
|
66
|
+
function isPixelData(arr) {
|
|
67
|
+
return ArrayBuffer.isView(arr) && arr.BYTES_PER_ELEMENT === 1;
|
|
68
|
+
}
|
|
69
|
+
function antialiased(img, x1, y1, width, height, a32, b32, checkerboard) {
|
|
70
|
+
const x0 = Math.max(x1 - 1, 0);
|
|
71
|
+
const y0 = Math.max(y1 - 1, 0);
|
|
72
|
+
const x2 = Math.min(x1 + 1, width - 1);
|
|
73
|
+
const y2 = Math.min(y1 + 1, height - 1);
|
|
74
|
+
const pos4 = (y1 * width + x1) * 4;
|
|
75
|
+
const cr = img[pos4];
|
|
76
|
+
const cg = img[pos4 + 1];
|
|
77
|
+
const cb = img[pos4 + 2];
|
|
78
|
+
const ca = img[pos4 + 3];
|
|
79
|
+
let zeroes = x1 === x0 || x1 === x2 || y1 === y0 || y1 === y2 ? 1 : 0;
|
|
80
|
+
let min = 0;
|
|
81
|
+
let max = 0;
|
|
82
|
+
let minX = 0;
|
|
83
|
+
let minY = 0;
|
|
84
|
+
let maxX = 0;
|
|
85
|
+
let maxY = 0;
|
|
86
|
+
for (let x = x0; x <= x2; x++) {
|
|
87
|
+
for (let y = y0; y <= y2; y++) {
|
|
88
|
+
if (x === x1 && y === y1) continue;
|
|
89
|
+
const delta = brightnessDelta(img, pos4, (y * width + x) * 4, cr, cg, cb, ca, checkerboard);
|
|
90
|
+
if (delta === 0) {
|
|
91
|
+
zeroes++;
|
|
92
|
+
if (zeroes > 2) return false;
|
|
93
|
+
} else if (delta < min) {
|
|
94
|
+
min = delta;
|
|
95
|
+
minX = x;
|
|
96
|
+
minY = y;
|
|
97
|
+
} else if (delta > max) {
|
|
98
|
+
max = delta;
|
|
99
|
+
maxX = x;
|
|
100
|
+
maxY = y;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (min === 0 || max === 0) return false;
|
|
105
|
+
return hasManySiblings(a32, minX, minY, width, height) && hasManySiblings(b32, minX, minY, width, height) || hasManySiblings(a32, maxX, maxY, width, height) && hasManySiblings(b32, maxX, maxY, width, height);
|
|
106
|
+
}
|
|
107
|
+
function hasManySiblings(img, x1, y1, width, height) {
|
|
108
|
+
const x0 = Math.max(x1 - 1, 0);
|
|
109
|
+
const y0 = Math.max(y1 - 1, 0);
|
|
110
|
+
const x2 = Math.min(x1 + 1, width - 1);
|
|
111
|
+
const y2 = Math.min(y1 + 1, height - 1);
|
|
112
|
+
const val = img[y1 * width + x1];
|
|
113
|
+
let zeroes = x1 === x0 || x1 === x2 || y1 === y0 || y1 === y2 ? 1 : 0;
|
|
114
|
+
for (let x = x0; x <= x2; x++) {
|
|
115
|
+
for (let y = y0; y <= y2; y++) {
|
|
116
|
+
if (x === x1 && y === y1) continue;
|
|
117
|
+
zeroes += +(val === img[y * width + x]);
|
|
118
|
+
if (zeroes > 2) return true;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
function colorDelta(img1, img2, k, m, checkerboard) {
|
|
124
|
+
const r1 = img1[k];
|
|
125
|
+
const g1 = img1[k + 1];
|
|
126
|
+
const b1 = img1[k + 2];
|
|
127
|
+
const a1 = img1[k + 3];
|
|
128
|
+
const r2 = img2[m];
|
|
129
|
+
const g2 = img2[m + 1];
|
|
130
|
+
const b2 = img2[m + 2];
|
|
131
|
+
const a2 = img2[m + 3];
|
|
132
|
+
let dr = r1 - r2;
|
|
133
|
+
let dg = g1 - g2;
|
|
134
|
+
let db = b1 - b2;
|
|
135
|
+
const da = a1 - a2;
|
|
136
|
+
if (a1 < 255 || a2 < 255) {
|
|
137
|
+
let rb = 255, gb = 255, bb = 255;
|
|
138
|
+
if (checkerboard) {
|
|
139
|
+
rb = 48 + 159 * (k % 2);
|
|
140
|
+
gb = 48 + 159 * ((k / 1.618033988749895 | 0) % 2);
|
|
141
|
+
bb = 48 + 159 * ((k / 2.618033988749895 | 0) % 2);
|
|
142
|
+
}
|
|
143
|
+
dr = (r1 * a1 - r2 * a2 - rb * da) / 255;
|
|
144
|
+
dg = (g1 * a1 - g2 * a2 - gb * da) / 255;
|
|
145
|
+
db = (b1 * a1 - b2 * a2 - bb * da) / 255;
|
|
146
|
+
}
|
|
147
|
+
const y = dr * 0.29889531 + dg * 0.58662247 + db * 0.11448223;
|
|
148
|
+
const i = dr * 0.59597799 - dg * 0.2741761 - db * 0.32180189;
|
|
149
|
+
const q = dr * 0.21147017 - dg * 0.52261711 + db * 0.31114694;
|
|
150
|
+
const delta = 0.5053 * y * y + 0.299 * i * i + 0.1957 * q * q;
|
|
151
|
+
return y > 0 ? -delta : delta;
|
|
152
|
+
}
|
|
153
|
+
function brightnessDelta(img, k, m, r1, g1, b1, a1, checkerboard) {
|
|
154
|
+
const r2 = img[m];
|
|
155
|
+
const g2 = img[m + 1];
|
|
156
|
+
const b2 = img[m + 2];
|
|
157
|
+
const a2 = img[m + 3];
|
|
158
|
+
let dr = r1 - r2;
|
|
159
|
+
let dg = g1 - g2;
|
|
160
|
+
let db = b1 - b2;
|
|
161
|
+
const da = a1 - a2;
|
|
162
|
+
if (!dr && !dg && !db && !da) return 0;
|
|
163
|
+
if (a1 < 255 || a2 < 255) {
|
|
164
|
+
let rb = 255, gb = 255, bb = 255;
|
|
165
|
+
if (checkerboard) {
|
|
166
|
+
rb = 48 + 159 * (k % 2);
|
|
167
|
+
gb = 48 + 159 * ((k / 1.618033988749895 | 0) % 2);
|
|
168
|
+
bb = 48 + 159 * ((k / 2.618033988749895 | 0) % 2);
|
|
169
|
+
}
|
|
170
|
+
dr = (r1 * a1 - r2 * a2 - rb * da) / 255;
|
|
171
|
+
dg = (g1 * a1 - g2 * a2 - gb * da) / 255;
|
|
172
|
+
db = (b1 * a1 - b2 * a2 - bb * da) / 255;
|
|
173
|
+
}
|
|
174
|
+
return dr * 0.29889531 + dg * 0.58662247 + db * 0.11448223;
|
|
175
|
+
}
|
|
176
|
+
function drawPixel(output, pos, r, g, b) {
|
|
177
|
+
output[pos] = r;
|
|
178
|
+
output[pos + 1] = g;
|
|
179
|
+
output[pos + 2] = b;
|
|
180
|
+
output[pos + 3] = 255;
|
|
181
|
+
}
|
|
182
|
+
function drawGrayPixel(img, i, alpha, output) {
|
|
183
|
+
const val = 255 + (img[i] * 0.29889531 + img[i + 1] * 0.58662247 + img[i + 2] * 0.11448223 - 255) * alpha * img[i + 3] / 255;
|
|
184
|
+
drawPixel(output, i, val, val, val);
|
|
185
|
+
}
|
|
186
|
+
export {
|
|
187
|
+
pixelmatch as default
|
|
188
|
+
};
|