scandit-datacapture-frameworks-label 7.5.1 → 7.6.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/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { FactoryMaker, Brush, CameraSettings, nameForSerialization, DefaultSerializeable, ignoreFromSerialization, ignoreFromSerializationIfNull, Quadrilateral, BaseController, Anchor, PointWithUnit, Rect, Point, Size, serializationDefault, NoViewfinder } from 'scandit-datacapture-frameworks-core';
1
+ import { FactoryMaker, Feedback, Brush, CameraSettings, nameForSerialization, DefaultSerializeable, ignoreFromSerialization, ignoreFromSerializationIfNull, Quadrilateral, BaseNewController, BaseController, Anchor, PointWithUnit, Rect, Point, Size, serializationDefault, NoViewfinder } from 'scandit-datacapture-frameworks-core';
2
2
  import { Barcode, getBarcodeDefaults } from 'scandit-datacapture-frameworks-barcode';
3
3
 
4
4
  function loadLabelCaptureDefaults(jsonDefaults) {
@@ -28,6 +28,9 @@ function parseLabelCaptureDefaults(jsonDefaults) {
28
28
  manualInputButtonText: jsonDefaults.LabelCapture.LabelCaptureValidationFlowOverlay.Settings.manualInputButtonText,
29
29
  }
30
30
  },
31
+ Feedback: {
32
+ success: Feedback.fromJSON(JSON.parse(jsonDefaults.LabelCapture.feedback).success),
33
+ },
31
34
  },
32
35
  };
33
36
  }
@@ -444,22 +447,34 @@ var LabelCaptureListenerEvents;
444
447
  (function (LabelCaptureListenerEvents) {
445
448
  LabelCaptureListenerEvents["didUpdateSession"] = "LabelCaptureListener.didUpdateSession";
446
449
  })(LabelCaptureListenerEvents || (LabelCaptureListenerEvents = {}));
447
- class LabelCaptureController extends BaseController {
450
+ class LabelCaptureController extends BaseNewController {
448
451
  constructor(mode) {
449
452
  super('LabelCaptureProxy');
450
453
  this.mode = mode;
454
+ this.initialize().catch(error => console.error('Failed to initialize LabelCaptureController:', error));
455
+ }
456
+ initialize() {
457
+ return __awaiter(this, void 0, void 0, function* () {
458
+ if (this.mode.listeners.length > 0) {
459
+ yield this.subscribeLabelCaptureListener();
460
+ }
461
+ });
451
462
  }
452
463
  setModeEnabledState(isEnabled) {
453
- return this._proxy.$setModeEnabledState({ modeId: this.mode.modeId, isEnabled });
464
+ return this._proxy.$setModeEnabledState({ modeId: this.modeId, isEnabled });
454
465
  }
455
466
  updateLabelCaptureSettings(settingsJson) {
456
- return this._proxy.$updateLabelCaptureSettings({ modeId: this.mode.modeId, settingsJson });
467
+ return this._proxy.$updateLabelCaptureSettings({ modeId: this.modeId, settingsJson });
457
468
  }
458
469
  subscribeLabelCaptureListener() {
459
470
  return __awaiter(this, void 0, void 0, function* () {
460
- yield this._proxy.$registerListenerForEvents({ modeId: this.mode.modeId });
471
+ if (this._boundHandleDidUpdateSession) {
472
+ return;
473
+ }
474
+ yield this._proxy.$registerListenerForEvents({ modeId: this.modeId });
475
+ this._boundHandleDidUpdateSession = this.handleDidUpdateSessionEvent.bind(this);
461
476
  this._proxy.subscribeForEvents(Object.values(LabelCaptureListenerEvents));
462
- this._proxy.eventEmitter.on(LabelCaptureListenerEvents.didUpdateSession, this.handleDidUpdateSessionEvent.bind(this));
477
+ this._proxy.eventEmitter.on(LabelCaptureListenerEvents.didUpdateSession, this._boundHandleDidUpdateSession);
463
478
  });
464
479
  }
465
480
  handleDidUpdateSessionEvent(ev) {
@@ -467,16 +482,29 @@ class LabelCaptureController extends BaseController {
467
482
  const payload = JSON.parse(ev.data);
468
483
  const session = LabelCaptureSession.fromJSON(JSON.parse(payload.session));
469
484
  this.notifyListenersOfDidUpdateSession(session);
470
- yield this._proxy.$finishDidUpdateSessionCallback({ isEnabled: this.mode.isEnabled });
485
+ yield this._proxy.$finishDidUpdateSessionCallback({ modeId: this.modeId, isEnabled: this.mode.isEnabled });
471
486
  });
472
487
  }
473
488
  unsubscribeLabelCaptureListener() {
474
489
  return __awaiter(this, void 0, void 0, function* () {
475
- yield this._proxy.$unregisterListenerForEvents({ modeId: this.mode.modeId });
490
+ yield this._proxy.$unregisterListenerForEvents({ modeId: this.modeId });
476
491
  this._proxy.unsubscribeFromEvents(Object.values(LabelCaptureListenerEvents));
477
- this._proxy.eventEmitter.off(LabelCaptureListenerEvents.didUpdateSession, this.handleDidUpdateSessionEvent.bind(this));
492
+ if (this._boundHandleDidUpdateSession) {
493
+ this._proxy.eventEmitter.off(LabelCaptureListenerEvents.didUpdateSession, this._boundHandleDidUpdateSession);
494
+ this._boundHandleDidUpdateSession = undefined;
495
+ }
478
496
  });
479
497
  }
498
+ updateFeedback(feedback) {
499
+ this._proxy.$updateLabelCaptureFeedback({ modeId: this.modeId, feedbackJson: JSON.stringify(feedback.toJSON()) });
500
+ }
501
+ dispose() {
502
+ this.unsubscribeLabelCaptureListener();
503
+ this._proxy.dispose();
504
+ }
505
+ get modeId() {
506
+ return this.mode.modeId;
507
+ }
480
508
  notifyListenersOfDidUpdateSession(session) {
481
509
  const mode = this.mode;
482
510
  mode.listeners.forEach(listener => {
@@ -487,53 +515,113 @@ class LabelCaptureController extends BaseController {
487
515
  }
488
516
  }
489
517
 
518
+ class LabelCaptureFeedback extends DefaultSerializeable {
519
+ static get defaultFeedback() {
520
+ return new LabelCaptureFeedback();
521
+ }
522
+ static get labelCaptureDefaults() {
523
+ return getLabelCaptureDefaults();
524
+ }
525
+ get success() {
526
+ return this._success;
527
+ }
528
+ set success(success) {
529
+ this._success = success;
530
+ this.updateFeedback();
531
+ }
532
+ updateFeedback() {
533
+ var _a;
534
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateFeedback(this);
535
+ }
536
+ constructor() {
537
+ super();
538
+ this.controller = null;
539
+ this._success = LabelCaptureFeedback.labelCaptureDefaults.LabelCapture.Feedback.success;
540
+ }
541
+ }
542
+ __decorate([
543
+ nameForSerialization('success')
544
+ ], LabelCaptureFeedback.prototype, "_success", void 0);
545
+ __decorate([
546
+ ignoreFromSerialization
547
+ ], LabelCaptureFeedback.prototype, "controller", void 0);
548
+ __decorate([
549
+ ignoreFromSerialization
550
+ ], LabelCaptureFeedback, "labelCaptureDefaults", null);
551
+
490
552
  class LabelCapture extends DefaultSerializeable {
491
553
  get isEnabled() {
492
554
  return this._isEnabled;
493
555
  }
494
556
  set isEnabled(isEnabled) {
557
+ var _a;
495
558
  this._isEnabled = isEnabled;
496
- this.controller.setModeEnabledState(isEnabled);
559
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.setModeEnabledState(isEnabled);
497
560
  }
498
561
  get context() {
499
562
  return this._context;
500
563
  }
564
+ static createRecommendedCameraSettings() {
565
+ return new CameraSettings(getLabelCaptureDefaults().LabelCapture.RecommendedCameraSettings);
566
+ }
567
+ /**
568
+ * @deprecated Use createRecommendedCameraSettings() instead to get a new instance that can be safely modified.
569
+ */
501
570
  static get recommendedCameraSettings() {
502
- return getLabelCaptureDefaults().LabelCapture.RecommendedCameraSettings;
571
+ if (LabelCapture._recommendedCameraSettings === null) {
572
+ LabelCapture._recommendedCameraSettings = LabelCapture.createRecommendedCameraSettings();
573
+ }
574
+ return LabelCapture._recommendedCameraSettings;
503
575
  }
504
576
  get _context() {
505
577
  return this.privateContext;
506
578
  }
507
579
  set _context(newContext) {
580
+ var _a, _b;
508
581
  if (newContext == null) {
509
- this.controller.unsubscribeLabelCaptureListener();
510
- }
511
- else if (this.privateContext == null) {
512
- this.controller.subscribeLabelCaptureListener();
582
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.dispose();
583
+ this.controller = null;
584
+ this._feedback.controller = null;
585
+ return;
513
586
  }
514
587
  this.privateContext = newContext;
515
- }
588
+ (_b = this.controller) !== null && _b !== void 0 ? _b : (this.controller = new LabelCaptureController(this));
589
+ this._feedback.controller = this.controller;
590
+ }
591
+ /**
592
+ * @deprecated Since 7.6. This factory will be removed in 8.0.
593
+ * Use the public constructor instead and configure manually:
594
+ * ```ts
595
+ * const mode = new LabelCapture(settings);
596
+ * context.addMode(mode);
597
+ * ```
598
+ */
516
599
  static forContext(context, settings) {
517
- const mode = new LabelCapture();
518
- mode.settings = settings;
600
+ const mode = new LabelCapture(settings);
519
601
  if (context) {
520
602
  context.addMode(mode);
521
603
  }
522
604
  return mode;
523
605
  }
524
- constructor() {
606
+ constructor(settings) {
525
607
  super();
526
608
  this.type = 'labelCapture';
527
- this.modeId = Math.floor(Math.random() * 1000000);
609
+ this.modeId = Math.floor(Math.random() * 100000000);
610
+ this.parentId = null;
528
611
  this._isEnabled = true;
612
+ this._feedback = LabelCaptureFeedback.defaultFeedback;
529
613
  this.hasListeners = false;
530
614
  this.privateContext = null;
531
615
  this.listeners = [];
532
- this.controller = new LabelCaptureController(this);
616
+ this.controller = null;
617
+ this.settings = settings;
533
618
  }
534
619
  applySettings(settings) {
535
- this.settings = settings;
536
- return this.controller.updateLabelCaptureSettings(JSON.stringify(settings.toJSON()));
620
+ return __awaiter(this, void 0, void 0, function* () {
621
+ var _a;
622
+ this.settings = settings;
623
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateLabelCaptureSettings(JSON.stringify(settings.toJSON()));
624
+ });
537
625
  }
538
626
  addListener(listener) {
539
627
  if (this.listeners.includes(listener)) {
@@ -549,10 +637,28 @@ class LabelCapture extends DefaultSerializeable {
549
637
  this.listeners.splice(this.listeners.indexOf(listener), 1);
550
638
  this.hasListeners = this.listeners.length > 0;
551
639
  }
640
+ get feedback() {
641
+ return this._feedback;
642
+ }
643
+ set feedback(feedback) {
644
+ var _a;
645
+ this._feedback.controller = null;
646
+ this._feedback = feedback;
647
+ this._feedback.controller = this.controller;
648
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateFeedback(feedback);
649
+ }
552
650
  }
651
+ LabelCapture._recommendedCameraSettings = null;
652
+ __decorate([
653
+ nameForSerialization('parentId'),
654
+ ignoreFromSerializationIfNull
655
+ ], LabelCapture.prototype, "parentId", void 0);
553
656
  __decorate([
554
657
  nameForSerialization('enabled')
555
658
  ], LabelCapture.prototype, "_isEnabled", void 0);
659
+ __decorate([
660
+ nameForSerialization('feedback')
661
+ ], LabelCapture.prototype, "_feedback", void 0);
556
662
  __decorate([
557
663
  ignoreFromSerialization
558
664
  ], LabelCapture.prototype, "privateContext", void 0);
@@ -573,13 +679,15 @@ var LabelCaptureAdvancedOverlayListenerEvents;
573
679
  LabelCaptureAdvancedOverlayListenerEvents["offsetForCapturedLabelField"] = "LabelCaptureAdvancedOverlayListener.offsetForFieldOfLabel";
574
680
  })(LabelCaptureAdvancedOverlayListenerEvents || (LabelCaptureAdvancedOverlayListenerEvents = {}));
575
681
  class LabelCaptureAdvancedOverlayController extends BaseController {
576
- constructor() {
682
+ constructor(overlay) {
577
683
  super('LabelCaptureAdvancedOverlayProxy');
684
+ this.overlay = overlay;
685
+ this.initialize();
578
686
  }
579
- static forOverlay(overlay) {
580
- const proxy = new LabelCaptureAdvancedOverlayController();
581
- proxy.overlay = overlay;
582
- return proxy;
687
+ initialize() {
688
+ if (this.overlay.listener) {
689
+ this.subscribeListener();
690
+ }
583
691
  }
584
692
  setViewForCapturedLabel(label, view) {
585
693
  return this._proxy.$setViewForCapturedLabel({
@@ -738,24 +846,27 @@ class LabelCaptureAdvancedOverlayController extends BaseController {
738
846
  }
739
847
 
740
848
  class LabelCaptureAdvancedOverlay extends DefaultSerializeable {
849
+ get view() {
850
+ return this._view;
851
+ }
741
852
  set view(newView) {
742
- if (newView == null) {
743
- this.proxy.unsubscribeListener();
744
- }
745
- else if (this._view == null) {
746
- this.proxy.subscribeListener();
853
+ var _a, _b;
854
+ if (newView === null) {
855
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.dispose();
856
+ this.controller = null;
857
+ this._view = null;
858
+ return;
747
859
  }
748
860
  this._view = newView;
749
- }
750
- get view() {
751
- return this._view;
861
+ (_b = this.controller) !== null && _b !== void 0 ? _b : (this.controller = new LabelCaptureAdvancedOverlayController(this));
752
862
  }
753
863
  get shouldShowScanAreaGuides() {
754
864
  return this._shouldShowScanAreaGuides;
755
865
  }
756
866
  set shouldShowScanAreaGuides(shouldShow) {
867
+ var _a;
757
868
  this._shouldShowScanAreaGuides = shouldShow;
758
- this.proxy.updateAdvancedOverlay(JSON.stringify(this.toJSON()));
869
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateAdvancedOverlay(JSON.stringify(this.toJSON()));
759
870
  }
760
871
  get listener() {
761
872
  return this._listener;
@@ -764,50 +875,77 @@ class LabelCaptureAdvancedOverlay extends DefaultSerializeable {
764
875
  this._listener = listener;
765
876
  this.hasListener = listener != null;
766
877
  }
878
+ /**
879
+ * @deprecated Since 7.6. This factory will be removed in 8.0.
880
+ * Use the public constructor instead and add the overlay to the view manually:
881
+ * ```ts
882
+ * const overlay = new LabelCaptureAdvancedOverlay(labelCapture);
883
+ * view.addOverlay(overlay);
884
+ * ```
885
+ */
767
886
  static withLabelCaptureForView(labelCapture, view) {
768
- const overlay = new LabelCaptureAdvancedOverlay();
769
- overlay.mode = labelCapture;
887
+ const overlay = new LabelCaptureAdvancedOverlay(labelCapture);
770
888
  if (view) {
771
889
  view.addOverlay(overlay);
772
890
  }
773
891
  return overlay;
774
892
  }
775
- constructor() {
893
+ constructor(mode) {
776
894
  super();
777
895
  this.type = 'labelCaptureAdvanced';
896
+ this.controller = null;
897
+ this._view = null;
778
898
  this._listener = null;
779
899
  this.hasListener = false;
780
900
  this._shouldShowScanAreaGuides = false;
781
- this.proxy = LabelCaptureAdvancedOverlayController.forOverlay(this);
901
+ this.modeId = mode.modeId;
782
902
  }
783
903
  setViewForCapturedLabel(capturedLabel, view) {
784
- return this.proxy.setViewForCapturedLabel(capturedLabel, view);
904
+ return __awaiter(this, void 0, void 0, function* () {
905
+ var _a;
906
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.setViewForCapturedLabel(capturedLabel, view);
907
+ });
785
908
  }
786
909
  setViewForCapturedLabelField(field, capturedLabel, view) {
787
- return this.proxy.setViewForCapturedLabelField(capturedLabel, field, view);
910
+ return __awaiter(this, void 0, void 0, function* () {
911
+ var _a;
912
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.setViewForCapturedLabelField(capturedLabel, field, view);
913
+ });
788
914
  }
789
915
  setAnchorForCapturedLabel(capturedLabel, anchor) {
790
- return this.proxy.setAnchorForCapturedLabel(capturedLabel, anchor);
916
+ return __awaiter(this, void 0, void 0, function* () {
917
+ var _a;
918
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.setAnchorForCapturedLabel(capturedLabel, anchor);
919
+ });
791
920
  }
792
921
  setAnchorForCapturedLabelField(field, capturedLabel, anchor) {
793
- return this.proxy.setAnchorForCapturedLabelField(capturedLabel, field, anchor);
922
+ return __awaiter(this, void 0, void 0, function* () {
923
+ var _a;
924
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.setAnchorForCapturedLabelField(capturedLabel, field, anchor);
925
+ });
794
926
  }
795
927
  setOffsetForCapturedLabel(capturedLabel, offset) {
796
- return this.proxy.setOffsetForCapturedLabel(capturedLabel, offset);
928
+ return __awaiter(this, void 0, void 0, function* () {
929
+ var _a;
930
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.setOffsetForCapturedLabel(capturedLabel, offset);
931
+ });
797
932
  }
798
933
  setOffsetForCapturedLabelField(field, capturedLabel, offset) {
799
- return this.proxy.setOffsetForCapturedLabelField(capturedLabel, field, offset);
934
+ return __awaiter(this, void 0, void 0, function* () {
935
+ var _a;
936
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.setOffsetForCapturedLabelField(capturedLabel, field, offset);
937
+ });
800
938
  }
801
939
  clearCapturedLabelViews() {
802
- return this.proxy.clearCapturedLabelViews();
940
+ return __awaiter(this, void 0, void 0, function* () {
941
+ var _a;
942
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.clearCapturedLabelViews();
943
+ });
803
944
  }
804
945
  }
805
946
  __decorate([
806
947
  ignoreFromSerialization
807
- ], LabelCaptureAdvancedOverlay.prototype, "proxy", void 0);
808
- __decorate([
809
- ignoreFromSerialization
810
- ], LabelCaptureAdvancedOverlay.prototype, "mode", void 0);
948
+ ], LabelCaptureAdvancedOverlay.prototype, "controller", void 0);
811
949
  __decorate([
812
950
  ignoreFromSerialization
813
951
  ], LabelCaptureAdvancedOverlay.prototype, "_view", void 0);
@@ -1206,13 +1344,15 @@ var LabelCaptureBasicOverlayListenerEvents;
1206
1344
  LabelCaptureBasicOverlayListenerEvents["didTapLabel"] = "LabelCaptureBasicOverlayListener.didTapLabel";
1207
1345
  })(LabelCaptureBasicOverlayListenerEvents || (LabelCaptureBasicOverlayListenerEvents = {}));
1208
1346
  class LabelCaptureBasicOverlayController extends BaseController {
1209
- constructor() {
1347
+ constructor(overlay) {
1210
1348
  super('LabelCaptureBasicOverlayProxy');
1349
+ this.overlay = overlay;
1350
+ this.initialize();
1211
1351
  }
1212
- static forOverlay(overlay) {
1213
- const proxy = new LabelCaptureBasicOverlayController();
1214
- proxy.overlay = overlay;
1215
- return proxy;
1352
+ initialize() {
1353
+ if (this.overlay.listener) {
1354
+ this.subscribeListener();
1355
+ }
1216
1356
  }
1217
1357
  setBrushForFieldOfLabel(brush, field, label) {
1218
1358
  return this._proxy.$setBrushForFieldOfLabel({
@@ -1282,6 +1422,10 @@ class LabelCaptureBasicOverlayController extends BaseController {
1282
1422
  updateBasicOverlay(basicOverlayJson) {
1283
1423
  return this._proxy.$updateLabelCaptureBasicOverlay({ dataCaptureViewId: this.dataCaptureViewId, basicOverlayJson });
1284
1424
  }
1425
+ dispose() {
1426
+ this.unsubscribeListener();
1427
+ this._proxy.dispose();
1428
+ }
1285
1429
  get dataCaptureViewId() {
1286
1430
  var _a, _b;
1287
1431
  return (_b = (_a = this.overlay.view) === null || _a === void 0 ? void 0 : _a.viewId) !== null && _b !== void 0 ? _b : -1;
@@ -1301,38 +1445,43 @@ class LabelCaptureBasicOverlay extends DefaultSerializeable {
1301
1445
  static get labelCaptureDefaults() {
1302
1446
  return getLabelCaptureDefaults();
1303
1447
  }
1448
+ get view() {
1449
+ return this._view;
1450
+ }
1304
1451
  set view(newView) {
1305
- if (newView == null) {
1306
- this.controller.unsubscribeListener();
1307
- }
1308
- else if (this._view == null) {
1309
- this.controller.subscribeListener();
1452
+ var _a, _b;
1453
+ if (newView === null) {
1454
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.dispose();
1455
+ this.controller = null;
1456
+ this._view = null;
1457
+ return;
1310
1458
  }
1311
1459
  this._view = newView;
1312
- }
1313
- get view() {
1314
- return this._view;
1460
+ (_b = this.controller) !== null && _b !== void 0 ? _b : (this.controller = new LabelCaptureBasicOverlayController(this));
1315
1461
  }
1316
1462
  get predictedFieldBrush() {
1317
1463
  return this._predictedFieldBrush;
1318
1464
  }
1319
1465
  set predictedFieldBrush(newBrush) {
1466
+ var _a;
1320
1467
  this._predictedFieldBrush = newBrush;
1321
- this.controller.updateBasicOverlay(JSON.stringify(this.toJSON()));
1468
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateBasicOverlay(JSON.stringify(this.toJSON()));
1322
1469
  }
1323
1470
  get capturedFieldBrush() {
1324
1471
  return this._capturedFieldBrush;
1325
1472
  }
1326
1473
  set capturedFieldBrush(newBrush) {
1474
+ var _a;
1327
1475
  this._capturedFieldBrush = newBrush;
1328
- this.controller.updateBasicOverlay(JSON.stringify(this.toJSON()));
1476
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateBasicOverlay(JSON.stringify(this.toJSON()));
1329
1477
  }
1330
1478
  get labelBrush() {
1331
1479
  return this._labelBrush;
1332
1480
  }
1333
1481
  set labelBrush(newBrush) {
1482
+ var _a;
1334
1483
  this._labelBrush = newBrush;
1335
- this.controller.updateBasicOverlay(JSON.stringify(this.toJSON()));
1484
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateBasicOverlay(JSON.stringify(this.toJSON()));
1336
1485
  }
1337
1486
  get listener() {
1338
1487
  return this._listener;
@@ -1345,30 +1494,45 @@ class LabelCaptureBasicOverlay extends DefaultSerializeable {
1345
1494
  return this._shouldShowScanAreaGuides;
1346
1495
  }
1347
1496
  set shouldShowScanAreaGuides(shouldShow) {
1497
+ var _a;
1348
1498
  this._shouldShowScanAreaGuides = shouldShow;
1349
- this.controller.updateBasicOverlay(JSON.stringify(this.toJSON()));
1499
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateBasicOverlay(JSON.stringify(this.toJSON()));
1350
1500
  }
1351
1501
  get viewfinder() {
1352
1502
  return this._viewfinder;
1353
1503
  }
1354
1504
  set viewfinder(newViewfinder) {
1505
+ var _a;
1355
1506
  this._viewfinder = newViewfinder;
1356
- this.controller.updateBasicOverlay(JSON.stringify(this.toJSON()));
1357
- }
1507
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateBasicOverlay(JSON.stringify(this.toJSON()));
1508
+ }
1509
+ /**
1510
+ * @deprecated Since 7.6. These factories will be removed in 8.0.
1511
+ * Use the public constructor instead and add the overlay to the view manually:
1512
+ * const overlay = new LabelCaptureBasicOverlay(labelCapture);
1513
+ * view.addOverlay(overlay);
1514
+ */
1358
1515
  static withLabelCapture(labelCapture) {
1359
1516
  return LabelCaptureBasicOverlay.withLabelCaptureForView(labelCapture, null);
1360
1517
  }
1518
+ /**
1519
+ * @deprecated Since 7.6. These factories will be removed in 8.0.
1520
+ * Use the public constructor instead and add the overlay to the view manually:
1521
+ * const overlay = new LabelCaptureBasicOverlay(labelCapture);
1522
+ * view.addOverlay(overlay);
1523
+ */
1361
1524
  static withLabelCaptureForView(labelCapture, view) {
1362
- const overlay = new LabelCaptureBasicOverlay();
1363
- overlay.mode = labelCapture;
1525
+ const overlay = new LabelCaptureBasicOverlay(labelCapture);
1364
1526
  if (view) {
1365
1527
  view.addOverlay(overlay);
1366
1528
  }
1367
1529
  return overlay;
1368
1530
  }
1369
- constructor() {
1531
+ constructor(mode) {
1370
1532
  super();
1371
1533
  this.type = 'labelCaptureBasic';
1534
+ this.controller = null;
1535
+ this._view = null;
1372
1536
  this._predictedFieldBrush = LabelCaptureBasicOverlay.defaultPredictedFieldBrush.copy;
1373
1537
  this._capturedFieldBrush = LabelCaptureBasicOverlay.defaultCapturedFieldBrush.copy;
1374
1538
  this._labelBrush = LabelCaptureBasicOverlay.defaultLabelBrush.copy;
@@ -1376,18 +1540,24 @@ class LabelCaptureBasicOverlay extends DefaultSerializeable {
1376
1540
  this.hasListener = false;
1377
1541
  this._listener = null;
1378
1542
  this._viewfinder = null;
1379
- this.controller = LabelCaptureBasicOverlayController.forOverlay(this);
1543
+ this.modeId = mode.modeId;
1380
1544
  }
1381
1545
  setBrushForFieldOfLabel(brush, field, label) {
1382
- return this.controller.setBrushForFieldOfLabel(brush, field, label);
1546
+ return __awaiter(this, void 0, void 0, function* () {
1547
+ var _a;
1548
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.setBrushForFieldOfLabel(brush, field, label);
1549
+ });
1383
1550
  }
1384
1551
  setBrushForLabel(brush, label) {
1385
- return this.controller.setBrushForLabel(brush, label);
1552
+ return __awaiter(this, void 0, void 0, function* () {
1553
+ var _a;
1554
+ return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.setBrushForLabel(brush, label);
1555
+ });
1386
1556
  }
1387
1557
  }
1388
1558
  __decorate([
1389
1559
  ignoreFromSerialization
1390
- ], LabelCaptureBasicOverlay.prototype, "mode", void 0);
1560
+ ], LabelCaptureBasicOverlay.prototype, "controller", void 0);
1391
1561
  __decorate([
1392
1562
  ignoreFromSerialization
1393
1563
  ], LabelCaptureBasicOverlay.prototype, "_view", void 0);
@@ -1406,9 +1576,6 @@ __decorate([
1406
1576
  __decorate([
1407
1577
  ignoreFromSerialization
1408
1578
  ], LabelCaptureBasicOverlay.prototype, "_listener", void 0);
1409
- __decorate([
1410
- ignoreFromSerialization
1411
- ], LabelCaptureBasicOverlay.prototype, "controller", void 0);
1412
1579
  __decorate([
1413
1580
  serializationDefault(NoViewfinder),
1414
1581
  nameForSerialization('viewfinder')
@@ -1419,14 +1586,16 @@ var LabelCaptureValidationFlowListenerEvents;
1419
1586
  LabelCaptureValidationFlowListenerEvents["didCaptureLabelWithFields"] = "LabelCaptureValidationFlowListener.didCaptureLabelWithFields";
1420
1587
  })(LabelCaptureValidationFlowListenerEvents || (LabelCaptureValidationFlowListenerEvents = {}));
1421
1588
  class LabelCaptureValidationFlowOverlayController extends BaseController {
1422
- constructor() {
1589
+ constructor(overlay) {
1423
1590
  super('LabelCaptureValidationFlowOverlayProxy');
1424
1591
  this.isSubscribed = false;
1592
+ this.overlay = overlay;
1593
+ this.initialize();
1425
1594
  }
1426
- static forOverlay(overlay) {
1427
- const proxy = new LabelCaptureValidationFlowOverlayController();
1428
- proxy.overlay = overlay;
1429
- return proxy;
1595
+ initialize() {
1596
+ if (this.overlay.listener) {
1597
+ this.subscribeLabelCaptureValidationFlowListener();
1598
+ }
1430
1599
  }
1431
1600
  updateValidationFlowOverlay() {
1432
1601
  return __awaiter(this, void 0, void 0, function* () {
@@ -1473,22 +1642,30 @@ class LabelCaptureValidationFlowOverlayController extends BaseController {
1473
1642
  }
1474
1643
 
1475
1644
  class LabelCaptureValidationFlowOverlay extends DefaultSerializeable {
1476
- set view(newView) {
1477
- if (newView == null) {
1478
- this.controller.unsubscribeLabelCaptureValidationFlowListener();
1479
- }
1480
- else if (this._view == null) {
1481
- this.controller.subscribeLabelCaptureValidationFlowListener();
1482
- }
1483
- this._view = newView;
1484
- }
1485
1645
  get view() {
1486
1646
  return this._view;
1487
1647
  }
1648
+ set view(newView) {
1649
+ var _a, _b;
1650
+ if (newView === null) {
1651
+ this._view = null;
1652
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.dispose();
1653
+ this.controller = null;
1654
+ return;
1655
+ }
1656
+ this._view = newView;
1657
+ (_b = this.controller) !== null && _b !== void 0 ? _b : (this.controller = new LabelCaptureValidationFlowOverlayController(this));
1658
+ }
1659
+ /**
1660
+ * @deprecated Since 7.6. This factory will be removed in 8.0.
1661
+ * Use the public constructor instead and add the overlay to the view manually:
1662
+ * ```ts
1663
+ * const overlay = new LabelCaptureValidationFlowOverlay(labelCapture);
1664
+ * view.addOverlay(overlay);
1665
+ * ```
1666
+ */
1488
1667
  static withLabelCaptureForView(labelCapture, view) {
1489
- const overlay = new LabelCaptureValidationFlowOverlay();
1490
- overlay.mode = labelCapture;
1491
- overlay.view = view;
1668
+ const overlay = new LabelCaptureValidationFlowOverlay(labelCapture);
1492
1669
  if (view) {
1493
1670
  view.addOverlay(overlay);
1494
1671
  }
@@ -1498,38 +1675,36 @@ class LabelCaptureValidationFlowOverlay extends DefaultSerializeable {
1498
1675
  return this._listener;
1499
1676
  }
1500
1677
  set listener(listener) {
1678
+ var _a, _b;
1501
1679
  this.hasListener = listener != null;
1502
1680
  if (this.view == null) {
1503
1681
  this._listener = listener;
1504
1682
  return;
1505
1683
  }
1506
1684
  if (listener == null) {
1507
- this.controller.unsubscribeLabelCaptureValidationFlowListener();
1685
+ (_a = this.controller) === null || _a === void 0 ? void 0 : _a.unsubscribeLabelCaptureValidationFlowListener();
1508
1686
  }
1509
1687
  else if (this.listener == null) {
1510
- this.controller.subscribeLabelCaptureValidationFlowListener();
1688
+ (_b = this.controller) === null || _b === void 0 ? void 0 : _b.subscribeLabelCaptureValidationFlowListener();
1511
1689
  }
1512
1690
  this._listener = listener;
1513
1691
  }
1514
1692
  applySettings(settings) {
1693
+ var _a, _b;
1515
1694
  this.settings = settings;
1516
- return this.controller.updateValidationFlowOverlay();
1695
+ return (_b = (_a = this.controller) === null || _a === void 0 ? void 0 : _a.updateValidationFlowOverlay()) !== null && _b !== void 0 ? _b : Promise.resolve();
1517
1696
  }
1518
- constructor() {
1697
+ constructor(mode) {
1519
1698
  super();
1520
1699
  this.type = 'validationFlow';
1521
1700
  this.settings = null;
1522
1701
  this.hasListener = false;
1523
1702
  this._listener = null;
1524
- this.controller = LabelCaptureValidationFlowOverlayController.forOverlay(this);
1703
+ this.controller = null;
1704
+ this._view = null;
1705
+ this.modeId = mode.modeId;
1525
1706
  }
1526
1707
  }
1527
- __decorate([
1528
- ignoreFromSerialization
1529
- ], LabelCaptureValidationFlowOverlay.prototype, "mode", void 0);
1530
- __decorate([
1531
- ignoreFromSerialization
1532
- ], LabelCaptureValidationFlowOverlay.prototype, "_view", void 0);
1533
1708
  __decorate([
1534
1709
  nameForSerialization('hasListener')
1535
1710
  ], LabelCaptureValidationFlowOverlay.prototype, "hasListener", void 0);
@@ -1539,6 +1714,9 @@ __decorate([
1539
1714
  __decorate([
1540
1715
  ignoreFromSerialization
1541
1716
  ], LabelCaptureValidationFlowOverlay.prototype, "controller", void 0);
1717
+ __decorate([
1718
+ ignoreFromSerialization
1719
+ ], LabelCaptureValidationFlowOverlay.prototype, "_view", void 0);
1542
1720
 
1543
1721
  class LabelCaptureValidationFlowSettings extends DefaultSerializeable {
1544
1722
  static create() {
@@ -1610,5 +1788,5 @@ __decorate([
1610
1788
  nameForSerialization('manualInputButtonText')
1611
1789
  ], LabelCaptureValidationFlowSettings.prototype, "_manualInputButtonText", void 0);
1612
1790
 
1613
- export { BarcodeField, CapturedLabel, CustomBarcode, CustomText, ExpiryDateText, ImeiOneBarcode, ImeiTwoBarcode, LabelCapture, LabelCaptureAdvancedOverlay, LabelCaptureAdvancedOverlayController, LabelCaptureAdvancedOverlayListenerEvents, LabelCaptureBasicOverlay, LabelCaptureBasicOverlayController, LabelCaptureBasicOverlayListenerEvents, LabelCaptureController, LabelCaptureListenerEvents, LabelCaptureSession, LabelCaptureSettings, LabelCaptureValidationFlowListenerEvents, LabelCaptureValidationFlowOverlay, LabelCaptureValidationFlowOverlayController, LabelCaptureValidationFlowSettings, LabelDateComponentFormat, LabelDateFormat, LabelDateResult, LabelDefinition, LabelField, LabelFieldDefinition, LabelFieldLocation, LabelFieldLocationType, LabelFieldState, LabelFieldType, PackingDateText, PartNumberBarcode, SerialNumberBarcode, TextField, TotalPriceText, UnitPriceText, WeightText, getLabelCaptureDefaults, loadLabelCaptureDefaults };
1791
+ export { BarcodeField, CapturedLabel, CustomBarcode, CustomText, ExpiryDateText, ImeiOneBarcode, ImeiTwoBarcode, LabelCapture, LabelCaptureAdvancedOverlay, LabelCaptureAdvancedOverlayController, LabelCaptureAdvancedOverlayListenerEvents, LabelCaptureBasicOverlay, LabelCaptureBasicOverlayController, LabelCaptureBasicOverlayListenerEvents, LabelCaptureController, LabelCaptureFeedback, LabelCaptureListenerEvents, LabelCaptureSession, LabelCaptureSettings, LabelCaptureValidationFlowListenerEvents, LabelCaptureValidationFlowOverlay, LabelCaptureValidationFlowOverlayController, LabelCaptureValidationFlowSettings, LabelDateComponentFormat, LabelDateFormat, LabelDateResult, LabelDefinition, LabelField, LabelFieldDefinition, LabelFieldLocation, LabelFieldLocationType, LabelFieldState, LabelFieldType, PackingDateText, PartNumberBarcode, SerialNumberBarcode, TextField, TotalPriceText, UnitPriceText, WeightText, getLabelCaptureDefaults, loadLabelCaptureDefaults };
1614
1792
  //# sourceMappingURL=index.js.map