@gueshbzh-perso/scanner 0.5.0 → 0.6.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 +16 -11
- package/dist/core.d.ts +27 -7
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +94 -30
- package/dist/core.js.map +1 -1
- package/dist/engine.d.ts +11 -2
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +140 -48
- package/dist/engine.js.map +1 -1
- package/dist/protocol.d.ts +9 -13
- package/dist/protocol.d.ts.map +1 -1
- package/dist/reader.d.ts +25 -2
- package/dist/reader.d.ts.map +1 -1
- package/dist/reader.js +70 -18
- package/dist/reader.js.map +1 -1
- package/dist/types.d.ts +10 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/wasm/scanner_wasm.d.ts +52 -0
- package/dist/wasm/scanner_wasm.js +87 -0
- package/dist/wasm/scanner_wasm_bg.wasm +0 -0
- package/dist/wasm/scanner_wasm_bg.wasm.d.ts +6 -0
- package/dist/wasm/scanner_wasm_simd_bg.wasm +0 -0
- package/dist/worker.js +15 -17
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
|
Binary file
|
package/dist/worker.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
// Web Worker entry point: decodes frames off the main thread.
|
|
2
|
-
|
|
1
|
+
// Web Worker entry point: decodes frames off the main thread. Stateless: the
|
|
2
|
+
// scan session (scheduling, confirmations, de-duplication) lives on the main
|
|
3
|
+
// thread, so any number of these workers can serve one camera stream.
|
|
4
|
+
import { DecoderCore, loadWasm } from './core.js';
|
|
3
5
|
const scope = self;
|
|
4
6
|
let core = null;
|
|
5
7
|
function engine() {
|
|
@@ -12,33 +14,29 @@ scope.onmessage = async (ev) => {
|
|
|
12
14
|
const buffer = 'buffer' in msg ? msg.buffer : undefined;
|
|
13
15
|
try {
|
|
14
16
|
switch (msg.type) {
|
|
15
|
-
case 'init':
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
case 'init': {
|
|
18
|
+
const version = await loadWasm(msg.module);
|
|
19
|
+
core = new DecoderCore();
|
|
20
|
+
scope.postMessage({ id: msg.id, ok: true, version });
|
|
18
21
|
break;
|
|
22
|
+
}
|
|
19
23
|
case 'configure':
|
|
20
24
|
engine().configure(msg.options);
|
|
21
25
|
scope.postMessage({ id: msg.id, ok: true });
|
|
22
26
|
break;
|
|
23
|
-
case '
|
|
24
|
-
const
|
|
27
|
+
case 'decode': {
|
|
28
|
+
const pixels = new Uint8Array(msg.buffer);
|
|
29
|
+
const report = engine().decode(pixels, msg.width, msg.height, msg.format, msg.plan);
|
|
25
30
|
// Hand the pixel buffer back so the main thread can reuse it.
|
|
26
|
-
scope.postMessage({ id: msg.id, ok: true,
|
|
31
|
+
scope.postMessage({ id: msg.id, ok: true, report, buffer: msg.buffer }, [msg.buffer]);
|
|
27
32
|
break;
|
|
28
33
|
}
|
|
29
34
|
case 'scan': {
|
|
30
|
-
const
|
|
35
|
+
const pixels = new Uint8Array(msg.buffer);
|
|
36
|
+
const results = engine().scan(pixels, msg.width, msg.height, msg.format, msg.options);
|
|
31
37
|
scope.postMessage({ id: msg.id, ok: true, results, buffer: msg.buffer }, [msg.buffer]);
|
|
32
38
|
break;
|
|
33
39
|
}
|
|
34
|
-
case 'reset':
|
|
35
|
-
engine().reset();
|
|
36
|
-
scope.postMessage({ id: msg.id, ok: true });
|
|
37
|
-
break;
|
|
38
|
-
case 'clearCooldown':
|
|
39
|
-
engine().clearCooldown(msg.text);
|
|
40
|
-
scope.postMessage({ id: msg.id, ok: true });
|
|
41
|
-
break;
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
42
|
catch (err) {
|
package/dist/worker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"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