@microblink/blinkid-ux-manager 7.7.4 → 8000.0.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.
Files changed (160) hide show
  1. package/README.md +182 -4
  2. package/dist/blinkid-ux-manager.js +2147 -1820
  3. package/package.json +2 -2
  4. package/types/core/BlinkIdTimeoutConfiguration.d.ts +31 -0
  5. package/types/core/BlinkIdTimeoutConfiguration.d.ts.map +1 -0
  6. package/types/core/BlinkIdUxManager.d.ts +84 -58
  7. package/types/core/BlinkIdUxManager.d.ts.map +1 -1
  8. package/types/core/BlinkIdUxManager.session-status.test.d.ts +5 -0
  9. package/types/core/BlinkIdUxManager.session-status.test.d.ts.map +1 -0
  10. package/types/core/BlinkIdUxManager.timeout.test.d.ts +5 -0
  11. package/types/core/BlinkIdUxManager.timeout.test.d.ts.map +1 -0
  12. package/types/core/__testdata/blinkidTestFixtures.d.ts +1 -4
  13. package/types/core/__testdata/blinkidTestFixtures.d.ts.map +1 -1
  14. package/types/core/blinkid-ui-state.d.ts +4 -9
  15. package/types/core/blinkid-ui-state.d.ts.map +1 -1
  16. package/types/core/createBlinkIdUxManager.d.ts +8 -0
  17. package/types/core/createBlinkIdUxManager.d.ts.map +1 -1
  18. package/types/core/extractionMode.d.ts +41 -0
  19. package/types/core/extractionMode.d.ts.map +1 -0
  20. package/types/core/extractionMode.test.d.ts +5 -0
  21. package/types/core/extractionMode.test.d.ts.map +1 -0
  22. package/types/core/test-helpers.integration.d.ts +3 -3
  23. package/types/core/test-helpers.integration.d.ts.map +1 -1
  24. package/types/core/test-utils.d.ts +14 -0
  25. package/types/core/test-utils.d.ts.map +1 -0
  26. package/types/core/ui-state-utils.d.ts +2 -1
  27. package/types/core/ui-state-utils.d.ts.map +1 -1
  28. package/types/index.d.ts +3 -2
  29. package/types/index.d.ts.map +1 -1
  30. package/types/index.rollup.d.ts +315 -143
  31. package/types/ui/BlinkIdFeedbackUi.d.ts +2 -2
  32. package/types/ui/BlinkIdFeedbackUi.d.ts.map +1 -1
  33. package/types/ui/LocalizationContext.d.ts +22 -4
  34. package/types/ui/LocalizationContext.d.ts.map +1 -1
  35. package/types/ui/UiFeedbackOverlay.d.ts +2 -0
  36. package/types/ui/UiFeedbackOverlay.d.ts.map +1 -1
  37. package/types/ui/createBlinkIdFeedbackUi.d.ts +3 -14
  38. package/types/ui/createBlinkIdFeedbackUi.d.ts.map +1 -1
  39. package/types/ui/dialogs/HelpModal.d.ts +43 -0
  40. package/types/ui/dialogs/HelpModal.d.ts.map +1 -1
  41. package/types/ui/dialogs/OnboardingGuideModal.d.ts +25 -0
  42. package/types/ui/dialogs/OnboardingGuideModal.d.ts.map +1 -1
  43. package/types/ui/dialogs/modalExtractionMode.d.ts +7 -0
  44. package/types/ui/dialogs/modalExtractionMode.d.ts.map +1 -0
  45. package/types/ui/dialogs/modalExtractionMode.test.d.ts +5 -0
  46. package/types/ui/dialogs/modalExtractionMode.test.d.ts.map +1 -0
  47. package/types/ui/feedbackMessages.d.ts +2 -1
  48. package/types/ui/feedbackMessages.d.ts.map +1 -1
  49. package/types/ui/locales/ak.d.ts +156 -61
  50. package/types/ui/locales/ak.d.ts.map +1 -1
  51. package/types/ui/locales/am.d.ts +156 -61
  52. package/types/ui/locales/am.d.ts.map +1 -1
  53. package/types/ui/locales/ar.d.ts +156 -61
  54. package/types/ui/locales/ar.d.ts.map +1 -1
  55. package/types/ui/locales/bn.d.ts +156 -61
  56. package/types/ui/locales/bn.d.ts.map +1 -1
  57. package/types/ui/locales/cs.d.ts +156 -61
  58. package/types/ui/locales/cs.d.ts.map +1 -1
  59. package/types/ui/locales/da.d.ts +156 -61
  60. package/types/ui/locales/da.d.ts.map +1 -1
  61. package/types/ui/locales/de.d.ts +156 -61
  62. package/types/ui/locales/de.d.ts.map +1 -1
  63. package/types/ui/locales/el.d.ts +156 -61
  64. package/types/ui/locales/el.d.ts.map +1 -1
  65. package/types/ui/locales/en.d.ts +156 -61
  66. package/types/ui/locales/en.d.ts.map +1 -1
  67. package/types/ui/locales/en_GB.d.ts +156 -61
  68. package/types/ui/locales/en_GB.d.ts.map +1 -1
  69. package/types/ui/locales/es.d.ts +156 -61
  70. package/types/ui/locales/es.d.ts.map +1 -1
  71. package/types/ui/locales/es_MX.d.ts +156 -61
  72. package/types/ui/locales/es_MX.d.ts.map +1 -1
  73. package/types/ui/locales/fa-latn.d.ts +156 -61
  74. package/types/ui/locales/fa-latn.d.ts.map +1 -1
  75. package/types/ui/locales/fi.d.ts +156 -61
  76. package/types/ui/locales/fi.d.ts.map +1 -1
  77. package/types/ui/locales/fil.d.ts +156 -61
  78. package/types/ui/locales/fil.d.ts.map +1 -1
  79. package/types/ui/locales/fr.d.ts +156 -61
  80. package/types/ui/locales/fr.d.ts.map +1 -1
  81. package/types/ui/locales/fr_CA.d.ts +156 -61
  82. package/types/ui/locales/fr_CA.d.ts.map +1 -1
  83. package/types/ui/locales/ha.d.ts +156 -61
  84. package/types/ui/locales/ha.d.ts.map +1 -1
  85. package/types/ui/locales/he.d.ts +156 -61
  86. package/types/ui/locales/he.d.ts.map +1 -1
  87. package/types/ui/locales/hi.d.ts +156 -61
  88. package/types/ui/locales/hi.d.ts.map +1 -1
  89. package/types/ui/locales/hr.d.ts +156 -61
  90. package/types/ui/locales/hr.d.ts.map +1 -1
  91. package/types/ui/locales/hu.d.ts +156 -61
  92. package/types/ui/locales/hu.d.ts.map +1 -1
  93. package/types/ui/locales/id.d.ts +156 -61
  94. package/types/ui/locales/id.d.ts.map +1 -1
  95. package/types/ui/locales/is.d.ts +156 -61
  96. package/types/ui/locales/is.d.ts.map +1 -1
  97. package/types/ui/locales/it.d.ts +156 -61
  98. package/types/ui/locales/it.d.ts.map +1 -1
  99. package/types/ui/locales/ja.d.ts +156 -61
  100. package/types/ui/locales/ja.d.ts.map +1 -1
  101. package/types/ui/locales/ka_GE.d.ts +156 -61
  102. package/types/ui/locales/ka_GE.d.ts.map +1 -1
  103. package/types/ui/locales/kk.d.ts +156 -61
  104. package/types/ui/locales/kk.d.ts.map +1 -1
  105. package/types/ui/locales/km_KH.d.ts +156 -61
  106. package/types/ui/locales/km_KH.d.ts.map +1 -1
  107. package/types/ui/locales/ko.d.ts +156 -61
  108. package/types/ui/locales/ko.d.ts.map +1 -1
  109. package/types/ui/locales/lv.d.ts +156 -61
  110. package/types/ui/locales/lv.d.ts.map +1 -1
  111. package/types/ui/locales/ms.d.ts +156 -61
  112. package/types/ui/locales/ms.d.ts.map +1 -1
  113. package/types/ui/locales/ne.d.ts +156 -61
  114. package/types/ui/locales/ne.d.ts.map +1 -1
  115. package/types/ui/locales/nl.d.ts +156 -61
  116. package/types/ui/locales/nl.d.ts.map +1 -1
  117. package/types/ui/locales/no.d.ts +156 -61
  118. package/types/ui/locales/no.d.ts.map +1 -1
  119. package/types/ui/locales/pl.d.ts +156 -61
  120. package/types/ui/locales/pl.d.ts.map +1 -1
  121. package/types/ui/locales/ps_AF.d.ts +156 -61
  122. package/types/ui/locales/ps_AF.d.ts.map +1 -1
  123. package/types/ui/locales/pt.d.ts +156 -61
  124. package/types/ui/locales/pt.d.ts.map +1 -1
  125. package/types/ui/locales/pt_BR.d.ts +156 -61
  126. package/types/ui/locales/pt_BR.d.ts.map +1 -1
  127. package/types/ui/locales/ro.d.ts +156 -61
  128. package/types/ui/locales/ro.d.ts.map +1 -1
  129. package/types/ui/locales/ru.d.ts +156 -61
  130. package/types/ui/locales/ru.d.ts.map +1 -1
  131. package/types/ui/locales/si.d.ts +156 -61
  132. package/types/ui/locales/si.d.ts.map +1 -1
  133. package/types/ui/locales/sk.d.ts +156 -61
  134. package/types/ui/locales/sk.d.ts.map +1 -1
  135. package/types/ui/locales/sl.d.ts +156 -61
  136. package/types/ui/locales/sl.d.ts.map +1 -1
  137. package/types/ui/locales/sr.d.ts +156 -61
  138. package/types/ui/locales/sr.d.ts.map +1 -1
  139. package/types/ui/locales/sv.d.ts +156 -61
  140. package/types/ui/locales/sv.d.ts.map +1 -1
  141. package/types/ui/locales/sw.d.ts +156 -61
  142. package/types/ui/locales/sw.d.ts.map +1 -1
  143. package/types/ui/locales/th.d.ts +156 -61
  144. package/types/ui/locales/th.d.ts.map +1 -1
  145. package/types/ui/locales/tr.d.ts +156 -61
  146. package/types/ui/locales/tr.d.ts.map +1 -1
  147. package/types/ui/locales/uk.d.ts +156 -61
  148. package/types/ui/locales/uk.d.ts.map +1 -1
  149. package/types/ui/locales/ur.d.ts +156 -61
  150. package/types/ui/locales/ur.d.ts.map +1 -1
  151. package/types/ui/locales/uz.d.ts +156 -61
  152. package/types/ui/locales/uz.d.ts.map +1 -1
  153. package/types/ui/locales/vi.d.ts +156 -61
  154. package/types/ui/locales/vi.d.ts.map +1 -1
  155. package/types/ui/locales/yo.d.ts +156 -61
  156. package/types/ui/locales/yo.d.ts.map +1 -1
  157. package/types/ui/locales/zh_CN.d.ts +156 -61
  158. package/types/ui/locales/zh_CN.d.ts.map +1 -1
  159. package/types/ui/locales/zh_TW.d.ts +156 -61
  160. package/types/ui/locales/zh_TW.d.ts.map +1 -1
package/README.md CHANGED
@@ -9,6 +9,7 @@ This package provides user experience management and feedback UI for the BlinkID
9
9
  - **Haptic Feedback:** Built-in haptic feedback support for enhanced user experience on mobile devices
10
10
  - **Document Filtering:** Advanced document class filtering capabilities
11
11
  - **Timeout Management:** Configurable scanning timeouts with automatic state management
12
+ - **Progress Callbacks:** Live progress snapshots for debug overlays and custom tooling
12
13
  - **Localization Support:** Multi-language support with customizable strings
13
14
  - **Explicit Teardown:** `destroy()` method for deterministic resource cleanup
14
15
  - **UI State Inspection:** `uiStateKey` (stabilized, visible state) and `mappedUiStateKey` (latest raw candidate before stabilization) getters
@@ -20,6 +21,10 @@ This package provides user experience management and feedback UI for the BlinkID
20
21
  - Includes haptic feedback system for mobile devices.
21
22
  - Used by [`@microblink/blinkid`](https://www.npmjs.com/package/@microblink/blinkid) and can be used directly for custom UI integrations.
22
23
 
24
+ ## Migration from v7 to v8000
25
+
26
+ For breaking changes and upgrade steps, see the [BlinkID v8000 migration guide](https://docs.microblink.com/blinkid/migration-v8000).
27
+
23
28
  ## Installation
24
29
 
25
30
  Install from npm using your preferred package manager:
@@ -104,6 +109,133 @@ const uxManager = await createBlinkIdUxManager(cameraManager, scanningSession);
104
109
  uxManager.destroy();
105
110
  ```
106
111
 
112
+ ### Configuring Scan Timeouts
113
+
114
+ BlinkID uses three timeout windows during capture:
115
+
116
+ - `inactivityTimeoutMs` restarts when the stabilized BlinkID UI state changes
117
+ - `scanStepTimeoutMs` limits the total active capture time for the current scan step
118
+ - `partiallySupportedBarcodeResolveTimeoutMs` resolves a barcode step after BlinkID reports a barcode whose parsing is not supported
119
+
120
+ When the stabilized UI state is `PROCESSING_BARCODE` (the visible "scan the
121
+ barcode" step), BlinkID suppresses the inactivity timeout and starts that
122
+ barcode step with a fresh `scanStepTimeoutMs` window.
123
+
124
+ You can override them when creating the manager:
125
+
126
+ ```javascript
127
+ const uxManager = await createBlinkIdUxManager(cameraManager, scanningSession, {
128
+ timeoutConfiguration: {
129
+ inactivityTimeoutMs: 15000,
130
+ scanStepTimeoutMs: 90000,
131
+ partiallySupportedBarcodeResolveTimeoutMs: 8000,
132
+ },
133
+ });
134
+ ```
135
+
136
+ Set any timeout to `null` to disable it:
137
+
138
+ ```javascript
139
+ const uxManager = await createBlinkIdUxManager(cameraManager, scanningSession, {
140
+ timeoutConfiguration: {
141
+ inactivityTimeoutMs: null,
142
+ scanStepTimeoutMs: 90000,
143
+ partiallySupportedBarcodeResolveTimeoutMs: null,
144
+ },
145
+ });
146
+ ```
147
+
148
+ You can also inspect or update the active configuration later:
149
+
150
+ ```javascript
151
+ uxManager.getTimeoutConfiguration();
152
+ uxManager.setTimeoutConfiguration({
153
+ inactivityTimeoutMs: 20000,
154
+ });
155
+ ```
156
+
157
+ ### Observing Processed Frames
158
+
159
+ Use `addOnFrameProcessCallback` to inspect each processed frame before a final
160
+ result is available or to drive custom scan-step behavior from your own logic.
161
+ The callback uses the exported `BlinkIdFrameProcessCallback` type:
162
+
163
+ ```typescript
164
+ export type BlinkIdFrameProcessCallback = (
165
+ frameResult: BlinkIdProcessResult,
166
+ advanceToNextStep: () => Promise<void>,
167
+ triggerStepTimeout: () => void,
168
+ getLastFrame: () => ArrayBuffer,
169
+ ) => void;
170
+ ```
171
+
172
+ Callback parameters:
173
+
174
+ - `frameResult` - the `BlinkIdProcessResult` for the current frame. It contains
175
+ input image analysis and result completeness data for that frame, but it is not
176
+ the final `BlinkIdScanningResult`.
177
+ - `advanceToNextStep` - manually advances the session to the next required scan
178
+ step. Use this when your custom frame-level logic decides that the active side
179
+ or barcode step is complete. This can also finish the scan when
180
+ `frameResult` already contains all data your integration needs, even if the
181
+ default flow would keep waiting for a barcode or another optional step that
182
+ the user cannot capture reliably.
183
+ - `triggerStepTimeout` - immediately triggers the scan-step timeout path for the
184
+ active step. Use this when custom validation decides the current step should
185
+ fail or stop waiting for more frames.
186
+ - `getLastFrame` - returns the raw `ArrayBuffer` for the frame that produced
187
+ `frameResult`, useful for QA overlays, diagnostics, or custom capture tooling.
188
+
189
+ ```typescript
190
+ const removeOnFrameProcess = uxManager.addOnFrameProcessCallback(
191
+ (frameResult, advanceToNextStep, triggerStepTimeout, getLastFrame) => {
192
+ if (hasAllRequiredData(frameResult)) {
193
+ void advanceToNextStep();
194
+ return;
195
+ }
196
+
197
+ if (shouldStopStep(frameResult)) {
198
+ triggerStepTimeout();
199
+ return;
200
+ }
201
+
202
+ const lastFrame = getLastFrame();
203
+ console.debug("Last processed frame bytes:", lastFrame.byteLength);
204
+ },
205
+ );
206
+
207
+ // Later, to stop receiving updates:
208
+ removeOnFrameProcess();
209
+ ```
210
+
211
+ ### Observing Progress
212
+
213
+ Use `addOnProgressCallback` to receive live BlinkID progress snapshots from the
214
+ manager's internal RAF loop, capped at 30 FPS. This is useful for QA overlays,
215
+ debug tooling, or custom telemetry.
216
+
217
+ ```javascript
218
+ const removeOnProgress = uxManager.addOnProgressCallback((progress) => {
219
+ console.log(progress.uiStateKey);
220
+ console.log(progress.inactivity.remainingMs);
221
+ console.log(progress.perSide.remainingMs);
222
+ console.log(progress.partiallySupportedBarcodeResolve.remainingMs);
223
+ });
224
+
225
+ // Later, to stop receiving updates:
226
+ removeOnProgress();
227
+ ```
228
+
229
+ Each progress payload includes:
230
+
231
+ - `uiStateKey` - current stabilized UI state
232
+ - `mappedUiStateKey` - latest raw candidate state before stabilization
233
+ - `inactivity` - configured, remaining, and status data for the inactivity timer
234
+ - `perSide` - configured, remaining, and status data for the scan-step timer
235
+ - `partiallySupportedBarcodeResolve` - configured, remaining, and status data for the partially supported barcode resolve timer
236
+ - `playbackState` - current camera playback state
237
+ - `isTimingActiveScanStep` - whether BlinkID is currently timing an active scan step
238
+
107
239
  ### Inspecting UI State
108
240
 
109
241
  Two getters provide visibility into the current UI state:
@@ -153,16 +285,62 @@ The output files will be available in the `dist/` and `types/` directories.
153
285
 
154
286
  ### Internationalization
155
287
 
156
- You can customize UI strings when creating the feedback UI:
288
+ You can customize UI strings when creating the feedback UI. The canonical key shape is defined by [`src/ui/locales/en.ts`](src/ui/locales/en.ts); `LocalizationStrings` in [`src/ui/LocalizationContext.tsx`](src/ui/LocalizationContext.tsx) follows that object.
289
+
290
+ #### v8000 breaking change: nested localization keys
291
+
292
+ Older releases used **flat** top-level keys (for example `scan_the_barcode`, `help_modal_title_1`). Current releases use a **nested** object. Overrides in `feedbackUiOptions.localizationStrings` (or the third argument to `createBlinkIdFeedbackUi`) must use the new paths; flat keys are no longer read. If you overrode flat keys in 7.x, use the **Flat key migration (pre-v8000 → current)** table in the v8000 package `CHANGELOG.md` (from the major release changeset) for the old-key to new-path mapping.
293
+
294
+ Example override with nested keys:
157
295
 
158
296
  ```typescript
159
297
  createBlinkIdFeedbackUi(uxManager, cameraUi, {
160
- localizationStrings: {
161
- scan_the_barcode: "Please scan the barcode"
162
- }
298
+ localizationStrings: {
299
+ feedback_messages: {
300
+ scan_the_barcode: "Please scan the barcode",
301
+ },
302
+ timeout_modal: {
303
+ title: "Scan did not finish",
304
+ },
305
+ },
163
306
  });
164
307
  ```
165
308
 
309
+ #### Structure overview
310
+
311
+ Top-level groups in `en.ts`:
312
+
313
+ - `feedback_messages` — short live feedback strings (blur, glare, scan-this-side hints, success ARIA labels).
314
+ - `help_button` — `aria_label`, `tooltip` for the help entry point.
315
+ - `help_modal` — shared chrome (`aria`, `back_btn`, `next_btn`, `done_btn`, `done_btn_aria`) plus three **flow groups** (`full_document`, `document_with_barcode`, `barcode_only`). Each group has step objects `visibility`, `lighting`, `blur` with `title`, `title_desktop`, `details`, `details_desktop` as applicable, and `camera_lens` with desktop-only `title_desktop` / `details_desktop` where used.
316
+ - `onboarding_modal` — shared `aria`, `btn` plus the same three groups (`full_document`, `document_with_barcode`, `barcode_only`) with `title`, `title_desktop`, `details`, `details_desktop`.
317
+ - `error_modal` — `cancel_btn`, `retry_btn` for error flows that expose those actions.
318
+ - `document_filtered_modal`, `document_not_recognized_modal` — `title` and `details` for document filtering / unsupported UI.
319
+ - `timeout_modal` — `title` and `details` for scan timeout / failure messaging.
320
+ - `sdk_aria` — ARIA label for the scanning screen region.
321
+
322
+ #### Extraction mode and which help/onboarding group is used
323
+
324
+ `BlinkIdExtractionMode` (see [`src/core/extractionMode.ts`](src/core/extractionMode.ts)) drives which subtree under `help_modal` and `onboarding_modal` is shown. The mapping matches [`helpModalContentByExtractionMode`](src/ui/dialogs/HelpModal.tsx) and [`onboardingModalContentByExtractionMode`](src/ui/dialogs/OnboardingGuideModal.tsx):
325
+
326
+ | Extraction mode | `help_modal` / `onboarding_modal` group |
327
+ | ------------------------- | ---------------------------------------- |
328
+ | `full-document` | `full_document` |
329
+ | `document-with-barcode` | `document_with_barcode` |
330
+ | `barcode-only` | `barcode_only` |
331
+
332
+ Feedback strings that depend on extraction mode (for example front vs barcode side) are selected in code via [`src/ui/feedbackMessages.ts`](src/ui/feedbackMessages.ts); new keys include `scan_the_barcode_side` and `keep_still` (used for the desktop blur path as a shorter “keep still” hint).
333
+
334
+ #### English copy changes (not just nesting)
335
+
336
+ - Several `feedback_messages` strings now say “**a** document” instead of “**the** document” where the copy is generic.
337
+ - New dedicated copy for **barcode-only** and **document + barcode** paths under `help_modal.barcode`, `help_modal.capture_barcode`, and matching `onboarding_modal` groups.
338
+ - New feedback keys: `scan_the_barcode_side`, `keep_still`.
339
+
340
+ #### Other locales
341
+
342
+ Every file under [`src/ui/locales/`](src/ui/locales/) follows the same nested structure as `en.ts`. If you maintain a fork or partial override, diff your strings against `en.ts` to pick up new keys and renamed paths.
343
+
166
344
  #### Provided Translations
167
345
 
168
346
  <details>