scandit-react-native-datacapture-core 7.4.1 → 7.5.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 +37 -13
- package/android/src/main/kotlin/com/scandit/datacapture/reactnative/core/ScanditDataCaptureCorePackage.kt +0 -4
- package/android/src/main/kotlin/com/scandit/datacapture/reactnative/core/ui/DataCaptureViewManager.kt +0 -1
- package/android/src/main/kotlin/com/scandit/datacapture/reactnative/core/utils/Extensions.kt +36 -0
- package/dist/core.js +213 -69
- package/dist/core.js.map +1 -1
- package/dist/dts/DataCaptureView.d.ts +3 -0
- package/dist/dts/index.d.ts +1 -1
- package/dist/dts/native/RNNativeCaller.d.ts +2 -0
- package/dist/index.js +50 -123
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/ios/Sources/Protocols/ScanditReactNativeFactoryContainer.swift +10 -0
- package/ios/Sources/ScanditDataCaptureCore.m +11 -11
- package/ios/Sources/ScanditDataCaptureCore.swift +51 -16
- package/ios/Sources/ScanditDataCaptureViewManager.swift +6 -3
- package/package.json +2 -2
- package/scandit-react-native-datacapture-core.podspec +25 -1
- package/dist/dts/native/CameraProxy.d.ts +0 -13
- package/dist/dts/native/DataCaptureContextProxy.d.ts +0 -17
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 = "7.
|
|
71
|
+
def sdk_version = "7.5.0-beta.2"
|
|
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) {
|
|
@@ -53,12 +53,12 @@ class ScanditDataCaptureCoreModule(
|
|
|
53
53
|
)
|
|
54
54
|
|
|
55
55
|
@ReactMethod
|
|
56
|
-
fun
|
|
56
|
+
fun subscribeContextListener() {
|
|
57
57
|
coreModule.registerDataCaptureContextListener()
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
@ReactMethod
|
|
61
|
-
fun
|
|
61
|
+
fun unsubscribeContextListener() {
|
|
62
62
|
coreModule.unregisterDataCaptureContextListener()
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -83,19 +83,28 @@ class ScanditDataCaptureCoreModule(
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
@ReactMethod
|
|
86
|
-
fun contextFromJSON(
|
|
87
|
-
|
|
86
|
+
fun contextFromJSON(readableMap: ReadableMap, promise: Promise) {
|
|
87
|
+
val contextJson = readableMap.getString("contextJson") ?: return promise.reject(
|
|
88
|
+
ParameterNullError("contextJson")
|
|
89
|
+
)
|
|
90
|
+
coreModule.createContextFromJson(contextJson, ReactNativeResult(promise))
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
@ReactMethod
|
|
91
|
-
fun updateContextFromJSON(
|
|
94
|
+
fun updateContextFromJSON(readableMap: ReadableMap, promise: Promise) {
|
|
95
|
+
val contextJson = readableMap.getString("contextJson") ?: return promise.reject(
|
|
96
|
+
ParameterNullError("contextJson")
|
|
97
|
+
)
|
|
92
98
|
mainThread.runOnMainThread {
|
|
93
|
-
coreModule.updateContextFromJson(
|
|
99
|
+
coreModule.updateContextFromJson(contextJson, ReactNativeResult(promise))
|
|
94
100
|
}
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
@ReactMethod
|
|
98
|
-
fun getFrame(
|
|
104
|
+
fun getFrame(readableMap: ReadableMap, promise: Promise) {
|
|
105
|
+
val frameId = readableMap.getString("frameId") ?: return promise.reject(
|
|
106
|
+
ParameterNullError("frameId")
|
|
107
|
+
)
|
|
99
108
|
coreModule.getLastFrameAsJson(frameId, ReactNativeResult(promise))
|
|
100
109
|
}
|
|
101
110
|
|
|
@@ -136,32 +145,47 @@ class ScanditDataCaptureCoreModule(
|
|
|
136
145
|
}
|
|
137
146
|
|
|
138
147
|
@ReactMethod
|
|
139
|
-
fun getCurrentCameraState(
|
|
148
|
+
fun getCurrentCameraState(readableMap: ReadableMap, promise: Promise) {
|
|
149
|
+
val cameraPosition = readableMap.getString("position") ?: return promise.reject(
|
|
150
|
+
ParameterNullError("position")
|
|
151
|
+
)
|
|
140
152
|
coreModule.getCameraState(cameraPosition, ReactNativeResult(promise))
|
|
141
153
|
}
|
|
142
154
|
|
|
143
155
|
@ReactMethod
|
|
144
|
-
fun isTorchAvailable(
|
|
156
|
+
fun isTorchAvailable(readableMap: ReadableMap, promise: Promise) {
|
|
157
|
+
val cameraPosition = readableMap.getString("cameraPosition") ?: return promise.reject(
|
|
158
|
+
ParameterNullError("cameraPosition")
|
|
159
|
+
)
|
|
145
160
|
coreModule.isTorchAvailable(cameraPosition, ReactNativeResult(promise))
|
|
146
161
|
}
|
|
147
162
|
|
|
148
163
|
@ReactMethod
|
|
149
|
-
fun switchCameraToDesiredState(
|
|
164
|
+
fun switchCameraToDesiredState(readableMap: ReadableMap, promise: Promise) {
|
|
165
|
+
val desiredStateJson = readableMap.getString("desiredStateJson") ?: return promise.reject(
|
|
166
|
+
ParameterNullError("desiredStateJson")
|
|
167
|
+
)
|
|
150
168
|
coreModule.switchCameraToDesiredState(desiredStateJson, ReactNativeResult(promise))
|
|
151
169
|
}
|
|
152
170
|
|
|
153
171
|
@ReactMethod
|
|
154
|
-
fun addModeToContext(
|
|
172
|
+
fun addModeToContext(readableMap: ReadableMap, promise: Promise) {
|
|
173
|
+
val modeJson = readableMap.getString("modeJson") ?: return promise.reject(
|
|
174
|
+
ParameterNullError("modeJson")
|
|
175
|
+
)
|
|
155
176
|
coreModule.addModeToContext(modeJson, ReactNativeResult(promise))
|
|
156
177
|
}
|
|
157
178
|
|
|
158
179
|
@ReactMethod
|
|
159
|
-
fun removeModeFromContext(
|
|
180
|
+
fun removeModeFromContext(readableMap: ReadableMap, promise: Promise) {
|
|
181
|
+
val modeJson = readableMap.getString("modeJson") ?: return promise.reject(
|
|
182
|
+
ParameterNullError("modeJson")
|
|
183
|
+
)
|
|
160
184
|
coreModule.removeModeFromContext(modeJson, ReactNativeResult(promise))
|
|
161
185
|
}
|
|
162
186
|
|
|
163
187
|
@ReactMethod
|
|
164
|
-
fun
|
|
188
|
+
fun removeAllModes(promise: Promise) {
|
|
165
189
|
coreModule.removeAllModes(ReactNativeResult(promise))
|
|
166
190
|
}
|
|
167
191
|
|
|
@@ -76,10 +76,6 @@ class ScanditDataCaptureCorePackage : ReactPackage {
|
|
|
76
76
|
private fun setupSharedModule(reactContext: ReactApplicationContext) {
|
|
77
77
|
lock.lock()
|
|
78
78
|
try {
|
|
79
|
-
// In React-Native if this function is called again we have to cleanup the existing
|
|
80
|
-
// instances and re-create them again.
|
|
81
|
-
serviceLocator.remove(CoreModule::class.java.name)
|
|
82
|
-
|
|
83
79
|
val eventEmitter: Emitter = ReactNativeEventEmitter(reactContext)
|
|
84
80
|
val coreModule = CoreModule.create(eventEmitter)
|
|
85
81
|
coreModule.onCreate(reactContext)
|
package/android/src/main/kotlin/com/scandit/datacapture/reactnative/core/utils/Extensions.kt
CHANGED
|
@@ -9,6 +9,7 @@ package com.scandit.datacapture.reactnative.core.utils
|
|
|
9
9
|
import com.facebook.react.bridge.*
|
|
10
10
|
import com.scandit.datacapture.core.common.geometry.MeasureUnit
|
|
11
11
|
import com.scandit.datacapture.core.common.geometry.PointWithUnit
|
|
12
|
+
import com.scandit.datacapture.frameworks.core.utils.DefaultFrameworksLog
|
|
12
13
|
import com.scandit.datacapture.reactnative.core.data.SerializableData
|
|
13
14
|
import java.util.*
|
|
14
15
|
|
|
@@ -23,3 +24,38 @@ fun WritableMap.putData(key: String, data: SerializableData) {
|
|
|
23
24
|
|
|
24
25
|
inline fun <reified T : JavaScriptModule> ReactApplicationContext.getJSModule(): T =
|
|
25
26
|
getJSModule(T::class.java)
|
|
27
|
+
|
|
28
|
+
val ReadableMap.viewId: Int
|
|
29
|
+
get() = this.getInt("viewId")
|
|
30
|
+
|
|
31
|
+
val ReadableMap.modeId: Int
|
|
32
|
+
get() = this.getInt("modeId")
|
|
33
|
+
|
|
34
|
+
fun ReadableMap.getSafeLong(key: String): Long? {
|
|
35
|
+
if (!hasKey(key) || isNull(key)) return null
|
|
36
|
+
|
|
37
|
+
return try {
|
|
38
|
+
when (getType(key)) {
|
|
39
|
+
ReadableType.Number -> {
|
|
40
|
+
val doubleValue = getDouble(key)
|
|
41
|
+
val longValue = doubleValue.toLong()
|
|
42
|
+
require(doubleValue == longValue.toDouble())
|
|
43
|
+
longValue
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
ReadableType.String ->
|
|
47
|
+
getString(key)?.toLongOrNull()
|
|
48
|
+
?: throw IllegalArgumentException(
|
|
49
|
+
"Value for '$key' is not a valid long string."
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
else -> throw IllegalArgumentException(
|
|
53
|
+
"Unsupported type for '$key'. Expected number or string."
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
} catch (e: Exception) {
|
|
57
|
+
DefaultFrameworksLog.getInstance()
|
|
58
|
+
.error("Failed to parse long for key '$key': ${e.message}", e)
|
|
59
|
+
return null
|
|
60
|
+
}
|
|
61
|
+
}
|