scandit-react-native-datacapture-core 8.0.0 → 8.1.0
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 +35 -16
- package/android/src/main/kotlin/com/scandit/datacapture/reactnative/core/utils/ReactNativeMethodCall.kt +57 -0
- package/dist/core.js +482 -695
- package/dist/core.js.map +1 -1
- package/dist/dts/DataCaptureView.d.ts +6 -5
- package/dist/dts/index.d.ts +1 -0
- package/dist/dts/native/CoreNativeCallerProvider.d.ts +4 -0
- package/dist/dts/native/RNNativeCaller.d.ts +7 -4
- package/dist/dts/native/ScanditNativeModule.d.ts +9 -0
- package/dist/index.js +52 -106
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/ios/Sources/Extensions/Brush+RNTSDCSerializer.swift +6 -4
- package/ios/Sources/Extensions/CGPoint+JSON.swift +2 -2
- package/ios/Sources/Extensions/CameraSettings+RNTSDCSerializer.swift +9 -7
- package/ios/Sources/Extensions/UIInterfaceOrientation+RNTSDCSerializer.swift +1 -1
- package/ios/Sources/Protocols/ScanditReactNativeFactoryContainer.swift +1 -2
- package/ios/Sources/ScanditDataCaptureCore.m +9 -4
- package/ios/Sources/ScanditDataCaptureCore.swift +174 -75
- package/ios/Sources/ScanditDataCaptureViewManager.swift +3 -3
- package/ios/Sources/Utils/JSView.swift +3 -2
- package/ios/Sources/Utils/ReactNativeEmitter.swift +3 -2
- package/ios/Sources/Utils/ReactNativeMethodCall.swift +159 -0
- package/ios/Sources/Utils/ReactNativeResult.swift +8 -4
- package/package.json +3 -4
- package/scandit-react-native-datacapture-core.podspec +1 -1
- package/scripts/detect_frameworks.rb +33 -7
- package/dist/dts/native/DataCaptureViewProxy.d.ts +0 -24
- package/dist/dts/native/FeedbackProxy.d.ts +0 -4
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 = "8.
|
|
71
|
+
def sdk_version = "8.1.0"
|
|
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) {
|
|
@@ -20,6 +20,7 @@ import com.scandit.datacapture.frameworks.core.errors.ParameterNullError
|
|
|
20
20
|
import com.scandit.datacapture.frameworks.core.locator.ServiceLocator
|
|
21
21
|
import com.scandit.datacapture.reactnative.core.ui.DataCaptureViewManager
|
|
22
22
|
import com.scandit.datacapture.reactnative.core.utils.ReactNativeResult
|
|
23
|
+
import com.scandit.datacapture.reactnative.core.utils.viewId
|
|
23
24
|
|
|
24
25
|
class ScanditDataCaptureCoreModule(
|
|
25
26
|
reactContext: ReactApplicationContext,
|
|
@@ -72,13 +73,13 @@ class ScanditDataCaptureCoreModule(
|
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
@ReactMethod
|
|
75
|
-
fun registerListenerForViewEvents(
|
|
76
|
-
coreModule.registerDataCaptureViewListener(viewId)
|
|
76
|
+
fun registerListenerForViewEvents(readableMap: ReadableMap) {
|
|
77
|
+
coreModule.registerDataCaptureViewListener(readableMap.viewId)
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
@ReactMethod
|
|
80
|
-
fun unregisterListenerForViewEvents(
|
|
81
|
-
coreModule.unregisterDataCaptureViewListener(viewId)
|
|
81
|
+
fun unregisterListenerForViewEvents(readableMap: ReadableMap) {
|
|
82
|
+
coreModule.unregisterDataCaptureViewListener(readableMap.viewId)
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
@ReactMethod
|
|
@@ -111,18 +112,21 @@ class ScanditDataCaptureCoreModule(
|
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
@ReactMethod
|
|
114
|
-
fun emitFeedback(
|
|
115
|
-
|
|
115
|
+
fun emitFeedback(readableMap: ReadableMap, promise: Promise) {
|
|
116
|
+
val feedbackJson = readableMap.getString("feedbackJson") ?: return promise.reject(
|
|
117
|
+
ParameterNullError("feedbackJson")
|
|
118
|
+
)
|
|
119
|
+
coreModule.emitFeedback(feedbackJson, ReactNativeResult(promise))
|
|
116
120
|
}
|
|
117
121
|
|
|
118
122
|
@ReactMethod
|
|
119
123
|
fun viewPointForFramePoint(readableMap: ReadableMap, promise: Promise) {
|
|
120
|
-
val pointJson = readableMap.getString("
|
|
121
|
-
ParameterNullError("
|
|
124
|
+
val pointJson = readableMap.getString("pointJson") ?: return promise.reject(
|
|
125
|
+
ParameterNullError("pointJson")
|
|
122
126
|
)
|
|
123
127
|
|
|
124
128
|
coreModule.viewPointForFramePoint(
|
|
125
|
-
readableMap.
|
|
129
|
+
readableMap.viewId,
|
|
126
130
|
pointJson,
|
|
127
131
|
ReactNativeResult(promise)
|
|
128
132
|
)
|
|
@@ -130,12 +134,12 @@ class ScanditDataCaptureCoreModule(
|
|
|
130
134
|
|
|
131
135
|
@ReactMethod
|
|
132
136
|
fun viewQuadrilateralForFrameQuadrilateral(readableMap: ReadableMap, promise: Promise) {
|
|
133
|
-
val quadrilateralJson = readableMap.getString("
|
|
134
|
-
ParameterNullError("
|
|
137
|
+
val quadrilateralJson = readableMap.getString("quadrilateralJson") ?: return promise.reject(
|
|
138
|
+
ParameterNullError("quadrilateralJson")
|
|
135
139
|
)
|
|
136
140
|
|
|
137
141
|
coreModule.viewQuadrilateralForFrameQuadrilateral(
|
|
138
|
-
readableMap.
|
|
142
|
+
readableMap.viewId,
|
|
139
143
|
quadrilateralJson,
|
|
140
144
|
ReactNativeResult(promise)
|
|
141
145
|
)
|
|
@@ -151,8 +155,8 @@ class ScanditDataCaptureCoreModule(
|
|
|
151
155
|
|
|
152
156
|
@ReactMethod
|
|
153
157
|
fun isTorchAvailable(readableMap: ReadableMap, promise: Promise) {
|
|
154
|
-
val cameraPosition = readableMap.getString("
|
|
155
|
-
ParameterNullError("
|
|
158
|
+
val cameraPosition = readableMap.getString("position") ?: return promise.reject(
|
|
159
|
+
ParameterNullError("position")
|
|
156
160
|
)
|
|
157
161
|
coreModule.isTorchAvailable(cameraPosition, ReactNativeResult(promise))
|
|
158
162
|
}
|
|
@@ -187,7 +191,10 @@ class ScanditDataCaptureCoreModule(
|
|
|
187
191
|
}
|
|
188
192
|
|
|
189
193
|
@ReactMethod
|
|
190
|
-
fun createDataCaptureView(
|
|
194
|
+
fun createDataCaptureView(readableMap: ReadableMap, promise: Promise) {
|
|
195
|
+
val viewJson = readableMap.getString("viewJson") ?: return promise.reject(
|
|
196
|
+
ParameterNullError("viewJson")
|
|
197
|
+
)
|
|
191
198
|
val viewManager = viewManagers[DataCaptureViewManager::class.java.name] as?
|
|
192
199
|
DataCaptureViewManager
|
|
193
200
|
if (viewManager == null) {
|
|
@@ -199,10 +206,22 @@ class ScanditDataCaptureCoreModule(
|
|
|
199
206
|
}
|
|
200
207
|
|
|
201
208
|
@ReactMethod
|
|
202
|
-
fun updateDataCaptureView(
|
|
209
|
+
fun updateDataCaptureView(readableMap: ReadableMap, promise: Promise) {
|
|
210
|
+
val viewJson = readableMap.getString("viewJson") ?: return promise.reject(
|
|
211
|
+
ParameterNullError("viewJson")
|
|
212
|
+
)
|
|
203
213
|
coreModule.updateDataCaptureView(viewJson, ReactNativeResult(promise))
|
|
204
214
|
}
|
|
205
215
|
|
|
216
|
+
@ReactMethod
|
|
217
|
+
fun removeDataCaptureView(
|
|
218
|
+
@Suppress("unused") readableMap: ReadableMap,
|
|
219
|
+
promise: Promise
|
|
220
|
+
) {
|
|
221
|
+
// Handled through the ViewManager
|
|
222
|
+
promise.resolve(null)
|
|
223
|
+
}
|
|
224
|
+
|
|
206
225
|
@ReactMethod
|
|
207
226
|
fun getOpenSourceSoftwareLicenseInfo(promise: Promise) {
|
|
208
227
|
coreModule.getOpenSourceSoftwareLicenseInfo(ReactNativeResult(promise))
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the Scandit Data Capture SDK
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2025- Scandit AG. All rights reserved.
|
|
5
|
+
*/
|
|
6
|
+
package com.scandit.datacapture.reactnative.core.utils
|
|
7
|
+
|
|
8
|
+
import com.facebook.react.bridge.ReadableMap
|
|
9
|
+
import com.facebook.react.bridge.ReadableType
|
|
10
|
+
import com.scandit.datacapture.frameworks.core.errors.ParameterNullError
|
|
11
|
+
import com.scandit.datacapture.frameworks.core.method.FrameworksMethodCall
|
|
12
|
+
|
|
13
|
+
class ReactNativeMethodCall(
|
|
14
|
+
private val readableMap: ReadableMap
|
|
15
|
+
) : FrameworksMethodCall {
|
|
16
|
+
|
|
17
|
+
override val method: String
|
|
18
|
+
get() = readableMap.getString("methodName") ?: "unknow"
|
|
19
|
+
|
|
20
|
+
@Suppress("UNCHECKED_CAST")
|
|
21
|
+
override fun <T> argument(key: String): T {
|
|
22
|
+
if (!readableMap.hasKey(key)) {
|
|
23
|
+
throw ParameterNullError(key)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return when (readableMap.getType(key)) {
|
|
27
|
+
ReadableType.Null -> return null as T
|
|
28
|
+
ReadableType.Boolean -> readableMap.getBoolean(key) as T
|
|
29
|
+
ReadableType.Number -> {
|
|
30
|
+
val doubleValue = readableMap.getDouble(key)
|
|
31
|
+
try {
|
|
32
|
+
return when {
|
|
33
|
+
doubleValue % 1.0 == 0.0 &&
|
|
34
|
+
doubleValue >= Int.MIN_VALUE &&
|
|
35
|
+
doubleValue <= Int.MAX_VALUE ->
|
|
36
|
+
doubleValue.toInt() as? T ?: doubleValue as T
|
|
37
|
+
|
|
38
|
+
doubleValue % 1.0 == 0.0 ->
|
|
39
|
+
doubleValue.toLong() as? T ?: doubleValue as T
|
|
40
|
+
|
|
41
|
+
else -> doubleValue as T
|
|
42
|
+
}
|
|
43
|
+
} catch (e: ClassCastException) {
|
|
44
|
+
doubleValue as T
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
ReadableType.String -> readableMap.getString(key) as T
|
|
48
|
+
ReadableType.Map -> readableMap.getMap(key) as T
|
|
49
|
+
ReadableType.Array -> readableMap.getArray(key) as T
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
override fun hasArgument(key: String): Boolean =
|
|
54
|
+
readableMap.hasKey(key)
|
|
55
|
+
|
|
56
|
+
override fun arguments(): Map<String, Any?> = readableMap.toHashMap()
|
|
57
|
+
}
|