scandit-react-native-datacapture-core 7.6.1 → 7.6.3

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/THIRD_PARTY.txt CHANGED
@@ -236,6 +236,52 @@ includes components licensed under the following licenses:
236
236
  SOFTWARE.
237
237
 
238
238
 
239
+ ================================================================================
240
+
241
+
242
+ Written by: Philip Hazel
243
+ Email local part: Philip.Hazel
244
+ Email domain: gmail.com
245
+
246
+ Retired from University of Cambridge Computing Service,
247
+ Cambridge, England.
248
+
249
+ Copyright (c) 1997-2007 University of Cambridge
250
+ Copyright (c) 2007-2024 Philip Hazel
251
+ All rights reserved.
252
+
253
+ Redistribution and use in source and binary forms, with or without modification,
254
+ are permitted provided that the following conditions are met:
255
+
256
+ * Redistributions of source code must retain the above copyright notice,
257
+ this list of conditions and the following disclaimer.
258
+
259
+ * Redistributions in binary form must reproduce the above copyright notice,
260
+ this list of conditions and the following disclaimer in the documentation
261
+ and/or other materials provided with the distribution.
262
+
263
+ * Neither the names of the copyright holders nor the names of the contributors
264
+ may be used to endorse or promote products derived from this software
265
+ without specific prior written permission.
266
+
267
+ This software is provided by the copyright holders and contributors "as is" and
268
+ any express or implied warranties, including, but not limited to, the implied
269
+ warranties of merchantability and fitness for a particular purpose are disclaimed.
270
+ In no event shall copyright holders or contributors be liable for any direct,
271
+ indirect, incidental, special, exemplary, or consequential damages
272
+ (including, but not limited to, procurement of substitute goods or services;
273
+ loss of use, data, or profits; or business interruption) however caused
274
+ and on any theory of liability, whether in contract, strict liability,
275
+ or tort (including negligence or otherwise) arising in any way out of
276
+ the use of this software, even if advised of the possibility of such damage.
277
+
278
+ The second condition in the BSD licence (covering binary redistributions)
279
+ does not apply all the way down a chain of software. If binary package A
280
+ includes PCRE2, it must respect the condition, but if package B is software
281
+ that includes package A, the condition is not imposed on package B unless
282
+ it uses PCRE2 independently.
283
+
284
+
239
285
  ================================================================================
240
286
 
241
287
 
@@ -68,7 +68,7 @@ if (file( "${rootProject.projectDir}/build-test.gradle").exists()) {
68
68
  }
69
69
 
70
70
  dependencies {
71
- def sdk_version = "7.6.1"
71
+ def sdk_version = "7.6.3"
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) {
@@ -18,8 +18,6 @@ import com.scandit.datacapture.frameworks.core.FrameworkModule
18
18
  import com.scandit.datacapture.frameworks.core.errors.ModuleNotStartedError
19
19
  import com.scandit.datacapture.frameworks.core.errors.ParameterNullError
20
20
  import com.scandit.datacapture.frameworks.core.locator.ServiceLocator
21
- import com.scandit.datacapture.frameworks.core.utils.DefaultMainThread
22
- import com.scandit.datacapture.frameworks.core.utils.MainThread
23
21
  import com.scandit.datacapture.reactnative.core.ui.DataCaptureViewManager
24
22
  import com.scandit.datacapture.reactnative.core.utils.ReactNativeResult
25
23
 
@@ -27,7 +25,6 @@ class ScanditDataCaptureCoreModule(
27
25
  reactContext: ReactApplicationContext,
28
26
  private val serviceLocator: ServiceLocator<FrameworkModule>,
29
27
  private val viewManagers: Map<String, ViewGroupManager<*>>,
30
- private val mainThread: MainThread = DefaultMainThread.getInstance(),
31
28
  ) : ReactContextBaseJavaModule(reactContext) {
32
29
 
33
30
  companion object {
@@ -63,13 +60,15 @@ class ScanditDataCaptureCoreModule(
63
60
  }
64
61
 
65
62
  @ReactMethod
66
- fun registerListenerForCameraEvents() {
63
+ fun registerListenerForCameraEvents(promise: Promise) {
67
64
  coreModule.registerFrameSourceListener()
65
+ promise.resolve(null)
68
66
  }
69
67
 
70
68
  @ReactMethod
71
- fun unregisterListenerForCameraEvents() {
69
+ fun unregisterListenerForCameraEvents(promise: Promise) {
72
70
  coreModule.unregisterFrameSourceListener()
71
+ promise.resolve(null)
73
72
  }
74
73
 
75
74
  @ReactMethod
@@ -95,9 +94,7 @@ class ScanditDataCaptureCoreModule(
95
94
  val contextJson = readableMap.getString("contextJson") ?: return promise.reject(
96
95
  ParameterNullError("contextJson")
97
96
  )
98
- mainThread.runOnMainThread {
99
- coreModule.updateContextFromJson(contextJson, ReactNativeResult(promise))
100
- }
97
+ coreModule.updateContextFromJson(contextJson, ReactNativeResult(promise))
101
98
  }
102
99
 
103
100
  @ReactMethod
package/dist/core.js CHANGED
@@ -778,13 +778,6 @@ class FrameDataSettingsBuilder {
778
778
  }
779
779
  }
780
780
 
781
- var CameraPosition;
782
- (function (CameraPosition) {
783
- CameraPosition["WorldFacing"] = "worldFacing";
784
- CameraPosition["UserFacing"] = "userFacing";
785
- CameraPosition["Unspecified"] = "unspecified";
786
- })(CameraPosition || (CameraPosition = {}));
787
-
788
781
  var FrameSourceListenerEvents;
789
782
  (function (FrameSourceListenerEvents) {
790
783
  FrameSourceListenerEvents["didChangeState"] = "FrameSourceListener.onStateChanged";
@@ -1532,19 +1525,30 @@ class HTMLElementState {
1532
1525
  }
1533
1526
  }
1534
1527
 
1535
- class ImageFrameSourceController {
1536
- static forImage(imageFrameSource) {
1537
- const controller = new ImageFrameSourceController();
1538
- controller.imageFrameSource = imageFrameSource;
1539
- return controller;
1528
+ class BaseNewController {
1529
+ get _proxy() {
1530
+ return this._cachedProxy;
1540
1531
  }
1541
- constructor() {
1542
- this.eventEmitter = FactoryMaker.getInstance('EventEmitter');
1543
- this._proxy = FactoryMaker.getInstance('ImageFrameSourceProxy');
1532
+ constructor(proxyName) {
1533
+ this._cachedProxy = FactoryMaker.createInstance(proxyName);
1534
+ }
1535
+ }
1536
+
1537
+ class ImageFrameSourceController extends BaseNewController {
1538
+ constructor(imageFrameSource) {
1539
+ super('ImageFrameSourceProxy');
1540
+ this.handleDidChangeStateEventWrapper = (ev) => {
1541
+ return this.handleDidChangeStateEvent(ev);
1542
+ };
1543
+ this.imageFrameSource = imageFrameSource;
1544
+ this.subscribeListener();
1545
+ }
1546
+ get privateImageFrameSource() {
1547
+ return this.imageFrameSource;
1544
1548
  }
1545
1549
  getCurrentState() {
1546
1550
  return __awaiter(this, void 0, void 0, function* () {
1547
- const result = yield this._proxy.getCurrentCameraState(this.imageFrameSource.position);
1551
+ const result = yield this._proxy.$getCurrentCameraState({ position: this.privateImageFrameSource.position });
1548
1552
  if (result == null) {
1549
1553
  return FrameSourceState.Off;
1550
1554
  }
@@ -1552,29 +1556,38 @@ class ImageFrameSourceController {
1552
1556
  });
1553
1557
  }
1554
1558
  switchCameraToDesiredState(desiredStateJson) {
1555
- return this._proxy.switchCameraToDesiredState(desiredStateJson);
1559
+ return this._proxy.$switchCameraToDesiredState({ desiredStateJson });
1556
1560
  }
1557
1561
  subscribeListener() {
1558
- var _a, _b;
1559
- this._proxy.registerListenerForEvents();
1560
- (_b = (_a = this._proxy).subscribeDidChangeState) === null || _b === void 0 ? void 0 : _b.call(_a);
1561
- this.eventEmitter.on(FrameSourceListenerEvents.didChangeState, (data) => {
1562
- const event = EventDataParser.parse(data);
1563
- if (event === null) {
1564
- console.error('ImageFrameSourceController didChangeState payload is null');
1565
- return;
1566
- }
1567
- const newState = event.state;
1568
- this.imageFrameSource.listeners.forEach(listener => {
1569
- if (listener.didChangeState) {
1570
- listener.didChangeState(this.imageFrameSource, newState);
1571
- }
1572
- });
1562
+ return __awaiter(this, void 0, void 0, function* () {
1563
+ yield this._proxy.$registerListenerForCameraEvents();
1564
+ this._proxy.subscribeForEvents([FrameSourceListenerEvents.didChangeState]);
1565
+ this._proxy.eventEmitter.on(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEventWrapper);
1573
1566
  });
1574
1567
  }
1575
1568
  unsubscribeListener() {
1576
- this._proxy.unregisterListenerForEvents();
1577
- this.eventEmitter.removeAllListeners(FrameSourceListenerEvents.didChangeState);
1569
+ return __awaiter(this, void 0, void 0, function* () {
1570
+ yield this._proxy.$unregisterListenerForCameraEvents();
1571
+ this._proxy.unsubscribeFromEvents([FrameSourceListenerEvents.didChangeState]);
1572
+ this._proxy.eventEmitter.off(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEventWrapper);
1573
+ });
1574
+ }
1575
+ dispose() {
1576
+ this.unsubscribeListener();
1577
+ this._proxy.dispose();
1578
+ }
1579
+ handleDidChangeStateEvent(ev) {
1580
+ const event = EventDataParser.parse(ev.data);
1581
+ if (event === null) {
1582
+ console.error('ImageFrameSourceController didChangeState payload is null');
1583
+ return;
1584
+ }
1585
+ const newState = event.state;
1586
+ this.privateImageFrameSource.listeners.forEach(listener => {
1587
+ if (listener.didChangeState) {
1588
+ listener.didChangeState(this.imageFrameSource, newState);
1589
+ }
1590
+ });
1578
1591
  }
1579
1592
  }
1580
1593
 
@@ -1610,7 +1623,7 @@ class ImageFrameSource extends DefaultSerializeable {
1610
1623
  this._desiredState = FrameSourceState.Off;
1611
1624
  this.listeners = [];
1612
1625
  this._context = null;
1613
- this.controller = ImageFrameSourceController.forImage(this);
1626
+ this.controller = new ImageFrameSourceController(this);
1614
1627
  }
1615
1628
  didChange() {
1616
1629
  if (this.context) {
@@ -1689,14 +1702,12 @@ class PrivateFrameData {
1689
1702
  }
1690
1703
  }
1691
1704
 
1692
- class BaseNewController {
1693
- get _proxy() {
1694
- return this._cachedProxy;
1695
- }
1696
- constructor(proxyName) {
1697
- this._cachedProxy = FactoryMaker.createInstance(proxyName);
1698
- }
1699
- }
1705
+ var CameraPosition;
1706
+ (function (CameraPosition) {
1707
+ CameraPosition["WorldFacing"] = "worldFacing";
1708
+ CameraPosition["UserFacing"] = "userFacing";
1709
+ CameraPosition["Unspecified"] = "unspecified";
1710
+ })(CameraPosition || (CameraPosition = {}));
1700
1711
 
1701
1712
  class CameraController extends BaseNewController {
1702
1713
  static get _proxy() {
@@ -1755,14 +1766,18 @@ class CameraController extends BaseNewController {
1755
1766
  return this._proxy.$switchCameraToDesiredState({ desiredStateJson: desiredState.toString() });
1756
1767
  }
1757
1768
  subscribeListener() {
1758
- this._proxy.$registerListenerForCameraEvents();
1759
- this._proxy.subscribeForEvents([FrameSourceListenerEvents.didChangeState]);
1760
- this._proxy.eventEmitter.on(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEvent.bind(this));
1769
+ return __awaiter(this, void 0, void 0, function* () {
1770
+ yield this._proxy.$registerListenerForCameraEvents();
1771
+ this._proxy.subscribeForEvents([FrameSourceListenerEvents.didChangeState]);
1772
+ this._proxy.eventEmitter.on(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEvent.bind(this));
1773
+ });
1761
1774
  }
1762
1775
  unsubscribeListener() {
1763
- this._proxy.$unregisterListenerForCameraEvents();
1764
- this._proxy.unsubscribeFromEvents([FrameSourceListenerEvents.didChangeState]);
1765
- this._proxy.eventEmitter.off(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEvent.bind(this));
1776
+ return __awaiter(this, void 0, void 0, function* () {
1777
+ yield this._proxy.$unregisterListenerForCameraEvents();
1778
+ this._proxy.unsubscribeFromEvents([FrameSourceListenerEvents.didChangeState]);
1779
+ this._proxy.eventEmitter.off(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEvent.bind(this));
1780
+ });
1766
1781
  }
1767
1782
  dispose() {
1768
1783
  this.unsubscribeListener();