@blazediff/core-wasm 5.3.0 → 5.4.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/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  </div>
10
10
 
11
- WebAssembly build of the BlazeDiff Rust algorithm for browsers, edge runtimes, and any wasm host. Same two-pass block algorithm as [`@blazediff/core-native`](https://www.npmjs.com/package/@blazediff/core-native), compiled to `wasm32` with `v128` SIMD (`+simd128`). **~58%** faster than [pixelmatch](https://github.com/mapbox/pixelmatch) on the same RGBA buffers; diff counts agree with pixelmatch to within ~0.05%.
11
+ WebAssembly build of the BlazeDiff Rust algorithm for browsers, edge runtimes, and any wasm host. Same two-pass block algorithm as [`@blazediff/core-native`](https://www.npmjs.com/package/@blazediff/core-native), compiled to `wasm32` with `v128` SIMD (`+simd128`). **~51%** faster than [pixelmatch](https://github.com/mapbox/pixelmatch) on the same RGBA buffers (up to ~90% on 4K); diff counts agree with pixelmatch to within ~0.05%.
12
12
 
13
13
  **Features:**
14
14
  - Same Rust algorithm as `@blazediff/core-native` (YIQ perceptual delta + block-based cold/hot pass)
@@ -271,13 +271,14 @@ vs `pixelmatch` on M1 Max, image I/O excluded (pre-decoded RGBA buffers):
271
271
 
272
272
  | Fixture | pixelmatch | core-wasm | Improvement |
273
273
  |---------------|------------|-----------|-------------|
274
- | 4k/1 | 287.72ms | 51.75ms | **82.0%** |
275
- | 4k/3 | 366.81ms | 69.90ms | **80.9%** |
276
- | page/2 | 443.83ms | 109.74ms | **75.3%** |
277
- | blazediff/3 | 14.60ms | 5.52ms | **62.2%** |
278
- | pixelmatch/1 | 0.87ms | 0.13ms | **84.6%** |
279
-
280
- Average **~58%** faster across the full fixture set. Counts agree with pixelmatch within ~0.05% (e.g. `4k/1`: 69 932 vs 69 912 of 17 920 000 pixels). Full benchmarks in [BENCHMARKS.md](https://github.com/teimurjan/blazediff/blob/main/BENCHMARKS.md).
274
+ | 4k/1 | 338.53ms | 34.42ms | **89.8%** |
275
+ | 4k/3 | 415.01ms | 45.34ms | **89.1%** |
276
+ | page/2 | 511.88ms | 70.89ms | **86.2%** |
277
+ | blazediff/3 | 12.08ms | 5.76ms | **52.3%** |
278
+ | pixelmatch/1 | 0.57ms | 0.11ms | **80.5%** |
279
+
280
+ Average **~51%** faster across the full fixture set (~60% across differing pairs). Counts agree with pixelmatch within ~0.05% (e.g. `4k/1`: 69 932 vs 69 912 of 17 920 000 pixels).
281
+ Full benchmarks in [BENCHMARKS.md](https://github.com/teimurjan/blazediff/blob/main/BENCHMARKS.md).
281
282
 
282
283
  ## Algorithm
283
284
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazediff/core-wasm",
3
- "version": "5.3.0",
3
+ "version": "5.4.0",
4
4
  "description": "WebAssembly build of blazediff for browsers, edge runtimes, and any wasm host. Same algorithm as @blazediff/core-native.",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -44,7 +44,7 @@
44
44
  "tsup": "8.5.0",
45
45
  "typescript": "5.9.2",
46
46
  "vitest": "^3.2.4",
47
- "@blazediff/core-native": "5.3.0"
47
+ "@blazediff/core-native": "5.4.0"
48
48
  },
49
49
  "scripts": {
50
50
  "typecheck": "tsc --noEmit",
@@ -1,5 +1,13 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ /**
4
+ * Interpret the diff between two RGBA buffers into structured change regions.
5
+ *
6
+ * Returns the `InterpretResult` (summary, regions with positions, change
7
+ * types, severity, etc.) serialized as a plain JS object - the same shape the
8
+ * native binding produces.
9
+ */
10
+ export function interpretRgba(rgba_a: Uint8Array, rgba_b: Uint8Array, width: number, height: number, threshold: number, include_aa: boolean, diff_mask: boolean, diff_color_alt?: Uint8Array | null, out_diff?: Uint8Array | null): any;
3
11
  export function _start(): void;
4
12
  /**
5
13
  * Diff two RGBA buffers. Returns the count of differing pixels.
@@ -9,14 +17,6 @@ export function _start(): void;
9
17
  * visualization and just get a count.
10
18
  */
11
19
  export function diffRgba(rgba_a: Uint8Array, rgba_b: Uint8Array, width: number, height: number, threshold: number, include_aa: boolean, diff_mask: boolean, diff_color_alt?: Uint8Array | null, out_diff?: Uint8Array | null): number;
12
- /**
13
- * Interpret the diff between two RGBA buffers into structured change regions.
14
- *
15
- * Returns the `InterpretResult` (summary, regions with positions, change
16
- * types, severity, etc.) serialized as a plain JS object - the same shape the
17
- * native binding produces.
18
- */
19
- export function interpretRgba(rgba_a: Uint8Array, rgba_b: Uint8Array, width: number, height: number, threshold: number, include_aa: boolean, diff_mask: boolean, diff_color_alt?: Uint8Array | null, out_diff?: Uint8Array | null): any;
20
20
 
21
21
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
22
22
 
package/wasm/blazediff.js CHANGED
@@ -112,10 +112,6 @@ function takeObject(idx) {
112
112
  return ret;
113
113
  }
114
114
 
115
- export function _start() {
116
- wasm._start();
117
- }
118
-
119
115
  function passArray8ToWasm0(arg, malloc) {
120
116
  const ptr = malloc(arg.length * 1, 1) >>> 0;
121
117
  getUint8ArrayMemory0().set(arg, ptr / 1);
@@ -127,11 +123,11 @@ function isLikeNone(x) {
127
123
  return x === undefined || x === null;
128
124
  }
129
125
  /**
130
- * Diff two RGBA buffers. Returns the count of differing pixels.
126
+ * Interpret the diff between two RGBA buffers into structured change regions.
131
127
  *
132
- * If `out_diff` is provided, the visualization is written into it in-place
133
- * (must be width*height*4 bytes). Pass `null`/`undefined` to skip the
134
- * visualization and just get a count.
128
+ * Returns the `InterpretResult` (summary, regions with positions, change
129
+ * types, severity, etc.) serialized as a plain JS object - the same shape the
130
+ * native binding produces.
135
131
  * @param {Uint8Array} rgba_a
136
132
  * @param {Uint8Array} rgba_b
137
133
  * @param {number} width
@@ -141,9 +137,9 @@ function isLikeNone(x) {
141
137
  * @param {boolean} diff_mask
142
138
  * @param {Uint8Array | null} [diff_color_alt]
143
139
  * @param {Uint8Array | null} [out_diff]
144
- * @returns {number}
140
+ * @returns {any}
145
141
  */
146
- export function diffRgba(rgba_a, rgba_b, width, height, threshold, include_aa, diff_mask, diff_color_alt, out_diff) {
142
+ export function interpretRgba(rgba_a, rgba_b, width, height, threshold, include_aa, diff_mask, diff_color_alt, out_diff) {
147
143
  try {
148
144
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
149
145
  const ptr0 = passArray8ToWasm0(rgba_a, wasm.__wbindgen_export_0);
@@ -152,25 +148,29 @@ export function diffRgba(rgba_a, rgba_b, width, height, threshold, include_aa, d
152
148
  const len1 = WASM_VECTOR_LEN;
153
149
  var ptr2 = isLikeNone(diff_color_alt) ? 0 : passArray8ToWasm0(diff_color_alt, wasm.__wbindgen_export_0);
154
150
  var len2 = WASM_VECTOR_LEN;
155
- wasm.diffRgba(retptr, ptr0, len0, ptr1, len1, width, height, threshold, include_aa, diff_mask, ptr2, len2, isLikeNone(out_diff) ? 0 : addHeapObject(out_diff));
151
+ wasm.interpretRgba(retptr, ptr0, len0, ptr1, len1, width, height, threshold, include_aa, diff_mask, ptr2, len2, isLikeNone(out_diff) ? 0 : addHeapObject(out_diff));
156
152
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
157
153
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
158
154
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
159
155
  if (r2) {
160
156
  throw takeObject(r1);
161
157
  }
162
- return r0 >>> 0;
158
+ return takeObject(r0);
163
159
  } finally {
164
160
  wasm.__wbindgen_add_to_stack_pointer(16);
165
161
  }
166
162
  }
167
163
 
164
+ export function _start() {
165
+ wasm._start();
166
+ }
167
+
168
168
  /**
169
- * Interpret the diff between two RGBA buffers into structured change regions.
169
+ * Diff two RGBA buffers. Returns the count of differing pixels.
170
170
  *
171
- * Returns the `InterpretResult` (summary, regions with positions, change
172
- * types, severity, etc.) serialized as a plain JS object - the same shape the
173
- * native binding produces.
171
+ * If `out_diff` is provided, the visualization is written into it in-place
172
+ * (must be width*height*4 bytes). Pass `null`/`undefined` to skip the
173
+ * visualization and just get a count.
174
174
  * @param {Uint8Array} rgba_a
175
175
  * @param {Uint8Array} rgba_b
176
176
  * @param {number} width
@@ -180,9 +180,9 @@ export function diffRgba(rgba_a, rgba_b, width, height, threshold, include_aa, d
180
180
  * @param {boolean} diff_mask
181
181
  * @param {Uint8Array | null} [diff_color_alt]
182
182
  * @param {Uint8Array | null} [out_diff]
183
- * @returns {any}
183
+ * @returns {number}
184
184
  */
185
- export function interpretRgba(rgba_a, rgba_b, width, height, threshold, include_aa, diff_mask, diff_color_alt, out_diff) {
185
+ export function diffRgba(rgba_a, rgba_b, width, height, threshold, include_aa, diff_mask, diff_color_alt, out_diff) {
186
186
  try {
187
187
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
188
188
  const ptr0 = passArray8ToWasm0(rgba_a, wasm.__wbindgen_export_0);
@@ -191,14 +191,14 @@ export function interpretRgba(rgba_a, rgba_b, width, height, threshold, include_
191
191
  const len1 = WASM_VECTOR_LEN;
192
192
  var ptr2 = isLikeNone(diff_color_alt) ? 0 : passArray8ToWasm0(diff_color_alt, wasm.__wbindgen_export_0);
193
193
  var len2 = WASM_VECTOR_LEN;
194
- wasm.interpretRgba(retptr, ptr0, len0, ptr1, len1, width, height, threshold, include_aa, diff_mask, ptr2, len2, isLikeNone(out_diff) ? 0 : addHeapObject(out_diff));
194
+ wasm.diffRgba(retptr, ptr0, len0, ptr1, len1, width, height, threshold, include_aa, diff_mask, ptr2, len2, isLikeNone(out_diff) ? 0 : addHeapObject(out_diff));
195
195
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
196
196
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
197
197
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
198
198
  if (r2) {
199
199
  throw takeObject(r1);
200
200
  }
201
- return takeObject(r0);
201
+ return r0 >>> 0;
202
202
  } finally {
203
203
  wasm.__wbindgen_add_to_stack_pointer(16);
204
204
  }
Binary file