scandit-datacapture-frameworks-label 7.4.1 → 7.5.0-beta.2

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
@@ -18,6 +18,16 @@ function parseLabelCaptureDefaults(jsonDefaults) {
18
18
  DefaultCapturedFieldBrush: Brush.fromJSON(jsonDefaults.LabelCapture.LabelCaptureBasicOverlay.DefaultCapturedFieldBrush),
19
19
  DefaultLabelBrush: Brush.fromJSON(jsonDefaults.LabelCapture.LabelCaptureBasicOverlay.DefaultLabelBrush)
20
20
  },
21
+ LabelCaptureValidationFlowOverlay: {
22
+ Settings: {
23
+ missingFieldsHintText: jsonDefaults.LabelCapture.LabelCaptureValidationFlowOverlay.Settings.missingFieldsHintText,
24
+ standbyHintText: jsonDefaults.LabelCapture.LabelCaptureValidationFlowOverlay.Settings.standbyHintText,
25
+ validationHintText: jsonDefaults.LabelCapture.LabelCaptureValidationFlowOverlay.Settings.validationHintText,
26
+ validationErrorText: jsonDefaults.LabelCapture.LabelCaptureValidationFlowOverlay.Settings.validationErrorText,
27
+ requiredFieldErrorText: jsonDefaults.LabelCapture.LabelCaptureValidationFlowOverlay.Settings.requiredFieldErrorText,
28
+ manualInputButtonText: jsonDefaults.LabelCapture.LabelCaptureValidationFlowOverlay.Settings.manualInputButtonText,
29
+ }
30
+ },
21
31
  },
22
32
  };
23
33
  }
@@ -434,53 +444,46 @@ var LabelCaptureListenerEvents;
434
444
  (function (LabelCaptureListenerEvents) {
435
445
  LabelCaptureListenerEvents["didUpdateSession"] = "LabelCaptureListener.didUpdateSession";
436
446
  })(LabelCaptureListenerEvents || (LabelCaptureListenerEvents = {}));
437
- class LabelCaptureListenerController extends BaseController {
438
- constructor() {
439
- super('LabelCaptureListenerProxy');
447
+ class LabelCaptureController extends BaseController {
448
+ constructor(mode) {
449
+ super('LabelCaptureProxy');
450
+ this.mode = mode;
440
451
  }
441
- static forLabelCapture(labelCapture) {
442
- const controller = new LabelCaptureListenerController();
443
- controller.mode = labelCapture;
444
- return controller;
452
+ setModeEnabledState(isEnabled) {
453
+ return this._proxy.$setModeEnabledState({ modeId: this.mode.modeId, isEnabled });
445
454
  }
446
- subscribeListener() {
455
+ updateLabelCaptureSettings(settingsJson) {
456
+ return this._proxy.$updateLabelCaptureSettings({ modeId: this.mode.modeId, settingsJson });
457
+ }
458
+ subscribeLabelCaptureListener() {
447
459
  return __awaiter(this, void 0, void 0, function* () {
448
460
  yield this._proxy.$registerListenerForEvents({ modeId: this.mode.modeId });
449
- this._proxy.on$didUpdateSession = (ev) => __awaiter(this, void 0, void 0, function* () {
450
- const payload = JSON.parse(ev.data);
451
- const session = LabelCaptureSession.fromJSON(JSON.parse(payload.session));
452
- this.notifyListenersOfDidUpdateSession(session);
453
- yield this._proxy.$finishDidUpdateSessionCallback({ isEnabled: this.mode.isEnabled });
454
- });
461
+ this._proxy.subscribeForEvents(Object.values(LabelCaptureListenerEvents));
462
+ this._proxy.eventEmitter.on(LabelCaptureListenerEvents.didUpdateSession, this.handleDidUpdateSessionEvent.bind(this));
455
463
  });
456
464
  }
457
- unsubscribeListener() {
465
+ handleDidUpdateSessionEvent(ev) {
466
+ return __awaiter(this, void 0, void 0, function* () {
467
+ const payload = JSON.parse(ev.data);
468
+ const session = LabelCaptureSession.fromJSON(JSON.parse(payload.session));
469
+ this.notifyListenersOfDidUpdateSession(session);
470
+ yield this._proxy.$finishDidUpdateSessionCallback({ isEnabled: this.mode.isEnabled });
471
+ });
472
+ }
473
+ unsubscribeLabelCaptureListener() {
458
474
  return __awaiter(this, void 0, void 0, function* () {
459
475
  yield this._proxy.$unregisterListenerForEvents({ modeId: this.mode.modeId });
476
+ this._proxy.unsubscribeFromEvents(Object.values(LabelCaptureListenerEvents));
477
+ this._proxy.eventEmitter.off(LabelCaptureListenerEvents.didUpdateSession, this.handleDidUpdateSessionEvent.bind(this));
460
478
  });
461
479
  }
462
480
  notifyListenersOfDidUpdateSession(session) {
463
481
  const mode = this.mode;
464
- mode.isInListenerCallback = true;
465
482
  mode.listeners.forEach(listener => {
466
483
  if (listener.didUpdateSession) {
467
484
  listener.didUpdateSession(this.mode, session);
468
485
  }
469
486
  });
470
- mode.isInListenerCallback = false;
471
- }
472
- }
473
-
474
- class LabelCaptureController extends BaseController {
475
- constructor(mode) {
476
- super('LabelCaptureProxy');
477
- this.mode = mode;
478
- }
479
- setModeEnabledState(isEnabled) {
480
- return this._proxy.$setModeEnabledState({ modeId: this.mode.modeId, isEnabled });
481
- }
482
- updateLabelCaptureSettings(settingsJson) {
483
- return this._proxy.$updateLabelCaptureSettings({ modeId: this.mode.modeId, settingsJson });
484
487
  }
485
488
  }
486
489
 
@@ -490,7 +493,7 @@ class LabelCapture extends DefaultSerializeable {
490
493
  }
491
494
  set isEnabled(isEnabled) {
492
495
  this._isEnabled = isEnabled;
493
- this.modeController.setModeEnabledState(isEnabled);
496
+ this.controller.setModeEnabledState(isEnabled);
494
497
  }
495
498
  get context() {
496
499
  return this._context;
@@ -503,10 +506,10 @@ class LabelCapture extends DefaultSerializeable {
503
506
  }
504
507
  set _context(newContext) {
505
508
  if (newContext == null) {
506
- this.listenerController.unsubscribeListener();
509
+ this.controller.unsubscribeLabelCaptureListener();
507
510
  }
508
511
  else if (this.privateContext == null) {
509
- this.listenerController.subscribeListener();
512
+ this.controller.subscribeLabelCaptureListener();
510
513
  }
511
514
  this.privateContext = newContext;
512
515
  }
@@ -526,13 +529,11 @@ class LabelCapture extends DefaultSerializeable {
526
529
  this.hasListeners = false;
527
530
  this.privateContext = null;
528
531
  this.listeners = [];
529
- this.isInListenerCallback = false;
530
- this.listenerController = LabelCaptureListenerController.forLabelCapture(this);
531
- this.modeController = new LabelCaptureController(this);
532
+ this.controller = new LabelCaptureController(this);
532
533
  }
533
534
  applySettings(settings) {
534
535
  this.settings = settings;
535
- return this.modeController.updateLabelCaptureSettings(JSON.stringify(settings.toJSON()));
536
+ return this.controller.updateLabelCaptureSettings(JSON.stringify(settings.toJSON()));
536
537
  }
537
538
  addListener(listener) {
538
539
  if (this.listeners.includes(listener)) {
@@ -560,13 +561,7 @@ __decorate([
560
561
  ], LabelCapture.prototype, "listeners", void 0);
561
562
  __decorate([
562
563
  ignoreFromSerialization
563
- ], LabelCapture.prototype, "listenerController", void 0);
564
- __decorate([
565
- ignoreFromSerialization
566
- ], LabelCapture.prototype, "isInListenerCallback", void 0);
567
- __decorate([
568
- ignoreFromSerialization
569
- ], LabelCapture.prototype, "modeController", void 0);
564
+ ], LabelCapture.prototype, "controller", void 0);
570
565
 
571
566
  var LabelCaptureAdvancedOverlayListenerEvents;
572
567
  (function (LabelCaptureAdvancedOverlayListenerEvents) {
@@ -589,19 +584,22 @@ class LabelCaptureAdvancedOverlayController extends BaseController {
589
584
  setViewForCapturedLabel(label, view) {
590
585
  return this._proxy.$setViewForCapturedLabel({
591
586
  jsonView: view ? JSON.stringify(view.toJSON()) : null,
592
- trackingId: label.trackingID
587
+ trackingId: label.trackingID,
588
+ dataCaptureViewId: this.dataCaptureViewId
593
589
  });
594
590
  }
595
591
  setAnchorForCapturedLabel(label, anchor) {
596
592
  return this._proxy.$setAnchorForCapturedLabel({
597
593
  anchor: anchor,
598
- trackingId: label.trackingID
594
+ trackingId: label.trackingID,
595
+ dataCaptureViewId: this.dataCaptureViewId
599
596
  });
600
597
  }
601
598
  setOffsetForCapturedLabel(label, offset) {
602
599
  return this._proxy.$setOffsetForCapturedLabel({
603
600
  offsetJson: JSON.stringify(offset.toJSON()),
604
- trackingId: label.trackingID
601
+ trackingId: label.trackingID,
602
+ dataCaptureViewId: this.dataCaptureViewId
605
603
  });
606
604
  }
607
605
  setViewForCapturedLabelField(label, field, view) {
@@ -611,7 +609,8 @@ class LabelCaptureAdvancedOverlayController extends BaseController {
611
609
  setViewForCapturedLabelFieldPrivate(identifier, view) {
612
610
  return this._proxy.$setViewForCapturedLabelField({
613
611
  view: view ? JSON.stringify(view.toJSON()) : null,
614
- identifier: identifier
612
+ identifier: identifier,
613
+ dataCaptureViewId: this.dataCaptureViewId
615
614
  });
616
615
  }
617
616
  setAnchorForCapturedLabelField(label, field, anchor) {
@@ -621,7 +620,8 @@ class LabelCaptureAdvancedOverlayController extends BaseController {
621
620
  setAnchorForCapturedLabelFieldPrivate(identifier, anchor) {
622
621
  return this._proxy.$setAnchorForCapturedLabelField({
623
622
  anchor: anchor,
624
- identifier: identifier
623
+ identifier: identifier,
624
+ dataCaptureViewId: this.dataCaptureViewId
625
625
  });
626
626
  }
627
627
  setOffsetForCapturedLabelField(label, field, offset) {
@@ -631,15 +631,25 @@ class LabelCaptureAdvancedOverlayController extends BaseController {
631
631
  setOffsetForCapturedLabelFieldPrivate(identifier, offset) {
632
632
  return this._proxy.$setOffsetForCapturedLabelField({
633
633
  offset: JSON.stringify(offset.toJSON()),
634
- identifier: identifier
634
+ identifier: identifier,
635
+ dataCaptureViewId: this.dataCaptureViewId
635
636
  });
636
637
  }
637
638
  clearCapturedLabelViews() {
638
- return this._proxy.$clearCapturedLabelViews();
639
+ return this._proxy.$clearCapturedLabelViews({ dataCaptureViewId: this.dataCaptureViewId });
639
640
  }
640
641
  subscribeListener() {
641
- this._proxy.$registerListenerForAdvancedOverlayEvents();
642
- this._proxy.on$viewForLabel = (ev) => __awaiter(this, void 0, void 0, function* () {
642
+ this._proxy.$registerListenerForAdvancedOverlayEvents({ dataCaptureViewId: this.dataCaptureViewId });
643
+ this._proxy.subscribeForEvents(Object.values(LabelCaptureAdvancedOverlayListenerEvents));
644
+ this._proxy.eventEmitter.on(LabelCaptureAdvancedOverlayListenerEvents.viewForLabel, this.handleViewForLabel.bind(this));
645
+ this._proxy.eventEmitter.on(LabelCaptureAdvancedOverlayListenerEvents.anchorForLabel, this.handleAnchorForLabel.bind(this));
646
+ this._proxy.eventEmitter.on(LabelCaptureAdvancedOverlayListenerEvents.offsetForLabel, this.handleOffsetForLabel.bind(this));
647
+ this._proxy.eventEmitter.on(LabelCaptureAdvancedOverlayListenerEvents.viewForCapturedLabelField, this.handleViewForCapturedLabelField.bind(this));
648
+ this._proxy.eventEmitter.on(LabelCaptureAdvancedOverlayListenerEvents.anchorForCapturedLabelField, this.handleAnchorForCapturedLabelField.bind(this));
649
+ this._proxy.eventEmitter.on(LabelCaptureAdvancedOverlayListenerEvents.offsetForCapturedLabelField, this.handleOffsetForCapturedLabelField.bind(this));
650
+ }
651
+ handleViewForLabel(ev) {
652
+ return __awaiter(this, void 0, void 0, function* () {
643
653
  const payload = JSON.parse(ev.data);
644
654
  let view = null;
645
655
  const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
@@ -648,7 +658,9 @@ class LabelCaptureAdvancedOverlayController extends BaseController {
648
658
  }
649
659
  yield this.setViewForCapturedLabel(label, view);
650
660
  });
651
- this._proxy.on$anchorForLabel = (ev) => __awaiter(this, void 0, void 0, function* () {
661
+ }
662
+ handleAnchorForLabel(ev) {
663
+ return __awaiter(this, void 0, void 0, function* () {
652
664
  const payload = JSON.parse(ev.data);
653
665
  let anchor = Anchor.Center;
654
666
  const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
@@ -657,16 +669,9 @@ class LabelCaptureAdvancedOverlayController extends BaseController {
657
669
  }
658
670
  yield this.setAnchorForCapturedLabel(label, anchor);
659
671
  });
660
- this._proxy.on$offsetForLabel = (ev) => __awaiter(this, void 0, void 0, function* () {
661
- const payload = JSON.parse(ev.data);
662
- let offset = PointWithUnit.zero;
663
- const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
664
- if (this.overlay.listener && this.overlay.listener.offsetForCapturedLabel) {
665
- offset = this.overlay.listener.offsetForCapturedLabel(this.overlay, label);
666
- }
667
- yield this.setOffsetForCapturedLabel(label, offset);
668
- });
669
- this._proxy.on$viewForCapturedLabelField = (ev) => __awaiter(this, void 0, void 0, function* () {
672
+ }
673
+ handleViewForCapturedLabelField(ev) {
674
+ return __awaiter(this, void 0, void 0, function* () {
670
675
  const payload = JSON.parse(ev.data);
671
676
  let view = null;
672
677
  const field = LabelField.fromJSON(JSON.parse(payload.field));
@@ -675,7 +680,20 @@ class LabelCaptureAdvancedOverlayController extends BaseController {
675
680
  }
676
681
  yield this.setViewForCapturedLabelFieldPrivate(payload.identifier, view);
677
682
  });
678
- this._proxy.on$anchorForCapturedLabelField = (ev) => __awaiter(this, void 0, void 0, function* () {
683
+ }
684
+ handleOffsetForLabel(ev) {
685
+ return __awaiter(this, void 0, void 0, function* () {
686
+ const payload = JSON.parse(ev.data);
687
+ let offset = PointWithUnit.zero;
688
+ const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
689
+ if (this.overlay.listener && this.overlay.listener.offsetForCapturedLabel) {
690
+ offset = this.overlay.listener.offsetForCapturedLabel(this.overlay, label);
691
+ }
692
+ yield this.setOffsetForCapturedLabel(label, offset);
693
+ });
694
+ }
695
+ handleAnchorForCapturedLabelField(ev) {
696
+ return __awaiter(this, void 0, void 0, function* () {
679
697
  const payload = JSON.parse(ev.data);
680
698
  let anchor = Anchor.Center;
681
699
  const field = LabelField.fromJSON(JSON.parse(payload.field));
@@ -684,7 +702,9 @@ class LabelCaptureAdvancedOverlayController extends BaseController {
684
702
  }
685
703
  yield this.setAnchorForCapturedLabelFieldPrivate(payload.identifier, anchor);
686
704
  });
687
- this._proxy.on$offsetForCapturedLabelField = (ev) => __awaiter(this, void 0, void 0, function* () {
705
+ }
706
+ handleOffsetForCapturedLabelField(ev) {
707
+ return __awaiter(this, void 0, void 0, function* () {
688
708
  const payload = JSON.parse(ev.data);
689
709
  let offset = PointWithUnit.zero;
690
710
  const field = LabelField.fromJSON(JSON.parse(payload.field));
@@ -695,10 +715,25 @@ class LabelCaptureAdvancedOverlayController extends BaseController {
695
715
  });
696
716
  }
697
717
  unsubscribeListener() {
698
- return this._proxy.$unregisterListenerForAdvancedOverlayEvents();
718
+ this._proxy.$unregisterListenerForAdvancedOverlayEvents({ dataCaptureViewId: this.dataCaptureViewId });
719
+ this._proxy.unsubscribeFromEvents(Object.values(LabelCaptureAdvancedOverlayListenerEvents));
720
+ this._proxy.eventEmitter.off(LabelCaptureAdvancedOverlayListenerEvents.viewForLabel, this.handleViewForLabel.bind(this));
721
+ this._proxy.eventEmitter.off(LabelCaptureAdvancedOverlayListenerEvents.anchorForLabel, this.handleAnchorForLabel.bind(this));
722
+ this._proxy.eventEmitter.off(LabelCaptureAdvancedOverlayListenerEvents.offsetForLabel, this.handleOffsetForLabel.bind(this));
723
+ this._proxy.eventEmitter.off(LabelCaptureAdvancedOverlayListenerEvents.viewForCapturedLabelField, this.handleViewForCapturedLabelField.bind(this));
724
+ this._proxy.eventEmitter.off(LabelCaptureAdvancedOverlayListenerEvents.anchorForCapturedLabelField, this.handleAnchorForCapturedLabelField.bind(this));
725
+ this._proxy.eventEmitter.off(LabelCaptureAdvancedOverlayListenerEvents.offsetForCapturedLabelField, this.handleOffsetForCapturedLabelField.bind(this));
726
+ }
727
+ dispose() {
728
+ this.unsubscribeListener();
729
+ this._proxy.dispose();
699
730
  }
700
731
  updateAdvancedOverlay(advancedOverlayJson) {
701
- return this._proxy.$updateLabelCaptureAdvancedOverlay({ advancedOverlayJson });
732
+ return this._proxy.$updateLabelCaptureAdvancedOverlay({ dataCaptureViewId: this.dataCaptureViewId, advancedOverlayJson });
733
+ }
734
+ get dataCaptureViewId() {
735
+ var _a, _b;
736
+ return (_b = (_a = this.overlay.view) === null || _a === void 0 ? void 0 : _a.viewId) !== null && _b !== void 0 ? _b : -1;
702
737
  }
703
738
  }
704
739
 
@@ -722,6 +757,13 @@ class LabelCaptureAdvancedOverlay extends DefaultSerializeable {
722
757
  this._shouldShowScanAreaGuides = shouldShow;
723
758
  this.proxy.updateAdvancedOverlay(JSON.stringify(this.toJSON()));
724
759
  }
760
+ get listener() {
761
+ return this._listener;
762
+ }
763
+ set listener(listener) {
764
+ this._listener = listener;
765
+ this.hasListener = listener != null;
766
+ }
725
767
  static withLabelCaptureForView(labelCapture, view) {
726
768
  const overlay = new LabelCaptureAdvancedOverlay();
727
769
  overlay.mode = labelCapture;
@@ -733,7 +775,8 @@ class LabelCaptureAdvancedOverlay extends DefaultSerializeable {
733
775
  constructor() {
734
776
  super();
735
777
  this.type = 'labelCaptureAdvanced';
736
- this.listener = null;
778
+ this._listener = null;
779
+ this.hasListener = false;
737
780
  this._shouldShowScanAreaGuides = false;
738
781
  this.proxy = LabelCaptureAdvancedOverlayController.forOverlay(this);
739
782
  }
@@ -770,7 +813,7 @@ __decorate([
770
813
  ], LabelCaptureAdvancedOverlay.prototype, "_view", void 0);
771
814
  __decorate([
772
815
  ignoreFromSerialization
773
- ], LabelCaptureAdvancedOverlay.prototype, "listener", void 0);
816
+ ], LabelCaptureAdvancedOverlay.prototype, "_listener", void 0);
774
817
  __decorate([
775
818
  nameForSerialization('shouldShowScanAreaGuides')
776
819
  ], LabelCaptureAdvancedOverlay.prototype, "_shouldShowScanAreaGuides", void 0);
@@ -874,10 +917,26 @@ class LabelDefinition extends DefaultSerializeable {
874
917
  definition.hiddenProperties = json.hidden_properties;
875
918
  return definition;
876
919
  }
920
+ static createVinLabelDefinition(name) {
921
+ const definition = new LabelDefinition(name);
922
+ definition._type = 'vin';
923
+ return definition;
924
+ }
925
+ static createPriceCaptureDefinition(name) {
926
+ const definition = new LabelDefinition(name);
927
+ definition._type = 'priceCapture';
928
+ return definition;
929
+ }
930
+ static createSevenSegmentDisplayLabelDefinition(name) {
931
+ const definition = new LabelDefinition(name);
932
+ definition._type = 'sevenSegment';
933
+ return definition;
934
+ }
877
935
  constructor(name) {
878
936
  super();
879
937
  this._name = '';
880
938
  this._fields = [];
939
+ this._type = null;
881
940
  this._hiddenProperties = {};
882
941
  this._name = name;
883
942
  }
@@ -888,6 +947,10 @@ __decorate([
888
947
  __decorate([
889
948
  nameForSerialization('fields')
890
949
  ], LabelDefinition.prototype, "_fields", void 0);
950
+ __decorate([
951
+ nameForSerialization('type'),
952
+ ignoreFromSerializationIfNull
953
+ ], LabelDefinition.prototype, "_type", void 0);
891
954
  __decorate([
892
955
  ignoreFromSerialization
893
956
  ], LabelDefinition.prototype, "_hiddenProperties", void 0);
@@ -1155,53 +1218,73 @@ class LabelCaptureBasicOverlayController extends BaseController {
1155
1218
  return this._proxy.$setBrushForFieldOfLabel({
1156
1219
  brushJson: brush ? JSON.stringify(brush.toJSON()) : null,
1157
1220
  fieldName: field.name,
1158
- trackingId: label.trackingID
1221
+ trackingId: label.trackingID,
1222
+ dataCaptureViewId: this.dataCaptureViewId
1159
1223
  });
1160
1224
  }
1161
1225
  setBrushForLabel(brush, label) {
1162
1226
  return this._proxy.$setBrushForLabel({
1163
1227
  brushJson: brush ? JSON.stringify(brush.toJSON()) : null,
1164
- trackingId: label.trackingID
1228
+ trackingId: label.trackingID,
1229
+ dataCaptureViewId: this.dataCaptureViewId
1165
1230
  });
1166
1231
  }
1167
1232
  subscribeListener() {
1168
1233
  return __awaiter(this, void 0, void 0, function* () {
1169
- yield this._proxy.$registerListenerForBasicOverlayEvents();
1170
- this._proxy.on$brushForFieldOfLabel = (ev) => __awaiter(this, void 0, void 0, function* () {
1171
- const payload = JSON.parse(ev.data);
1172
- let brush = this.overlay.capturedFieldBrush;
1173
- const field = LabelField.fromJSON(JSON.parse(payload.field));
1174
- const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
1175
- if (this.overlay.listener && this.overlay.listener.brushForFieldOfLabel) {
1176
- brush = this.overlay.listener.brushForFieldOfLabel(this.overlay, field, label);
1177
- }
1178
- yield this.setBrushForFieldOfLabel(brush, field, label);
1179
- });
1180
- this._proxy.on$brushForLabel = (ev) => __awaiter(this, void 0, void 0, function* () {
1181
- const payload = JSON.parse(ev.data);
1182
- let brush = this.overlay.labelBrush;
1234
+ yield this._proxy.$registerListenerForBasicOverlayEvents({ dataCaptureViewId: this.dataCaptureViewId });
1235
+ this._proxy.subscribeForEvents(Object.values(LabelCaptureBasicOverlayListenerEvents));
1236
+ this._proxy.eventEmitter.on(LabelCaptureBasicOverlayListenerEvents.brushForFieldOfLabel, this.handleBrushForFieldOfLabel.bind(this));
1237
+ this._proxy.eventEmitter.on(LabelCaptureBasicOverlayListenerEvents.brushForLabel, this.handleBrushForLabel.bind(this));
1238
+ this._proxy.eventEmitter.on(LabelCaptureBasicOverlayListenerEvents.didTapLabel, this.handleDidTapLabel.bind(this));
1239
+ });
1240
+ }
1241
+ handleBrushForFieldOfLabel(ev) {
1242
+ return __awaiter(this, void 0, void 0, function* () {
1243
+ const payload = JSON.parse(ev.data);
1244
+ let brush = this.overlay.capturedFieldBrush;
1245
+ const field = LabelField.fromJSON(JSON.parse(payload.field));
1246
+ const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
1247
+ if (this.overlay.listener && this.overlay.listener.brushForFieldOfLabel) {
1248
+ brush = this.overlay.listener.brushForFieldOfLabel(this.overlay, field, label);
1249
+ }
1250
+ yield this.setBrushForFieldOfLabel(brush, field, label);
1251
+ });
1252
+ }
1253
+ handleBrushForLabel(ev) {
1254
+ return __awaiter(this, void 0, void 0, function* () {
1255
+ const payload = JSON.parse(ev.data);
1256
+ let brush = this.overlay.labelBrush;
1257
+ const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
1258
+ if (this.overlay.listener && this.overlay.listener.brushForLabel) {
1259
+ brush = this.overlay.listener.brushForLabel(this.overlay, label);
1260
+ }
1261
+ yield this.setBrushForLabel(brush, label);
1262
+ });
1263
+ }
1264
+ handleDidTapLabel(ev) {
1265
+ return __awaiter(this, void 0, void 0, function* () {
1266
+ const payload = JSON.parse(ev.data);
1267
+ if (this.overlay.listener && this.overlay.listener.didTapLabel) {
1183
1268
  const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
1184
- if (this.overlay.listener && this.overlay.listener.brushForLabel) {
1185
- brush = this.overlay.listener.brushForLabel(this.overlay, label);
1186
- }
1187
- yield this.setBrushForLabel(brush, label);
1188
- });
1189
- this._proxy.on$didTapLabel = (ev) => __awaiter(this, void 0, void 0, function* () {
1190
- const payload = JSON.parse(ev.data);
1191
- if (this.overlay.listener && this.overlay.listener.didTapLabel) {
1192
- const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
1193
- this.overlay.listener.didTapLabel(this.overlay, label);
1194
- }
1195
- });
1269
+ this.overlay.listener.didTapLabel(this.overlay, label);
1270
+ }
1196
1271
  });
1197
1272
  }
1198
1273
  unsubscribeListener() {
1199
1274
  return __awaiter(this, void 0, void 0, function* () {
1200
- yield this._proxy.$unregisterListenerForBasicOverlayEvents();
1275
+ this._proxy.$unregisterListenerForBasicOverlayEvents({ dataCaptureViewId: this.dataCaptureViewId });
1276
+ this._proxy.unsubscribeFromEvents(Object.values(LabelCaptureBasicOverlayListenerEvents));
1277
+ this._proxy.eventEmitter.off(LabelCaptureBasicOverlayListenerEvents.brushForFieldOfLabel, this.handleBrushForFieldOfLabel.bind(this));
1278
+ this._proxy.eventEmitter.off(LabelCaptureBasicOverlayListenerEvents.brushForLabel, this.handleBrushForLabel.bind(this));
1279
+ this._proxy.eventEmitter.off(LabelCaptureBasicOverlayListenerEvents.didTapLabel, this.handleDidTapLabel.bind(this));
1201
1280
  });
1202
1281
  }
1203
1282
  updateBasicOverlay(basicOverlayJson) {
1204
- return this._proxy.$updateLabelCaptureBasicOverlay({ basicOverlayJson });
1283
+ return this._proxy.$updateLabelCaptureBasicOverlay({ dataCaptureViewId: this.dataCaptureViewId, basicOverlayJson });
1284
+ }
1285
+ get dataCaptureViewId() {
1286
+ var _a, _b;
1287
+ return (_b = (_a = this.overlay.view) === null || _a === void 0 ? void 0 : _a.viewId) !== null && _b !== void 0 ? _b : -1;
1205
1288
  }
1206
1289
  }
1207
1290
 
@@ -1251,6 +1334,13 @@ class LabelCaptureBasicOverlay extends DefaultSerializeable {
1251
1334
  this._labelBrush = newBrush;
1252
1335
  this.controller.updateBasicOverlay(JSON.stringify(this.toJSON()));
1253
1336
  }
1337
+ get listener() {
1338
+ return this._listener;
1339
+ }
1340
+ set listener(listener) {
1341
+ this._listener = listener;
1342
+ this.hasListener = listener != null;
1343
+ }
1254
1344
  get shouldShowScanAreaGuides() {
1255
1345
  return this._shouldShowScanAreaGuides;
1256
1346
  }
@@ -1283,7 +1373,8 @@ class LabelCaptureBasicOverlay extends DefaultSerializeable {
1283
1373
  this._capturedFieldBrush = LabelCaptureBasicOverlay.defaultCapturedFieldBrush.copy;
1284
1374
  this._labelBrush = LabelCaptureBasicOverlay.defaultLabelBrush.copy;
1285
1375
  this._shouldShowScanAreaGuides = false;
1286
- this.listener = null;
1376
+ this.hasListener = false;
1377
+ this._listener = null;
1287
1378
  this._viewfinder = null;
1288
1379
  this.controller = LabelCaptureBasicOverlayController.forOverlay(this);
1289
1380
  }
@@ -1314,7 +1405,7 @@ __decorate([
1314
1405
  ], LabelCaptureBasicOverlay.prototype, "_shouldShowScanAreaGuides", void 0);
1315
1406
  __decorate([
1316
1407
  ignoreFromSerialization
1317
- ], LabelCaptureBasicOverlay.prototype, "listener", void 0);
1408
+ ], LabelCaptureBasicOverlay.prototype, "_listener", void 0);
1318
1409
  __decorate([
1319
1410
  ignoreFromSerialization
1320
1411
  ], LabelCaptureBasicOverlay.prototype, "controller", void 0);
@@ -1323,5 +1414,201 @@ __decorate([
1323
1414
  nameForSerialization('viewfinder')
1324
1415
  ], LabelCaptureBasicOverlay.prototype, "_viewfinder", void 0);
1325
1416
 
1326
- export { BarcodeField, CapturedLabel, CustomBarcode, CustomText, ExpiryDateText, ImeiOneBarcode, ImeiTwoBarcode, LabelCapture, LabelCaptureAdvancedOverlay, LabelCaptureAdvancedOverlayController, LabelCaptureAdvancedOverlayListenerEvents, LabelCaptureBasicOverlay, LabelCaptureBasicOverlayController, LabelCaptureBasicOverlayListenerEvents, LabelCaptureController, LabelCaptureListenerController, LabelCaptureListenerEvents, LabelCaptureSession, LabelCaptureSettings, LabelDateComponentFormat, LabelDateFormat, LabelDateResult, LabelDefinition, LabelField, LabelFieldDefinition, LabelFieldLocation, LabelFieldLocationType, LabelFieldState, LabelFieldType, PackingDateText, PartNumberBarcode, SerialNumberBarcode, TextField, TotalPriceText, UnitPriceText, WeightText, getLabelCaptureDefaults, loadLabelCaptureDefaults };
1417
+ var LabelCaptureValidationFlowListenerEvents;
1418
+ (function (LabelCaptureValidationFlowListenerEvents) {
1419
+ LabelCaptureValidationFlowListenerEvents["didCaptureLabelWithFields"] = "LabelCaptureValidationFlowListener.didCaptureLabelWithFields";
1420
+ })(LabelCaptureValidationFlowListenerEvents || (LabelCaptureValidationFlowListenerEvents = {}));
1421
+ class LabelCaptureValidationFlowOverlayController extends BaseController {
1422
+ constructor() {
1423
+ super('LabelCaptureValidationFlowOverlayProxy');
1424
+ this.isSubscribed = false;
1425
+ }
1426
+ static forOverlay(overlay) {
1427
+ const proxy = new LabelCaptureValidationFlowOverlayController();
1428
+ proxy.overlay = overlay;
1429
+ return proxy;
1430
+ }
1431
+ updateValidationFlowOverlay() {
1432
+ return __awaiter(this, void 0, void 0, function* () {
1433
+ yield this._proxy.$updateLabelCaptureValidationFlowOverlay({ dataCaptureViewId: this.dataCaptureViewId, overlayJson: JSON.stringify(this.overlay.toJSON()) });
1434
+ });
1435
+ }
1436
+ subscribeLabelCaptureValidationFlowListener() {
1437
+ if (this.isSubscribed) {
1438
+ return;
1439
+ }
1440
+ this._proxy.$registerListenerForValidationFlowEvents({ dataCaptureViewId: this.dataCaptureViewId });
1441
+ this._proxy.subscribeForEvents(Object.values(LabelCaptureValidationFlowListenerEvents));
1442
+ this._proxy.eventEmitter.on(LabelCaptureValidationFlowListenerEvents.didCaptureLabelWithFields, this.handleDidCaptureLabelWithFieldsEvent.bind(this));
1443
+ this.isSubscribed = true;
1444
+ }
1445
+ unsubscribeLabelCaptureValidationFlowListener() {
1446
+ if (!this.isSubscribed) {
1447
+ return;
1448
+ }
1449
+ this._proxy.$unregisterListenerForValidationFlowEvents({ dataCaptureViewId: this.dataCaptureViewId });
1450
+ this._proxy.eventEmitter.off(LabelCaptureValidationFlowListenerEvents.didCaptureLabelWithFields, this.handleDidCaptureLabelWithFieldsEvent.bind(this));
1451
+ this._proxy.unsubscribeFromEvents(Object.values(LabelCaptureValidationFlowListenerEvents));
1452
+ this.isSubscribed = false;
1453
+ }
1454
+ handleDidCaptureLabelWithFieldsEvent(ev) {
1455
+ return __awaiter(this, void 0, void 0, function* () {
1456
+ const payload = JSON.parse(ev.data);
1457
+ const fields = payload.fields.map((field) => LabelField.fromJSON(JSON.parse(field)));
1458
+ this.notifyListenersOfDidCaptureLabelWithFields(fields);
1459
+ });
1460
+ }
1461
+ notifyListenersOfDidCaptureLabelWithFields(fields) {
1462
+ var _a;
1463
+ (_a = this.overlay.listener) === null || _a === void 0 ? void 0 : _a.didCaptureLabelWithFields(fields);
1464
+ }
1465
+ get dataCaptureViewId() {
1466
+ var _a, _b;
1467
+ return (_b = (_a = this.overlay.view) === null || _a === void 0 ? void 0 : _a.viewId) !== null && _b !== void 0 ? _b : -1;
1468
+ }
1469
+ dispose() {
1470
+ this.unsubscribeLabelCaptureValidationFlowListener();
1471
+ this._proxy.dispose();
1472
+ }
1473
+ }
1474
+
1475
+ 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
+ get view() {
1486
+ return this._view;
1487
+ }
1488
+ static withLabelCaptureForView(labelCapture, view) {
1489
+ const overlay = new LabelCaptureValidationFlowOverlay();
1490
+ overlay.mode = labelCapture;
1491
+ overlay.view = view;
1492
+ if (view) {
1493
+ view.addOverlay(overlay);
1494
+ }
1495
+ return overlay;
1496
+ }
1497
+ get listener() {
1498
+ return this._listener;
1499
+ }
1500
+ set listener(listener) {
1501
+ this.hasListener = listener != null;
1502
+ if (this.view == null) {
1503
+ this._listener = listener;
1504
+ return;
1505
+ }
1506
+ if (listener == null) {
1507
+ this.controller.unsubscribeLabelCaptureValidationFlowListener();
1508
+ }
1509
+ else if (this.listener == null) {
1510
+ this.controller.subscribeLabelCaptureValidationFlowListener();
1511
+ }
1512
+ this._listener = listener;
1513
+ }
1514
+ applySettings(settings) {
1515
+ this.settings = settings;
1516
+ return this.controller.updateValidationFlowOverlay();
1517
+ }
1518
+ constructor() {
1519
+ super();
1520
+ this.type = 'validationFlow';
1521
+ this.settings = null;
1522
+ this.hasListener = false;
1523
+ this._listener = null;
1524
+ this.controller = LabelCaptureValidationFlowOverlayController.forOverlay(this);
1525
+ }
1526
+ }
1527
+ __decorate([
1528
+ ignoreFromSerialization
1529
+ ], LabelCaptureValidationFlowOverlay.prototype, "mode", void 0);
1530
+ __decorate([
1531
+ ignoreFromSerialization
1532
+ ], LabelCaptureValidationFlowOverlay.prototype, "_view", void 0);
1533
+ __decorate([
1534
+ nameForSerialization('hasListener')
1535
+ ], LabelCaptureValidationFlowOverlay.prototype, "hasListener", void 0);
1536
+ __decorate([
1537
+ ignoreFromSerialization
1538
+ ], LabelCaptureValidationFlowOverlay.prototype, "_listener", void 0);
1539
+ __decorate([
1540
+ ignoreFromSerialization
1541
+ ], LabelCaptureValidationFlowOverlay.prototype, "controller", void 0);
1542
+
1543
+ class LabelCaptureValidationFlowSettings extends DefaultSerializeable {
1544
+ static create() {
1545
+ return new LabelCaptureValidationFlowSettings();
1546
+ }
1547
+ constructor() {
1548
+ super();
1549
+ const defaults = getLabelCaptureDefaults().LabelCapture.LabelCaptureValidationFlowOverlay.Settings;
1550
+ this._missingFieldsHintText = defaults.missingFieldsHintText;
1551
+ this._standbyHintText = defaults.standbyHintText;
1552
+ this._validationHintText = defaults.validationHintText;
1553
+ this._validationErrorText = defaults.validationErrorText;
1554
+ this._requiredFieldErrorText = defaults.requiredFieldErrorText;
1555
+ this._manualInputButtonText = defaults.manualInputButtonText;
1556
+ }
1557
+ get missingFieldsHintText() {
1558
+ return this._missingFieldsHintText;
1559
+ }
1560
+ set missingFieldsHintText(text) {
1561
+ this._missingFieldsHintText = text;
1562
+ }
1563
+ get standbyHintText() {
1564
+ return this._standbyHintText;
1565
+ }
1566
+ set standbyHintText(text) {
1567
+ this._standbyHintText = text;
1568
+ }
1569
+ get validationHintText() {
1570
+ return this._validationHintText;
1571
+ }
1572
+ set validationHintText(text) {
1573
+ this._validationHintText = text;
1574
+ }
1575
+ get validationErrorText() {
1576
+ return this._validationErrorText;
1577
+ }
1578
+ set validationErrorText(text) {
1579
+ this._validationErrorText = text;
1580
+ }
1581
+ get requiredFieldErrorText() {
1582
+ return this._requiredFieldErrorText;
1583
+ }
1584
+ set requiredFieldErrorText(text) {
1585
+ this._requiredFieldErrorText = text;
1586
+ }
1587
+ get manualInputButtonText() {
1588
+ return this._manualInputButtonText;
1589
+ }
1590
+ set manualInputButtonText(text) {
1591
+ this._manualInputButtonText = text;
1592
+ }
1593
+ }
1594
+ __decorate([
1595
+ nameForSerialization('missingFieldsHintText')
1596
+ ], LabelCaptureValidationFlowSettings.prototype, "_missingFieldsHintText", void 0);
1597
+ __decorate([
1598
+ nameForSerialization('standbyHintText')
1599
+ ], LabelCaptureValidationFlowSettings.prototype, "_standbyHintText", void 0);
1600
+ __decorate([
1601
+ nameForSerialization('validationHintText')
1602
+ ], LabelCaptureValidationFlowSettings.prototype, "_validationHintText", void 0);
1603
+ __decorate([
1604
+ nameForSerialization('validationErrorText')
1605
+ ], LabelCaptureValidationFlowSettings.prototype, "_validationErrorText", void 0);
1606
+ __decorate([
1607
+ nameForSerialization('requiredFieldErrorText')
1608
+ ], LabelCaptureValidationFlowSettings.prototype, "_requiredFieldErrorText", void 0);
1609
+ __decorate([
1610
+ nameForSerialization('manualInputButtonText')
1611
+ ], LabelCaptureValidationFlowSettings.prototype, "_manualInputButtonText", void 0);
1612
+
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 };
1327
1614
  //# sourceMappingURL=index.js.map