react-native-nitro-modules 0.10.0 → 0.12.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 (120) hide show
  1. package/NitroModules.podspec +4 -0
  2. package/README.md +2 -2
  3. package/android/CMakeLists.txt +3 -0
  4. package/android/build.gradle +27 -3
  5. package/android/src/main/cpp/JNIOnLoad.cpp +5 -5
  6. package/android/src/main/cpp/platform/NitroLogger.cpp +1 -1
  7. package/android/src/main/cpp/turbomodule/JNitroModules.cpp +41 -0
  8. package/android/src/main/cpp/turbomodule/JNitroModules.hpp +37 -0
  9. package/android/src/main/java/com/margelo/nitro/NitroModules.kt +69 -0
  10. package/android/src/main/java/com/margelo/nitro/NitroModulesPackage.kt +34 -0
  11. package/android/src/main/java/com/margelo/nitro/core/HybridObject.kt +6 -2
  12. package/android/src/newarch/NitroModulesSpec.kt +6 -0
  13. package/android/src/oldarch/NitroModulesSpec.kt +9 -0
  14. package/cpp/core/HybridFunction.hpp +13 -4
  15. package/cpp/entrypoint/HybridNitroModulesProxy.cpp +55 -0
  16. package/cpp/entrypoint/HybridNitroModulesProxy.hpp +48 -0
  17. package/cpp/entrypoint/InstallNitro.cpp +28 -0
  18. package/cpp/entrypoint/InstallNitro.hpp +41 -0
  19. package/cpp/jsi/JSIConverter+ArrayBuffer.hpp +6 -6
  20. package/cpp/jsi/JSIConverter+HostObject.hpp +73 -0
  21. package/cpp/jsi/JSIConverter+HybridObject.hpp +1 -1
  22. package/cpp/jsi/JSIConverter+Promise.hpp +1 -0
  23. package/cpp/jsi/JSIConverter+Tuple.hpp +2 -2
  24. package/cpp/jsi/JSIConverter.hpp +1 -0
  25. package/cpp/prototype/HybridObjectPrototype.cpp +4 -3
  26. package/cpp/threading/CallInvokerDispatcher.hpp +5 -0
  27. package/cpp/utils/NitroDefines.hpp +8 -0
  28. package/cpp/utils/TypeInfo.hpp +40 -20
  29. package/ios/core/ArrayBufferHolder.hpp +1 -1
  30. package/ios/core/HybridObjectSpec.swift +1 -1
  31. package/ios/platform/NitroLogger.mm +1 -2
  32. package/ios/turbomodule/NativeNitroModules+NewArch.mm +67 -0
  33. package/ios/turbomodule/NativeNitroModules+OldArch.mm +71 -0
  34. package/ios/turbomodule/NativeNitroModules.h +22 -0
  35. package/lib/BoxedHybridObject.d.ts +12 -0
  36. package/lib/BoxedHybridObject.js +1 -0
  37. package/lib/ModuleNotFoundError.js +3 -13
  38. package/lib/NitroModules.d.ts +1 -83
  39. package/lib/NitroModules.js +2 -94
  40. package/lib/NitroModulesProxy.d.ts +58 -0
  41. package/lib/NitroModulesProxy.js +1 -0
  42. package/lib/commonjs/BoxedHybridObject.js +6 -0
  43. package/lib/commonjs/BoxedHybridObject.js.map +1 -0
  44. package/lib/commonjs/ModuleNotFoundError.js +3 -15
  45. package/lib/commonjs/ModuleNotFoundError.js.map +1 -1
  46. package/lib/commonjs/NitroModules.js +11 -100
  47. package/lib/commonjs/NitroModules.js.map +1 -1
  48. package/lib/commonjs/NitroModulesProxy.js +6 -0
  49. package/lib/commonjs/NitroModulesProxy.js.map +1 -0
  50. package/lib/commonjs/turbomodule/NativeNitroModules.js +36 -0
  51. package/lib/commonjs/turbomodule/NativeNitroModules.js.map +1 -0
  52. package/lib/commonjs/turbomodule/NativeNitroModules.web.js +17 -0
  53. package/lib/commonjs/turbomodule/NativeNitroModules.web.js.map +1 -0
  54. package/lib/module/BoxedHybridObject.js +4 -0
  55. package/lib/module/BoxedHybridObject.js.map +1 -0
  56. package/lib/module/ModuleNotFoundError.js +3 -15
  57. package/lib/module/ModuleNotFoundError.js.map +1 -1
  58. package/lib/module/NitroModules.js +2 -100
  59. package/lib/module/NitroModules.js.map +1 -1
  60. package/lib/module/NitroModulesProxy.js +4 -0
  61. package/lib/module/NitroModulesProxy.js.map +1 -0
  62. package/lib/module/turbomodule/NativeNitroModules.js +31 -0
  63. package/lib/module/turbomodule/NativeNitroModules.js.map +1 -0
  64. package/lib/{NitroModulesTurboModule.web.js → module/turbomodule/NativeNitroModules.web.js} +9 -1
  65. package/lib/module/turbomodule/NativeNitroModules.web.js.map +1 -0
  66. package/lib/tsconfig.tsbuildinfo +1 -1
  67. package/lib/turbomodule/NativeNitroModules.d.ts +7 -0
  68. package/lib/turbomodule/NativeNitroModules.js +27 -0
  69. package/lib/turbomodule/NativeNitroModules.web.d.ts +2 -0
  70. package/lib/turbomodule/NativeNitroModules.web.js +9 -0
  71. package/lib/typescript/AnyMap.d.ts +20 -0
  72. package/lib/typescript/BoxedHybridObject.d.ts +13 -0
  73. package/lib/typescript/BoxedHybridObject.d.ts.map +1 -0
  74. package/lib/typescript/ModuleNotFoundError.d.ts +7 -0
  75. package/lib/typescript/ModuleNotFoundError.d.ts.map +1 -1
  76. package/lib/typescript/NitroModules.d.ts +1 -83
  77. package/lib/typescript/NitroModules.d.ts.map +1 -1
  78. package/lib/typescript/NitroModulesProxy.d.ts +59 -0
  79. package/lib/typescript/NitroModulesProxy.d.ts.map +1 -0
  80. package/lib/typescript/__tests__/index.test.d.ts +1 -0
  81. package/lib/typescript/index.d.ts +4 -0
  82. package/lib/typescript/turbomodule/NativeNitroModules.d.ts +8 -0
  83. package/lib/typescript/turbomodule/NativeNitroModules.d.ts.map +1 -0
  84. package/lib/typescript/turbomodule/NativeNitroModules.web.d.ts +3 -0
  85. package/lib/typescript/turbomodule/NativeNitroModules.web.d.ts.map +1 -0
  86. package/package.json +10 -3
  87. package/src/BoxedHybridObject.ts +13 -0
  88. package/src/ModuleNotFoundError.ts +3 -19
  89. package/src/NitroModules.ts +2 -108
  90. package/src/NitroModulesProxy.ts +61 -0
  91. package/src/turbomodule/NativeNitroModules.ts +48 -0
  92. package/src/turbomodule/NativeNitroModules.web.ts +16 -0
  93. package/android/src/main/java/com/margelo/nitro/NitroModulesPackage.java +0 -30
  94. package/cpp/turbomodule/NativeNitroModules.cpp +0 -146
  95. package/cpp/turbomodule/NativeNitroModules.h +0 -8
  96. package/cpp/turbomodule/NativeNitroModules.hpp +0 -38
  97. package/cpp/turbomodule/RegisterNativeNitroModules.cpp +0 -33
  98. package/cpp/turbomodule/RegisterNativeNitroModules.hpp +0 -21
  99. package/ios/turbomodule/NitroModuleOnLoad.mm +0 -32
  100. package/lib/NativeNitroModules.d.ts +0 -16
  101. package/lib/NativeNitroModules.js +0 -22
  102. package/lib/NativeNitroModules.web.d.ts +0 -4
  103. package/lib/NativeNitroModules.web.js +0 -3
  104. package/lib/NitroModulesTurboModule.d.ts +0 -18
  105. package/lib/NitroModulesTurboModule.js +0 -23
  106. package/lib/NitroModulesTurboModule.web.d.ts +0 -1
  107. package/lib/commonjs/NitroModulesTurboModule.js +0 -34
  108. package/lib/commonjs/NitroModulesTurboModule.js.map +0 -1
  109. package/lib/commonjs/NitroModulesTurboModule.web.js +0 -11
  110. package/lib/commonjs/NitroModulesTurboModule.web.js.map +0 -1
  111. package/lib/module/NitroModulesTurboModule.js +0 -30
  112. package/lib/module/NitroModulesTurboModule.js.map +0 -1
  113. package/lib/module/NitroModulesTurboModule.web.js +0 -7
  114. package/lib/module/NitroModulesTurboModule.web.js.map +0 -1
  115. package/lib/typescript/NitroModulesTurboModule.d.ts +0 -19
  116. package/lib/typescript/NitroModulesTurboModule.d.ts.map +0 -1
  117. package/lib/typescript/NitroModulesTurboModule.web.d.ts +0 -2
  118. package/lib/typescript/NitroModulesTurboModule.web.d.ts.map +0 -1
  119. package/src/NitroModulesTurboModule.ts +0 -50
  120. package/src/NitroModulesTurboModule.web.ts +0 -7
@@ -1,146 +0,0 @@
1
- //
2
- // NativeNitroModules.cpp
3
- // NitroModules
4
- //
5
- // Created by Marc Rousavy on 21.06.24.
6
- //
7
-
8
- #include "NativeNitroModules.hpp"
9
- #include "BoxedHybridObject.hpp"
10
- #include "CallInvokerDispatcher.hpp"
11
- #include "Dispatcher.hpp"
12
- #include "HybridObjectRegistry.hpp"
13
- #include "NitroDefines.hpp"
14
-
15
- namespace facebook::react {
16
-
17
- using namespace margelo::nitro;
18
-
19
- NativeNitroModules::NativeNitroModules(std::shared_ptr<CallInvoker> jsInvoker)
20
- : TurboModule(kModuleName, jsInvoker), _callInvoker(jsInvoker) {}
21
-
22
- jsi::Value NativeNitroModules::get(jsi::Runtime& runtime, const jsi::PropNameID& propName) {
23
- std::string name = propName.utf8(runtime);
24
-
25
- if (name == "install") {
26
- return jsi::Function::createFromHostFunction(
27
- runtime, jsi::PropNameID::forUtf8(runtime, "install"), 0,
28
- [this](jsi::Runtime& runtime, const jsi::Value& thisArg, const jsi::Value* args, size_t count) -> jsi::Value {
29
- install(runtime);
30
- return jsi::Value::undefined();
31
- });
32
- }
33
- if (name == "createHybridObject") {
34
- return jsi::Function::createFromHostFunction(
35
- runtime, jsi::PropNameID::forUtf8(runtime, "createHybridObject"), 1,
36
- [this](jsi::Runtime& runtime, const jsi::Value& thisArg, const jsi::Value* args, size_t count) -> jsi::Value {
37
- #ifdef NITRO_DEBUG
38
- if (count != 1) [[unlikely]] {
39
- throw jsi::JSError(runtime,
40
- "NitroModules.createHybridObject(..) expects 1 argument, but " + std::to_string(count) + " were supplied!");
41
- }
42
- #endif
43
- jsi::String objectName = args[0].asString(runtime);
44
- return createHybridObject(runtime, objectName);
45
- });
46
- }
47
- if (name == "hasHybridObject") {
48
- return jsi::Function::createFromHostFunction(
49
- runtime, jsi::PropNameID::forUtf8(runtime, "hasHybridObject"), 1,
50
- [this](jsi::Runtime& runtime, const jsi::Value& thisArg, const jsi::Value* args, size_t count) -> jsi::Value {
51
- #ifdef NITRO_DEBUG
52
- if (count != 1) [[unlikely]] {
53
- throw jsi::JSError(runtime,
54
- "NitroModules.hasHybridObject(..) expects 1 argument (name), but received " + std::to_string(count) + "!");
55
- }
56
- #endif
57
- jsi::String objectName = args[0].asString(runtime);
58
- return hasHybridObject(runtime, objectName);
59
- });
60
- }
61
- if (name == "getAllHybridObjectNames") {
62
- return jsi::Function::createFromHostFunction(runtime, jsi::PropNameID::forUtf8(runtime, "getAllHybridObjectNames"), 0,
63
- [this](jsi::Runtime& runtime, const jsi::Value& thisArg, const jsi::Value* args,
64
- size_t count) -> jsi::Value { return getAllHybridObjectNames(runtime); });
65
- }
66
- if (name == "hasNativeState") {
67
- return jsi::Function::createFromHostFunction(
68
- runtime, jsi::PropNameID::forUtf8(runtime, "hasNativeState"), 1,
69
- [](jsi::Runtime& runtime, const jsi::Value& thisArg, const jsi::Value* args, size_t count) -> jsi::Value {
70
- jsi::Object object = args[0].asObject(runtime);
71
- bool has = object.hasNativeState(runtime) && object.getNativeState(runtime) != nullptr;
72
- return jsi::Value(has);
73
- });
74
- }
75
- if (name == "removeNativeState") {
76
- return jsi::Function::createFromHostFunction(
77
- runtime, jsi::PropNameID::forUtf8(runtime, "removeNativeState"), 1,
78
- [](jsi::Runtime& runtime, const jsi::Value& thisArg, const jsi::Value* args, size_t count) -> jsi::Value {
79
- jsi::Object object = args[0].asObject(runtime);
80
- object.setNativeState(runtime, nullptr);
81
- return jsi::Value::undefined();
82
- });
83
- }
84
- if (name == "box") {
85
- return jsi::Function::createFromHostFunction(
86
- runtime, jsi::PropNameID::forUtf8(runtime, "box"), 1,
87
- [](jsi::Runtime& runtime, const jsi::Value& thisArg, const jsi::Value* args, size_t count) -> jsi::Value {
88
- jsi::Object object = args[0].asObject(runtime);
89
- #ifdef NITRO_DEBUG
90
- if (!object.hasNativeState(runtime)) {
91
- std::string stringified = args[0].toString(runtime).utf8(runtime);
92
- throw std::runtime_error("Cannot box object " + stringified + " - it does not have a NativeState!");
93
- }
94
- #endif
95
-
96
- std::shared_ptr<jsi::NativeState> nativeState = object.getNativeState(runtime);
97
- std::shared_ptr<HybridObject> maybeHybridObject = std::dynamic_pointer_cast<HybridObject>(nativeState);
98
- if (maybeHybridObject == nullptr) {
99
- std::string stringified = args[0].toString(runtime).utf8(runtime);
100
- throw std::runtime_error("Cannot box object " + stringified + " - it has a NativeState, but it's not a HybridObject!");
101
- }
102
-
103
- auto boxed = std::make_shared<BoxedHybridObject>(maybeHybridObject);
104
- return jsi::Object::createFromHostObject(runtime, boxed);
105
- });
106
- }
107
- if (name == "buildType") {
108
- #ifdef NITRO_DEBUG
109
- return jsi::String::createFromAscii(runtime, "debug");
110
- #else
111
- return jsi::String::createFromAscii(runtime, "release");
112
- #endif
113
- }
114
-
115
- return jsi::Value::undefined();
116
- }
117
-
118
- void NativeNitroModules::install(jsi::Runtime& runtime) {
119
- // Installs the global Dispatcher mechanism into this Runtime.
120
- // This allows creating Promises and calling back to JS.
121
- auto dispatcher = std::make_shared<CallInvokerDispatcher>(_callInvoker);
122
- Dispatcher::installRuntimeGlobalDispatcher(runtime, dispatcher);
123
- }
124
-
125
- jsi::Value NativeNitroModules::createHybridObject(jsi::Runtime& runtime, const jsi::String& hybridObjectName) {
126
- auto name = hybridObjectName.utf8(runtime);
127
- auto hybridObject = HybridObjectRegistry::createHybridObject(name);
128
- return hybridObject->toObject(runtime);
129
- }
130
-
131
- jsi::Value NativeNitroModules::hasHybridObject(jsi::Runtime& runtime, const jsi::String& hybridObjectName) {
132
- std::string name = hybridObjectName.utf8(runtime);
133
- bool exists = HybridObjectRegistry::hasHybridObject(name);
134
- return exists;
135
- }
136
-
137
- jsi::Value NativeNitroModules::getAllHybridObjectNames(jsi::Runtime& runtime) {
138
- std::vector<std::string> keys = HybridObjectRegistry::getAllHybridObjectNames();
139
- jsi::Array array(runtime, keys.size());
140
- for (size_t i = 0; i < keys.size(); i++) {
141
- array.setValueAtIndex(runtime, i, jsi::String::createFromUtf8(runtime, keys[i]));
142
- }
143
- return array;
144
- }
145
-
146
- } // namespace facebook::react
@@ -1,8 +0,0 @@
1
- //
2
- // Created by Marc Rousavy on 26.07.24.
3
- //
4
-
5
- #pragma once
6
-
7
- // Forward include, because in react-native they use `.h` instead of `.hpp`
8
- #include "NativeNitroModules.hpp"
@@ -1,38 +0,0 @@
1
- //
2
- // NativeNitroModules.hpp
3
- // NitroModules
4
- //
5
- // Created by Marc Rousavy on 21.06.24.
6
- //
7
-
8
- #pragma once
9
-
10
- #include <ReactCommon/TurboModule.h>
11
-
12
- namespace facebook::react {
13
-
14
- using namespace facebook;
15
-
16
- // The base C++-based TurboModule. This is the entry point where all nitro modules get initialized.
17
- class NativeNitroModules : public TurboModule {
18
- public:
19
- explicit NativeNitroModules(std::shared_ptr<CallInvoker> jsInvoker);
20
-
21
- public:
22
- jsi::Value get(jsi::Runtime& runtime, const jsi::PropNameID& propName) override;
23
-
24
- // Setup
25
- void install(jsi::Runtime& runtime);
26
- // Hybrid Objects stuff
27
- jsi::Value createHybridObject(jsi::Runtime& runtime, const jsi::String& hybridObjectName);
28
- jsi::Value hasHybridObject(jsi::Runtime& runtime, const jsi::String& hybridObjectName);
29
- jsi::Value getAllHybridObjectNames(jsi::Runtime& runtime);
30
-
31
- public:
32
- constexpr static auto kModuleName = "NitroModulesCxx";
33
-
34
- private:
35
- std::shared_ptr<CallInvoker> _callInvoker;
36
- };
37
-
38
- } // namespace facebook::react
@@ -1,33 +0,0 @@
1
- //
2
- // RegisterNativeNitroModules.cpp
3
- // DoubleConversion
4
- //
5
- // Created by Marc Rousavy on 21.06.24.
6
- //
7
-
8
- #include "RegisterNativeNitroModules.hpp"
9
- #include "NativeNitroModules.hpp"
10
- #include <memory>
11
- #include <string>
12
-
13
- #if __has_include(<ReactCommon/CallInvoker.h>)
14
- // Android style imports
15
- #include <ReactCommon/CallInvoker.h>
16
- #include <ReactCommon/CxxTurboModuleUtils.h>
17
- #else
18
- // iOS style imports
19
- #include <React-callinvoker/ReactCommon/CallInvoker.h>
20
- #include <ReactCommon/ReactCommon/CxxTurboModuleUtils.h>
21
- #endif
22
-
23
- namespace margelo::nitro {
24
-
25
- using namespace facebook;
26
-
27
- void RegisterNativeNitroModules::registerNativeNitroModules() {
28
- react::registerCxxModuleToGlobalModuleMap(
29
- std::string(react::NativeNitroModules::kModuleName),
30
- [&](std::shared_ptr<react::CallInvoker> jsInvoker) { return std::make_shared<react::NativeNitroModules>(jsInvoker); });
31
- }
32
-
33
- } // namespace margelo::nitro
@@ -1,21 +0,0 @@
1
- //
2
- // RegisterNativeNitroModules.hpp
3
- // DoubleConversion
4
- //
5
- // Created by Marc Rousavy on 21.06.24.
6
- //
7
-
8
- #pragma once
9
-
10
- namespace margelo::nitro {
11
-
12
- class RegisterNativeNitroModules {
13
- public:
14
- /**
15
- Registers the native NitroModules TurboModule into the React Runtime.
16
- This can be called from Swift/Objective-C.
17
- */
18
- static void registerNativeNitroModules();
19
- };
20
-
21
- } // namespace margelo::nitro
@@ -1,32 +0,0 @@
1
- //
2
- // NitroModuleOnLoad.mm
3
- // DoubleConversion
4
- //
5
- // Created by Marc Rousavy on 21.06.24.
6
- //
7
-
8
- #import "HybridObjectRegistry.hpp"
9
- #import "RegisterNativeNitroModules.hpp"
10
- #import <Foundation/Foundation.h>
11
-
12
- // just import headers so we have syntax highlighting
13
- #import "ArrayBufferHolder.hpp"
14
- #import "HybridContext.hpp"
15
- #import "PromiseHolder.hpp"
16
- #import "SwiftClosure.hpp"
17
-
18
- @interface NitroModulesOnLoad : NSObject
19
- @end
20
-
21
- @implementation NitroModulesOnLoad
22
-
23
- using namespace margelo::nitro;
24
-
25
- + (void)load {
26
- // When this Objective-C class is loaded, it registers the CxxTurboModule in the react module system.
27
- // We need Objective-C here because these things do not get compiled out - meaning this will always be
28
- // called when the app starts.
29
- RegisterNativeNitroModules::registerNativeNitroModules();
30
- }
31
-
32
- @end
@@ -1,16 +0,0 @@
1
- import type { TurboModule } from 'react-native';
2
- import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
3
- export interface Spec extends TurboModule {
4
- install(): void;
5
- createHybridObject(name: string, args?: UnsafeObject): UnsafeObject;
6
- hasHybridObject(name: string): boolean;
7
- getAllHybridObjectNames(): string[];
8
- hasNativeState(obj: UnsafeObject): boolean;
9
- removeNativeState(obj: UnsafeObject): void;
10
- }
11
- export declare function getNativeNitroModules(): Spec;
12
- declare global {
13
- var __nitroModulesJSICache: {};
14
- var __nitroDispatcher: {};
15
- }
16
- export declare function isRuntimeAlive(): boolean;
@@ -1,22 +0,0 @@
1
- import { TurboModuleRegistry } from 'react-native';
2
- import { ModuleNotFoundError } from './ModuleNotFoundError';
3
- let turboModule;
4
- export function getNativeNitroModules() {
5
- if (turboModule == null) {
6
- try {
7
- // 1. Get (and initialize) the C++ TurboModule
8
- turboModule = TurboModuleRegistry.getEnforcing('NitroModulesCxx');
9
- // 2. Install Dispatcher and required bindings into the Runtime
10
- turboModule.install();
11
- }
12
- catch (e) {
13
- throw new ModuleNotFoundError(e);
14
- }
15
- }
16
- return turboModule;
17
- }
18
- export function isRuntimeAlive() {
19
- const cache = global.__nitroModulesJSICache;
20
- const dispatcher = global.__nitroDispatcher;
21
- return cache != null && dispatcher != null;
22
- }
@@ -1,4 +0,0 @@
1
- import type { TurboModule } from 'react-native';
2
- export interface Spec extends TurboModule {
3
- }
4
- export declare function getNativeNitroModules(): Spec;
@@ -1,3 +0,0 @@
1
- export function getNativeNitroModules() {
2
- throw new Error(`Native NitroModules are not available on web! Make sure you're not calling getNativeNitroModules() in a web (.web.ts) environment.`);
3
- }
@@ -1,18 +0,0 @@
1
- import type { TurboModule } from 'react-native';
2
- import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
3
- export interface NativeNitroSpec extends TurboModule {
4
- install(): void;
5
- createHybridObject(name: string): UnsafeObject;
6
- hasHybridObject(name: string): boolean;
7
- getAllHybridObjectNames(): string[];
8
- hasNativeState(obj: UnsafeObject): boolean;
9
- removeNativeState(obj: UnsafeObject): void;
10
- buildType: 'debug' | 'release';
11
- box(obj: UnsafeObject): UnsafeObject;
12
- }
13
- export declare function getNativeNitroModules(): NativeNitroSpec;
14
- declare global {
15
- var __nitroModulesJSICache: {};
16
- var __nitroDispatcher: {};
17
- }
18
- export declare function isRuntimeAlive(): boolean;
@@ -1,23 +0,0 @@
1
- import { TurboModuleRegistry } from 'react-native';
2
- import { ModuleNotFoundError } from './ModuleNotFoundError';
3
- let turboModule;
4
- export function getNativeNitroModules() {
5
- if (turboModule == null) {
6
- try {
7
- // 1. Get (and initialize) the C++ TurboModule
8
- turboModule =
9
- TurboModuleRegistry.getEnforcing('NitroModulesCxx');
10
- // 2. Install Dispatcher and required bindings into the Runtime
11
- turboModule.install();
12
- }
13
- catch (e) {
14
- throw new ModuleNotFoundError(e);
15
- }
16
- }
17
- return turboModule;
18
- }
19
- export function isRuntimeAlive() {
20
- const cache = global.__nitroModulesJSICache;
21
- const dispatcher = global.__nitroDispatcher;
22
- return cache != null && dispatcher != null;
23
- }
@@ -1 +0,0 @@
1
- export declare function getNativeNitroModules(): never;
@@ -1,34 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getNativeNitroModules = getNativeNitroModules;
7
- exports.isRuntimeAlive = isRuntimeAlive;
8
- var _reactNative = require("react-native");
9
- var _ModuleNotFoundError = require("./ModuleNotFoundError");
10
- // This TurboModule is *not* codegen'd.
11
- // It's handwritten, because otherwise the app's CMakeLists wants to build it.
12
- // Instead, we want to build it ourselves and have full control over the CMakeLists.
13
-
14
- let turboModule;
15
- function getNativeNitroModules() {
16
- if (turboModule == null) {
17
- try {
18
- // 1. Get (and initialize) the C++ TurboModule
19
- turboModule = _reactNative.TurboModuleRegistry.getEnforcing('NitroModulesCxx');
20
-
21
- // 2. Install Dispatcher and required bindings into the Runtime
22
- turboModule.install();
23
- } catch (e) {
24
- throw new _ModuleNotFoundError.ModuleNotFoundError(e);
25
- }
26
- }
27
- return turboModule;
28
- }
29
- function isRuntimeAlive() {
30
- const cache = global.__nitroModulesJSICache;
31
- const dispatcher = global.__nitroDispatcher;
32
- return cache != null && dispatcher != null;
33
- }
34
- //# sourceMappingURL=NitroModulesTurboModule.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_reactNative","require","_ModuleNotFoundError","turboModule","getNativeNitroModules","TurboModuleRegistry","getEnforcing","install","e","ModuleNotFoundError","isRuntimeAlive","cache","global","__nitroModulesJSICache","dispatcher","__nitroDispatcher"],"sourceRoot":"../../src","sources":["NitroModulesTurboModule.ts"],"mappings":";;;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,oBAAA,GAAAD,OAAA;AAEA;AACA;AACA;;AAeA,IAAIE,WAAwC;AACrC,SAASC,qBAAqBA,CAAA,EAAoB;EACvD,IAAID,WAAW,IAAI,IAAI,EAAE;IACvB,IAAI;MACF;MACAA,WAAW,GACTE,gCAAmB,CAACC,YAAY,CAAkB,iBAAiB,CAAC;;MAEtE;MACAH,WAAW,CAACI,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC,OAAOC,CAAC,EAAE;MACV,MAAM,IAAIC,wCAAmB,CAACD,CAAC,CAAC;IAClC;EACF;EAEA,OAAOL,WAAW;AACpB;AAOO,SAASO,cAAcA,CAAA,EAAG;EAC/B,MAAMC,KAAK,GAAGC,MAAM,CAACC,sBAAsB;EAC3C,MAAMC,UAAU,GAAGF,MAAM,CAACG,iBAAiB;EAC3C,OAAOJ,KAAK,IAAI,IAAI,IAAIG,UAAU,IAAI,IAAI;AAC5C","ignoreList":[]}
@@ -1,11 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getNativeNitroModules = getNativeNitroModules;
7
- var _reactNative = require("react-native");
8
- function getNativeNitroModules() {
9
- throw new Error(`Native NitroModules are not available on ${_reactNative.Platform.OS}! Make sure you're not calling getNativeNitroModules() in a ${_reactNative.Platform.OS} (.${_reactNative.Platform.OS}.ts) environment.`);
10
- }
11
- //# sourceMappingURL=NitroModulesTurboModule.web.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_reactNative","require","getNativeNitroModules","Error","Platform","OS"],"sourceRoot":"../../src","sources":["NitroModulesTurboModule.web.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,SAASC,qBAAqBA,CAAA,EAAU;EAC7C,MAAM,IAAIC,KAAK,CACb,4CAA4CC,qBAAQ,CAACC,EAAE,+DAA+DD,qBAAQ,CAACC,EAAE,MAAMD,qBAAQ,CAACC,EAAE,mBACpJ,CAAC;AACH","ignoreList":[]}
@@ -1,30 +0,0 @@
1
- "use strict";
2
-
3
- import { TurboModuleRegistry } from 'react-native';
4
- import { ModuleNotFoundError } from './ModuleNotFoundError';
5
-
6
- // This TurboModule is *not* codegen'd.
7
- // It's handwritten, because otherwise the app's CMakeLists wants to build it.
8
- // Instead, we want to build it ourselves and have full control over the CMakeLists.
9
-
10
- let turboModule;
11
- export function getNativeNitroModules() {
12
- if (turboModule == null) {
13
- try {
14
- // 1. Get (and initialize) the C++ TurboModule
15
- turboModule = TurboModuleRegistry.getEnforcing('NitroModulesCxx');
16
-
17
- // 2. Install Dispatcher and required bindings into the Runtime
18
- turboModule.install();
19
- } catch (e) {
20
- throw new ModuleNotFoundError(e);
21
- }
22
- }
23
- return turboModule;
24
- }
25
- export function isRuntimeAlive() {
26
- const cache = global.__nitroModulesJSICache;
27
- const dispatcher = global.__nitroDispatcher;
28
- return cache != null && dispatcher != null;
29
- }
30
- //# sourceMappingURL=NitroModulesTurboModule.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["TurboModuleRegistry","ModuleNotFoundError","turboModule","getNativeNitroModules","getEnforcing","install","e","isRuntimeAlive","cache","global","__nitroModulesJSICache","dispatcher","__nitroDispatcher"],"sourceRoot":"../../src","sources":["NitroModulesTurboModule.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AAElD,SAASC,mBAAmB,QAAQ,uBAAuB;;AAE3D;AACA;AACA;;AAeA,IAAIC,WAAwC;AAC5C,OAAO,SAASC,qBAAqBA,CAAA,EAAoB;EACvD,IAAID,WAAW,IAAI,IAAI,EAAE;IACvB,IAAI;MACF;MACAA,WAAW,GACTF,mBAAmB,CAACI,YAAY,CAAkB,iBAAiB,CAAC;;MAEtE;MACAF,WAAW,CAACG,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC,OAAOC,CAAC,EAAE;MACV,MAAM,IAAIL,mBAAmB,CAACK,CAAC,CAAC;IAClC;EACF;EAEA,OAAOJ,WAAW;AACpB;AAOA,OAAO,SAASK,cAAcA,CAAA,EAAG;EAC/B,MAAMC,KAAK,GAAGC,MAAM,CAACC,sBAAsB;EAC3C,MAAMC,UAAU,GAAGF,MAAM,CAACG,iBAAiB;EAC3C,OAAOJ,KAAK,IAAI,IAAI,IAAIG,UAAU,IAAI,IAAI;AAC5C","ignoreList":[]}
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- import { Platform } from 'react-native';
4
- export function getNativeNitroModules() {
5
- throw new Error(`Native NitroModules are not available on ${Platform.OS}! Make sure you're not calling getNativeNitroModules() in a ${Platform.OS} (.${Platform.OS}.ts) environment.`);
6
- }
7
- //# sourceMappingURL=NitroModulesTurboModule.web.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["Platform","getNativeNitroModules","Error","OS"],"sourceRoot":"../../src","sources":["NitroModulesTurboModule.web.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,SAASC,qBAAqBA,CAAA,EAAU;EAC7C,MAAM,IAAIC,KAAK,CACb,4CAA4CF,QAAQ,CAACG,EAAE,+DAA+DH,QAAQ,CAACG,EAAE,MAAMH,QAAQ,CAACG,EAAE,mBACpJ,CAAC;AACH","ignoreList":[]}
@@ -1,19 +0,0 @@
1
- import type { TurboModule } from 'react-native';
2
- import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
3
- export interface NativeNitroSpec extends TurboModule {
4
- install(): void;
5
- createHybridObject(name: string): UnsafeObject;
6
- hasHybridObject(name: string): boolean;
7
- getAllHybridObjectNames(): string[];
8
- hasNativeState(obj: UnsafeObject): boolean;
9
- removeNativeState(obj: UnsafeObject): void;
10
- buildType: 'debug' | 'release';
11
- box(obj: UnsafeObject): UnsafeObject;
12
- }
13
- export declare function getNativeNitroModules(): NativeNitroSpec;
14
- declare global {
15
- var __nitroModulesJSICache: {};
16
- var __nitroDispatcher: {};
17
- }
18
- export declare function isRuntimeAlive(): boolean;
19
- //# sourceMappingURL=NitroModulesTurboModule.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NitroModulesTurboModule.d.ts","sourceRoot":"","sources":["../../src/NitroModulesTurboModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAA;AAM7E,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAElD,OAAO,IAAI,IAAI,CAAA;IAEf,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAAA;IAC9C,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IACtC,uBAAuB,IAAI,MAAM,EAAE,CAAA;IAEnC,cAAc,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAA;IAC1C,iBAAiB,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI,CAAA;IAC1C,SAAS,EAAE,OAAO,GAAG,SAAS,CAAA;IAC9B,GAAG,CAAC,GAAG,EAAE,YAAY,GAAG,YAAY,CAAA;CACrC;AAGD,wBAAgB,qBAAqB,IAAI,eAAe,CAevD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,sBAAsB,EAAE,EAAE,CAAA;IAC9B,IAAI,iBAAiB,EAAE,EAAE,CAAA;CAC1B;AAED,wBAAgB,cAAc,YAI7B"}
@@ -1,2 +0,0 @@
1
- export declare function getNativeNitroModules(): never;
2
- //# sourceMappingURL=NitroModulesTurboModule.web.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NitroModulesTurboModule.web.d.ts","sourceRoot":"","sources":["../../src/NitroModulesTurboModule.web.ts"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,IAAI,KAAK,CAI7C"}
@@ -1,50 +0,0 @@
1
- import type { TurboModule } from 'react-native'
2
- import { TurboModuleRegistry } from 'react-native'
3
- import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes'
4
- import { ModuleNotFoundError } from './ModuleNotFoundError'
5
-
6
- // This TurboModule is *not* codegen'd.
7
- // It's handwritten, because otherwise the app's CMakeLists wants to build it.
8
- // Instead, we want to build it ourselves and have full control over the CMakeLists.
9
- export interface NativeNitroSpec extends TurboModule {
10
- // Set up
11
- install(): void
12
- // Hybrid Objects stuff
13
- createHybridObject(name: string): UnsafeObject
14
- hasHybridObject(name: string): boolean
15
- getAllHybridObjectNames(): string[]
16
- // JSI Helpers
17
- hasNativeState(obj: UnsafeObject): boolean
18
- removeNativeState(obj: UnsafeObject): void
19
- buildType: 'debug' | 'release'
20
- box(obj: UnsafeObject): UnsafeObject
21
- }
22
-
23
- let turboModule: NativeNitroSpec | undefined
24
- export function getNativeNitroModules(): NativeNitroSpec {
25
- if (turboModule == null) {
26
- try {
27
- // 1. Get (and initialize) the C++ TurboModule
28
- turboModule =
29
- TurboModuleRegistry.getEnforcing<NativeNitroSpec>('NitroModulesCxx')
30
-
31
- // 2. Install Dispatcher and required bindings into the Runtime
32
- turboModule.install()
33
- } catch (e) {
34
- throw new ModuleNotFoundError(e)
35
- }
36
- }
37
-
38
- return turboModule
39
- }
40
-
41
- declare global {
42
- var __nitroModulesJSICache: {}
43
- var __nitroDispatcher: {}
44
- }
45
-
46
- export function isRuntimeAlive() {
47
- const cache = global.__nitroModulesJSICache
48
- const dispatcher = global.__nitroDispatcher
49
- return cache != null && dispatcher != null
50
- }
@@ -1,7 +0,0 @@
1
- import { Platform } from 'react-native'
2
-
3
- export function getNativeNitroModules(): never {
4
- throw new Error(
5
- `Native NitroModules are not available on ${Platform.OS}! Make sure you're not calling getNativeNitroModules() in a ${Platform.OS} (.${Platform.OS}.ts) environment.`
6
- )
7
- }