scandit-react-native-datacapture-id 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.
Files changed (29) hide show
  1. package/THIRD_PARTY.txt +1 -1
  2. package/android/build.gradle +29 -1
  3. package/android/generated/java/com/facebook/fbreact/specs/NativeScanditDataCaptureIdSpec.java +75 -0
  4. package/android/generated/jni/CMakeLists.txt +29 -0
  5. package/android/generated/jni/ScanditReactNativeDatacaptureIdSpec-generated.cpp +40 -0
  6. package/android/generated/jni/ScanditReactNativeDatacaptureIdSpec.h +31 -0
  7. package/android/generated/jni/react/renderer/components/ScanditReactNativeDatacaptureIdSpec/ScanditReactNativeDatacaptureIdSpecJSI-generated.cpp +33 -0
  8. package/android/generated/jni/react/renderer/components/ScanditReactNativeDatacaptureIdSpec/ScanditReactNativeDatacaptureIdSpecJSI.h +151 -0
  9. package/android/src/main/kotlin/com/scandit/datacapture/reactnative/id/{ScanditDataCaptureIdModule.kt → ScanditDataCaptureIdModuleBase.kt} +14 -31
  10. package/android/src/main/kotlin/com/scandit/datacapture/reactnative/id/ScanditDataCaptureIdPackage.kt +2 -15
  11. package/android/src/main/newArch/kotlin/com/scandit/datacapture/reactnative/id/ScanditDataCaptureIdModule.kt +53 -0
  12. package/android/src/main/oldArch/kotlin/com/scandit/datacapture/reactnative/id/ScanditDataCaptureIdModule.kt +63 -0
  13. package/dist/id.js +26 -12
  14. package/dist/id.js.map +1 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/tsconfig.tsbuildinfo +1 -1
  17. package/ios/Sources/NewArch/ScanditDataCaptureId.mm +95 -0
  18. package/ios/Sources/OldArch/ScanditDataCaptureId.mm +83 -0
  19. package/ios/Sources/ScanditDataCaptureId.h +25 -0
  20. package/ios/Sources/ScanditDataCaptureId.swift +51 -26
  21. package/ios/generated/ScanditReactNativeDatacaptureIdSpec/ScanditReactNativeDatacaptureIdSpec-generated.mm +53 -0
  22. package/ios/generated/ScanditReactNativeDatacaptureIdSpec/ScanditReactNativeDatacaptureIdSpec.h +103 -0
  23. package/ios/generated/ScanditReactNativeDatacaptureIdSpecJSI-generated.cpp +33 -0
  24. package/ios/generated/ScanditReactNativeDatacaptureIdSpecJSI.h +151 -0
  25. package/package.json +24 -11
  26. package/react-native.config.js +12 -0
  27. package/scandit-react-native-datacapture-id.podspec +17 -30
  28. package/specs/NativeScanditDataCaptureId.ts +29 -0
  29. package/ios/Sources/ScanditDataCaptureId.m +0 -9
@@ -0,0 +1,95 @@
1
+ /*
2
+ * This file is part of the Scandit Data Capture SDK
3
+ *
4
+ * Copyright (C) 2021- Scandit AG. All rights reserved.
5
+ */
6
+
7
+ #import <React/RCTEventEmitter.h>
8
+ #import <React/RCTBridgeModule.h>
9
+ #import <ScanditReactNativeDatacaptureIdSpec/ScanditReactNativeDatacaptureIdSpec.h>
10
+ #import <ReactCommon/RCTTurboModule.h>
11
+ #import "ScanditDataCaptureId.h"
12
+ #import "ScanditDataCaptureId-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 Id native module.
21
+ /// Inherits from the generated spec base class and uses direct method declarations.
22
+ @implementation NativeScanditDataCaptureId {
23
+ ScanditDataCaptureIdImpl *_impl;
24
+ }
25
+
26
+ RCT_EXPORT_MODULE(ScanditDataCaptureId)
27
+
28
+ - (instancetype)init {
29
+ if (self = [super init]) {
30
+ _impl = [[ScanditDataCaptureIdImpl alloc] init];
31
+ }
32
+ return self;
33
+ }
34
+
35
+ + (BOOL)requiresMainQueueSetup {
36
+ return YES;
37
+ }
38
+
39
+ - (void)initialize {
40
+ __weak NativeScanditDataCaptureId *weakSelf = self;
41
+ SDCEventEmitBlock emitterBlock = ^(NSDictionary *_Nonnull payload) {
42
+ __strong NativeScanditDataCaptureId *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 [self getConstantsOnMainQueue];
56
+ }
57
+
58
+ - (NSDictionary *)getConstants {
59
+ return [self getConstantsOnMainQueue];
60
+ }
61
+
62
+ - (NSDictionary *)getConstantsOnMainQueue {
63
+ __block NSDictionary *constants;
64
+ if ([NSThread isMainThread]) {
65
+ constants = [_impl getConstants];
66
+ } else {
67
+ dispatch_sync(dispatch_get_main_queue(), ^{
68
+ constants = [_impl getConstants];
69
+ });
70
+ }
71
+ return constants;
72
+ }
73
+
74
+ - (NSArray<NSString *> *)supportedEvents {
75
+ return [_impl supportedEvents];
76
+ }
77
+
78
+ - (void)invalidate {
79
+ [_impl invalidate];
80
+ }
81
+
82
+ // MARK: - Native Module Methods
83
+
84
+ - (void)executeId:(NSDictionary *)data
85
+ resolve:(RCTPromiseResolveBlock)resolve
86
+ reject:(RCTPromiseRejectBlock)reject {
87
+ [_impl executeIdWithData:data resolve:resolve reject:reject];
88
+ }
89
+
90
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
91
+ (const facebook::react::ObjCTurboModule::InitParams &)params {
92
+ return std::make_shared<facebook::react::NativeScanditDataCaptureIdSpecJSI>(params);
93
+ }
94
+
95
+ @end
@@ -0,0 +1,83 @@
1
+ /*
2
+ * This file is part of the Scandit Data Capture SDK
3
+ *
4
+ * Copyright (C) 2021- Scandit AG. All rights reserved.
5
+ */
6
+
7
+ #import <React/RCTEventEmitter.h>
8
+ #import <React/RCTBridgeModule.h>
9
+ #import "ScanditDataCaptureId.h"
10
+ #import "ScanditDataCaptureId-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 Id native module.
19
+ /// Inherits from RCTEventEmitter and exports methods via RCT_EXPORT_METHOD macros.
20
+ @implementation NativeScanditDataCaptureId {
21
+ ScanditDataCaptureIdImpl *_impl;
22
+ }
23
+
24
+ RCT_EXPORT_MODULE(ScanditDataCaptureId)
25
+
26
+ - (instancetype)init {
27
+ if (self = [super init]) {
28
+ _impl = [[ScanditDataCaptureIdImpl 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 [self getConstantsOnMainQueue];
47
+ }
48
+
49
+ - (NSDictionary *)getConstants {
50
+ return [self getConstantsOnMainQueue];
51
+ }
52
+
53
+ - (NSDictionary *)getConstantsOnMainQueue {
54
+ __block NSDictionary *constants;
55
+ if ([NSThread isMainThread]) {
56
+ constants = [_impl getConstants];
57
+ } else {
58
+ dispatch_sync(dispatch_get_main_queue(), ^{
59
+ constants = [_impl getConstants];
60
+ });
61
+ }
62
+ return constants;
63
+ }
64
+
65
+ - (NSArray<NSString *> *)supportedEvents {
66
+ return [_impl supportedEvents];
67
+ }
68
+
69
+ - (void)invalidate {
70
+ [super invalidate];
71
+ [_impl invalidate];
72
+ }
73
+
74
+ // MARK: - Native Module Methods
75
+
76
+ RCT_EXPORT_METHOD(executeId
77
+ : (NSDictionary *)data resolve
78
+ : (RCTPromiseResolveBlock)resolve reject
79
+ : (RCTPromiseRejectBlock)reject) {
80
+ [_impl executeIdWithData:data resolve:resolve reject:reject];
81
+ }
82
+
83
+ @end
@@ -3,3 +3,28 @@
3
3
  *
4
4
  * Copyright (C) 2021- Scandit AG. All rights reserved.
5
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 <ScanditReactNativeDatacaptureIdSpec/ScanditReactNativeDatacaptureIdSpec.h>
16
+ #import <React/RCTInitializing.h>
17
+ #import <React/RCTInvalidating.h>
18
+ #endif
19
+
20
+ /// Native module for Scandit Data Capture Id.
21
+ /// This Obj-C++ class conforms to the TurboModule spec and delegates to ScanditDataCaptureIdImpl
22
+ /// (Swift). Following the Adapter Pattern from React Native's TurboModule Swift guide.
23
+ #ifdef RCT_NEW_ARCH_ENABLED
24
+ @interface NativeScanditDataCaptureId
25
+ : NativeScanditDataCaptureIdSpecBase <NativeScanditDataCaptureIdSpec, RCTInitializing,
26
+ RCTInvalidating>
27
+ #else
28
+ @interface NativeScanditDataCaptureId : RCTEventEmitter <RCTBridgeModule>
29
+ #endif
30
+ @end
@@ -10,50 +10,75 @@ import ScanditDataCaptureCore
10
10
  import ScanditFrameworksCore
11
11
  import ScanditFrameworksId
12
12
 
13
- @objc(ScanditDataCaptureId)
14
- class ScanditDataCaptureId: RCTEventEmitter {
13
+ /// Swift implementation for the Id native module.
14
+ /// This class contains all business logic and is used by the Obj-C++ adapter (NativeScanditDataCaptureId).
15
+ /// Following the Adapter Pattern from React Native's TurboModule Swift guide.
16
+ @objcMembers
17
+ public class ScanditDataCaptureIdImpl: NSObject {
15
18
  var idModule: IdCaptureModule!
16
19
 
17
- override init() {
18
- super.init()
19
- let emitter = ReactNativeEmitter(emitter: self)
20
- idModule = IdCaptureModule(emitter: emitter)
21
- idModule.didStart()
22
- }
20
+ /// Reference to the RCTEventEmitter adapter.
21
+ weak var emitter: RCTEventEmitter?
23
22
 
24
- override func supportedEvents() -> [String]! {
25
- FrameworksIdCaptureEvent.allCases.map { $0.rawValue }
23
+ public override init() {
24
+ super.init()
26
25
  }
27
26
 
28
- override func constantsToExport() -> [AnyHashable: Any]! {
29
- [
30
- "Defaults": idModule.getDefaults()
31
- ]
27
+ /// Called by the Obj-C++ adapter to set up the emitter reference and initialize modules (old architecture).
28
+ public func setup(with emitter: RCTEventEmitter) {
29
+ self.emitter = emitter
30
+ guard let reactEmitter = ScanditDataCaptureCore.ReactNativeEmitterFactory.create(emitter: emitter) else {
31
+ fatalError("Failed to create ReactNativeEmitter")
32
+ }
33
+ idModule = IdCaptureModule(emitter: reactEmitter)
34
+ idModule.didStart()
32
35
  }
33
36
 
34
- @objc override class func requiresMainQueueSetup() -> Bool {
35
- true
37
+ /// Called by the Obj-C++ adapter to set up the emitter reference and initialize modules (new architecture).
38
+ /// - Parameters:
39
+ /// - emitter: The RCTEventEmitter (nil in new arch since we don't inherit from RCTEventEmitter).
40
+ /// - turboEmitter: TurboModule emitter block for new architecture.
41
+ @objc(setupWith:turboEmitter:)
42
+ public func setup(with emitter: RCTEventEmitter?, turboEmitter: SDCEventEmitBlock?) {
43
+ self.emitter = emitter
44
+ guard
45
+ let reactEmitter = ScanditDataCaptureCore.ReactNativeEmitterFactory.create(
46
+ emitter: emitter,
47
+ turboEmitter: turboEmitter
48
+ )
49
+ else {
50
+ fatalError("Failed to create ReactNativeEmitter")
51
+ }
52
+ idModule = IdCaptureModule(emitter: reactEmitter)
53
+ idModule.didStart()
36
54
  }
37
55
 
38
- @objc override var methodQueue: DispatchQueue! {
39
- sdcSharedMethodQueue
56
+ public func supportedEvents() -> [String] {
57
+ FrameworksIdCaptureEvent.allCases.map { $0.rawValue }
40
58
  }
41
59
 
42
- @objc override func invalidate() {
43
- super.invalidate()
44
- idModule.didStop()
60
+ public func getConstants() -> [AnyHashable: Any] {
61
+ guard let module = idModule else {
62
+ return [:]
63
+ }
64
+ return [
65
+ "Defaults": module.getDefaults()
66
+ ]
45
67
  }
46
68
 
47
- deinit {
48
- invalidate()
69
+ public func invalidate() {
70
+ idModule?.didStop()
49
71
  }
50
72
 
51
- @objc(executeId:resolve:reject:)
52
- func executeId(
73
+ public func executeId(
53
74
  data: [String: Any],
54
75
  resolve: @escaping RCTPromiseResolveBlock,
55
76
  reject: @escaping RCTPromiseRejectBlock
56
77
  ) {
78
+ guard let module = idModule else {
79
+ reject("MODULE_NOT_INITIALIZED", "IdModule is not initialized. setup() may not have been called.", nil)
80
+ return
81
+ }
57
82
 
58
83
  let coreModuleName = String(describing: CoreModule.self)
59
84
  guard let coreModule = DefaultServiceLocator.shared.resolve(clazzName: coreModuleName) as? CoreModule else {
@@ -65,7 +90,7 @@ class ScanditDataCaptureId: RCTEventEmitter {
65
90
  let handled = coreModule.execute(
66
91
  ReactNativeMethodCall(data),
67
92
  result: result,
68
- module: idModule
93
+ module: module
69
94
  )
70
95
 
71
96
  if !handled {
@@ -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 "ScanditReactNativeDatacaptureIdSpec.h"
15
+
16
+
17
+ @implementation NativeScanditDataCaptureIdSpecBase
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_NativeScanditDataCaptureIdSpecJSI_executeId(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
33
+ return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "executeId", @selector(executeId:resolve:reject:), args, count);
34
+ }
35
+
36
+ static facebook::jsi::Value __hostFunction_NativeScanditDataCaptureIdSpecJSI_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
+ NativeScanditDataCaptureIdSpecJSI::NativeScanditDataCaptureIdSpecJSI(const ObjCTurboModule::InitParams &params)
41
+ : ObjCTurboModule(params) {
42
+
43
+ methodMap_["executeId"] = MethodMetadata {1, __hostFunction_NativeScanditDataCaptureIdSpecJSI_executeId};
44
+
45
+
46
+ methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativeScanditDataCaptureIdSpecJSI_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 ScanditReactNativeDatacaptureIdSpec symbols
19
+ #ifndef ScanditReactNativeDatacaptureIdSpec_H
20
+ #define ScanditReactNativeDatacaptureIdSpec_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 NativeScanditDataCaptureId {
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 NativeScanditDataCaptureIdSpec <RCTBridgeModule, RCTTurboModule>
66
+
67
+ - (void)executeId:(NSDictionary *)data
68
+ resolve:(RCTPromiseResolveBlock)resolve
69
+ reject:(RCTPromiseRejectBlock)reject;
70
+ - (facebook::react::ModuleConstants<JS::NativeScanditDataCaptureId::Constants::Builder>)constantsToExport;
71
+ - (facebook::react::ModuleConstants<JS::NativeScanditDataCaptureId::Constants::Builder>)getConstants;
72
+
73
+ @end
74
+
75
+ @interface NativeScanditDataCaptureIdSpecBase : 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 'NativeScanditDataCaptureId'
87
+ */
88
+ class JSI_EXPORT NativeScanditDataCaptureIdSpecJSI : public ObjCTurboModule {
89
+ public:
90
+ NativeScanditDataCaptureIdSpecJSI(const ObjCTurboModule::InitParams &params);
91
+ };
92
+ } // namespace facebook::react
93
+ inline JS::NativeScanditDataCaptureId::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::NativeScanditDataCaptureId::Constants::Builder::Builder(Constants i) : _factory(^{
100
+ return i.unsafeRawValue();
101
+ }) {}
102
+ NS_ASSUME_NONNULL_END
103
+ #endif // ScanditReactNativeDatacaptureIdSpec_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 "ScanditReactNativeDatacaptureIdSpecJSI.h"
11
+
12
+ namespace facebook::react {
13
+
14
+ static jsi::Value __hostFunction_NativeScanditDataCaptureIdCxxSpecJSI_getConstants(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
15
+ return static_cast<NativeScanditDataCaptureIdCxxSpecJSI *>(&turboModule)->getConstants(
16
+ rt
17
+ );
18
+ }
19
+ static jsi::Value __hostFunction_NativeScanditDataCaptureIdCxxSpecJSI_executeId(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
20
+ return static_cast<NativeScanditDataCaptureIdCxxSpecJSI *>(&turboModule)->executeId(
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
+ NativeScanditDataCaptureIdCxxSpecJSI::NativeScanditDataCaptureIdCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
27
+ : TurboModule("ScanditDataCaptureId", jsInvoker) {
28
+ methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativeScanditDataCaptureIdCxxSpecJSI_getConstants};
29
+ methodMap_["executeId"] = MethodMetadata {1, __hostFunction_NativeScanditDataCaptureIdCxxSpecJSI_executeId};
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 - NativeScanditDataCaptureIdScanditEventPayload
20
+
21
+ template <typename P0, typename P1, typename P2, typename P3>
22
+ struct NativeScanditDataCaptureIdScanditEventPayload {
23
+ P0 name;
24
+ P1 data;
25
+ P2 viewId;
26
+ P3 modeId;
27
+ bool operator==(const NativeScanditDataCaptureIdScanditEventPayload &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 NativeScanditDataCaptureIdScanditEventPayloadBridging {
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 NativeScanditDataCaptureIdCxxSpecJSI : public TurboModule {
84
+ protected:
85
+ NativeScanditDataCaptureIdCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
86
+
87
+ public:
88
+ virtual jsi::Object getConstants(jsi::Runtime &rt) = 0;
89
+ virtual jsi::Value executeId(jsi::Runtime &rt, jsi::Object data) = 0;
90
+
91
+ };
92
+
93
+ template <typename T>
94
+ class JSI_EXPORT NativeScanditDataCaptureIdCxxSpec : 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 = "ScanditDataCaptureId";
105
+
106
+ protected:
107
+ NativeScanditDataCaptureIdCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
108
+ : TurboModule(std::string{NativeScanditDataCaptureIdCxxSpec::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 NativeScanditDataCaptureIdCxxSpecJSI {
120
+ public:
121
+ Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
122
+ NativeScanditDataCaptureIdCxxSpecJSI(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 executeId(jsi::Runtime &rt, jsi::Object data) override {
135
+ static_assert(
136
+ bridging::getParameterCount(&T::executeId) == 2,
137
+ "Expected executeId(...) to have 2 parameters");
138
+
139
+ return bridging::callFromJs<jsi::Value>(
140
+ rt, &T::executeId, jsInvoker_, instance_, std::move(data));
141
+ }
142
+
143
+ private:
144
+ friend class NativeScanditDataCaptureIdCxxSpec;
145
+ T *instance_;
146
+ };
147
+
148
+ Delegate delegate_;
149
+ };
150
+
151
+ } // namespace facebook::react