@blazediff/matcher 1.2.0 → 1.2.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/package.json +6 -6
- package/dist/index.d.mts +0 -216
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blazediff/matcher",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Core matcher logic for visual regression testing with blazediff",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"picocolors": "^1.1.1",
|
|
36
|
-
"@blazediff/
|
|
37
|
-
"@blazediff/core": "1.9.
|
|
38
|
-
"@blazediff/
|
|
39
|
-
"@blazediff/pngjs-transformer": "2.1.
|
|
40
|
-
"@blazediff/ssim": "1.7.
|
|
36
|
+
"@blazediff/bin": "3.1.1",
|
|
37
|
+
"@blazediff/core": "1.9.1",
|
|
38
|
+
"@blazediff/gmsd": "1.7.1",
|
|
39
|
+
"@blazediff/pngjs-transformer": "2.1.1",
|
|
40
|
+
"@blazediff/ssim": "1.7.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^24.3.0",
|
package/dist/index.d.mts
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Comparison methods available in blazediff
|
|
3
|
-
*/
|
|
4
|
-
type ComparisonMethod = "bin" | "core" | "ssim" | "msssim" | "hitchhikers-ssim" | "gmsd";
|
|
5
|
-
/**
|
|
6
|
-
* Status of a snapshot operation
|
|
7
|
-
*/
|
|
8
|
-
type SnapshotStatus = "added" | "matched" | "updated" | "failed";
|
|
9
|
-
/**
|
|
10
|
-
* Image input - file path, raw PNG buffer, or buffer with dimensions
|
|
11
|
-
*/
|
|
12
|
-
type ImageInput = string | Buffer | Uint8Array | {
|
|
13
|
-
data: Uint8Array | Uint8ClampedArray | Buffer;
|
|
14
|
-
width: number;
|
|
15
|
-
height: number;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Options for the matcher
|
|
19
|
-
*/
|
|
20
|
-
interface MatcherOptions {
|
|
21
|
-
/** Comparison method to use */
|
|
22
|
-
method: ComparisonMethod;
|
|
23
|
-
/**
|
|
24
|
-
* Failure threshold - number of pixels or percentage difference allowed
|
|
25
|
-
* @default 0
|
|
26
|
-
*/
|
|
27
|
-
failureThreshold?: number;
|
|
28
|
-
/**
|
|
29
|
-
* How to interpret failureThreshold
|
|
30
|
-
* @default 'pixel'
|
|
31
|
-
*/
|
|
32
|
-
failureThresholdType?: "pixel" | "percent";
|
|
33
|
-
/**
|
|
34
|
-
* Directory to store snapshots relative to test file
|
|
35
|
-
* @default '__snapshots__'
|
|
36
|
-
*/
|
|
37
|
-
snapshotsDir?: string;
|
|
38
|
-
/**
|
|
39
|
-
* Custom identifier for the snapshot file
|
|
40
|
-
* If not provided, derived from test name
|
|
41
|
-
*/
|
|
42
|
-
snapshotIdentifier?: string;
|
|
43
|
-
/**
|
|
44
|
-
* Snapshot update mode (following Vitest's logic)
|
|
45
|
-
* - 'all': update all snapshots (vitest -u)
|
|
46
|
-
* - 'new': create new snapshots only, don't update existing (default)
|
|
47
|
-
* - 'none': don't create or update any snapshots
|
|
48
|
-
* - true: same as 'all' (backwards compatibility)
|
|
49
|
-
* - false: same as 'new' (backwards compatibility)
|
|
50
|
-
* @default 'new'
|
|
51
|
-
*/
|
|
52
|
-
updateSnapshots?: boolean | "all" | "new" | "none";
|
|
53
|
-
/**
|
|
54
|
-
* Custom update command to display in error messages
|
|
55
|
-
* @default '--update'
|
|
56
|
-
*/
|
|
57
|
-
updateCommand?: string;
|
|
58
|
-
/**
|
|
59
|
-
* Color difference threshold for core/bin methods (0-1)
|
|
60
|
-
* Lower = more strict
|
|
61
|
-
* @default 0.1
|
|
62
|
-
*/
|
|
63
|
-
threshold?: number;
|
|
64
|
-
/**
|
|
65
|
-
* Enable anti-aliasing detection (bin method)
|
|
66
|
-
* @default false
|
|
67
|
-
*/
|
|
68
|
-
antialiasing?: boolean;
|
|
69
|
-
/**
|
|
70
|
-
* Include anti-aliased pixels in diff count (core method)
|
|
71
|
-
* @default false
|
|
72
|
-
*/
|
|
73
|
-
includeAA?: boolean;
|
|
74
|
-
/**
|
|
75
|
-
* Window size for SSIM variants
|
|
76
|
-
* @default 11
|
|
77
|
-
*/
|
|
78
|
-
windowSize?: number;
|
|
79
|
-
/**
|
|
80
|
-
* k1 constant for SSIM
|
|
81
|
-
* @default 0.01
|
|
82
|
-
*/
|
|
83
|
-
k1?: number;
|
|
84
|
-
/**
|
|
85
|
-
* k2 constant for SSIM
|
|
86
|
-
* @default 0.03
|
|
87
|
-
*/
|
|
88
|
-
k2?: number;
|
|
89
|
-
/**
|
|
90
|
-
* Downsample factor for GMSD (0 or 1)
|
|
91
|
-
* @default 0
|
|
92
|
-
*/
|
|
93
|
-
downsample?: 0 | 1;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Result of a comparison operation
|
|
97
|
-
*/
|
|
98
|
-
interface ComparisonResult {
|
|
99
|
-
/** Whether the comparison passed */
|
|
100
|
-
pass: boolean;
|
|
101
|
-
/** Human-readable message describing the result */
|
|
102
|
-
message: string;
|
|
103
|
-
/** Number of different pixels (for pixel-based methods) */
|
|
104
|
-
diffCount?: number;
|
|
105
|
-
/** Percentage of different pixels */
|
|
106
|
-
diffPercentage?: number;
|
|
107
|
-
/** Similarity score (for SSIM/GMSD - 1 = identical for SSIM, 0 = identical for GMSD) */
|
|
108
|
-
score?: number;
|
|
109
|
-
/** Path to baseline snapshot */
|
|
110
|
-
baselinePath?: string;
|
|
111
|
-
/** Path to received image (saved for debugging) */
|
|
112
|
-
receivedPath?: string;
|
|
113
|
-
/** Path to diff visualization */
|
|
114
|
-
diffPath?: string;
|
|
115
|
-
/** Status of the snapshot operation */
|
|
116
|
-
snapshotStatus?: SnapshotStatus;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Context provided by test frameworks
|
|
120
|
-
*/
|
|
121
|
-
interface TestContext {
|
|
122
|
-
/** Absolute path to the test file */
|
|
123
|
-
testPath: string;
|
|
124
|
-
/** Name of the current test */
|
|
125
|
-
testName: string;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Image data with dimensions
|
|
129
|
-
*/
|
|
130
|
-
interface ImageData {
|
|
131
|
-
data: Uint8Array;
|
|
132
|
-
width: number;
|
|
133
|
-
height: number;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
interface RunComparisonResult {
|
|
137
|
-
/** Number of different pixels (for pixel-based methods) */
|
|
138
|
-
diffCount?: number;
|
|
139
|
-
/** Percentage of different pixels */
|
|
140
|
-
diffPercentage?: number;
|
|
141
|
-
/** Score for perceptual methods (SSIM: 1=identical, GMSD: 0=identical) */
|
|
142
|
-
score?: number;
|
|
143
|
-
/** Diff visualization output buffer */
|
|
144
|
-
diffOutput?: Uint8Array;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Validate that the comparison method supports the given input type
|
|
148
|
-
*/
|
|
149
|
-
declare function validateMethodSupportsInput(method: ComparisonMethod, input: ImageInput): void;
|
|
150
|
-
/**
|
|
151
|
-
* Run comparison using the specified method
|
|
152
|
-
*/
|
|
153
|
-
declare function runComparison(received: ImageInput, baseline: ImageInput, method: ComparisonMethod, options: MatcherOptions, diffOutputPath?: string): Promise<RunComparisonResult>;
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Check if input is a file path
|
|
157
|
-
*/
|
|
158
|
-
declare function isFilePath(input: ImageInput): input is string;
|
|
159
|
-
/**
|
|
160
|
-
* Check if input is a raw PNG buffer (Buffer or Uint8Array without dimensions)
|
|
161
|
-
*/
|
|
162
|
-
declare function isRawPngBuffer(input: ImageInput): input is Buffer | Uint8Array;
|
|
163
|
-
/**
|
|
164
|
-
* Check if input is an image buffer with dimensions
|
|
165
|
-
*/
|
|
166
|
-
declare function isImageBuffer(input: ImageInput): input is {
|
|
167
|
-
data: Uint8Array | Uint8ClampedArray | Buffer;
|
|
168
|
-
width: number;
|
|
169
|
-
height: number;
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* Load a PNG image from file path
|
|
173
|
-
*/
|
|
174
|
-
declare function loadPNG(filePath: string): Promise<ImageData>;
|
|
175
|
-
/**
|
|
176
|
-
* Save image data to a PNG file
|
|
177
|
-
*/
|
|
178
|
-
declare function savePNG(filePath: string, data: Uint8Array | Uint8ClampedArray | Buffer, width: number, height: number): Promise<void>;
|
|
179
|
-
/**
|
|
180
|
-
* Normalize image input to ImageData
|
|
181
|
-
* - File path: loads the PNG
|
|
182
|
-
* - Raw PNG buffer: decodes to get dimensions
|
|
183
|
-
* - Buffer with dimensions: returns as-is with normalized Uint8Array
|
|
184
|
-
*/
|
|
185
|
-
declare function normalizeImageInput(input: ImageInput): Promise<ImageData>;
|
|
186
|
-
/**
|
|
187
|
-
* Check if a file exists
|
|
188
|
-
*/
|
|
189
|
-
declare function fileExists(filePath: string): boolean;
|
|
190
|
-
|
|
191
|
-
interface FormatOptions {
|
|
192
|
-
pass: boolean;
|
|
193
|
-
method: ComparisonMethod;
|
|
194
|
-
snapshotCreated: boolean;
|
|
195
|
-
baselinePath: string;
|
|
196
|
-
receivedPath: string;
|
|
197
|
-
diffPath: string;
|
|
198
|
-
diffCount?: number;
|
|
199
|
-
diffPercentage?: number;
|
|
200
|
-
score?: number;
|
|
201
|
-
threshold: number;
|
|
202
|
-
thresholdType: "pixel" | "percent";
|
|
203
|
-
updateCommand?: string;
|
|
204
|
-
}
|
|
205
|
-
declare function formatMessage(opts: FormatOptions): string;
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Main snapshot comparison function
|
|
209
|
-
*/
|
|
210
|
-
declare function getOrCreateSnapshot(received: ImageInput, options: MatcherOptions, testContext: TestContext): Promise<ComparisonResult>;
|
|
211
|
-
/**
|
|
212
|
-
* Compare two images directly without snapshot management
|
|
213
|
-
*/
|
|
214
|
-
declare function compareImages(received: ImageInput, baseline: ImageInput, options: MatcherOptions): Promise<ComparisonResult>;
|
|
215
|
-
|
|
216
|
-
export { type ComparisonMethod, type ComparisonResult, type FormatOptions, type ImageData, type ImageInput, type MatcherOptions, type TestContext, compareImages, fileExists, formatMessage as formatReport, getOrCreateSnapshot, isFilePath, isImageBuffer, isRawPngBuffer, loadPNG, normalizeImageInput, runComparison, savePNG, validateMethodSupportsInput };
|