@stll/scan-engine 0.1.2 → 0.1.3
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.
|
@@ -17,7 +17,7 @@ export class WasmScanResult {
|
|
|
17
17
|
export function clean_scan_rgba(
|
|
18
18
|
width: number,
|
|
19
19
|
height: number,
|
|
20
|
-
pixels: Uint8Array,
|
|
20
|
+
pixels: Uint8Array | number[],
|
|
21
21
|
dpi: number,
|
|
22
22
|
output: string,
|
|
23
23
|
content_crop: boolean,
|
|
@@ -44,21 +44,24 @@ export interface InitOutput {
|
|
|
44
44
|
) => void;
|
|
45
45
|
readonly wasmscanresult_applied_quad: (a: number, b: number) => void;
|
|
46
46
|
readonly wasmscanresult_content_box: (a: number, b: number) => void;
|
|
47
|
+
readonly wasmscanresult_height: (a: number) => number;
|
|
47
48
|
readonly wasmscanresult_pixels: (a: number, b: number) => void;
|
|
48
49
|
readonly wasmscanresult_reason: (a: number, b: number) => void;
|
|
49
|
-
readonly wasmscanresult_status: (a: number, b: number) => void;
|
|
50
|
-
readonly wasmscanresult_height: (a: number) => number;
|
|
51
50
|
readonly wasmscanresult_skew_degrees: (a: number) => number;
|
|
51
|
+
readonly wasmscanresult_status: (a: number, b: number) => void;
|
|
52
52
|
readonly wasmscanresult_width: (a: number) => number;
|
|
53
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
53
54
|
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
54
55
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
55
|
-
readonly __wbindgen_export2: (
|
|
56
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number) => void;
|
|
57
|
+
readonly __wbindgen_export3: (
|
|
56
58
|
a: number,
|
|
57
59
|
b: number,
|
|
58
60
|
c: number,
|
|
59
61
|
d: number,
|
|
60
62
|
) => number;
|
|
61
|
-
readonly
|
|
63
|
+
readonly __wbindgen_export4: (a: number) => void;
|
|
64
|
+
readonly __wbindgen_start: () => void;
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
package/generated/scan_engine.js
CHANGED
|
@@ -22,12 +22,12 @@ export class WasmScanResult {
|
|
|
22
22
|
*/
|
|
23
23
|
get applied_quad() {
|
|
24
24
|
try {
|
|
25
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
25
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
26
26
|
wasm.wasmscanresult_applied_quad(retptr, this.__wbg_ptr);
|
|
27
27
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
28
28
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
29
29
|
var v1 = getArrayF32FromWasm0(r0, r1).slice();
|
|
30
|
-
wasm.
|
|
30
|
+
wasm.__wbindgen_export2(r0, r1 * 4, 4);
|
|
31
31
|
return v1;
|
|
32
32
|
} finally {
|
|
33
33
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -38,12 +38,12 @@ export class WasmScanResult {
|
|
|
38
38
|
*/
|
|
39
39
|
get content_box() {
|
|
40
40
|
try {
|
|
41
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
41
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
42
42
|
wasm.wasmscanresult_content_box(retptr, this.__wbg_ptr);
|
|
43
43
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
44
44
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
45
45
|
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
46
|
-
wasm.
|
|
46
|
+
wasm.__wbindgen_export2(r0, r1 * 4, 4);
|
|
47
47
|
return v1;
|
|
48
48
|
} finally {
|
|
49
49
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -61,12 +61,12 @@ export class WasmScanResult {
|
|
|
61
61
|
*/
|
|
62
62
|
get pixels() {
|
|
63
63
|
try {
|
|
64
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
64
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
65
65
|
wasm.wasmscanresult_pixels(retptr, this.__wbg_ptr);
|
|
66
66
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
67
67
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
68
68
|
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
69
|
-
wasm.
|
|
69
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
70
70
|
return v1;
|
|
71
71
|
} finally {
|
|
72
72
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -79,7 +79,7 @@ export class WasmScanResult {
|
|
|
79
79
|
let deferred1_0;
|
|
80
80
|
let deferred1_1;
|
|
81
81
|
try {
|
|
82
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
82
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
83
83
|
wasm.wasmscanresult_reason(retptr, this.__wbg_ptr);
|
|
84
84
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
85
85
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
@@ -88,7 +88,7 @@ export class WasmScanResult {
|
|
|
88
88
|
return getStringFromWasm0(r0, r1);
|
|
89
89
|
} finally {
|
|
90
90
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
91
|
-
wasm.
|
|
91
|
+
wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
@@ -105,7 +105,7 @@ export class WasmScanResult {
|
|
|
105
105
|
let deferred1_0;
|
|
106
106
|
let deferred1_1;
|
|
107
107
|
try {
|
|
108
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
108
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
109
109
|
wasm.wasmscanresult_status(retptr, this.__wbg_ptr);
|
|
110
110
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
111
111
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
@@ -114,7 +114,7 @@ export class WasmScanResult {
|
|
|
114
114
|
return getStringFromWasm0(r0, r1);
|
|
115
115
|
} finally {
|
|
116
116
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
117
|
-
wasm.
|
|
117
|
+
wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
@@ -131,7 +131,7 @@ if (Symbol.dispose)
|
|
|
131
131
|
/**
|
|
132
132
|
* @param {number} width
|
|
133
133
|
* @param {number} height
|
|
134
|
-
* @param {Uint8Array} pixels
|
|
134
|
+
* @param {Uint8Array | number[]} pixels
|
|
135
135
|
* @param {number} dpi
|
|
136
136
|
* @param {string} output
|
|
137
137
|
* @param {boolean} content_crop
|
|
@@ -148,32 +148,48 @@ export function clean_scan_rgba(
|
|
|
148
148
|
deskew,
|
|
149
149
|
) {
|
|
150
150
|
try {
|
|
151
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
152
|
-
const
|
|
153
|
-
const
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
151
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
152
|
+
const val3 = +width;
|
|
153
|
+
const val4 = +height;
|
|
154
|
+
const val5 = +dpi;
|
|
155
|
+
const val6 = +content_crop;
|
|
156
|
+
const val7 = +deskew;
|
|
157
|
+
let ptr0, len0, ptr1, len1;
|
|
158
|
+
try {
|
|
159
|
+
ptr0 = passArray8ToWasm0(pixels, wasm.__wbindgen_export);
|
|
160
|
+
len0 = WASM_VECTOR_LEN;
|
|
161
|
+
ptr1 = passStringToWasm0(
|
|
162
|
+
output,
|
|
163
|
+
wasm.__wbindgen_export,
|
|
164
|
+
wasm.__wbindgen_export3,
|
|
165
|
+
);
|
|
166
|
+
len1 = WASM_VECTOR_LEN;
|
|
167
|
+
} catch (e) {
|
|
168
|
+
if (ptr1) {
|
|
169
|
+
wasm.__wbindgen_export2(ptr1, len1 * 1, 1);
|
|
170
|
+
}
|
|
171
|
+
if (ptr0) {
|
|
172
|
+
wasm.__wbindgen_export2(ptr0, len0 * 1, 1);
|
|
173
|
+
}
|
|
174
|
+
throw e;
|
|
175
|
+
}
|
|
160
176
|
wasm.clean_scan_rgba(
|
|
161
177
|
retptr,
|
|
162
|
-
|
|
163
|
-
|
|
178
|
+
val3,
|
|
179
|
+
val4,
|
|
164
180
|
ptr0,
|
|
165
181
|
len0,
|
|
166
|
-
|
|
182
|
+
val5,
|
|
167
183
|
ptr1,
|
|
168
184
|
len1,
|
|
169
|
-
|
|
170
|
-
|
|
185
|
+
val6,
|
|
186
|
+
val7,
|
|
171
187
|
);
|
|
172
188
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
173
189
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
174
190
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
175
191
|
if (r2) {
|
|
176
|
-
throw
|
|
192
|
+
throw takeFromExternrefTable0(r1);
|
|
177
193
|
}
|
|
178
194
|
return WasmScanResult.__wrap(r0);
|
|
179
195
|
} finally {
|
|
@@ -183,13 +199,21 @@ export function clean_scan_rgba(
|
|
|
183
199
|
function __wbg_get_imports() {
|
|
184
200
|
const import0 = {
|
|
185
201
|
__proto__: null,
|
|
186
|
-
|
|
202
|
+
__wbg___wbindgen_throw_4c88d8bf264fd984: function (arg0, arg1) {
|
|
187
203
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
188
204
|
},
|
|
189
|
-
|
|
205
|
+
__wbindgen_generic_0000000000000001: function (arg0, arg1) {
|
|
190
206
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
191
207
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
192
|
-
return
|
|
208
|
+
return ret;
|
|
209
|
+
},
|
|
210
|
+
__wbindgen_init_externref_table: function () {
|
|
211
|
+
const table = wasm.__wbindgen_externrefs;
|
|
212
|
+
table.set(0, undefined);
|
|
213
|
+
table.set(1024, undefined);
|
|
214
|
+
table.set(1025, null);
|
|
215
|
+
table.set(1026, true);
|
|
216
|
+
table.set(1027, false);
|
|
193
217
|
},
|
|
194
218
|
};
|
|
195
219
|
return {
|
|
@@ -203,21 +227,6 @@ const WasmScanResultFinalization =
|
|
|
203
227
|
? { register: () => {}, unregister: () => {} }
|
|
204
228
|
: new FinalizationRegistry((ptr) => wasm.__wbg_wasmscanresult_free(ptr, 1));
|
|
205
229
|
|
|
206
|
-
function addHeapObject(obj) {
|
|
207
|
-
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
208
|
-
const idx = heap_next;
|
|
209
|
-
heap_next = heap[idx];
|
|
210
|
-
|
|
211
|
-
heap[idx] = obj;
|
|
212
|
-
return idx;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function dropObject(idx) {
|
|
216
|
-
if (idx < 1028) return;
|
|
217
|
-
heap[idx] = heap_next;
|
|
218
|
-
heap_next = idx;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
230
|
function getArrayF32FromWasm0(ptr, len) {
|
|
222
231
|
ptr = ptr >>> 0;
|
|
223
232
|
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
@@ -258,7 +267,8 @@ function getFloat32ArrayMemory0() {
|
|
|
258
267
|
}
|
|
259
268
|
|
|
260
269
|
function getStringFromWasm0(ptr, len) {
|
|
261
|
-
|
|
270
|
+
ptr = ptr >>> 0;
|
|
271
|
+
return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
262
272
|
}
|
|
263
273
|
|
|
264
274
|
let cachedUint32ArrayMemory0 = null;
|
|
@@ -283,15 +293,6 @@ function getUint8ArrayMemory0() {
|
|
|
283
293
|
return cachedUint8ArrayMemory0;
|
|
284
294
|
}
|
|
285
295
|
|
|
286
|
-
function getObject(idx) {
|
|
287
|
-
return heap[idx];
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
let heap = new Array(1024).fill(undefined);
|
|
291
|
-
heap.push(undefined, null, true, false);
|
|
292
|
-
|
|
293
|
-
let heap_next = heap.length;
|
|
294
|
-
|
|
295
296
|
function passArray8ToWasm0(arg, malloc) {
|
|
296
297
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
297
298
|
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
@@ -338,32 +339,24 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
338
339
|
return ptr;
|
|
339
340
|
}
|
|
340
341
|
|
|
341
|
-
function
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
return
|
|
342
|
+
function takeFromExternrefTable0(idx) {
|
|
343
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
344
|
+
wasm.__wbindgen_export4(idx);
|
|
345
|
+
return value;
|
|
345
346
|
}
|
|
346
347
|
|
|
347
|
-
let cachedTextDecoder = new TextDecoder("utf-8", {
|
|
348
|
-
ignoreBOM: true,
|
|
349
|
-
fatal: true,
|
|
350
|
-
});
|
|
348
|
+
let cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
351
349
|
cachedTextDecoder.decode();
|
|
352
350
|
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
353
351
|
let numBytesDecoded = 0;
|
|
354
|
-
function decodeText(
|
|
355
|
-
numBytesDecoded +=
|
|
352
|
+
function decodeText(bytes) {
|
|
353
|
+
numBytesDecoded += bytes.length;
|
|
356
354
|
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
357
|
-
cachedTextDecoder = new TextDecoder("utf-8", {
|
|
358
|
-
ignoreBOM: true,
|
|
359
|
-
fatal: true,
|
|
360
|
-
});
|
|
355
|
+
cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
361
356
|
cachedTextDecoder.decode();
|
|
362
|
-
numBytesDecoded =
|
|
357
|
+
numBytesDecoded = bytes.length;
|
|
363
358
|
}
|
|
364
|
-
return cachedTextDecoder.decode(
|
|
365
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + len),
|
|
366
|
-
);
|
|
359
|
+
return cachedTextDecoder.decode(bytes);
|
|
367
360
|
}
|
|
368
361
|
|
|
369
362
|
const cachedTextEncoder = new TextEncoder();
|
|
@@ -390,16 +383,23 @@ function __wbg_finalize_init(instance, module) {
|
|
|
390
383
|
cachedFloat32ArrayMemory0 = null;
|
|
391
384
|
cachedUint32ArrayMemory0 = null;
|
|
392
385
|
cachedUint8ArrayMemory0 = null;
|
|
386
|
+
wasm.__wbindgen_start();
|
|
393
387
|
return wasm;
|
|
394
388
|
}
|
|
395
389
|
|
|
396
390
|
async function __wbg_load(module, imports) {
|
|
397
391
|
if (typeof Response === "function" && module instanceof Response) {
|
|
392
|
+
if (!module.ok) {
|
|
393
|
+
throw new Error(
|
|
394
|
+
`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`,
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
398
|
if (typeof WebAssembly.instantiateStreaming === "function") {
|
|
399
399
|
try {
|
|
400
400
|
return await WebAssembly.instantiateStreaming(module, imports);
|
|
401
401
|
} catch (e) {
|
|
402
|
-
const validResponse =
|
|
402
|
+
const validResponse = expectedResponseType(module.type);
|
|
403
403
|
|
|
404
404
|
if (
|
|
405
405
|
validResponse &&
|
|
@@ -457,7 +457,18 @@ function initSync(module) {
|
|
|
457
457
|
return __wbg_finalize_init(instance, module);
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
+
let __wbg_init_promise;
|
|
460
461
|
async function __wbg_init(module_or_path) {
|
|
462
|
+
if (__wbg_init_promise === undefined) {
|
|
463
|
+
__wbg_init_promise = __wbg_init_once(module_or_path);
|
|
464
|
+
__wbg_init_promise.catch(() => {
|
|
465
|
+
__wbg_init_promise = undefined;
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
return __wbg_init_promise;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
async function __wbg_init_once(module_or_path) {
|
|
461
472
|
if (module_or_path !== undefined) {
|
|
462
473
|
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
463
474
|
({ module_or_path } = module_or_path);
|
|
Binary file
|
|
@@ -15,18 +15,21 @@ export const clean_scan_rgba: (
|
|
|
15
15
|
) => void;
|
|
16
16
|
export const wasmscanresult_applied_quad: (a: number, b: number) => void;
|
|
17
17
|
export const wasmscanresult_content_box: (a: number, b: number) => void;
|
|
18
|
+
export const wasmscanresult_height: (a: number) => number;
|
|
18
19
|
export const wasmscanresult_pixels: (a: number, b: number) => void;
|
|
19
20
|
export const wasmscanresult_reason: (a: number, b: number) => void;
|
|
20
|
-
export const wasmscanresult_status: (a: number, b: number) => void;
|
|
21
|
-
export const wasmscanresult_height: (a: number) => number;
|
|
22
21
|
export const wasmscanresult_skew_degrees: (a: number) => number;
|
|
22
|
+
export const wasmscanresult_status: (a: number, b: number) => void;
|
|
23
23
|
export const wasmscanresult_width: (a: number) => number;
|
|
24
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
24
25
|
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
25
26
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
26
|
-
export const __wbindgen_export2: (
|
|
27
|
+
export const __wbindgen_export2: (a: number, b: number, c: number) => void;
|
|
28
|
+
export const __wbindgen_export3: (
|
|
27
29
|
a: number,
|
|
28
30
|
b: number,
|
|
29
31
|
c: number,
|
|
30
32
|
d: number,
|
|
31
33
|
) => number;
|
|
32
|
-
export const
|
|
34
|
+
export const __wbindgen_export4: (a: number) => void;
|
|
35
|
+
export const __wbindgen_start: () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/scan-engine",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Document scan cleanup engine (Rust, WebAssembly): deskew, content crop and binarization off the main thread, plus a per-page review state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"binarization",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@stll/typescript-config": "0.0.0",
|
|
71
71
|
"bun-types": "1.4.4",
|
|
72
|
-
"tsdown": "0.23.
|
|
72
|
+
"tsdown": "0.23.4"
|
|
73
73
|
},
|
|
74
74
|
"main": "./dist/scan-engine.js",
|
|
75
75
|
"types": "./dist/scan-engine.d.ts"
|