scandit-react-native-datacapture-parser 8.2.1 → 8.3.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.
Files changed (25) hide show
  1. package/android/build.gradle +29 -1
  2. package/android/generated/java/com/facebook/fbreact/specs/NativeScanditDataCaptureParserSpec.java +75 -0
  3. package/android/generated/jni/CMakeLists.txt +29 -0
  4. package/android/generated/jni/ScanditReactNativeDatacaptureParserSpec-generated.cpp +40 -0
  5. package/android/generated/jni/ScanditReactNativeDatacaptureParserSpec.h +31 -0
  6. package/android/generated/jni/react/renderer/components/ScanditReactNativeDatacaptureParserSpec/ScanditReactNativeDatacaptureParserSpecJSI-generated.cpp +33 -0
  7. package/android/generated/jni/react/renderer/components/ScanditReactNativeDatacaptureParserSpec/ScanditReactNativeDatacaptureParserSpecJSI.h +151 -0
  8. package/android/src/main/kotlin/com/scandit/datacapture/reactnative/parser/{ScanditDataCaptureParserModule.kt → ScanditDataCaptureParserModuleBase.kt} +8 -25
  9. package/android/src/main/newArch/kotlin/com/scandit/datacapture/reactnative/parser/ScanditDataCaptureParserModule.kt +42 -0
  10. package/android/src/main/oldArch/kotlin/com/scandit/datacapture/reactnative/parser/ScanditDataCaptureParserModule.kt +54 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/tsconfig.tsbuildinfo +1 -1
  13. package/ios/Sources/NewArch/ScanditDataCaptureParser.mm +83 -0
  14. package/ios/Sources/OldArch/ScanditDataCaptureParser.mm +71 -0
  15. package/ios/Sources/ScanditDataCaptureParser.h +29 -0
  16. package/ios/Sources/ScanditDataCaptureParser.swift +41 -21
  17. package/ios/generated/ScanditReactNativeDatacaptureParserSpec/ScanditReactNativeDatacaptureParserSpec-generated.mm +53 -0
  18. package/ios/generated/ScanditReactNativeDatacaptureParserSpec/ScanditReactNativeDatacaptureParserSpec.h +103 -0
  19. package/ios/generated/ScanditReactNativeDatacaptureParserSpecJSI-generated.cpp +33 -0
  20. package/ios/generated/ScanditReactNativeDatacaptureParserSpecJSI.h +151 -0
  21. package/package.json +24 -11
  22. package/react-native.config.js +12 -0
  23. package/scandit-react-native-datacapture-parser.podspec +17 -31
  24. package/specs/NativeScanditDataCaptureParser.ts +28 -0
  25. package/ios/Sources/ScanditDataCaptureParser.m +0 -15
@@ -0,0 +1,83 @@
1
+ /*
2
+ * This file is part of the Scandit Data Capture SDK
3
+ *
4
+ * Copyright (C) 2026- Scandit AG. All rights reserved.
5
+ */
6
+
7
+ #import <React/RCTBridgeModule.h>
8
+ #import <React/RCTEventEmitter.h>
9
+ #import <ScanditReactNativeDatacaptureParserSpec/ScanditReactNativeDatacaptureParserSpec.h>
10
+ #import <ReactCommon/RCTTurboModule.h>
11
+ #import "ScanditDataCaptureParser.h"
12
+ #import "ScanditDataCaptureParser-Swift.h"
13
+
14
+ // Forward declare and import the shared method queue from Core module
15
+ // The actual implementation is in ScanditDataCaptureCore Swift module
16
+ @interface SDCSharedMethodQueue : NSObject
17
+ + (dispatch_queue_t)queue;
18
+ @end
19
+
20
+ /// New Architecture (TurboModule) adapter for the Parser native module.
21
+ /// Inherits from the generated spec base class and uses direct method declarations.
22
+ @implementation NativeScanditDataCaptureParser {
23
+ ScanditDataCaptureParserImpl *_impl;
24
+ }
25
+
26
+ RCT_EXPORT_MODULE(ScanditDataCaptureParser)
27
+
28
+ - (instancetype)init {
29
+ if (self = [super init]) {
30
+ _impl = [[ScanditDataCaptureParserImpl alloc] init];
31
+ }
32
+ return self;
33
+ }
34
+
35
+ + (BOOL)requiresMainQueueSetup {
36
+ return YES;
37
+ }
38
+
39
+ - (void)initialize {
40
+ __weak NativeScanditDataCaptureParser *weakSelf = self;
41
+ SDCEventEmitBlock emitterBlock = ^(NSDictionary *_Nonnull payload) {
42
+ __strong NativeScanditDataCaptureParser *strongSelf = weakSelf;
43
+ if (strongSelf) {
44
+ [strongSelf emitOnScanditEvent:payload];
45
+ }
46
+ };
47
+ [_impl setupWith:nil turboEmitter:emitterBlock];
48
+ }
49
+
50
+ - (dispatch_queue_t)methodQueue {
51
+ return [SDCSharedMethodQueue queue];
52
+ }
53
+
54
+ - (NSDictionary *)constantsToExport {
55
+ return [_impl getConstants];
56
+ }
57
+
58
+ - (NSDictionary *)getConstants {
59
+ return [_impl getConstants];
60
+ }
61
+
62
+ - (NSArray<NSString *> *)supportedEvents {
63
+ return [_impl supportedEvents];
64
+ }
65
+
66
+ - (void)invalidate {
67
+ [_impl invalidate];
68
+ }
69
+
70
+ // MARK: - Native Module Methods
71
+
72
+ - (void)executeParser:(NSDictionary *)data
73
+ resolve:(RCTPromiseResolveBlock)resolve
74
+ reject:(RCTPromiseRejectBlock)reject {
75
+ [_impl executeParserWithData:data resolve:resolve reject:reject];
76
+ }
77
+
78
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
79
+ (const facebook::react::ObjCTurboModule::InitParams &)params {
80
+ return std::make_shared<facebook::react::NativeScanditDataCaptureParserSpecJSI>(params);
81
+ }
82
+
83
+ @end
@@ -0,0 +1,71 @@
1
+ /*
2
+ * This file is part of the Scandit Data Capture SDK
3
+ *
4
+ * Copyright (C) 2026- Scandit AG. All rights reserved.
5
+ */
6
+
7
+ #import <React/RCTBridgeModule.h>
8
+ #import <React/RCTEventEmitter.h>
9
+ #import "ScanditDataCaptureParser.h"
10
+ #import "ScanditDataCaptureParser-Swift.h"
11
+
12
+ // Forward declare and import the shared method queue from Core module
13
+ // The actual implementation is in ScanditDataCaptureCore Swift module
14
+ @interface SDCSharedMethodQueue : NSObject
15
+ + (dispatch_queue_t)queue;
16
+ @end
17
+
18
+ /// Old Architecture (Paper/Bridge) adapter for the Parser native module.
19
+ /// Inherits from RCTEventEmitter and exports methods via RCT_EXPORT_METHOD macros.
20
+ @implementation NativeScanditDataCaptureParser {
21
+ ScanditDataCaptureParserImpl *_impl;
22
+ }
23
+
24
+ RCT_EXPORT_MODULE(ScanditDataCaptureParser)
25
+
26
+ - (instancetype)init {
27
+ if (self = [super init]) {
28
+ _impl = [[ScanditDataCaptureParserImpl alloc] init];
29
+ }
30
+ return self;
31
+ }
32
+
33
+ + (BOOL)requiresMainQueueSetup {
34
+ return YES;
35
+ }
36
+
37
+ - (void)initialize {
38
+ [_impl setupWith:self];
39
+ }
40
+
41
+ - (dispatch_queue_t)methodQueue {
42
+ return [SDCSharedMethodQueue queue];
43
+ }
44
+
45
+ - (NSDictionary *)constantsToExport {
46
+ return [_impl getConstants];
47
+ }
48
+
49
+ - (NSDictionary *)getConstants {
50
+ return [_impl getConstants];
51
+ }
52
+
53
+ - (NSArray<NSString *> *)supportedEvents {
54
+ return [_impl supportedEvents];
55
+ }
56
+
57
+ - (void)invalidate {
58
+ [super invalidate];
59
+ [_impl invalidate];
60
+ }
61
+
62
+ // MARK: - Native Module Methods
63
+
64
+ RCT_EXPORT_METHOD(executeParser
65
+ : (NSDictionary *)data resolve
66
+ : (RCTPromiseResolveBlock)resolve reject
67
+ : (RCTPromiseRejectBlock)reject) {
68
+ [_impl executeParserWithData:data resolve:resolve reject:reject];
69
+ }
70
+
71
+ @end
@@ -0,0 +1,29 @@
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
+ #import <Foundation/Foundation.h>
8
+ #import <React/RCTEventEmitter.h>
9
+
10
+ // Block type for TurboModule event emission (Swift interop)
11
+ // Defined unconditionally for Swift header generation, used only in new arch
12
+ typedef void (^SDCEventEmitBlock)(NSDictionary *_Nonnull payload);
13
+
14
+ #ifdef RCT_NEW_ARCH_ENABLED
15
+ #import <ScanditReactNativeDatacaptureParserSpec/ScanditReactNativeDatacaptureParserSpec.h>
16
+ #import <React/RCTInitializing.h>
17
+ #import <React/RCTInvalidating.h>
18
+ #endif
19
+
20
+ /// Obj-C++ adapter class that conforms to TurboModule spec and delegates to Swift implementation.
21
+ /// Following the Adapter Pattern from React Native's TurboModule Swift guide.
22
+ #ifdef RCT_NEW_ARCH_ENABLED
23
+ @interface NativeScanditDataCaptureParser
24
+ : NativeScanditDataCaptureParserSpecBase <NativeScanditDataCaptureParserSpec, RCTInitializing,
25
+ RCTInvalidating>
26
+ #else
27
+ @interface NativeScanditDataCaptureParser : RCTEventEmitter <RCTBridgeModule>
28
+ #endif
29
+ @end
@@ -9,39 +9,64 @@ import ScanditDataCaptureCore
9
9
  import ScanditFrameworksCore
10
10
  import ScanditFrameworksParser
11
11
 
12
- @objc(ScanditDataCaptureParser)
13
- class ScanditDataCaptureParser: RCTEventEmitter {
14
- var parserModule: ParserModule
12
+ /// Swift implementation for the Parser native module.
13
+ /// This class contains all business logic and is used by the Obj-C++ adapter (NativeScanditDataCaptureParser).
14
+ /// Following the Adapter Pattern from React Native's TurboModule Swift guide.
15
+ @objcMembers
16
+ public class ScanditDataCaptureParserImpl: NSObject {
17
+ var parserModule: ParserModule!
15
18
 
16
- override init() {
17
- parserModule = ParserModule()
19
+ /// Reference to the RCTEventEmitter adapter.
20
+ weak var emitter: RCTEventEmitter?
21
+
22
+ public override init() {
18
23
  super.init()
19
- parserModule.didStart()
20
24
  }
21
25
 
22
- @objc override class func requiresMainQueueSetup() -> Bool {
23
- true
26
+ /// Called by the Obj-C++ adapter to set up the emitter reference and initialize modules.
27
+ public func setup(with emitter: RCTEventEmitter) {
28
+ self.emitter = emitter
29
+ initializeModules()
30
+ }
31
+
32
+ /// Called by the Obj-C++ adapter to set up the emitter reference and initialize modules (new architecture).
33
+ /// - Parameters:
34
+ /// - emitter: The RCTEventEmitter (nil in new arch since we don't inherit from RCTEventEmitter).
35
+ /// - turboEmitter: TurboModule emitter block for new architecture.
36
+ @objc(setupWith:turboEmitter:)
37
+ public func setup(with emitter: RCTEventEmitter?, turboEmitter: SDCEventEmitBlock?) {
38
+ self.emitter = emitter
39
+ guard
40
+ let reactEmitter = ScanditDataCaptureCore.ReactNativeEmitterFactory.create(
41
+ emitter: emitter,
42
+ turboEmitter: turboEmitter
43
+ )
44
+ else {
45
+ fatalError("Failed to create ReactNativeEmitter")
46
+ }
47
+ initializeModules()
24
48
  }
25
49
 
26
- @objc override var methodQueue: DispatchQueue! {
27
- sdcSharedMethodQueue
50
+ private func initializeModules() {
51
+ // Note: ParserModule doesn't emit events
52
+ parserModule = ParserModule()
53
+ parserModule.didStart()
54
+
28
55
  }
29
56
 
30
- override func supportedEvents() -> [String]! {
57
+ public func supportedEvents() -> [String] {
31
58
  []
32
59
  }
33
60
 
34
- override func constantsToExport() -> [AnyHashable: Any]! {
61
+ public func getConstants() -> [AnyHashable: Any] {
35
62
  [:]
36
63
  }
37
64
 
38
- @objc(executeParser:resolve:reject:)
39
- func executeParser(
65
+ public func executeParser(
40
66
  data: [String: Any],
41
67
  resolve: @escaping RCTPromiseResolveBlock,
42
68
  reject: @escaping RCTPromiseRejectBlock
43
69
  ) {
44
-
45
70
  let coreModuleName = String(describing: CoreModule.self)
46
71
  guard let coreModule = DefaultServiceLocator.shared.resolve(clazzName: coreModuleName) as? CoreModule else {
47
72
  reject("-1", "Unable to retrieve the CoreModule from the locator.", nil)
@@ -61,12 +86,7 @@ class ScanditDataCaptureParser: RCTEventEmitter {
61
86
  }
62
87
  }
63
88
 
64
- @objc override func invalidate() {
89
+ public func invalidate() {
65
90
  parserModule.didStop()
66
- super.invalidate()
67
- }
68
-
69
- deinit {
70
- invalidate()
71
91
  }
72
92
  }
@@ -0,0 +1,53 @@
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: GenerateModuleObjCpp
8
+ *
9
+ * We create an umbrella header (and corresponding implementation) here since
10
+ * Cxx compilation in BUCK has a limitation: source-code producing genrule()s
11
+ * must have a single output. More files => more genrule()s => slower builds.
12
+ */
13
+
14
+ #import "ScanditReactNativeDatacaptureParserSpec.h"
15
+
16
+
17
+ @implementation NativeScanditDataCaptureParserSpecBase
18
+ - (void)emitOnScanditEvent:(NSDictionary *)value
19
+ {
20
+ _eventEmitterCallback("onScanditEvent", value);
21
+ }
22
+
23
+ - (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper
24
+ {
25
+ _eventEmitterCallback = std::move(eventEmitterCallbackWrapper->_eventEmitterCallback);
26
+ }
27
+ @end
28
+
29
+
30
+ namespace facebook::react {
31
+
32
+ static facebook::jsi::Value __hostFunction_NativeScanditDataCaptureParserSpecJSI_executeParser(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
33
+ return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "executeParser", @selector(executeParser:resolve:reject:), args, count);
34
+ }
35
+
36
+ static facebook::jsi::Value __hostFunction_NativeScanditDataCaptureParserSpecJSI_getConstants(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
37
+ return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, ObjectKind, "getConstants", @selector(getConstants), args, count);
38
+ }
39
+
40
+ NativeScanditDataCaptureParserSpecJSI::NativeScanditDataCaptureParserSpecJSI(const ObjCTurboModule::InitParams &params)
41
+ : ObjCTurboModule(params) {
42
+
43
+ methodMap_["executeParser"] = MethodMetadata {1, __hostFunction_NativeScanditDataCaptureParserSpecJSI_executeParser};
44
+
45
+
46
+ methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativeScanditDataCaptureParserSpecJSI_getConstants};
47
+
48
+ eventEmitterMap_["onScanditEvent"] = std::make_shared<AsyncEventEmitter<id>>();
49
+ setEventEmitterCallback([&](const std::string &name, id value) {
50
+ static_cast<AsyncEventEmitter<id> &>(*eventEmitterMap_[name]).emit(value);
51
+ });
52
+ }
53
+ } // namespace facebook::react
@@ -0,0 +1,103 @@
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: GenerateModuleObjCpp
8
+ *
9
+ * We create an umbrella header (and corresponding implementation) here since
10
+ * Cxx compilation in BUCK has a limitation: source-code producing genrule()s
11
+ * must have a single output. More files => more genrule()s => slower builds.
12
+ */
13
+
14
+ #ifndef __cplusplus
15
+ #error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
16
+ #endif
17
+
18
+ // Avoid multiple includes of ScanditReactNativeDatacaptureParserSpec symbols
19
+ #ifndef ScanditReactNativeDatacaptureParserSpec_H
20
+ #define ScanditReactNativeDatacaptureParserSpec_H
21
+
22
+ #import <Foundation/Foundation.h>
23
+ #import <RCTRequired/RCTRequired.h>
24
+ #import <RCTTypeSafety/RCTConvertHelpers.h>
25
+ #import <RCTTypeSafety/RCTTypedModuleConstants.h>
26
+ #import <React/RCTBridgeModule.h>
27
+ #import <React/RCTCxxConvert.h>
28
+ #import <React/RCTManagedPointer.h>
29
+ #import <ReactCommon/RCTTurboModule.h>
30
+ #import <optional>
31
+ #import <vector>
32
+
33
+
34
+ NS_ASSUME_NONNULL_BEGIN
35
+ namespace JS {
36
+ namespace NativeScanditDataCaptureParser {
37
+ struct Constants {
38
+
39
+ struct Builder {
40
+ // Backwards compat for RCTTypedModuleConstants
41
+ using ResultT = Constants;
42
+
43
+ struct Input {
44
+ RCTRequired<id<NSObject>> Defaults;
45
+ };
46
+
47
+ /** Initialize with a set of values */
48
+ Builder(const Input i);
49
+ /** Initialize with an existing Constants */
50
+ Builder(Constants i);
51
+ /** Builds the object. Generally used only by the infrastructure. */
52
+ NSDictionary *buildUnsafeRawValue() const { return _factory(); };
53
+ private:
54
+ NSDictionary *(^_factory)(void);
55
+ };
56
+
57
+ static Constants fromUnsafeRawValue(NSDictionary *const v) { return {v}; }
58
+ NSDictionary *unsafeRawValue() const { return _v; }
59
+ private:
60
+ Constants(NSDictionary *const v) : _v(v) {}
61
+ NSDictionary *_v;
62
+ };
63
+ }
64
+ }
65
+ @protocol NativeScanditDataCaptureParserSpec <RCTBridgeModule, RCTTurboModule>
66
+
67
+ - (void)executeParser:(NSDictionary *)data
68
+ resolve:(RCTPromiseResolveBlock)resolve
69
+ reject:(RCTPromiseRejectBlock)reject;
70
+ - (facebook::react::ModuleConstants<JS::NativeScanditDataCaptureParser::Constants::Builder>)constantsToExport;
71
+ - (facebook::react::ModuleConstants<JS::NativeScanditDataCaptureParser::Constants::Builder>)getConstants;
72
+
73
+ @end
74
+
75
+ @interface NativeScanditDataCaptureParserSpecBase : NSObject {
76
+ @protected
77
+ facebook::react::EventEmitterCallback _eventEmitterCallback;
78
+ }
79
+ - (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper;
80
+
81
+ - (void)emitOnScanditEvent:(NSDictionary *)value;
82
+ @end
83
+
84
+ namespace facebook::react {
85
+ /**
86
+ * ObjC++ class for module 'NativeScanditDataCaptureParser'
87
+ */
88
+ class JSI_EXPORT NativeScanditDataCaptureParserSpecJSI : public ObjCTurboModule {
89
+ public:
90
+ NativeScanditDataCaptureParserSpecJSI(const ObjCTurboModule::InitParams &params);
91
+ };
92
+ } // namespace facebook::react
93
+ inline JS::NativeScanditDataCaptureParser::Constants::Builder::Builder(const Input i) : _factory(^{
94
+ NSMutableDictionary *d = [NSMutableDictionary new];
95
+ auto Defaults = i.Defaults.get();
96
+ d[@"Defaults"] = Defaults;
97
+ return d;
98
+ }) {}
99
+ inline JS::NativeScanditDataCaptureParser::Constants::Builder::Builder(Constants i) : _factory(^{
100
+ return i.unsafeRawValue();
101
+ }) {}
102
+ NS_ASSUME_NONNULL_END
103
+ #endif // ScanditReactNativeDatacaptureParserSpec_H
@@ -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
package/package.json CHANGED
@@ -1,18 +1,16 @@
1
1
  {
2
2
  "name": "scandit-react-native-datacapture-parser",
3
- "version": "8.2.1",
3
+ "version": "8.3.0",
4
4
  "description": "Scandit Data Capture SDK for React Native",
5
5
  "homepage": "https://github.com/Scandit/scandit-react-native-datacapture-parser",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/dts/index.d.ts",
8
8
  "flow": "dist/index.js.flow",
9
9
  "scripts": {
10
- "test": "pnpm run lint",
11
- "lint": "eslint --debug ts",
12
- "build": "pnpm run rollup && pnpm run generate-flow",
13
- "rollup": "rollup -c rollup.config.js --bundleConfigAsCjs",
10
+ "build": "rollup -c ../../rollup.config.js --bundleConfigAsCjs",
14
11
  "generate-flow": "flowgen dist/dts/index.d.ts -o dist/index.js.flow",
15
- "start": "pnpm build -- --watch"
12
+ "test": "pnpm run lint",
13
+ "lint": "eslint ts"
16
14
  },
17
15
  "keywords": [
18
16
  "scandit",
@@ -33,13 +31,28 @@
33
31
  "@rollup/plugin-typescript": "11.1.3",
34
32
  "flowgen": "^1.21.0",
35
33
  "rollup": "3.29.2",
36
- "rollup-plugin-modify": "3.0.0",
37
34
  "typescript": "4.9.5"
38
35
  },
39
36
  "dependencies": {
40
- "scandit-datacapture-frameworks-core": "8.2.1",
41
- "scandit-datacapture-frameworks-parser": "8.2.1",
42
- "scandit-react-native-datacapture-core": "8.2.1"
37
+ "scandit-datacapture-frameworks-core": "8.3.0",
38
+ "scandit-datacapture-frameworks-parser": "8.3.0",
39
+ "scandit-react-native-datacapture-core": "8.3.0"
43
40
  },
44
- "packageManager": "pnpm@10.15.0"
41
+ "packageManager": "pnpm@10.15.0",
42
+ "codegenConfig": {
43
+ "name": "ScanditReactNativeDatacaptureParserSpec",
44
+ "type": "modules",
45
+ "jsSrcsDir": "specs",
46
+ "outputDir": {
47
+ "ios": "ios/generated",
48
+ "android": "android/generated"
49
+ },
50
+ "includesGeneratedCode": true,
51
+ "android": {
52
+ "javaPackageName": "com.scandit.datacapture.reactnative.parser"
53
+ },
54
+ "ios": {
55
+ "unstableRequiresMainQueueSetup": true
56
+ }
57
+ }
45
58
  }