@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.cts
CHANGED
|
@@ -1,12 +1,1115 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
/// <reference types="emscripten" />
|
|
2
|
+
|
|
3
|
+
import { MountableElement } from 'solid-js/web';
|
|
4
|
+
import { SetStoreFunction } from 'solid-js/store';
|
|
5
|
+
|
|
6
|
+
export declare class Analyzer extends EmbindObject {
|
|
7
|
+
/**
|
|
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.
|
|
14
|
+
*/
|
|
15
|
+
getResult: () => AnalyzerResult;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the analyzer settings.
|
|
18
|
+
*/
|
|
19
|
+
getSettings: () => AnalyzerSettings;
|
|
20
|
+
/**
|
|
21
|
+
* Updates the analyzer settings.
|
|
22
|
+
*/
|
|
23
|
+
updateSettings: (settings: AnalyzerSettings) => void;
|
|
24
|
+
/** Resets the currently active capturing process. */
|
|
25
|
+
reset: () => void;
|
|
26
|
+
/**
|
|
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.
|
|
31
|
+
*
|
|
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.
|
|
38
|
+
*/
|
|
39
|
+
finishSideCapture: () => boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Copyright (c) 2023 Microblink Ltd. All rights reserved.
|
|
44
|
+
*
|
|
45
|
+
* ANY UNAUTHORIZED USE OR SALE, DUPLICATION, OR DISTRIBUTION
|
|
46
|
+
* OF THIS PROGRAM OR ANY OF ITS PARTS, IN SOURCE OR BINARY FORMS,
|
|
47
|
+
* WITH OR WITHOUT MODIFICATION, WITH THE PURPOSE OF ACQUIRING
|
|
48
|
+
* UNLAWFUL MATERIAL OR ANY OTHER BENEFIT IS PROHIBITED!
|
|
49
|
+
* THIS PROGRAM IS PROTECTED BY COPYRIGHT LAWS AND YOU MAY NOT
|
|
50
|
+
* REVERSE ENGINEER, DECOMPILE, OR DISASSEMBLE IT.
|
|
51
|
+
*/
|
|
52
|
+
/**
|
|
53
|
+
* The result returned from `Analyzer.getResult`
|
|
54
|
+
*/
|
|
55
|
+
export declare type AnalyzerResult = {
|
|
56
|
+
/** Result of the first side capture */
|
|
57
|
+
firstCapture?: SideCaptureResult;
|
|
58
|
+
/** Result of the second side capture */
|
|
59
|
+
secondCapture?: SideCaptureResult;
|
|
60
|
+
/** Document group */
|
|
61
|
+
documentGroup: DocumentGroup;
|
|
62
|
+
/** Completeness status of the capture process */
|
|
63
|
+
completenessStatus: CompletenessStatus;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Copyright (c) 2023 Microblink Ltd. All rights reserved.
|
|
68
|
+
*
|
|
69
|
+
* ANY UNAUTHORIZED USE OR SALE, DUPLICATION, OR DISTRIBUTION
|
|
70
|
+
* OF THIS PROGRAM OR ANY OF ITS PARTS, IN SOURCE OR BINARY FORMS,
|
|
71
|
+
* WITH OR WITHOUT MODIFICATION, WITH THE PURPOSE OF ACQUIRING
|
|
72
|
+
* UNLAWFUL MATERIAL OR ANY OTHER BENEFIT IS PROHIBITED!
|
|
73
|
+
* THIS PROGRAM IS PROTECTED BY COPYRIGHT LAWS AND YOU MAY NOT
|
|
74
|
+
* REVERSE ENGINEER, DECOMPILE, OR DISASSEMBLE IT.
|
|
75
|
+
*/
|
|
76
|
+
/**
|
|
77
|
+
* Settings for the analyzer.
|
|
78
|
+
*/
|
|
79
|
+
export declare type AnalyzerSettings = {
|
|
80
|
+
/**
|
|
81
|
+
* Whether to capture a single side or capture both sides
|
|
82
|
+
* of a document with automatic side detection.
|
|
83
|
+
*/
|
|
84
|
+
captureSingleSide: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Whether to return an image of a cropped and perspective-corrected document.
|
|
87
|
+
*/
|
|
88
|
+
returnTransformedDocumentImage: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Configures the capture strategy used to select the best frame.
|
|
91
|
+
*
|
|
92
|
+
* The following values are possible:
|
|
93
|
+
*
|
|
94
|
+
* - `"optimize-for-speed"` - Analysis is faster, but it is possible to
|
|
95
|
+
* capture frames with lower quality
|
|
96
|
+
* - `"optimize-for-quality"` - Analysis is slower in order to capture high
|
|
97
|
+
* quality frames.
|
|
98
|
+
* - `"default"` - Trade-off between quality and speed.
|
|
99
|
+
* - `"single-frame"` - Captures first acceptable frame.
|
|
100
|
+
*/
|
|
101
|
+
captureStrategy: CaptureStrategy;
|
|
102
|
+
/**
|
|
103
|
+
* Enables document capture with a margin defined as the percentage of the
|
|
104
|
+
* dimensions of the framed document.
|
|
105
|
+
*
|
|
106
|
+
* Both margin and document are required to be fully visible on camera frame
|
|
107
|
+
* in order to finish capture.
|
|
108
|
+
*
|
|
109
|
+
* Allowed values are from 0 to 1. (0%-100%)
|
|
110
|
+
*/
|
|
111
|
+
documentFramingMargin: number;
|
|
112
|
+
/**
|
|
113
|
+
* Whether to return an image of the transformed document with applied margin
|
|
114
|
+
* used during document framing.
|
|
115
|
+
*/
|
|
116
|
+
keepMarginOnTransformedDocumentImage: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Parameters for lighting estimation.
|
|
119
|
+
*
|
|
120
|
+
* Thresholds used to classify the frame as too dark.
|
|
121
|
+
*
|
|
122
|
+
* If the calculated lighting score are outside these thresholds, the frame is
|
|
123
|
+
* discarded. Allowed values are from 0 to 1.
|
|
124
|
+
*
|
|
125
|
+
* ```typescript
|
|
126
|
+
* type LightingThresholds = {
|
|
127
|
+
* tooDarkThreshold: number;
|
|
128
|
+
* tooBrightThreshold: number;
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
lightingThresholds: LightingThresholds;
|
|
133
|
+
/**
|
|
134
|
+
* Whether to discard frames with blurred documents.
|
|
135
|
+
*
|
|
136
|
+
* If it is enabled, the capture process is allowed to finish with blur on the
|
|
137
|
+
* document.
|
|
138
|
+
*/
|
|
139
|
+
ignoreBlur: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Whether to discard frames with glare detected on the document.
|
|
142
|
+
*
|
|
143
|
+
* If it is enabled, the capture process is allowed to finish with glare on
|
|
144
|
+
* the document.
|
|
145
|
+
*/
|
|
146
|
+
ignoreGlare: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Defines percentage of the document area that is allowed to be occluded by hand.
|
|
149
|
+
*
|
|
150
|
+
* Allowed values are from 0 to 1.
|
|
151
|
+
*/
|
|
152
|
+
handOcclusionThreshold: number;
|
|
153
|
+
/**
|
|
154
|
+
* Threshold for detecting tilted documents. Frames with documents tilted more
|
|
155
|
+
* than defined by this threshold are discarded.
|
|
156
|
+
*
|
|
157
|
+
* Allowed values are from 0 to 1.
|
|
158
|
+
*/
|
|
159
|
+
tiltThreshold: number;
|
|
160
|
+
/**
|
|
161
|
+
* Required minimum DPI of the captured document on transformed image.
|
|
162
|
+
*
|
|
163
|
+
* Affects how close the document needs to be to the camera in order to get
|
|
164
|
+
* captured.
|
|
165
|
+
*
|
|
166
|
+
* Allowed values are from 150 to 400.
|
|
167
|
+
*/
|
|
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;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export declare type BaltazarRequest = Readonly<{
|
|
179
|
+
licenseId: string;
|
|
180
|
+
licensee: string;
|
|
181
|
+
packageName: string;
|
|
182
|
+
platform: string;
|
|
183
|
+
sdkName: string;
|
|
184
|
+
sdkVersion: string;
|
|
185
|
+
}>;
|
|
186
|
+
|
|
187
|
+
export declare type BaltazarResponseData = {
|
|
188
|
+
[key: string]: string;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
declare type Brand<T, Tbrand extends string> = T & {
|
|
192
|
+
[brand]: Tbrand;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
declare const brand: unique symbol;
|
|
196
|
+
|
|
197
|
+
declare interface CameraDeviceInfo extends Omit<MediaDeviceInfo, "kind"> {
|
|
198
|
+
kind: Extract<MediaDeviceInfo["kind"], "videoinput">;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export declare type CaptureBindings = {
|
|
202
|
+
initializeWithLicenseKey: (licenceKey: string, userId: string, allowHelloMessage: boolean) => LicenseUnlockResult;
|
|
203
|
+
Analyzer: typeof Analyzer;
|
|
204
|
+
submitServerPermission: (serverPermission: StringifiedBaltazarResponse) => ServerPermissionSubmitResult;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export declare type CaptureCallbacks = Partial<{
|
|
208
|
+
/**
|
|
209
|
+
* Will be called on every frame after it has finished processing
|
|
210
|
+
* @param frameResult Detailed information on the frame analysis result {@linkcode FrameAnalysisResult}
|
|
211
|
+
* @param frame {@linkcode ImageData} of the frame. Make sure to copy it as it
|
|
212
|
+
* will be overwritten when the next frame finishes processing.
|
|
213
|
+
*/
|
|
214
|
+
onFrameAnalysis: (frameResult: FrameAnalysisResult, frame: ImageData) => void;
|
|
215
|
+
/**
|
|
216
|
+
* Will be called after the entire recognition process has finished successfully.
|
|
217
|
+
* @param result The result of the recognition process {@linkcode AnalyzerResult}
|
|
218
|
+
*/
|
|
219
|
+
onCaptureResult: (result: AnalyzerResult) => void;
|
|
220
|
+
}>;
|
|
221
|
+
|
|
222
|
+
export declare type CaptureComponent = {
|
|
223
|
+
/** Dismounts the component from the DOM and unloads the SDK */
|
|
224
|
+
dismount: () => void;
|
|
225
|
+
} & ExposedComponentApi;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Singleton that represents the Capture SDK
|
|
229
|
+
*/
|
|
230
|
+
export declare interface CaptureSdk extends _CaptureSdk {
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* The class that represents the Capture SDK.
|
|
235
|
+
* Not exported to prevent manual instantiation.
|
|
236
|
+
* @private
|
|
237
|
+
*/
|
|
238
|
+
declare class _CaptureSdk {
|
|
239
|
+
#private;
|
|
240
|
+
constructor(directApi: DirectApi);
|
|
241
|
+
/**
|
|
242
|
+
* Single-time setup for a video element
|
|
243
|
+
*/
|
|
244
|
+
setupVideoElement(videoElement: HTMLVideoElement): void;
|
|
245
|
+
/**
|
|
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.
|
|
250
|
+
*/
|
|
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>;
|
|
263
|
+
/**
|
|
264
|
+
* Starts the video playback
|
|
265
|
+
*
|
|
266
|
+
* @returns resolves when playback starts
|
|
267
|
+
*/
|
|
268
|
+
startPlayback(): Promise<void>;
|
|
269
|
+
/**
|
|
270
|
+
* Starts a best-effort camera stream on a provided video element
|
|
271
|
+
*/
|
|
272
|
+
startCameraStream(videoElement: HTMLVideoElement, autoplay?: boolean): Promise<void>;
|
|
273
|
+
/**
|
|
274
|
+
* Starts playback and capture.
|
|
275
|
+
*/
|
|
276
|
+
startCapture(): Promise<void>;
|
|
277
|
+
/**
|
|
278
|
+
* Pauses the capture process without resetting the recognizer.
|
|
279
|
+
*/
|
|
280
|
+
pauseCapture(): void;
|
|
281
|
+
/**
|
|
282
|
+
* Cancels the capture process. Unlike {@linkcode pauseCapture}, it also resets
|
|
283
|
+
* the analyzer.
|
|
284
|
+
*/
|
|
285
|
+
cancelCapture(): Promise<void>;
|
|
286
|
+
/**
|
|
287
|
+
* Resets the currently active capturing process.
|
|
288
|
+
*/
|
|
289
|
+
resetCapture(): Promise<void>;
|
|
290
|
+
/**
|
|
291
|
+
* Stops the currently active stream
|
|
292
|
+
*/
|
|
293
|
+
stopStream(): Promise<void>;
|
|
294
|
+
/**
|
|
295
|
+
* Attempts to finish the side capture early.
|
|
296
|
+
*
|
|
297
|
+
* @returns `true` if there are enough captured frames to finish the current
|
|
298
|
+
* side capture, `false` otherwise.
|
|
299
|
+
*/
|
|
300
|
+
finishSideCapture(): Promise<boolean>;
|
|
301
|
+
/**
|
|
302
|
+
* Pauses the video playback. This will also stop the capturing process.
|
|
303
|
+
*/
|
|
304
|
+
pausePlayback(): void;
|
|
305
|
+
/**
|
|
306
|
+
* Set up callbacks on the SDK
|
|
307
|
+
*
|
|
308
|
+
* @param newCallbacks A subset of available
|
|
309
|
+
* {@linkcode CaptureCallbacks}. Will overwrite the previously set one.
|
|
310
|
+
*
|
|
311
|
+
* Send an empty object (`{}`) to clear callbacks.
|
|
312
|
+
*/
|
|
313
|
+
setCallbacks(newCallbacks: CaptureCallbacks): void;
|
|
314
|
+
/**
|
|
315
|
+
* If true, the video and captured frames will be mirrored horizontally.
|
|
316
|
+
*/
|
|
317
|
+
setMirrorX(mirrorX: boolean): void;
|
|
318
|
+
/**
|
|
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}
|
|
322
|
+
*/
|
|
323
|
+
subscribe: {
|
|
324
|
+
(listener: (selectedState: ReactiveStore, previousSelectedState: ReactiveStore) => void): () => void;
|
|
325
|
+
<U>(selector: (state: ReactiveStore) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
326
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
327
|
+
fireImmediately?: boolean | undefined;
|
|
328
|
+
} | undefined): () => void;
|
|
329
|
+
};
|
|
330
|
+
/**
|
|
331
|
+
* Gets the current internal state of the Capture SDK.
|
|
332
|
+
*/
|
|
333
|
+
getState: () => ReactiveStore;
|
|
334
|
+
/**
|
|
335
|
+
* Resets the captureSdk and terminates the workers and the Wasm runtime.
|
|
336
|
+
*/
|
|
337
|
+
destroy(): Promise<void>;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export declare type CaptureSdkSettings = Prettify<DirectApiSettings & {
|
|
341
|
+
/** Optional callbacks */
|
|
342
|
+
callbacks?: CaptureCallbacks;
|
|
343
|
+
}>;
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Document side classification.
|
|
347
|
+
*
|
|
348
|
+
* If side classification was uncertain, `"unknown"` is returned.
|
|
349
|
+
*/
|
|
350
|
+
export declare type CaptureSide = "unknown" | "front" | "back";
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* The capture state.
|
|
354
|
+
*/
|
|
355
|
+
export declare type CaptureState = "side-captured" | "document-captured" | "first-side-capture-in-progress" | "second-side-capture-in-progress";
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Capture strategy used to select the best frame.
|
|
359
|
+
*
|
|
360
|
+
* The following values are possible:
|
|
361
|
+
*
|
|
362
|
+
* - `"optimize-for-speed"` - Analysis is faster, but it is possible to capture
|
|
363
|
+
* frames with lower quality
|
|
364
|
+
* - `"optimize-for-quality"` - Analysis is slower in order to capture high
|
|
365
|
+
* quality frames.
|
|
366
|
+
* - `"default"` - Trade-off for quality and speed.
|
|
367
|
+
* - `"single-frame"` - Captures first acceptable frame.
|
|
368
|
+
*/
|
|
369
|
+
export declare type CaptureStrategy = "optimize-for-speed" | "optimize-for-quality" | "default" | "single-frame";
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Represents all bound properties on the Wasm object
|
|
373
|
+
*/
|
|
374
|
+
export declare type CaptureWasmModule = CaptureBindings & EmscriptenModule;
|
|
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
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Completeness status of capture process.
|
|
410
|
+
*/
|
|
411
|
+
export declare type CompletenessStatus = "empty" | "one-side-missing" | "complete";
|
|
412
|
+
|
|
413
|
+
export declare class ConfiguredCamera {
|
|
414
|
+
#private;
|
|
415
|
+
deviceInfo: CameraDeviceInfo;
|
|
416
|
+
settings: MediaTrackSettings;
|
|
417
|
+
activeStream: MediaStream | null;
|
|
418
|
+
name: string;
|
|
419
|
+
constructor(deviceInfo: CameraDeviceInfo, settings: MediaTrackSettings);
|
|
420
|
+
startStream(): Promise<MediaStream>;
|
|
421
|
+
stopStream(): void;
|
|
422
|
+
getVideoTrack(): MediaStreamTrack | undefined;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Creates a singleton instance of the Capture SDK.
|
|
427
|
+
* @param settings {@linkcode CaptureSdkSettings}
|
|
428
|
+
* @returns A singleton instance of {@linkcode CaptureSdk}
|
|
429
|
+
*/
|
|
430
|
+
export declare function createCaptureSdk(settings: CaptureSdkSettings): Promise<CaptureSdk>;
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Creates the capture UI and loads the SDK
|
|
434
|
+
*
|
|
435
|
+
* @param settings {@linkcode CreateCaptureUiSettings}
|
|
436
|
+
* @returns An object with methods for controlling the Capture SDK and the UI
|
|
437
|
+
* component
|
|
438
|
+
*/
|
|
439
|
+
export declare function createCaptureUi(settings: CreateCaptureUiSettings): Promise<CaptureComponent>;
|
|
440
|
+
|
|
441
|
+
declare type CreateCaptureUiSettings = {
|
|
442
|
+
sdkSettings: CaptureSdkSettings;
|
|
443
|
+
uiSettings?: UiSettings;
|
|
444
|
+
};
|
|
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
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Copyright (c) 2023 Microblink Ltd. All rights reserved.
|
|
457
|
+
*
|
|
458
|
+
* ANY UNAUTHORIZED USE OR SALE, DUPLICATION, OR DISTRIBUTION
|
|
459
|
+
* OF THIS PROGRAM OR ANY OF ITS PARTS, IN SOURCE OR BINARY FORMS,
|
|
460
|
+
* WITH OR WITHOUT MODIFICATION, WITH THE PURPOSE OF ACQUIRING
|
|
461
|
+
* UNLAWFUL MATERIAL OR ANY OTHER BENEFIT IS PROHIBITED!
|
|
462
|
+
* THIS PROGRAM IS PROTECTED BY COPYRIGHT LAWS AND YOU MAY NOT
|
|
463
|
+
* REVERSE ENGINEER, DECOMPILE, OR DISASSEMBLE IT.
|
|
464
|
+
*/
|
|
465
|
+
declare const _default: {
|
|
466
|
+
scan_the_front_side: string;
|
|
467
|
+
flip_document: string;
|
|
468
|
+
scan_the_back_side: string;
|
|
469
|
+
scanning_wrong_side: string;
|
|
470
|
+
move_closer: string;
|
|
471
|
+
move_farther: string;
|
|
472
|
+
camera_angle_too_steep: string;
|
|
473
|
+
document_too_close_to_edge: string;
|
|
474
|
+
rotate_phone_animation: string;
|
|
475
|
+
rotate_phone: string;
|
|
476
|
+
lightning_too_bright: string;
|
|
477
|
+
lightning_too_dark: string;
|
|
478
|
+
blur_detected: string;
|
|
479
|
+
glare_detected: string;
|
|
480
|
+
occluded: string;
|
|
481
|
+
need_help_tooltip: string;
|
|
482
|
+
onboarding_field_visible_title: string;
|
|
483
|
+
onboarding_field_visible_details: string;
|
|
484
|
+
tutorial_fields_visible_title: string;
|
|
485
|
+
tutorial_fields_visible_start: string;
|
|
486
|
+
tutorial_fields_visible_details: string;
|
|
487
|
+
tutorial_harsh_light_title: string;
|
|
488
|
+
tutorial_harsh_light_details: string;
|
|
489
|
+
tutorial_keep_still_title: string;
|
|
490
|
+
tutorial_keep_still_details: string;
|
|
491
|
+
camera_unavailable: string;
|
|
492
|
+
camera_permission_error: string;
|
|
493
|
+
settings: string;
|
|
494
|
+
camera_media_capture_error: string;
|
|
495
|
+
camera_unable_to_resume_session: string;
|
|
496
|
+
camera_query_in_progress: string;
|
|
497
|
+
done: string;
|
|
498
|
+
cancel: string;
|
|
499
|
+
back: string;
|
|
500
|
+
next: string;
|
|
501
|
+
ok: string;
|
|
502
|
+
dismiss: string;
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
/**
|
|
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.
|
|
510
|
+
*/
|
|
511
|
+
export declare interface DirectApi extends _DirectApi {
|
|
512
|
+
}
|
|
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
|
+
*/
|
|
595
|
+
export declare type DocumentBlurStatus = "not-available" | "blur-detected" | "blur-not-detected";
|
|
596
|
+
|
|
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";
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* The document glare status for the current frame.
|
|
604
|
+
*/
|
|
605
|
+
export declare type DocumentGlareStatus = "not-available" | "glare-detected" | "glare-not-detected";
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Document group classification.
|
|
609
|
+
*/
|
|
610
|
+
export declare type DocumentGroup = "unknown" | "dl" | "id" | "passport" | "passport-card" | "visa";
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* The document lighting status for the current frame.
|
|
614
|
+
*/
|
|
615
|
+
export declare type DocumentLightingStatus = "not-available" | "too-bright" | "too-dark" | "normal";
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* The document occlusion status for the current frame.
|
|
619
|
+
*/
|
|
620
|
+
export declare type DocumentOcclusionStatus = "not-available" | "occluded" | "not-occluded";
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Analysis status of the document side for the current frame.
|
|
624
|
+
*/
|
|
625
|
+
export declare type DocumentSideAnalysisStatus = "not-available" | "side-already-captured" | "side-not-captured";
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Copyright (c) 2023 Microblink Ltd. All rights reserved.
|
|
629
|
+
*
|
|
630
|
+
* ANY UNAUTHORIZED USE OR SALE, DUPLICATION, OR DISTRIBUTION
|
|
631
|
+
* OF THIS PROGRAM OR ANY OF ITS PARTS, IN SOURCE OR BINARY FORMS,
|
|
632
|
+
* WITH OR WITHOUT MODIFICATION, WITH THE PURPOSE OF ACQUIRING
|
|
633
|
+
* UNLAWFUL MATERIAL OR ANY OTHER BENEFIT IS PROHIBITED!
|
|
634
|
+
* THIS PROGRAM IS PROTECTED BY COPYRIGHT LAWS AND YOU MAY NOT
|
|
635
|
+
* REVERSE ENGINEER, DECOMPILE, OR DISASSEMBLE IT.
|
|
636
|
+
*/
|
|
637
|
+
/**
|
|
638
|
+
* Specifies an abstract object placed on the WebAssembly heap.
|
|
639
|
+
* Objects placed on the WebAssembly heap are not cleaned up by the
|
|
640
|
+
* garbage collector of the JavaScript engine. The memory used by
|
|
641
|
+
* the object must be cleaned up manually by calling the delete() method.
|
|
642
|
+
*
|
|
643
|
+
* {@link} https://emscripten.org/docs/porting/connecting_cpp_and_javascript/embind.html#memory-management
|
|
644
|
+
*/
|
|
645
|
+
declare abstract class EmbindObject {
|
|
646
|
+
/**
|
|
647
|
+
* Cleans up the object from the WebAssembly heap.
|
|
648
|
+
*/
|
|
649
|
+
delete(): Promise<void>;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
export declare type ExposedComponentApi = {
|
|
653
|
+
/** Can return undefined if called after the SDK has been
|
|
654
|
+
* destroyed
|
|
655
|
+
*/
|
|
656
|
+
captureSdk: CaptureSdk | undefined;
|
|
657
|
+
updateLocalization: SetStoreFunction<LocalizationStrings>;
|
|
658
|
+
};
|
|
659
|
+
|
|
660
|
+
declare class FeedbackParser {
|
|
661
|
+
private timeWindow;
|
|
662
|
+
private decayRate;
|
|
663
|
+
private eventStack;
|
|
664
|
+
private currentUiState;
|
|
665
|
+
private currentStateStartTime;
|
|
666
|
+
reset(): void;
|
|
667
|
+
/**
|
|
668
|
+
* Returns a weighted UI state based on the history
|
|
669
|
+
*/
|
|
670
|
+
getUiState(frameAnalysisResult: FrameAnalysisResult): Readonly<{
|
|
671
|
+
key: UiStateKey;
|
|
672
|
+
reticleType: ReticleType;
|
|
673
|
+
minDuration: number;
|
|
674
|
+
}>;
|
|
675
|
+
/**
|
|
676
|
+
* Returns a requested UI state key based on the latest frame
|
|
677
|
+
*/
|
|
678
|
+
private getUiStateKeyFromResult;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
export declare const feedbackParser: FeedbackParser;
|
|
682
|
+
|
|
683
|
+
declare const finalizer: unique symbol;
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* The return type of `Analyzer.analyze` when an error occurs.
|
|
687
|
+
*/
|
|
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";
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Copyright (c) 2023 Microblink Ltd. All rights reserved.
|
|
699
|
+
*
|
|
700
|
+
* ANY UNAUTHORIZED USE OR SALE, DUPLICATION, OR DISTRIBUTION
|
|
701
|
+
* OF THIS PROGRAM OR ANY OF ITS PARTS, IN SOURCE OR BINARY FORMS,
|
|
702
|
+
* WITH OR WITHOUT MODIFICATION, WITH THE PURPOSE OF ACQUIRING
|
|
703
|
+
* UNLAWFUL MATERIAL OR ANY OTHER BENEFIT IS PROHIBITED!
|
|
704
|
+
* THIS PROGRAM IS PROTECTED BY COPYRIGHT LAWS AND YOU MAY NOT
|
|
705
|
+
* REVERSE ENGINEER, DECOMPILE, OR DISASSEMBLE IT.
|
|
706
|
+
*/
|
|
707
|
+
/**
|
|
708
|
+
* The return type of `Analyzer.analyze`. It contains the current capture state
|
|
709
|
+
* and frame analysis status.
|
|
710
|
+
*/
|
|
711
|
+
export declare type FrameAnalysisResult = {
|
|
712
|
+
captureState: CaptureState;
|
|
713
|
+
frameCaptured: boolean;
|
|
714
|
+
frameAnalysisStatus: FrameAnalysisStatus;
|
|
715
|
+
};
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* The frame analysis status.
|
|
719
|
+
*/
|
|
720
|
+
export declare type FrameAnalysisStatus = {
|
|
721
|
+
sideAnalysisStatus: DocumentSideAnalysisStatus;
|
|
722
|
+
framingStatus: DocumentFramingStatus;
|
|
723
|
+
lightingStatus: DocumentLightingStatus;
|
|
724
|
+
blurStatus: DocumentBlurStatus;
|
|
725
|
+
glareStatus: DocumentGlareStatus;
|
|
726
|
+
occlusionStatus: DocumentOcclusionStatus;
|
|
727
|
+
};
|
|
728
|
+
|
|
729
|
+
export declare const getBase64StringFromDataURL: (dataURL: string) => string;
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* Copyright (c) 2023 Microblink Ltd. All rights reserved.
|
|
733
|
+
*
|
|
734
|
+
* ANY UNAUTHORIZED USE OR SALE, DUPLICATION, OR DISTRIBUTION
|
|
735
|
+
* OF THIS PROGRAM OR ANY OF ITS PARTS, IN SOURCE OR BINARY FORMS,
|
|
736
|
+
* WITH OR WITHOUT MODIFICATION, WITH THE PURPOSE OF ACQUIRING
|
|
737
|
+
* UNLAWFUL MATERIAL OR ANY OTHER BENEFIT IS PROHIBITED!
|
|
738
|
+
* THIS PROGRAM IS PROTECTED BY COPYRIGHT LAWS AND YOU MAY NOT
|
|
739
|
+
* REVERSE ENGINEER, DECOMPILE, OR DISASSEMBLE IT.
|
|
740
|
+
*/
|
|
741
|
+
export declare const imageDataToUrl: (imageData: ImageData) => string;
|
|
742
|
+
|
|
743
|
+
export declare enum LicenseTokenState {
|
|
744
|
+
Invalid = 0,
|
|
745
|
+
RequiresServerPermission = 1,
|
|
746
|
+
Valid = 2
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* Copyright (c) 2023 Microblink Ltd. All rights reserved.
|
|
751
|
+
*
|
|
752
|
+
* ANY UNAUTHORIZED USE OR SALE, DUPLICATION, OR DISTRIBUTION
|
|
753
|
+
* OF THIS PROGRAM OR ANY OF ITS PARTS, IN SOURCE OR BINARY FORMS,
|
|
754
|
+
* WITH OR WITHOUT MODIFICATION, WITH THE PURPOSE OF ACQUIRING
|
|
755
|
+
* UNLAWFUL MATERIAL OR ANY OTHER BENEFIT IS PROHIBITED!
|
|
756
|
+
* THIS PROGRAM IS PROTECTED BY COPYRIGHT LAWS AND YOU MAY NOT
|
|
757
|
+
* REVERSE ENGINEER, DECOMPILE, OR DISASSEMBLE IT.
|
|
758
|
+
*/
|
|
759
|
+
export declare type LicenseUnlockResult = Readonly<{
|
|
760
|
+
isTrial: boolean;
|
|
761
|
+
licenseId: string;
|
|
762
|
+
licensee: string;
|
|
763
|
+
packageName: string;
|
|
764
|
+
sdkName: string;
|
|
765
|
+
sdkVersion: string;
|
|
766
|
+
unlockResult: LicenseTokenState;
|
|
767
|
+
licenseError: string;
|
|
768
|
+
}>;
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* Parameters for lighting estimation.
|
|
772
|
+
*
|
|
773
|
+
* Thresholds used to classify the frame as too dark.
|
|
774
|
+
*
|
|
775
|
+
* If the calculated lighting score are outside these thresholds, the frame is
|
|
776
|
+
* discarded. Allowed values are from 0 to 1.
|
|
777
|
+
*/
|
|
778
|
+
export declare type LightingThresholds = {
|
|
779
|
+
tooDarkThreshold: number;
|
|
780
|
+
tooBrightThreshold: number;
|
|
781
|
+
};
|
|
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
|
+
|
|
799
|
+
declare type LocalizationStrings = typeof _default;
|
|
800
|
+
|
|
801
|
+
/**
|
|
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.
|
|
810
|
+
*/
|
|
811
|
+
declare type LocalObject<T> = {
|
|
812
|
+
[P in keyof T]: LocalProperty<T[P]>;
|
|
813
|
+
};
|
|
814
|
+
|
|
815
|
+
/**
|
|
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>`.
|
|
843
|
+
*/
|
|
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>;
|
|
870
|
+
|
|
871
|
+
export declare type ReactiveStore = {
|
|
872
|
+
/**
|
|
873
|
+
* The video element that is currently being used for capture.
|
|
874
|
+
*/
|
|
875
|
+
videoElement: HTMLVideoElement | null;
|
|
876
|
+
/**
|
|
877
|
+
* The list of cameras that are available to the user.
|
|
878
|
+
*/
|
|
879
|
+
cameras: ConfiguredCamera[];
|
|
880
|
+
/**
|
|
881
|
+
* The currently selected camera.
|
|
882
|
+
*/
|
|
883
|
+
selectedCamera: ConfiguredCamera | null;
|
|
884
|
+
/**
|
|
885
|
+
* The callbacks that are used to communicate with the capture sdk.
|
|
886
|
+
*/
|
|
887
|
+
callbacks: CaptureCallbacks;
|
|
888
|
+
/**
|
|
889
|
+
* Whether the camera stream is currently active and playing back on the video
|
|
890
|
+
* element.
|
|
891
|
+
*/
|
|
892
|
+
isPlaying: boolean;
|
|
893
|
+
/**
|
|
894
|
+
* Whether the active video stream is currently being captured and processed
|
|
895
|
+
* by the Analyzer.
|
|
896
|
+
*/
|
|
897
|
+
isCapturing: boolean;
|
|
898
|
+
/**
|
|
899
|
+
* Whether the camera is currently being swapped.
|
|
900
|
+
*/
|
|
901
|
+
isSwappingCamera: boolean;
|
|
902
|
+
/**
|
|
903
|
+
* Whether the camera list is currently being queried.
|
|
904
|
+
*/
|
|
905
|
+
isQueryingCameras: boolean;
|
|
906
|
+
/**
|
|
907
|
+
* The analyzer settings that are currently being used.
|
|
908
|
+
*/
|
|
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
|
+
*/
|
|
918
|
+
uiState: UiState;
|
|
919
|
+
/**
|
|
920
|
+
* Whether the capture requires landscape mode.
|
|
921
|
+
*/
|
|
922
|
+
captureRequiresLandscape: boolean;
|
|
923
|
+
/**
|
|
924
|
+
* Whether the SDK has been initialized.
|
|
925
|
+
*/
|
|
926
|
+
initialized: boolean;
|
|
927
|
+
/**
|
|
928
|
+
* If the SDK has encountered an error, this will be set to the error.
|
|
929
|
+
*/
|
|
930
|
+
errorState: Error | null;
|
|
931
|
+
};
|
|
932
|
+
|
|
933
|
+
declare const releaseProxy: unique symbol;
|
|
934
|
+
|
|
935
|
+
/**
|
|
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()`.
|
|
938
|
+
*/
|
|
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;
|
|
948
|
+
|
|
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
|
+
};
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Takes the raw type of a remote property and returns the type that is visible to the local thread on the proxy.
|
|
963
|
+
*
|
|
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
|
|
966
|
+
*/
|
|
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";
|
|
976
|
+
|
|
977
|
+
export declare type ServerPermissionSubmitResult = Readonly<{
|
|
978
|
+
status: ServerPermissionSubmitResultStatus;
|
|
979
|
+
lease: number;
|
|
980
|
+
networkErrorDescription?: string;
|
|
981
|
+
}>;
|
|
982
|
+
|
|
983
|
+
export declare enum ServerPermissionSubmitResultStatus {
|
|
984
|
+
Ok = 0,
|
|
985
|
+
NetworkError = 1,
|
|
986
|
+
RemoteLock = 2,
|
|
987
|
+
PermissionExpired = 3,
|
|
988
|
+
PayloadCorrupted = 4,
|
|
989
|
+
PayloadSignatureVerificationFailed = 5,
|
|
990
|
+
IncorrectTokenState = 6
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
declare type SetStateInternal<T> = {
|
|
994
|
+
_(partial: T | Partial<T> | {
|
|
995
|
+
_(state: T): T | Partial<T>;
|
|
996
|
+
}['_'], replace?: boolean | undefined): void;
|
|
997
|
+
}['_'];
|
|
998
|
+
|
|
999
|
+
/**
|
|
1000
|
+
* Capture result of a single document side.
|
|
1001
|
+
*/
|
|
1002
|
+
export declare type SideCaptureResult = {
|
|
1003
|
+
/**
|
|
1004
|
+
* Original image of the captured document side, untransformed, as it was used
|
|
1005
|
+
* in the analysis.
|
|
1006
|
+
*/
|
|
1007
|
+
imageResult: ImageData;
|
|
1008
|
+
/**
|
|
1009
|
+
* Image of the cropped and perspective-corrected document. The transformed
|
|
1010
|
+
* image is returned in the correct orientation.
|
|
1011
|
+
*/
|
|
1012
|
+
transformedImageResult: ImageData | null;
|
|
1013
|
+
/**
|
|
1014
|
+
* Document side classification.
|
|
1015
|
+
*
|
|
1016
|
+
* If the side classification was uncertain, `"unknown"` is returned.
|
|
1017
|
+
*/
|
|
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;
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
declare interface StoreApi<T> {
|
|
1027
|
+
setState: SetStateInternal<T>;
|
|
1028
|
+
getState: () => T;
|
|
1029
|
+
subscribe: (listener: (state: T, prevState: T) => void) => () => void;
|
|
1030
|
+
/**
|
|
1031
|
+
* @deprecated Use `unsubscribe` returned by `subscribe`
|
|
1032
|
+
*/
|
|
1033
|
+
destroy: () => void;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
/**
|
|
1037
|
+
* Branded type for type safety. Requires casting where required.
|
|
1038
|
+
*/
|
|
1039
|
+
export declare type StringifiedBaltazarResponse = Brand<string, "StringifiedBaltazarResponse">;
|
|
1040
|
+
|
|
1041
|
+
declare type UiSettings = {
|
|
1042
|
+
/** Target DOM node where you want the UI component to mount.
|
|
1043
|
+
*
|
|
1044
|
+
* If not provided, the component will be portalled in the document root,
|
|
1045
|
+
* taking up the entire screen.
|
|
1046
|
+
*/
|
|
1047
|
+
target?: MountableElement;
|
|
1048
|
+
/** If `true`, an onboarding screen will be visible once the video feed starts.
|
|
1049
|
+
*
|
|
1050
|
+
* @default `true`
|
|
1051
|
+
* */
|
|
1052
|
+
showTutorial?: boolean;
|
|
1053
|
+
/** If `true`, errors thrown in the SDK will be shown in a dialog.
|
|
1054
|
+
*
|
|
1055
|
+
* @default `true`
|
|
1056
|
+
* */
|
|
1057
|
+
showErrorDialog?: boolean;
|
|
1058
|
+
/**
|
|
1059
|
+
* User provided localization keys
|
|
1060
|
+
*/
|
|
1061
|
+
localization?: Partial<Record<keyof LocalizationStrings, string>>;
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
export declare type UiState = Readonly<{
|
|
1065
|
+
key: UiStateKey;
|
|
1066
|
+
reticleType: ReticleType;
|
|
1067
|
+
minDuration: number;
|
|
1068
|
+
}>;
|
|
1069
|
+
|
|
1070
|
+
export declare type UiStateEvent = {
|
|
1071
|
+
stateKey: Readonly<UiStateKey>;
|
|
1072
|
+
timeStamp: Readonly<DOMHighResTimeStamp>;
|
|
1073
|
+
currentWeight: number;
|
|
1074
|
+
};
|
|
1075
|
+
|
|
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";
|
|
1077
|
+
|
|
1078
|
+
export declare const uiStateMap: Readonly<Record<UiStateKey, UiState>>;
|
|
1079
|
+
|
|
1080
|
+
/**
|
|
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>`.
|
|
1085
|
+
*/
|
|
1086
|
+
declare type Unpromisify<P> = P extends Promise<infer T> ? T : P;
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* Inverse of `ProxyOrClone<T>`.
|
|
1090
|
+
*/
|
|
1091
|
+
declare type UnproxyOrClone<T> = T extends RemoteObject<ProxyMarked> ? Local<T> : T;
|
|
1092
|
+
|
|
1093
|
+
/**
|
|
1094
|
+
* ⚠️ DANGER AHEAD ⚠️
|
|
1095
|
+
*
|
|
1096
|
+
* The Zustand store. Use only if you know what you're doing.
|
|
1097
|
+
*
|
|
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.
|
|
1100
|
+
*
|
|
1101
|
+
* Prefer using subscriptions if you require observable state.
|
|
1102
|
+
*
|
|
1103
|
+
* {@link https://github.com/pmndrs/zustand}
|
|
1104
|
+
*/
|
|
1105
|
+
export declare const zustandStore: Omit<StoreApi<ReactiveStore>, "subscribe"> & {
|
|
1106
|
+
subscribe: {
|
|
1107
|
+
(listener: (selectedState: ReactiveStore, previousSelectedState: ReactiveStore) => void): () => void;
|
|
1108
|
+
<U>(selector: (state: ReactiveStore) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
1109
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
1110
|
+
fireImmediately?: boolean | undefined;
|
|
1111
|
+
} | undefined): () => void;
|
|
1112
|
+
};
|
|
1113
|
+
};
|
|
1114
|
+
|
|
1115
|
+
export { }
|