@microblink/blinkid-ux-manager 7.0.0-next.4 → 7.0.0-next.7

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 ADDED
@@ -0,0 +1,9 @@
1
+ # BlinkID UX Manager
2
+
3
+ `@microblink/blinkid-ux-manager` parses the results from `@microblink/blinkid-core` and guides the user through the scanning process.
4
+
5
+ It also controls `@microblink/camera-manager` when it's required during the scanning process.
6
+
7
+ This package provides a headless component and a UI component which is the feedback overlay used in the camera manager component.
8
+
9
+ For details, check out the documentation at https://github.com/BlinkID/blinkid-next-web
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@microblink/blinkid-ux-manager",
3
- "version": "7.0.0-next.4",
4
- "author": "",
3
+ "version": "7.0.0-next.7",
4
+ "author": "Microblink",
5
5
  "type": "module",
6
6
  "main": "./dist/blinkid-ux-manager.js",
7
7
  "module": "./dist/blinkid-ux-manager.js",
@@ -11,12 +11,17 @@
11
11
  "types"
12
12
  ],
13
13
  "dependencies": {
14
- "@microblink/blinkid-core": "^7.0.0-next.4",
15
- "@microblink/camera-manager": "^7.0.0-next.4"
14
+ "@microblink/blinkid-core": "^7.0.0-next.7",
15
+ "@microblink/camera-manager": "^7.0.0-next.7"
16
16
  },
17
17
  "access": "public",
18
18
  "registry": "https://registry.npmjs.org/",
19
19
  "types": "./types/index.rollup.d.ts",
20
+ "homepage": "https://github.com/BlinkID/blinkid-next-web",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/BlinkID/blinkid-next-web.git"
24
+ },
20
25
  "exports": {
21
26
  ".": {
22
27
  "types": "./types/index.rollup.d.ts",
@@ -0,0 +1,219 @@
1
+ import { BlinkIdCore } from '@microblink/blinkid-core';
2
+ import { BlinkIdResult } from '@microblink/blinkid-core';
3
+ import type { CameraManager } from '@microblink/camera-manager';
4
+ import { CameraManagerComponent } from '@microblink/camera-manager';
5
+ import { FrameAnalysisResult } from '@microblink/blinkid-core';
6
+
7
+ /**
8
+ * Copyright (c) 2025 Microblink Ltd. All rights reserved.
9
+ */
10
+ /**
11
+ * BlinkID processing error. These errors are usually unrecoverable and require
12
+ * the user to retry the scanning process.
13
+ */
14
+ export declare type BlinkIdProcessingError = "timeout" | "unsupported-document" | "unknown";
15
+
16
+ export declare type BlinkIdReticleType = "searching" | "processing" | "error" | "done" | "flip";
17
+
18
+ export declare type BlinkIdUiState = BlinkIdUiStateMap[keyof BlinkIdUiStateMap];
19
+
20
+ export declare type BlinkIdUiStateKey = "PROCESSING" | "SIDE_CAPTURED" | "DOCUMENT_CAPTURED" | "SENSING_FRONT" | "SENSING_BACK" | "LOW_QUALITY_FRONT" | "LOW_QUALITY_BACK" | "DOCUMENT_FRAMING_CAMERA_TOO_FAR" | "DOCUMENT_FRAMING_CAMERA_TOO_CLOSE" | "DOCUMENT_FRAMING_CAMERA_ANGLE_TOO_STEEP" | "DOCUMENT_TOO_CLOSE_TO_FRAME_EDGE" | "BLUR_DETECTED" | "GLARE_DETECTED" | "OCCLUDED" | "SCAN_BARCODE" | "WRONG_SIDE";
21
+
22
+ /**
23
+ * Extended UI state for BlinkID.
24
+ */
25
+ export declare type BlinkIdUiStateMap = {
26
+ [K in BlinkIdUiStateKey]: UiState & {
27
+ key: K;
28
+ reticleType: BlinkIdReticleType;
29
+ };
30
+ };
31
+
32
+ export declare const blinkIdUiStateMap: BlinkIdUiStateMap;
33
+
34
+ /**
35
+ * Manages the UX of the BlinkID SDK.
36
+ */
37
+ export declare class BlinkIdUxManager {
38
+ #private;
39
+ cameraManager: CameraManager;
40
+ blinkIdCore: BlinkIdCore;
41
+ uiState: BlinkIdUiState;
42
+ errorState?: BlinkIdProcessingError;
43
+ rawUiStateKey: BlinkIdUiStateKey;
44
+ feedbackStabilizer: FeedbackStabilizer<typeof blinkIdUiStateMap>;
45
+ clearScanTimeout: () => void;
46
+ /**
47
+ * Adds a callback function to be executed when the UI state changes.
48
+ * @param callback - Function to be called when UI state changes. Receives the new UI state as parameter.
49
+ * @returns A cleanup function that removes the callback when called.
50
+ * @example
51
+ * const cleanup = manager.addOnUiStateChangedCallback((newState) => {
52
+ * console.log('UI state changed to:', newState);
53
+ * });
54
+ *
55
+ * cleanup();
56
+ */
57
+ addOnUiStateChangedCallback(callback: (uiState: BlinkIdUiState) => void): () => void;
58
+ /**
59
+ * Registers a callback function to be called when a scan result is available.
60
+ * @param callback - A function that will be called with the scan result.
61
+ * @returns A cleanup function that, when called, will remove the registered callback.
62
+ *
63
+ * @example
64
+ *
65
+ * const cleanup = manager.addOnResultCallback((result) => {
66
+ * console.log('Scan result:', result);
67
+ * });
68
+ *
69
+ * // Later, to remove the callback:
70
+ * cleanup();
71
+ */
72
+ addOnResultCallback(callback: (result: BlinkIdResult) => void): () => void;
73
+ /**
74
+ * Registers a callback function to be called when a frame is processed.
75
+ * @param callback - A function that will be called with the frame analysis result.
76
+ * @returns A cleanup function that, when called, will remove the registered callback.
77
+ *
78
+ * @example
79
+ * const cleanup = manager.addOnFrameProcessCallback((frameResult) => {
80
+ * console.log('Frame processed:', frameResult);
81
+ * });
82
+ *
83
+ * // Later, to remove the callback:
84
+ * cleanup();
85
+ */
86
+ addOnFrameProcessCallback(callback: (frameResult: FrameAnalysisResult) => void): () => void;
87
+ /**
88
+ * Registers a callback function to be called when an error occurs during processing.
89
+ * @param callback - A function that will be called with the error state.
90
+ * @returns A cleanup function that, when called, will remove the registered callback.
91
+ *
92
+ * @example
93
+ * const cleanup = manager.addOnErrorCallback((error) => {
94
+ * console.error('Processing error:', error);
95
+ * });
96
+ *
97
+ * // Later, to remove the callback:
98
+ * cleanup();
99
+ */
100
+ addOnErrorCallback(callback: (errorState: BlinkIdProcessingError) => void): () => void;
101
+ /**
102
+ * Registers a callback function to be called when the user cancels the scanning process.
103
+ * @param callback - A function that will be called with the cancellation reason.
104
+ * @returns A cleanup function that, when called, will remove the registered callback.
105
+ *
106
+ * @example
107
+ * const cleanup = manager.addOnUserCancelCallback((reason) => {
108
+ * console.log('User cancelled scan:', reason);
109
+ * });
110
+ *
111
+ * // Later, to remove the callback:
112
+ * cleanup();
113
+ */
114
+ addOnUserCancelCallback(callback: (reason: unknown) => void): () => void;
115
+ constructor(cameraManager: CameraManager, blinkIdCore: BlinkIdCore);
116
+ /**
117
+ * Set the duration of the timeout in milliseconds.
118
+ */
119
+ setTimeoutDuration(duration: number): void;
120
+ handleUiStateChange(uiState: BlinkIdUiState): Promise<void>;
121
+ }
122
+
123
+ export declare function createBlinkIdFeedbackUi(blinkIdUxManager: BlinkIdUxManager, cameraManagerComponent: CameraManagerComponent, options?: FeedbackUiOptions): () => void;
124
+
125
+ /**
126
+ * Copyright (c) 2025 Microblink Ltd. All rights reserved.
127
+ */
128
+ declare const _default: {
129
+ readonly scan_the_front_side: "Scan the front side of the document";
130
+ readonly flip_document: "Flip the document";
131
+ readonly scan_the_back_side: "Scan the back side of the document";
132
+ readonly scan_the_barcode: "Scan the barcode";
133
+ readonly scanning_wrong_side: "Scanning wrong side";
134
+ readonly move_closer: "Move closer";
135
+ readonly move_farther: "Move farther";
136
+ readonly camera_angle_too_steep: "Keep document parallel to phone";
137
+ readonly document_too_close_to_edge: "Move farther";
138
+ readonly blur_detected: "Keep document and phone still";
139
+ readonly glare_detected: "Tilt or move document to remove reflection";
140
+ readonly occluded: "Keep the document fully visible";
141
+ };
142
+
143
+ export declare class FeedbackStabilizer<SdkSpecificStateMap extends UiStateMap> {
144
+ private initialKey;
145
+ private uiStateMap;
146
+ private timeWindow;
147
+ private decayRate;
148
+ private eventQueue;
149
+ /** this is a special queue as min duration of the event can be longer than the `timeWindow` */
150
+ private singleEventQueue;
151
+ private currentKey;
152
+ private currentStateStartTime;
153
+ private summedScores;
154
+ private scoreBoard;
155
+ get currentState(): SdkSpecificStateMap[`${Extract<keyof SdkSpecificStateMap, string | number>}`];
156
+ getEventQueue(): UiStateEvent[];
157
+ getScores(): Record<string, number>;
158
+ getScoreBoard(): Record<string, number[]>;
159
+ setTimeWindow(timeWindow: number): void;
160
+ constructor(uiStateMap: SdkSpecificStateMap, initialKey: StringKeyOf<SdkSpecificStateMap>, timeWindow?: number, decayRate?: number);
161
+ reset(): void;
162
+ canShowNewUiState: () => boolean;
163
+ /**
164
+ * Returns a weighted UI state based on the history
165
+ */
166
+ getNewUiState(incomingUiStateKey: StringKeyOf<SdkSpecificStateMap>): SdkSpecificStateMap[StringKeyOf<SdkSpecificStateMap>];
167
+ }
168
+
169
+ export declare type FeedbackUiOptions = {
170
+ localizationStrings?: Partial<LocalizationStrings>;
171
+ /**
172
+ * If set to `true`, the BlinkID instance will not be terminated when the
173
+ * feedback UI is unmounted.
174
+ *
175
+ * @defaultValue false
176
+ */
177
+ preserveSdkInstance?: boolean;
178
+ };
179
+
180
+ /**
181
+ * Used temporarily as processing status was added after the tests were written
182
+ */
183
+ export declare type FrameAnalysisResultWithoutProcessingStatus = Omit<FrameAnalysisResult, "processingStatus">;
184
+
185
+ export declare function getUiStateKeyFromFrameResult(frameAnalysisResult: FrameAnalysisResultWithoutProcessingStatus): BlinkIdUiStateKey;
186
+
187
+ export declare type LocaleRecord = typeof _default;
188
+
189
+ export declare type LocalizationStrings = {
190
+ [K in keyof LocaleRecord]: LocaleRecord[K] | (string & {});
191
+ };
192
+
193
+ declare type StringKeyOf<BaseType> = `${Extract<keyof BaseType, string | number>}`;
194
+
195
+ export declare type UiState = {
196
+ key: string;
197
+ minDuration: number;
198
+ /**
199
+ * If true, the event will be emmited once the previous event is done.
200
+ * It's not going through the averaging process
201
+ */
202
+ singleEmit?: boolean;
203
+ initialWeight?: number;
204
+ };
205
+
206
+ export declare type UiStateEvent = {
207
+ key: string;
208
+ timeStamp: DOMHighResTimeStamp;
209
+ currentWeight: number;
210
+ /**
211
+ * If true, the event will be emmited once the previous event is done.
212
+ * It's not going through the averaging process
213
+ */
214
+ singleEmit?: boolean;
215
+ };
216
+
217
+ export declare type UiStateMap = Record<string, UiState>;
218
+
219
+ export { }