scanic 1.2.0 → 1.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/src/scanic.d.ts CHANGED
@@ -122,9 +122,39 @@ export interface CornerEditor {
122
122
  destroy(): void;
123
123
  }
124
124
 
125
+ /**
126
+ * Options for the optional ML detector (`detector: 'ml'`). The ONNX Runtime JS
127
+ * API is bundled into scanic's ESM build as a lazy, code-split chunk (no extra
128
+ * install); the model and custom wasm are lazy-loaded from the companion
129
+ * `scanic-ml` package on a CDN by default. (UMD/CommonJS consumers must provide
130
+ * `onnxruntime-web@1.23.x` themselves, as UMD can't code-split.)
131
+ */
132
+ export interface MlDetectorOptions {
133
+ /** Base URL for the wasm + `.ort` model. Default: scanic-ml on jsDelivr. */
134
+ assetBaseUrl?: string;
135
+ /** Explicit model URL (overrides `assetBaseUrl` for the model). */
136
+ modelUrl?: string;
137
+ /** Explicit wasm directory (overrides `assetBaseUrl` for the runtime wasm). */
138
+ wasmPaths?: string;
139
+ /** Pre-fetched `.ort` model bytes (skips the network fetch). */
140
+ modelBytes?: Uint8Array;
141
+ /** ORT thread count. Default 1; values >1 require COOP/COEP headers on the host. */
142
+ numThreads?: number;
143
+ /** Minimum P(document) to report success. Default 0.5. */
144
+ minScore?: number;
145
+ }
146
+
125
147
  export interface DetectionOptions {
126
148
  mode?: 'detect' | 'extract';
127
149
  output?: 'canvas' | 'imagedata' | 'dataurl';
150
+ /**
151
+ * Detection backend. `'classical'` (default) is the pure-JS/WASM Canny
152
+ * pipeline. `'ml'` uses the optional DocCornerNet SimCC model via
153
+ * onnxruntime-web — more robust on cluttered/low-contrast photos.
154
+ */
155
+ detector?: 'classical' | 'ml';
156
+ /** Options forwarded to the ML detector when `detector: 'ml'`. */
157
+ ml?: MlDetectorOptions;
128
158
  debug?: boolean;
129
159
  maxProcessingDimension?: number;
130
160
  lowThreshold?: number;
@@ -159,6 +189,8 @@ export interface ScannerResult {
159
189
  success: boolean;
160
190
  message: string;
161
191
  confidence?: number | null;
192
+ /** P(document present) from the ML detector (`detector: 'ml'`); null otherwise. */
193
+ score?: number | null;
162
194
  output: HTMLCanvasElement | ImageData | string | null;
163
195
  corners: CornerPoints | null;
164
196
  contour: Point[] | null;