scandit-react-native-datacapture-core 6.24.1 → 6.25.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/android/build.gradle +1 -1
- package/android/src/main/kotlin/com/scandit/datacapture/reactnative/core/ScanditDataCaptureCoreModule.kt +16 -1
- package/android/src/main/kotlin/com/scandit/datacapture/reactnative/core/ScanditDataCaptureCorePackage.kt +14 -2
- package/android/src/main/kotlin/com/scandit/datacapture/reactnative/core/ui/DataCaptureViewManager.kt +2 -12
- package/android/src/main/kotlin/com/scandit/datacapture/reactnative/core/ui/FragmentBase.kt +11 -0
- package/android/src/main/kotlin/com/scandit/datacapture/reactnative/core/ui/ScanditViewGroupManager.kt +11 -0
- package/dist/core.js +42 -16
- package/dist/core.js.map +1 -1
- package/dist/index.js +2 -2802
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/ios/Sources/ScanditDataCaptureViewManager.swift +6 -5
- package/package.json +2 -2
- package/scandit-react-native-datacapture-core.podspec +1 -1
package/android/build.gradle
CHANGED
|
@@ -64,7 +64,7 @@ android {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
dependencies {
|
|
67
|
-
def sdk_version = "6.
|
|
67
|
+
def sdk_version = "6.25.0-beta.2"
|
|
68
68
|
|
|
69
69
|
println("Version of the native sdk used in this build: ${safeExtGet('global_sdk_version', sdk_version)}")
|
|
70
70
|
if (findProject(':scandit-datacapture-frameworks-core') != null) {
|
|
@@ -11,11 +11,15 @@ import com.facebook.react.bridge.ReactApplicationContext
|
|
|
11
11
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
12
12
|
import com.facebook.react.bridge.ReactMethod
|
|
13
13
|
import com.scandit.datacapture.core.capture.DataCaptureVersion
|
|
14
|
+
import com.scandit.datacapture.core.ui.DataCaptureView
|
|
14
15
|
import com.scandit.datacapture.frameworks.core.CoreModule
|
|
16
|
+
import com.scandit.datacapture.frameworks.core.deserialization.DefaultDeserializationLifecycleObserver
|
|
17
|
+
import com.scandit.datacapture.frameworks.core.deserialization.DeserializationLifecycleObserver
|
|
15
18
|
import com.scandit.datacapture.frameworks.core.utils.DefaultLastFrameData
|
|
16
19
|
import com.scandit.datacapture.frameworks.core.utils.DefaultMainThread
|
|
17
20
|
import com.scandit.datacapture.frameworks.core.utils.LastFrameData
|
|
18
21
|
import com.scandit.datacapture.frameworks.core.utils.MainThread
|
|
22
|
+
import com.scandit.datacapture.reactnative.core.ui.DataCaptureViewManager
|
|
19
23
|
import com.scandit.datacapture.reactnative.core.utils.Error
|
|
20
24
|
import com.scandit.datacapture.reactnative.core.utils.ReactNativeResult
|
|
21
25
|
import com.scandit.datacapture.reactnative.core.utils.reject
|
|
@@ -23,9 +27,10 @@ import com.scandit.datacapture.reactnative.core.utils.reject
|
|
|
23
27
|
class ScanditDataCaptureCoreModule(
|
|
24
28
|
reactContext: ReactApplicationContext,
|
|
25
29
|
private val coreModule: CoreModule,
|
|
30
|
+
private val dataCaptureViewManager: DataCaptureViewManager,
|
|
26
31
|
private val mainThread: MainThread = DefaultMainThread.getInstance(),
|
|
27
32
|
private val lastFrameData: LastFrameData = DefaultLastFrameData.getInstance()
|
|
28
|
-
) : ReactContextBaseJavaModule(reactContext) {
|
|
33
|
+
) : ReactContextBaseJavaModule(reactContext), DeserializationLifecycleObserver.Observer {
|
|
29
34
|
|
|
30
35
|
companion object {
|
|
31
36
|
private const val VERSION_KEY = "Version"
|
|
@@ -34,11 +39,17 @@ class ScanditDataCaptureCoreModule(
|
|
|
34
39
|
private val ERROR_NULL_FRAME = Error(5, "Frame is null, it might've been reused already.")
|
|
35
40
|
}
|
|
36
41
|
|
|
42
|
+
private val deserializationLifecycleObserver: DeserializationLifecycleObserver =
|
|
43
|
+
DefaultDeserializationLifecycleObserver.getInstance()
|
|
44
|
+
|
|
37
45
|
init {
|
|
38
46
|
coreModule.onCreate(reactContext)
|
|
47
|
+
deserializationLifecycleObserver.attach(this)
|
|
39
48
|
}
|
|
49
|
+
|
|
40
50
|
override fun invalidate() {
|
|
41
51
|
coreModule.onDestroy()
|
|
52
|
+
deserializationLifecycleObserver.detach(this)
|
|
42
53
|
super.invalidate()
|
|
43
54
|
}
|
|
44
55
|
|
|
@@ -49,6 +60,10 @@ class ScanditDataCaptureCoreModule(
|
|
|
49
60
|
DEFAULTS_KEY to coreModule.getDefaults()
|
|
50
61
|
)
|
|
51
62
|
|
|
63
|
+
override fun onDataCaptureViewDeserialized(dataCaptureView: DataCaptureView?) {
|
|
64
|
+
dataCaptureViewManager.onDataCaptureViewDeserialized(dataCaptureView)
|
|
65
|
+
}
|
|
66
|
+
|
|
52
67
|
@ReactMethod
|
|
53
68
|
fun registerListenerForEvents() {
|
|
54
69
|
coreModule.registerDataCaptureContextListener()
|
|
@@ -21,11 +21,23 @@ class ScanditDataCaptureCorePackage : ReactPackage {
|
|
|
21
21
|
override fun createNativeModules(
|
|
22
22
|
reactContext: ReactApplicationContext
|
|
23
23
|
): MutableList<NativeModule> =
|
|
24
|
-
mutableListOf(
|
|
24
|
+
mutableListOf(
|
|
25
|
+
ScanditDataCaptureCoreModule(
|
|
26
|
+
reactContext,
|
|
27
|
+
getCoreModule(
|
|
28
|
+
reactContext
|
|
29
|
+
),
|
|
30
|
+
dataCaptureViewManager
|
|
31
|
+
)
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
private val dataCaptureViewManager: DataCaptureViewManager by lazy {
|
|
35
|
+
DataCaptureViewManager()
|
|
36
|
+
}
|
|
25
37
|
|
|
26
38
|
override fun createViewManagers(
|
|
27
39
|
reactContext: ReactApplicationContext
|
|
28
|
-
): MutableList<ViewManager<*, *>> = mutableListOf(
|
|
40
|
+
): MutableList<ViewManager<*, *>> = mutableListOf(dataCaptureViewManager)
|
|
29
41
|
|
|
30
42
|
private fun getCoreModule(reactContext: ReactApplicationContext): CoreModule {
|
|
31
43
|
val eventEmitter: Emitter = ReactNativeEventEmitter(reactContext)
|
|
@@ -11,23 +11,13 @@ import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
|
|
11
11
|
import android.widget.FrameLayout
|
|
12
12
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
13
13
|
import com.scandit.datacapture.core.ui.DataCaptureView
|
|
14
|
-
import com.scandit.datacapture.frameworks.core.deserialization.DefaultDeserializationLifecycleObserver
|
|
15
|
-
import com.scandit.datacapture.frameworks.core.deserialization.DeserializationLifecycleObserver
|
|
16
14
|
import com.scandit.datacapture.frameworks.core.utils.DefaultMainThread
|
|
17
15
|
import com.scandit.datacapture.frameworks.core.utils.MainThread
|
|
18
16
|
import java.lang.ref.WeakReference
|
|
19
17
|
|
|
20
18
|
class DataCaptureViewManager(
|
|
21
19
|
private val mainThread: MainThread = DefaultMainThread.getInstance()
|
|
22
|
-
) : ScanditViewGroupManager<FrameLayout>()
|
|
23
|
-
DeserializationLifecycleObserver.Observer {
|
|
24
|
-
|
|
25
|
-
private val deserializationLifecycleObserver: DeserializationLifecycleObserver =
|
|
26
|
-
DefaultDeserializationLifecycleObserver.getInstance()
|
|
27
|
-
|
|
28
|
-
init {
|
|
29
|
-
deserializationLifecycleObserver.attach(this)
|
|
30
|
-
}
|
|
20
|
+
) : ScanditViewGroupManager<FrameLayout>() {
|
|
31
21
|
|
|
32
22
|
override fun getName(): String = "RNTDataCaptureView"
|
|
33
23
|
|
|
@@ -54,7 +44,7 @@ class DataCaptureViewManager(
|
|
|
54
44
|
}
|
|
55
45
|
}
|
|
56
46
|
|
|
57
|
-
|
|
47
|
+
fun onDataCaptureViewDeserialized(dataCaptureView: DataCaptureView?) {
|
|
58
48
|
if (dataCaptureView == null) return
|
|
59
49
|
|
|
60
50
|
currentContainer?.let {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the Scandit Data Capture SDK
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024- Scandit AG. All rights reserved.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
package com.scandit.datacapture.reactnative.core.ui
|
|
8
|
+
|
|
9
|
+
import androidx.fragment.app.Fragment
|
|
10
|
+
|
|
11
|
+
abstract class FragmentBase : Fragment()
|
|
@@ -15,6 +15,8 @@ import com.facebook.react.uimanager.ViewGroupManager
|
|
|
15
15
|
abstract class ScanditViewGroupManager<T> : ViewGroupManager<T>() where T : ViewGroup {
|
|
16
16
|
private val containers = mutableListOf<T>()
|
|
17
17
|
|
|
18
|
+
protected val fragmentsCache: MutableMap<T, FragmentBase> = mutableMapOf()
|
|
19
|
+
|
|
18
20
|
val currentContainer: T?
|
|
19
21
|
get() = if (containers.size > 0) containers[containers.size - 1] else null
|
|
20
22
|
|
|
@@ -23,6 +25,11 @@ abstract class ScanditViewGroupManager<T> : ViewGroupManager<T>() where T : View
|
|
|
23
25
|
|
|
24
26
|
abstract fun createNewInstance(reactContext: ThemedReactContext): T
|
|
25
27
|
|
|
28
|
+
override fun invalidate() {
|
|
29
|
+
super.invalidate()
|
|
30
|
+
containers.clear()
|
|
31
|
+
}
|
|
32
|
+
|
|
26
33
|
override fun createViewInstance(reactContext: ThemedReactContext): T {
|
|
27
34
|
val container = createNewInstance(reactContext).also {
|
|
28
35
|
containers.add(it)
|
|
@@ -42,6 +49,10 @@ abstract class ScanditViewGroupManager<T> : ViewGroupManager<T>() where T : View
|
|
|
42
49
|
if (containers.size == 0) {
|
|
43
50
|
cancelMeasureAndLayout()
|
|
44
51
|
}
|
|
52
|
+
fragmentsCache.remove(view)?.let {
|
|
53
|
+
it.onDestroyView()
|
|
54
|
+
it.onDestroy()
|
|
55
|
+
}
|
|
45
56
|
}
|
|
46
57
|
|
|
47
58
|
protected fun disposeInternal() {
|
package/dist/core.js
CHANGED
|
@@ -375,7 +375,7 @@ FactoryMaker.instances = new Map();
|
|
|
375
375
|
|
|
376
376
|
function createEventEmitter() {
|
|
377
377
|
const ee = new EventEmitter();
|
|
378
|
-
FactoryMaker.
|
|
378
|
+
FactoryMaker.bindInstanceIfNotExists('EventEmitter', ee);
|
|
379
379
|
}
|
|
380
380
|
|
|
381
381
|
class BaseController {
|
|
@@ -609,7 +609,7 @@ class ImageFrameSourceController {
|
|
|
609
609
|
}
|
|
610
610
|
unsubscribeListener() {
|
|
611
611
|
this._proxy.unregisterListenerForEvents();
|
|
612
|
-
this.eventEmitter.removeAllListeners();
|
|
612
|
+
this.eventEmitter.removeAllListeners(FrameSourceListenerEvents.didChangeState);
|
|
613
613
|
}
|
|
614
614
|
}
|
|
615
615
|
|
|
@@ -810,6 +810,17 @@ class Camera extends DefaultSerializeable {
|
|
|
810
810
|
}
|
|
811
811
|
return camera;
|
|
812
812
|
}
|
|
813
|
+
static asPositionWithSettings(cameraPosition, settings) {
|
|
814
|
+
if (Camera.coreDefaults.Camera.availablePositions.includes(cameraPosition)) {
|
|
815
|
+
const camera = new Camera();
|
|
816
|
+
camera.settings = settings;
|
|
817
|
+
camera.position = cameraPosition;
|
|
818
|
+
return camera;
|
|
819
|
+
}
|
|
820
|
+
else {
|
|
821
|
+
return null;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
813
824
|
static atPosition(cameraPosition) {
|
|
814
825
|
if (Camera.coreDefaults.Camera.availablePositions.includes(cameraPosition)) {
|
|
815
826
|
const camera = new Camera();
|
|
@@ -1028,8 +1039,8 @@ class DataCaptureContextController {
|
|
|
1028
1039
|
}
|
|
1029
1040
|
unsubscribeListener() {
|
|
1030
1041
|
this._proxy.unregisterListenerForDataCaptureContext();
|
|
1031
|
-
this.eventEmitter.
|
|
1032
|
-
this.eventEmitter.
|
|
1042
|
+
this.eventEmitter.removeAllListeners(DataCaptureContextEvents.didChangeStatus);
|
|
1043
|
+
this.eventEmitter.removeAllListeners(DataCaptureContextEvents.didStartObservingContext);
|
|
1033
1044
|
}
|
|
1034
1045
|
initialize() {
|
|
1035
1046
|
this.subscribeListener();
|
|
@@ -1799,7 +1810,7 @@ class DataCaptureViewController extends BaseController {
|
|
|
1799
1810
|
}
|
|
1800
1811
|
unsubscribeListener() {
|
|
1801
1812
|
this._proxy.unregisterListenerForViewEvents();
|
|
1802
|
-
this.eventEmitter.removeAllListeners();
|
|
1813
|
+
this.eventEmitter.removeAllListeners(DataCaptureViewEvents.didChangeSize);
|
|
1803
1814
|
}
|
|
1804
1815
|
}
|
|
1805
1816
|
|
|
@@ -1987,25 +1998,25 @@ __decorate([
|
|
|
1987
1998
|
ignoreFromSerialization
|
|
1988
1999
|
], BaseDataCaptureView.prototype, "coreDefaults", null);
|
|
1989
2000
|
__decorate([
|
|
1990
|
-
|
|
2001
|
+
nameForSerialization('scanAreaMargins')
|
|
1991
2002
|
], BaseDataCaptureView.prototype, "_scanAreaMargins", void 0);
|
|
1992
2003
|
__decorate([
|
|
1993
|
-
|
|
2004
|
+
nameForSerialization('pointOfInterest')
|
|
1994
2005
|
], BaseDataCaptureView.prototype, "_pointOfInterest", void 0);
|
|
1995
2006
|
__decorate([
|
|
1996
|
-
|
|
2007
|
+
nameForSerialization('logoAnchor')
|
|
1997
2008
|
], BaseDataCaptureView.prototype, "_logoAnchor", void 0);
|
|
1998
2009
|
__decorate([
|
|
1999
|
-
|
|
2010
|
+
nameForSerialization('logoOffset')
|
|
2000
2011
|
], BaseDataCaptureView.prototype, "_logoOffset", void 0);
|
|
2001
2012
|
__decorate([
|
|
2002
|
-
|
|
2013
|
+
nameForSerialization('focusGesture')
|
|
2003
2014
|
], BaseDataCaptureView.prototype, "_focusGesture", void 0);
|
|
2004
2015
|
__decorate([
|
|
2005
|
-
|
|
2016
|
+
nameForSerialization('zoomGesture')
|
|
2006
2017
|
], BaseDataCaptureView.prototype, "_zoomGesture", void 0);
|
|
2007
2018
|
__decorate([
|
|
2008
|
-
|
|
2019
|
+
nameForSerialization('logoStyle')
|
|
2009
2020
|
], BaseDataCaptureView.prototype, "_logoStyle", void 0);
|
|
2010
2021
|
__decorate([
|
|
2011
2022
|
ignoreFromSerialization
|
|
@@ -2402,12 +2413,17 @@ class RectangularViewfinder extends DefaultSerializeable {
|
|
|
2402
2413
|
get sizeWithUnitAndAspect() {
|
|
2403
2414
|
return this._sizeWithUnitAndAspect;
|
|
2404
2415
|
}
|
|
2416
|
+
set sizeWithUnitAndAspect(value) {
|
|
2417
|
+
this._sizeWithUnitAndAspect = value;
|
|
2418
|
+
this.update();
|
|
2419
|
+
}
|
|
2405
2420
|
get coreDefaults() {
|
|
2406
2421
|
return getCoreDefaults();
|
|
2407
2422
|
}
|
|
2408
2423
|
constructor(style, lineStyle) {
|
|
2409
2424
|
super();
|
|
2410
2425
|
this.type = 'rectangular';
|
|
2426
|
+
this.eventEmitter = FactoryMaker.getInstance('EventEmitter');
|
|
2411
2427
|
const viewfinderStyle = style || this.coreDefaults.RectangularViewfinder.defaultStyle;
|
|
2412
2428
|
this._style = this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].style;
|
|
2413
2429
|
this._lineStyle = this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].lineStyle;
|
|
@@ -2433,36 +2449,43 @@ class RectangularViewfinder extends DefaultSerializeable {
|
|
|
2433
2449
|
}
|
|
2434
2450
|
set dimming(value) {
|
|
2435
2451
|
this._dimming = value;
|
|
2452
|
+
this.update();
|
|
2436
2453
|
}
|
|
2437
2454
|
get disabledDimming() {
|
|
2438
2455
|
return this._disabledDimming;
|
|
2439
2456
|
}
|
|
2440
2457
|
set disabledDimming(value) {
|
|
2441
2458
|
this._disabledDimming = value;
|
|
2459
|
+
this.update();
|
|
2442
2460
|
}
|
|
2443
2461
|
get animation() {
|
|
2444
2462
|
return this._animation;
|
|
2445
2463
|
}
|
|
2446
2464
|
set animation(animation) {
|
|
2447
2465
|
this._animation = animation;
|
|
2466
|
+
this.update();
|
|
2448
2467
|
}
|
|
2449
2468
|
setSize(size) {
|
|
2450
|
-
this.
|
|
2469
|
+
this.sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithWidthAndHeight(size);
|
|
2451
2470
|
}
|
|
2452
2471
|
setWidthAndAspectRatio(width, heightToWidthAspectRatio) {
|
|
2453
|
-
this.
|
|
2472
|
+
this.sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithWidthAndAspectRatio(width, heightToWidthAspectRatio);
|
|
2454
2473
|
}
|
|
2455
2474
|
setHeightAndAspectRatio(height, widthToHeightAspectRatio) {
|
|
2456
|
-
this.
|
|
2475
|
+
this.sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithHeightAndAspectRatio(height, widthToHeightAspectRatio);
|
|
2457
2476
|
}
|
|
2458
2477
|
setShorterDimensionAndAspectRatio(fraction, aspectRatio) {
|
|
2459
|
-
this.
|
|
2478
|
+
this.sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithShorterDimensionAndAspectRatio(new NumberWithUnit(fraction, MeasureUnit.Fraction), aspectRatio);
|
|
2460
2479
|
}
|
|
2461
2480
|
get disabledColor() {
|
|
2462
2481
|
return this._disabledColor;
|
|
2463
2482
|
}
|
|
2464
2483
|
set disabledColor(value) {
|
|
2465
2484
|
this._disabledColor = value;
|
|
2485
|
+
this.update();
|
|
2486
|
+
}
|
|
2487
|
+
update() {
|
|
2488
|
+
this.eventEmitter.emit('viewfinder.update');
|
|
2466
2489
|
}
|
|
2467
2490
|
}
|
|
2468
2491
|
__decorate([
|
|
@@ -2487,6 +2510,9 @@ __decorate([
|
|
|
2487
2510
|
__decorate([
|
|
2488
2511
|
nameForSerialization('disabledColor')
|
|
2489
2512
|
], RectangularViewfinder.prototype, "_disabledColor", void 0);
|
|
2513
|
+
__decorate([
|
|
2514
|
+
ignoreFromSerialization
|
|
2515
|
+
], RectangularViewfinder.prototype, "eventEmitter", void 0);
|
|
2490
2516
|
|
|
2491
2517
|
var RectangularViewfinderStyle;
|
|
2492
2518
|
(function (RectangularViewfinderStyle) {
|