scandit-datacapture-frameworks-core 6.21.2 → 6.22.0-beta.1

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
@@ -365,8 +365,10 @@ class FactoryMaker {
365
365
  console.warn(`Trying to get a non existing instance for ${clsName}`);
366
366
  return;
367
367
  }
368
- const instance = item.instance ? item.instance : (_a = item.builder) === null || _a === void 0 ? void 0 : _a.call(item);
369
- return instance;
368
+ if (!item.instance && item.builder) {
369
+ item.instance = (_a = item.builder) === null || _a === void 0 ? void 0 : _a.call(item);
370
+ }
371
+ return item.instance;
370
372
  }
371
373
  }
372
374
  FactoryMaker.instances = new Map();
@@ -590,6 +592,9 @@ class ImageFrameSourceController {
590
592
  getCurrentState() {
591
593
  return this._proxy.getCurrentCameraState(this.imageFrameSource.position);
592
594
  }
595
+ switchCameraToDesiredState(desiredStateJson) {
596
+ return this._proxy.switchCameraToDesiredState(desiredStateJson);
597
+ }
593
598
  subscribeListener() {
594
599
  this._proxy.registerListenerForEvents();
595
600
  this._proxy.subscribeDidChangeState();
@@ -652,7 +657,7 @@ class ImageFrameSource extends DefaultSerializeable {
652
657
  }
653
658
  switchToDesiredState(state) {
654
659
  this._desiredState = state;
655
- return this.didChange();
660
+ return this.controller.switchCameraToDesiredState(state);
656
661
  }
657
662
  addListener(listener) {
658
663
  if (listener == null) {
@@ -751,6 +756,9 @@ class CameraController {
751
756
  getIsTorchAvailable() {
752
757
  return CameraController._proxy.isTorchAvailable(this.privateCamera.position);
753
758
  }
759
+ switchCameraToDesiredState(desiredState) {
760
+ return CameraController._proxy.switchCameraToDesiredState(desiredState);
761
+ }
754
762
  subscribeListener() {
755
763
  CameraController._proxy.registerListenerForCameraEvents();
756
764
  CameraController._proxy.subscribeDidChangeState();
@@ -763,7 +771,6 @@ class CameraController {
763
771
  }
764
772
  unsubscribeListener() {
765
773
  CameraController._proxy.unregisterListenerForCameraEvents();
766
- CameraController._proxy.unsubscribeDidChangeState();
767
774
  this.eventEmitter.off(FrameSourceListenerEvents.didChangeState);
768
775
  }
769
776
  }
@@ -827,7 +834,7 @@ class Camera extends DefaultSerializeable {
827
834
  }
828
835
  switchToDesiredState(state) {
829
836
  this._desiredState = state;
830
- return this.didChange();
837
+ return this.controller.switchCameraToDesiredState(state);
831
838
  }
832
839
  getCurrentState() {
833
840
  return this.controller.getCurrentState();
@@ -835,6 +842,13 @@ class Camera extends DefaultSerializeable {
835
842
  getIsTorchAvailable() {
836
843
  return this.controller.getIsTorchAvailable();
837
844
  }
845
+ /**
846
+ * @deprecated
847
+ */
848
+ get isTorchAvailable() {
849
+ console.warn('isTorchAvailable is deprecated. Use getIsTorchAvailable instead.');
850
+ return false;
851
+ }
838
852
  addListener(listener) {
839
853
  if (listener == null) {
840
854
  return;
@@ -878,7 +892,7 @@ __decorate([
878
892
  nameForSerialization('desiredTorchState')
879
893
  ], Camera.prototype, "_desiredTorchState", void 0);
880
894
  __decorate([
881
- nameForSerialization('desiredState')
895
+ ignoreFromSerialization
882
896
  ], Camera.prototype, "_desiredState", void 0);
883
897
  __decorate([
884
898
  ignoreFromSerialization
@@ -902,6 +916,8 @@ class ZoomSwitchControl extends DefaultSerializeable {
902
916
  zoomedIn: { default: null, pressed: null },
903
917
  };
904
918
  this.view = null;
919
+ this.anchor = null;
920
+ this.offset = null;
905
921
  }
906
922
  get zoomedOutImage() {
907
923
  return this.icon.zoomedOut.default;
@@ -949,6 +965,8 @@ class TorchSwitchControl extends DefaultSerializeable {
949
965
  off: { default: null, pressed: null },
950
966
  };
951
967
  this.view = null;
968
+ this.anchor = null;
969
+ this.offset = null;
952
970
  }
953
971
  get torchOffImage() {
954
972
  return this.icon.off.default;
@@ -1947,6 +1965,12 @@ var DataCaptureContextEvents;
1947
1965
  DataCaptureContextEvents["didStartObservingContext"] = "didStartObservingContext";
1948
1966
  })(DataCaptureContextEvents || (DataCaptureContextEvents = {}));
1949
1967
  class DataCaptureContextController {
1968
+ get framework() {
1969
+ return this._proxy.framework;
1970
+ }
1971
+ get frameworkVersion() {
1972
+ return this._proxy.frameworkVersion;
1973
+ }
1950
1974
  get privateContext() {
1951
1975
  return this.context;
1952
1976
  }
@@ -1971,6 +1995,15 @@ class DataCaptureContextController {
1971
1995
  }
1972
1996
  });
1973
1997
  }
1998
+ addModeToContext(mode) {
1999
+ return this._proxy.addModeToContext(JSON.stringify(mode.toJSON()));
2000
+ }
2001
+ removeModeFromContext(mode) {
2002
+ return this._proxy.removeModeFromContext(JSON.stringify(mode.toJSON()));
2003
+ }
2004
+ removeAllModesFromContext() {
2005
+ return this._proxy.removeAllModesFromContext();
2006
+ }
1974
2007
  dispose() {
1975
2008
  this.unsubscribeListener();
1976
2009
  this._proxy.dispose();
@@ -2028,6 +2061,12 @@ class DataCaptureContextController {
2028
2061
  }
2029
2062
 
2030
2063
  class DataCaptureContext extends DefaultSerializeable {
2064
+ get framework() {
2065
+ return this.controller.framework;
2066
+ }
2067
+ get frameworkVersion() {
2068
+ return this.controller.frameworkVersion;
2069
+ }
2031
2070
  static get coreDefaults() {
2032
2071
  return getCoreDefaults();
2033
2072
  }
@@ -2037,6 +2076,13 @@ class DataCaptureContext extends DefaultSerializeable {
2037
2076
  static get deviceID() {
2038
2077
  return DataCaptureContext.coreDefaults.deviceID;
2039
2078
  }
2079
+ /**
2080
+ * @deprecated
2081
+ */
2082
+ get deviceID() {
2083
+ console.log('The instance property "deviceID" on the DataCaptureContext is deprecated, please use the static property DataCaptureContext.deviceID instead.');
2084
+ return DataCaptureContext.deviceID;
2085
+ }
2040
2086
  static forLicenseKey(licenseKey) {
2041
2087
  return DataCaptureContext.forLicenseKeyWithOptions(licenseKey, null);
2042
2088
  }
@@ -2057,16 +2103,10 @@ class DataCaptureContext extends DefaultSerializeable {
2057
2103
  super();
2058
2104
  this.licenseKey = licenseKey;
2059
2105
  this.deviceName = deviceName;
2060
- // TODO Needs to be changed
2061
- this.framework = 'capacitor';
2062
- this.frameworkVersion = `TODO:CHANGE`;
2063
2106
  this.settings = new DataCaptureContextSettings();
2064
2107
  this._frameSource = null;
2065
- // TODO: Change this
2066
- // private view: PrivateDataCaptureView | null = null;
2067
2108
  this.view = null;
2068
2109
  this.modes = [];
2069
- this.components = [];
2070
2110
  this.listeners = [];
2071
2111
  this.initialize();
2072
2112
  }
@@ -2096,14 +2136,14 @@ class DataCaptureContext extends DefaultSerializeable {
2096
2136
  if (!this.modes.includes(mode)) {
2097
2137
  this.modes.push(mode);
2098
2138
  mode._context = this;
2099
- this.update();
2139
+ this.controller.addModeToContext(mode);
2100
2140
  }
2101
2141
  }
2102
2142
  removeMode(mode) {
2103
2143
  if (this.modes.includes(mode)) {
2104
2144
  this.modes.splice(this.modes.indexOf(mode), 1);
2105
2145
  mode._context = null;
2106
- this.update();
2146
+ this.controller.removeModeFromContext(mode);
2107
2147
  }
2108
2148
  }
2109
2149
  removeAllModes() {
@@ -2111,7 +2151,7 @@ class DataCaptureContext extends DefaultSerializeable {
2111
2151
  mode._context = null;
2112
2152
  });
2113
2153
  this.modes = [];
2114
- this.update();
2154
+ this.controller.removeAllModesFromContext();
2115
2155
  }
2116
2156
  dispose() {
2117
2157
  var _a;
@@ -2139,18 +2179,13 @@ class DataCaptureContext extends DefaultSerializeable {
2139
2179
  }
2140
2180
  return this.controller.updateContextFromJSON();
2141
2181
  }
2142
- addComponent(component) {
2143
- if (this.components.includes(component)) {
2144
- return Promise.resolve();
2145
- }
2146
- this.components.push(component);
2147
- component._context = this;
2148
- return this.update();
2149
- }
2150
2182
  }
2151
2183
  __decorate([
2152
2184
  nameForSerialization('frameSource')
2153
2185
  ], DataCaptureContext.prototype, "_frameSource", void 0);
2186
+ __decorate([
2187
+ ignoreFromSerialization
2188
+ ], DataCaptureContext.prototype, "modes", void 0);
2154
2189
  __decorate([
2155
2190
  ignoreFromSerialization
2156
2191
  ], DataCaptureContext.prototype, "controller", void 0);
@@ -2161,6 +2196,15 @@ __decorate([
2161
2196
  ignoreFromSerialization
2162
2197
  ], DataCaptureContext, "coreDefaults", null);
2163
2198
 
2199
+ var VibrationType;
2200
+ (function (VibrationType) {
2201
+ VibrationType["default"] = "default";
2202
+ VibrationType["selectionHaptic"] = "selectionHaptic";
2203
+ VibrationType["successHaptic"] = "successHaptic";
2204
+ VibrationType["waveForm"] = "waveForm";
2205
+ VibrationType["impactHaptic"] = "impactHaptic";
2206
+ })(VibrationType || (VibrationType = {}));
2207
+
2164
2208
  class Vibration extends DefaultSerializeable {
2165
2209
  static get defaultVibration() {
2166
2210
  return new Vibration(VibrationType.default);
@@ -2171,6 +2215,9 @@ class Vibration extends DefaultSerializeable {
2171
2215
  static get successHapticFeedback() {
2172
2216
  return new Vibration(VibrationType.successHaptic);
2173
2217
  }
2218
+ static get impactHapticFeedback() {
2219
+ return new Vibration(VibrationType.impactHaptic);
2220
+ }
2174
2221
  static fromJSON(json) {
2175
2222
  if (json.type === 'waveForm') {
2176
2223
  return new WaveFormVibration(json.timings, json.amplitudes);
@@ -2182,13 +2229,6 @@ class Vibration extends DefaultSerializeable {
2182
2229
  this.type = type;
2183
2230
  }
2184
2231
  }
2185
- var VibrationType;
2186
- (function (VibrationType) {
2187
- VibrationType["default"] = "default";
2188
- VibrationType["selectionHaptic"] = "selectionHaptic";
2189
- VibrationType["successHaptic"] = "successHaptic";
2190
- VibrationType["waveForm"] = "waveForm";
2191
- })(VibrationType || (VibrationType = {}));
2192
2232
  class WaveFormVibration extends Vibration {
2193
2233
  get timings() {
2194
2234
  return this._timings;
@@ -2371,6 +2411,7 @@ class DataCaptureViewController extends BaseController {
2371
2411
  static forDataCaptureView(view) {
2372
2412
  const controller = new DataCaptureViewController();
2373
2413
  controller.view = view;
2414
+ controller.createView();
2374
2415
  controller.subscribeListener();
2375
2416
  return controller;
2376
2417
  }
@@ -2398,9 +2439,24 @@ class DataCaptureViewController extends BaseController {
2398
2439
  hide() {
2399
2440
  return this._proxy.hide();
2400
2441
  }
2442
+ createView() {
2443
+ return this._proxy.createView(JSON.stringify(this.view.toJSON()));
2444
+ }
2445
+ updateView() {
2446
+ return this._proxy.updateView(JSON.stringify(this.view.toJSON()));
2447
+ }
2401
2448
  dispose() {
2402
2449
  this.unsubscribeListener();
2403
2450
  }
2451
+ addOverlay(overlay) {
2452
+ return this._proxy.addOverlay(JSON.stringify(overlay.toJSON()));
2453
+ }
2454
+ removeOverlay(overlay) {
2455
+ return this._proxy.removeOverlay(JSON.stringify(overlay.toJSON()));
2456
+ }
2457
+ removeAllOverlays() {
2458
+ return this._proxy.removeAllOverlays();
2459
+ }
2404
2460
  subscribeListener() {
2405
2461
  this._proxy.registerListenerForViewEvents();
2406
2462
  this._proxy.subscribeDidChangeSize();
@@ -2433,12 +2489,60 @@ class BaseDataCaptureView extends DefaultSerializeable {
2433
2489
  this._context = context;
2434
2490
  if (this._context) {
2435
2491
  this._context.view = this;
2436
- this._context.update();
2437
2492
  }
2438
2493
  }
2439
2494
  get coreDefaults() {
2440
2495
  return getCoreDefaults();
2441
2496
  }
2497
+ get scanAreaMargins() {
2498
+ return this._scanAreaMargins;
2499
+ }
2500
+ set scanAreaMargins(newValue) {
2501
+ this._scanAreaMargins = newValue;
2502
+ this.controller.updateView();
2503
+ }
2504
+ get pointOfInterest() {
2505
+ return this._pointOfInterest;
2506
+ }
2507
+ set pointOfInterest(newValue) {
2508
+ this._pointOfInterest = newValue;
2509
+ this.controller.updateView();
2510
+ }
2511
+ get logoAnchor() {
2512
+ return this._logoAnchor;
2513
+ }
2514
+ set logoAnchor(newValue) {
2515
+ this._logoAnchor = newValue;
2516
+ this.controller.updateView();
2517
+ }
2518
+ get logoOffset() {
2519
+ return this._logoOffset;
2520
+ }
2521
+ set logoOffset(newValue) {
2522
+ this._logoOffset = newValue;
2523
+ this.controller.updateView();
2524
+ }
2525
+ get focusGesture() {
2526
+ return this._focusGesture;
2527
+ }
2528
+ set focusGesture(newValue) {
2529
+ this._focusGesture = newValue;
2530
+ this.controller.updateView();
2531
+ }
2532
+ get zoomGesture() {
2533
+ return this._zoomGesture;
2534
+ }
2535
+ set zoomGesture(newValue) {
2536
+ this._zoomGesture = newValue;
2537
+ this.controller.updateView();
2538
+ }
2539
+ get logoStyle() {
2540
+ return this._logoStyle;
2541
+ }
2542
+ set logoStyle(newValue) {
2543
+ this._logoStyle = newValue;
2544
+ this.controller.updateView();
2545
+ }
2442
2546
  get privateContext() {
2443
2547
  return this.context;
2444
2548
  }
@@ -2454,13 +2558,13 @@ class BaseDataCaptureView extends DefaultSerializeable {
2454
2558
  this.controls = [];
2455
2559
  this.listeners = [];
2456
2560
  this.controller = DataCaptureViewController.forDataCaptureView(this);
2457
- this.scanAreaMargins = this.coreDefaults.DataCaptureView.scanAreaMargins;
2458
- this.pointOfInterest = this.coreDefaults.DataCaptureView.pointOfInterest;
2459
- this.logoAnchor = this.coreDefaults.DataCaptureView.logoAnchor;
2460
- this.logoOffset = this.coreDefaults.DataCaptureView.logoOffset;
2461
- this.focusGesture = this.coreDefaults.DataCaptureView.focusGesture;
2462
- this.zoomGesture = this.coreDefaults.DataCaptureView.zoomGesture;
2463
- this.logoStyle = this.coreDefaults.DataCaptureView.logoStyle;
2561
+ this._scanAreaMargins = this.coreDefaults.DataCaptureView.scanAreaMargins;
2562
+ this._pointOfInterest = this.coreDefaults.DataCaptureView.pointOfInterest;
2563
+ this._logoAnchor = this.coreDefaults.DataCaptureView.logoAnchor;
2564
+ this._logoOffset = this.coreDefaults.DataCaptureView.logoOffset;
2565
+ this._focusGesture = this.coreDefaults.DataCaptureView.focusGesture;
2566
+ this._zoomGesture = this.coreDefaults.DataCaptureView.zoomGesture;
2567
+ this._logoStyle = this.coreDefaults.DataCaptureView.logoStyle;
2464
2568
  }
2465
2569
  addOverlay(overlay) {
2466
2570
  if (this.overlays.includes(overlay)) {
@@ -2468,7 +2572,7 @@ class BaseDataCaptureView extends DefaultSerializeable {
2468
2572
  }
2469
2573
  overlay.view = this;
2470
2574
  this.overlays.push(overlay);
2471
- this.privateContext.update();
2575
+ this.controller.addOverlay(overlay);
2472
2576
  }
2473
2577
  removeOverlay(overlay) {
2474
2578
  if (!this.overlays.includes(overlay)) {
@@ -2476,7 +2580,7 @@ class BaseDataCaptureView extends DefaultSerializeable {
2476
2580
  }
2477
2581
  overlay.view = null;
2478
2582
  this.overlays.splice(this.overlays.indexOf(overlay), 1);
2479
- this.privateContext.update();
2583
+ this.controller.removeOverlay(overlay);
2480
2584
  }
2481
2585
  addListener(listener) {
2482
2586
  if (!this.listeners.includes(listener)) {
@@ -2498,21 +2602,31 @@ class BaseDataCaptureView extends DefaultSerializeable {
2498
2602
  if (!this.controls.includes(control)) {
2499
2603
  control.view = this;
2500
2604
  this.controls.push(control);
2501
- this.privateContext.update();
2605
+ this.controller.updateView();
2606
+ }
2607
+ }
2608
+ addControlWithAnchorAndOffset(control, anchor, offset) {
2609
+ if (!this.controls.includes(control)) {
2610
+ control.view = this;
2611
+ control.anchor = anchor;
2612
+ control.offset = offset;
2613
+ this.controls.push(control);
2614
+ this.controller.updateView();
2502
2615
  }
2503
2616
  }
2504
2617
  removeControl(control) {
2505
2618
  if (this.controls.includes(control)) {
2506
2619
  control.view = null;
2507
- this.controls.splice(this.overlays.indexOf(control), 1);
2508
- this.privateContext.update();
2620
+ this.controls.splice(this.controls.indexOf(control), 1);
2621
+ this.controller.updateView();
2509
2622
  }
2510
2623
  }
2511
2624
  controlUpdated() {
2512
- this.privateContext.update();
2625
+ this.controller.updateView();
2513
2626
  }
2514
2627
  dispose() {
2515
- this.overlays.forEach(overlay => this.removeOverlay(overlay));
2628
+ this.overlays = [];
2629
+ this.controller.removeAllOverlays();
2516
2630
  this.listeners.forEach(listener => this.removeListener(listener));
2517
2631
  this.controller.dispose();
2518
2632
  }
@@ -2546,6 +2660,30 @@ __decorate([
2546
2660
  __decorate([
2547
2661
  ignoreFromSerialization
2548
2662
  ], BaseDataCaptureView.prototype, "coreDefaults", null);
2663
+ __decorate([
2664
+ ignoreFromSerialization
2665
+ ], BaseDataCaptureView.prototype, "_scanAreaMargins", void 0);
2666
+ __decorate([
2667
+ ignoreFromSerialization
2668
+ ], BaseDataCaptureView.prototype, "_pointOfInterest", void 0);
2669
+ __decorate([
2670
+ ignoreFromSerialization
2671
+ ], BaseDataCaptureView.prototype, "_logoAnchor", void 0);
2672
+ __decorate([
2673
+ ignoreFromSerialization
2674
+ ], BaseDataCaptureView.prototype, "_logoOffset", void 0);
2675
+ __decorate([
2676
+ ignoreFromSerialization
2677
+ ], BaseDataCaptureView.prototype, "_focusGesture", void 0);
2678
+ __decorate([
2679
+ ignoreFromSerialization
2680
+ ], BaseDataCaptureView.prototype, "_zoomGesture", void 0);
2681
+ __decorate([
2682
+ ignoreFromSerialization
2683
+ ], BaseDataCaptureView.prototype, "_logoStyle", void 0);
2684
+ __decorate([
2685
+ ignoreFromSerialization
2686
+ ], BaseDataCaptureView.prototype, "overlays", void 0);
2549
2687
  __decorate([
2550
2688
  ignoreFromSerialization
2551
2689
  ], BaseDataCaptureView.prototype, "controller", void 0);
@@ -2572,5 +2710,5 @@ var Expiration;
2572
2710
 
2573
2711
  createEventEmitter();
2574
2712
 
2575
- 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, VideoResolution, WaveFormVibration, ZoomSwitchControl, getCoreDefaults, ignoreFromSerialization, ignoreFromSerializationIfNull, loadCoreDefaults, nameForSerialization, serializationDefault };
2713
+ 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 };
2576
2714
  //# sourceMappingURL=index.js.map