scandit-datacapture-frameworks-label 8.2.1 → 8.3.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 (33) hide show
  1. package/dist/dts/defaults/LabelCaptureDefaults.d.ts +5 -0
  2. package/dist/dts/generated/LabelProxyAdapter.d.ts +4 -0
  3. package/dist/dts/labelcapture/AdaptiveRecognitionMode.d.ts +4 -0
  4. package/dist/dts/labelcapture/CustomBarcode.d.ts +2 -0
  5. package/dist/dts/labelcapture/CustomText.d.ts +2 -0
  6. package/dist/dts/labelcapture/DateText.d.ts +17 -0
  7. package/dist/dts/labelcapture/ExpiryDateText.d.ts +2 -0
  8. package/dist/dts/labelcapture/ImeiOneBarcode.d.ts +2 -0
  9. package/dist/dts/labelcapture/ImeiTwoBarcode.d.ts +2 -0
  10. package/dist/dts/labelcapture/LabelCaptureSession.d.ts +2 -0
  11. package/dist/dts/labelcapture/LabelCaptureValidationFlowListener.d.ts +4 -1
  12. package/dist/dts/labelcapture/LabelCaptureValidationFlowSettings.d.ts +16 -1
  13. package/dist/dts/labelcapture/LabelDefinition.d.ts +6 -0
  14. package/dist/dts/labelcapture/LabelField.d.ts +3 -0
  15. package/dist/dts/labelcapture/LabelFieldDefinition.d.ts +4 -0
  16. package/dist/dts/labelcapture/LabelFieldValueType.d.ts +7 -0
  17. package/dist/dts/labelcapture/LabelResultUpdateType.d.ts +5 -0
  18. package/dist/dts/labelcapture/PackingDateText.d.ts +2 -0
  19. package/dist/dts/labelcapture/PartNumberBarcode.d.ts +2 -0
  20. package/dist/dts/labelcapture/SerialNumberBarcode.d.ts +2 -0
  21. package/dist/dts/labelcapture/TotalPriceText.d.ts +2 -0
  22. package/dist/dts/labelcapture/UnitPriceText.d.ts +2 -0
  23. package/dist/dts/labelcapture/WeightText.d.ts +2 -0
  24. package/dist/dts/labelcapture/controller/LabelCaptureController.d.ts +4 -4
  25. package/dist/dts/labelcapture/controller/LabelCaptureValidationFlowOverlayController.d.ts +9 -1
  26. package/dist/dts/labelcapture/index.d.ts +4 -0
  27. package/dist/dts/labelcapture/private/PrivateLabelField.d.ts +1 -0
  28. package/dist/dts/labelcapture/view/LabelCaptureValidationFlowOverlay.d.ts +3 -0
  29. package/dist/index.js +402 -21
  30. package/dist/index.js.map +1 -1
  31. package/package.json +5 -5
  32. package/test/LabelCaptureValidationFlowOverlayController.test.ts +40 -26
  33. package/test/LabelCaptureValidationFlowSettings.test.ts +5 -0
@@ -1,9 +1,14 @@
1
1
  import { describe, it, expect, jest, beforeEach, afterEach, beforeAll } from '@jest/globals';
2
- import { EventEmitter, EventPayload, FactoryMaker } from 'scandit-datacapture-frameworks-core';
3
- import { LabelCaptureValidationFlowOverlayController, LabelCaptureValidationFlowListenerEvents } from '../src/labelcapture/controller/LabelCaptureValidationFlowOverlayController';
2
+ import { EventEmitter, EventPayload, FactoryMaker, FrameData, CoreProxy, createNativeProxy } from 'scandit-datacapture-frameworks-core';
3
+ import { MockCaller, MockNativeEventEmitter } from '../__mocks__/ScanditDataCaptureCore';
4
+ import {
5
+ LabelCaptureValidationFlowOverlayController,
6
+ LabelCaptureValidationFlowListenerEvents,
7
+ } from '../src/labelcapture/controller/LabelCaptureValidationFlowOverlayController';
4
8
  import { LabelCaptureValidationFlowOverlay } from '../src/labelcapture/view/LabelCaptureValidationFlowOverlay';
5
9
  import { LabelCaptureValidationFlowListener } from '../src/labelcapture/LabelCaptureValidationFlowListener';
6
10
  import { LabelField } from '../src/labelcapture/LabelField';
11
+ import { LabelResultUpdateType } from '../src/labelcapture/LabelResultUpdateType';
7
12
  import { LabelCapture } from '../src/labelcapture/LabelCapture';
8
13
  import { LabelCaptureSettings } from '../src/labelcapture/LabelCaptureSettings';
9
14
  import { LabelCaptureValidationFlowSettings } from '../src/labelcapture/LabelCaptureValidationFlowSettings';
@@ -26,6 +31,11 @@ const mockDefaults: LabelCaptureDefaults = {
26
31
  validationErrorText: 'Validation error',
27
32
  requiredFieldErrorText: 'Required field',
28
33
  manualInputButtonText: 'Enter manually',
34
+ validationFinishButtonText: 'Finish',
35
+ validationRestartButtonText: 'Clear All',
36
+ validationPauseButtonText: 'Pause',
37
+ validationAdaptiveScanningText: 'Processing, tap to type manually',
38
+ validationScanningText: 'Scanning',
29
39
  },
30
40
  },
31
41
  Feedback: {
@@ -76,6 +86,14 @@ describe('LabelCaptureValidationFlowOverlayController', () => {
76
86
  FactoryMaker.bindInstanceIfNotExists('LabelCaptureDefaults', mockDefaults);
77
87
  // Register the proxy builder - each test gets a fresh proxy
78
88
  FactoryMaker.bindLazyInstance('LabelCaptureValidationFlowOverlayProxy', () => createMockLabelProxy());
89
+
90
+ // Register CoreProxy for FrameDataController
91
+ const mockNativeModule = {
92
+ getLastFrameAsJson: jest.fn(() => Promise.resolve(null)),
93
+ };
94
+ const nativeEventEmitter = new MockNativeEventEmitter();
95
+ const caller = new MockCaller(mockNativeModule, nativeEventEmitter);
96
+ FactoryMaker.bindLazyInstance('CoreProxy', () => createNativeProxy<CoreProxy>(caller));
79
97
  });
80
98
 
81
99
  beforeEach(() => {
@@ -105,6 +123,14 @@ describe('LabelCaptureValidationFlowOverlayController', () => {
105
123
  mockListener = {
106
124
  didCaptureLabelWithFields: jest.fn(),
107
125
  didSubmitManualInputForField: jest.fn(),
126
+ didUpdateValidationFlowResult: jest.fn(
127
+ async (
128
+ type: LabelResultUpdateType,
129
+ asyncId: number,
130
+ fields: LabelField[],
131
+ getFrameData: () => Promise<FrameData | null>
132
+ ): Promise<void> => {}
133
+ ),
108
134
  };
109
135
  });
110
136
 
@@ -206,10 +232,7 @@ describe('LabelCaptureValidationFlowOverlayController', () => {
206
232
  jest.spyOn(LabelField as any, 'fromJSON').mockReturnValue(mockField);
207
233
 
208
234
  // when - emit event directly on the EventEmitter
209
- mockProxy.eventEmitter.emit(
210
- LabelCaptureValidationFlowListenerEvents.didSubmitManualInputForField,
211
- eventPayload
212
- );
235
+ mockProxy.eventEmitter.emit(LabelCaptureValidationFlowListenerEvents.didSubmitManualInputForField, eventPayload);
213
236
 
214
237
  // then
215
238
  expect(mockListener.didSubmitManualInputForField).toHaveBeenCalledTimes(1);
@@ -240,10 +263,7 @@ describe('LabelCaptureValidationFlowOverlayController', () => {
240
263
  jest.spyOn(LabelField as any, 'fromJSON').mockReturnValue(mockField);
241
264
 
242
265
  // when - emit event directly on the EventEmitter
243
- mockProxy.eventEmitter.emit(
244
- LabelCaptureValidationFlowListenerEvents.didSubmitManualInputForField,
245
- eventPayload
246
- );
266
+ mockProxy.eventEmitter.emit(LabelCaptureValidationFlowListenerEvents.didSubmitManualInputForField, eventPayload);
247
267
 
248
268
  // then
249
269
  expect(mockListener.didSubmitManualInputForField).toHaveBeenCalledWith(
@@ -274,10 +294,7 @@ describe('LabelCaptureValidationFlowOverlayController', () => {
274
294
  };
275
295
 
276
296
  // when - emit event directly on the EventEmitter
277
- mockProxy.eventEmitter.emit(
278
- LabelCaptureValidationFlowListenerEvents.didSubmitManualInputForField,
279
- eventPayload
280
- );
297
+ mockProxy.eventEmitter.emit(LabelCaptureValidationFlowListenerEvents.didSubmitManualInputForField, eventPayload);
281
298
 
282
299
  // then
283
300
  expect(mockListener.didSubmitManualInputForField).not.toHaveBeenCalled();
@@ -298,7 +315,7 @@ describe('LabelCaptureValidationFlowOverlayController', () => {
298
315
  const eventPayload: EventPayload = {
299
316
  name: LabelCaptureValidationFlowListenerEvents.didCaptureLabelWithFields,
300
317
  data: JSON.stringify({
301
- fields: fieldsData.map((f) => JSON.stringify(f)),
318
+ fields: fieldsData.map(f => JSON.stringify(f)),
302
319
  }),
303
320
  };
304
321
 
@@ -308,10 +325,7 @@ describe('LabelCaptureValidationFlowOverlayController', () => {
308
325
  });
309
326
 
310
327
  // when - emit event directly on the EventEmitter
311
- mockProxy.eventEmitter.emit(
312
- LabelCaptureValidationFlowListenerEvents.didCaptureLabelWithFields,
313
- eventPayload
314
- );
328
+ mockProxy.eventEmitter.emit(LabelCaptureValidationFlowListenerEvents.didCaptureLabelWithFields, eventPayload);
315
329
 
316
330
  // then
317
331
  expect(mockListener.didCaptureLabelWithFields).toHaveBeenCalledTimes(1);
@@ -338,10 +352,7 @@ describe('LabelCaptureValidationFlowOverlayController', () => {
338
352
  jest.spyOn(LabelField as any, 'fromJSON').mockReturnValue(null);
339
353
 
340
354
  // when - emit event directly on the EventEmitter
341
- mockProxy.eventEmitter.emit(
342
- LabelCaptureValidationFlowListenerEvents.didCaptureLabelWithFields,
343
- eventPayload
344
- );
355
+ mockProxy.eventEmitter.emit(LabelCaptureValidationFlowListenerEvents.didCaptureLabelWithFields, eventPayload);
345
356
 
346
357
  // then
347
358
  expect(mockListener.didCaptureLabelWithFields).toHaveBeenCalledWith([]);
@@ -360,7 +371,10 @@ describe('LabelCaptureValidationFlowOverlayController', () => {
360
371
 
361
372
  // then
362
373
  expect(mockAdapter.updateLabelCaptureValidationFlowOverlay).toHaveBeenCalled();
363
- const callArgs = (mockAdapter.updateLabelCaptureValidationFlowOverlay as jest.Mock).mock.calls[0][0] as { dataCaptureViewId: number; overlayJson: string };
374
+ const callArgs = (mockAdapter.updateLabelCaptureValidationFlowOverlay as jest.Mock).mock.calls[0][0] as {
375
+ dataCaptureViewId: number;
376
+ overlayJson: string;
377
+ };
364
378
  expect(callArgs).toHaveProperty('dataCaptureViewId');
365
379
  expect(callArgs).toHaveProperty('overlayJson');
366
380
  expect(JSON.parse(callArgs.overlayJson)).toHaveProperty('hasListener');
@@ -392,7 +406,7 @@ describe('LabelCaptureValidationFlowOverlayController', () => {
392
406
  (newController as any).adapter = newMockAdapter;
393
407
 
394
408
  // Wait for async initialize
395
- await new Promise((resolve) => setTimeout(resolve, 10));
409
+ await new Promise(resolve => setTimeout(resolve, 10));
396
410
 
397
411
  // then - verify that subscribe was called (via eventEmitter.on)
398
412
  const newProxy = (newController as any)._proxy;
@@ -416,7 +430,7 @@ describe('LabelCaptureValidationFlowOverlayController', () => {
416
430
  const onSpy = jest.spyOn(newProxy.eventEmitter, 'on');
417
431
 
418
432
  // Wait for async initialize
419
- await new Promise((resolve) => setTimeout(resolve, 10));
433
+ await new Promise(resolve => setTimeout(resolve, 10));
420
434
 
421
435
  // then - should not have subscribed since no listener
422
436
  // When we subscribe now, it should actually add listeners
@@ -20,6 +20,11 @@ const mockDefaults: LabelCaptureDefaults = {
20
20
  validationErrorText: 'Validation error',
21
21
  requiredFieldErrorText: 'Required field',
22
22
  manualInputButtonText: 'Enter manually',
23
+ validationFinishButtonText: 'Finish',
24
+ validationRestartButtonText: 'Clear All',
25
+ validationPauseButtonText: 'Pause',
26
+ validationAdaptiveScanningText: 'Processing, tap to type manually',
27
+ validationScanningText: 'Scanning',
23
28
  },
24
29
  },
25
30
  Feedback: {