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.
- package/NitroModules.podspec +4 -0
- package/README.md +2 -2
- package/android/CMakeLists.txt +3 -0
- package/android/build.gradle +27 -3
- package/android/src/main/cpp/JNIOnLoad.cpp +5 -5
- package/android/src/main/cpp/platform/NitroLogger.cpp +1 -1
- package/android/src/main/cpp/turbomodule/JNitroModules.cpp +41 -0
- package/android/src/main/cpp/turbomodule/JNitroModules.hpp +37 -0
- package/android/src/main/java/com/margelo/nitro/NitroModules.kt +69 -0
- package/android/src/main/java/com/margelo/nitro/NitroModulesPackage.kt +34 -0
- package/android/src/main/java/com/margelo/nitro/core/HybridObject.kt +6 -2
- package/android/src/newarch/NitroModulesSpec.kt +6 -0
- package/android/src/oldarch/NitroModulesSpec.kt +9 -0
- package/cpp/core/HybridFunction.hpp +13 -4
- package/cpp/entrypoint/HybridNitroModulesProxy.cpp +55 -0
- package/cpp/entrypoint/HybridNitroModulesProxy.hpp +48 -0
- package/cpp/entrypoint/InstallNitro.cpp +28 -0
- package/cpp/entrypoint/InstallNitro.hpp +41 -0
- package/cpp/jsi/JSIConverter+ArrayBuffer.hpp +6 -6
- package/cpp/jsi/JSIConverter+HostObject.hpp +73 -0
- package/cpp/jsi/JSIConverter+HybridObject.hpp +1 -1
- package/cpp/jsi/JSIConverter+Promise.hpp +1 -0
- package/cpp/jsi/JSIConverter+Tuple.hpp +2 -2
- package/cpp/jsi/JSIConverter.hpp +1 -0
- package/cpp/prototype/HybridObjectPrototype.cpp +4 -3
- package/cpp/threading/CallInvokerDispatcher.hpp +5 -0
- package/cpp/utils/NitroDefines.hpp +8 -0
- package/cpp/utils/TypeInfo.hpp +40 -20
- package/ios/core/ArrayBufferHolder.hpp +1 -1
- package/ios/core/HybridObjectSpec.swift +1 -1
- package/ios/platform/NitroLogger.mm +1 -2
- package/ios/turbomodule/NativeNitroModules+NewArch.mm +67 -0
- package/ios/turbomodule/NativeNitroModules+OldArch.mm +71 -0
- package/ios/turbomodule/NativeNitroModules.h +22 -0
- package/lib/BoxedHybridObject.d.ts +12 -0
- package/lib/BoxedHybridObject.js +1 -0
- package/lib/ModuleNotFoundError.js +3 -13
- package/lib/NitroModules.d.ts +1 -83
- package/lib/NitroModules.js +2 -94
- package/lib/NitroModulesProxy.d.ts +58 -0
- package/lib/NitroModulesProxy.js +1 -0
- package/lib/commonjs/BoxedHybridObject.js +6 -0
- package/lib/commonjs/BoxedHybridObject.js.map +1 -0
- package/lib/commonjs/ModuleNotFoundError.js +3 -15
- package/lib/commonjs/ModuleNotFoundError.js.map +1 -1
- package/lib/commonjs/NitroModules.js +11 -100
- package/lib/commonjs/NitroModules.js.map +1 -1
- package/lib/commonjs/NitroModulesProxy.js +6 -0
- package/lib/commonjs/NitroModulesProxy.js.map +1 -0
- package/lib/commonjs/turbomodule/NativeNitroModules.js +36 -0
- package/lib/commonjs/turbomodule/NativeNitroModules.js.map +1 -0
- package/lib/commonjs/turbomodule/NativeNitroModules.web.js +17 -0
- package/lib/commonjs/turbomodule/NativeNitroModules.web.js.map +1 -0
- package/lib/module/BoxedHybridObject.js +4 -0
- package/lib/module/BoxedHybridObject.js.map +1 -0
- package/lib/module/ModuleNotFoundError.js +3 -15
- package/lib/module/ModuleNotFoundError.js.map +1 -1
- package/lib/module/NitroModules.js +2 -100
- package/lib/module/NitroModules.js.map +1 -1
- package/lib/module/NitroModulesProxy.js +4 -0
- package/lib/module/NitroModulesProxy.js.map +1 -0
- package/lib/module/turbomodule/NativeNitroModules.js +31 -0
- package/lib/module/turbomodule/NativeNitroModules.js.map +1 -0
- package/lib/{NitroModulesTurboModule.web.js → module/turbomodule/NativeNitroModules.web.js} +9 -1
- package/lib/module/turbomodule/NativeNitroModules.web.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/turbomodule/NativeNitroModules.d.ts +7 -0
- package/lib/turbomodule/NativeNitroModules.js +27 -0
- package/lib/turbomodule/NativeNitroModules.web.d.ts +2 -0
- package/lib/turbomodule/NativeNitroModules.web.js +9 -0
- package/lib/typescript/AnyMap.d.ts +20 -0
- package/lib/typescript/BoxedHybridObject.d.ts +13 -0
- package/lib/typescript/BoxedHybridObject.d.ts.map +1 -0
- package/lib/typescript/ModuleNotFoundError.d.ts +7 -0
- package/lib/typescript/ModuleNotFoundError.d.ts.map +1 -1
- package/lib/typescript/NitroModules.d.ts +1 -83
- package/lib/typescript/NitroModules.d.ts.map +1 -1
- package/lib/typescript/NitroModulesProxy.d.ts +59 -0
- package/lib/typescript/NitroModulesProxy.d.ts.map +1 -0
- package/lib/typescript/__tests__/index.test.d.ts +1 -0
- package/lib/typescript/index.d.ts +4 -0
- package/lib/typescript/turbomodule/NativeNitroModules.d.ts +8 -0
- package/lib/typescript/turbomodule/NativeNitroModules.d.ts.map +1 -0
- package/lib/typescript/turbomodule/NativeNitroModules.web.d.ts +3 -0
- package/lib/typescript/turbomodule/NativeNitroModules.web.d.ts.map +1 -0
- package/package.json +10 -3
- package/src/BoxedHybridObject.ts +13 -0
- package/src/ModuleNotFoundError.ts +3 -19
- package/src/NitroModules.ts +2 -108
- package/src/NitroModulesProxy.ts +61 -0
- package/src/turbomodule/NativeNitroModules.ts +48 -0
- package/src/turbomodule/NativeNitroModules.web.ts +16 -0
- package/android/src/main/java/com/margelo/nitro/NitroModulesPackage.java +0 -30
- package/cpp/turbomodule/NativeNitroModules.cpp +0 -146
- package/cpp/turbomodule/NativeNitroModules.h +0 -8
- package/cpp/turbomodule/NativeNitroModules.hpp +0 -38
- package/cpp/turbomodule/RegisterNativeNitroModules.cpp +0 -33
- package/cpp/turbomodule/RegisterNativeNitroModules.hpp +0 -21
- package/ios/turbomodule/NitroModuleOnLoad.mm +0 -32
- package/lib/NativeNitroModules.d.ts +0 -16
- package/lib/NativeNitroModules.js +0 -22
- package/lib/NativeNitroModules.web.d.ts +0 -4
- package/lib/NativeNitroModules.web.js +0 -3
- package/lib/NitroModulesTurboModule.d.ts +0 -18
- package/lib/NitroModulesTurboModule.js +0 -23
- package/lib/NitroModulesTurboModule.web.d.ts +0 -1
- package/lib/commonjs/NitroModulesTurboModule.js +0 -34
- package/lib/commonjs/NitroModulesTurboModule.js.map +0 -1
- package/lib/commonjs/NitroModulesTurboModule.web.js +0 -11
- package/lib/commonjs/NitroModulesTurboModule.web.js.map +0 -1
- package/lib/module/NitroModulesTurboModule.js +0 -30
- package/lib/module/NitroModulesTurboModule.js.map +0 -1
- package/lib/module/NitroModulesTurboModule.web.js +0 -7
- package/lib/module/NitroModulesTurboModule.web.js.map +0 -1
- package/lib/typescript/NitroModulesTurboModule.d.ts +0 -19
- package/lib/typescript/NitroModulesTurboModule.d.ts.map +0 -1
- package/lib/typescript/NitroModulesTurboModule.web.d.ts +0 -2
- package/lib/typescript/NitroModulesTurboModule.web.d.ts.map +0 -1
- package/src/NitroModulesTurboModule.ts +0 -50
- 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,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,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 +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
|
-
}
|