@blazediff/core-wasm 5.0.0 → 5.2.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 +42 -3
- package/dist/index.d.ts +102 -4
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/wasm/blazediff.d.ts +15 -6
- package/wasm/blazediff.js +110 -31
- package/wasm/blazediff_bg.wasm +0 -0
- package/wasm/blazediff_bg.wasm.d.ts +5 -4
package/README.md
CHANGED
|
@@ -103,7 +103,7 @@ Initializes the wasm module. Safe to call multiple times; subsequent calls retur
|
|
|
103
103
|
|
|
104
104
|
### `diff(a, b, width, height, output?, options?)`
|
|
105
105
|
|
|
106
|
-
Compares two RGBA pixel buffers and returns the number of differing pixels.
|
|
106
|
+
Compares two RGBA pixel buffers and returns the number of differing pixels. Set `interpret: true` to return structured interpretation while producing the diff output in the same pass.
|
|
107
107
|
|
|
108
108
|
<table>
|
|
109
109
|
<tr>
|
|
@@ -138,12 +138,12 @@ Compares two RGBA pixel buffers and returns the number of differing pixels.
|
|
|
138
138
|
</tr>
|
|
139
139
|
<tr>
|
|
140
140
|
<td><code>options</code></td>
|
|
141
|
-
<td>DiffOptions</td>
|
|
141
|
+
<td>DiffOptions | InterpretedDiffOptions</td>
|
|
142
142
|
<td>Comparison options (optional)</td>
|
|
143
143
|
</tr>
|
|
144
144
|
</table>
|
|
145
145
|
|
|
146
|
-
**Returns:** `Promise<number>`
|
|
146
|
+
**Returns:** `Promise<number>` by default, or `Promise<DiffResult>` with `interpret: true`
|
|
147
147
|
|
|
148
148
|
<table>
|
|
149
149
|
<tr>
|
|
@@ -170,8 +170,47 @@ Compares two RGBA pixel buffers and returns the number of differing pixels.
|
|
|
170
170
|
<td>false</td>
|
|
171
171
|
<td>Render diff with transparent background instead of grayscale base</td>
|
|
172
172
|
</tr>
|
|
173
|
+
<tr>
|
|
174
|
+
<td><code>diffColorAlt</code></td>
|
|
175
|
+
<td>[number, number, number]</td>
|
|
176
|
+
<td>diff color</td>
|
|
177
|
+
<td>Alternative RGB color for darkening differences</td>
|
|
178
|
+
</tr>
|
|
179
|
+
<tr>
|
|
180
|
+
<td><code>interpret</code></td>
|
|
181
|
+
<td>boolean</td>
|
|
182
|
+
<td>false</td>
|
|
183
|
+
<td>Return structured interpretation from the same diff pass</td>
|
|
184
|
+
</tr>
|
|
173
185
|
</table>
|
|
174
186
|
|
|
187
|
+
With `interpret: true`, `diff()` returns:
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
type DiffResult =
|
|
191
|
+
| { match: true; interpretation: InterpretResult }
|
|
192
|
+
| {
|
|
193
|
+
match: false;
|
|
194
|
+
reason: 'pixel-diff';
|
|
195
|
+
diffCount: number;
|
|
196
|
+
diffPercentage: number;
|
|
197
|
+
interpretation: InterpretResult;
|
|
198
|
+
};
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
const result = await diff(a, b, width, height, output, {
|
|
203
|
+
diffColorAlt: [0, 128, 255],
|
|
204
|
+
interpret: true,
|
|
205
|
+
});
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### `interpret(a, b, width, height, options?)`
|
|
209
|
+
|
|
210
|
+
Returns structured change regions without retaining a diff visualization. It is a convenience wrapper over `diff()` with `interpret: true`.
|
|
211
|
+
|
|
212
|
+
**Returns:** `Promise<InterpretResult>`
|
|
213
|
+
|
|
175
214
|
## Usage
|
|
176
215
|
|
|
177
216
|
### Browser
|
package/dist/index.d.ts
CHANGED
|
@@ -5,10 +5,90 @@ interface DiffOptions {
|
|
|
5
5
|
includeAA?: boolean;
|
|
6
6
|
/** Render output with transparent background instead of grayscale base. Default: false */
|
|
7
7
|
diffMask?: boolean;
|
|
8
|
+
/** Alternative RGB color for darkening differences. Default: diff color */
|
|
9
|
+
diffColorAlt?: [number, number, number];
|
|
8
10
|
}
|
|
11
|
+
interface InterpretedDiffOptions extends DiffOptions {
|
|
12
|
+
/** Return structured interpretation from the same diff pass. */
|
|
13
|
+
interpret: true;
|
|
14
|
+
}
|
|
15
|
+
interface InterpretOptions {
|
|
16
|
+
/** Color difference threshold (0-1). Lower = stricter. Default: 0.1 */
|
|
17
|
+
threshold?: number;
|
|
18
|
+
/** Count anti-aliased pixels as differences. Default: false */
|
|
19
|
+
includeAA?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface BoundingBox {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
}
|
|
27
|
+
interface ShapeStats {
|
|
28
|
+
fillRatio: number;
|
|
29
|
+
borderRatio: number;
|
|
30
|
+
innerFillRatio: number;
|
|
31
|
+
centerDensity: number;
|
|
32
|
+
rowOccupancy: number;
|
|
33
|
+
colOccupancy: number;
|
|
34
|
+
}
|
|
35
|
+
interface ColorDeltaStats {
|
|
36
|
+
meanDelta: number;
|
|
37
|
+
maxDelta: number;
|
|
38
|
+
deltaStddev: number;
|
|
39
|
+
}
|
|
40
|
+
interface GradientStats {
|
|
41
|
+
edgeScore: number;
|
|
42
|
+
edgeScoreImg2: number;
|
|
43
|
+
edgeCorrelation: number;
|
|
44
|
+
}
|
|
45
|
+
interface ClassificationSignals {
|
|
46
|
+
blendsWithBgInImg1: boolean;
|
|
47
|
+
blendsWithBgInImg2: boolean;
|
|
48
|
+
lowColorDelta: boolean;
|
|
49
|
+
lowEdgeChange: boolean;
|
|
50
|
+
denseFill: boolean;
|
|
51
|
+
sparseFill: boolean;
|
|
52
|
+
tinyRegion: boolean;
|
|
53
|
+
edgesCorrelated: boolean;
|
|
54
|
+
confidence: number;
|
|
55
|
+
}
|
|
56
|
+
interface ChangeRegion {
|
|
57
|
+
bbox: BoundingBox;
|
|
58
|
+
pixelCount: number;
|
|
59
|
+
percentage: number;
|
|
60
|
+
position: string;
|
|
61
|
+
shape: string;
|
|
62
|
+
shapeStats: ShapeStats;
|
|
63
|
+
changeType: string;
|
|
64
|
+
signals: ClassificationSignals;
|
|
65
|
+
confidence: number;
|
|
66
|
+
colorDelta: ColorDeltaStats;
|
|
67
|
+
gradient: GradientStats;
|
|
68
|
+
}
|
|
69
|
+
interface InterpretResult {
|
|
70
|
+
summary: string;
|
|
71
|
+
diffCount: number;
|
|
72
|
+
totalRegions: number;
|
|
73
|
+
regions: ChangeRegion[];
|
|
74
|
+
severity: string;
|
|
75
|
+
diffPercentage: number;
|
|
76
|
+
width: number;
|
|
77
|
+
height: number;
|
|
78
|
+
}
|
|
79
|
+
type DiffResult = {
|
|
80
|
+
match: true;
|
|
81
|
+
interpretation: InterpretResult;
|
|
82
|
+
} | {
|
|
83
|
+
match: false;
|
|
84
|
+
reason: "pixel-diff";
|
|
85
|
+
diffCount: number;
|
|
86
|
+
diffPercentage: number;
|
|
87
|
+
interpretation: InterpretResult;
|
|
88
|
+
};
|
|
9
89
|
type WasmInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
10
90
|
/**
|
|
11
|
-
* Initialize the wasm module. Safe to call multiple times
|
|
91
|
+
* Initialize the wasm module. Safe to call multiple times - subsequent calls
|
|
12
92
|
* return the same promise. By default fetches the bundled `blazediff_bg.wasm`
|
|
13
93
|
* via the module's import path. Pass a custom `URL`, `Response`, or bytes to
|
|
14
94
|
* load the wasm from a different location (CDN, custom asset pipeline, etc.).
|
|
@@ -22,8 +102,26 @@ declare function initBlazediff(input?: WasmInput): Promise<void>;
|
|
|
22
102
|
* the `ImageDecoder` API) and pass the resulting `Uint8Array` here.
|
|
23
103
|
*
|
|
24
104
|
* If `output` is provided it must be `width * height * 4` bytes long and the
|
|
25
|
-
* diff visualization is written into it in place.
|
|
105
|
+
* diff visualization is written into it in place. Set `interpret: true` to
|
|
106
|
+
* return structured interpretation from the same diff pass.
|
|
107
|
+
*/
|
|
108
|
+
declare function diff(a: Uint8Array, b: Uint8Array, width: number, height: number, output: Uint8Array | undefined, options: InterpretedDiffOptions): Promise<DiffResult>;
|
|
109
|
+
declare function diff(a: Uint8Array, b: Uint8Array, width: number, height: number, output?: Uint8Array, options?: DiffOptions & {
|
|
110
|
+
interpret?: false;
|
|
111
|
+
}): Promise<number>;
|
|
112
|
+
declare function diff(a: Uint8Array, b: Uint8Array, width: number, height: number, output?: Uint8Array, options?: DiffOptions & {
|
|
113
|
+
interpret?: boolean;
|
|
114
|
+
}): Promise<number | DiffResult>;
|
|
115
|
+
/**
|
|
116
|
+
* Interpret the diff between two RGBA pixel buffers into structured change
|
|
117
|
+
* regions - what changed, where, and how much. Returns the same shape as the
|
|
118
|
+
* native `@blazediff/core-native` `interpret`, with semantic change types,
|
|
119
|
+
* spatial positions, and severity.
|
|
120
|
+
*
|
|
121
|
+
* Both buffers must be `width * height * 4` bytes in RGBA8 order. Decode
|
|
122
|
+
* PNG/JPEG with `createImageBitmap` + `OffscreenCanvas.getImageData()` (or the
|
|
123
|
+
* `ImageDecoder` API) and pass the resulting `Uint8Array` here.
|
|
26
124
|
*/
|
|
27
|
-
declare function
|
|
125
|
+
declare function interpret(a: Uint8Array, b: Uint8Array, width: number, height: number, options?: InterpretOptions): Promise<InterpretResult>;
|
|
28
126
|
|
|
29
|
-
export { type DiffOptions, type WasmInput, diff, initBlazediff };
|
|
127
|
+
export { type BoundingBox, type ChangeRegion, type ClassificationSignals, type ColorDeltaStats, type DiffOptions, type DiffResult, type GradientStats, type InterpretOptions, type InterpretResult, type InterpretedDiffOptions, type ShapeStats, type WasmInput, diff, initBlazediff, interpret };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import s,{diffRgba,interpretRgba}from'../wasm/blazediff.js';var o;function f(e){if(e){if(e.length!==3||e.some(r=>!Number.isInteger(r)||r<0||r>255))throw new RangeError("diffColorAlt must contain three integer RGB channels");return Uint8Array.from(e)}}function b(e){return e.diffCount===0?{match:true,interpretation:e}:{match:false,reason:"pixel-diff",diffCount:e.diffCount,diffPercentage:e.diffPercentage,interpretation:e}}function m(e){return o||(o=s(e===void 0?void 0:{module_or_path:e}).then(()=>{})),o}async function p(e,r,t,i,a,n={}){if(await m(),!n.interpret)return diffRgba(e,r,t,i,n.threshold??.1,n.includeAA??false,n.diffMask??false,f(n.diffColorAlt),a);let u=interpretRgba(e,r,t,i,n.threshold??.1,n.includeAA??false,n.diffMask??false,f(n.diffColorAlt),a);return b(u)}async function c(e,r,t,i,a={}){return (await p(e,r,t,i,void 0,{...a,interpret:true})).interpretation}export{p as diff,m as initBlazediff,c as interpret};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blazediff/core-wasm",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.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.
|
|
47
|
+
"@blazediff/core-native": "5.2.0"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"typecheck": "tsc --noEmit",
|
package/wasm/blazediff.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
export function _start(): void;
|
|
4
3
|
/**
|
|
5
4
|
* Diff two RGBA buffers. Returns the count of differing pixels.
|
|
6
5
|
*
|
|
@@ -8,17 +7,27 @@ export function _start(): void;
|
|
|
8
7
|
* (must be width*height*4 bytes). Pass `null`/`undefined` to skip the
|
|
9
8
|
* visualization and just get a count.
|
|
10
9
|
*/
|
|
11
|
-
export function diffRgba(rgba_a: Uint8Array, rgba_b: Uint8Array, width: number, height: number, threshold: number, include_aa: boolean, diff_mask: boolean, out_diff?: Uint8Array | null): number;
|
|
10
|
+
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;
|
|
11
|
+
/**
|
|
12
|
+
* Interpret the diff between two RGBA buffers into structured change regions.
|
|
13
|
+
*
|
|
14
|
+
* Returns the `InterpretResult` (summary, regions with positions, change
|
|
15
|
+
* types, severity, etc.) serialized as a plain JS object - the same shape the
|
|
16
|
+
* native binding produces.
|
|
17
|
+
*/
|
|
18
|
+
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;
|
|
19
|
+
export function _start(): void;
|
|
12
20
|
|
|
13
21
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
14
22
|
|
|
15
23
|
export interface InitOutput {
|
|
16
24
|
readonly memory: WebAssembly.Memory;
|
|
17
25
|
readonly _start: () => void;
|
|
18
|
-
readonly diffRgba: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
|
|
19
|
-
readonly
|
|
20
|
-
readonly
|
|
21
|
-
readonly
|
|
26
|
+
readonly diffRgba: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => void;
|
|
27
|
+
readonly interpretRgba: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => void;
|
|
28
|
+
readonly __wbindgen_export_0: (a: number, b: number) => number;
|
|
29
|
+
readonly __wbindgen_export_1: (a: number, b: number, c: number, d: number) => number;
|
|
30
|
+
readonly __wbindgen_export_2: (a: number, b: number, c: number) => void;
|
|
22
31
|
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
23
32
|
readonly __wbindgen_start: () => void;
|
|
24
33
|
}
|
package/wasm/blazediff.js
CHANGED
|
@@ -6,20 +6,7 @@ heap.push(undefined, null, true, false);
|
|
|
6
6
|
|
|
7
7
|
function getObject(idx) { return heap[idx]; }
|
|
8
8
|
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
function addHeapObject(obj) {
|
|
12
|
-
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
13
|
-
const idx = heap_next;
|
|
14
|
-
heap_next = heap[idx];
|
|
15
|
-
|
|
16
|
-
heap[idx] = obj;
|
|
17
|
-
return idx;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
21
|
-
|
|
22
|
-
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
9
|
+
let WASM_VECTOR_LEN = 0;
|
|
23
10
|
|
|
24
11
|
let cachedUint8ArrayMemory0 = null;
|
|
25
12
|
|
|
@@ -30,13 +17,6 @@ function getUint8ArrayMemory0() {
|
|
|
30
17
|
return cachedUint8ArrayMemory0;
|
|
31
18
|
}
|
|
32
19
|
|
|
33
|
-
function getStringFromWasm0(ptr, len) {
|
|
34
|
-
ptr = ptr >>> 0;
|
|
35
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
let WASM_VECTOR_LEN = 0;
|
|
39
|
-
|
|
40
20
|
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
41
21
|
|
|
42
22
|
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
@@ -100,6 +80,26 @@ function getDataViewMemory0() {
|
|
|
100
80
|
return cachedDataViewMemory0;
|
|
101
81
|
}
|
|
102
82
|
|
|
83
|
+
let heap_next = heap.length;
|
|
84
|
+
|
|
85
|
+
function addHeapObject(obj) {
|
|
86
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
87
|
+
const idx = heap_next;
|
|
88
|
+
heap_next = heap[idx];
|
|
89
|
+
|
|
90
|
+
heap[idx] = obj;
|
|
91
|
+
return idx;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
95
|
+
|
|
96
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
97
|
+
|
|
98
|
+
function getStringFromWasm0(ptr, len) {
|
|
99
|
+
ptr = ptr >>> 0;
|
|
100
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
103
|
function dropObject(idx) {
|
|
104
104
|
if (idx < 132) return;
|
|
105
105
|
heap[idx] = heap_next;
|
|
@@ -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);
|
|
@@ -139,17 +135,20 @@ function isLikeNone(x) {
|
|
|
139
135
|
* @param {number} threshold
|
|
140
136
|
* @param {boolean} include_aa
|
|
141
137
|
* @param {boolean} diff_mask
|
|
138
|
+
* @param {Uint8Array | null} [diff_color_alt]
|
|
142
139
|
* @param {Uint8Array | null} [out_diff]
|
|
143
140
|
* @returns {number}
|
|
144
141
|
*/
|
|
145
|
-
export function diffRgba(rgba_a, rgba_b, width, height, threshold, include_aa, diff_mask, out_diff) {
|
|
142
|
+
export function diffRgba(rgba_a, rgba_b, width, height, threshold, include_aa, diff_mask, diff_color_alt, out_diff) {
|
|
146
143
|
try {
|
|
147
144
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
148
|
-
const ptr0 = passArray8ToWasm0(rgba_a, wasm.
|
|
145
|
+
const ptr0 = passArray8ToWasm0(rgba_a, wasm.__wbindgen_export_0);
|
|
149
146
|
const len0 = WASM_VECTOR_LEN;
|
|
150
|
-
const ptr1 = passArray8ToWasm0(rgba_b, wasm.
|
|
147
|
+
const ptr1 = passArray8ToWasm0(rgba_b, wasm.__wbindgen_export_0);
|
|
151
148
|
const len1 = WASM_VECTOR_LEN;
|
|
152
|
-
|
|
149
|
+
var ptr2 = isLikeNone(diff_color_alt) ? 0 : passArray8ToWasm0(diff_color_alt, wasm.__wbindgen_export_0);
|
|
150
|
+
var len2 = WASM_VECTOR_LEN;
|
|
151
|
+
wasm.diffRgba(retptr, ptr0, len0, ptr1, len1, width, height, threshold, include_aa, diff_mask, ptr2, len2, isLikeNone(out_diff) ? 0 : addHeapObject(out_diff));
|
|
153
152
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
154
153
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
155
154
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -162,6 +161,49 @@ export function diffRgba(rgba_a, rgba_b, width, height, threshold, include_aa, d
|
|
|
162
161
|
}
|
|
163
162
|
}
|
|
164
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Interpret the diff between two RGBA buffers into structured change regions.
|
|
166
|
+
*
|
|
167
|
+
* Returns the `InterpretResult` (summary, regions with positions, change
|
|
168
|
+
* types, severity, etc.) serialized as a plain JS object - the same shape the
|
|
169
|
+
* native binding produces.
|
|
170
|
+
* @param {Uint8Array} rgba_a
|
|
171
|
+
* @param {Uint8Array} rgba_b
|
|
172
|
+
* @param {number} width
|
|
173
|
+
* @param {number} height
|
|
174
|
+
* @param {number} threshold
|
|
175
|
+
* @param {boolean} include_aa
|
|
176
|
+
* @param {boolean} diff_mask
|
|
177
|
+
* @param {Uint8Array | null} [diff_color_alt]
|
|
178
|
+
* @param {Uint8Array | null} [out_diff]
|
|
179
|
+
* @returns {any}
|
|
180
|
+
*/
|
|
181
|
+
export function interpretRgba(rgba_a, rgba_b, width, height, threshold, include_aa, diff_mask, diff_color_alt, out_diff) {
|
|
182
|
+
try {
|
|
183
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
184
|
+
const ptr0 = passArray8ToWasm0(rgba_a, wasm.__wbindgen_export_0);
|
|
185
|
+
const len0 = WASM_VECTOR_LEN;
|
|
186
|
+
const ptr1 = passArray8ToWasm0(rgba_b, wasm.__wbindgen_export_0);
|
|
187
|
+
const len1 = WASM_VECTOR_LEN;
|
|
188
|
+
var ptr2 = isLikeNone(diff_color_alt) ? 0 : passArray8ToWasm0(diff_color_alt, wasm.__wbindgen_export_0);
|
|
189
|
+
var len2 = WASM_VECTOR_LEN;
|
|
190
|
+
wasm.interpretRgba(retptr, ptr0, len0, ptr1, len1, width, height, threshold, include_aa, diff_mask, ptr2, len2, isLikeNone(out_diff) ? 0 : addHeapObject(out_diff));
|
|
191
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
192
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
193
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
194
|
+
if (r2) {
|
|
195
|
+
throw takeObject(r1);
|
|
196
|
+
}
|
|
197
|
+
return takeObject(r0);
|
|
198
|
+
} finally {
|
|
199
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export function _start() {
|
|
204
|
+
wasm._start();
|
|
205
|
+
}
|
|
206
|
+
|
|
165
207
|
async function __wbg_load(module, imports) {
|
|
166
208
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
167
209
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
@@ -196,6 +238,13 @@ async function __wbg_load(module, imports) {
|
|
|
196
238
|
function __wbg_get_imports() {
|
|
197
239
|
const imports = {};
|
|
198
240
|
imports.wbg = {};
|
|
241
|
+
imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
|
|
242
|
+
const ret = String(getObject(arg1));
|
|
243
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
244
|
+
const len1 = WASM_VECTOR_LEN;
|
|
245
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
246
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
247
|
+
};
|
|
199
248
|
imports.wbg.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
|
|
200
249
|
const ret = getObject(arg0).buffer;
|
|
201
250
|
return addHeapObject(ret);
|
|
@@ -208,13 +257,21 @@ function __wbg_get_imports() {
|
|
|
208
257
|
deferred0_1 = arg1;
|
|
209
258
|
console.error(getStringFromWasm0(arg0, arg1));
|
|
210
259
|
} finally {
|
|
211
|
-
wasm.
|
|
260
|
+
wasm.__wbindgen_export_2(deferred0_0, deferred0_1, 1);
|
|
212
261
|
}
|
|
213
262
|
};
|
|
214
263
|
imports.wbg.__wbg_length_a446193dc22c12f8 = function(arg0) {
|
|
215
264
|
const ret = getObject(arg0).length;
|
|
216
265
|
return ret;
|
|
217
266
|
};
|
|
267
|
+
imports.wbg.__wbg_new_405e22f390576ce2 = function() {
|
|
268
|
+
const ret = new Object();
|
|
269
|
+
return addHeapObject(ret);
|
|
270
|
+
};
|
|
271
|
+
imports.wbg.__wbg_new_78feb108b6472713 = function() {
|
|
272
|
+
const ret = new Array();
|
|
273
|
+
return addHeapObject(ret);
|
|
274
|
+
};
|
|
218
275
|
imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
|
|
219
276
|
const ret = new Error();
|
|
220
277
|
return addHeapObject(ret);
|
|
@@ -223,16 +280,26 @@ function __wbg_get_imports() {
|
|
|
223
280
|
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
|
224
281
|
return addHeapObject(ret);
|
|
225
282
|
};
|
|
283
|
+
imports.wbg.__wbg_set_37837023f3d740e8 = function(arg0, arg1, arg2) {
|
|
284
|
+
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
285
|
+
};
|
|
286
|
+
imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
|
|
287
|
+
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
288
|
+
};
|
|
226
289
|
imports.wbg.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
|
|
227
290
|
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
|
228
291
|
};
|
|
229
292
|
imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
|
230
293
|
const ret = getObject(arg1).stack;
|
|
231
|
-
const ptr1 = passStringToWasm0(ret, wasm.
|
|
294
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
232
295
|
const len1 = WASM_VECTOR_LEN;
|
|
233
296
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
234
297
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
235
298
|
};
|
|
299
|
+
imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
|
|
300
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
301
|
+
return addHeapObject(ret);
|
|
302
|
+
};
|
|
236
303
|
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
237
304
|
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
238
305
|
return addHeapObject(ret);
|
|
@@ -241,9 +308,21 @@ function __wbg_get_imports() {
|
|
|
241
308
|
const ret = wasm.memory;
|
|
242
309
|
return addHeapObject(ret);
|
|
243
310
|
};
|
|
311
|
+
imports.wbg.__wbindgen_number_new = function(arg0) {
|
|
312
|
+
const ret = arg0;
|
|
313
|
+
return addHeapObject(ret);
|
|
314
|
+
};
|
|
315
|
+
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
|
316
|
+
const ret = getObject(arg0);
|
|
317
|
+
return addHeapObject(ret);
|
|
318
|
+
};
|
|
244
319
|
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
245
320
|
takeObject(arg0);
|
|
246
321
|
};
|
|
322
|
+
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
323
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
324
|
+
return addHeapObject(ret);
|
|
325
|
+
};
|
|
247
326
|
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
248
327
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
249
328
|
};
|
package/wasm/blazediff_bg.wasm
CHANGED
|
Binary file
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const _start: () => void;
|
|
5
|
-
export const diffRgba: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
|
|
6
|
-
export const
|
|
7
|
-
export const
|
|
8
|
-
export const
|
|
5
|
+
export const diffRgba: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => void;
|
|
6
|
+
export const interpretRgba: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => void;
|
|
7
|
+
export const __wbindgen_export_0: (a: number, b: number) => number;
|
|
8
|
+
export const __wbindgen_export_1: (a: number, b: number, c: number, d: number) => number;
|
|
9
|
+
export const __wbindgen_export_2: (a: number, b: number, c: number) => void;
|
|
9
10
|
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
10
11
|
export const __wbindgen_start: () => void;
|