scandit-datacapture-frameworks-core 6.22.1 → 6.23.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
@@ -803,6 +803,13 @@ class Camera extends DefaultSerializeable {
803
803
  return null;
804
804
  }
805
805
  }
806
+ static withSettings(settings) {
807
+ const camera = Camera.default;
808
+ if (camera) {
809
+ camera.settings = settings;
810
+ }
811
+ return camera;
812
+ }
806
813
  static atPosition(cameraPosition) {
807
814
  if (Camera.coreDefaults.Camera.availablePositions.includes(cameraPosition)) {
808
815
  const camera = new Camera();
@@ -908,227 +915,305 @@ __decorate([
908
915
  ignoreFromSerialization
909
916
  ], Camera, "coreDefaults", null);
910
917
 
911
- class ZoomSwitchControl extends DefaultSerializeable {
912
- constructor() {
913
- super(...arguments);
914
- this.type = 'zoom';
915
- this.icon = {
916
- zoomedOut: { default: null, pressed: null },
917
- zoomedIn: { default: null, pressed: null },
918
- };
919
- this.view = null;
920
- this.anchor = null;
921
- this.offset = null;
918
+ class ControlImage extends DefaultSerializeable {
919
+ constructor(type, data, name) {
920
+ super();
921
+ this.type = type;
922
+ this._data = data;
923
+ this._name = name;
922
924
  }
923
- get zoomedOutImage() {
924
- return this.icon.zoomedOut.default;
925
+ static fromBase64EncodedImage(data) {
926
+ if (data === null)
927
+ return null;
928
+ return new ControlImage("base64", data, null);
925
929
  }
926
- set zoomedOutImage(zoomedOutImage) {
927
- var _a;
928
- this.icon.zoomedOut.default = zoomedOutImage;
929
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
930
+ static fromResourceName(resource) {
931
+ return new ControlImage("resource", null, resource);
930
932
  }
931
- get zoomedInImage() {
932
- return this.icon.zoomedIn.default;
933
+ isBase64EncodedImage() {
934
+ return this.type === "base64";
933
935
  }
934
- set zoomedInImage(zoomedInImage) {
935
- var _a;
936
- this.icon.zoomedIn.default = zoomedInImage;
937
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
936
+ get data() {
937
+ return this._data;
938
938
  }
939
- get zoomedInPressedImage() {
940
- return this.icon.zoomedIn.pressed;
939
+ }
940
+ __decorate([
941
+ ignoreFromSerializationIfNull,
942
+ nameForSerialization('data')
943
+ ], ControlImage.prototype, "_data", void 0);
944
+ __decorate([
945
+ ignoreFromSerializationIfNull,
946
+ nameForSerialization('name')
947
+ ], ControlImage.prototype, "_name", void 0);
948
+
949
+ class ContextStatus {
950
+ static fromJSON(json) {
951
+ const status = new ContextStatus();
952
+ status._code = json.code;
953
+ status._message = json.message;
954
+ status._isValid = json.isValid;
955
+ return status;
941
956
  }
942
- set zoomedInPressedImage(zoomedInPressedImage) {
943
- var _a;
944
- this.icon.zoomedIn.pressed = zoomedInPressedImage;
945
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
957
+ get message() {
958
+ return this._message;
946
959
  }
947
- get zoomedOutPressedImage() {
948
- return this.icon.zoomedOut.pressed;
960
+ get code() {
961
+ return this._code;
949
962
  }
950
- set zoomedOutPressedImage(zoomedOutPressedImage) {
951
- var _a;
952
- this.icon.zoomedOut.pressed = zoomedOutPressedImage;
953
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
963
+ get isValid() {
964
+ return this._isValid;
954
965
  }
955
966
  }
956
- __decorate([
957
- ignoreFromSerialization
958
- ], ZoomSwitchControl.prototype, "view", void 0);
959
967
 
960
- class TorchSwitchControl extends DefaultSerializeable {
968
+ class DataCaptureContextSettings extends DefaultSerializeable {
961
969
  constructor() {
962
- super(...arguments);
963
- this.type = 'torch';
964
- this.icon = {
965
- on: { default: null, pressed: null },
966
- off: { default: null, pressed: null },
967
- };
968
- this.view = null;
969
- this.anchor = null;
970
- this.offset = null;
970
+ super();
971
971
  }
972
- get torchOffImage() {
973
- return this.icon.off.default;
972
+ setProperty(name, value) {
973
+ this[name] = value;
974
974
  }
975
- set torchOffImage(torchOffImage) {
976
- var _a;
977
- this.icon.off.default = torchOffImage;
978
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
975
+ getProperty(name) {
976
+ return this[name];
979
977
  }
980
- get torchOffPressedImage() {
981
- return this.icon.off.pressed;
978
+ }
979
+
980
+ var DataCaptureContextEvents;
981
+ (function (DataCaptureContextEvents) {
982
+ DataCaptureContextEvents["didChangeStatus"] = "didChangeStatus";
983
+ DataCaptureContextEvents["didStartObservingContext"] = "didStartObservingContext";
984
+ })(DataCaptureContextEvents || (DataCaptureContextEvents = {}));
985
+ class DataCaptureContextController {
986
+ get framework() {
987
+ return this._proxy.framework;
982
988
  }
983
- set torchOffPressedImage(torchOffPressedImage) {
984
- var _a;
985
- this.icon.off.pressed = torchOffPressedImage;
986
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
989
+ get frameworkVersion() {
990
+ return this._proxy.frameworkVersion;
987
991
  }
988
- get torchOnImage() {
989
- return this.icon.on.default;
992
+ get privateContext() {
993
+ return this.context;
990
994
  }
991
- set torchOnImage(torchOnImage) {
992
- var _a;
993
- this.icon.on.default = torchOnImage;
994
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
995
+ static forDataCaptureContext(context) {
996
+ const controller = new DataCaptureContextController();
997
+ controller.context = context;
998
+ controller.initialize();
999
+ return controller;
995
1000
  }
996
- get torchOnPressedImage() {
997
- return this.icon.on.pressed;
1001
+ constructor() {
1002
+ this._proxy = FactoryMaker.getInstance('DataCaptureContextProxy');
1003
+ this.eventEmitter = FactoryMaker.getInstance('EventEmitter');
998
1004
  }
999
- set torchOnPressedImage(torchOnPressedImage) {
1000
- var _a;
1001
- this.icon.on.pressed = torchOnPressedImage;
1002
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
1005
+ updateContextFromJSON() {
1006
+ return __awaiter(this, void 0, void 0, function* () {
1007
+ try {
1008
+ yield this._proxy.updateContextFromJSON(this.context);
1009
+ }
1010
+ catch (error) {
1011
+ this.notifyListenersOfDeserializationError(error);
1012
+ throw error;
1013
+ }
1014
+ });
1003
1015
  }
1004
- }
1005
- __decorate([
1006
- ignoreFromSerialization
1007
- ], TorchSwitchControl.prototype, "view", void 0);
1008
-
1009
- var VideoResolution;
1010
- (function (VideoResolution) {
1011
- VideoResolution["Auto"] = "auto";
1012
- VideoResolution["HD"] = "hd";
1013
- VideoResolution["FullHD"] = "fullHd";
1014
- VideoResolution["UHD4K"] = "uhd4k";
1015
- })(VideoResolution || (VideoResolution = {}));
1016
-
1017
- var FocusRange;
1018
- (function (FocusRange) {
1019
- FocusRange["Full"] = "full";
1020
- FocusRange["Near"] = "near";
1021
- FocusRange["Far"] = "far";
1022
- })(FocusRange || (FocusRange = {}));
1023
-
1024
- var FocusGestureStrategy;
1025
- (function (FocusGestureStrategy) {
1026
- FocusGestureStrategy["None"] = "none";
1027
- FocusGestureStrategy["Manual"] = "manual";
1028
- FocusGestureStrategy["ManualUntilCapture"] = "manualUntilCapture";
1029
- FocusGestureStrategy["AutoOnLocation"] = "autoOnLocation";
1030
- })(FocusGestureStrategy || (FocusGestureStrategy = {}));
1031
-
1032
- var LogoStyle;
1033
- (function (LogoStyle) {
1034
- LogoStyle["Minimal"] = "minimal";
1035
- LogoStyle["Extended"] = "extended";
1036
- })(LogoStyle || (LogoStyle = {}));
1037
-
1038
- class CameraSettings extends DefaultSerializeable {
1039
- static get coreDefaults() {
1040
- return getCoreDefaults();
1016
+ addModeToContext(mode) {
1017
+ return this._proxy.addModeToContext(JSON.stringify(mode.toJSON()));
1041
1018
  }
1042
- get focusRange() {
1043
- return this.focus.range;
1019
+ removeModeFromContext(mode) {
1020
+ return this._proxy.removeModeFromContext(JSON.stringify(mode.toJSON()));
1044
1021
  }
1045
- set focusRange(newRange) {
1046
- this.focus.range = newRange;
1022
+ removeAllModesFromContext() {
1023
+ return this._proxy.removeAllModesFromContext();
1047
1024
  }
1048
- get focusGestureStrategy() {
1049
- return this.focus.focusGestureStrategy;
1025
+ dispose() {
1026
+ this.unsubscribeListener();
1027
+ this._proxy.dispose();
1050
1028
  }
1051
- set focusGestureStrategy(newStrategy) {
1052
- this.focus.focusGestureStrategy = newStrategy;
1029
+ unsubscribeListener() {
1030
+ this._proxy.unsubscribeListener();
1031
+ this.eventEmitter.removeListener(DataCaptureContextEvents.didChangeStatus);
1032
+ this.eventEmitter.removeListener(DataCaptureContextEvents.didStartObservingContext);
1053
1033
  }
1054
- get shouldPreferSmoothAutoFocus() {
1055
- return this.focus.shouldPreferSmoothAutoFocus;
1034
+ initialize() {
1035
+ this.subscribeListener();
1036
+ return this.initializeContextFromJSON();
1056
1037
  }
1057
- set shouldPreferSmoothAutoFocus(newShouldPreferSmoothAutoFocus) {
1058
- this.focus.shouldPreferSmoothAutoFocus = newShouldPreferSmoothAutoFocus;
1038
+ initializeContextFromJSON() {
1039
+ return __awaiter(this, void 0, void 0, function* () {
1040
+ try {
1041
+ this._proxy.contextFromJSON(this.context);
1042
+ }
1043
+ catch (error) {
1044
+ this.notifyListenersOfDeserializationError(error);
1045
+ throw error;
1046
+ }
1047
+ });
1059
1048
  }
1060
- get maxFrameRate() {
1061
- // tslint:disable-next-line:no-console
1062
- console.warn('maxFrameRate is deprecated');
1063
- return 0;
1049
+ subscribeListener() {
1050
+ var _a, _b, _c, _d;
1051
+ this._proxy.registerListenerForEvents();
1052
+ (_b = (_a = this._proxy).subscribeDidChangeStatus) === null || _b === void 0 ? void 0 : _b.call(_a);
1053
+ (_d = (_c = this._proxy).subscribeDidStartObservingContext) === null || _d === void 0 ? void 0 : _d.call(_c);
1054
+ this.eventEmitter.on(DataCaptureContextEvents.didChangeStatus, (contextStatus) => {
1055
+ this.notifyListenersOfDidChangeStatus(contextStatus);
1056
+ });
1057
+ this.eventEmitter.on(DataCaptureContextEvents.didStartObservingContext, () => {
1058
+ this.privateContext.listeners.forEach(listener => {
1059
+ var _a;
1060
+ (_a = listener.didStartObservingContext) === null || _a === void 0 ? void 0 : _a.call(listener, this.context);
1061
+ });
1062
+ });
1064
1063
  }
1065
- set maxFrameRate(newValue) {
1066
- // tslint:disable-next-line:no-console
1067
- console.warn('maxFrameRate is deprecated');
1064
+ notifyListenersOfDeserializationError(error) {
1065
+ const contextStatus = ContextStatus
1066
+ .fromJSON({
1067
+ message: error,
1068
+ code: -1,
1069
+ isValid: true,
1070
+ });
1071
+ this.notifyListenersOfDidChangeStatus(contextStatus);
1068
1072
  }
1069
- static fromJSON(json) {
1070
- const settings = new CameraSettings();
1071
- settings.preferredResolution = json.preferredResolution;
1072
- settings.zoomFactor = json.zoomFactor;
1073
- settings.focusRange = json.focusRange;
1074
- settings.zoomGestureZoomFactor = json.zoomGestureZoomFactor;
1075
- settings.focusGestureStrategy = json.focusGestureStrategy;
1076
- settings.shouldPreferSmoothAutoFocus = json.shouldPreferSmoothAutoFocus;
1077
- if (json.properties !== undefined) {
1078
- for (const key of Object.keys(json.properties)) {
1079
- settings.setProperty(key, json.properties[key]);
1073
+ notifyListenersOfDidChangeStatus(contextStatus) {
1074
+ this.privateContext.listeners.forEach(listener => {
1075
+ if (listener.didChangeStatus) {
1076
+ listener.didChangeStatus(this.context, contextStatus);
1080
1077
  }
1081
- }
1082
- return settings;
1078
+ });
1083
1079
  }
1084
- constructor(settings) {
1085
- super();
1086
- this.focusHiddenProperties = [
1087
- 'range',
1088
- 'manualLensPosition',
1089
- 'shouldPreferSmoothAutoFocus',
1090
- 'focusStrategy',
1091
- 'focusGestureStrategy'
1092
- ];
1093
- this.preferredResolution = CameraSettings.coreDefaults.Camera.Settings.preferredResolution;
1094
- this.zoomFactor = CameraSettings.coreDefaults.Camera.Settings.zoomFactor;
1095
- this.zoomGestureZoomFactor = CameraSettings.coreDefaults.Camera.Settings.zoomGestureZoomFactor;
1096
- this.focus = {
1097
- range: CameraSettings.coreDefaults.Camera.Settings.focusRange,
1098
- focusGestureStrategy: CameraSettings.coreDefaults.Camera.Settings.focusGestureStrategy,
1099
- shouldPreferSmoothAutoFocus: CameraSettings.coreDefaults.Camera.Settings.shouldPreferSmoothAutoFocus
1100
- };
1101
- this.preferredResolution = CameraSettings.coreDefaults.Camera.Settings.preferredResolution;
1102
- this.zoomFactor = CameraSettings.coreDefaults.Camera.Settings.zoomFactor;
1103
- this.zoomGestureZoomFactor = CameraSettings.coreDefaults.Camera.Settings.zoomGestureZoomFactor;
1104
- this.focus = {
1105
- range: CameraSettings.coreDefaults.Camera.Settings.focusRange,
1106
- focusGestureStrategy: CameraSettings.coreDefaults.Camera.Settings.focusGestureStrategy,
1107
- shouldPreferSmoothAutoFocus: CameraSettings.coreDefaults.Camera.Settings.shouldPreferSmoothAutoFocus,
1108
- };
1109
- if (settings !== undefined && settings !== null) {
1110
- Object.getOwnPropertyNames(settings).forEach(propertyName => {
1111
- this[propertyName] = settings[propertyName];
1112
- });
1080
+ }
1081
+
1082
+ class DataCaptureContext extends DefaultSerializeable {
1083
+ get framework() {
1084
+ return this.controller.framework;
1085
+ }
1086
+ get frameworkVersion() {
1087
+ return this.controller.frameworkVersion;
1088
+ }
1089
+ static get coreDefaults() {
1090
+ return getCoreDefaults();
1091
+ }
1092
+ get frameSource() {
1093
+ return this._frameSource;
1094
+ }
1095
+ static get deviceID() {
1096
+ return DataCaptureContext.coreDefaults.deviceID;
1097
+ }
1098
+ /**
1099
+ * @deprecated
1100
+ */
1101
+ get deviceID() {
1102
+ console.log('The instance property "deviceID" on the DataCaptureContext is deprecated, please use the static property DataCaptureContext.deviceID instead.');
1103
+ return DataCaptureContext.deviceID;
1104
+ }
1105
+ static forLicenseKey(licenseKey) {
1106
+ return DataCaptureContext.forLicenseKeyWithOptions(licenseKey, null);
1107
+ }
1108
+ static forLicenseKeyWithSettings(licenseKey, settings) {
1109
+ const context = this.forLicenseKey(licenseKey);
1110
+ if (settings !== null) {
1111
+ context.applySettings(settings);
1112
+ }
1113
+ return context;
1114
+ }
1115
+ static forLicenseKeyWithOptions(licenseKey, options) {
1116
+ if (options == null) {
1117
+ options = { deviceName: null };
1113
1118
  }
1119
+ return new DataCaptureContext(licenseKey, options.deviceName || '');
1114
1120
  }
1115
- setProperty(name, value) {
1116
- if (this.focusHiddenProperties.includes(name)) {
1117
- this.focus[name] = value;
1121
+ constructor(licenseKey, deviceName) {
1122
+ super();
1123
+ this.licenseKey = licenseKey;
1124
+ this.deviceName = deviceName;
1125
+ this.settings = new DataCaptureContextSettings();
1126
+ this._frameSource = null;
1127
+ this.view = null;
1128
+ this.modes = [];
1129
+ this.listeners = [];
1130
+ this.initialize();
1131
+ }
1132
+ setFrameSource(frameSource) {
1133
+ if (this._frameSource) {
1134
+ this._frameSource.context = null;
1135
+ }
1136
+ this._frameSource = frameSource;
1137
+ if (frameSource) {
1138
+ frameSource.context = this;
1139
+ }
1140
+ return this.update();
1141
+ }
1142
+ addListener(listener) {
1143
+ if (this.listeners.includes(listener)) {
1118
1144
  return;
1119
1145
  }
1120
- this[name] = value;
1146
+ this.listeners.push(listener);
1121
1147
  }
1122
- getProperty(name) {
1123
- if (this.focusHiddenProperties.includes(name)) {
1124
- return this.focus[name];
1148
+ removeListener(listener) {
1149
+ if (!this.listeners.includes(listener)) {
1150
+ return;
1125
1151
  }
1126
- return this[name];
1152
+ this.listeners.splice(this.listeners.indexOf(listener), 1);
1153
+ }
1154
+ addMode(mode) {
1155
+ if (!this.modes.includes(mode)) {
1156
+ this.modes.push(mode);
1157
+ mode._context = this;
1158
+ this.controller.addModeToContext(mode);
1159
+ }
1160
+ }
1161
+ removeMode(mode) {
1162
+ if (this.modes.includes(mode)) {
1163
+ this.modes.splice(this.modes.indexOf(mode), 1);
1164
+ mode._context = null;
1165
+ this.controller.removeModeFromContext(mode);
1166
+ }
1167
+ }
1168
+ removeAllModes() {
1169
+ this.modes.forEach(mode => {
1170
+ mode._context = null;
1171
+ });
1172
+ this.modes = [];
1173
+ this.controller.removeAllModesFromContext();
1174
+ }
1175
+ dispose() {
1176
+ var _a;
1177
+ if (!this.controller) {
1178
+ return;
1179
+ }
1180
+ (_a = this.view) === null || _a === void 0 ? void 0 : _a.dispose();
1181
+ this.removeAllModes();
1182
+ this.controller.dispose();
1183
+ }
1184
+ applySettings(settings) {
1185
+ this.settings = settings;
1186
+ return this.update();
1187
+ }
1188
+ // Called when the capture view is shown, that is the earliest point that we need the context deserialized.
1189
+ initialize() {
1190
+ if (this.controller) {
1191
+ return;
1192
+ }
1193
+ this.controller = DataCaptureContextController.forDataCaptureContext(this);
1194
+ }
1195
+ update() {
1196
+ if (!this.controller) {
1197
+ return Promise.resolve();
1198
+ }
1199
+ return this.controller.updateContextFromJSON();
1127
1200
  }
1128
1201
  }
1202
+ __decorate([
1203
+ nameForSerialization('frameSource')
1204
+ ], DataCaptureContext.prototype, "_frameSource", void 0);
1129
1205
  __decorate([
1130
1206
  ignoreFromSerialization
1131
- ], CameraSettings.prototype, "focusHiddenProperties", void 0);
1207
+ ], DataCaptureContext.prototype, "modes", void 0);
1208
+ __decorate([
1209
+ ignoreFromSerialization
1210
+ ], DataCaptureContext.prototype, "controller", void 0);
1211
+ __decorate([
1212
+ ignoreFromSerialization
1213
+ ], DataCaptureContext.prototype, "listeners", void 0);
1214
+ __decorate([
1215
+ ignoreFromSerialization
1216
+ ], DataCaptureContext, "coreDefaults", null);
1132
1217
 
1133
1218
  class Point extends DefaultSerializeable {
1134
1219
  get x() {
@@ -1640,563 +1725,885 @@ var Direction;
1640
1725
  Direction["BottomToTop"] = "bottomToTop";
1641
1726
  })(Direction || (Direction = {}));
1642
1727
 
1643
- const NoViewfinder = { type: 'none' };
1644
-
1645
- class RectangularViewfinderAnimation extends DefaultSerializeable {
1646
- static fromJSON(json) {
1647
- if (json === null) {
1648
- return null;
1649
- }
1650
- return new RectangularViewfinderAnimation(json.looping);
1728
+ var DataCaptureViewEvents;
1729
+ (function (DataCaptureViewEvents) {
1730
+ DataCaptureViewEvents["didChangeSize"] = "didChangeSize";
1731
+ })(DataCaptureViewEvents || (DataCaptureViewEvents = {}));
1732
+ class DataCaptureViewController extends BaseController {
1733
+ static forDataCaptureView(view) {
1734
+ const controller = new DataCaptureViewController();
1735
+ controller.view = view;
1736
+ controller.createView();
1737
+ controller.subscribeListener();
1738
+ return controller;
1651
1739
  }
1652
- get isLooping() {
1653
- return this._isLooping;
1740
+ constructor() {
1741
+ super('DataCaptureViewProxy');
1654
1742
  }
1655
- constructor(isLooping) {
1656
- super();
1657
- this._isLooping = false;
1658
- this._isLooping = isLooping;
1743
+ viewPointForFramePoint(point) {
1744
+ return __awaiter(this, void 0, void 0, function* () {
1745
+ const jsonString = yield this._proxy.viewPointForFramePoint(JSON.stringify(point.toJSON()));
1746
+ return Point.fromJSON(JSON.parse(jsonString));
1747
+ });
1659
1748
  }
1660
- }
1661
- __decorate([
1662
- nameForSerialization('isLooping')
1663
- ], RectangularViewfinderAnimation.prototype, "_isLooping", void 0);
1664
-
1665
- class SpotlightViewfinder extends DefaultSerializeable {
1666
- get sizeWithUnitAndAspect() {
1667
- return this._sizeWithUnitAndAspect;
1749
+ viewQuadrilateralForFrameQuadrilateral(quadrilateral) {
1750
+ return __awaiter(this, void 0, void 0, function* () {
1751
+ const jsonString = yield this._proxy.viewQuadrilateralForFrameQuadrilateral(JSON.stringify(quadrilateral.toJSON()));
1752
+ return Quadrilateral.fromJSON(JSON.parse(jsonString));
1753
+ });
1668
1754
  }
1669
- get coreDefaults() {
1670
- return getCoreDefaults();
1755
+ setPositionAndSize(top, left, width, height, shouldBeUnderWebView) {
1756
+ return this._proxy.setPositionAndSize(top, left, width, height, shouldBeUnderWebView);
1671
1757
  }
1672
- constructor() {
1673
- super();
1674
- this.type = 'spotlight';
1675
- console.warn('SpotlightViewfinder is deprecated and will be removed in a future release. Use RectangularViewfinder instead.');
1676
- this._sizeWithUnitAndAspect = this.coreDefaults.SpotlightViewfinder.size;
1677
- this.enabledBorderColor = this.coreDefaults.SpotlightViewfinder.enabledBorderColor;
1678
- this.disabledBorderColor = this.coreDefaults.SpotlightViewfinder.disabledBorderColor;
1679
- this.backgroundColor = this.coreDefaults.SpotlightViewfinder.backgroundColor;
1758
+ show() {
1759
+ return this._proxy.show();
1680
1760
  }
1681
- setSize(size) {
1682
- this._sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithWidthAndHeight(size);
1761
+ hide() {
1762
+ return this._proxy.hide();
1683
1763
  }
1684
- setWidthAndAspectRatio(width, heightToWidthAspectRatio) {
1685
- this._sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithWidthAndAspectRatio(width, heightToWidthAspectRatio);
1764
+ createView() {
1765
+ return this._proxy.createView(JSON.stringify(this.view.toJSON()));
1686
1766
  }
1687
- setHeightAndAspectRatio(height, widthToHeightAspectRatio) {
1688
- this._sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithHeightAndAspectRatio(height, widthToHeightAspectRatio);
1767
+ updateView() {
1768
+ return this._proxy.updateView(JSON.stringify(this.view.toJSON()));
1689
1769
  }
1690
- }
1691
- __decorate([
1692
- nameForSerialization('size')
1693
- ], SpotlightViewfinder.prototype, "_sizeWithUnitAndAspect", void 0);
1694
-
1695
- class LaserlineViewfinder extends DefaultSerializeable {
1696
- get coreDefaults() {
1697
- return getCoreDefaults();
1770
+ dispose() {
1771
+ this.unsubscribeListener();
1698
1772
  }
1699
- constructor(style) {
1700
- super();
1701
- this.type = 'laserline';
1702
- const viewfinderStyle = style || this.coreDefaults.LaserlineViewfinder.defaultStyle;
1703
- this._style = this.coreDefaults.LaserlineViewfinder.styles[viewfinderStyle].style;
1704
- this.width = this.coreDefaults.LaserlineViewfinder.styles[viewfinderStyle].width;
1705
- this.enabledColor = this.coreDefaults.LaserlineViewfinder.styles[viewfinderStyle].enabledColor;
1706
- this.disabledColor = this.coreDefaults.LaserlineViewfinder.styles[viewfinderStyle].disabledColor;
1773
+ addOverlay(overlay) {
1774
+ return this._proxy.addOverlay(JSON.stringify(overlay.toJSON()));
1707
1775
  }
1708
- get style() {
1709
- return this._style;
1776
+ removeOverlay(overlay) {
1777
+ return this._proxy.removeOverlay(JSON.stringify(overlay.toJSON()));
1710
1778
  }
1711
- }
1712
- __decorate([
1713
- nameForSerialization('style')
1714
- ], LaserlineViewfinder.prototype, "_style", void 0);
1715
-
1716
- var LaserlineViewfinderStyle;
1717
- (function (LaserlineViewfinderStyle) {
1718
- LaserlineViewfinderStyle["Legacy"] = "legacy";
1719
- LaserlineViewfinderStyle["Animated"] = "animated";
1720
- })(LaserlineViewfinderStyle || (LaserlineViewfinderStyle = {}));
1779
+ removeAllOverlays() {
1780
+ return this._proxy.removeAllOverlays();
1781
+ }
1782
+ subscribeListener() {
1783
+ var _a, _b;
1784
+ this._proxy.registerListenerForViewEvents();
1785
+ (_b = (_a = this._proxy).subscribeDidChangeSize) === null || _b === void 0 ? void 0 : _b.call(_a);
1786
+ this.eventEmitter.on(DataCaptureViewEvents.didChangeSize, (payload) => {
1787
+ const payloadJSON = JSON.parse(payload);
1788
+ const size = Size.fromJSON(payloadJSON.size);
1789
+ const orientation = payloadJSON.orientation;
1790
+ this.view.listeners.forEach(listener => {
1791
+ if (listener.didChangeSize) {
1792
+ listener.didChangeSize(this.view.viewComponent, size, orientation);
1793
+ }
1794
+ });
1795
+ });
1796
+ }
1797
+ unsubscribeListener() {
1798
+ this._proxy.unregisterListenerForViewEvents();
1799
+ this.eventEmitter.removeAllListeners();
1800
+ }
1801
+ }
1721
1802
 
1722
- class RectangularViewfinder extends DefaultSerializeable {
1723
- get sizeWithUnitAndAspect() {
1724
- return this._sizeWithUnitAndAspect;
1803
+ class BaseDataCaptureView extends DefaultSerializeable {
1804
+ get context() {
1805
+ return this._context;
1806
+ }
1807
+ set context(context) {
1808
+ if (!(context instanceof DataCaptureContext || context == null)) {
1809
+ // This should never happen, but let's just be sure
1810
+ throw new Error('The context for a capture view must be a DataCaptureContext');
1811
+ }
1812
+ this._context = context;
1813
+ if (this._context) {
1814
+ this._context.view = this;
1815
+ }
1725
1816
  }
1726
1817
  get coreDefaults() {
1727
1818
  return getCoreDefaults();
1728
1819
  }
1729
- constructor(style, lineStyle) {
1820
+ get scanAreaMargins() {
1821
+ return this._scanAreaMargins;
1822
+ }
1823
+ set scanAreaMargins(newValue) {
1824
+ this._scanAreaMargins = newValue;
1825
+ this.controller.updateView();
1826
+ }
1827
+ get pointOfInterest() {
1828
+ return this._pointOfInterest;
1829
+ }
1830
+ set pointOfInterest(newValue) {
1831
+ this._pointOfInterest = newValue;
1832
+ this.controller.updateView();
1833
+ }
1834
+ get logoAnchor() {
1835
+ return this._logoAnchor;
1836
+ }
1837
+ set logoAnchor(newValue) {
1838
+ this._logoAnchor = newValue;
1839
+ this.controller.updateView();
1840
+ }
1841
+ get logoOffset() {
1842
+ return this._logoOffset;
1843
+ }
1844
+ set logoOffset(newValue) {
1845
+ this._logoOffset = newValue;
1846
+ this.controller.updateView();
1847
+ }
1848
+ get focusGesture() {
1849
+ return this._focusGesture;
1850
+ }
1851
+ set focusGesture(newValue) {
1852
+ this._focusGesture = newValue;
1853
+ this.controller.updateView();
1854
+ }
1855
+ get zoomGesture() {
1856
+ return this._zoomGesture;
1857
+ }
1858
+ set zoomGesture(newValue) {
1859
+ this._zoomGesture = newValue;
1860
+ this.controller.updateView();
1861
+ }
1862
+ get logoStyle() {
1863
+ return this._logoStyle;
1864
+ }
1865
+ set logoStyle(newValue) {
1866
+ this._logoStyle = newValue;
1867
+ this.controller.updateView();
1868
+ }
1869
+ get privateContext() {
1870
+ return this.context;
1871
+ }
1872
+ static forContext(context) {
1873
+ const view = new BaseDataCaptureView();
1874
+ view.context = context;
1875
+ return view;
1876
+ }
1877
+ constructor() {
1730
1878
  super();
1731
- this.type = 'rectangular';
1732
- const viewfinderStyle = style || this.coreDefaults.RectangularViewfinder.defaultStyle;
1733
- this._style = this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].style;
1734
- this._lineStyle = this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].lineStyle;
1735
- this._dimming = parseFloat(this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].dimming);
1736
- this._disabledDimming =
1737
- parseFloat(this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].disabledDimming);
1738
- this._animation = this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].animation;
1739
- this.color = this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].color;
1740
- this._sizeWithUnitAndAspect = this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].size;
1741
- this._disabledColor = this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].disabledColor;
1742
- if (lineStyle !== undefined) {
1743
- this._lineStyle = lineStyle;
1879
+ this._context = null;
1880
+ this.overlays = [];
1881
+ this.controls = [];
1882
+ this.listeners = [];
1883
+ this.controller = DataCaptureViewController.forDataCaptureView(this);
1884
+ this._scanAreaMargins = this.coreDefaults.DataCaptureView.scanAreaMargins;
1885
+ this._pointOfInterest = this.coreDefaults.DataCaptureView.pointOfInterest;
1886
+ this._logoAnchor = this.coreDefaults.DataCaptureView.logoAnchor;
1887
+ this._logoOffset = this.coreDefaults.DataCaptureView.logoOffset;
1888
+ this._focusGesture = this.coreDefaults.DataCaptureView.focusGesture;
1889
+ this._zoomGesture = this.coreDefaults.DataCaptureView.zoomGesture;
1890
+ this._logoStyle = this.coreDefaults.DataCaptureView.logoStyle;
1891
+ }
1892
+ addOverlay(overlay) {
1893
+ if (this.overlays.includes(overlay)) {
1894
+ return;
1744
1895
  }
1896
+ overlay.view = this;
1897
+ this.overlays.push(overlay);
1898
+ this.controller.addOverlay(overlay);
1745
1899
  }
1746
- get style() {
1747
- return this._style;
1900
+ removeOverlay(overlay) {
1901
+ if (!this.overlays.includes(overlay)) {
1902
+ return;
1903
+ }
1904
+ overlay.view = null;
1905
+ this.overlays.splice(this.overlays.indexOf(overlay), 1);
1906
+ this.controller.removeOverlay(overlay);
1748
1907
  }
1749
- get lineStyle() {
1750
- return this._lineStyle;
1908
+ addListener(listener) {
1909
+ if (!this.listeners.includes(listener)) {
1910
+ this.listeners.push(listener);
1911
+ }
1751
1912
  }
1752
- get dimming() {
1753
- return this._dimming;
1913
+ removeListener(listener) {
1914
+ if (this.listeners.includes(listener)) {
1915
+ this.listeners.splice(this.listeners.indexOf(listener), 1);
1916
+ }
1754
1917
  }
1755
- set dimming(value) {
1756
- this._dimming = value;
1918
+ viewPointForFramePoint(point) {
1919
+ return this.controller.viewPointForFramePoint(point);
1757
1920
  }
1758
- get disabledDimming() {
1759
- return this._disabledDimming;
1921
+ viewQuadrilateralForFrameQuadrilateral(quadrilateral) {
1922
+ return this.controller.viewQuadrilateralForFrameQuadrilateral(quadrilateral);
1760
1923
  }
1761
- set disabledDimming(value) {
1762
- this._disabledDimming = value;
1924
+ addControl(control) {
1925
+ if (!this.controls.includes(control)) {
1926
+ control.view = this;
1927
+ this.controls.push(control);
1928
+ this.controller.updateView();
1929
+ }
1763
1930
  }
1764
- get animation() {
1765
- return this._animation;
1931
+ addControlWithAnchorAndOffset(control, anchor, offset) {
1932
+ if (!this.controls.includes(control)) {
1933
+ control.view = this;
1934
+ control.anchor = anchor;
1935
+ control.offset = offset;
1936
+ this.controls.push(control);
1937
+ this.controller.updateView();
1938
+ }
1766
1939
  }
1767
- set animation(animation) {
1768
- this._animation = animation;
1940
+ removeControl(control) {
1941
+ if (this.controls.includes(control)) {
1942
+ control.view = null;
1943
+ this.controls.splice(this.controls.indexOf(control), 1);
1944
+ this.controller.updateView();
1945
+ }
1769
1946
  }
1770
- setSize(size) {
1771
- this._sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithWidthAndHeight(size);
1947
+ controlUpdated() {
1948
+ this.controller.updateView();
1772
1949
  }
1773
- setWidthAndAspectRatio(width, heightToWidthAspectRatio) {
1774
- this._sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithWidthAndAspectRatio(width, heightToWidthAspectRatio);
1950
+ dispose() {
1951
+ this.overlays = [];
1952
+ this.controller.removeAllOverlays();
1953
+ this.listeners.forEach(listener => this.removeListener(listener));
1954
+ this.controller.dispose();
1775
1955
  }
1776
- setHeightAndAspectRatio(height, widthToHeightAspectRatio) {
1777
- this._sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithHeightAndAspectRatio(height, widthToHeightAspectRatio);
1956
+ // HTML Views only
1957
+ setFrame(frame, isUnderContent = false) {
1958
+ return this.setPositionAndSize(frame.origin.y, frame.origin.x, frame.size.width, frame.size.height, isUnderContent);
1778
1959
  }
1779
- setShorterDimensionAndAspectRatio(fraction, aspectRatio) {
1780
- this._sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithShorterDimensionAndAspectRatio(new NumberWithUnit(fraction, MeasureUnit.Fraction), aspectRatio);
1960
+ setPositionAndSize(top, left, width, height, shouldBeUnderWebView) {
1961
+ return this.controller.setPositionAndSize(top, left, width, height, shouldBeUnderWebView);
1781
1962
  }
1782
- get disabledColor() {
1783
- return this._disabledColor;
1963
+ show() {
1964
+ if (!this.context) {
1965
+ throw new Error('There should be a context attached to a view that should be shown');
1966
+ }
1967
+ this.privateContext.initialize();
1968
+ return this.controller.show();
1784
1969
  }
1785
- set disabledColor(value) {
1786
- this._disabledColor = value;
1970
+ hide() {
1971
+ if (!this.context) {
1972
+ throw new Error('There should be a context attached to a view that should be shown');
1973
+ }
1974
+ return this.controller.hide();
1787
1975
  }
1788
1976
  }
1789
1977
  __decorate([
1790
- nameForSerialization('style')
1791
- ], RectangularViewfinder.prototype, "_style", void 0);
1978
+ ignoreFromSerialization
1979
+ ], BaseDataCaptureView.prototype, "_context", void 0);
1792
1980
  __decorate([
1793
- nameForSerialization('lineStyle')
1794
- ], RectangularViewfinder.prototype, "_lineStyle", void 0);
1981
+ ignoreFromSerialization
1982
+ ], BaseDataCaptureView.prototype, "viewComponent", void 0);
1795
1983
  __decorate([
1796
- nameForSerialization('dimming')
1797
- ], RectangularViewfinder.prototype, "_dimming", void 0);
1984
+ ignoreFromSerialization
1985
+ ], BaseDataCaptureView.prototype, "coreDefaults", null);
1798
1986
  __decorate([
1799
- nameForSerialization('disabledDimming')
1800
- ], RectangularViewfinder.prototype, "_disabledDimming", void 0);
1987
+ ignoreFromSerialization
1988
+ ], BaseDataCaptureView.prototype, "_scanAreaMargins", void 0);
1801
1989
  __decorate([
1802
- nameForSerialization('animation'),
1803
1990
  ignoreFromSerialization
1804
- ], RectangularViewfinder.prototype, "_animation", void 0);
1991
+ ], BaseDataCaptureView.prototype, "_pointOfInterest", void 0);
1805
1992
  __decorate([
1806
- nameForSerialization('size')
1807
- ], RectangularViewfinder.prototype, "_sizeWithUnitAndAspect", void 0);
1993
+ ignoreFromSerialization
1994
+ ], BaseDataCaptureView.prototype, "_logoAnchor", void 0);
1808
1995
  __decorate([
1809
- nameForSerialization('disabledColor')
1810
- ], RectangularViewfinder.prototype, "_disabledColor", void 0);
1811
-
1812
- var RectangularViewfinderStyle;
1813
- (function (RectangularViewfinderStyle) {
1814
- RectangularViewfinderStyle["Legacy"] = "legacy";
1815
- RectangularViewfinderStyle["Rounded"] = "rounded";
1816
- RectangularViewfinderStyle["Square"] = "square";
1817
- })(RectangularViewfinderStyle || (RectangularViewfinderStyle = {}));
1818
-
1819
- var RectangularViewfinderLineStyle;
1820
- (function (RectangularViewfinderLineStyle) {
1821
- RectangularViewfinderLineStyle["Light"] = "light";
1822
- RectangularViewfinderLineStyle["Bold"] = "bold";
1823
- })(RectangularViewfinderLineStyle || (RectangularViewfinderLineStyle = {}));
1996
+ ignoreFromSerialization
1997
+ ], BaseDataCaptureView.prototype, "_logoOffset", void 0);
1998
+ __decorate([
1999
+ ignoreFromSerialization
2000
+ ], BaseDataCaptureView.prototype, "_focusGesture", void 0);
2001
+ __decorate([
2002
+ ignoreFromSerialization
2003
+ ], BaseDataCaptureView.prototype, "_zoomGesture", void 0);
2004
+ __decorate([
2005
+ ignoreFromSerialization
2006
+ ], BaseDataCaptureView.prototype, "_logoStyle", void 0);
2007
+ __decorate([
2008
+ ignoreFromSerialization
2009
+ ], BaseDataCaptureView.prototype, "overlays", void 0);
2010
+ __decorate([
2011
+ ignoreFromSerialization
2012
+ ], BaseDataCaptureView.prototype, "controller", void 0);
2013
+ __decorate([
2014
+ ignoreFromSerialization
2015
+ ], BaseDataCaptureView.prototype, "listeners", void 0);
1824
2016
 
1825
- class AimerViewfinder extends DefaultSerializeable {
1826
- get coreDefaults() {
1827
- return getCoreDefaults();
1828
- }
2017
+ class ZoomSwitchControl extends DefaultSerializeable {
1829
2018
  constructor() {
1830
- super();
1831
- this.type = 'aimer';
1832
- this.frameColor = this.coreDefaults.AimerViewfinder.frameColor;
1833
- this.dotColor = this.coreDefaults.AimerViewfinder.dotColor;
2019
+ super(...arguments);
2020
+ this.type = 'zoom';
2021
+ this.icon = {
2022
+ zoomedOut: { default: null, pressed: null },
2023
+ zoomedIn: { default: null, pressed: null },
2024
+ };
2025
+ this.view = null;
2026
+ this.anchor = null;
2027
+ this.offset = null;
2028
+ }
2029
+ get zoomedOutImage() {
2030
+ var _a, _b;
2031
+ if (((_a = this.icon.zoomedOut.default) === null || _a === void 0 ? void 0 : _a.isBase64EncodedImage()) == true) {
2032
+ return (_b = this.icon.zoomedOut.default) === null || _b === void 0 ? void 0 : _b.data;
2033
+ }
2034
+ return null;
2035
+ }
2036
+ set zoomedOutImage(zoomedOutImage) {
2037
+ var _a;
2038
+ this.icon.zoomedOut.default = ControlImage.fromBase64EncodedImage(zoomedOutImage);
2039
+ (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
2040
+ }
2041
+ get zoomedInImage() {
2042
+ var _a, _b;
2043
+ if (((_a = this.icon.zoomedIn.default) === null || _a === void 0 ? void 0 : _a.isBase64EncodedImage()) == true) {
2044
+ return (_b = this.icon.zoomedIn.default) === null || _b === void 0 ? void 0 : _b.data;
2045
+ }
2046
+ return null;
2047
+ }
2048
+ set zoomedInImage(zoomedInImage) {
2049
+ var _a;
2050
+ this.icon.zoomedIn.default = ControlImage.fromBase64EncodedImage(zoomedInImage);
2051
+ (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
2052
+ }
2053
+ get zoomedInPressedImage() {
2054
+ var _a, _b;
2055
+ if (((_a = this.icon.zoomedIn.pressed) === null || _a === void 0 ? void 0 : _a.isBase64EncodedImage()) == true) {
2056
+ return (_b = this.icon.zoomedIn.pressed) === null || _b === void 0 ? void 0 : _b.data;
2057
+ }
2058
+ return null;
2059
+ }
2060
+ set zoomedInPressedImage(zoomedInPressedImage) {
2061
+ var _a;
2062
+ this.icon.zoomedIn.pressed = ControlImage.fromBase64EncodedImage(zoomedInPressedImage);
2063
+ (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
2064
+ }
2065
+ get zoomedOutPressedImage() {
2066
+ var _a, _b;
2067
+ if (((_a = this.icon.zoomedOut.pressed) === null || _a === void 0 ? void 0 : _a.isBase64EncodedImage()) == true) {
2068
+ return (_b = this.icon.zoomedOut.pressed) === null || _b === void 0 ? void 0 : _b.data;
2069
+ }
2070
+ return null;
2071
+ }
2072
+ set zoomedOutPressedImage(zoomedOutPressedImage) {
2073
+ var _a;
2074
+ this.icon.zoomedOut.pressed = ControlImage.fromBase64EncodedImage(zoomedOutPressedImage);
2075
+ (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
2076
+ }
2077
+ setZoomedInImage(resource) {
2078
+ var _a;
2079
+ this.icon.zoomedIn.default = ControlImage.fromResourceName(resource);
2080
+ (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
2081
+ }
2082
+ setZoomedInPressedImage(resource) {
2083
+ var _a;
2084
+ this.icon.zoomedIn.pressed = ControlImage.fromResourceName(resource);
2085
+ (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
2086
+ }
2087
+ setZoomedOutImage(resource) {
2088
+ var _a;
2089
+ this.icon.zoomedOut.default = ControlImage.fromResourceName(resource);
2090
+ (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
2091
+ }
2092
+ setZoomedOutPressedImage(resource) {
2093
+ var _a;
2094
+ this.icon.zoomedOut.pressed = ControlImage.fromResourceName(resource);
2095
+ (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
1834
2096
  }
1835
2097
  }
2098
+ __decorate([
2099
+ ignoreFromSerialization
2100
+ ], ZoomSwitchControl.prototype, "view", void 0);
1836
2101
 
1837
- function parseDefaults(jsonDefaults) {
1838
- const coreDefaults = {
1839
- Camera: {
1840
- Settings: {
1841
- preferredResolution: jsonDefaults.Camera.Settings.preferredResolution,
1842
- zoomFactor: jsonDefaults.Camera.Settings.zoomFactor,
1843
- focusRange: jsonDefaults.Camera.Settings.focusRange,
1844
- zoomGestureZoomFactor: jsonDefaults.Camera.Settings.zoomGestureZoomFactor,
1845
- focusGestureStrategy: jsonDefaults.Camera.Settings.focusGestureStrategy,
1846
- shouldPreferSmoothAutoFocus: jsonDefaults.Camera.Settings.shouldPreferSmoothAutoFocus,
1847
- properties: jsonDefaults.Camera.Settings.properties,
1848
- },
1849
- defaultPosition: (jsonDefaults.Camera.defaultPosition || null),
1850
- availablePositions: jsonDefaults.Camera.availablePositions,
1851
- },
1852
- DataCaptureView: {
1853
- scanAreaMargins: MarginsWithUnit
1854
- .fromJSON(JSON.parse(jsonDefaults.DataCaptureView.scanAreaMargins)),
1855
- pointOfInterest: PointWithUnit
1856
- .fromJSON(JSON.parse(jsonDefaults.DataCaptureView.pointOfInterest)),
1857
- logoAnchor: jsonDefaults.DataCaptureView.logoAnchor,
1858
- logoOffset: PointWithUnit
1859
- .fromJSON(JSON.parse(jsonDefaults.DataCaptureView.logoOffset)),
1860
- focusGesture: PrivateFocusGestureDeserializer
1861
- .fromJSON(JSON.parse(jsonDefaults.DataCaptureView.focusGesture)),
1862
- zoomGesture: PrivateZoomGestureDeserializer
1863
- .fromJSON(JSON.parse(jsonDefaults.DataCaptureView.zoomGesture)),
1864
- logoStyle: jsonDefaults.DataCaptureView.logoStyle,
1865
- },
1866
- LaserlineViewfinder: Object
1867
- .keys(jsonDefaults.LaserlineViewfinder.styles)
1868
- .reduce((acc, key) => {
1869
- const viewfinder = jsonDefaults.LaserlineViewfinder.styles[key];
1870
- acc.styles[key] = {
1871
- width: NumberWithUnit
1872
- .fromJSON(JSON.parse(viewfinder.width)),
1873
- enabledColor: Color
1874
- .fromJSON(viewfinder.enabledColor),
1875
- disabledColor: Color
1876
- .fromJSON(viewfinder.disabledColor),
1877
- style: viewfinder.style,
1878
- };
1879
- return acc;
1880
- }, { defaultStyle: jsonDefaults.LaserlineViewfinder.defaultStyle, styles: {} }),
1881
- RectangularViewfinder: Object
1882
- .keys(jsonDefaults.RectangularViewfinder.styles)
1883
- .reduce((acc, key) => {
1884
- const viewfinder = jsonDefaults.RectangularViewfinder.styles[key];
1885
- acc.styles[key] = {
1886
- size: SizeWithUnitAndAspect
1887
- .fromJSON(JSON.parse(viewfinder.size)),
1888
- color: Color.fromJSON(viewfinder.color),
1889
- disabledColor: Color.fromJSON(viewfinder.disabledColor),
1890
- style: viewfinder.style,
1891
- lineStyle: viewfinder.lineStyle,
1892
- dimming: viewfinder.dimming,
1893
- disabledDimming: viewfinder.disabledDimming,
1894
- animation: RectangularViewfinderAnimation
1895
- .fromJSON(JSON.parse(viewfinder.animation)),
1896
- };
1897
- return acc;
1898
- }, { defaultStyle: jsonDefaults.RectangularViewfinder.defaultStyle, styles: {} }),
1899
- SpotlightViewfinder: {
1900
- size: SizeWithUnitAndAspect
1901
- .fromJSON(JSON.parse(jsonDefaults.SpotlightViewfinder.size)),
1902
- enabledBorderColor: Color
1903
- .fromJSON(jsonDefaults.SpotlightViewfinder.enabledBorderColor),
1904
- disabledBorderColor: Color
1905
- .fromJSON(jsonDefaults.SpotlightViewfinder.disabledBorderColor),
1906
- backgroundColor: Color
1907
- .fromJSON(jsonDefaults.SpotlightViewfinder.backgroundColor),
1908
- },
1909
- AimerViewfinder: {
1910
- frameColor: Color.fromJSON(jsonDefaults.AimerViewfinder.frameColor),
1911
- dotColor: Color.fromJSON(jsonDefaults.AimerViewfinder.dotColor),
1912
- },
1913
- Brush: {
1914
- fillColor: Color
1915
- .fromJSON(jsonDefaults.Brush.fillColor),
1916
- strokeColor: Color
1917
- .fromJSON(jsonDefaults.Brush.strokeColor),
1918
- strokeWidth: jsonDefaults.Brush.strokeWidth,
1919
- },
1920
- deviceID: jsonDefaults.deviceID,
1921
- };
1922
- // Inject defaults to avoid a circular dependency between these classes and the defaults
1923
- Brush.defaults = coreDefaults.Brush;
1924
- return coreDefaults;
2102
+ class TorchSwitchControl extends DefaultSerializeable {
2103
+ constructor() {
2104
+ super(...arguments);
2105
+ this.type = 'torch';
2106
+ this.icon = {
2107
+ on: { default: null, pressed: null },
2108
+ off: { default: null, pressed: null },
2109
+ };
2110
+ this.view = null;
2111
+ this.anchor = null;
2112
+ this.offset = null;
2113
+ }
2114
+ get torchOffImage() {
2115
+ var _a, _b;
2116
+ if (((_a = this.icon.off.default) === null || _a === void 0 ? void 0 : _a.isBase64EncodedImage()) == true) {
2117
+ return (_b = this.icon.off.default) === null || _b === void 0 ? void 0 : _b.data;
2118
+ }
2119
+ return null;
2120
+ }
2121
+ set torchOffImage(torchOffImage) {
2122
+ var _a;
2123
+ this.icon.off.default = ControlImage.fromBase64EncodedImage(torchOffImage);
2124
+ (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
2125
+ }
2126
+ get torchOffPressedImage() {
2127
+ var _a, _b;
2128
+ if (((_a = this.icon.off.pressed) === null || _a === void 0 ? void 0 : _a.isBase64EncodedImage()) == true) {
2129
+ return (_b = this.icon.off.pressed) === null || _b === void 0 ? void 0 : _b.data;
2130
+ }
2131
+ return null;
2132
+ }
2133
+ set torchOffPressedImage(torchOffPressedImage) {
2134
+ var _a;
2135
+ this.icon.off.pressed = ControlImage.fromBase64EncodedImage(torchOffPressedImage);
2136
+ (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
2137
+ }
2138
+ get torchOnImage() {
2139
+ var _a, _b;
2140
+ if (((_a = this.icon.on.default) === null || _a === void 0 ? void 0 : _a.isBase64EncodedImage()) == true) {
2141
+ return (_b = this.icon.on.default) === null || _b === void 0 ? void 0 : _b.data;
2142
+ }
2143
+ return null;
2144
+ }
2145
+ set torchOnImage(torchOnImage) {
2146
+ var _a;
2147
+ this.icon.on.default = ControlImage.fromBase64EncodedImage(torchOnImage);
2148
+ (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
2149
+ }
2150
+ get torchOnPressedImage() {
2151
+ var _a, _b;
2152
+ if (((_a = this.icon.on.pressed) === null || _a === void 0 ? void 0 : _a.isBase64EncodedImage()) == true) {
2153
+ return (_b = this.icon.on.pressed) === null || _b === void 0 ? void 0 : _b.data;
2154
+ }
2155
+ return null;
2156
+ }
2157
+ setTorchOffImage(resource) {
2158
+ var _a;
2159
+ this.icon.off.default = ControlImage.fromResourceName(resource);
2160
+ (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
2161
+ }
2162
+ setTorchOffPressedImage(resource) {
2163
+ var _a;
2164
+ this.icon.off.pressed = ControlImage.fromResourceName(resource);
2165
+ (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
2166
+ }
2167
+ setTorchOnImage(resource) {
2168
+ var _a;
2169
+ this.icon.on.default = ControlImage.fromResourceName(resource);
2170
+ (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
2171
+ }
2172
+ setTorchOnPressedImage(resource) {
2173
+ var _a;
2174
+ this.icon.on.pressed = ControlImage.fromResourceName(resource);
2175
+ (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
2176
+ }
2177
+ setImageResource(resource) {
2178
+ var _a;
2179
+ this.icon.off.default = ControlImage.fromResourceName(resource);
2180
+ this.icon.off.pressed = ControlImage.fromResourceName(resource);
2181
+ this.icon.on.default = ControlImage.fromResourceName(resource);
2182
+ this.icon.on.pressed = ControlImage.fromResourceName(resource);
2183
+ (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
2184
+ }
2185
+ set torchOnPressedImage(torchOnPressedImage) {
2186
+ var _a;
2187
+ this.icon.on.pressed = ControlImage.fromBase64EncodedImage(torchOnPressedImage);
2188
+ (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
2189
+ }
1925
2190
  }
2191
+ __decorate([
2192
+ ignoreFromSerialization
2193
+ ], TorchSwitchControl.prototype, "view", void 0);
1926
2194
 
1927
- function loadCoreDefaults(jsonDefaults) {
1928
- const coreDefaults = parseDefaults(jsonDefaults);
1929
- FactoryMaker.bindInstanceIfNotExists('CoreDefaults', coreDefaults);
1930
- }
2195
+ var VideoResolution;
2196
+ (function (VideoResolution) {
2197
+ VideoResolution["Auto"] = "auto";
2198
+ VideoResolution["HD"] = "hd";
2199
+ VideoResolution["FullHD"] = "fullHd";
2200
+ VideoResolution["UHD4K"] = "uhd4k";
2201
+ })(VideoResolution || (VideoResolution = {}));
1931
2202
 
1932
- class ContextStatus {
1933
- static fromJSON(json) {
1934
- const status = new ContextStatus();
1935
- status._code = json.code;
1936
- status._message = json.message;
1937
- status._isValid = json.isValid;
1938
- return status;
2203
+ var FocusRange;
2204
+ (function (FocusRange) {
2205
+ FocusRange["Full"] = "full";
2206
+ FocusRange["Near"] = "near";
2207
+ FocusRange["Far"] = "far";
2208
+ })(FocusRange || (FocusRange = {}));
2209
+
2210
+ var FocusGestureStrategy;
2211
+ (function (FocusGestureStrategy) {
2212
+ FocusGestureStrategy["None"] = "none";
2213
+ FocusGestureStrategy["Manual"] = "manual";
2214
+ FocusGestureStrategy["ManualUntilCapture"] = "manualUntilCapture";
2215
+ FocusGestureStrategy["AutoOnLocation"] = "autoOnLocation";
2216
+ })(FocusGestureStrategy || (FocusGestureStrategy = {}));
2217
+
2218
+ var LogoStyle;
2219
+ (function (LogoStyle) {
2220
+ LogoStyle["Minimal"] = "minimal";
2221
+ LogoStyle["Extended"] = "extended";
2222
+ })(LogoStyle || (LogoStyle = {}));
2223
+
2224
+ class CameraSettings extends DefaultSerializeable {
2225
+ static get coreDefaults() {
2226
+ return getCoreDefaults();
2227
+ }
2228
+ get focusRange() {
2229
+ return this.focus.range;
2230
+ }
2231
+ set focusRange(newRange) {
2232
+ this.focus.range = newRange;
2233
+ }
2234
+ get focusGestureStrategy() {
2235
+ return this.focus.focusGestureStrategy;
2236
+ }
2237
+ set focusGestureStrategy(newStrategy) {
2238
+ this.focus.focusGestureStrategy = newStrategy;
1939
2239
  }
1940
- get message() {
1941
- return this._message;
2240
+ get shouldPreferSmoothAutoFocus() {
2241
+ return this.focus.shouldPreferSmoothAutoFocus;
1942
2242
  }
1943
- get code() {
1944
- return this._code;
2243
+ set shouldPreferSmoothAutoFocus(newShouldPreferSmoothAutoFocus) {
2244
+ this.focus.shouldPreferSmoothAutoFocus = newShouldPreferSmoothAutoFocus;
1945
2245
  }
1946
- get isValid() {
1947
- return this._isValid;
2246
+ get maxFrameRate() {
2247
+ // tslint:disable-next-line:no-console
2248
+ console.warn('maxFrameRate is deprecated');
2249
+ return 0;
1948
2250
  }
1949
- }
1950
-
1951
- class DataCaptureContextSettings extends DefaultSerializeable {
1952
- constructor() {
2251
+ set maxFrameRate(newValue) {
2252
+ // tslint:disable-next-line:no-console
2253
+ console.warn('maxFrameRate is deprecated');
2254
+ }
2255
+ static fromJSON(json) {
2256
+ const settings = new CameraSettings();
2257
+ settings.preferredResolution = json.preferredResolution;
2258
+ settings.zoomFactor = json.zoomFactor;
2259
+ settings.focusRange = json.focusRange;
2260
+ settings.zoomGestureZoomFactor = json.zoomGestureZoomFactor;
2261
+ settings.focusGestureStrategy = json.focusGestureStrategy;
2262
+ settings.shouldPreferSmoothAutoFocus = json.shouldPreferSmoothAutoFocus;
2263
+ if (json.properties !== undefined) {
2264
+ for (const key of Object.keys(json.properties)) {
2265
+ settings.setProperty(key, json.properties[key]);
2266
+ }
2267
+ }
2268
+ return settings;
2269
+ }
2270
+ constructor(settings) {
1953
2271
  super();
2272
+ this.focusHiddenProperties = [
2273
+ 'range',
2274
+ 'manualLensPosition',
2275
+ 'shouldPreferSmoothAutoFocus',
2276
+ 'focusStrategy',
2277
+ 'focusGestureStrategy'
2278
+ ];
2279
+ this.preferredResolution = CameraSettings.coreDefaults.Camera.Settings.preferredResolution;
2280
+ this.zoomFactor = CameraSettings.coreDefaults.Camera.Settings.zoomFactor;
2281
+ this.zoomGestureZoomFactor = CameraSettings.coreDefaults.Camera.Settings.zoomGestureZoomFactor;
2282
+ this.focus = {
2283
+ range: CameraSettings.coreDefaults.Camera.Settings.focusRange,
2284
+ focusGestureStrategy: CameraSettings.coreDefaults.Camera.Settings.focusGestureStrategy,
2285
+ shouldPreferSmoothAutoFocus: CameraSettings.coreDefaults.Camera.Settings.shouldPreferSmoothAutoFocus
2286
+ };
2287
+ this.preferredResolution = CameraSettings.coreDefaults.Camera.Settings.preferredResolution;
2288
+ this.zoomFactor = CameraSettings.coreDefaults.Camera.Settings.zoomFactor;
2289
+ this.zoomGestureZoomFactor = CameraSettings.coreDefaults.Camera.Settings.zoomGestureZoomFactor;
2290
+ this.focus = {
2291
+ range: CameraSettings.coreDefaults.Camera.Settings.focusRange,
2292
+ focusGestureStrategy: CameraSettings.coreDefaults.Camera.Settings.focusGestureStrategy,
2293
+ shouldPreferSmoothAutoFocus: CameraSettings.coreDefaults.Camera.Settings.shouldPreferSmoothAutoFocus,
2294
+ };
2295
+ if (settings !== undefined && settings !== null) {
2296
+ Object.getOwnPropertyNames(settings).forEach(propertyName => {
2297
+ this[propertyName] = settings[propertyName];
2298
+ });
2299
+ }
1954
2300
  }
1955
2301
  setProperty(name, value) {
2302
+ if (this.focusHiddenProperties.includes(name)) {
2303
+ this.focus[name] = value;
2304
+ return;
2305
+ }
1956
2306
  this[name] = value;
1957
2307
  }
1958
2308
  getProperty(name) {
2309
+ if (this.focusHiddenProperties.includes(name)) {
2310
+ return this.focus[name];
2311
+ }
1959
2312
  return this[name];
1960
2313
  }
1961
2314
  }
2315
+ __decorate([
2316
+ ignoreFromSerialization
2317
+ ], CameraSettings.prototype, "focusHiddenProperties", void 0);
1962
2318
 
1963
- var DataCaptureContextEvents;
1964
- (function (DataCaptureContextEvents) {
1965
- DataCaptureContextEvents["didChangeStatus"] = "didChangeStatus";
1966
- DataCaptureContextEvents["didStartObservingContext"] = "didStartObservingContext";
1967
- })(DataCaptureContextEvents || (DataCaptureContextEvents = {}));
1968
- class DataCaptureContextController {
1969
- get framework() {
1970
- return this._proxy.framework;
1971
- }
1972
- get frameworkVersion() {
1973
- return this._proxy.frameworkVersion;
1974
- }
1975
- get privateContext() {
1976
- return this.context;
1977
- }
1978
- static forDataCaptureContext(context) {
1979
- const controller = new DataCaptureContextController();
1980
- controller.context = context;
1981
- controller.initialize();
1982
- return controller;
1983
- }
1984
- constructor() {
1985
- this._proxy = FactoryMaker.getInstance('DataCaptureContextProxy');
1986
- this.eventEmitter = FactoryMaker.getInstance('EventEmitter');
2319
+ const NoViewfinder = { type: 'none' };
2320
+
2321
+ class RectangularViewfinderAnimation extends DefaultSerializeable {
2322
+ static fromJSON(json) {
2323
+ if (json === null) {
2324
+ return null;
2325
+ }
2326
+ return new RectangularViewfinderAnimation(json.looping);
1987
2327
  }
1988
- updateContextFromJSON() {
1989
- return __awaiter(this, void 0, void 0, function* () {
1990
- try {
1991
- yield this._proxy.updateContextFromJSON(this.context);
1992
- }
1993
- catch (error) {
1994
- this.notifyListenersOfDeserializationError(error);
1995
- throw error;
1996
- }
1997
- });
2328
+ get isLooping() {
2329
+ return this._isLooping;
1998
2330
  }
1999
- addModeToContext(mode) {
2000
- return this._proxy.addModeToContext(JSON.stringify(mode.toJSON()));
2331
+ constructor(isLooping) {
2332
+ super();
2333
+ this._isLooping = false;
2334
+ this._isLooping = isLooping;
2001
2335
  }
2002
- removeModeFromContext(mode) {
2003
- return this._proxy.removeModeFromContext(JSON.stringify(mode.toJSON()));
2336
+ }
2337
+ __decorate([
2338
+ nameForSerialization('isLooping')
2339
+ ], RectangularViewfinderAnimation.prototype, "_isLooping", void 0);
2340
+
2341
+ class SpotlightViewfinder extends DefaultSerializeable {
2342
+ get sizeWithUnitAndAspect() {
2343
+ return this._sizeWithUnitAndAspect;
2004
2344
  }
2005
- removeAllModesFromContext() {
2006
- return this._proxy.removeAllModesFromContext();
2345
+ get coreDefaults() {
2346
+ return getCoreDefaults();
2007
2347
  }
2008
- dispose() {
2009
- this.unsubscribeListener();
2010
- this._proxy.dispose();
2348
+ constructor() {
2349
+ super();
2350
+ this.type = 'spotlight';
2351
+ console.warn('SpotlightViewfinder is deprecated and will be removed in a future release. Use RectangularViewfinder instead.');
2352
+ this._sizeWithUnitAndAspect = this.coreDefaults.SpotlightViewfinder.size;
2353
+ this.enabledBorderColor = this.coreDefaults.SpotlightViewfinder.enabledBorderColor;
2354
+ this.disabledBorderColor = this.coreDefaults.SpotlightViewfinder.disabledBorderColor;
2355
+ this.backgroundColor = this.coreDefaults.SpotlightViewfinder.backgroundColor;
2011
2356
  }
2012
- unsubscribeListener() {
2013
- this._proxy.unsubscribeListener();
2014
- this.eventEmitter.removeListener(DataCaptureContextEvents.didChangeStatus);
2015
- this.eventEmitter.removeListener(DataCaptureContextEvents.didStartObservingContext);
2357
+ setSize(size) {
2358
+ this._sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithWidthAndHeight(size);
2016
2359
  }
2017
- initialize() {
2018
- this.subscribeListener();
2019
- return this.initializeContextFromJSON();
2360
+ setWidthAndAspectRatio(width, heightToWidthAspectRatio) {
2361
+ this._sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithWidthAndAspectRatio(width, heightToWidthAspectRatio);
2020
2362
  }
2021
- initializeContextFromJSON() {
2022
- return __awaiter(this, void 0, void 0, function* () {
2023
- try {
2024
- this._proxy.contextFromJSON(this.context);
2025
- }
2026
- catch (error) {
2027
- this.notifyListenersOfDeserializationError(error);
2028
- throw error;
2029
- }
2030
- });
2363
+ setHeightAndAspectRatio(height, widthToHeightAspectRatio) {
2364
+ this._sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithHeightAndAspectRatio(height, widthToHeightAspectRatio);
2031
2365
  }
2032
- subscribeListener() {
2033
- var _a, _b, _c, _d;
2034
- this._proxy.registerListenerForEvents();
2035
- (_b = (_a = this._proxy).subscribeDidChangeStatus) === null || _b === void 0 ? void 0 : _b.call(_a);
2036
- (_d = (_c = this._proxy).subscribeDidStartObservingContext) === null || _d === void 0 ? void 0 : _d.call(_c);
2037
- this.eventEmitter.on(DataCaptureContextEvents.didChangeStatus, (contextStatus) => {
2038
- this.notifyListenersOfDidChangeStatus(contextStatus);
2039
- });
2040
- this.eventEmitter.on(DataCaptureContextEvents.didStartObservingContext, () => {
2041
- this.privateContext.listeners.forEach(listener => {
2042
- var _a;
2043
- (_a = listener.didStartObservingContext) === null || _a === void 0 ? void 0 : _a.call(listener, this.context);
2044
- });
2045
- });
2366
+ }
2367
+ __decorate([
2368
+ nameForSerialization('size')
2369
+ ], SpotlightViewfinder.prototype, "_sizeWithUnitAndAspect", void 0);
2370
+
2371
+ class LaserlineViewfinder extends DefaultSerializeable {
2372
+ get coreDefaults() {
2373
+ return getCoreDefaults();
2046
2374
  }
2047
- notifyListenersOfDeserializationError(error) {
2048
- const contextStatus = ContextStatus
2049
- .fromJSON({
2050
- message: error,
2051
- code: -1,
2052
- isValid: true,
2053
- });
2054
- this.notifyListenersOfDidChangeStatus(contextStatus);
2375
+ constructor(style) {
2376
+ super();
2377
+ this.type = 'laserline';
2378
+ const viewfinderStyle = style || this.coreDefaults.LaserlineViewfinder.defaultStyle;
2379
+ this._style = this.coreDefaults.LaserlineViewfinder.styles[viewfinderStyle].style;
2380
+ this.width = this.coreDefaults.LaserlineViewfinder.styles[viewfinderStyle].width;
2381
+ this.enabledColor = this.coreDefaults.LaserlineViewfinder.styles[viewfinderStyle].enabledColor;
2382
+ this.disabledColor = this.coreDefaults.LaserlineViewfinder.styles[viewfinderStyle].disabledColor;
2055
2383
  }
2056
- notifyListenersOfDidChangeStatus(contextStatus) {
2057
- this.privateContext.listeners.forEach(listener => {
2058
- if (listener.didChangeStatus) {
2059
- listener.didChangeStatus(this.context, contextStatus);
2060
- }
2061
- });
2384
+ get style() {
2385
+ return this._style;
2062
2386
  }
2063
2387
  }
2388
+ __decorate([
2389
+ nameForSerialization('style')
2390
+ ], LaserlineViewfinder.prototype, "_style", void 0);
2064
2391
 
2065
- class DataCaptureContext extends DefaultSerializeable {
2066
- get framework() {
2067
- return this.controller.framework;
2068
- }
2069
- get frameworkVersion() {
2070
- return this.controller.frameworkVersion;
2392
+ var LaserlineViewfinderStyle;
2393
+ (function (LaserlineViewfinderStyle) {
2394
+ LaserlineViewfinderStyle["Legacy"] = "legacy";
2395
+ LaserlineViewfinderStyle["Animated"] = "animated";
2396
+ })(LaserlineViewfinderStyle || (LaserlineViewfinderStyle = {}));
2397
+
2398
+ class RectangularViewfinder extends DefaultSerializeable {
2399
+ get sizeWithUnitAndAspect() {
2400
+ return this._sizeWithUnitAndAspect;
2071
2401
  }
2072
- static get coreDefaults() {
2402
+ get coreDefaults() {
2073
2403
  return getCoreDefaults();
2074
2404
  }
2075
- get frameSource() {
2076
- return this._frameSource;
2077
- }
2078
- static get deviceID() {
2079
- return DataCaptureContext.coreDefaults.deviceID;
2080
- }
2081
- /**
2082
- * @deprecated
2083
- */
2084
- get deviceID() {
2085
- console.log('The instance property "deviceID" on the DataCaptureContext is deprecated, please use the static property DataCaptureContext.deviceID instead.');
2086
- return DataCaptureContext.deviceID;
2405
+ constructor(style, lineStyle) {
2406
+ super();
2407
+ this.type = 'rectangular';
2408
+ const viewfinderStyle = style || this.coreDefaults.RectangularViewfinder.defaultStyle;
2409
+ this._style = this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].style;
2410
+ this._lineStyle = this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].lineStyle;
2411
+ this._dimming = parseFloat(this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].dimming);
2412
+ this._disabledDimming =
2413
+ parseFloat(this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].disabledDimming);
2414
+ this._animation = this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].animation;
2415
+ this.color = this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].color;
2416
+ this._sizeWithUnitAndAspect = this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].size;
2417
+ this._disabledColor = this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].disabledColor;
2418
+ if (lineStyle !== undefined) {
2419
+ this._lineStyle = lineStyle;
2420
+ }
2087
2421
  }
2088
- static forLicenseKey(licenseKey) {
2089
- return DataCaptureContext.forLicenseKeyWithOptions(licenseKey, null);
2422
+ get style() {
2423
+ return this._style;
2090
2424
  }
2091
- static forLicenseKeyWithSettings(licenseKey, settings) {
2092
- const context = this.forLicenseKey(licenseKey);
2093
- if (settings !== null) {
2094
- context.applySettings(settings);
2095
- }
2096
- return context;
2425
+ get lineStyle() {
2426
+ return this._lineStyle;
2097
2427
  }
2098
- static forLicenseKeyWithOptions(licenseKey, options) {
2099
- if (options == null) {
2100
- options = { deviceName: null };
2101
- }
2102
- return new DataCaptureContext(licenseKey, options.deviceName || '');
2428
+ get dimming() {
2429
+ return this._dimming;
2103
2430
  }
2104
- constructor(licenseKey, deviceName) {
2105
- super();
2106
- this.licenseKey = licenseKey;
2107
- this.deviceName = deviceName;
2108
- this.settings = new DataCaptureContextSettings();
2109
- this._frameSource = null;
2110
- this.view = null;
2111
- this.modes = [];
2112
- this.listeners = [];
2113
- this.initialize();
2431
+ set dimming(value) {
2432
+ this._dimming = value;
2114
2433
  }
2115
- setFrameSource(frameSource) {
2116
- if (this._frameSource) {
2117
- this._frameSource.context = null;
2118
- }
2119
- this._frameSource = frameSource;
2120
- if (frameSource) {
2121
- frameSource.context = this;
2122
- }
2123
- return this.update();
2434
+ get disabledDimming() {
2435
+ return this._disabledDimming;
2124
2436
  }
2125
- addListener(listener) {
2126
- if (this.listeners.includes(listener)) {
2127
- return;
2128
- }
2129
- this.listeners.push(listener);
2437
+ set disabledDimming(value) {
2438
+ this._disabledDimming = value;
2130
2439
  }
2131
- removeListener(listener) {
2132
- if (!this.listeners.includes(listener)) {
2133
- return;
2134
- }
2135
- this.listeners.splice(this.listeners.indexOf(listener), 1);
2440
+ get animation() {
2441
+ return this._animation;
2136
2442
  }
2137
- addMode(mode) {
2138
- if (!this.modes.includes(mode)) {
2139
- this.modes.push(mode);
2140
- mode._context = this;
2141
- this.controller.addModeToContext(mode);
2142
- }
2443
+ set animation(animation) {
2444
+ this._animation = animation;
2143
2445
  }
2144
- removeMode(mode) {
2145
- if (this.modes.includes(mode)) {
2146
- this.modes.splice(this.modes.indexOf(mode), 1);
2147
- mode._context = null;
2148
- this.controller.removeModeFromContext(mode);
2149
- }
2446
+ setSize(size) {
2447
+ this._sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithWidthAndHeight(size);
2150
2448
  }
2151
- removeAllModes() {
2152
- this.modes.forEach(mode => {
2153
- mode._context = null;
2154
- });
2155
- this.modes = [];
2156
- this.controller.removeAllModesFromContext();
2449
+ setWidthAndAspectRatio(width, heightToWidthAspectRatio) {
2450
+ this._sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithWidthAndAspectRatio(width, heightToWidthAspectRatio);
2157
2451
  }
2158
- dispose() {
2159
- var _a;
2160
- if (!this.controller) {
2161
- return;
2162
- }
2163
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.dispose();
2164
- this.removeAllModes();
2165
- this.controller.dispose();
2452
+ setHeightAndAspectRatio(height, widthToHeightAspectRatio) {
2453
+ this._sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithHeightAndAspectRatio(height, widthToHeightAspectRatio);
2166
2454
  }
2167
- applySettings(settings) {
2168
- this.settings = settings;
2169
- return this.update();
2455
+ setShorterDimensionAndAspectRatio(fraction, aspectRatio) {
2456
+ this._sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithShorterDimensionAndAspectRatio(new NumberWithUnit(fraction, MeasureUnit.Fraction), aspectRatio);
2170
2457
  }
2171
- // Called when the capture view is shown, that is the earliest point that we need the context deserialized.
2172
- initialize() {
2173
- if (this.controller) {
2174
- return;
2175
- }
2176
- this.controller = DataCaptureContextController.forDataCaptureContext(this);
2458
+ get disabledColor() {
2459
+ return this._disabledColor;
2177
2460
  }
2178
- update() {
2179
- if (!this.controller) {
2180
- return Promise.resolve();
2181
- }
2182
- return this.controller.updateContextFromJSON();
2461
+ set disabledColor(value) {
2462
+ this._disabledColor = value;
2183
2463
  }
2184
2464
  }
2185
2465
  __decorate([
2186
- nameForSerialization('frameSource')
2187
- ], DataCaptureContext.prototype, "_frameSource", void 0);
2466
+ nameForSerialization('style')
2467
+ ], RectangularViewfinder.prototype, "_style", void 0);
2188
2468
  __decorate([
2189
- ignoreFromSerialization
2190
- ], DataCaptureContext.prototype, "modes", void 0);
2469
+ nameForSerialization('lineStyle')
2470
+ ], RectangularViewfinder.prototype, "_lineStyle", void 0);
2191
2471
  __decorate([
2192
- ignoreFromSerialization
2193
- ], DataCaptureContext.prototype, "controller", void 0);
2472
+ nameForSerialization('dimming')
2473
+ ], RectangularViewfinder.prototype, "_dimming", void 0);
2194
2474
  __decorate([
2195
- ignoreFromSerialization
2196
- ], DataCaptureContext.prototype, "listeners", void 0);
2475
+ nameForSerialization('disabledDimming')
2476
+ ], RectangularViewfinder.prototype, "_disabledDimming", void 0);
2197
2477
  __decorate([
2478
+ nameForSerialization('animation'),
2198
2479
  ignoreFromSerialization
2199
- ], DataCaptureContext, "coreDefaults", null);
2480
+ ], RectangularViewfinder.prototype, "_animation", void 0);
2481
+ __decorate([
2482
+ nameForSerialization('size')
2483
+ ], RectangularViewfinder.prototype, "_sizeWithUnitAndAspect", void 0);
2484
+ __decorate([
2485
+ nameForSerialization('disabledColor')
2486
+ ], RectangularViewfinder.prototype, "_disabledColor", void 0);
2487
+
2488
+ var RectangularViewfinderStyle;
2489
+ (function (RectangularViewfinderStyle) {
2490
+ RectangularViewfinderStyle["Legacy"] = "legacy";
2491
+ RectangularViewfinderStyle["Rounded"] = "rounded";
2492
+ RectangularViewfinderStyle["Square"] = "square";
2493
+ })(RectangularViewfinderStyle || (RectangularViewfinderStyle = {}));
2494
+
2495
+ var RectangularViewfinderLineStyle;
2496
+ (function (RectangularViewfinderLineStyle) {
2497
+ RectangularViewfinderLineStyle["Light"] = "light";
2498
+ RectangularViewfinderLineStyle["Bold"] = "bold";
2499
+ })(RectangularViewfinderLineStyle || (RectangularViewfinderLineStyle = {}));
2500
+
2501
+ class AimerViewfinder extends DefaultSerializeable {
2502
+ get coreDefaults() {
2503
+ return getCoreDefaults();
2504
+ }
2505
+ constructor() {
2506
+ super();
2507
+ this.type = 'aimer';
2508
+ this.frameColor = this.coreDefaults.AimerViewfinder.frameColor;
2509
+ this.dotColor = this.coreDefaults.AimerViewfinder.dotColor;
2510
+ }
2511
+ }
2512
+
2513
+ function parseDefaults(jsonDefaults) {
2514
+ const coreDefaults = {
2515
+ Camera: {
2516
+ Settings: {
2517
+ preferredResolution: jsonDefaults.Camera.Settings.preferredResolution,
2518
+ zoomFactor: jsonDefaults.Camera.Settings.zoomFactor,
2519
+ focusRange: jsonDefaults.Camera.Settings.focusRange,
2520
+ zoomGestureZoomFactor: jsonDefaults.Camera.Settings.zoomGestureZoomFactor,
2521
+ focusGestureStrategy: jsonDefaults.Camera.Settings.focusGestureStrategy,
2522
+ shouldPreferSmoothAutoFocus: jsonDefaults.Camera.Settings.shouldPreferSmoothAutoFocus,
2523
+ properties: jsonDefaults.Camera.Settings.properties,
2524
+ },
2525
+ defaultPosition: (jsonDefaults.Camera.defaultPosition || null),
2526
+ availablePositions: jsonDefaults.Camera.availablePositions,
2527
+ },
2528
+ DataCaptureView: {
2529
+ scanAreaMargins: MarginsWithUnit
2530
+ .fromJSON(JSON.parse(jsonDefaults.DataCaptureView.scanAreaMargins)),
2531
+ pointOfInterest: PointWithUnit
2532
+ .fromJSON(JSON.parse(jsonDefaults.DataCaptureView.pointOfInterest)),
2533
+ logoAnchor: jsonDefaults.DataCaptureView.logoAnchor,
2534
+ logoOffset: PointWithUnit
2535
+ .fromJSON(JSON.parse(jsonDefaults.DataCaptureView.logoOffset)),
2536
+ focusGesture: PrivateFocusGestureDeserializer
2537
+ .fromJSON(JSON.parse(jsonDefaults.DataCaptureView.focusGesture)),
2538
+ zoomGesture: PrivateZoomGestureDeserializer
2539
+ .fromJSON(JSON.parse(jsonDefaults.DataCaptureView.zoomGesture)),
2540
+ logoStyle: jsonDefaults.DataCaptureView.logoStyle,
2541
+ },
2542
+ LaserlineViewfinder: Object
2543
+ .keys(jsonDefaults.LaserlineViewfinder.styles)
2544
+ .reduce((acc, key) => {
2545
+ const viewfinder = jsonDefaults.LaserlineViewfinder.styles[key];
2546
+ acc.styles[key] = {
2547
+ width: NumberWithUnit
2548
+ .fromJSON(JSON.parse(viewfinder.width)),
2549
+ enabledColor: Color
2550
+ .fromJSON(viewfinder.enabledColor),
2551
+ disabledColor: Color
2552
+ .fromJSON(viewfinder.disabledColor),
2553
+ style: viewfinder.style,
2554
+ };
2555
+ return acc;
2556
+ }, { defaultStyle: jsonDefaults.LaserlineViewfinder.defaultStyle, styles: {} }),
2557
+ RectangularViewfinder: Object
2558
+ .keys(jsonDefaults.RectangularViewfinder.styles)
2559
+ .reduce((acc, key) => {
2560
+ const viewfinder = jsonDefaults.RectangularViewfinder.styles[key];
2561
+ acc.styles[key] = {
2562
+ size: SizeWithUnitAndAspect
2563
+ .fromJSON(JSON.parse(viewfinder.size)),
2564
+ color: Color.fromJSON(viewfinder.color),
2565
+ disabledColor: Color.fromJSON(viewfinder.disabledColor),
2566
+ style: viewfinder.style,
2567
+ lineStyle: viewfinder.lineStyle,
2568
+ dimming: viewfinder.dimming,
2569
+ disabledDimming: viewfinder.disabledDimming,
2570
+ animation: RectangularViewfinderAnimation
2571
+ .fromJSON(JSON.parse(viewfinder.animation)),
2572
+ };
2573
+ return acc;
2574
+ }, { defaultStyle: jsonDefaults.RectangularViewfinder.defaultStyle, styles: {} }),
2575
+ SpotlightViewfinder: {
2576
+ size: SizeWithUnitAndAspect
2577
+ .fromJSON(JSON.parse(jsonDefaults.SpotlightViewfinder.size)),
2578
+ enabledBorderColor: Color
2579
+ .fromJSON(jsonDefaults.SpotlightViewfinder.enabledBorderColor),
2580
+ disabledBorderColor: Color
2581
+ .fromJSON(jsonDefaults.SpotlightViewfinder.disabledBorderColor),
2582
+ backgroundColor: Color
2583
+ .fromJSON(jsonDefaults.SpotlightViewfinder.backgroundColor),
2584
+ },
2585
+ AimerViewfinder: {
2586
+ frameColor: Color.fromJSON(jsonDefaults.AimerViewfinder.frameColor),
2587
+ dotColor: Color.fromJSON(jsonDefaults.AimerViewfinder.dotColor),
2588
+ },
2589
+ Brush: {
2590
+ fillColor: Color
2591
+ .fromJSON(jsonDefaults.Brush.fillColor),
2592
+ strokeColor: Color
2593
+ .fromJSON(jsonDefaults.Brush.strokeColor),
2594
+ strokeWidth: jsonDefaults.Brush.strokeWidth,
2595
+ },
2596
+ deviceID: jsonDefaults.deviceID,
2597
+ };
2598
+ // Inject defaults to avoid a circular dependency between these classes and the defaults
2599
+ Brush.defaults = coreDefaults.Brush;
2600
+ return coreDefaults;
2601
+ }
2602
+
2603
+ function loadCoreDefaults(jsonDefaults) {
2604
+ const coreDefaults = parseDefaults(jsonDefaults);
2605
+ FactoryMaker.bindInstanceIfNotExists('CoreDefaults', coreDefaults);
2606
+ }
2200
2607
 
2201
2608
  var VibrationType;
2202
2609
  (function (VibrationType) {
@@ -2272,427 +2679,138 @@ __decorate([
2272
2679
  class FeedbackController {
2273
2680
  constructor(feedback) {
2274
2681
  this.feedback = feedback;
2275
- this._proxy = FactoryMaker.getInstance('FeedbackProxy');
2276
- }
2277
- static forFeedback(feedback) {
2278
- const controller = new FeedbackController(feedback);
2279
- return controller;
2280
- }
2281
- emit() {
2282
- this._proxy.emitFeedback(this.feedback);
2283
- }
2284
- }
2285
-
2286
- class Feedback extends DefaultSerializeable {
2287
- static get defaultFeedback() {
2288
- return new Feedback(Vibration.defaultVibration, Sound.defaultSound);
2289
- }
2290
- get vibration() {
2291
- return this._vibration;
2292
- }
2293
- get sound() {
2294
- return this._sound;
2295
- }
2296
- static fromJSON(json) {
2297
- return new Feedback((json === null || json === void 0 ? void 0 : json.vibration) ? Vibration.fromJSON(json.vibration) : null, (json === null || json === void 0 ? void 0 : json.sound) ? Sound.fromJSON(json.sound) : null);
2298
- }
2299
- constructor(vibration, sound) {
2300
- super();
2301
- this._vibration = null;
2302
- this._sound = null;
2303
- this._vibration = vibration;
2304
- this._sound = sound;
2305
- this.controller = FeedbackController.forFeedback(this);
2306
- }
2307
- emit() {
2308
- this.controller.emit();
2309
- }
2310
- toJSON() {
2311
- return super.toJSON();
2312
- }
2313
- }
2314
- __decorate([
2315
- ignoreFromSerializationIfNull,
2316
- nameForSerialization('vibration')
2317
- ], Feedback.prototype, "_vibration", void 0);
2318
- __decorate([
2319
- ignoreFromSerializationIfNull,
2320
- nameForSerialization('sound')
2321
- ], Feedback.prototype, "_sound", void 0);
2322
- __decorate([
2323
- ignoreFromSerialization
2324
- ], Feedback.prototype, "controller", void 0);
2325
-
2326
- const NoneLocationSelection = { type: 'none' };
2327
-
2328
- class RadiusLocationSelection extends DefaultSerializeable {
2329
- get radius() {
2330
- return this._radius;
2331
- }
2332
- static fromJSON(JSON) {
2333
- const radius = NumberWithUnit.fromJSON(JSON.radius);
2334
- return new RadiusLocationSelection(radius);
2335
- }
2336
- constructor(radius) {
2337
- super();
2338
- this.type = 'radius';
2339
- this._radius = radius;
2340
- }
2341
- }
2342
- __decorate([
2343
- nameForSerialization('radius')
2344
- ], RadiusLocationSelection.prototype, "_radius", void 0);
2345
-
2346
- class RectangularLocationSelection extends DefaultSerializeable {
2347
- constructor() {
2348
- super(...arguments);
2349
- this.type = 'rectangular';
2350
- }
2351
- get sizeWithUnitAndAspect() {
2352
- return this._sizeWithUnitAndAspect;
2353
- }
2354
- static withSize(size) {
2355
- const locationSelection = new RectangularLocationSelection();
2356
- locationSelection._sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithWidthAndHeight(size);
2357
- return locationSelection;
2358
- }
2359
- static withWidthAndAspectRatio(width, heightToWidthAspectRatio) {
2360
- const locationSelection = new RectangularLocationSelection();
2361
- locationSelection._sizeWithUnitAndAspect = SizeWithUnitAndAspect
2362
- .sizeWithWidthAndAspectRatio(width, heightToWidthAspectRatio);
2363
- return locationSelection;
2364
- }
2365
- static withHeightAndAspectRatio(height, widthToHeightAspectRatio) {
2366
- const locationSelection = new RectangularLocationSelection();
2367
- locationSelection._sizeWithUnitAndAspect = SizeWithUnitAndAspect
2368
- .sizeWithHeightAndAspectRatio(height, widthToHeightAspectRatio);
2369
- return locationSelection;
2370
- }
2371
- static fromJSON(rectangularLocationSelectionJSON) {
2372
- if (rectangularLocationSelectionJSON.aspect.width && rectangularLocationSelectionJSON.aspect.height) {
2373
- const width = NumberWithUnit
2374
- .fromJSON(rectangularLocationSelectionJSON.aspect.width);
2375
- const height = NumberWithUnit
2376
- .fromJSON(rectangularLocationSelectionJSON.aspect.height);
2377
- const size = new SizeWithUnit(width, height);
2378
- return this.withSize(size);
2379
- }
2380
- else if (rectangularLocationSelectionJSON.aspect.width && rectangularLocationSelectionJSON.aspect.aspect) {
2381
- const width = NumberWithUnit
2382
- .fromJSON(rectangularLocationSelectionJSON.aspect.width);
2383
- return this.withWidthAndAspectRatio(width, rectangularLocationSelectionJSON.aspect.aspect);
2384
- }
2385
- else if (rectangularLocationSelectionJSON.aspect.height && rectangularLocationSelectionJSON.aspect.aspect) {
2386
- const height = NumberWithUnit
2387
- .fromJSON(rectangularLocationSelectionJSON.aspect.height);
2388
- return this.withHeightAndAspectRatio(height, rectangularLocationSelectionJSON.aspect.aspect);
2389
- }
2390
- else if (rectangularLocationSelectionJSON.aspect.shorterDimension && rectangularLocationSelectionJSON.aspect.aspect) {
2391
- const shorterDimension = NumberWithUnit
2392
- .fromJSON(rectangularLocationSelectionJSON.aspect.shorterDimension);
2393
- const sizeWithUnitAndAspect = SizeWithUnitAndAspect
2394
- .sizeWithShorterDimensionAndAspectRatio(shorterDimension, rectangularLocationSelectionJSON.aspect.aspect);
2395
- const locationSelection = new RectangularLocationSelection();
2396
- locationSelection._sizeWithUnitAndAspect = sizeWithUnitAndAspect;
2397
- return locationSelection;
2398
- }
2399
- else {
2400
- throw new Error(`RectangularLocationSelectionJSON is malformed: ${JSON.stringify(rectangularLocationSelectionJSON)}`);
2401
- }
2402
- }
2403
- }
2404
- __decorate([
2405
- nameForSerialization('size')
2406
- ], RectangularLocationSelection.prototype, "_sizeWithUnitAndAspect", void 0);
2407
-
2408
- var DataCaptureViewEvents;
2409
- (function (DataCaptureViewEvents) {
2410
- DataCaptureViewEvents["didChangeSize"] = "didChangeSize";
2411
- })(DataCaptureViewEvents || (DataCaptureViewEvents = {}));
2412
- class DataCaptureViewController extends BaseController {
2413
- static forDataCaptureView(view) {
2414
- const controller = new DataCaptureViewController();
2415
- controller.view = view;
2416
- controller.createView();
2417
- controller.subscribeListener();
2418
- return controller;
2419
- }
2420
- constructor() {
2421
- super('DataCaptureViewProxy');
2422
- }
2423
- viewPointForFramePoint(point) {
2424
- return __awaiter(this, void 0, void 0, function* () {
2425
- const jsonString = yield this._proxy.viewPointForFramePoint(JSON.stringify(point.toJSON()));
2426
- return Point.fromJSON(JSON.parse(jsonString));
2427
- });
2428
- }
2429
- viewQuadrilateralForFrameQuadrilateral(quadrilateral) {
2430
- return __awaiter(this, void 0, void 0, function* () {
2431
- const jsonString = yield this._proxy.viewQuadrilateralForFrameQuadrilateral(JSON.stringify(quadrilateral.toJSON()));
2432
- return Quadrilateral.fromJSON(JSON.parse(jsonString));
2433
- });
2434
- }
2435
- setPositionAndSize(top, left, width, height, shouldBeUnderWebView) {
2436
- return this._proxy.setPositionAndSize(top, left, width, height, shouldBeUnderWebView);
2437
- }
2438
- show() {
2439
- return this._proxy.show();
2440
- }
2441
- hide() {
2442
- return this._proxy.hide();
2443
- }
2444
- createView() {
2445
- return this._proxy.createView(JSON.stringify(this.view.toJSON()));
2446
- }
2447
- updateView() {
2448
- return this._proxy.updateView(JSON.stringify(this.view.toJSON()));
2449
- }
2450
- dispose() {
2451
- this.unsubscribeListener();
2452
- }
2453
- addOverlay(overlay) {
2454
- return this._proxy.addOverlay(JSON.stringify(overlay.toJSON()));
2455
- }
2456
- removeOverlay(overlay) {
2457
- return this._proxy.removeOverlay(JSON.stringify(overlay.toJSON()));
2458
- }
2459
- removeAllOverlays() {
2460
- return this._proxy.removeAllOverlays();
2461
- }
2462
- subscribeListener() {
2463
- var _a, _b;
2464
- this._proxy.registerListenerForViewEvents();
2465
- (_b = (_a = this._proxy).subscribeDidChangeSize) === null || _b === void 0 ? void 0 : _b.call(_a);
2466
- this.eventEmitter.on(DataCaptureViewEvents.didChangeSize, (payload) => {
2467
- const payloadJSON = JSON.parse(payload);
2468
- const size = Size.fromJSON(payloadJSON.size);
2469
- const orientation = payloadJSON.orientation;
2470
- this.view.listeners.forEach(listener => {
2471
- if (listener.didChangeSize) {
2472
- listener.didChangeSize(this.view.viewComponent, size, orientation);
2473
- }
2474
- });
2475
- });
2476
- }
2477
- unsubscribeListener() {
2478
- this._proxy.unregisterListenerForViewEvents();
2479
- this.eventEmitter.removeAllListeners();
2480
- }
2481
- }
2482
-
2483
- class BaseDataCaptureView extends DefaultSerializeable {
2484
- get context() {
2485
- return this._context;
2486
- }
2487
- set context(context) {
2488
- if (!(context instanceof DataCaptureContext || context == null)) {
2489
- // This should never happen, but let's just be sure
2490
- throw new Error('The context for a capture view must be a DataCaptureContext');
2491
- }
2492
- this._context = context;
2493
- if (this._context) {
2494
- this._context.view = this;
2495
- }
2496
- }
2497
- get coreDefaults() {
2498
- return getCoreDefaults();
2499
- }
2500
- get scanAreaMargins() {
2501
- return this._scanAreaMargins;
2502
- }
2503
- set scanAreaMargins(newValue) {
2504
- this._scanAreaMargins = newValue;
2505
- this.controller.updateView();
2506
- }
2507
- get pointOfInterest() {
2508
- return this._pointOfInterest;
2509
- }
2510
- set pointOfInterest(newValue) {
2511
- this._pointOfInterest = newValue;
2512
- this.controller.updateView();
2513
- }
2514
- get logoAnchor() {
2515
- return this._logoAnchor;
2516
- }
2517
- set logoAnchor(newValue) {
2518
- this._logoAnchor = newValue;
2519
- this.controller.updateView();
2682
+ this._proxy = FactoryMaker.getInstance('FeedbackProxy');
2520
2683
  }
2521
- get logoOffset() {
2522
- return this._logoOffset;
2684
+ static forFeedback(feedback) {
2685
+ const controller = new FeedbackController(feedback);
2686
+ return controller;
2523
2687
  }
2524
- set logoOffset(newValue) {
2525
- this._logoOffset = newValue;
2526
- this.controller.updateView();
2688
+ emit() {
2689
+ this._proxy.emitFeedback(this.feedback);
2527
2690
  }
2528
- get focusGesture() {
2529
- return this._focusGesture;
2691
+ }
2692
+
2693
+ class Feedback extends DefaultSerializeable {
2694
+ static get defaultFeedback() {
2695
+ return new Feedback(Vibration.defaultVibration, Sound.defaultSound);
2530
2696
  }
2531
- set focusGesture(newValue) {
2532
- this._focusGesture = newValue;
2533
- this.controller.updateView();
2697
+ get vibration() {
2698
+ return this._vibration;
2534
2699
  }
2535
- get zoomGesture() {
2536
- return this._zoomGesture;
2700
+ get sound() {
2701
+ return this._sound;
2537
2702
  }
2538
- set zoomGesture(newValue) {
2539
- this._zoomGesture = newValue;
2540
- this.controller.updateView();
2703
+ static fromJSON(json) {
2704
+ return new Feedback((json === null || json === void 0 ? void 0 : json.vibration) ? Vibration.fromJSON(json.vibration) : null, (json === null || json === void 0 ? void 0 : json.sound) ? Sound.fromJSON(json.sound) : null);
2541
2705
  }
2542
- get logoStyle() {
2543
- return this._logoStyle;
2706
+ constructor(vibration, sound) {
2707
+ super();
2708
+ this._vibration = null;
2709
+ this._sound = null;
2710
+ this._vibration = vibration;
2711
+ this._sound = sound;
2712
+ this.controller = FeedbackController.forFeedback(this);
2544
2713
  }
2545
- set logoStyle(newValue) {
2546
- this._logoStyle = newValue;
2547
- this.controller.updateView();
2714
+ emit() {
2715
+ this.controller.emit();
2548
2716
  }
2549
- get privateContext() {
2550
- return this.context;
2717
+ toJSON() {
2718
+ return super.toJSON();
2551
2719
  }
2552
- static forContext(context) {
2553
- const view = new BaseDataCaptureView();
2554
- view.context = context;
2555
- return view;
2720
+ }
2721
+ __decorate([
2722
+ ignoreFromSerializationIfNull,
2723
+ nameForSerialization('vibration')
2724
+ ], Feedback.prototype, "_vibration", void 0);
2725
+ __decorate([
2726
+ ignoreFromSerializationIfNull,
2727
+ nameForSerialization('sound')
2728
+ ], Feedback.prototype, "_sound", void 0);
2729
+ __decorate([
2730
+ ignoreFromSerialization
2731
+ ], Feedback.prototype, "controller", void 0);
2732
+
2733
+ const NoneLocationSelection = { type: 'none' };
2734
+
2735
+ class RadiusLocationSelection extends DefaultSerializeable {
2736
+ get radius() {
2737
+ return this._radius;
2556
2738
  }
2557
- constructor() {
2558
- super();
2559
- this._context = null;
2560
- this.overlays = [];
2561
- this.controls = [];
2562
- this.listeners = [];
2563
- this.controller = DataCaptureViewController.forDataCaptureView(this);
2564
- this._scanAreaMargins = this.coreDefaults.DataCaptureView.scanAreaMargins;
2565
- this._pointOfInterest = this.coreDefaults.DataCaptureView.pointOfInterest;
2566
- this._logoAnchor = this.coreDefaults.DataCaptureView.logoAnchor;
2567
- this._logoOffset = this.coreDefaults.DataCaptureView.logoOffset;
2568
- this._focusGesture = this.coreDefaults.DataCaptureView.focusGesture;
2569
- this._zoomGesture = this.coreDefaults.DataCaptureView.zoomGesture;
2570
- this._logoStyle = this.coreDefaults.DataCaptureView.logoStyle;
2739
+ static fromJSON(JSON) {
2740
+ const radius = NumberWithUnit.fromJSON(JSON.radius);
2741
+ return new RadiusLocationSelection(radius);
2571
2742
  }
2572
- addOverlay(overlay) {
2573
- if (this.overlays.includes(overlay)) {
2574
- return;
2575
- }
2576
- overlay.view = this;
2577
- this.overlays.push(overlay);
2578
- this.controller.addOverlay(overlay);
2743
+ constructor(radius) {
2744
+ super();
2745
+ this.type = 'radius';
2746
+ this._radius = radius;
2579
2747
  }
2580
- removeOverlay(overlay) {
2581
- if (!this.overlays.includes(overlay)) {
2582
- return;
2583
- }
2584
- overlay.view = null;
2585
- this.overlays.splice(this.overlays.indexOf(overlay), 1);
2586
- this.controller.removeOverlay(overlay);
2748
+ }
2749
+ __decorate([
2750
+ nameForSerialization('radius')
2751
+ ], RadiusLocationSelection.prototype, "_radius", void 0);
2752
+
2753
+ class RectangularLocationSelection extends DefaultSerializeable {
2754
+ constructor() {
2755
+ super(...arguments);
2756
+ this.type = 'rectangular';
2587
2757
  }
2588
- addListener(listener) {
2589
- if (!this.listeners.includes(listener)) {
2590
- this.listeners.push(listener);
2591
- }
2758
+ get sizeWithUnitAndAspect() {
2759
+ return this._sizeWithUnitAndAspect;
2592
2760
  }
2593
- removeListener(listener) {
2594
- if (this.listeners.includes(listener)) {
2595
- this.listeners.splice(this.listeners.indexOf(listener), 1);
2596
- }
2761
+ static withSize(size) {
2762
+ const locationSelection = new RectangularLocationSelection();
2763
+ locationSelection._sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithWidthAndHeight(size);
2764
+ return locationSelection;
2597
2765
  }
2598
- viewPointForFramePoint(point) {
2599
- return this.controller.viewPointForFramePoint(point);
2766
+ static withWidthAndAspectRatio(width, heightToWidthAspectRatio) {
2767
+ const locationSelection = new RectangularLocationSelection();
2768
+ locationSelection._sizeWithUnitAndAspect = SizeWithUnitAndAspect
2769
+ .sizeWithWidthAndAspectRatio(width, heightToWidthAspectRatio);
2770
+ return locationSelection;
2600
2771
  }
2601
- viewQuadrilateralForFrameQuadrilateral(quadrilateral) {
2602
- return this.controller.viewQuadrilateralForFrameQuadrilateral(quadrilateral);
2772
+ static withHeightAndAspectRatio(height, widthToHeightAspectRatio) {
2773
+ const locationSelection = new RectangularLocationSelection();
2774
+ locationSelection._sizeWithUnitAndAspect = SizeWithUnitAndAspect
2775
+ .sizeWithHeightAndAspectRatio(height, widthToHeightAspectRatio);
2776
+ return locationSelection;
2603
2777
  }
2604
- addControl(control) {
2605
- if (!this.controls.includes(control)) {
2606
- control.view = this;
2607
- this.controls.push(control);
2608
- this.controller.updateView();
2778
+ static fromJSON(rectangularLocationSelectionJSON) {
2779
+ if (rectangularLocationSelectionJSON.aspect.width && rectangularLocationSelectionJSON.aspect.height) {
2780
+ const width = NumberWithUnit
2781
+ .fromJSON(rectangularLocationSelectionJSON.aspect.width);
2782
+ const height = NumberWithUnit
2783
+ .fromJSON(rectangularLocationSelectionJSON.aspect.height);
2784
+ const size = new SizeWithUnit(width, height);
2785
+ return this.withSize(size);
2609
2786
  }
2610
- }
2611
- addControlWithAnchorAndOffset(control, anchor, offset) {
2612
- if (!this.controls.includes(control)) {
2613
- control.view = this;
2614
- control.anchor = anchor;
2615
- control.offset = offset;
2616
- this.controls.push(control);
2617
- this.controller.updateView();
2787
+ else if (rectangularLocationSelectionJSON.aspect.width && rectangularLocationSelectionJSON.aspect.aspect) {
2788
+ const width = NumberWithUnit
2789
+ .fromJSON(rectangularLocationSelectionJSON.aspect.width);
2790
+ return this.withWidthAndAspectRatio(width, rectangularLocationSelectionJSON.aspect.aspect);
2618
2791
  }
2619
- }
2620
- removeControl(control) {
2621
- if (this.controls.includes(control)) {
2622
- control.view = null;
2623
- this.controls.splice(this.controls.indexOf(control), 1);
2624
- this.controller.updateView();
2792
+ else if (rectangularLocationSelectionJSON.aspect.height && rectangularLocationSelectionJSON.aspect.aspect) {
2793
+ const height = NumberWithUnit
2794
+ .fromJSON(rectangularLocationSelectionJSON.aspect.height);
2795
+ return this.withHeightAndAspectRatio(height, rectangularLocationSelectionJSON.aspect.aspect);
2625
2796
  }
2626
- }
2627
- controlUpdated() {
2628
- this.controller.updateView();
2629
- }
2630
- dispose() {
2631
- this.overlays = [];
2632
- this.controller.removeAllOverlays();
2633
- this.listeners.forEach(listener => this.removeListener(listener));
2634
- this.controller.dispose();
2635
- }
2636
- // HTML Views only
2637
- setFrame(frame, isUnderContent = false) {
2638
- return this.setPositionAndSize(frame.origin.y, frame.origin.x, frame.size.width, frame.size.height, isUnderContent);
2639
- }
2640
- setPositionAndSize(top, left, width, height, shouldBeUnderWebView) {
2641
- return this.controller.setPositionAndSize(top, left, width, height, shouldBeUnderWebView);
2642
- }
2643
- show() {
2644
- if (!this.context) {
2645
- throw new Error('There should be a context attached to a view that should be shown');
2797
+ else if (rectangularLocationSelectionJSON.aspect.shorterDimension && rectangularLocationSelectionJSON.aspect.aspect) {
2798
+ const shorterDimension = NumberWithUnit
2799
+ .fromJSON(rectangularLocationSelectionJSON.aspect.shorterDimension);
2800
+ const sizeWithUnitAndAspect = SizeWithUnitAndAspect
2801
+ .sizeWithShorterDimensionAndAspectRatio(shorterDimension, rectangularLocationSelectionJSON.aspect.aspect);
2802
+ const locationSelection = new RectangularLocationSelection();
2803
+ locationSelection._sizeWithUnitAndAspect = sizeWithUnitAndAspect;
2804
+ return locationSelection;
2646
2805
  }
2647
- this.privateContext.initialize();
2648
- return this.controller.show();
2649
- }
2650
- hide() {
2651
- if (!this.context) {
2652
- throw new Error('There should be a context attached to a view that should be shown');
2806
+ else {
2807
+ throw new Error(`RectangularLocationSelectionJSON is malformed: ${JSON.stringify(rectangularLocationSelectionJSON)}`);
2653
2808
  }
2654
- return this.controller.hide();
2655
2809
  }
2656
2810
  }
2657
2811
  __decorate([
2658
- ignoreFromSerialization
2659
- ], BaseDataCaptureView.prototype, "_context", void 0);
2660
- __decorate([
2661
- ignoreFromSerialization
2662
- ], BaseDataCaptureView.prototype, "viewComponent", void 0);
2663
- __decorate([
2664
- ignoreFromSerialization
2665
- ], BaseDataCaptureView.prototype, "coreDefaults", null);
2666
- __decorate([
2667
- ignoreFromSerialization
2668
- ], BaseDataCaptureView.prototype, "_scanAreaMargins", void 0);
2669
- __decorate([
2670
- ignoreFromSerialization
2671
- ], BaseDataCaptureView.prototype, "_pointOfInterest", void 0);
2672
- __decorate([
2673
- ignoreFromSerialization
2674
- ], BaseDataCaptureView.prototype, "_logoAnchor", void 0);
2675
- __decorate([
2676
- ignoreFromSerialization
2677
- ], BaseDataCaptureView.prototype, "_logoOffset", void 0);
2678
- __decorate([
2679
- ignoreFromSerialization
2680
- ], BaseDataCaptureView.prototype, "_focusGesture", void 0);
2681
- __decorate([
2682
- ignoreFromSerialization
2683
- ], BaseDataCaptureView.prototype, "_zoomGesture", void 0);
2684
- __decorate([
2685
- ignoreFromSerialization
2686
- ], BaseDataCaptureView.prototype, "_logoStyle", void 0);
2687
- __decorate([
2688
- ignoreFromSerialization
2689
- ], BaseDataCaptureView.prototype, "overlays", void 0);
2690
- __decorate([
2691
- ignoreFromSerialization
2692
- ], BaseDataCaptureView.prototype, "controller", void 0);
2693
- __decorate([
2694
- ignoreFromSerialization
2695
- ], BaseDataCaptureView.prototype, "listeners", void 0);
2812
+ nameForSerialization('size')
2813
+ ], RectangularLocationSelection.prototype, "_sizeWithUnitAndAspect", void 0);
2696
2814
 
2697
2815
  class LicenseInfo extends DefaultSerializeable {
2698
2816
  get expiration() {
@@ -2713,5 +2831,5 @@ var Expiration;
2713
2831
 
2714
2832
  createEventEmitter();
2715
2833
 
2716
- export { AimerViewfinder, Anchor, BaseController, BaseDataCaptureView, BaseNativeProxy, Brush, Camera, CameraController, CameraPosition, CameraSettings, Color, ContextStatus, DataCaptureContext, DataCaptureContextEvents, DataCaptureContextSettings, DataCaptureViewController, DataCaptureViewEvents, DefaultSerializeable, Direction, EventEmitter, Expiration, FactoryMaker, Feedback, FocusGestureStrategy, FocusRange, FrameSourceListenerEvents, FrameSourceState, ImageBuffer, ImageFrameSource, LaserlineViewfinder, LaserlineViewfinderStyle, LicenseInfo, LogoStyle, MarginsWithUnit, MeasureUnit, NoViewfinder, NoneLocationSelection, NumberWithUnit, Orientation, Point, PointWithUnit, PrivateFocusGestureDeserializer, PrivateFrameData, PrivateZoomGestureDeserializer, Quadrilateral, RadiusLocationSelection, Rect, RectWithUnit, RectangularLocationSelection, RectangularViewfinder, RectangularViewfinderAnimation, RectangularViewfinderLineStyle, RectangularViewfinderStyle, Size, SizeWithAspect, SizeWithUnit, SizeWithUnitAndAspect, SizingMode, Sound, SpotlightViewfinder, SwipeToZoom, TapToFocus, TorchState, TorchSwitchControl, Vibration, VibrationType, VideoResolution, WaveFormVibration, ZoomSwitchControl, getCoreDefaults, ignoreFromSerialization, ignoreFromSerializationIfNull, loadCoreDefaults, nameForSerialization, serializationDefault };
2834
+ export { AimerViewfinder, Anchor, BaseController, BaseDataCaptureView, BaseNativeProxy, Brush, Camera, CameraController, CameraPosition, CameraSettings, Color, ContextStatus, ControlImage, DataCaptureContext, DataCaptureContextEvents, DataCaptureContextSettings, DataCaptureViewController, DataCaptureViewEvents, DefaultSerializeable, Direction, EventEmitter, Expiration, FactoryMaker, Feedback, FocusGestureStrategy, FocusRange, FrameSourceListenerEvents, FrameSourceState, ImageBuffer, ImageFrameSource, LaserlineViewfinder, LaserlineViewfinderStyle, LicenseInfo, LogoStyle, MarginsWithUnit, MeasureUnit, NoViewfinder, NoneLocationSelection, NumberWithUnit, Orientation, Point, PointWithUnit, PrivateFocusGestureDeserializer, PrivateFrameData, PrivateZoomGestureDeserializer, Quadrilateral, RadiusLocationSelection, Rect, RectWithUnit, RectangularLocationSelection, RectangularViewfinder, RectangularViewfinderAnimation, RectangularViewfinderLineStyle, RectangularViewfinderStyle, Size, SizeWithAspect, SizeWithUnit, SizeWithUnitAndAspect, SizingMode, Sound, SpotlightViewfinder, SwipeToZoom, TapToFocus, TorchState, TorchSwitchControl, Vibration, VibrationType, VideoResolution, WaveFormVibration, ZoomSwitchControl, getCoreDefaults, ignoreFromSerialization, ignoreFromSerializationIfNull, loadCoreDefaults, nameForSerialization, serializationDefault };
2717
2835
  //# sourceMappingURL=index.js.map