react-native-nitro-modules 0.3.0 → 0.4.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.
- package/NitroModules.podspec +2 -1
- package/README.md +31 -0
- package/android/CMakeLists.txt +4 -4
- package/android/gradle.properties +1 -1
- package/android/src/main/cpp/JNIOnLoad.cpp +7 -6
- package/android/src/main/java/com/margelo/nitro/HybridObject.kt +0 -11
- package/android/src/main/java/com/margelo/nitro/HybridObjectRegistry.java +2 -13
- package/android/src/main/java/com/margelo/nitro/NitroModulesPackage.java +12 -0
- package/cpp/core/AnyMap.hpp +12 -0
- package/cpp/core/ArrayBuffer.cpp +88 -0
- package/cpp/core/ArrayBuffer.hpp +29 -75
- package/cpp/jsi/JSICache.cpp +1 -3
- package/cpp/jsi/JSIConverter+Promise.hpp +2 -2
- package/cpp/jsi/{Promise.cpp → JSPromise.cpp} +6 -6
- package/cpp/jsi/{Promise.hpp → JSPromise.hpp} +10 -10
- package/cpp/registry/HybridObjectRegistry.cpp +13 -0
- package/cpp/registry/HybridObjectRegistry.hpp +4 -2
- package/cpp/turbomodule/NativeNitroModules.cpp +38 -2
- package/cpp/turbomodule/NativeNitroModules.hpp +2 -0
- package/cpp/utils/NitroDefines.hpp +6 -0
- package/ios/core/ArrayBuffer.swift +51 -0
- package/ios/core/ArrayBufferHolder.hpp +69 -0
- package/ios/core/ClosureWrapper.swift +25 -0
- package/ios/core/Promise.cpp +10 -0
- package/ios/core/Promise.hpp +43 -0
- package/ios/platform/ThreadUtils.cpp +1 -0
- package/lib/NativeNitroModules.d.ts +2 -0
- package/lib/NitroModules.d.ts +9 -1
- package/lib/NitroModules.js +15 -1
- package/lib/commonjs/NativeNitroModules.js.map +1 -1
- package/lib/commonjs/NitroModules.js +15 -1
- package/lib/commonjs/NitroModules.js.map +1 -1
- package/lib/module/NativeNitroModules.js.map +1 -1
- package/lib/module/NitroModules.js +15 -1
- package/lib/module/NitroModules.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/typescript/NativeNitroModules.d.ts +2 -0
- package/lib/typescript/NativeNitroModules.d.ts.map +1 -1
- package/lib/typescript/NitroModules.d.ts +9 -1
- package/lib/typescript/NitroModules.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/NativeNitroModules.ts +2 -0
- package/src/NitroModules.ts +15 -1
- package/lib/typescript/AnyMap.d.ts +0 -17
- package/lib/typescript/HybridObject.d.ts +0 -83
- package/lib/typescript/ModuleNotFoundError.d.ts +0 -7
- package/lib/typescript/NativeNitroModules.web.d.ts +0 -5
- package/lib/typescript/__tests__/index.test.d.ts +0 -1
- package/lib/typescript/index.d.ts +0 -4
|
@@ -15,7 +15,7 @@ namespace margelo::nitro {
|
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* A registry that holds initializers for HybridObjects.
|
|
18
|
-
* This will be used to initialize them from JS using `NitroModules.
|
|
18
|
+
* This will be used to initialize them from JS using `NitroModules.createHybridObject<T>(name)`.
|
|
19
19
|
*/
|
|
20
20
|
class HybridObjectRegistry {
|
|
21
21
|
public:
|
|
@@ -28,11 +28,13 @@ public:
|
|
|
28
28
|
/**
|
|
29
29
|
* Registers the given HybridObject in the `HybridObjectRegistry`.
|
|
30
30
|
* It will be uniquely identified via it's `hybridObjectName`, and can be initialized from
|
|
31
|
-
* JS using `NitroModules.
|
|
31
|
+
* JS using `NitroModules.createHybridObject<T>(name)` - which will call the `constructorFn` here.
|
|
32
32
|
*/
|
|
33
33
|
static void registerHybridObjectConstructor(const std::string& hybridObjectName, HybridObjectConstructorFn&& constructorFn);
|
|
34
34
|
|
|
35
35
|
static std::shared_ptr<HybridObject> createHybridObject(const std::string& hybridObjectName);
|
|
36
|
+
static bool hasHybridObject(const std::string& hybridObjectName);
|
|
37
|
+
static std::vector<std::string> getAllHybridObjectNames();
|
|
36
38
|
|
|
37
39
|
private:
|
|
38
40
|
static std::unordered_map<std::string, HybridObjectConstructorFn>& getRegistry();
|
|
@@ -32,12 +32,14 @@ jsi::Value NativeNitroModules::get(jsi::Runtime& runtime, const jsi::PropNameID&
|
|
|
32
32
|
}
|
|
33
33
|
if (name == "createHybridObject") {
|
|
34
34
|
return jsi::Function::createFromHostFunction(
|
|
35
|
-
runtime, jsi::PropNameID::forUtf8(runtime, "
|
|
35
|
+
runtime, jsi::PropNameID::forUtf8(runtime, "createHybridObject"), 2,
|
|
36
36
|
[=](jsi::Runtime& runtime, const jsi::Value& thisArg, const jsi::Value* args, size_t count) -> jsi::Value {
|
|
37
|
-
|
|
37
|
+
#if DEBUG
|
|
38
|
+
if (count != 1 && count != 2) [[unlikely]] {
|
|
38
39
|
throw jsi::JSError(runtime, "NitroModules.createHybridObject(..) expects 1 or 2 arguments, but " + std::to_string(count) +
|
|
39
40
|
" were supplied!");
|
|
40
41
|
}
|
|
42
|
+
#endif
|
|
41
43
|
jsi::String objectName = args[0].asString(runtime);
|
|
42
44
|
std::optional<jsi::Object> optionalArgs = std::nullopt;
|
|
43
45
|
if (count > 1) {
|
|
@@ -47,6 +49,25 @@ jsi::Value NativeNitroModules::get(jsi::Runtime& runtime, const jsi::PropNameID&
|
|
|
47
49
|
return createHybridObject(runtime, objectName, optionalArgs);
|
|
48
50
|
});
|
|
49
51
|
}
|
|
52
|
+
if (name == "hasHybridObject") {
|
|
53
|
+
return jsi::Function::createFromHostFunction(
|
|
54
|
+
runtime, jsi::PropNameID::forUtf8(runtime, "hasHybridObject"), 1,
|
|
55
|
+
[=](jsi::Runtime& runtime, const jsi::Value& thisArg, const jsi::Value* args, size_t count) -> jsi::Value {
|
|
56
|
+
#if DEBUG
|
|
57
|
+
if (count != 1) [[unlikely]] {
|
|
58
|
+
throw jsi::JSError(runtime,
|
|
59
|
+
"NitroModules.hasHybridObject(..) expects 1 argument (name), but received " + std::to_string(count) + "!");
|
|
60
|
+
}
|
|
61
|
+
#endif
|
|
62
|
+
jsi::String objectName = args[0].asString(runtime);
|
|
63
|
+
return hasHybridObject(runtime, objectName);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (name == "getAllHybridObjectNames") {
|
|
67
|
+
return jsi::Function::createFromHostFunction(runtime, jsi::PropNameID::forUtf8(runtime, "getAllHybridObjectNames"), 0,
|
|
68
|
+
[=](jsi::Runtime& runtime, const jsi::Value& thisArg, const jsi::Value* args,
|
|
69
|
+
size_t count) -> jsi::Value { return getAllHybridObjectNames(runtime); });
|
|
70
|
+
}
|
|
50
71
|
|
|
51
72
|
return jsi::Value::undefined();
|
|
52
73
|
}
|
|
@@ -66,4 +87,19 @@ jsi::Value NativeNitroModules::createHybridObject(jsi::Runtime& runtime, const j
|
|
|
66
87
|
return hybridObject->toObject(runtime);
|
|
67
88
|
}
|
|
68
89
|
|
|
90
|
+
jsi::Value NativeNitroModules::hasHybridObject(jsi::Runtime& runtime, const jsi::String& hybridObjectName) {
|
|
91
|
+
std::string name = hybridObjectName.utf8(runtime);
|
|
92
|
+
bool exists = HybridObjectRegistry::hasHybridObject(name);
|
|
93
|
+
return exists;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
jsi::Value NativeNitroModules::getAllHybridObjectNames(jsi::Runtime& runtime) {
|
|
97
|
+
std::vector<std::string> keys = HybridObjectRegistry::getAllHybridObjectNames();
|
|
98
|
+
jsi::Array array(runtime, keys.size());
|
|
99
|
+
for (size_t i = 0; i < keys.size(); i++) {
|
|
100
|
+
array.setValueAtIndex(runtime, i, jsi::String::createFromUtf8(runtime, keys[i]));
|
|
101
|
+
}
|
|
102
|
+
return array;
|
|
103
|
+
}
|
|
104
|
+
|
|
69
105
|
} // namespace facebook::react
|
|
@@ -24,6 +24,8 @@ public:
|
|
|
24
24
|
|
|
25
25
|
void install(jsi::Runtime& runtime);
|
|
26
26
|
jsi::Value createHybridObject(jsi::Runtime& runtime, const jsi::String& hybridObjectName, const std::optional<jsi::Object>& args);
|
|
27
|
+
jsi::Value hasHybridObject(jsi::Runtime& runtime, const jsi::String& hybridObjectName);
|
|
28
|
+
jsi::Value getAllHybridObjectNames(jsi::Runtime& runtime);
|
|
27
29
|
|
|
28
30
|
public:
|
|
29
31
|
constexpr static auto kModuleName = "NitroModulesCxx";
|
|
@@ -18,8 +18,14 @@
|
|
|
18
18
|
#if _CXX_INTEROP_HAS_ATTRIBUTE(swift_attr)
|
|
19
19
|
// Rename Type for Swift
|
|
20
20
|
#define SWIFT_NAME(_name) __attribute__((swift_name(#_name)))
|
|
21
|
+
// Make Swift type private
|
|
22
|
+
#define SWIFT_PRIVATE __attribute__((swift_private))
|
|
23
|
+
// Make getter + setter a computed property
|
|
24
|
+
#define SWIFT_COMPUTED_PROPERTY __attribute__((swift_attr("import_computed_property")))
|
|
21
25
|
#else
|
|
22
26
|
#define SWIFT_NAME(_name)
|
|
27
|
+
#define SWIFT_PRIVATE
|
|
28
|
+
#define SWIFT_COMPUTED_PROPERTY
|
|
23
29
|
#endif
|
|
24
30
|
|
|
25
31
|
#if _CXX_INTEROP_HAS_ATTRIBUTE(enum_extensibility)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//
|
|
2
|
+
// ArrayBuffer.swift
|
|
3
|
+
// NitroModules
|
|
4
|
+
//
|
|
5
|
+
// Created by Marc Rousavy on 17.07.24.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
public typealias ArrayBufferHolder = margelo.nitro.ArrayBufferHolder
|
|
11
|
+
|
|
12
|
+
public extension ArrayBufferHolder {
|
|
13
|
+
/**
|
|
14
|
+
* Create a new `ArrayBufferHolder` that wraps the given `data` of the given `size`
|
|
15
|
+
* without performing a copy.
|
|
16
|
+
* When the `ArrayBuffer` is no longer used, `onDelete` will be called, in which
|
|
17
|
+
* you as a caller are responsible for deleting `data`.
|
|
18
|
+
*/
|
|
19
|
+
static func wrap(wrappingDataWithoutCopy data: UnsafeMutablePointer<UInt8>,
|
|
20
|
+
size: Int,
|
|
21
|
+
onDelete delete: @escaping () -> Void) -> ArrayBufferHolder {
|
|
22
|
+
// Convert escaping Swift closure to a `void*`
|
|
23
|
+
let wrapper = ClosureWrapper(closure: delete)
|
|
24
|
+
let wrappedClosure = Unmanaged.passRetained(wrapper).toOpaque()
|
|
25
|
+
|
|
26
|
+
return ArrayBufferHolder.makeBuffer(data, size, { context in
|
|
27
|
+
guard let context else {
|
|
28
|
+
fatalError("Context was null, even though we created one!")
|
|
29
|
+
}
|
|
30
|
+
// Convert `void*` to a Swift closure
|
|
31
|
+
let closure = Unmanaged<ClosureWrapper>.fromOpaque(context).takeRetainedValue()
|
|
32
|
+
// Call it (deleteFunc)
|
|
33
|
+
closure.invoke()
|
|
34
|
+
}, wrappedClosure)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Allocate a new buffer of the given `size`.
|
|
39
|
+
* If `initializeToZero` is `true`, all bytes are set to `0`, otherwise they are left untouched.
|
|
40
|
+
*/
|
|
41
|
+
static func allocate(size: Int, initializeToZero: Bool = false) -> ArrayBufferHolder {
|
|
42
|
+
let data = UnsafeMutablePointer<UInt8>.allocate(capacity: size)
|
|
43
|
+
if initializeToZero {
|
|
44
|
+
data.initialize(repeating: 0, count: size)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return ArrayBufferHolder.makeBuffer(data, size, { data in
|
|
48
|
+
data?.deallocate()
|
|
49
|
+
}, data)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
//
|
|
2
|
+
// ArrayBufferHolder.hpp
|
|
3
|
+
// react-native-nitro
|
|
4
|
+
//
|
|
5
|
+
// Created by Marc Rousavy on 14.08.24.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "ArrayBuffer.hpp"
|
|
11
|
+
#include "NitroDefines.hpp"
|
|
12
|
+
#include <memory>
|
|
13
|
+
|
|
14
|
+
namespace margelo::nitro {
|
|
15
|
+
|
|
16
|
+
using namespace facebook;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Holds instances of `std::shared_ptr<ArrayBuffer>`.
|
|
20
|
+
* The reason this exists is because we cannot directly use `shared_ptr`,
|
|
21
|
+
* nor virtual functions (`jsi::MutableBuffer`) in Swift.
|
|
22
|
+
*
|
|
23
|
+
* Passing around instances of `ArrayBufferHolder` (or `std::shared_ptr<ArrayBuffer>`)
|
|
24
|
+
* does not involve any data copies and is almost zero-overhead - even when passed to JS.
|
|
25
|
+
*/
|
|
26
|
+
class ArrayBufferHolder {
|
|
27
|
+
public:
|
|
28
|
+
ArrayBufferHolder(const std::shared_ptr<ArrayBuffer>& arrayBuffer) : _arrayBuffer(arrayBuffer) {}
|
|
29
|
+
|
|
30
|
+
public:
|
|
31
|
+
/**
|
|
32
|
+
* Create a new `NativeArrayBuffer` that wraps the given data of the given size, without copying it.
|
|
33
|
+
*
|
|
34
|
+
* Once the `ArrayBuffer` is no longer in use, the given `deleteFunc` will be called with the given `deleteFuncContext`
|
|
35
|
+
* as an argument. The caller is responsible for deleting `data` (and `deleteFuncContext`) once this is called.
|
|
36
|
+
*/
|
|
37
|
+
static ArrayBufferHolder makeBuffer(uint8_t* data, size_t size, DeleteFn deleteFunc, void* deleteFuncContext) {
|
|
38
|
+
auto arrayBuffer = ArrayBuffer::makeBuffer(data, size, deleteFunc, deleteFuncContext);
|
|
39
|
+
return ArrayBufferHolder(arrayBuffer);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public:
|
|
43
|
+
/**
|
|
44
|
+
* Gets the raw bytes the underlying `ArrayBuffer` points to.
|
|
45
|
+
*/
|
|
46
|
+
void* getData() const SWIFT_COMPUTED_PROPERTY {
|
|
47
|
+
return _arrayBuffer->data();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Gets the size of the raw bytes the underlying `ArrayBuffer` points to.
|
|
51
|
+
*/
|
|
52
|
+
size_t getSize() const SWIFT_COMPUTED_PROPERTY {
|
|
53
|
+
return _arrayBuffer->size();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
bool isOwner() const SWIFT_COMPUTED_PROPERTY {
|
|
57
|
+
return _arrayBuffer->isOwner();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public:
|
|
61
|
+
inline std::shared_ptr<ArrayBuffer> getArrayBuffer() const {
|
|
62
|
+
return _arrayBuffer;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private:
|
|
66
|
+
std::shared_ptr<ArrayBuffer> _arrayBuffer;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//
|
|
2
|
+
// ClosureWrapper.swift
|
|
3
|
+
// NitroModules
|
|
4
|
+
//
|
|
5
|
+
// Created by Marc Rousavy on 14.08.24.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a closure in a Swift class.
|
|
12
|
+
* This can be used to create unmanaged pointers (`void*`) and
|
|
13
|
+
* passed to C-style function pointers via `void* context` parameters.
|
|
14
|
+
*/
|
|
15
|
+
final class ClosureWrapper {
|
|
16
|
+
let closure: () -> Void
|
|
17
|
+
|
|
18
|
+
init(closure: @escaping () -> Void) {
|
|
19
|
+
self.closure = closure
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
func invoke() {
|
|
23
|
+
closure()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Promise.hpp
|
|
3
|
+
// NitroModules
|
|
4
|
+
//
|
|
5
|
+
// Created by Marc Rousavy on 11.08.24.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <future>
|
|
11
|
+
#include <memory>
|
|
12
|
+
#include <string>
|
|
13
|
+
|
|
14
|
+
namespace margelo::nitro {
|
|
15
|
+
|
|
16
|
+
class Promise {
|
|
17
|
+
public:
|
|
18
|
+
Promise(const Promise&) = delete;
|
|
19
|
+
Promise(Promise&&) = delete;
|
|
20
|
+
|
|
21
|
+
public:
|
|
22
|
+
void reject(const std::string& message) {
|
|
23
|
+
// TODO: reject()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
void resolve(int result) {
|
|
27
|
+
// TODO: resolve()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private:
|
|
31
|
+
explicit Promise() {
|
|
32
|
+
// TODO: Init? From Future?
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
static std::shared_ptr<Promise> run(void (*run)(std::shared_ptr<Promise> promise)) {
|
|
37
|
+
auto promise = std::shared_ptr<Promise>(new Promise());
|
|
38
|
+
run(promise);
|
|
39
|
+
return promise;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
} // namespace margelo::nitro
|
|
@@ -3,6 +3,8 @@ import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
|
|
|
3
3
|
export interface Spec extends TurboModule {
|
|
4
4
|
install(): void;
|
|
5
5
|
createHybridObject(name: string, args?: UnsafeObject): UnsafeObject;
|
|
6
|
+
hasHybridObject(name: string): boolean;
|
|
7
|
+
getAllHybridObjectNames(): string[];
|
|
6
8
|
}
|
|
7
9
|
export declare function getNativeNitroModules(): Spec;
|
|
8
10
|
declare global {
|
package/lib/NitroModules.d.ts
CHANGED
|
@@ -13,5 +13,13 @@ export declare const NitroModules: {
|
|
|
13
13
|
* @returns An instance of {@linkcode T}
|
|
14
14
|
* @throws an Error if {@linkcode T} has not been registered under the name {@linkcode name}.
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
createHybridObject<T extends HybridObject<any>>(name: string): T;
|
|
17
|
+
/**
|
|
18
|
+
* Get a list of all registered Hybrid Objects.
|
|
19
|
+
*/
|
|
20
|
+
getAllHybridObjectNames(): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Returns whether a HybridObject under the given {@linkcode name} is registered, or not.
|
|
23
|
+
*/
|
|
24
|
+
hasHybridObject(name: string): boolean;
|
|
17
25
|
};
|
package/lib/NitroModules.js
CHANGED
|
@@ -13,9 +13,23 @@ export const NitroModules = {
|
|
|
13
13
|
* @returns An instance of {@linkcode T}
|
|
14
14
|
* @throws an Error if {@linkcode T} has not been registered under the name {@linkcode name}.
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
createHybridObject(name) {
|
|
17
17
|
const nitro = getNativeNitroModules();
|
|
18
18
|
const instance = nitro.createHybridObject(name);
|
|
19
19
|
return instance;
|
|
20
20
|
},
|
|
21
|
+
/**
|
|
22
|
+
* Get a list of all registered Hybrid Objects.
|
|
23
|
+
*/
|
|
24
|
+
getAllHybridObjectNames() {
|
|
25
|
+
const nitro = getNativeNitroModules();
|
|
26
|
+
return nitro.getAllHybridObjectNames();
|
|
27
|
+
},
|
|
28
|
+
/**
|
|
29
|
+
* Returns whether a HybridObject under the given {@linkcode name} is registered, or not.
|
|
30
|
+
*/
|
|
31
|
+
hasHybridObject(name) {
|
|
32
|
+
const nitro = getNativeNitroModules();
|
|
33
|
+
return nitro.hasHybridObject(name);
|
|
34
|
+
},
|
|
21
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_ModuleNotFoundError","turboModule","getNativeNitroModules","TurboModuleRegistry","getEnforcing","install","e","ModuleNotFoundError","isRuntimeAlive","cache","global","__nitroModulesJSICache","dispatcher","__nitroDispatcher"],"sourceRoot":"../../src","sources":["NativeNitroModules.ts"],"mappings":";;;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,oBAAA,GAAAD,OAAA;
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_ModuleNotFoundError","turboModule","getNativeNitroModules","TurboModuleRegistry","getEnforcing","install","e","ModuleNotFoundError","isRuntimeAlive","cache","global","__nitroModulesJSICache","dispatcher","__nitroDispatcher"],"sourceRoot":"../../src","sources":["NativeNitroModules.ts"],"mappings":";;;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,oBAAA,GAAAD,OAAA;AASA,IAAIE,WAA6B;AAC1B,SAASC,qBAAqBA,CAAA,EAAS;EAC5C,IAAID,WAAW,IAAI,IAAI,EAAE;IACvB,IAAI;MACF;MACAA,WAAW,GAAGE,gCAAmB,CAACC,YAAY,CAAO,iBAAiB,CAAC;;MAEvE;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":[]}
|
|
@@ -23,10 +23,24 @@ const NitroModules = exports.NitroModules = {
|
|
|
23
23
|
* @returns An instance of {@linkcode T}
|
|
24
24
|
* @throws an Error if {@linkcode T} has not been registered under the name {@linkcode name}.
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
createHybridObject(name) {
|
|
27
27
|
const nitro = (0, _NativeNitroModules.getNativeNitroModules)();
|
|
28
28
|
const instance = nitro.createHybridObject(name);
|
|
29
29
|
return instance;
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* Get a list of all registered Hybrid Objects.
|
|
33
|
+
*/
|
|
34
|
+
getAllHybridObjectNames() {
|
|
35
|
+
const nitro = (0, _NativeNitroModules.getNativeNitroModules)();
|
|
36
|
+
return nitro.getAllHybridObjectNames();
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* Returns whether a HybridObject under the given {@linkcode name} is registered, or not.
|
|
40
|
+
*/
|
|
41
|
+
hasHybridObject(name) {
|
|
42
|
+
const nitro = (0, _NativeNitroModules.getNativeNitroModules)();
|
|
43
|
+
return nitro.hasHybridObject(name);
|
|
30
44
|
}
|
|
31
45
|
};
|
|
32
46
|
//# sourceMappingURL=NitroModules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_NativeNitroModules","require","NitroModules","exports","
|
|
1
|
+
{"version":3,"names":["_NativeNitroModules","require","NitroModules","exports","createHybridObject","name","nitro","getNativeNitroModules","instance","getAllHybridObjectNames","hasHybridObject"],"sourceRoot":"../../src","sources":["NitroModules.ts"],"mappings":";;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACO,MAAMC,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG;EAC1B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEE,kBAAkBA,CAA8BC,IAAY,EAAK;IAC/D,MAAMC,KAAK,GAAG,IAAAC,yCAAqB,EAAC,CAAC;IACrC,MAAMC,QAAQ,GAAGF,KAAK,CAACF,kBAAkB,CAACC,IAAI,CAAC;IAC/C,OAAOG,QAAQ;EACjB,CAAC;EACD;AACF;AACA;EACEC,uBAAuBA,CAAA,EAAa;IAClC,MAAMH,KAAK,GAAG,IAAAC,yCAAqB,EAAC,CAAC;IACrC,OAAOD,KAAK,CAACG,uBAAuB,CAAC,CAAC;EACxC,CAAC;EACD;AACF;AACA;EACEC,eAAeA,CAACL,IAAY,EAAW;IACrC,MAAMC,KAAK,GAAG,IAAAC,yCAAqB,EAAC,CAAC;IACrC,OAAOD,KAAK,CAACI,eAAe,CAACL,IAAI,CAAC;EACpC;AACF,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","ModuleNotFoundError","turboModule","getNativeNitroModules","getEnforcing","install","e","isRuntimeAlive","cache","global","__nitroModulesJSICache","dispatcher","__nitroDispatcher"],"sourceRoot":"../../src","sources":["NativeNitroModules.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;AAElD,SAASC,mBAAmB,QAAQ,uBAAuB;
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","ModuleNotFoundError","turboModule","getNativeNitroModules","getEnforcing","install","e","isRuntimeAlive","cache","global","__nitroModulesJSICache","dispatcher","__nitroDispatcher"],"sourceRoot":"../../src","sources":["NativeNitroModules.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;AAElD,SAASC,mBAAmB,QAAQ,uBAAuB;AAS3D,IAAIC,WAA6B;AACjC,OAAO,SAASC,qBAAqBA,CAAA,EAAS;EAC5C,IAAID,WAAW,IAAI,IAAI,EAAE;IACvB,IAAI;MACF;MACAA,WAAW,GAAGF,mBAAmB,CAACI,YAAY,CAAO,iBAAiB,CAAC;;MAEvE;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":[]}
|
|
@@ -18,10 +18,24 @@ export const NitroModules = {
|
|
|
18
18
|
* @returns An instance of {@linkcode T}
|
|
19
19
|
* @throws an Error if {@linkcode T} has not been registered under the name {@linkcode name}.
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
createHybridObject(name) {
|
|
22
22
|
const nitro = getNativeNitroModules();
|
|
23
23
|
const instance = nitro.createHybridObject(name);
|
|
24
24
|
return instance;
|
|
25
|
+
},
|
|
26
|
+
/**
|
|
27
|
+
* Get a list of all registered Hybrid Objects.
|
|
28
|
+
*/
|
|
29
|
+
getAllHybridObjectNames() {
|
|
30
|
+
const nitro = getNativeNitroModules();
|
|
31
|
+
return nitro.getAllHybridObjectNames();
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* Returns whether a HybridObject under the given {@linkcode name} is registered, or not.
|
|
35
|
+
*/
|
|
36
|
+
hasHybridObject(name) {
|
|
37
|
+
const nitro = getNativeNitroModules();
|
|
38
|
+
return nitro.hasHybridObject(name);
|
|
25
39
|
}
|
|
26
40
|
};
|
|
27
41
|
//# sourceMappingURL=NitroModules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getNativeNitroModules","NitroModules","
|
|
1
|
+
{"version":3,"names":["getNativeNitroModules","NitroModules","createHybridObject","name","nitro","instance","getAllHybridObjectNames","hasHybridObject"],"sourceRoot":"../../src","sources":["NitroModules.ts"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,sBAAsB;;AAG5D;AACA;AACA;;AAKA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GAAG;EAC1B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,kBAAkBA,CAA8BC,IAAY,EAAK;IAC/D,MAAMC,KAAK,GAAGJ,qBAAqB,CAAC,CAAC;IACrC,MAAMK,QAAQ,GAAGD,KAAK,CAACF,kBAAkB,CAACC,IAAI,CAAC;IAC/C,OAAOE,QAAQ;EACjB,CAAC;EACD;AACF;AACA;EACEC,uBAAuBA,CAAA,EAAa;IAClC,MAAMF,KAAK,GAAGJ,qBAAqB,CAAC,CAAC;IACrC,OAAOI,KAAK,CAACE,uBAAuB,CAAC,CAAC;EACxC,CAAC;EACD;AACF;AACA;EACEC,eAAeA,CAACJ,IAAY,EAAW;IACrC,MAAMC,KAAK,GAAGJ,qBAAqB,CAAC,CAAC;IACrC,OAAOI,KAAK,CAACG,eAAe,CAACJ,IAAI,CAAC;EACpC;AACF,CAAC","ignoreList":[]}
|