scandit-react-native-datacapture-parser 8.2.0 → 8.3.0-beta.1
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 +1 -1
- package/android/build.gradle +29 -1
- package/android/generated/java/com/facebook/fbreact/specs/NativeScanditDataCaptureParserSpec.java +75 -0
- package/android/generated/jni/CMakeLists.txt +29 -0
- package/android/generated/jni/ScanditReactNativeDatacaptureParserSpec-generated.cpp +40 -0
- package/android/generated/jni/ScanditReactNativeDatacaptureParserSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/ScanditReactNativeDatacaptureParserSpec/ScanditReactNativeDatacaptureParserSpecJSI-generated.cpp +33 -0
- package/android/generated/jni/react/renderer/components/ScanditReactNativeDatacaptureParserSpec/ScanditReactNativeDatacaptureParserSpecJSI.h +151 -0
- package/android/src/main/kotlin/com/scandit/datacapture/reactnative/parser/{ScanditDataCaptureParserModule.kt → ScanditDataCaptureParserModuleBase.kt} +8 -25
- package/android/src/main/newArch/kotlin/com/scandit/datacapture/reactnative/parser/ScanditDataCaptureParserModule.kt +42 -0
- package/android/src/main/oldArch/kotlin/com/scandit/datacapture/reactnative/parser/ScanditDataCaptureParserModule.kt +54 -0
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/ios/Sources/NewArch/ScanditDataCaptureParser.mm +83 -0
- package/ios/Sources/OldArch/ScanditDataCaptureParser.mm +71 -0
- package/ios/Sources/ScanditDataCaptureParser.h +29 -0
- package/ios/Sources/ScanditDataCaptureParser.swift +41 -21
- package/ios/generated/ScanditReactNativeDatacaptureParserSpec/ScanditReactNativeDatacaptureParserSpec-generated.mm +53 -0
- package/ios/generated/ScanditReactNativeDatacaptureParserSpec/ScanditReactNativeDatacaptureParserSpec.h +103 -0
- package/ios/generated/ScanditReactNativeDatacaptureParserSpecJSI-generated.cpp +33 -0
- package/ios/generated/ScanditReactNativeDatacaptureParserSpecJSI.h +151 -0
- package/package.json +24 -11
- package/react-native.config.js +12 -0
- package/scandit-react-native-datacapture-parser.podspec +17 -31
- package/specs/NativeScanditDataCaptureParser.ts +28 -0
- package/ios/Sources/ScanditDataCaptureParser.m +0 -15
package/THIRD_PARTY.txt
CHANGED
|
@@ -211,7 +211,6 @@ includes components licensed under the following licenses:
|
|
|
211
211
|
|
|
212
212
|
|
|
213
213
|
Copyright (c) 2017-2022 Arm Limited
|
|
214
|
-
Copyright (c) 2007-2010 Baptiste Lepilleur
|
|
215
214
|
Copyright (c) 2013-2022 Niels Lohmann
|
|
216
215
|
Copyright (c) 2008-2018 The Khronos Group Inc.
|
|
217
216
|
|
|
@@ -284,6 +283,7 @@ includes components licensed under the following licenses:
|
|
|
284
283
|
|
|
285
284
|
================================================================================
|
|
286
285
|
|
|
286
|
+
|
|
287
287
|
Copyright (c) 2017 Ollix
|
|
288
288
|
|
|
289
289
|
Permission is hereby granted, free of charge, to any person
|
package/android/build.gradle
CHANGED
|
@@ -3,6 +3,14 @@ import com.android.Version
|
|
|
3
3
|
apply plugin: "com.android.library"
|
|
4
4
|
apply plugin: "kotlin-android"
|
|
5
5
|
|
|
6
|
+
def isNewArchitectureEnabled() {
|
|
7
|
+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (isNewArchitectureEnabled()) {
|
|
11
|
+
apply plugin: "com.facebook.react"
|
|
12
|
+
}
|
|
13
|
+
|
|
6
14
|
static def supportsNamespace() {
|
|
7
15
|
def parsed = Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
8
16
|
def major = parsed[0].toInteger()
|
|
@@ -51,6 +59,20 @@ android {
|
|
|
51
59
|
|
|
52
60
|
compileSdkVersion safeExtGet("compileSdkVersion", 33)
|
|
53
61
|
|
|
62
|
+
sourceSets {
|
|
63
|
+
main {
|
|
64
|
+
if (supportsNamespace()) {
|
|
65
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml" // no package on it
|
|
66
|
+
}
|
|
67
|
+
if (isNewArchitectureEnabled()) {
|
|
68
|
+
kotlin.srcDirs += ['src/main/newArch/kotlin']
|
|
69
|
+
java.srcDirs += ['generated/java']
|
|
70
|
+
} else {
|
|
71
|
+
kotlin.srcDirs += ['src/main/oldArch/kotlin']
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
54
76
|
defaultConfig {
|
|
55
77
|
minSdkVersion safeExtGet("minSdkVersion", 24)
|
|
56
78
|
targetSdkVersion safeExtGet("targetSdkVersion", 33)
|
|
@@ -63,12 +85,18 @@ android {
|
|
|
63
85
|
}
|
|
64
86
|
}
|
|
65
87
|
|
|
88
|
+
if (isNewArchitectureEnabled()) {
|
|
89
|
+
react {
|
|
90
|
+
codegenJavaPackageName = "com.scandit.datacapture.reactnative.parser"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
66
94
|
if (file( "${rootProject.projectDir}/build-test.gradle").exists()) {
|
|
67
95
|
apply from: "${rootProject.projectDir}/build-test.gradle"
|
|
68
96
|
}
|
|
69
97
|
|
|
70
98
|
dependencies {
|
|
71
|
-
def sdk_version = "8.
|
|
99
|
+
def sdk_version = "8.3.0-beta.1"
|
|
72
100
|
|
|
73
101
|
println("Version of the native sdk used in this build: ${safeExtGet('global_sdk_version', sdk_version)}")
|
|
74
102
|
api project(path: ':scandit-react-native-datacapture-core')
|
package/android/generated/java/com/facebook/fbreact/specs/NativeScanditDataCaptureParserSpec.java
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJavaSpec.js
|
|
9
|
+
*
|
|
10
|
+
* @nolint
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
package com.facebook.fbreact.specs;
|
|
14
|
+
|
|
15
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
16
|
+
import com.facebook.react.bridge.Promise;
|
|
17
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
18
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
19
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
20
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
21
|
+
import com.facebook.react.common.build.ReactBuildConfig;
|
|
22
|
+
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
|
23
|
+
import java.util.Arrays;
|
|
24
|
+
import java.util.HashSet;
|
|
25
|
+
import java.util.Map;
|
|
26
|
+
import java.util.Set;
|
|
27
|
+
import javax.annotation.Nonnull;
|
|
28
|
+
import javax.annotation.Nullable;
|
|
29
|
+
|
|
30
|
+
public abstract class NativeScanditDataCaptureParserSpec extends ReactContextBaseJavaModule implements TurboModule {
|
|
31
|
+
public static final String NAME = "ScanditDataCaptureParser";
|
|
32
|
+
|
|
33
|
+
public NativeScanditDataCaptureParserSpec(ReactApplicationContext reactContext) {
|
|
34
|
+
super(reactContext);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@Override
|
|
38
|
+
public @Nonnull String getName() {
|
|
39
|
+
return NAME;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
protected final void emitOnScanditEvent(ReadableMap value) {
|
|
43
|
+
mEventEmitterCallback.invoke("onScanditEvent", value);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
protected abstract Map<String, Object> getTypedExportedConstants();
|
|
47
|
+
|
|
48
|
+
@Override
|
|
49
|
+
@DoNotStrip
|
|
50
|
+
public final @Nullable Map<String, Object> getConstants() {
|
|
51
|
+
Map<String, Object> constants = getTypedExportedConstants();
|
|
52
|
+
if (ReactBuildConfig.DEBUG || ReactBuildConfig.IS_INTERNAL_BUILD) {
|
|
53
|
+
Set<String> obligatoryFlowConstants = new HashSet<>(Arrays.asList(
|
|
54
|
+
"Defaults"
|
|
55
|
+
));
|
|
56
|
+
Set<String> optionalFlowConstants = new HashSet<>();
|
|
57
|
+
Set<String> undeclaredConstants = new HashSet<>(constants.keySet());
|
|
58
|
+
undeclaredConstants.removeAll(obligatoryFlowConstants);
|
|
59
|
+
undeclaredConstants.removeAll(optionalFlowConstants);
|
|
60
|
+
if (!undeclaredConstants.isEmpty()) {
|
|
61
|
+
throw new IllegalStateException(String.format("Native Module Flow doesn't declare constants: %s", undeclaredConstants));
|
|
62
|
+
}
|
|
63
|
+
undeclaredConstants = obligatoryFlowConstants;
|
|
64
|
+
undeclaredConstants.removeAll(constants.keySet());
|
|
65
|
+
if (!undeclaredConstants.isEmpty()) {
|
|
66
|
+
throw new IllegalStateException(String.format("Native Module doesn't fill in constants: %s", undeclaredConstants));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return constants;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@ReactMethod
|
|
73
|
+
@DoNotStrip
|
|
74
|
+
public abstract void executeParser(ReadableMap data, Promise promise);
|
|
75
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
cmake_minimum_required(VERSION 3.13)
|
|
7
|
+
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
8
|
+
|
|
9
|
+
file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/ScanditReactNativeDatacaptureParserSpec/*.cpp)
|
|
10
|
+
|
|
11
|
+
add_library(
|
|
12
|
+
react_codegen_ScanditReactNativeDatacaptureParserSpec
|
|
13
|
+
OBJECT
|
|
14
|
+
${react_codegen_SRCS}
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
target_include_directories(react_codegen_ScanditReactNativeDatacaptureParserSpec PUBLIC . react/renderer/components/ScanditReactNativeDatacaptureParserSpec)
|
|
18
|
+
|
|
19
|
+
target_link_libraries(
|
|
20
|
+
react_codegen_ScanditReactNativeDatacaptureParserSpec
|
|
21
|
+
fbjni
|
|
22
|
+
jsi
|
|
23
|
+
# We need to link different libraries based on whether we are building rncore or not, that's necessary
|
|
24
|
+
# because we want to break a circular dependency between react_codegen_rncore and reactnative
|
|
25
|
+
reactnative
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
target_compile_reactnative_options(react_codegen_ScanditReactNativeDatacaptureParserSpec PRIVATE)
|
|
29
|
+
target_compile_options(react_codegen_ScanditReactNativeDatacaptureParserSpec PRIVATE -Wno-deprecated-declarations)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJniCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "ScanditReactNativeDatacaptureParserSpec.h"
|
|
12
|
+
|
|
13
|
+
namespace facebook::react {
|
|
14
|
+
|
|
15
|
+
static facebook::jsi::Value __hostFunction_NativeScanditDataCaptureParserSpecJSI_getConstants(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
16
|
+
static jmethodID cachedMethodId = nullptr;
|
|
17
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, ObjectKind, "getConstants", "()Ljava/util/Map;", args, count, cachedMethodId);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static facebook::jsi::Value __hostFunction_NativeScanditDataCaptureParserSpecJSI_executeParser(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
21
|
+
static jmethodID cachedMethodId = nullptr;
|
|
22
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "executeParser", "(Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
NativeScanditDataCaptureParserSpecJSI::NativeScanditDataCaptureParserSpecJSI(const JavaTurboModule::InitParams ¶ms)
|
|
26
|
+
: JavaTurboModule(params) {
|
|
27
|
+
methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativeScanditDataCaptureParserSpecJSI_getConstants};
|
|
28
|
+
methodMap_["executeParser"] = MethodMetadata {1, __hostFunction_NativeScanditDataCaptureParserSpecJSI_executeParser};
|
|
29
|
+
eventEmitterMap_["onScanditEvent"] = std::make_shared<AsyncEventEmitter<folly::dynamic>>();
|
|
30
|
+
setEventEmitterCallback(params.instance);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
std::shared_ptr<TurboModule> ScanditReactNativeDatacaptureParserSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) {
|
|
34
|
+
if (moduleName == "ScanditDataCaptureParser") {
|
|
35
|
+
return std::make_shared<NativeScanditDataCaptureParserSpecJSI>(params);
|
|
36
|
+
}
|
|
37
|
+
return nullptr;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJniH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include <ReactCommon/JavaTurboModule.h>
|
|
14
|
+
#include <ReactCommon/TurboModule.h>
|
|
15
|
+
#include <jsi/jsi.h>
|
|
16
|
+
|
|
17
|
+
namespace facebook::react {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* JNI C++ class for module 'NativeScanditDataCaptureParser'
|
|
21
|
+
*/
|
|
22
|
+
class JSI_EXPORT NativeScanditDataCaptureParserSpecJSI : public JavaTurboModule {
|
|
23
|
+
public:
|
|
24
|
+
NativeScanditDataCaptureParserSpecJSI(const JavaTurboModule::InitParams ¶ms);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
JSI_EXPORT
|
|
29
|
+
std::shared_ptr<TurboModule> ScanditReactNativeDatacaptureParserSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms);
|
|
30
|
+
|
|
31
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include "ScanditReactNativeDatacaptureParserSpecJSI.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
static jsi::Value __hostFunction_NativeScanditDataCaptureParserCxxSpecJSI_getConstants(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
15
|
+
return static_cast<NativeScanditDataCaptureParserCxxSpecJSI *>(&turboModule)->getConstants(
|
|
16
|
+
rt
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
static jsi::Value __hostFunction_NativeScanditDataCaptureParserCxxSpecJSI_executeParser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
20
|
+
return static_cast<NativeScanditDataCaptureParserCxxSpecJSI *>(&turboModule)->executeParser(
|
|
21
|
+
rt,
|
|
22
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asObject(rt)
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
NativeScanditDataCaptureParserCxxSpecJSI::NativeScanditDataCaptureParserCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
|
27
|
+
: TurboModule("ScanditDataCaptureParser", jsInvoker) {
|
|
28
|
+
methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativeScanditDataCaptureParserCxxSpecJSI_getConstants};
|
|
29
|
+
methodMap_["executeParser"] = MethodMetadata {1, __hostFunction_NativeScanditDataCaptureParserCxxSpecJSI_executeParser};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <ReactCommon/TurboModule.h>
|
|
13
|
+
#include <react/bridging/Bridging.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
#pragma mark - NativeScanditDataCaptureParserScanditEventPayload
|
|
20
|
+
|
|
21
|
+
template <typename P0, typename P1, typename P2, typename P3>
|
|
22
|
+
struct NativeScanditDataCaptureParserScanditEventPayload {
|
|
23
|
+
P0 name;
|
|
24
|
+
P1 data;
|
|
25
|
+
P2 viewId;
|
|
26
|
+
P3 modeId;
|
|
27
|
+
bool operator==(const NativeScanditDataCaptureParserScanditEventPayload &other) const {
|
|
28
|
+
return name == other.name && data == other.data && viewId == other.viewId && modeId == other.modeId;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
template <typename T>
|
|
33
|
+
struct NativeScanditDataCaptureParserScanditEventPayloadBridging {
|
|
34
|
+
static T types;
|
|
35
|
+
|
|
36
|
+
static T fromJs(
|
|
37
|
+
jsi::Runtime &rt,
|
|
38
|
+
const jsi::Object &value,
|
|
39
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
40
|
+
T result{
|
|
41
|
+
bridging::fromJs<decltype(types.name)>(rt, value.getProperty(rt, "name"), jsInvoker),
|
|
42
|
+
bridging::fromJs<decltype(types.data)>(rt, value.getProperty(rt, "data"), jsInvoker),
|
|
43
|
+
bridging::fromJs<decltype(types.viewId)>(rt, value.getProperty(rt, "viewId"), jsInvoker),
|
|
44
|
+
bridging::fromJs<decltype(types.modeId)>(rt, value.getProperty(rt, "modeId"), jsInvoker)};
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#ifdef DEBUG
|
|
49
|
+
static jsi::String nameToJs(jsi::Runtime &rt, decltype(types.name) value) {
|
|
50
|
+
return bridging::toJs(rt, value);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static jsi::String dataToJs(jsi::Runtime &rt, decltype(types.data) value) {
|
|
54
|
+
return bridging::toJs(rt, value);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static double viewIdToJs(jsi::Runtime &rt, decltype(types.viewId) value) {
|
|
58
|
+
return bridging::toJs(rt, value);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static double modeIdToJs(jsi::Runtime &rt, decltype(types.modeId) value) {
|
|
62
|
+
return bridging::toJs(rt, value);
|
|
63
|
+
}
|
|
64
|
+
#endif
|
|
65
|
+
|
|
66
|
+
static jsi::Object toJs(
|
|
67
|
+
jsi::Runtime &rt,
|
|
68
|
+
const T &value,
|
|
69
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
70
|
+
auto result = facebook::jsi::Object(rt);
|
|
71
|
+
result.setProperty(rt, "name", bridging::toJs(rt, value.name, jsInvoker));
|
|
72
|
+
result.setProperty(rt, "data", bridging::toJs(rt, value.data, jsInvoker));
|
|
73
|
+
if (value.viewId) {
|
|
74
|
+
result.setProperty(rt, "viewId", bridging::toJs(rt, value.viewId.value(), jsInvoker));
|
|
75
|
+
}
|
|
76
|
+
if (value.modeId) {
|
|
77
|
+
result.setProperty(rt, "modeId", bridging::toJs(rt, value.modeId.value(), jsInvoker));
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
class JSI_EXPORT NativeScanditDataCaptureParserCxxSpecJSI : public TurboModule {
|
|
84
|
+
protected:
|
|
85
|
+
NativeScanditDataCaptureParserCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
|
|
86
|
+
|
|
87
|
+
public:
|
|
88
|
+
virtual jsi::Object getConstants(jsi::Runtime &rt) = 0;
|
|
89
|
+
virtual jsi::Value executeParser(jsi::Runtime &rt, jsi::Object data) = 0;
|
|
90
|
+
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
template <typename T>
|
|
94
|
+
class JSI_EXPORT NativeScanditDataCaptureParserCxxSpec : public TurboModule {
|
|
95
|
+
public:
|
|
96
|
+
jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
|
|
97
|
+
return delegate_.create(rt, propName);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
|
|
101
|
+
return delegate_.getPropertyNames(runtime);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static constexpr std::string_view kModuleName = "ScanditDataCaptureParser";
|
|
105
|
+
|
|
106
|
+
protected:
|
|
107
|
+
NativeScanditDataCaptureParserCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
|
|
108
|
+
: TurboModule(std::string{NativeScanditDataCaptureParserCxxSpec::kModuleName}, jsInvoker),
|
|
109
|
+
delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
|
|
110
|
+
|
|
111
|
+
template <typename OnScanditEventType> void emitOnScanditEvent(OnScanditEventType value) {
|
|
112
|
+
static_assert(bridging::supportsFromJs<OnScanditEventType, jsi::Object>, "value cannnot be converted to jsi::Object");
|
|
113
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*delegate_.eventEmitterMap_["onScanditEvent"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
114
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private:
|
|
119
|
+
class Delegate : public NativeScanditDataCaptureParserCxxSpecJSI {
|
|
120
|
+
public:
|
|
121
|
+
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
|
|
122
|
+
NativeScanditDataCaptureParserCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
|
|
123
|
+
eventEmitterMap_["onScanditEvent"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
jsi::Object getConstants(jsi::Runtime &rt) override {
|
|
127
|
+
static_assert(
|
|
128
|
+
bridging::getParameterCount(&T::getConstants) == 1,
|
|
129
|
+
"Expected getConstants(...) to have 1 parameters");
|
|
130
|
+
|
|
131
|
+
return bridging::callFromJs<jsi::Object>(
|
|
132
|
+
rt, &T::getConstants, jsInvoker_, instance_);
|
|
133
|
+
}
|
|
134
|
+
jsi::Value executeParser(jsi::Runtime &rt, jsi::Object data) override {
|
|
135
|
+
static_assert(
|
|
136
|
+
bridging::getParameterCount(&T::executeParser) == 2,
|
|
137
|
+
"Expected executeParser(...) to have 2 parameters");
|
|
138
|
+
|
|
139
|
+
return bridging::callFromJs<jsi::Value>(
|
|
140
|
+
rt, &T::executeParser, jsInvoker_, instance_, std::move(data));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private:
|
|
144
|
+
friend class NativeScanditDataCaptureParserCxxSpec;
|
|
145
|
+
T *instance_;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
Delegate delegate_;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
} // namespace facebook::react
|
|
@@ -8,11 +8,7 @@ package com.scandit.datacapture.reactnative.parser
|
|
|
8
8
|
|
|
9
9
|
import com.facebook.react.bridge.Arguments
|
|
10
10
|
import com.facebook.react.bridge.Promise
|
|
11
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
12
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
13
|
-
import com.facebook.react.bridge.ReactMethod
|
|
14
11
|
import com.facebook.react.bridge.ReadableMap
|
|
15
|
-
import com.facebook.react.module.annotations.ReactModule
|
|
16
12
|
import com.scandit.datacapture.frameworks.core.CoreModule
|
|
17
13
|
import com.scandit.datacapture.frameworks.core.FrameworkModule
|
|
18
14
|
import com.scandit.datacapture.frameworks.core.locator.ServiceLocator
|
|
@@ -20,30 +16,27 @@ import com.scandit.datacapture.frameworks.parser.ParserModule
|
|
|
20
16
|
import com.scandit.datacapture.reactnative.core.utils.ReactNativeMethodCall
|
|
21
17
|
import com.scandit.datacapture.reactnative.core.utils.ReactNativeResult
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Base implementation for the Scandit Data Capture Parser module.
|
|
21
|
+
* Contains all shared business logic used by both old and new architecture modules.
|
|
22
|
+
*/
|
|
23
|
+
class ScanditDataCaptureParserModuleBase(
|
|
26
24
|
private val parserModule: ParserModule,
|
|
27
25
|
private val serviceLocator: ServiceLocator<FrameworkModule>,
|
|
28
|
-
)
|
|
29
|
-
|
|
26
|
+
) {
|
|
30
27
|
companion object {
|
|
31
28
|
const val NAME = "ScanditDataCaptureParser"
|
|
32
29
|
private const val DEFAULTS_KEY = "Defaults"
|
|
33
30
|
}
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
override fun getConstants(): MutableMap<String, Any> = mutableMapOf(
|
|
32
|
+
fun getDefaults(): MutableMap<String, Any> = mutableMapOf(
|
|
38
33
|
DEFAULTS_KEY to Arguments.createMap()
|
|
39
34
|
)
|
|
40
35
|
|
|
41
|
-
|
|
36
|
+
fun onInvalidate() {
|
|
42
37
|
parserModule.onDestroy()
|
|
43
|
-
super.invalidate()
|
|
44
38
|
}
|
|
45
39
|
|
|
46
|
-
@ReactMethod
|
|
47
40
|
fun executeParser(data: ReadableMap, promise: Promise) {
|
|
48
41
|
val coreModule = serviceLocator.resolve(
|
|
49
42
|
CoreModule::class.java.simpleName
|
|
@@ -65,14 +58,4 @@ open class ScanditDataCaptureParserModule(
|
|
|
65
58
|
)
|
|
66
59
|
}
|
|
67
60
|
}
|
|
68
|
-
|
|
69
|
-
@ReactMethod
|
|
70
|
-
fun addListener(@Suppress("UNUSED_PARAMETER") eventName: String?) {
|
|
71
|
-
// Keep: Required for RN built in Event Emitter Calls.
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
@ReactMethod
|
|
75
|
-
fun removeListeners(@Suppress("UNUSED_PARAMETER") count: Int?) {
|
|
76
|
-
// Keep: Required for RN built in Event Emitter Calls.
|
|
77
|
-
}
|
|
78
61
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the Scandit Data Capture SDK
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2020- Scandit AG. All rights reserved.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
package com.scandit.datacapture.reactnative.parser
|
|
8
|
+
|
|
9
|
+
import com.facebook.fbreact.specs.NativeScanditDataCaptureParserSpec
|
|
10
|
+
import com.facebook.react.bridge.Promise
|
|
11
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
12
|
+
import com.facebook.react.bridge.ReadableMap
|
|
13
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
14
|
+
import com.scandit.datacapture.frameworks.core.FrameworkModule
|
|
15
|
+
import com.scandit.datacapture.frameworks.core.locator.ServiceLocator
|
|
16
|
+
import com.scandit.datacapture.frameworks.parser.ParserModule
|
|
17
|
+
|
|
18
|
+
@ReactModule(name = ScanditDataCaptureParserModuleBase.NAME)
|
|
19
|
+
class ScanditDataCaptureParserModule(
|
|
20
|
+
reactContext: ReactApplicationContext,
|
|
21
|
+
parserModule: ParserModule,
|
|
22
|
+
serviceLocator: ServiceLocator<FrameworkModule>,
|
|
23
|
+
) : NativeScanditDataCaptureParserSpec(reactContext) {
|
|
24
|
+
|
|
25
|
+
private val moduleBase = ScanditDataCaptureParserModuleBase(parserModule, serviceLocator)
|
|
26
|
+
|
|
27
|
+
companion object {
|
|
28
|
+
const val NAME = ScanditDataCaptureParserModuleBase.NAME
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
override fun getName(): String = NAME
|
|
32
|
+
|
|
33
|
+
override fun getTypedExportedConstants(): MutableMap<String, Any> = moduleBase.getDefaults()
|
|
34
|
+
|
|
35
|
+
override fun invalidate() {
|
|
36
|
+
moduleBase.onInvalidate()
|
|
37
|
+
super.invalidate()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
override fun executeParser(data: ReadableMap, promise: Promise) =
|
|
41
|
+
moduleBase.executeParser(data, promise)
|
|
42
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the Scandit Data Capture SDK
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2020- Scandit AG. All rights reserved.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
package com.scandit.datacapture.reactnative.parser
|
|
8
|
+
|
|
9
|
+
import com.facebook.react.bridge.Promise
|
|
10
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
11
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
12
|
+
import com.facebook.react.bridge.ReactMethod
|
|
13
|
+
import com.facebook.react.bridge.ReadableMap
|
|
14
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
15
|
+
import com.scandit.datacapture.frameworks.core.FrameworkModule
|
|
16
|
+
import com.scandit.datacapture.frameworks.core.locator.ServiceLocator
|
|
17
|
+
import com.scandit.datacapture.frameworks.parser.ParserModule
|
|
18
|
+
|
|
19
|
+
@ReactModule(name = ScanditDataCaptureParserModuleBase.NAME)
|
|
20
|
+
class ScanditDataCaptureParserModule(
|
|
21
|
+
reactContext: ReactApplicationContext,
|
|
22
|
+
parserModule: ParserModule,
|
|
23
|
+
serviceLocator: ServiceLocator<FrameworkModule>,
|
|
24
|
+
) : ReactContextBaseJavaModule(reactContext) {
|
|
25
|
+
|
|
26
|
+
private val moduleBase = ScanditDataCaptureParserModuleBase(parserModule, serviceLocator)
|
|
27
|
+
|
|
28
|
+
companion object {
|
|
29
|
+
const val NAME = ScanditDataCaptureParserModuleBase.NAME
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
override fun getName(): String = NAME
|
|
33
|
+
|
|
34
|
+
override fun getConstants(): MutableMap<String, Any> = moduleBase.getDefaults()
|
|
35
|
+
|
|
36
|
+
override fun invalidate() {
|
|
37
|
+
moduleBase.onInvalidate()
|
|
38
|
+
super.invalidate()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@ReactMethod
|
|
42
|
+
fun executeParser(data: ReadableMap, promise: Promise) =
|
|
43
|
+
moduleBase.executeParser(data, promise)
|
|
44
|
+
|
|
45
|
+
@ReactMethod
|
|
46
|
+
fun addListener(@Suppress("UNUSED_PARAMETER") eventName: String?) {
|
|
47
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@ReactMethod
|
|
51
|
+
fun removeListeners(@Suppress("UNUSED_PARAMETER") count: Int?) {
|
|
52
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
53
|
+
}
|
|
54
|
+
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../ts/native/ParserNativeCallerProvider.ts","../../ts/native/initProxy.ts","../../ts/index.ts"],"sourcesContent":[null,null,null],"names":[],"mappings":";;;;;MAIa,4BAA4B,CAAA;AACvC,IAAA,eAAe,CAAC,SAA0B,EAAA;QACxC,IAAI,CAAC,uBAAuB,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;AAChD,YAAA,MAAM,IAAI,KAAK,CAAC,2CAA2C,SAAS,CAAA,CAAE,CAAC,CAAC;SACzE;;AAED,QAAA,MAAM,YAAY,GAAG,eAAe,CAAC,0BAA0B,CAAC,CAAC;AACjE,QAAA,OAAO,oBAAoB,CAAC,YAAY,CAAC,CAAC;KAC3C;AACF;;SCVe,eAAe,GAAA;AAC7B,IAAA,qBAAqB,CAAC,IAAI,4BAA4B,EAAE,CAAC,CAAC;AAC5D;;ACFA,eAAe,EAAE"}
|