@stll/scan-engine 0.1.0 → 0.1.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/dist/review.d.ts CHANGED
@@ -47,4 +47,5 @@ export type TargetPageBox = PhysicalPageSize & {
47
47
  rotation: ScanPageRotation;
48
48
  };
49
49
  export declare const targetPageBox: (pageSize: PhysicalPageSize, rotation: ScanPageRotation) => TargetPageBox;
50
- //#endregion
50
+ //#endregion
51
+ export {};
@@ -54,4 +54,5 @@ type WorkerEngineOptions = {
54
54
  };
55
55
  export declare const createScanEngine: (load?: WasmLoader, workerOptions?: WorkerEngineOptions) => ScanEngine;
56
56
  export declare const scanEngine: ScanEngine;
57
- //#endregion
57
+ //#endregion
58
+ export {};
@@ -1,16 +1,17 @@
1
1
  import { ScanEngineError } from "./types.js";
2
2
  import { Result } from "better-result";
3
3
  import { fetchWithTimeout } from "@stll/fetch";
4
+ import { readBodyWithIdleDeadline } from "@stll/fetch/body-reader";
4
5
  import { clean_scan_rgba, initSync } from "../generated/scan_engine.js";
5
6
  //#region src/scan-engine.ts
6
7
  const WASM_LOAD_TIMEOUT_MS = 1e4;
7
8
  const WORKER_REQUEST_TIMEOUT_MS = 1e4;
8
9
  const loadWasmBindings = async () => {
9
10
  const response = await fetchWithTimeout(new URL("../generated/scan_engine_bg.wasm", import.meta.url), { timeout: {
10
- type: "idle",
11
+ type: "headers",
11
12
  ms: WASM_LOAD_TIMEOUT_MS
12
13
  } });
13
- const module = await WebAssembly.compile(await response.arrayBuffer());
14
+ const module = await WebAssembly.compile(await readBodyWithIdleDeadline(response, { idleMs: WASM_LOAD_TIMEOUT_MS }));
14
15
  initSync({ module });
15
16
  return { clean_scan_rgba };
16
17
  };
@@ -1,4 +1,5 @@
1
1
  import { fetchWithTimeout } from "@stll/fetch";
2
+ import { readBodyWithIdleDeadline } from "@stll/fetch/body-reader";
2
3
  import initWasm, { clean_scan_rgba } from "../generated/scan_engine.js";
3
4
  //#region src/scan-engine.worker.ts
4
5
  const WASM_LOAD_TIMEOUT_MS = 1e4;
@@ -8,9 +9,9 @@ const post = (response, transfer = []) => {
8
9
  let initialized;
9
10
  const initialize = async () => {
10
11
  initialized ??= fetchWithTimeout(new URL("../generated/scan_engine_bg.wasm", import.meta.url), { timeout: {
11
- type: "idle",
12
+ type: "headers",
12
13
  ms: WASM_LOAD_TIMEOUT_MS
13
- } }).then(async (response) => await response.arrayBuffer()).then(async (module_or_path) => {
14
+ } }).then(async (response) => await readBodyWithIdleDeadline(response, { idleMs: WASM_LOAD_TIMEOUT_MS })).then(async (module_or_path) => {
14
15
  await initWasm({ module_or_path });
15
16
  });
16
17
  await initialized;
package/dist/types.d.ts CHANGED
@@ -69,4 +69,5 @@ export declare class ScanEngineError extends ScanEngineError_base<{
69
69
  export type ScanEngine = {
70
70
  clean: (page: RasterizedScanPage, options: ScanOptions) => Promise<Result<CleanScanResult, ScanEngineError>>;
71
71
  };
72
- //#endregion
72
+ //#endregion
73
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/scan-engine",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
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",
@@ -62,13 +62,13 @@
62
62
  "prepack": "bun run build"
63
63
  },
64
64
  "dependencies": {
65
- "@stll/fetch": "^0.1.0",
65
+ "@stll/fetch": "^0.2.0",
66
66
  "better-result": "3.0.1"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@stll/typescript-config": "0.0.0",
70
70
  "bun-types": "1.4.4",
71
- "tsdown": "0.23.0"
71
+ "tsdown": "0.23.1"
72
72
  },
73
73
  "main": "./dist/scan-engine.js",
74
74
  "types": "./dist/scan-engine.d.ts"