scandit-react-native-datacapture-core 7.5.1 → 7.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -68,7 +68,7 @@ if (file( "${rootProject.projectDir}/build-test.gradle").exists()) {
68
68
  }
69
69
 
70
70
  dependencies {
71
- def sdk_version = "7.5.1"
71
+ def sdk_version = "7.6.0"
72
72
 
73
73
  println("Version of the native sdk used in this build: ${safeExtGet('global_sdk_version', sdk_version)}")
74
74
  if (findProject(':scandit-datacapture-frameworks-core') != null) {
@@ -109,7 +109,7 @@ class ScanditDataCaptureCoreModule(
109
109
  }
110
110
 
111
111
  @ReactMethod
112
- fun dispose() {
112
+ fun disposeContext() {
113
113
  coreModule.disposeContext()
114
114
  }
115
115
 
package/dist/core.js CHANGED
@@ -2239,31 +2239,44 @@ class DataCaptureContext extends DefaultSerializeable {
2239
2239
  }
2240
2240
  }
2241
2241
  addMode(mode) {
2242
+ this.addModeInternal(mode);
2243
+ }
2244
+ setMode(mode) {
2245
+ this.removeAllModes();
2246
+ this.addModeInternal(mode);
2247
+ }
2248
+ addModeInternal(mode) {
2242
2249
  if (!this.modes.includes(mode)) {
2243
2250
  this.modes.push(mode);
2244
- mode._context = this;
2245
2251
  this.controller.addModeToContext(mode);
2252
+ mode._context = this;
2246
2253
  }
2247
2254
  }
2248
- setMode(mode) {
2249
- if (this.modes.length > 0) {
2250
- this.removeAllModes();
2251
- }
2252
- this.addMode(mode);
2253
- }
2254
2255
  removeCurrentMode() {
2255
- if (this.modes.length > 0) {
2256
- this.removeMode(this.modes[0]);
2256
+ if (this.modes.length === 0) {
2257
+ return;
2258
+ }
2259
+ if (this.modes.length > 1) {
2260
+ console.warn('removeCurrentMode() called with multiple modes active. Consider using removeMode() for specific mode removal. Only the first mode will be removed.');
2257
2261
  }
2262
+ this.removeModeInternal(this.modes[0]);
2258
2263
  }
2259
2264
  removeMode(mode) {
2260
- if (this.modes.includes(mode)) {
2261
- this.modes.splice(this.modes.indexOf(mode), 1);
2262
- mode._context = null;
2263
- this.controller.removeModeFromContext(mode);
2264
- }
2265
+ this.removeModeInternal(mode);
2266
+ }
2267
+ removeModeInternal(mode) {
2268
+ return __awaiter(this, void 0, void 0, function* () {
2269
+ if (this.modes.includes(mode)) {
2270
+ this.modes.splice(this.modes.indexOf(mode), 1);
2271
+ mode._context = null;
2272
+ this.controller.removeModeFromContext(mode);
2273
+ }
2274
+ });
2265
2275
  }
2266
2276
  removeAllModes() {
2277
+ if (this.modes.length === 0) {
2278
+ return;
2279
+ }
2267
2280
  this.modes.forEach(mode => {
2268
2281
  mode._context = null;
2269
2282
  });
@@ -2328,17 +2341,9 @@ var DataCaptureViewEvents;
2328
2341
  DataCaptureViewEvents["didChangeSize"] = "DataCaptureViewListener.onSizeChanged";
2329
2342
  })(DataCaptureViewEvents || (DataCaptureViewEvents = {}));
2330
2343
  class DataCaptureViewController extends BaseController {
2331
- static forDataCaptureView(view, autoCreateNativeView) {
2332
- const controller = new DataCaptureViewController();
2333
- controller.view = view;
2334
- if (autoCreateNativeView) {
2335
- controller.createView();
2336
- controller.subscribeListener();
2337
- }
2338
- return controller;
2339
- }
2340
- constructor() {
2344
+ constructor(view) {
2341
2345
  super('DataCaptureViewProxy');
2346
+ this.view = view;
2342
2347
  }
2343
2348
  viewPointForFramePoint(point) {
2344
2349
  return __awaiter(this, void 0, void 0, function* () {
@@ -2492,13 +2497,12 @@ class BaseDataCaptureView extends DefaultSerializeable {
2492
2497
  get privateContext() {
2493
2498
  return this.context;
2494
2499
  }
2495
- static forContext(context, autoCreateNativeView = true) {
2496
- const view = new BaseDataCaptureView(autoCreateNativeView);
2500
+ static forContext(context) {
2501
+ const view = new BaseDataCaptureView(context);
2497
2502
  view.context = context;
2498
- view.isViewCreated = autoCreateNativeView;
2499
2503
  return view;
2500
2504
  }
2501
- constructor(autoCreateNativeView) {
2505
+ constructor(context) {
2502
2506
  super();
2503
2507
  this._context = null;
2504
2508
  this._viewId = -1;
@@ -2507,7 +2511,7 @@ class BaseDataCaptureView extends DefaultSerializeable {
2507
2511
  this.controls = [];
2508
2512
  this.listeners = [];
2509
2513
  this.isViewCreated = false;
2510
- this.controller = DataCaptureViewController.forDataCaptureView(this, autoCreateNativeView);
2514
+ this.context = context;
2511
2515
  this._scanAreaMargins = this.coreDefaults.DataCaptureView.scanAreaMargins;
2512
2516
  this._pointOfInterest = this.coreDefaults.DataCaptureView.pointOfInterest;
2513
2517
  this._logoAnchor = this.coreDefaults.DataCaptureView.logoAnchor;
@@ -2515,6 +2519,7 @@ class BaseDataCaptureView extends DefaultSerializeable {
2515
2519
  this._focusGesture = this.coreDefaults.DataCaptureView.focusGesture;
2516
2520
  this._zoomGesture = this.coreDefaults.DataCaptureView.zoomGesture;
2517
2521
  this._logoStyle = this.coreDefaults.DataCaptureView.logoStyle;
2522
+ this.controller = new DataCaptureViewController(this);
2518
2523
  }
2519
2524
  addOverlay(overlay) {
2520
2525
  if (this.overlays.includes(overlay)) {
@@ -2533,7 +2538,14 @@ class BaseDataCaptureView extends DefaultSerializeable {
2533
2538
  this.controller.updateView();
2534
2539
  }
2535
2540
  removeAllOverlays() {
2536
- this.overlays = [];
2541
+ if (this.overlays.length === 0) {
2542
+ return;
2543
+ }
2544
+ const overlaysCopy = [...this.overlays];
2545
+ for (const overlay of overlaysCopy) {
2546
+ overlay.view = null;
2547
+ this.overlays.splice(this.overlays.indexOf(overlay), 1);
2548
+ }
2537
2549
  this.controller.updateView();
2538
2550
  }
2539
2551
  addListener(listener) {
@@ -2598,7 +2610,7 @@ class BaseDataCaptureView extends DefaultSerializeable {
2598
2610
  });
2599
2611
  }
2600
2612
  dispose() {
2601
- this.overlays = [];
2613
+ this.removeAllOverlays();
2602
2614
  this.listeners.forEach(listener => this.removeListener(listener));
2603
2615
  this.controller.dispose();
2604
2616
  this.viewId = -1;
@@ -2937,6 +2949,7 @@ class CameraSettings extends DefaultSerializeable {
2937
2949
  return settings;
2938
2950
  }
2939
2951
  constructor(settings) {
2952
+ var _a, _b, _c, _d, _e, _f;
2940
2953
  super();
2941
2954
  this.focusHiddenProperties = [
2942
2955
  'range',
@@ -2953,13 +2966,13 @@ class CameraSettings extends DefaultSerializeable {
2953
2966
  focusGestureStrategy: CameraSettings.coreDefaults.Camera.Settings.focusGestureStrategy,
2954
2967
  shouldPreferSmoothAutoFocus: CameraSettings.coreDefaults.Camera.Settings.shouldPreferSmoothAutoFocus
2955
2968
  };
2956
- this.preferredResolution = CameraSettings.coreDefaults.Camera.Settings.preferredResolution;
2957
- this.zoomFactor = CameraSettings.coreDefaults.Camera.Settings.zoomFactor;
2958
- this.zoomGestureZoomFactor = CameraSettings.coreDefaults.Camera.Settings.zoomGestureZoomFactor;
2969
+ this.preferredResolution = (_a = settings === null || settings === void 0 ? void 0 : settings.preferredResolution) !== null && _a !== void 0 ? _a : CameraSettings.coreDefaults.Camera.Settings.preferredResolution;
2970
+ this.zoomFactor = (_b = settings === null || settings === void 0 ? void 0 : settings.zoomFactor) !== null && _b !== void 0 ? _b : CameraSettings.coreDefaults.Camera.Settings.zoomFactor;
2971
+ this.zoomGestureZoomFactor = (_c = settings === null || settings === void 0 ? void 0 : settings.zoomGestureZoomFactor) !== null && _c !== void 0 ? _c : CameraSettings.coreDefaults.Camera.Settings.zoomGestureZoomFactor;
2959
2972
  this.focus = {
2960
- range: CameraSettings.coreDefaults.Camera.Settings.focusRange,
2961
- focusGestureStrategy: CameraSettings.coreDefaults.Camera.Settings.focusGestureStrategy,
2962
- shouldPreferSmoothAutoFocus: CameraSettings.coreDefaults.Camera.Settings.shouldPreferSmoothAutoFocus,
2973
+ range: (_d = settings === null || settings === void 0 ? void 0 : settings.focusRange) !== null && _d !== void 0 ? _d : CameraSettings.coreDefaults.Camera.Settings.focusRange,
2974
+ focusGestureStrategy: (_e = settings === null || settings === void 0 ? void 0 : settings.focusGestureStrategy) !== null && _e !== void 0 ? _e : CameraSettings.coreDefaults.Camera.Settings.focusGestureStrategy,
2975
+ shouldPreferSmoothAutoFocus: (_f = settings === null || settings === void 0 ? void 0 : settings.shouldPreferSmoothAutoFocus) !== null && _f !== void 0 ? _f : CameraSettings.coreDefaults.Camera.Settings.shouldPreferSmoothAutoFocus,
2963
2976
  };
2964
2977
  if (settings !== undefined && settings !== null) {
2965
2978
  Object.getOwnPropertyNames(settings).forEach(propertyName => {