@microblink/capture 1.0.8 → 1.1.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 +18 -3
- package/dist/capture.js +6980 -9023
- package/dist/capture.umd.cjs +37 -58
- package/dist/resources/DO_NOT_MODIFY_THIS_DIRECTORY.md +2 -0
- package/dist/resources/advanced/capture-wasm.data +0 -0
- package/dist/resources/advanced/capture-wasm.js +4039 -152
- package/dist/resources/advanced/capture-wasm.wasm +0 -0
- package/dist/resources/advanced-threads/capture-wasm.data +0 -0
- package/dist/resources/advanced-threads/capture-wasm.js +4483 -171
- package/dist/resources/advanced-threads/capture-wasm.wasm +0 -0
- package/dist/resources/advanced-threads/capture-wasm.worker.js +109 -1
- package/dist/resources/basic/capture-wasm.data +0 -0
- package/dist/resources/basic/capture-wasm.js +4036 -152
- package/dist/resources/basic/capture-wasm.wasm +0 -0
- package/dist/resources/capture-worker.js +2 -2
- package/dist/style.css +1 -1
- package/package.json +5 -8
- package/types/index.d.cts +1115 -12
- package/types/index.d.ts +456 -235
package/types/index.d.ts
CHANGED
|
@@ -1,24 +1,40 @@
|
|
|
1
|
+
/// <reference types="emscripten" />
|
|
2
|
+
|
|
1
3
|
import { MountableElement } from 'solid-js/web';
|
|
2
4
|
import { SetStoreFunction } from 'solid-js/store';
|
|
3
5
|
|
|
4
6
|
export declare class Analyzer extends EmbindObject {
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
8
|
+
* Analyses a single image and returns either `FrameAnalysisResult` or `FrameAnalysisError`.
|
|
9
|
+
* Each captured image is stored as a candidate for the best frame.
|
|
10
|
+
*/
|
|
11
|
+
analyze(image: ImageData): FrameAnalysisResult | FrameAnalysisError;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the analyzer result.
|
|
7
14
|
*/
|
|
8
|
-
analyze(image: ImageData): FrameAnalysisResult;
|
|
9
15
|
getResult: () => AnalyzerResult;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the analyzer settings.
|
|
18
|
+
*/
|
|
10
19
|
getSettings: () => AnalyzerSettings;
|
|
20
|
+
/**
|
|
21
|
+
* Updates the analyzer settings.
|
|
22
|
+
*/
|
|
11
23
|
updateSettings: (settings: AnalyzerSettings) => void;
|
|
12
|
-
/**
|
|
24
|
+
/** Resets the currently active capturing process. */
|
|
13
25
|
reset: () => void;
|
|
14
26
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
27
|
+
* Attempts to finish the side capture early.
|
|
28
|
+
*
|
|
29
|
+
* If there aren't enough captured frames, the method returns `false` and
|
|
30
|
+
* further `Analyzer.analyze` calls are required.
|
|
17
31
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
32
|
+
* Otherwise, the method returns `true` and the `Analyzer` uses the best frame
|
|
33
|
+
* candidate to finish the side capture and either finish the capture process
|
|
34
|
+
* or continue to the next side.
|
|
35
|
+
*
|
|
36
|
+
* @returns `true` if there are enough captured frames to finish the capture
|
|
37
|
+
* process and `getResult` can be called, `false` otherwise.
|
|
22
38
|
*/
|
|
23
39
|
finishSideCapture: () => boolean;
|
|
24
40
|
}
|
|
@@ -34,7 +50,7 @@ export declare class Analyzer extends EmbindObject {
|
|
|
34
50
|
* REVERSE ENGINEER, DECOMPILE, OR DISASSEMBLE IT.
|
|
35
51
|
*/
|
|
36
52
|
/**
|
|
37
|
-
* The result returned from `Analyzer.
|
|
53
|
+
* The result returned from `Analyzer.getResult`
|
|
38
54
|
*/
|
|
39
55
|
export declare type AnalyzerResult = {
|
|
40
56
|
/** Result of the first side capture */
|
|
@@ -44,7 +60,7 @@ export declare type AnalyzerResult = {
|
|
|
44
60
|
/** Document group */
|
|
45
61
|
documentGroup: DocumentGroup;
|
|
46
62
|
/** Completeness status of the capture process */
|
|
47
|
-
|
|
63
|
+
completenessStatus: CompletenessStatus;
|
|
48
64
|
};
|
|
49
65
|
|
|
50
66
|
/**
|
|
@@ -62,7 +78,7 @@ export declare type AnalyzerResult = {
|
|
|
62
78
|
*/
|
|
63
79
|
export declare type AnalyzerSettings = {
|
|
64
80
|
/**
|
|
65
|
-
* Whether to capture a single side or capture
|
|
81
|
+
* Whether to capture a single side or capture both sides
|
|
66
82
|
* of a document with automatic side detection.
|
|
67
83
|
*/
|
|
68
84
|
captureSingleSide: boolean;
|
|
@@ -71,7 +87,7 @@ export declare type AnalyzerSettings = {
|
|
|
71
87
|
*/
|
|
72
88
|
returnTransformedDocumentImage: boolean;
|
|
73
89
|
/**
|
|
74
|
-
* Configures capture strategy used to select the best frame.
|
|
90
|
+
* Configures the capture strategy used to select the best frame.
|
|
75
91
|
*
|
|
76
92
|
* The following values are possible:
|
|
77
93
|
*
|
|
@@ -79,7 +95,7 @@ export declare type AnalyzerSettings = {
|
|
|
79
95
|
* capture frames with lower quality
|
|
80
96
|
* - `"optimize-for-quality"` - Analysis is slower in order to capture high
|
|
81
97
|
* quality frames.
|
|
82
|
-
* - `"default"` - Trade-off
|
|
98
|
+
* - `"default"` - Trade-off between quality and speed.
|
|
83
99
|
* - `"single-frame"` - Captures first acceptable frame.
|
|
84
100
|
*/
|
|
85
101
|
captureStrategy: CaptureStrategy;
|
|
@@ -90,7 +106,7 @@ export declare type AnalyzerSettings = {
|
|
|
90
106
|
* Both margin and document are required to be fully visible on camera frame
|
|
91
107
|
* in order to finish capture.
|
|
92
108
|
*
|
|
93
|
-
* Allowed values are from 0 to 1.
|
|
109
|
+
* Allowed values are from 0 to 1. (0%-100%)
|
|
94
110
|
*/
|
|
95
111
|
documentFramingMargin: number;
|
|
96
112
|
/**
|
|
@@ -150,6 +166,13 @@ export declare type AnalyzerSettings = {
|
|
|
150
166
|
* Allowed values are from 150 to 400.
|
|
151
167
|
*/
|
|
152
168
|
minimumDocumentDpi: number;
|
|
169
|
+
/**
|
|
170
|
+
* Whether to automatically adjust minimum document dpi.
|
|
171
|
+
*
|
|
172
|
+
* If it is enabled, the minimum dpi is adjusted to optimal value for the
|
|
173
|
+
* provided input resolution to enable capture of all document groups.
|
|
174
|
+
*/
|
|
175
|
+
adjustMinimumDocumentDpi: boolean;
|
|
153
176
|
};
|
|
154
177
|
|
|
155
178
|
export declare type BaltazarRequest = Readonly<{
|
|
@@ -175,12 +198,6 @@ declare interface CameraDeviceInfo extends Omit<MediaDeviceInfo, "kind"> {
|
|
|
175
198
|
kind: Extract<MediaDeviceInfo["kind"], "videoinput">;
|
|
176
199
|
}
|
|
177
200
|
|
|
178
|
-
/**
|
|
179
|
-
* Cancels the capture process. Unlike {@linkcode pauseCapture}, it also resets
|
|
180
|
-
* the analyzer.
|
|
181
|
-
*/
|
|
182
|
-
declare function cancelCapture(): Promise<void>;
|
|
183
|
-
|
|
184
201
|
export declare type CaptureBindings = {
|
|
185
202
|
initializeWithLicenseKey: (licenceKey: string, userId: string, allowHelloMessage: boolean) => LicenseUnlockResult;
|
|
186
203
|
Analyzer: typeof Analyzer;
|
|
@@ -190,14 +207,14 @@ export declare type CaptureBindings = {
|
|
|
190
207
|
export declare type CaptureCallbacks = Partial<{
|
|
191
208
|
/**
|
|
192
209
|
* Will be called on every frame after it has finished processing
|
|
210
|
+
* @param frameResult Detailed information on the frame analysis result {@linkcode FrameAnalysisResult}
|
|
193
211
|
* @param frame {@linkcode ImageData} of the frame. Make sure to copy it as it
|
|
194
212
|
* will be overwritten when the next frame finishes processing.
|
|
195
|
-
* @param frameResult Detailed information on the frame analysis
|
|
196
213
|
*/
|
|
197
|
-
onFrameAnalysis: (
|
|
214
|
+
onFrameAnalysis: (frameResult: FrameAnalysisResult, frame: ImageData) => void;
|
|
198
215
|
/**
|
|
199
216
|
* Will be called after the entire recognition process has finished successfully.
|
|
200
|
-
* @param result The result
|
|
217
|
+
* @param result The result of the recognition process {@linkcode AnalyzerResult}
|
|
201
218
|
*/
|
|
202
219
|
onCaptureResult: (result: AnalyzerResult) => void;
|
|
203
220
|
}>;
|
|
@@ -207,67 +224,84 @@ export declare type CaptureComponent = {
|
|
|
207
224
|
dismount: () => void;
|
|
208
225
|
} & ExposedComponentApi;
|
|
209
226
|
|
|
210
|
-
/**
|
|
211
|
-
|
|
227
|
+
/**
|
|
228
|
+
* Singleton that represents the Capture SDK
|
|
229
|
+
*/
|
|
230
|
+
export declare interface CaptureSdk extends _CaptureSdk {
|
|
231
|
+
}
|
|
212
232
|
|
|
213
233
|
/**
|
|
214
|
-
* The
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* of {@linkcode createCaptureSdk}
|
|
218
|
-
*
|
|
234
|
+
* The class that represents the Capture SDK.
|
|
235
|
+
* Not exported to prevent manual instantiation.
|
|
236
|
+
* @private
|
|
219
237
|
*/
|
|
220
|
-
declare
|
|
238
|
+
declare class _CaptureSdk {
|
|
239
|
+
#private;
|
|
240
|
+
constructor(directApi: DirectApi);
|
|
221
241
|
/**
|
|
222
|
-
*
|
|
242
|
+
* Single-time setup for a video element
|
|
223
243
|
*/
|
|
224
|
-
|
|
244
|
+
setupVideoElement(videoElement: HTMLVideoElement): void;
|
|
225
245
|
/**
|
|
226
|
-
*
|
|
246
|
+
* Updates the analyzer. Capture process can't be active. Stop it using
|
|
247
|
+
* {@linkcode updateAnalyzerSettings} if required.
|
|
248
|
+
* @param settings {@linkcode AnalyzerSettings}. Will merge with the current
|
|
249
|
+
* settings.
|
|
227
250
|
*/
|
|
228
|
-
|
|
251
|
+
updateAnalyzerSettings(settings: Partial<AnalyzerSettings>): Promise<void>;
|
|
252
|
+
/**
|
|
253
|
+
* Select a camera device from available ones.
|
|
254
|
+
*
|
|
255
|
+
* @param camera A camera device configured by the SDK. You can see available
|
|
256
|
+
* devices using on {@linkcode ReactiveStore.cameras} available by calling {@linkcode captureSdk.getState()}
|
|
257
|
+
*/
|
|
258
|
+
selectCamera(camera: ConfiguredCamera): Promise<void>;
|
|
259
|
+
/**
|
|
260
|
+
* Refreshes available devices on the system and updates the state.
|
|
261
|
+
*/
|
|
262
|
+
updateCameraDevices(): Promise<void>;
|
|
229
263
|
/**
|
|
230
264
|
* Starts the video playback
|
|
231
265
|
*
|
|
232
266
|
* @returns resolves when playback starts
|
|
233
267
|
*/
|
|
234
|
-
startPlayback:
|
|
268
|
+
startPlayback(): Promise<void>;
|
|
235
269
|
/**
|
|
236
|
-
*
|
|
270
|
+
* Starts a best-effort camera stream on a provided video element
|
|
237
271
|
*/
|
|
238
|
-
|
|
272
|
+
startCameraStream(videoElement: HTMLVideoElement, autoplay?: boolean): Promise<void>;
|
|
239
273
|
/**
|
|
240
274
|
* Starts playback and capture.
|
|
241
275
|
*/
|
|
242
|
-
startCapture:
|
|
276
|
+
startCapture(): Promise<void>;
|
|
243
277
|
/**
|
|
244
278
|
* Pauses the capture process without resetting the recognizer.
|
|
245
279
|
*/
|
|
246
|
-
pauseCapture:
|
|
280
|
+
pauseCapture(): void;
|
|
247
281
|
/**
|
|
248
282
|
* Cancels the capture process. Unlike {@linkcode pauseCapture}, it also resets
|
|
249
283
|
* the analyzer.
|
|
250
284
|
*/
|
|
251
|
-
cancelCapture:
|
|
285
|
+
cancelCapture(): Promise<void>;
|
|
252
286
|
/**
|
|
253
|
-
*
|
|
287
|
+
* Resets the currently active capturing process.
|
|
254
288
|
*/
|
|
255
|
-
|
|
289
|
+
resetCapture(): Promise<void>;
|
|
256
290
|
/**
|
|
257
|
-
*
|
|
291
|
+
* Stops the currently active stream
|
|
258
292
|
*/
|
|
259
|
-
|
|
293
|
+
stopStream(): Promise<void>;
|
|
260
294
|
/**
|
|
261
|
-
*
|
|
295
|
+
* Attempts to finish the side capture early.
|
|
262
296
|
*
|
|
263
|
-
* @
|
|
264
|
-
*
|
|
297
|
+
* @returns `true` if there are enough captured frames to finish the current
|
|
298
|
+
* side capture, `false` otherwise.
|
|
265
299
|
*/
|
|
266
|
-
|
|
300
|
+
finishSideCapture(): Promise<boolean>;
|
|
267
301
|
/**
|
|
268
|
-
*
|
|
302
|
+
* Pauses the video playback. This will also stop the capturing process.
|
|
269
303
|
*/
|
|
270
|
-
|
|
304
|
+
pausePlayback(): void;
|
|
271
305
|
/**
|
|
272
306
|
* Set up callbacks on the SDK
|
|
273
307
|
*
|
|
@@ -276,17 +310,15 @@ declare const captureSdk: {
|
|
|
276
310
|
*
|
|
277
311
|
* Send an empty object (`{}`) to clear callbacks.
|
|
278
312
|
*/
|
|
279
|
-
setCallbacks:
|
|
313
|
+
setCallbacks(newCallbacks: CaptureCallbacks): void;
|
|
280
314
|
/**
|
|
281
|
-
*
|
|
282
|
-
* {@linkcode updateAnalyzerSettings} if required.
|
|
283
|
-
* @param settings {@linkcode AnalyzerSettings}. Will merge with the current
|
|
284
|
-
* settings.
|
|
315
|
+
* If true, the video and captured frames will be mirrored horizontally.
|
|
285
316
|
*/
|
|
286
|
-
|
|
317
|
+
setMirrorX(mirrorX: boolean): void;
|
|
287
318
|
/**
|
|
288
|
-
* Allows the user to subscribe to state changes inside the Capture SDK.
|
|
289
|
-
* For usage information, see
|
|
319
|
+
* Allows the user to subscribe to state changes inside the Capture SDK.
|
|
320
|
+
* Implemented using Zustand. For usage information, see
|
|
321
|
+
* {@link https://github.com/pmndrs/zustand#using-subscribe-with-selector}
|
|
290
322
|
*/
|
|
291
323
|
subscribe: {
|
|
292
324
|
(listener: (selectedState: ReactiveStore, previousSelectedState: ReactiveStore) => void): () => void;
|
|
@@ -300,32 +332,26 @@ declare const captureSdk: {
|
|
|
300
332
|
*/
|
|
301
333
|
getState: () => ReactiveStore;
|
|
302
334
|
/**
|
|
303
|
-
* Resets the
|
|
335
|
+
* Resets the captureSdk and terminates the workers and the Wasm runtime.
|
|
304
336
|
*/
|
|
305
|
-
destroy:
|
|
306
|
-
}
|
|
337
|
+
destroy(): Promise<void>;
|
|
338
|
+
}
|
|
307
339
|
|
|
308
|
-
export declare type CaptureSdkSettings = {
|
|
309
|
-
/** The licence key for loading the Capture SDK. Required. */
|
|
310
|
-
licenseKey: string;
|
|
340
|
+
export declare type CaptureSdkSettings = Prettify<DirectApiSettings & {
|
|
311
341
|
/** Optional callbacks */
|
|
312
342
|
callbacks?: CaptureCallbacks;
|
|
313
|
-
|
|
314
|
-
analyzerSettings?: Partial<AnalyzerSettings>;
|
|
315
|
-
/** By default, the SDK will look for the required `/resources` directory on the current URL path.
|
|
316
|
-
*
|
|
317
|
-
* If you are hosting the resources on a different URL, provide a new relative or absolute one.
|
|
318
|
-
*/
|
|
319
|
-
resourceUrl?: string;
|
|
320
|
-
};
|
|
343
|
+
}>;
|
|
321
344
|
|
|
322
345
|
/**
|
|
323
346
|
* Document side classification.
|
|
324
347
|
*
|
|
325
|
-
*
|
|
348
|
+
* If side classification was uncertain, `"unknown"` is returned.
|
|
326
349
|
*/
|
|
327
350
|
export declare type CaptureSide = "unknown" | "front" | "back";
|
|
328
351
|
|
|
352
|
+
/**
|
|
353
|
+
* The capture state.
|
|
354
|
+
*/
|
|
329
355
|
export declare type CaptureState = "side-captured" | "document-captured" | "first-side-capture-in-progress" | "second-side-capture-in-progress";
|
|
330
356
|
|
|
331
357
|
/**
|
|
@@ -347,10 +373,42 @@ export declare type CaptureStrategy = "optimize-for-speed" | "optimize-for-quali
|
|
|
347
373
|
*/
|
|
348
374
|
export declare type CaptureWasmModule = CaptureBindings & EmscriptenModule;
|
|
349
375
|
|
|
376
|
+
declare class CaptureWorker {
|
|
377
|
+
#private;
|
|
378
|
+
/**
|
|
379
|
+
* @returns a Comlink-proxified instance of the Wasm module
|
|
380
|
+
*/
|
|
381
|
+
loadWasm(): Promise<CaptureBindings & EmscriptenModule & ProxyMarked>;
|
|
382
|
+
/**
|
|
383
|
+
* Separate function so that we can set a finalizer on the analyzer.
|
|
384
|
+
*/
|
|
385
|
+
createAnalyzer(): (Analyzer & ProxyMarked) | undefined;
|
|
386
|
+
/**
|
|
387
|
+
* Separate function so that we can clear the `imageData` buffer
|
|
388
|
+
*/
|
|
389
|
+
analyze(image: Parameters<Analyzer["analyze"]>[0]): FrameAnalysisResult | FrameAnalysisError;
|
|
390
|
+
/**
|
|
391
|
+
* Terminates the workers and the Wasm runtime.
|
|
392
|
+
*/
|
|
393
|
+
terminate(): void;
|
|
394
|
+
/** By default, the SDK will look for the required `/resources` directory on
|
|
395
|
+
* the current URL path.
|
|
396
|
+
*
|
|
397
|
+
* If you are hosting the resources on a different URL, provide a new relative
|
|
398
|
+
* or absolute one. The SDK will then search for files in the `/resources`
|
|
399
|
+
* directory of that URL.
|
|
400
|
+
*/
|
|
401
|
+
setResourceUrl(url: string): void;
|
|
402
|
+
/**
|
|
403
|
+
* This method is called when the worker is terminated.
|
|
404
|
+
*/
|
|
405
|
+
[finalizer](): void;
|
|
406
|
+
}
|
|
407
|
+
|
|
350
408
|
/**
|
|
351
|
-
* Completeness status of capture process
|
|
409
|
+
* Completeness status of capture process.
|
|
352
410
|
*/
|
|
353
|
-
export declare type
|
|
411
|
+
export declare type CompletenessStatus = "empty" | "one-side-missing" | "complete";
|
|
354
412
|
|
|
355
413
|
export declare class ConfiguredCamera {
|
|
356
414
|
#private;
|
|
@@ -365,95 +423,11 @@ export declare class ConfiguredCamera {
|
|
|
365
423
|
}
|
|
366
424
|
|
|
367
425
|
/**
|
|
368
|
-
*
|
|
426
|
+
* Creates a singleton instance of the Capture SDK.
|
|
427
|
+
* @param settings {@linkcode CaptureSdkSettings}
|
|
428
|
+
* @returns A singleton instance of {@linkcode CaptureSdk}
|
|
369
429
|
*/
|
|
370
|
-
export declare function createCaptureSdk(settings: CaptureSdkSettings): Promise<
|
|
371
|
-
/**
|
|
372
|
-
* Starts a best-effort camera stream on a provided video element
|
|
373
|
-
*/
|
|
374
|
-
startCameraStream: typeof startCameraStream;
|
|
375
|
-
/**
|
|
376
|
-
* Stops the currently active stream
|
|
377
|
-
*/
|
|
378
|
-
stopStream: typeof stopStream;
|
|
379
|
-
/**
|
|
380
|
-
* Starts the video playback
|
|
381
|
-
*
|
|
382
|
-
* @returns resolves when playback starts
|
|
383
|
-
*/
|
|
384
|
-
startPlayback: typeof startPlayback;
|
|
385
|
-
/**
|
|
386
|
-
* Pauses the video playback. This will also stop the capturing process.
|
|
387
|
-
*/
|
|
388
|
-
pausePlayback: typeof pausePlayback;
|
|
389
|
-
/**
|
|
390
|
-
* Starts playback and capture.
|
|
391
|
-
*/
|
|
392
|
-
startCapture: typeof startCapture;
|
|
393
|
-
/**
|
|
394
|
-
* Pauses the capture process without resetting the recognizer.
|
|
395
|
-
*/
|
|
396
|
-
pauseCapture: typeof pauseCapture;
|
|
397
|
-
/**
|
|
398
|
-
* Cancels the capture process. Unlike {@linkcode pauseCapture}, it also resets
|
|
399
|
-
* the analyzer.
|
|
400
|
-
*/
|
|
401
|
-
cancelCapture: typeof cancelCapture;
|
|
402
|
-
/**
|
|
403
|
-
* Finishes capturing the current side
|
|
404
|
-
*/
|
|
405
|
-
finishSideCapture: typeof finishSideCapture;
|
|
406
|
-
/**
|
|
407
|
-
* Resets the analyzer.
|
|
408
|
-
*/
|
|
409
|
-
resetAnalyzer: typeof resetAnalyzer;
|
|
410
|
-
/**
|
|
411
|
-
* Select a camera device from available ones.
|
|
412
|
-
*
|
|
413
|
-
* @param camera A camera device configured by the SDK. You can see available
|
|
414
|
-
* devices using on {@linkcode ReactiveStore.cameras} available by calling {@linkcode captureSdk.getState()}
|
|
415
|
-
*/
|
|
416
|
-
selectCamera: typeof selectCamera;
|
|
417
|
-
/**
|
|
418
|
-
* Refreshes available devices on the system and updates the state.
|
|
419
|
-
*/
|
|
420
|
-
updateCameraDevices: typeof updateCameraDevices;
|
|
421
|
-
/**
|
|
422
|
-
* Set up callbacks on the SDK
|
|
423
|
-
*
|
|
424
|
-
* @param newCallbacks A subset of available
|
|
425
|
-
* {@linkcode CaptureCallbacks}. Will overwrite the previously set one.
|
|
426
|
-
*
|
|
427
|
-
* Send an empty object (`{}`) to clear callbacks.
|
|
428
|
-
*/
|
|
429
|
-
setCallbacks: typeof setCallbacks;
|
|
430
|
-
/**
|
|
431
|
-
* Updates the analyzer. Capture process can't be active. Stop it using
|
|
432
|
-
* {@linkcode updateAnalyzerSettings} if required.
|
|
433
|
-
* @param settings {@linkcode AnalyzerSettings}. Will merge with the current
|
|
434
|
-
* settings.
|
|
435
|
-
*/
|
|
436
|
-
updateAnalyzerSettings: typeof updateAnalyzerSettings;
|
|
437
|
-
/**
|
|
438
|
-
* Allows the user to subscribe to state changes inside the Capture SDK. Implemented using Zustand.
|
|
439
|
-
* For usage information, see {@link https://github.com/pmndrs/zustand#using-subscribe-with-selector}
|
|
440
|
-
*/
|
|
441
|
-
subscribe: {
|
|
442
|
-
(listener: (selectedState: ReactiveStore, previousSelectedState: ReactiveStore) => void): () => void;
|
|
443
|
-
<U>(selector: (state: ReactiveStore) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
444
|
-
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
445
|
-
fireImmediately?: boolean | undefined;
|
|
446
|
-
} | undefined): () => void;
|
|
447
|
-
};
|
|
448
|
-
/**
|
|
449
|
-
* Gets the current internal state of the Capture SDK.
|
|
450
|
-
*/
|
|
451
|
-
getState: () => ReactiveStore;
|
|
452
|
-
/**
|
|
453
|
-
* Resets the SDK core and terminates the workers and the Wasm runtime.
|
|
454
|
-
*/
|
|
455
|
-
destroy: typeof destroy;
|
|
456
|
-
}>;
|
|
430
|
+
export declare function createCaptureSdk(settings: CaptureSdkSettings): Promise<CaptureSdk>;
|
|
457
431
|
|
|
458
432
|
/**
|
|
459
433
|
* Creates the capture UI and loads the SDK
|
|
@@ -469,6 +443,15 @@ declare type CreateCaptureUiSettings = {
|
|
|
469
443
|
uiSettings?: UiSettings;
|
|
470
444
|
};
|
|
471
445
|
|
|
446
|
+
/**
|
|
447
|
+
* Creates a new `DirectApi` instance.
|
|
448
|
+
* @param settings - The settings for the `DirectApi` instance.
|
|
449
|
+
* @returns A new `DirectApi` instance.
|
|
450
|
+
*/
|
|
451
|
+
export declare function createDirectApi(settings: DirectApiSettings): Promise<DirectApi>;
|
|
452
|
+
|
|
453
|
+
declare const createEndpoint: unique symbol;
|
|
454
|
+
|
|
472
455
|
/**
|
|
473
456
|
* Copyright (c) 2023 Microblink Ltd. All rights reserved.
|
|
474
457
|
*
|
|
@@ -488,6 +471,8 @@ declare const _default: {
|
|
|
488
471
|
move_farther: string;
|
|
489
472
|
camera_angle_too_steep: string;
|
|
490
473
|
document_too_close_to_edge: string;
|
|
474
|
+
rotate_phone_animation: string;
|
|
475
|
+
rotate_phone: string;
|
|
491
476
|
lightning_too_bright: string;
|
|
492
477
|
lightning_too_dark: string;
|
|
493
478
|
blur_detected: string;
|
|
@@ -518,14 +503,105 @@ declare const _default: {
|
|
|
518
503
|
};
|
|
519
504
|
|
|
520
505
|
/**
|
|
521
|
-
*
|
|
506
|
+
* The `DirectApi` is a wrapper around the `capture-worker` module.
|
|
507
|
+
*
|
|
508
|
+
* This is a low-level API that exposes the `capture-worker` module directly and
|
|
509
|
+
* should only be used if the `CaptureSDK` API isn't sufficient.
|
|
522
510
|
*/
|
|
523
|
-
declare
|
|
511
|
+
export declare interface DirectApi extends _DirectApi {
|
|
512
|
+
}
|
|
524
513
|
|
|
514
|
+
/**
|
|
515
|
+
* The `_DirectApi` class is private to prevent manual instantiation.
|
|
516
|
+
* @private
|
|
517
|
+
*/
|
|
518
|
+
declare class _DirectApi {
|
|
519
|
+
#private;
|
|
520
|
+
constructor(remoteWorker: Remote<ProxyWorker>, remoteAnalyzer: Remote<Analyzer & ProxyMarked>);
|
|
521
|
+
/**
|
|
522
|
+
* Analyzes a single frame.
|
|
523
|
+
*
|
|
524
|
+
* @remarks
|
|
525
|
+
* This method is a proxy to the `capture-worker` module.
|
|
526
|
+
* It is a workaround to avoid memory leaks when using the `Remote` object
|
|
527
|
+
* directly.
|
|
528
|
+
*
|
|
529
|
+
* @param image - The image to analyze.
|
|
530
|
+
* @returns The analysis result or an error.
|
|
531
|
+
*/
|
|
532
|
+
analyze: (image: ImageData) => Promise<FrameAnalysisResult | FrameAnalysisError>;
|
|
533
|
+
/**
|
|
534
|
+
* Attempts to finish the side capture early.
|
|
535
|
+
*
|
|
536
|
+
* If there aren't enough captured frames, the method returns `false` and
|
|
537
|
+
* further `Analyzer.analyze` calls are required.
|
|
538
|
+
*
|
|
539
|
+
* Otherwise, the method returns `true` and the `Analyzer` uses the best frame
|
|
540
|
+
* candidate to finish the side capture and either finish the capture process
|
|
541
|
+
* or continue to the next side.
|
|
542
|
+
*
|
|
543
|
+
* @returns `true` if there are enough captured frames to finish the capture
|
|
544
|
+
* process and `getResult` can be called, `false` otherwise.
|
|
545
|
+
*/
|
|
546
|
+
finishSideCapture: () => Promise<boolean>;
|
|
547
|
+
/**
|
|
548
|
+
* Returns the analyzer result.
|
|
549
|
+
* @returns The analysis result.
|
|
550
|
+
*/
|
|
551
|
+
getResult: () => Promise<AnalyzerResult>;
|
|
552
|
+
/**
|
|
553
|
+
* Returns the analyzer settings.
|
|
554
|
+
* @returns The analyzer settings.
|
|
555
|
+
*/
|
|
556
|
+
getSettings: () => Promise<AnalyzerSettings>;
|
|
557
|
+
/**
|
|
558
|
+
* Updates the analyzer settings. The new settings are merged with the current
|
|
559
|
+
* settings.
|
|
560
|
+
*
|
|
561
|
+
* Don't update settings in the middle of a capture session. Call
|
|
562
|
+
* `resetCapture` first.
|
|
563
|
+
*
|
|
564
|
+
* @param newSettings - The new analyzer settings. Can be a partial object.
|
|
565
|
+
*/
|
|
566
|
+
updateSettings: (newSettings: Partial<AnalyzerSettings>) => Promise<void>;
|
|
567
|
+
/**
|
|
568
|
+
* Resets the currently active capturing process.
|
|
569
|
+
*/
|
|
570
|
+
resetCapture: () => Promise<void>;
|
|
571
|
+
/**
|
|
572
|
+
* Terminates the workers and the Wasm runtime.
|
|
573
|
+
*/
|
|
574
|
+
terminateWorker(): Promise<void>;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
export declare type DirectApiSettings = {
|
|
578
|
+
/** The licence key for loading the Capture SDK. Required. */
|
|
579
|
+
licenseKey: string;
|
|
580
|
+
/** Custom settings for the Capture analyzer */
|
|
581
|
+
analyzerSettings?: Partial<AnalyzerSettings>;
|
|
582
|
+
/** By default, the SDK will look for the required `/resources` directory on
|
|
583
|
+
the current URL path.
|
|
584
|
+
*
|
|
585
|
+
If you are hosting the resources on a different URL, provide a new relative
|
|
586
|
+
or absolute one. The SDK will then search for files in the `/resources`
|
|
587
|
+
directory of that URL.
|
|
588
|
+
*/
|
|
589
|
+
resourceUrl?: string;
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* The document blur status for the current frame.
|
|
594
|
+
*/
|
|
525
595
|
export declare type DocumentBlurStatus = "not-available" | "blur-detected" | "blur-not-detected";
|
|
526
596
|
|
|
527
|
-
|
|
597
|
+
/**
|
|
598
|
+
* The document framing status for the current frame.
|
|
599
|
+
*/
|
|
600
|
+
export declare type DocumentFramingStatus = "not-available" | "no-document" | "camera-too-far" | "camera-too-close" | "camera-angle-too-steep" | "camera-orientation-unsuitable" | "document-too-close-to-frame-edge" | "ok";
|
|
528
601
|
|
|
602
|
+
/**
|
|
603
|
+
* The document glare status for the current frame.
|
|
604
|
+
*/
|
|
529
605
|
export declare type DocumentGlareStatus = "not-available" | "glare-detected" | "glare-not-detected";
|
|
530
606
|
|
|
531
607
|
/**
|
|
@@ -533,11 +609,19 @@ export declare type DocumentGlareStatus = "not-available" | "glare-detected" | "
|
|
|
533
609
|
*/
|
|
534
610
|
export declare type DocumentGroup = "unknown" | "dl" | "id" | "passport" | "passport-card" | "visa";
|
|
535
611
|
|
|
612
|
+
/**
|
|
613
|
+
* The document lighting status for the current frame.
|
|
614
|
+
*/
|
|
536
615
|
export declare type DocumentLightingStatus = "not-available" | "too-bright" | "too-dark" | "normal";
|
|
537
616
|
|
|
617
|
+
/**
|
|
618
|
+
* The document occlusion status for the current frame.
|
|
619
|
+
*/
|
|
538
620
|
export declare type DocumentOcclusionStatus = "not-available" | "occluded" | "not-occluded";
|
|
539
621
|
|
|
540
|
-
/**
|
|
622
|
+
/**
|
|
623
|
+
* Analysis status of the document side for the current frame.
|
|
624
|
+
*/
|
|
541
625
|
export declare type DocumentSideAnalysisStatus = "not-available" | "side-already-captured" | "side-not-captured";
|
|
542
626
|
|
|
543
627
|
/**
|
|
@@ -573,16 +657,13 @@ export declare type ExposedComponentApi = {
|
|
|
573
657
|
updateLocalization: SetStoreFunction<LocalizationStrings>;
|
|
574
658
|
};
|
|
575
659
|
|
|
576
|
-
|
|
660
|
+
declare class FeedbackParser {
|
|
577
661
|
private timeWindow;
|
|
578
662
|
private decayRate;
|
|
579
663
|
private eventStack;
|
|
580
|
-
private analyzerSettings;
|
|
581
664
|
private currentUiState;
|
|
582
665
|
private currentStateStartTime;
|
|
583
|
-
constructor(analyzerSettings: AnalyzerSettings);
|
|
584
666
|
reset(): void;
|
|
585
|
-
updateSettings(analyzerSettings: AnalyzerSettings): void;
|
|
586
667
|
/**
|
|
587
668
|
* Returns a weighted UI state based on the history
|
|
588
669
|
*/
|
|
@@ -597,10 +678,21 @@ export declare class FeedbackParser {
|
|
|
597
678
|
private getUiStateKeyFromResult;
|
|
598
679
|
}
|
|
599
680
|
|
|
681
|
+
export declare const feedbackParser: FeedbackParser;
|
|
682
|
+
|
|
683
|
+
declare const finalizer: unique symbol;
|
|
684
|
+
|
|
600
685
|
/**
|
|
601
|
-
*
|
|
686
|
+
* The return type of `Analyzer.analyze` when an error occurs.
|
|
602
687
|
*/
|
|
603
|
-
declare
|
|
688
|
+
export declare type FrameAnalysisError = {
|
|
689
|
+
error: FrameAnalysisErrorType;
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* The type of error that can occur during frame analysis.
|
|
694
|
+
*/
|
|
695
|
+
export declare type FrameAnalysisErrorType = "analyzer-settings-unsuitable-error" | "unknown-error";
|
|
604
696
|
|
|
605
697
|
/**
|
|
606
698
|
* Copyright (c) 2023 Microblink Ltd. All rights reserved.
|
|
@@ -612,12 +704,19 @@ declare function finishSideCapture(): Promise<void>;
|
|
|
612
704
|
* THIS PROGRAM IS PROTECTED BY COPYRIGHT LAWS AND YOU MAY NOT
|
|
613
705
|
* REVERSE ENGINEER, DECOMPILE, OR DISASSEMBLE IT.
|
|
614
706
|
*/
|
|
707
|
+
/**
|
|
708
|
+
* The return type of `Analyzer.analyze`. It contains the current capture state
|
|
709
|
+
* and frame analysis status.
|
|
710
|
+
*/
|
|
615
711
|
export declare type FrameAnalysisResult = {
|
|
616
712
|
captureState: CaptureState;
|
|
617
713
|
frameCaptured: boolean;
|
|
618
714
|
frameAnalysisStatus: FrameAnalysisStatus;
|
|
619
715
|
};
|
|
620
716
|
|
|
717
|
+
/**
|
|
718
|
+
* The frame analysis status.
|
|
719
|
+
*/
|
|
621
720
|
export declare type FrameAnalysisStatus = {
|
|
622
721
|
sideAnalysisStatus: DocumentSideAnalysisStatus;
|
|
623
722
|
framingStatus: DocumentFramingStatus;
|
|
@@ -681,50 +780,199 @@ export declare type LightingThresholds = {
|
|
|
681
780
|
tooBrightThreshold: number;
|
|
682
781
|
};
|
|
683
782
|
|
|
783
|
+
/**
|
|
784
|
+
* Takes the raw type of a remote object, function or class as a remote thread would see it through a proxy (e.g. when
|
|
785
|
+
* passed in as a function argument) and returns the type the local thread has to supply.
|
|
786
|
+
*
|
|
787
|
+
* This is the inverse of `Remote<T>`. It takes a `Remote<T>` and returns its original input `T`.
|
|
788
|
+
*/
|
|
789
|
+
declare type Local<T> = Omit<LocalObject<T>, keyof ProxyMethods> & (T extends (...args: infer TArguments) => infer TReturn ? (...args: {
|
|
790
|
+
[I in keyof TArguments]: ProxyOrClone<TArguments[I]>;
|
|
791
|
+
}) => MaybePromise<UnproxyOrClone<Unpromisify<TReturn>>> : unknown) & (T extends {
|
|
792
|
+
new (...args: infer TArguments): infer TInstance;
|
|
793
|
+
} ? {
|
|
794
|
+
new (...args: {
|
|
795
|
+
[I in keyof TArguments]: ProxyOrClone<TArguments[I]>;
|
|
796
|
+
}): MaybePromise<Local<Unpromisify<TInstance>>>;
|
|
797
|
+
} : unknown);
|
|
798
|
+
|
|
684
799
|
declare type LocalizationStrings = typeof _default;
|
|
685
800
|
|
|
686
801
|
/**
|
|
687
|
-
*
|
|
802
|
+
* Takes the type of an object as a remote thread would see it through a proxy (e.g. when passed in as a function
|
|
803
|
+
* argument) and returns the type that the local thread has to supply.
|
|
804
|
+
*
|
|
805
|
+
* This does not handle call signatures, which is handled by the more general `Local<T>` type.
|
|
806
|
+
*
|
|
807
|
+
* This is the inverse of `RemoteObject<T>`.
|
|
808
|
+
*
|
|
809
|
+
* @template T The type of a proxied object.
|
|
688
810
|
*/
|
|
689
|
-
declare
|
|
811
|
+
declare type LocalObject<T> = {
|
|
812
|
+
[P in keyof T]: LocalProperty<T[P]>;
|
|
813
|
+
};
|
|
690
814
|
|
|
691
815
|
/**
|
|
692
|
-
*
|
|
816
|
+
* Takes the raw type of a property as a remote thread would see it through a proxy (e.g. when passed in as a function
|
|
817
|
+
* argument) and returns the type that the local thread has to supply.
|
|
818
|
+
*
|
|
819
|
+
* This is the inverse of `RemoteProperty<T>`.
|
|
820
|
+
*
|
|
821
|
+
* Note: This needs to be its own type alias, otherwise it will not distribute over unions. See
|
|
822
|
+
* https://www.typescriptlang.org/docs/handbook/advanced-types.html#distributive-conditional-types
|
|
823
|
+
*/
|
|
824
|
+
declare type LocalProperty<T> = T extends Function | ProxyMarked ? Local<T> : Unpromisify<T>;
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* Expresses that a type can be either a sync or async.
|
|
828
|
+
*/
|
|
829
|
+
declare type MaybePromise<T> = Promise<T> | T;
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* Displays the resolved type instead of intersections.
|
|
833
|
+
*/
|
|
834
|
+
declare type Prettify<T> = {
|
|
835
|
+
[K in keyof T]: T[K];
|
|
836
|
+
} & {};
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* Takes a type and wraps it in a Promise, if it not already is one.
|
|
840
|
+
* This is to avoid `Promise<Promise<T>>`.
|
|
841
|
+
*
|
|
842
|
+
* This is the inverse of `Unpromisify<T>`.
|
|
693
843
|
*/
|
|
694
|
-
declare
|
|
844
|
+
declare type Promisify<T> = T extends Promise<unknown> ? T : Promise<T>;
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* Interface of values that were marked to be proxied with `comlink.proxy()`.
|
|
848
|
+
* Can also be implemented by classes.
|
|
849
|
+
*/
|
|
850
|
+
declare interface ProxyMarked {
|
|
851
|
+
[proxyMarker]: true;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
declare const proxyMarker: unique symbol;
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* Additional special comlink methods available on each proxy returned by `Comlink.wrap()`.
|
|
858
|
+
*/
|
|
859
|
+
declare interface ProxyMethods {
|
|
860
|
+
[createEndpoint]: () => Promise<MessagePort>;
|
|
861
|
+
[releaseProxy]: () => void;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
/**
|
|
865
|
+
* Proxies `T` if it is a `ProxyMarked`, clones it otherwise (as handled by structured cloning and transfer handlers).
|
|
866
|
+
*/
|
|
867
|
+
declare type ProxyOrClone<T> = T extends ProxyMarked ? Remote<T> : T;
|
|
868
|
+
|
|
869
|
+
declare type ProxyWorker = Omit<CaptureWorker, typeof finalizer>;
|
|
695
870
|
|
|
696
871
|
export declare type ReactiveStore = {
|
|
872
|
+
/**
|
|
873
|
+
* The video element that is currently being used for capture.
|
|
874
|
+
*/
|
|
697
875
|
videoElement: HTMLVideoElement | null;
|
|
876
|
+
/**
|
|
877
|
+
* The list of cameras that are available to the user.
|
|
878
|
+
*/
|
|
698
879
|
cameras: ConfiguredCamera[];
|
|
880
|
+
/**
|
|
881
|
+
* The currently selected camera.
|
|
882
|
+
*/
|
|
699
883
|
selectedCamera: ConfiguredCamera | null;
|
|
884
|
+
/**
|
|
885
|
+
* The callbacks that are used to communicate with the capture sdk.
|
|
886
|
+
*/
|
|
700
887
|
callbacks: CaptureCallbacks;
|
|
888
|
+
/**
|
|
889
|
+
* Whether the camera stream is currently active and playing back on the video
|
|
890
|
+
* element.
|
|
891
|
+
*/
|
|
701
892
|
isPlaying: boolean;
|
|
893
|
+
/**
|
|
894
|
+
* Whether the active video stream is currently being captured and processed
|
|
895
|
+
* by the Analyzer.
|
|
896
|
+
*/
|
|
702
897
|
isCapturing: boolean;
|
|
898
|
+
/**
|
|
899
|
+
* Whether the camera is currently being swapped.
|
|
900
|
+
*/
|
|
703
901
|
isSwappingCamera: boolean;
|
|
902
|
+
/**
|
|
903
|
+
* Whether the camera list is currently being queried.
|
|
904
|
+
*/
|
|
704
905
|
isQueryingCameras: boolean;
|
|
906
|
+
/**
|
|
907
|
+
* The analyzer settings that are currently being used.
|
|
908
|
+
*/
|
|
705
909
|
analyzerSettings: AnalyzerSettings;
|
|
910
|
+
/**
|
|
911
|
+
* Indicates if the captured frames will be mirrored horizontally
|
|
912
|
+
*/
|
|
913
|
+
mirrorX: boolean;
|
|
914
|
+
/**
|
|
915
|
+
* The current UI state. Represents the current feedback messages being shown
|
|
916
|
+
* to the user.
|
|
917
|
+
*/
|
|
706
918
|
uiState: UiState;
|
|
707
|
-
/**
|
|
919
|
+
/**
|
|
920
|
+
* Whether the capture requires landscape mode.
|
|
921
|
+
*/
|
|
922
|
+
captureRequiresLandscape: boolean;
|
|
923
|
+
/**
|
|
924
|
+
* Whether the SDK has been initialized.
|
|
925
|
+
*/
|
|
708
926
|
initialized: boolean;
|
|
927
|
+
/**
|
|
928
|
+
* If the SDK has encountered an error, this will be set to the error.
|
|
929
|
+
*/
|
|
709
930
|
errorState: Error | null;
|
|
710
931
|
};
|
|
711
932
|
|
|
933
|
+
declare const releaseProxy: unique symbol;
|
|
934
|
+
|
|
712
935
|
/**
|
|
713
|
-
*
|
|
936
|
+
* Takes the raw type of a remote object, function or class in the other thread and returns the type as it is visible to
|
|
937
|
+
* the local thread from the proxy return value of `Comlink.wrap()` or `Comlink.proxy()`.
|
|
714
938
|
*/
|
|
715
|
-
declare
|
|
716
|
-
|
|
717
|
-
|
|
939
|
+
declare type Remote<T> = RemoteObject<T> & (T extends (...args: infer TArguments) => infer TReturn ? (...args: {
|
|
940
|
+
[I in keyof TArguments]: UnproxyOrClone<TArguments[I]>;
|
|
941
|
+
}) => Promisify<ProxyOrClone<Unpromisify<TReturn>>> : unknown) & (T extends {
|
|
942
|
+
new (...args: infer TArguments): infer TInstance;
|
|
943
|
+
} ? {
|
|
944
|
+
new (...args: {
|
|
945
|
+
[I in keyof TArguments]: UnproxyOrClone<TArguments[I]>;
|
|
946
|
+
}): Promisify<Remote<TInstance>>;
|
|
947
|
+
} : unknown) & ProxyMethods;
|
|
718
948
|
|
|
719
|
-
|
|
949
|
+
/**
|
|
950
|
+
* Takes the raw type of a remote object in the other thread and returns the type as it is visible to the local thread
|
|
951
|
+
* when proxied with `Comlink.proxy()`.
|
|
952
|
+
*
|
|
953
|
+
* This does not handle call signatures, which is handled by the more general `Remote<T>` type.
|
|
954
|
+
*
|
|
955
|
+
* @template T The raw type of a remote object as seen in the other thread.
|
|
956
|
+
*/
|
|
957
|
+
declare type RemoteObject<T> = {
|
|
958
|
+
[P in keyof T]: RemoteProperty<T[P]>;
|
|
959
|
+
};
|
|
720
960
|
|
|
721
961
|
/**
|
|
722
|
-
*
|
|
962
|
+
* Takes the raw type of a remote property and returns the type that is visible to the local thread on the proxy.
|
|
723
963
|
*
|
|
724
|
-
*
|
|
725
|
-
*
|
|
964
|
+
* Note: This needs to be its own type alias, otherwise it will not distribute over unions.
|
|
965
|
+
* See https://www.typescriptlang.org/docs/handbook/advanced-types.html#distributive-conditional-types
|
|
726
966
|
*/
|
|
727
|
-
declare
|
|
967
|
+
declare type RemoteProperty<T> = T extends Function | ProxyMarked ? Remote<T> : Promisify<T>;
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* Resets the store to its initial state.
|
|
971
|
+
* Stops all camera streams as a side effect.
|
|
972
|
+
*/
|
|
973
|
+
export declare const resetCoreStore: () => void;
|
|
974
|
+
|
|
975
|
+
export declare type ReticleType = "searching" | "processing" | "error" | "done" | "flip" | "rotate";
|
|
728
976
|
|
|
729
977
|
export declare type ServerPermissionSubmitResult = Readonly<{
|
|
730
978
|
status: ServerPermissionSubmitResultStatus;
|
|
@@ -742,16 +990,6 @@ export declare enum ServerPermissionSubmitResultStatus {
|
|
|
742
990
|
IncorrectTokenState = 6
|
|
743
991
|
}
|
|
744
992
|
|
|
745
|
-
/**
|
|
746
|
-
* Set up callbacks on the SDK
|
|
747
|
-
*
|
|
748
|
-
* @param newCallbacks A subset of available
|
|
749
|
-
* {@linkcode CaptureCallbacks}. Will overwrite the previously set one.
|
|
750
|
-
*
|
|
751
|
-
* Send an empty object (`{}`) to clear callbacks.
|
|
752
|
-
*/
|
|
753
|
-
declare function setCallbacks(newCallbacks: CaptureCallbacks): void;
|
|
754
|
-
|
|
755
993
|
declare type SetStateInternal<T> = {
|
|
756
994
|
_(partial: T | Partial<T> | {
|
|
757
995
|
_(state: T): T | Partial<T>;
|
|
@@ -759,12 +997,12 @@ declare type SetStateInternal<T> = {
|
|
|
759
997
|
}['_'];
|
|
760
998
|
|
|
761
999
|
/**
|
|
762
|
-
*
|
|
1000
|
+
* Capture result of a single document side.
|
|
763
1001
|
*/
|
|
764
1002
|
export declare type SideCaptureResult = {
|
|
765
1003
|
/**
|
|
766
|
-
* Original image of the captured document, untransformed, as it was used
|
|
767
|
-
* analysis.
|
|
1004
|
+
* Original image of the captured document side, untransformed, as it was used
|
|
1005
|
+
* in the analysis.
|
|
768
1006
|
*/
|
|
769
1007
|
imageResult: ImageData;
|
|
770
1008
|
/**
|
|
@@ -775,33 +1013,16 @@ export declare type SideCaptureResult = {
|
|
|
775
1013
|
/**
|
|
776
1014
|
* Document side classification.
|
|
777
1015
|
*
|
|
778
|
-
*
|
|
1016
|
+
* If the side classification was uncertain, `"unknown"` is returned.
|
|
779
1017
|
*/
|
|
780
1018
|
side: CaptureSide;
|
|
1019
|
+
/**
|
|
1020
|
+
* If the document is captured at lower dpi than `minimumDocumentDpi` from settings,
|
|
1021
|
+
* flag is set to `true`.
|
|
1022
|
+
*/
|
|
1023
|
+
dpiAdjusted: boolean;
|
|
781
1024
|
};
|
|
782
1025
|
|
|
783
|
-
/**
|
|
784
|
-
* Starts a best-effort camera stream on a provided video element
|
|
785
|
-
*/
|
|
786
|
-
declare function startCameraStream(videoElement: HTMLVideoElement, autoplay?: boolean): Promise<void>;
|
|
787
|
-
|
|
788
|
-
/**
|
|
789
|
-
* Starts playback and capture.
|
|
790
|
-
*/
|
|
791
|
-
declare function startCapture(): Promise<void>;
|
|
792
|
-
|
|
793
|
-
/**
|
|
794
|
-
* Starts the video playback
|
|
795
|
-
*
|
|
796
|
-
* @returns resolves when playback starts
|
|
797
|
-
*/
|
|
798
|
-
declare function startPlayback(): Promise<void>;
|
|
799
|
-
|
|
800
|
-
/**
|
|
801
|
-
* Stops the currently active stream
|
|
802
|
-
*/
|
|
803
|
-
declare function stopStream(): Promise<void>;
|
|
804
|
-
|
|
805
1026
|
declare interface StoreApi<T> {
|
|
806
1027
|
setState: SetStateInternal<T>;
|
|
807
1028
|
getState: () => T;
|
|
@@ -852,30 +1073,30 @@ export declare type UiStateEvent = {
|
|
|
852
1073
|
currentWeight: number;
|
|
853
1074
|
};
|
|
854
1075
|
|
|
855
|
-
export declare type UiStateKey = "PROCESSING" | "SIDE_CAPTURED" | "
|
|
1076
|
+
export declare type UiStateKey = "PROCESSING" | "SIDE_CAPTURED" | "DOCUMENT_CAPTURED" | "SENSING_FRONT" | "SENSING_BACK" | "DOCUMENT_FRAMING_CAMERA_TOO_FAR" | "DOCUMENT_FRAMING_CAMERA_TOO_CLOSE" | "DOCUMENT_FRAMING_CAMERA_ORIENTATION_UNSUITABLE" | "DOCUMENT_FRAMING_CAMERA_ORIENTATION_UNSUITABLE_ANIMATION" | "DOCUMENT_FRAMING_CAMERA_ANGLE_TOO_STEEP" | "DOCUMENT_TOO_CLOSE_TO_FRAME_EDGE" | "LIGHTING_TOO_DARK" | "LIGHTING_TOO_BRIGHT" | "BLUR_DETECTED" | "GLARE_DETECTED" | "OCCLUDED" | "WRONG_SIDE";
|
|
856
1077
|
|
|
857
1078
|
export declare const uiStateMap: Readonly<Record<UiStateKey, UiState>>;
|
|
858
1079
|
|
|
859
1080
|
/**
|
|
860
|
-
*
|
|
861
|
-
*
|
|
862
|
-
*
|
|
863
|
-
*
|
|
1081
|
+
* Takes a type that may be Promise and unwraps the Promise type.
|
|
1082
|
+
* If `P` is not a Promise, it returns `P`.
|
|
1083
|
+
*
|
|
1084
|
+
* This is the inverse of `Promisify<T>`.
|
|
864
1085
|
*/
|
|
865
|
-
declare
|
|
1086
|
+
declare type Unpromisify<P> = P extends Promise<infer T> ? T : P;
|
|
866
1087
|
|
|
867
1088
|
/**
|
|
868
|
-
*
|
|
1089
|
+
* Inverse of `ProxyOrClone<T>`.
|
|
869
1090
|
*/
|
|
870
|
-
declare
|
|
1091
|
+
declare type UnproxyOrClone<T> = T extends RemoteObject<ProxyMarked> ? Local<T> : T;
|
|
871
1092
|
|
|
872
1093
|
/**
|
|
873
1094
|
* ⚠️ DANGER AHEAD ⚠️
|
|
874
1095
|
*
|
|
875
1096
|
* The Zustand store. Use only if you know what you're doing.
|
|
876
1097
|
*
|
|
877
|
-
* Never
|
|
878
|
-
* Make sure you only observe the state.
|
|
1098
|
+
* Never set the state as this will break the application logic. We do not have
|
|
1099
|
+
* two-way binding. Make sure you only observe the state.
|
|
879
1100
|
*
|
|
880
1101
|
* Prefer using subscriptions if you require observable state.
|
|
881
1102
|
*
|