-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathNodeApiHostModuleProvider.mm
More file actions
44 lines (37 loc) · 1.24 KB
/
NodeApiHostModuleProvider.mm
File metadata and controls
44 lines (37 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#import "CxxNodeApiHostModule.hpp"
#import "WeakNodeApiInjector.hpp"
#define USE_CXX_TURBO_MODULE_UTILS 0
#if defined(__has_include)
#if __has_include(<ReactCommon/CxxTurboModuleUtils.h>)
#undef USE_CXX_TURBO_MODULE_UTILS
#define USE_CXX_TURBO_MODULE_UTILS 1
#endif
#endif
#if USE_CXX_TURBO_MODULE_UTILS
#import <ReactCommon/CxxTurboModuleUtils.h>
@interface NodeApiHost : NSObject
#else
#import <ReactCommon/RCTTurboModule.h>
@interface NodeApiHost : NSObject <RCTBridgeModule, RCTTurboModule>
#endif // USE_CXX_TURBO_MODULE_UTILS
@end
@implementation NodeApiHost
#if USE_CXX_TURBO_MODULE_UTILS
+ (void)load {
callstack::nodeapihost::injectIntoWeakNodeApi();
facebook::react::registerCxxModuleToGlobalModuleMap(
callstack::nodeapihost::CxxNodeApiHostModule::kModuleName,
[](std::shared_ptr<facebook::react::CallInvoker> jsInvoker) {
return std::make_shared<callstack::nodeapihost::CxxNodeApiHostModule>(
jsInvoker);
});
}
#else
RCT_EXPORT_MODULE()
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
(const facebook::react::ObjCTurboModule::InitParams &)params {
return std::make_shared<callstack::nodeapihost::CxxNodeApiHostModule>(
params.jsInvoker);
}
#endif // USE_CXX_TURBO_MODULE_UTILS
@end