scandit-capacitor-datacapture-core 7.3.0 → 7.4.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.
@@ -16,5 +16,5 @@ Pod::Spec.new do |s|
16
16
  s.swift_version = "5.7"
17
17
 
18
18
  s.dependency "Capacitor"
19
- s.dependency "scandit-datacapture-frameworks-core", '= 7.3.0'
19
+ s.dependency "scandit-datacapture-frameworks-core", '= 7.4.0-beta.2'
20
20
  end
@@ -83,7 +83,7 @@ repositories {
83
83
  }
84
84
 
85
85
  dependencies {
86
- def sdk_version = "7.3.0"
86
+ def sdk_version = "7.4.0-beta.2"
87
87
 
88
88
  implementation fileTree(dir: 'libs', include: ['*.jar'])
89
89
 
@@ -20,10 +20,6 @@ import com.scandit.datacapture.frameworks.core.CoreModule
20
20
  import com.scandit.datacapture.frameworks.core.events.Emitter
21
21
  import com.scandit.datacapture.frameworks.core.lifecycle.ActivityLifecycleDispatcher
22
22
  import com.scandit.datacapture.frameworks.core.lifecycle.DefaultActivityLifecycle
23
- import com.scandit.datacapture.frameworks.core.listeners.FrameworksDataCaptureContextListener
24
- import com.scandit.datacapture.frameworks.core.listeners.FrameworksDataCaptureViewListener
25
- import com.scandit.datacapture.frameworks.core.listeners.FrameworksFrameSourceDeserializer
26
- import com.scandit.datacapture.frameworks.core.listeners.FrameworksFrameSourceListener
27
23
  import org.json.JSONException
28
24
  import org.json.JSONObject
29
25
 
@@ -47,16 +43,11 @@ class ScanditCaptureCoreNative :
47
43
  "ScanditTextNative"
48
44
  )
49
45
  }
46
+
50
47
  private val lifecycleDispatcher: ActivityLifecycleDispatcher =
51
48
  DefaultActivityLifecycle.getInstance()
52
49
  private val captureViewHandler = DataCaptureViewHandler()
53
- private val frameSourceListener = FrameworksFrameSourceListener(this)
54
- private val coreModule = CoreModule(
55
- frameSourceListener,
56
- FrameworksDataCaptureContextListener(this),
57
- FrameworksDataCaptureViewListener(this),
58
- FrameworksFrameSourceDeserializer(frameSourceListener)
59
- )
50
+ private val coreModule = CoreModule.create(this)
60
51
  private var lastFrameSourceState: FrameSourceState = FrameSourceState.OFF
61
52
 
62
53
  private val plugins = mutableListOf<Plugin>()
@@ -92,7 +83,7 @@ class ScanditCaptureCoreNative :
92
83
  coreModule.switchToDesiredCameraState(lastFrameSourceState)
93
84
  }
94
85
  coreModule.registerDataCaptureContextListener()
95
- coreModule.registerDataCaptureViewListener()
86
+ coreModule.registerTopmostDataCaptureViewListener()
96
87
  coreModule.registerFrameSourceListener()
97
88
  lifecycleDispatcher.dispatchOnStart()
98
89
  }
@@ -102,7 +93,7 @@ class ScanditCaptureCoreNative :
102
93
  lastFrameSourceState = coreModule.getCurrentCameraDesiredState() ?: FrameSourceState.OFF
103
94
  coreModule.switchToDesiredCameraState(FrameSourceState.OFF)
104
95
  coreModule.unregisterDataCaptureContextListener()
105
- coreModule.unregisterDataCaptureViewListener()
96
+ coreModule.unregisterTopmostDataCaptureViewListener()
106
97
  coreModule.unregisterFrameSourceListener()
107
98
  }
108
99
 
@@ -246,15 +237,23 @@ class ScanditCaptureCoreNative :
246
237
  val pointJson = call.data.getString("point")
247
238
  ?: return call.reject(EMPTY_STRING_ERROR)
248
239
 
249
- coreModule.viewPointForFramePoint(pointJson, CapacitorResult(call))
240
+ val viewId = call.data.getInt("viewId")
241
+
242
+ coreModule.viewPointForFramePoint(viewId, pointJson, CapacitorResult(call))
250
243
  }
251
244
 
252
245
  @PluginMethod
253
246
  fun viewQuadrilateralForFrameQuadrilateral(call: PluginCall) {
254
- val pointJson = call.data.getString("point")
247
+ val quadrilateralJson = call.data.getString("quadrilateral")
255
248
  ?: return call.reject(EMPTY_STRING_ERROR)
256
249
 
257
- coreModule.viewQuadrilateralForFrameQuadrilateral(pointJson, CapacitorResult(call))
250
+ val viewId = call.data.getInt("viewId")
251
+
252
+ coreModule.viewQuadrilateralForFrameQuadrilateral(
253
+ viewId,
254
+ quadrilateralJson,
255
+ CapacitorResult(call)
256
+ )
258
257
  }
259
258
  //endregion
260
259
 
@@ -287,13 +286,15 @@ class ScanditCaptureCoreNative :
287
286
 
288
287
  @PluginMethod
289
288
  fun subscribeViewListener(call: PluginCall) {
290
- coreModule.registerDataCaptureViewListener()
289
+ val viewId = call.data.getInt("viewId")
290
+ coreModule.registerDataCaptureViewListener(viewId)
291
291
  call.resolve()
292
292
  }
293
293
 
294
294
  @PluginMethod
295
295
  fun unsubscribeViewListener(call: PluginCall) {
296
- coreModule.unregisterDataCaptureViewListener()
296
+ val viewId = call.data.getInt("viewId")
297
+ coreModule.unregisterDataCaptureViewListener(viewId)
297
298
  call.resolve()
298
299
  }
299
300
 
@@ -349,9 +350,10 @@ class ScanditCaptureCoreNative :
349
350
 
350
351
  @PluginMethod
351
352
  fun removeDataCaptureView(call: PluginCall) {
353
+ val viewId = call.data.getInt("viewId")
352
354
  // In capacitor we just show 1 datacapture view at a time
353
- val dcViewToRemove = captureViewHandler.dataCaptureView
354
- if (dcViewToRemove != null) {
355
+ val dcViewToRemove = coreModule.getDataCaptureViewById(viewId)
356
+ dcViewToRemove?.post {
355
357
  coreModule.dataCaptureViewDisposed(dcViewToRemove)
356
358
  captureViewHandler.removeDataCaptureView(dcViewToRemove)
357
359
  }
package/dist/core.js CHANGED
@@ -2238,13 +2238,13 @@ class DataCaptureViewController extends BaseController {
2238
2238
  }
2239
2239
  viewPointForFramePoint(point) {
2240
2240
  return __awaiter(this, void 0, void 0, function* () {
2241
- const result = yield this._proxy.viewPointForFramePoint(JSON.stringify(point.toJSON()));
2241
+ const result = yield this._proxy.viewPointForFramePoint({ viewId: this.view.viewId, pointJson: JSON.stringify(point.toJSON()) });
2242
2242
  return Point.fromJSON(JSON.parse(result.data));
2243
2243
  });
2244
2244
  }
2245
2245
  viewQuadrilateralForFrameQuadrilateral(quadrilateral) {
2246
2246
  return __awaiter(this, void 0, void 0, function* () {
2247
- const result = yield this._proxy.viewQuadrilateralForFrameQuadrilateral(JSON.stringify(quadrilateral.toJSON()));
2247
+ const result = yield this._proxy.viewQuadrilateralForFrameQuadrilateral({ viewId: this.view.viewId, quadrilateralJson: JSON.stringify(quadrilateral.toJSON()) });
2248
2248
  return Quadrilateral.fromJSON(JSON.parse(result.data));
2249
2249
  });
2250
2250
  }
@@ -2264,7 +2264,7 @@ class DataCaptureViewController extends BaseController {
2264
2264
  });
2265
2265
  }
2266
2266
  removeNativeView() {
2267
- return this._proxy.removeView();
2267
+ return this._proxy.removeView(this.view.viewId);
2268
2268
  }
2269
2269
  createView() {
2270
2270
  return this._proxy.createView(JSON.stringify(this.view.toJSON()));
@@ -2277,7 +2277,7 @@ class DataCaptureViewController extends BaseController {
2277
2277
  }
2278
2278
  subscribeListener() {
2279
2279
  var _a, _b;
2280
- this._proxy.registerListenerForViewEvents();
2280
+ this._proxy.registerListenerForViewEvents(this.view.viewId);
2281
2281
  (_b = (_a = this._proxy).subscribeDidChangeSize) === null || _b === void 0 ? void 0 : _b.call(_a);
2282
2282
  this.eventEmitter.on(DataCaptureViewEvents.didChangeSize, (data) => {
2283
2283
  const event = EventDataParser.parse(data);
@@ -2285,6 +2285,9 @@ class DataCaptureViewController extends BaseController {
2285
2285
  console.error('DataCaptureViewController didChangeSize payload is null');
2286
2286
  return;
2287
2287
  }
2288
+ if (event.viewId !== this.view.viewId) {
2289
+ return;
2290
+ }
2288
2291
  const size = Size.fromJSON(event.size);
2289
2292
  const orientation = event.orientation;
2290
2293
  this.view.listeners.forEach(listener => {
@@ -2295,7 +2298,7 @@ class DataCaptureViewController extends BaseController {
2295
2298
  });
2296
2299
  }
2297
2300
  unsubscribeListener() {
2298
- this._proxy.unregisterListenerForViewEvents();
2301
+ this._proxy.unregisterListenerForViewEvents(this.view.viewId);
2299
2302
  this.eventEmitter.removeAllListeners(DataCaptureViewEvents.didChangeSize);
2300
2303
  }
2301
2304
  }
@@ -2320,6 +2323,13 @@ class BaseDataCaptureView extends DefaultSerializeable {
2320
2323
  get scanAreaMargins() {
2321
2324
  return this._scanAreaMargins;
2322
2325
  }
2326
+ get viewId() {
2327
+ var _a;
2328
+ return (_a = this._viewId) !== null && _a !== void 0 ? _a : -1;
2329
+ }
2330
+ set viewId(newValue) {
2331
+ this._viewId = newValue;
2332
+ }
2323
2333
  set scanAreaMargins(newValue) {
2324
2334
  this._scanAreaMargins = newValue;
2325
2335
  this.controller.updateView();
@@ -2378,7 +2388,6 @@ class BaseDataCaptureView extends DefaultSerializeable {
2378
2388
  constructor(autoCreateNativeView) {
2379
2389
  super();
2380
2390
  this._context = null;
2381
- this.viewId = null;
2382
2391
  this.overlays = [];
2383
2392
  this.controls = [];
2384
2393
  this.listeners = [];
@@ -2450,11 +2459,12 @@ class BaseDataCaptureView extends DefaultSerializeable {
2450
2459
  controlUpdated() {
2451
2460
  this.controller.updateView();
2452
2461
  }
2453
- createNativeView() {
2462
+ createNativeView(viewId) {
2454
2463
  return __awaiter(this, void 0, void 0, function* () {
2455
2464
  if (this.isViewCreated) {
2456
2465
  return Promise.resolve();
2457
2466
  }
2467
+ this.viewId = viewId;
2458
2468
  yield this.controller.createNativeView();
2459
2469
  this.isViewCreated = true;
2460
2470
  });
@@ -2507,8 +2517,8 @@ __decorate([
2507
2517
  nameForSerialization('scanAreaMargins')
2508
2518
  ], BaseDataCaptureView.prototype, "_scanAreaMargins", void 0);
2509
2519
  __decorate([
2510
- ignoreFromSerializationIfNull
2511
- ], BaseDataCaptureView.prototype, "viewId", void 0);
2520
+ nameForSerialization('viewId')
2521
+ ], BaseDataCaptureView.prototype, "_viewId", void 0);
2512
2522
  __decorate([
2513
2523
  nameForSerialization('pointOfInterest')
2514
2524
  ], BaseDataCaptureView.prototype, "_pointOfInterest", void 0);
@@ -2981,6 +2991,19 @@ class AimerViewfinder extends DefaultSerializeable {
2981
2991
  }
2982
2992
  }
2983
2993
 
2994
+ class LaserlineViewfinder extends DefaultSerializeable {
2995
+ get coreDefaults() {
2996
+ return getCoreDefaults();
2997
+ }
2998
+ constructor() {
2999
+ super();
3000
+ this.type = 'laserline';
3001
+ this.width = this.coreDefaults.LaserlineViewfinder.width;
3002
+ this.enabledColor = this.coreDefaults.LaserlineViewfinder.enabledColor;
3003
+ this.disabledColor = this.coreDefaults.LaserlineViewfinder.disabledColor;
3004
+ }
3005
+ }
3006
+
2984
3007
  function parseDefaults(jsonDefaults) {
2985
3008
  const coreDefaults = {
2986
3009
  Camera: {
@@ -3035,6 +3058,11 @@ function parseDefaults(jsonDefaults) {
3035
3058
  Brush: new Brush(Color
3036
3059
  .fromJSON(jsonDefaults.Brush.fillColor), Color
3037
3060
  .fromJSON(jsonDefaults.Brush.strokeColor), jsonDefaults.Brush.strokeWidth),
3061
+ LaserlineViewfinder: {
3062
+ width: NumberWithUnit.fromJSON(JSON.parse(jsonDefaults.LaserlineViewfinder.width)),
3063
+ enabledColor: Color.fromJSON(jsonDefaults.LaserlineViewfinder.enabledColor),
3064
+ disabledColor: Color.fromJSON(jsonDefaults.LaserlineViewfinder.disabledColor),
3065
+ },
3038
3066
  deviceID: jsonDefaults.deviceID,
3039
3067
  };
3040
3068
  // Inject defaults to avoid a circular dependency between these classes and the defaults
@@ -3401,6 +3429,97 @@ function createAdvancedInstanceAwareNativeProxy(nativeCaller, eventsEnum = undef
3401
3429
  return new AdvancedInstanceAwareNativeProxy(nativeCaller, eventsList);
3402
3430
  }
3403
3431
 
3432
+ /**
3433
+ * JS Proxy hook to act as middleware to all the calls performed by an AdvancedNativeProxy instance
3434
+ * This will allow AdvancedNativeProxy to call dynamically the methods defined in the interface defined
3435
+ * as parameter in createAdvancedNativeProxy function
3436
+ */
3437
+ const nativeProxyHook = {
3438
+ /**
3439
+ * Dynamic property getter for the AdvancedNativeProxy
3440
+ * In order to call a native method this needs to be preceded by the `$` symbol on the name, ie `$methodName`
3441
+ * In order to set a native event handler this needs to be preceded by `on$` prefix, ie `on$eventName`
3442
+ * @param advancedNativeProxy
3443
+ * @param prop
3444
+ */
3445
+ get(nativeProxy, prop) {
3446
+ // Important: $ and on$ are required since if they are not added all
3447
+ // properties present on AdvancedNativeProxy will be redirected to the
3448
+ // advancedNativeProxy._call, which will call native even for the own
3449
+ // properties of the class
3450
+ // All the methods with the following structure
3451
+ // $methodName will be redirected to the special _call
3452
+ // method on AdvancedNativeProxy
3453
+ if (prop.startsWith("$")) {
3454
+ if (prop in nativeProxy) {
3455
+ return nativeProxy[prop];
3456
+ }
3457
+ return (args) => {
3458
+ return nativeProxy._call(prop.substring(1), args);
3459
+ };
3460
+ }
3461
+ else {
3462
+ return nativeProxy[prop];
3463
+ }
3464
+ }
3465
+ };
3466
+ class NativeProxy extends BaseInstanceAwareNativeProxy {
3467
+ constructor(nativeCaller) {
3468
+ super();
3469
+ this.nativeCaller = nativeCaller;
3470
+ this.eventSubscriptions = new Map();
3471
+ this.eventHandlers = new Map();
3472
+ // Create the cached handler once
3473
+ this.cachedEventHandler = (eventName) => (args) => __awaiter(this, void 0, void 0, function* () {
3474
+ this.eventEmitter.emit(eventName, args);
3475
+ });
3476
+ // Wrapping the NativeProxy instance with the JS proxy hook
3477
+ return new Proxy(this, nativeProxyHook);
3478
+ }
3479
+ subscribeForEvents(events) {
3480
+ return __awaiter(this, void 0, void 0, function* () {
3481
+ for (const event of events) {
3482
+ yield this._registerEvent(event);
3483
+ }
3484
+ });
3485
+ }
3486
+ unsubscribeFromEvents(events) {
3487
+ return __awaiter(this, void 0, void 0, function* () {
3488
+ for (const event of events) {
3489
+ yield this._unregisterEvent(event);
3490
+ }
3491
+ });
3492
+ }
3493
+ dispose() {
3494
+ return __awaiter(this, void 0, void 0, function* () {
3495
+ for (const nativeEventName of this.eventSubscriptions.keys()) {
3496
+ yield this._unregisterEvent(nativeEventName);
3497
+ }
3498
+ this.eventSubscriptions.clear();
3499
+ });
3500
+ }
3501
+ _call(fnName, args) {
3502
+ return this.nativeCaller.callFn(fnName, args);
3503
+ }
3504
+ _registerEvent(event) {
3505
+ return __awaiter(this, void 0, void 0, function* () {
3506
+ const handler = this.cachedEventHandler(event);
3507
+ const subscription = yield this.nativeCaller.registerEvent(event, handler);
3508
+ this.eventSubscriptions.set(event, subscription);
3509
+ });
3510
+ }
3511
+ _unregisterEvent(event) {
3512
+ return __awaiter(this, void 0, void 0, function* () {
3513
+ const subscription = this.eventSubscriptions.get(event);
3514
+ yield this.nativeCaller.unregisterEvent(event, subscription);
3515
+ this.eventSubscriptions.delete(event);
3516
+ });
3517
+ }
3518
+ }
3519
+ function createNativeProxy(nativeCaller) {
3520
+ return new NativeProxy(nativeCaller);
3521
+ }
3522
+
3404
3523
  class BaseNewController {
3405
3524
  get _proxy() {
3406
3525
  return this._cachedProxy;
@@ -3412,5 +3531,5 @@ class BaseNewController {
3412
3531
 
3413
3532
  createEventEmitter();
3414
3533
 
3415
- export { AdvancedInstanceAwareNativeProxy, AdvancedNativeProxy, AimerViewfinder, Anchor, BaseController, BaseDataCaptureView, BaseInstanceAwareNativeProxy, BaseNativeProxy, BaseNewController, Brush, Camera, CameraController, CameraPosition, CameraSettings, Color, ContextStatus, ControlImage, DataCaptureContext, DataCaptureContextEvents, DataCaptureContextSettings, DataCaptureViewController, DataCaptureViewEvents, DefaultSerializeable, Direction, EventDataParser, EventEmitter, Expiration, FactoryMaker, Feedback, FocusGestureStrategy, FocusRange, FontFamily, FrameSourceListenerEvents, FrameSourceState, HTMLElementState, HtmlElementPosition, HtmlElementSize, ImageBuffer, ImageFrameSource, LicenseInfo, LogoStyle, MarginsWithUnit, MeasureUnit, NoViewfinder, NoneLocationSelection, NumberWithUnit, Observable, OpenSourceSoftwareLicenseInfo, Orientation, Point, PointWithUnit, PrivateFocusGestureDeserializer, PrivateFrameData, PrivateZoomGestureDeserializer, Quadrilateral, RadiusLocationSelection, Rect, RectWithUnit, RectangularLocationSelection, RectangularViewfinder, RectangularViewfinderAnimation, RectangularViewfinderLineStyle, RectangularViewfinderStyle, ScanIntention, ScanditIcon, ScanditIconBuilder, ScanditIconShape, ScanditIconType, Size, SizeWithAspect, SizeWithUnit, SizeWithUnitAndAspect, SizingMode, Sound, SwipeToZoom, TapToFocus, TextAlignment, TorchState, TorchSwitchControl, Vibration, VibrationType, VideoResolution, WaveFormVibration, ZoomSwitchControl, createAdvancedInstanceAwareNativeProxy, createAdvancedNativeFromCtorProxy, createAdvancedNativeProxy, getCoreDefaults, ignoreFromSerialization, ignoreFromSerializationIfNull, loadCoreDefaults, nameForSerialization, serializationDefault };
3534
+ export { AdvancedInstanceAwareNativeProxy, AdvancedNativeProxy, AimerViewfinder, Anchor, BaseController, BaseDataCaptureView, BaseInstanceAwareNativeProxy, BaseNativeProxy, BaseNewController, Brush, Camera, CameraController, CameraPosition, CameraSettings, Color, ContextStatus, ControlImage, DataCaptureContext, DataCaptureContextEvents, DataCaptureContextSettings, DataCaptureViewController, DataCaptureViewEvents, DefaultSerializeable, Direction, EventDataParser, EventEmitter, Expiration, FactoryMaker, Feedback, FocusGestureStrategy, FocusRange, FontFamily, FrameSourceListenerEvents, FrameSourceState, HTMLElementState, HtmlElementPosition, HtmlElementSize, ImageBuffer, ImageFrameSource, LaserlineViewfinder, LicenseInfo, LogoStyle, MarginsWithUnit, MeasureUnit, NativeProxy, NoViewfinder, NoneLocationSelection, NumberWithUnit, Observable, OpenSourceSoftwareLicenseInfo, Orientation, Point, PointWithUnit, PrivateFocusGestureDeserializer, PrivateFrameData, PrivateZoomGestureDeserializer, Quadrilateral, RadiusLocationSelection, Rect, RectWithUnit, RectangularLocationSelection, RectangularViewfinder, RectangularViewfinderAnimation, RectangularViewfinderLineStyle, RectangularViewfinderStyle, ScanIntention, ScanditIcon, ScanditIconBuilder, ScanditIconShape, ScanditIconType, Size, SizeWithAspect, SizeWithUnit, SizeWithUnitAndAspect, SizingMode, Sound, SwipeToZoom, TapToFocus, TextAlignment, TorchState, TorchSwitchControl, Vibration, VibrationType, VideoResolution, WaveFormVibration, ZoomSwitchControl, createAdvancedInstanceAwareNativeProxy, createAdvancedNativeFromCtorProxy, createAdvancedNativeProxy, createNativeProxy, getCoreDefaults, ignoreFromSerialization, ignoreFromSerializationIfNull, loadCoreDefaults, nameForSerialization, serializationDefault };
3416
3535
  //# sourceMappingURL=core.js.map