scandit-react-native-datacapture-core 6.28.1 → 6.28.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/android/build.gradle +1 -1
- package/android/src/main/kotlin/com/scandit/datacapture/reactnative/core/ScanditDataCaptureCoreModule.kt +11 -14
- package/android/src/main/kotlin/com/scandit/datacapture/reactnative/core/ScanditDataCaptureCorePackage.kt +29 -24
- package/android/src/main/kotlin/com/scandit/datacapture/reactnative/core/ui/DataCaptureViewManager.kt +36 -15
- package/android/src/main/kotlin/com/scandit/datacapture/reactnative/core/ui/ScanditViewGroupManager.kt +2 -8
- package/dist/core.js +48 -1
- package/dist/core.js.map +1 -1
- package/dist/dts/DataCaptureView.d.ts +2 -0
- package/dist/index.js +15 -21
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/ios/Sources/ScanditDataCaptureCore.swift +3 -1
- package/ios/Sources/ScanditDataCaptureViewManager.swift +16 -11
- package/package.json +2 -2
- package/scandit-react-native-datacapture-core.podspec +1 -1
- package/android/src/main/kotlin/com/scandit/datacapture/reactnative/core/ui/FragmentBase.kt +0 -11
package/android/build.gradle
CHANGED
|
@@ -68,7 +68,7 @@ if (file( "${rootProject.projectDir}/build-test.gradle").exists()) {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
dependencies {
|
|
71
|
-
def sdk_version = "6.28.
|
|
71
|
+
def sdk_version = "6.28.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) {
|
|
@@ -12,8 +12,9 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
|
12
12
|
import com.facebook.react.bridge.ReactMethod
|
|
13
13
|
import com.scandit.datacapture.core.capture.DataCaptureVersion
|
|
14
14
|
import com.scandit.datacapture.frameworks.core.CoreModule
|
|
15
|
-
import com.scandit.datacapture.frameworks.core.
|
|
16
|
-
import com.scandit.datacapture.frameworks.core.
|
|
15
|
+
import com.scandit.datacapture.frameworks.core.FrameworkModule
|
|
16
|
+
import com.scandit.datacapture.frameworks.core.errors.ModuleNotStartedError
|
|
17
|
+
import com.scandit.datacapture.frameworks.core.locator.ServiceLocator
|
|
17
18
|
import com.scandit.datacapture.frameworks.core.utils.DefaultLastFrameData
|
|
18
19
|
import com.scandit.datacapture.frameworks.core.utils.DefaultMainThread
|
|
19
20
|
import com.scandit.datacapture.frameworks.core.utils.LastFrameData
|
|
@@ -24,10 +25,10 @@ import com.scandit.datacapture.reactnative.core.utils.reject
|
|
|
24
25
|
|
|
25
26
|
class ScanditDataCaptureCoreModule(
|
|
26
27
|
reactContext: ReactApplicationContext,
|
|
27
|
-
private val
|
|
28
|
+
private val serviceLocator: ServiceLocator<FrameworkModule>,
|
|
28
29
|
private val mainThread: MainThread = DefaultMainThread.getInstance(),
|
|
29
30
|
private val lastFrameData: LastFrameData = DefaultLastFrameData.getInstance()
|
|
30
|
-
) : ReactContextBaseJavaModule(reactContext)
|
|
31
|
+
) : ReactContextBaseJavaModule(reactContext) {
|
|
31
32
|
|
|
32
33
|
companion object {
|
|
33
34
|
private const val VERSION_KEY = "Version"
|
|
@@ -35,18 +36,8 @@ class ScanditDataCaptureCoreModule(
|
|
|
35
36
|
|
|
36
37
|
private val ERROR_NULL_FRAME = Error(5, "Frame is null, it might've been reused already.")
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
-
private val deserializationLifecycleObserver: DeserializationLifecycleObserver =
|
|
40
|
-
DefaultDeserializationLifecycleObserver.getInstance()
|
|
41
|
-
|
|
42
|
-
init {
|
|
43
|
-
coreModule.onCreate(reactContext)
|
|
44
|
-
deserializationLifecycleObserver.attach(this)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
39
|
override fun invalidate() {
|
|
48
40
|
coreModule.onDestroy()
|
|
49
|
-
deserializationLifecycleObserver.detach(this)
|
|
50
41
|
super.invalidate()
|
|
51
42
|
}
|
|
52
43
|
|
|
@@ -177,4 +168,10 @@ class ScanditDataCaptureCoreModule(
|
|
|
177
168
|
fun updateDataCaptureView(viewJson: String, promise: Promise) {
|
|
178
169
|
coreModule.updateDataCaptureView(viewJson, ReactNativeResult(promise))
|
|
179
170
|
}
|
|
171
|
+
|
|
172
|
+
private val coreModule: CoreModule
|
|
173
|
+
get() {
|
|
174
|
+
return serviceLocator.resolve(CoreModule::class.java.name) as? CoreModule?
|
|
175
|
+
?: throw ModuleNotStartedError(ScanditDataCaptureCoreModule::class.java.simpleName)
|
|
176
|
+
}
|
|
180
177
|
}
|
|
@@ -14,46 +14,51 @@ import com.scandit.datacapture.frameworks.core.events.Emitter
|
|
|
14
14
|
import com.scandit.datacapture.frameworks.core.listeners.FrameworksDataCaptureContextListener
|
|
15
15
|
import com.scandit.datacapture.frameworks.core.listeners.FrameworksDataCaptureViewListener
|
|
16
16
|
import com.scandit.datacapture.frameworks.core.listeners.FrameworksFrameSourceListener
|
|
17
|
+
import com.scandit.datacapture.frameworks.core.locator.DefaultServiceLocator
|
|
17
18
|
import com.scandit.datacapture.reactnative.core.ui.DataCaptureViewManager
|
|
18
19
|
import com.scandit.datacapture.reactnative.core.utils.ReactNativeEventEmitter
|
|
20
|
+
import java.util.concurrent.locks.ReentrantLock
|
|
19
21
|
|
|
20
22
|
class ScanditDataCaptureCorePackage : ReactPackage {
|
|
23
|
+
private val serviceLocator = DefaultServiceLocator.getInstance()
|
|
24
|
+
|
|
21
25
|
override fun createNativeModules(
|
|
22
26
|
reactContext: ReactApplicationContext
|
|
23
|
-
): MutableList<NativeModule>
|
|
24
|
-
|
|
27
|
+
): MutableList<NativeModule> {
|
|
28
|
+
setupSharedModule(reactContext)
|
|
29
|
+
return mutableListOf(
|
|
25
30
|
ScanditDataCaptureCoreModule(
|
|
26
31
|
reactContext,
|
|
27
|
-
|
|
28
|
-
reactContext
|
|
29
|
-
),
|
|
32
|
+
serviceLocator,
|
|
30
33
|
)
|
|
31
34
|
)
|
|
35
|
+
}
|
|
32
36
|
|
|
33
37
|
override fun createViewManagers(
|
|
34
38
|
reactContext: ReactApplicationContext
|
|
35
|
-
): MutableList<ViewManager<*, *>> =
|
|
36
|
-
mutableListOf(DataCaptureViewManager(getCoreModule(reactContext)))
|
|
39
|
+
): MutableList<ViewManager<*, *>> = mutableListOf(DataCaptureViewManager(serviceLocator))
|
|
37
40
|
|
|
38
|
-
private
|
|
41
|
+
private fun setupSharedModule(reactContext: ReactApplicationContext) {
|
|
42
|
+
lock.lock()
|
|
43
|
+
try {
|
|
44
|
+
// In React-Native if this function is called again we have to cleanup the existing
|
|
45
|
+
// instances and re-create them again.
|
|
46
|
+
serviceLocator.remove(CoreModule::class.java.name)
|
|
39
47
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
val eventEmitter: Emitter = ReactNativeEventEmitter(reactContext)
|
|
49
|
+
val coreModule = CoreModule.create(
|
|
50
|
+
FrameworksFrameSourceListener(eventEmitter),
|
|
51
|
+
FrameworksDataCaptureContextListener(eventEmitter),
|
|
52
|
+
FrameworksDataCaptureViewListener(eventEmitter)
|
|
53
|
+
)
|
|
54
|
+
coreModule.onCreate(reactContext)
|
|
55
|
+
serviceLocator.register(coreModule)
|
|
56
|
+
} finally {
|
|
57
|
+
lock.unlock()
|
|
46
58
|
}
|
|
59
|
+
}
|
|
47
60
|
|
|
48
|
-
|
|
49
|
-
val
|
|
50
|
-
FrameworksFrameSourceListener(
|
|
51
|
-
eventEmitter
|
|
52
|
-
),
|
|
53
|
-
FrameworksDataCaptureContextListener(eventEmitter),
|
|
54
|
-
FrameworksDataCaptureViewListener(eventEmitter)
|
|
55
|
-
)
|
|
56
|
-
this.coreModule = instance
|
|
57
|
-
return instance
|
|
61
|
+
companion object {
|
|
62
|
+
private val lock: ReentrantLock = ReentrantLock()
|
|
58
63
|
}
|
|
59
64
|
}
|
|
@@ -9,17 +9,19 @@ package com.scandit.datacapture.reactnative.core.ui
|
|
|
9
9
|
import android.view.ViewGroup
|
|
10
10
|
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
|
11
11
|
import android.widget.FrameLayout
|
|
12
|
+
import com.facebook.react.bridge.ReadableArray
|
|
12
13
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
13
14
|
import com.scandit.datacapture.core.ui.DataCaptureView
|
|
14
15
|
import com.scandit.datacapture.frameworks.core.CoreModule
|
|
16
|
+
import com.scandit.datacapture.frameworks.core.FrameworkModule
|
|
17
|
+
import com.scandit.datacapture.frameworks.core.errors.ModuleNotStartedError
|
|
15
18
|
import com.scandit.datacapture.frameworks.core.handlers.DataCaptureViewHandler
|
|
16
19
|
import com.scandit.datacapture.frameworks.core.handlers.DefaultDataCaptureViewHandler
|
|
17
|
-
import com.scandit.datacapture.frameworks.core.
|
|
18
|
-
import com.scandit.datacapture.frameworks.core.
|
|
20
|
+
import com.scandit.datacapture.frameworks.core.locator.ServiceLocator
|
|
21
|
+
import com.scandit.datacapture.frameworks.core.result.NoopFrameworksResult
|
|
19
22
|
|
|
20
23
|
class DataCaptureViewManager(
|
|
21
|
-
private val
|
|
22
|
-
private val mainThread: MainThread = DefaultMainThread.getInstance(),
|
|
24
|
+
private val serviceLocator: ServiceLocator<FrameworkModule>,
|
|
23
25
|
private val dataCaptureViewHandler: DataCaptureViewHandler =
|
|
24
26
|
DefaultDataCaptureViewHandler.getInstance()
|
|
25
27
|
) : ScanditViewGroupManager<FrameLayout>() {
|
|
@@ -29,20 +31,12 @@ class DataCaptureViewManager(
|
|
|
29
31
|
override fun createNewInstance(reactContext: ThemedReactContext): FrameLayout =
|
|
30
32
|
FrameLayout(reactContext)
|
|
31
33
|
|
|
32
|
-
override fun createViewInstance(reactContext: ThemedReactContext): FrameLayout {
|
|
33
|
-
val container = super.createViewInstance(reactContext)
|
|
34
|
-
dataCaptureViewHandler.topmostDataCaptureView?.let { view ->
|
|
35
|
-
addDataCaptureViewToContainer(view, container)
|
|
36
|
-
}
|
|
37
|
-
return container
|
|
38
|
-
}
|
|
39
|
-
|
|
40
34
|
override fun onDropViewInstance(view: FrameLayout) {
|
|
41
35
|
// remove current DCView from core cache
|
|
42
36
|
for (i in 0 until view.childCount) {
|
|
43
37
|
val child = view.getChildAt(i)
|
|
44
38
|
if (child is DataCaptureView) { // it should always be a DCView but you never know
|
|
45
|
-
|
|
39
|
+
coreModule.dataCaptureViewDisposed(child)
|
|
46
40
|
}
|
|
47
41
|
}
|
|
48
42
|
|
|
@@ -55,15 +49,31 @@ class DataCaptureViewManager(
|
|
|
55
49
|
}
|
|
56
50
|
}
|
|
57
51
|
|
|
52
|
+
override fun getCommandsMap(): MutableMap<String, Int> = mutableMapOf(
|
|
53
|
+
CREATE_FRAGMENT_COMMAND to CREATE_FRAGMENT_COMMAND_INDEX
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
override fun receiveCommand(root: FrameLayout, commandId: String?, args: ReadableArray?) {
|
|
57
|
+
if (commandId == CREATE_FRAGMENT_COMMAND) {
|
|
58
|
+
val viewJson = args?.getString(0) ?: return
|
|
59
|
+
|
|
60
|
+
coreModule.createDataCaptureView(viewJson, NoopFrameworksResult())?.let {
|
|
61
|
+
currentContainer?.let { container ->
|
|
62
|
+
addDataCaptureViewToContainer(it, container)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
58
68
|
private fun addDataCaptureViewToContainer(
|
|
59
69
|
dataCaptureView: DataCaptureView,
|
|
60
70
|
container: FrameLayout
|
|
61
71
|
) {
|
|
62
|
-
|
|
72
|
+
container.post {
|
|
63
73
|
if (container.childCount > 0 && container.getChildAt(0) === dataCaptureView) {
|
|
64
74
|
// Same instance already attached. No need to detach and attach it again because
|
|
65
75
|
// it will trigger some overlay cleanup that we don't want.
|
|
66
|
-
return@
|
|
76
|
+
return@post
|
|
67
77
|
}
|
|
68
78
|
|
|
69
79
|
/*
|
|
@@ -80,4 +90,15 @@ class DataCaptureViewManager(
|
|
|
80
90
|
container.addView(dataCaptureView, MATCH_PARENT, MATCH_PARENT)
|
|
81
91
|
}
|
|
82
92
|
}
|
|
93
|
+
|
|
94
|
+
private val coreModule: CoreModule
|
|
95
|
+
get() {
|
|
96
|
+
return serviceLocator.resolve(CoreModule::class.java.name) as? CoreModule?
|
|
97
|
+
?: throw ModuleNotStartedError(DataCaptureViewManager::class.java.simpleName)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
companion object {
|
|
101
|
+
private const val CREATE_FRAGMENT_COMMAND_INDEX = 1
|
|
102
|
+
private const val CREATE_FRAGMENT_COMMAND = "createDataCaptureView"
|
|
103
|
+
}
|
|
83
104
|
}
|
|
@@ -12,17 +12,13 @@ import android.view.ViewGroup
|
|
|
12
12
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
13
13
|
import com.facebook.react.uimanager.ViewGroupManager
|
|
14
14
|
|
|
15
|
-
abstract class ScanditViewGroupManager<T> :
|
|
15
|
+
abstract class ScanditViewGroupManager<T> :
|
|
16
|
+
ViewGroupManager<T>() where T : ViewGroup {
|
|
16
17
|
private val containers = mutableListOf<T>()
|
|
17
18
|
|
|
18
|
-
protected val fragmentsCache: MutableMap<T, FragmentBase> = mutableMapOf()
|
|
19
|
-
|
|
20
19
|
val currentContainer: T?
|
|
21
20
|
get() = if (containers.size > 0) containers[containers.size - 1] else null
|
|
22
21
|
|
|
23
|
-
// Action to be executed after the container is created via the createViewInstance function
|
|
24
|
-
var postContainerCreationAction: (() -> Unit)? = null
|
|
25
|
-
|
|
26
22
|
abstract fun createNewInstance(reactContext: ThemedReactContext): T
|
|
27
23
|
|
|
28
24
|
override fun invalidate() {
|
|
@@ -38,8 +34,6 @@ abstract class ScanditViewGroupManager<T> : ViewGroupManager<T>() where T : View
|
|
|
38
34
|
if (containers.size == 1) {
|
|
39
35
|
scheduleMeasureAndLayout()
|
|
40
36
|
}
|
|
41
|
-
postContainerCreationAction?.invoke()
|
|
42
|
-
postContainerCreationAction = null
|
|
43
37
|
return container
|
|
44
38
|
}
|
|
45
39
|
|
package/dist/core.js
CHANGED
|
@@ -1763,6 +1763,53 @@ var ScanIntention;
|
|
|
1763
1763
|
ScanIntention["Smart"] = "smart";
|
|
1764
1764
|
})(ScanIntention || (ScanIntention = {}));
|
|
1765
1765
|
|
|
1766
|
+
class HtmlElementPosition {
|
|
1767
|
+
constructor(top, left) {
|
|
1768
|
+
this.top = 0;
|
|
1769
|
+
this.left = 0;
|
|
1770
|
+
this.top = top;
|
|
1771
|
+
this.left = left;
|
|
1772
|
+
}
|
|
1773
|
+
didChangeComparedTo(other) {
|
|
1774
|
+
if (!other)
|
|
1775
|
+
return true;
|
|
1776
|
+
return this.top !== other.top || this.left !== other.left;
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
class HtmlElementSize {
|
|
1780
|
+
constructor(width, height) {
|
|
1781
|
+
this.width = width;
|
|
1782
|
+
this.height = height;
|
|
1783
|
+
}
|
|
1784
|
+
didChangeComparedTo(other) {
|
|
1785
|
+
if (!other)
|
|
1786
|
+
return true;
|
|
1787
|
+
return this.width !== other.width || this.height !== other.height;
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
class HTMLElementState {
|
|
1791
|
+
constructor() {
|
|
1792
|
+
this.isShown = false;
|
|
1793
|
+
this.position = null;
|
|
1794
|
+
this.size = null;
|
|
1795
|
+
this.shouldBeUnderContent = false;
|
|
1796
|
+
}
|
|
1797
|
+
get isValid() {
|
|
1798
|
+
return this.isShown !== undefined && this.isShown !== null
|
|
1799
|
+
&& this.position !== undefined && this.position !== null
|
|
1800
|
+
&& this.size !== undefined && this.size !== null
|
|
1801
|
+
&& this.shouldBeUnderContent !== undefined && this.shouldBeUnderContent !== null;
|
|
1802
|
+
}
|
|
1803
|
+
didChangeComparedTo(other) {
|
|
1804
|
+
var _a, _b, _c, _d;
|
|
1805
|
+
if (!other)
|
|
1806
|
+
return true;
|
|
1807
|
+
const positionChanged = (_b = (_a = this.position) === null || _a === void 0 ? void 0 : _a.didChangeComparedTo(other.position)) !== null && _b !== void 0 ? _b : (this.position !== other.position);
|
|
1808
|
+
const sizeChanged = (_d = (_c = this.size) === null || _c === void 0 ? void 0 : _c.didChangeComparedTo(other.size)) !== null && _d !== void 0 ? _d : (this.size !== other.size);
|
|
1809
|
+
return positionChanged || sizeChanged || this.shouldBeUnderContent !== other.shouldBeUnderContent;
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
|
|
1766
1813
|
var DataCaptureViewEvents;
|
|
1767
1814
|
(function (DataCaptureViewEvents) {
|
|
1768
1815
|
DataCaptureViewEvents["didChangeSize"] = "DataCaptureViewListener.onSizeChanged";
|
|
@@ -2915,5 +2962,5 @@ var Expiration;
|
|
|
2915
2962
|
|
|
2916
2963
|
createEventEmitter();
|
|
2917
2964
|
|
|
2918
|
-
export { AimerViewfinder, Anchor, BaseController, BaseDataCaptureView, BaseNativeProxy, Brush, Camera, CameraController, CameraPosition, CameraSettings, Color, ContextStatus, ControlImage, DataCaptureContext, DataCaptureContextEvents, DataCaptureContextFeatures, 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, ScanIntention, Size, SizeWithAspect, SizeWithUnit, SizeWithUnitAndAspect, SizingMode, Sound, SpotlightViewfinder, SwipeToZoom, TapToFocus, TorchState, TorchSwitchControl, Vibration, VibrationType, VideoResolution, WaveFormVibration, ZoomSwitchControl, getCoreDefaults, ignoreFromSerialization, ignoreFromSerializationIfNull, loadCoreDefaults, nameForSerialization, serializationDefault };
|
|
2965
|
+
export { AimerViewfinder, Anchor, BaseController, BaseDataCaptureView, BaseNativeProxy, Brush, Camera, CameraController, CameraPosition, CameraSettings, Color, ContextStatus, ControlImage, DataCaptureContext, DataCaptureContextEvents, DataCaptureContextFeatures, DataCaptureContextSettings, DataCaptureViewController, DataCaptureViewEvents, DefaultSerializeable, Direction, EventEmitter, Expiration, FactoryMaker, Feedback, FocusGestureStrategy, FocusRange, FrameSourceListenerEvents, FrameSourceState, HTMLElementState, HtmlElementPosition, HtmlElementSize, 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, ScanIntention, Size, SizeWithAspect, SizeWithUnit, SizeWithUnitAndAspect, SizingMode, Sound, SpotlightViewfinder, SwipeToZoom, TapToFocus, TorchState, TorchSwitchControl, Vibration, VibrationType, VideoResolution, WaveFormVibration, ZoomSwitchControl, getCoreDefaults, ignoreFromSerialization, ignoreFromSerializationIfNull, loadCoreDefaults, nameForSerialization, serializationDefault };
|
|
2919
2966
|
//# sourceMappingURL=core.js.map
|