react-native-nitro-modules 0.22.0 → 0.23.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/android/build.gradle +1 -1
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/margelo/nitro/views/HybridView.kt +11 -0
- package/cpp/core/ArrayBuffer.cpp +2 -2
- package/cpp/core/ArrayBuffer.hpp +3 -3
- package/cpp/core/HybridFunction.hpp +3 -0
- package/cpp/core/HybridObject.hpp +1 -1
- package/cpp/core/Promise.hpp +3 -3
- package/cpp/jsi/JSICache.cpp +4 -4
- package/cpp/jsi/JSICache.hpp +18 -18
- package/cpp/jsi/JSIConverter+Function.hpp +3 -2
- package/cpp/prototype/HybridObjectPrototype.cpp +2 -2
- package/cpp/prototype/HybridObjectPrototype.hpp +2 -2
- package/cpp/registry/HybridObjectRegistry.cpp +3 -0
- package/cpp/utils/BorrowingReference.hpp +161 -54
- package/cpp/utils/NitroDefines.hpp +1 -11
- package/cpp/utils/OwningLock.hpp +14 -14
- package/cpp/utils/ReferenceState.hpp +40 -0
- package/cpp/utils/WeakReference+Owning.hpp +33 -0
- package/cpp/utils/WeakReference.hpp +102 -0
- package/cpp/views/CachedProp.hpp +3 -3
- package/ios/core/AnyMapHolder.swift +8 -8
- package/ios/turbomodule/NativeNitroModules+NewArch.mm +1 -1
- package/lib/commonjs/index.js +11 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/views/HybridView.js +0 -11
- package/lib/commonjs/views/HybridView.js.map +1 -1
- package/lib/commonjs/views/getHostComponent.js +20 -1
- package/lib/commonjs/views/getHostComponent.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/views/HybridView.js +0 -26
- package/lib/module/views/HybridView.js.map +1 -1
- package/lib/module/views/getHostComponent.js +21 -1
- package/lib/module/views/getHostComponent.js.map +1 -1
- package/lib/tsconfig.build.tsbuildinfo +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/views/HybridView.d.ts +89 -16
- package/lib/typescript/views/HybridView.d.ts.map +1 -1
- package/lib/typescript/views/getHostComponent.d.ts +46 -3
- package/lib/typescript/views/getHostComponent.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +2 -0
- package/src/views/HybridView.ts +96 -18
- package/src/views/getHostComponent.ts +67 -5
- package/cpp/utils/BorrowingReference+Owning.hpp +0 -36
- package/cpp/utils/OwningReference.hpp +0 -250
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//
|
|
2
|
+
// ReferenceState.hpp
|
|
3
|
+
// react-native-nitro
|
|
4
|
+
//
|
|
5
|
+
// Created by Marc Rousavy on 03.02.24.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <atomic>
|
|
11
|
+
#include <mutex>
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro {
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Holds state for an `BorrowingReference` (or `WeakReference`).
|
|
17
|
+
*
|
|
18
|
+
* The state tracks the amount of strong- and weak- references to any kind of value,
|
|
19
|
+
* including an extra `isDeleted` flag that specifies whether the value has been force-deleted.
|
|
20
|
+
*
|
|
21
|
+
* Also, a `mutex` allows for thread-safe access of the `isDeleted` flag.
|
|
22
|
+
*/
|
|
23
|
+
struct ReferenceState {
|
|
24
|
+
std::atomic_size_t strongRefCount;
|
|
25
|
+
std::atomic_size_t weakRefCount;
|
|
26
|
+
bool isDeleted;
|
|
27
|
+
std::mutex mutex;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Decrements the strong ref count by one, and returns whether the value should be deleted.
|
|
31
|
+
*/
|
|
32
|
+
inline bool decrementStrongRefCount() {
|
|
33
|
+
size_t oldRefCount = strongRefCount.fetch_sub(1);
|
|
34
|
+
return oldRefCount <= 1;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
explicit ReferenceState() : strongRefCount(1), weakRefCount(0), isDeleted(false) {}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// WeakReference+Owning.hpp
|
|
3
|
+
// react-native-nitro
|
|
4
|
+
//
|
|
5
|
+
// Created by Marc Rousavy on 23.06.24.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "BorrowingReference.hpp"
|
|
11
|
+
|
|
12
|
+
namespace margelo::nitro {
|
|
13
|
+
|
|
14
|
+
template <typename T>
|
|
15
|
+
WeakReference<T>::WeakReference(const BorrowingReference<T>& ref) {
|
|
16
|
+
_value = ref._value;
|
|
17
|
+
_state = ref._state;
|
|
18
|
+
_state->weakRefCount++;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
template <typename T>
|
|
22
|
+
BorrowingReference<T> WeakReference<T>::lock() const {
|
|
23
|
+
std::unique_lock lock(_state->mutex);
|
|
24
|
+
|
|
25
|
+
if (_state->isDeleted) {
|
|
26
|
+
// return nullptr
|
|
27
|
+
return BorrowingReference<T>();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return BorrowingReference(*this);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
//
|
|
2
|
+
// WeakReference.hpp
|
|
3
|
+
// NitroModules
|
|
4
|
+
//
|
|
5
|
+
// Created by Marc Rousavy on 21.06.24.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "ReferenceState.hpp"
|
|
11
|
+
#include <atomic>
|
|
12
|
+
#include <cstddef>
|
|
13
|
+
#include <mutex>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro {
|
|
16
|
+
|
|
17
|
+
// forward-declaration to avoid duplicate symbols
|
|
18
|
+
template <typename T>
|
|
19
|
+
class BorrowingReference;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
A `WeakReference<T>` is a weak reference to a pointer created by `BorrowingReference<T>`.
|
|
23
|
+
It can be locked to gain a strong `BorrowingReference<T>` again if it has not been deleted yet.
|
|
24
|
+
*/
|
|
25
|
+
template <typename T>
|
|
26
|
+
class WeakReference final {
|
|
27
|
+
private:
|
|
28
|
+
explicit WeakReference(const BorrowingReference<T>& ref);
|
|
29
|
+
|
|
30
|
+
public:
|
|
31
|
+
WeakReference() : _value(nullptr), _state(nullptr) {}
|
|
32
|
+
|
|
33
|
+
WeakReference(const WeakReference& ref) : _value(ref._value), _state(ref._state) {
|
|
34
|
+
if (_state != nullptr) {
|
|
35
|
+
// increment ref count after copy
|
|
36
|
+
_state->weakRefCount++;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
WeakReference(WeakReference&& ref) : _value(ref._value), _state(ref._state) {
|
|
41
|
+
// Remove state from other WeakReference after moving since it's now stale data
|
|
42
|
+
ref._value = nullptr;
|
|
43
|
+
ref._state = nullptr;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
WeakReference& operator=(const WeakReference& ref) {
|
|
47
|
+
if (this == &ref)
|
|
48
|
+
return *this;
|
|
49
|
+
|
|
50
|
+
if (_state != nullptr) {
|
|
51
|
+
// destroy previous pointer
|
|
52
|
+
_state->weakRefCount--;
|
|
53
|
+
maybeDestroy();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
_value = ref._value;
|
|
57
|
+
_state = ref._state;
|
|
58
|
+
if (_state != nullptr) {
|
|
59
|
+
// increment new pointer
|
|
60
|
+
_state->weakRefCount++;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return *this;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
~WeakReference() {
|
|
67
|
+
if (_state == nullptr) {
|
|
68
|
+
// we are just a dangling nullptr.
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
_state->weakRefCount--;
|
|
73
|
+
maybeDestroy();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
Try to lock the borrowing reference to an owning reference, or `nullptr` if it has already been deleted.
|
|
78
|
+
*/
|
|
79
|
+
[[nodiscard]]
|
|
80
|
+
BorrowingReference<T> lock() const;
|
|
81
|
+
|
|
82
|
+
public:
|
|
83
|
+
friend class BorrowingReference<T>;
|
|
84
|
+
|
|
85
|
+
private:
|
|
86
|
+
void maybeDestroy() {
|
|
87
|
+
if (_state->strongRefCount == 0 && _state->weakRefCount == 0) {
|
|
88
|
+
// free the full memory if there are no more references at all
|
|
89
|
+
if (!_state->isDeleted) [[unlikely]] {
|
|
90
|
+
throw std::runtime_error("WeakReference<T> encountered a stale _value - BorrowingReference<T> should've already deleted this!");
|
|
91
|
+
}
|
|
92
|
+
delete _state;
|
|
93
|
+
_state = nullptr;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private:
|
|
98
|
+
T* _value;
|
|
99
|
+
ReferenceState* _state;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
} // namespace margelo::nitro
|
package/cpp/views/CachedProp.hpp
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
#pragma once
|
|
6
6
|
|
|
7
|
+
#include "BorrowingReference.hpp"
|
|
7
8
|
#include "JSIConverter.hpp"
|
|
8
9
|
#include "NitroDefines.hpp"
|
|
9
|
-
#include "OwningReference.hpp"
|
|
10
10
|
#include <jsi/jsi.h>
|
|
11
11
|
|
|
12
12
|
namespace margelo::nitro {
|
|
@@ -17,7 +17,7 @@ template <typename T>
|
|
|
17
17
|
struct CachedProp {
|
|
18
18
|
public:
|
|
19
19
|
T value;
|
|
20
|
-
|
|
20
|
+
BorrowingReference<jsi::Value> jsiValue;
|
|
21
21
|
bool isDirty = false;
|
|
22
22
|
|
|
23
23
|
public:
|
|
@@ -35,7 +35,7 @@ public:
|
|
|
35
35
|
}
|
|
36
36
|
T converted = JSIConverter<T>::fromJSI(runtime, value);
|
|
37
37
|
JSICacheReference cache = JSICache::getOrCreateCache(runtime);
|
|
38
|
-
|
|
38
|
+
BorrowingReference<jsi::Value> cached = cache.makeShared(jsi::Value(runtime, value));
|
|
39
39
|
return CachedProp<T>(std::move(converted), std::move(cached), /* isDirty */ true);
|
|
40
40
|
}
|
|
41
41
|
};
|
|
@@ -44,7 +44,7 @@ public indirect enum AnyValue {
|
|
|
44
44
|
/**
|
|
45
45
|
* Represents an `AnyMap` that can be passed to Swift.
|
|
46
46
|
*/
|
|
47
|
-
public class AnyMapHolder {
|
|
47
|
+
public final class AnyMapHolder {
|
|
48
48
|
public let cppPart: margelo.nitro.TSharedMap
|
|
49
49
|
|
|
50
50
|
public init() {
|
|
@@ -54,7 +54,7 @@ public class AnyMapHolder {
|
|
|
54
54
|
public init(withPreallocatedSize size: Int) {
|
|
55
55
|
cppPart = margelo.nitro.AnyMap.make(size)
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
public init(withCppPart otherCppPart: margelo.nitro.TSharedMap) {
|
|
59
59
|
cppPart = otherCppPart
|
|
60
60
|
}
|
|
@@ -120,7 +120,7 @@ public class AnyMapHolder {
|
|
|
120
120
|
let value = cppPart.pointee.getString(std.string(key))
|
|
121
121
|
return String(value)
|
|
122
122
|
}
|
|
123
|
-
|
|
123
|
+
|
|
124
124
|
/**
|
|
125
125
|
* Gets the array value at the given key.
|
|
126
126
|
* If no value exists at the given key, or if it is not a double,
|
|
@@ -130,7 +130,7 @@ public class AnyMapHolder {
|
|
|
130
130
|
let value = cppPart.pointee.getArray(std.string(key))
|
|
131
131
|
return value.toSwift()
|
|
132
132
|
}
|
|
133
|
-
|
|
133
|
+
|
|
134
134
|
/**
|
|
135
135
|
* Gets the object value at the given key.
|
|
136
136
|
* If no value exists at the given key, or if it is not a double,
|
|
@@ -177,14 +177,14 @@ public class AnyMapHolder {
|
|
|
177
177
|
public func setString(key: String, value: String) {
|
|
178
178
|
cppPart.pointee.setString(std.string(key), std.string(value))
|
|
179
179
|
}
|
|
180
|
-
|
|
180
|
+
|
|
181
181
|
/**
|
|
182
182
|
* Set the given key to the given array value.
|
|
183
183
|
*/
|
|
184
184
|
public func setArray(key: String, value: [AnyValue]) {
|
|
185
185
|
cppPart.pointee.setArray(std.string(key), margelo.nitro.AnyArray.create(value))
|
|
186
186
|
}
|
|
187
|
-
|
|
187
|
+
|
|
188
188
|
/**
|
|
189
189
|
* Set the given key to the given object value.
|
|
190
190
|
*/
|
|
@@ -228,14 +228,14 @@ public class AnyMapHolder {
|
|
|
228
228
|
public func isString(key: String) -> Bool {
|
|
229
229
|
return cppPart.pointee.isString(std.string(key))
|
|
230
230
|
}
|
|
231
|
-
|
|
231
|
+
|
|
232
232
|
/**
|
|
233
233
|
* Gets whether the given `key` is holding an array value, or not.
|
|
234
234
|
*/
|
|
235
235
|
public func isArray(key: String) -> Bool {
|
|
236
236
|
return cppPart.pointee.isArray(std.string(key))
|
|
237
237
|
}
|
|
238
|
-
|
|
238
|
+
|
|
239
239
|
/**
|
|
240
240
|
* Gets whether the given `key` is holding an object value, or not.
|
|
241
241
|
*/
|
|
@@ -34,7 +34,7 @@ RCT_EXPORT_MODULE(NitroModules)
|
|
|
34
34
|
|
|
35
35
|
- (void)installJSIBindingsWithRuntime:(jsi::Runtime&)runtime {
|
|
36
36
|
// 1. Get CallInvoker we cached statically
|
|
37
|
-
|
|
37
|
+
std::shared_ptr<react::CallInvoker> callInvoker = _callInvoker.lock();
|
|
38
38
|
if (callInvoker == nullptr) {
|
|
39
39
|
throw std::runtime_error("Cannot install global.NitroModulesProxy - CallInvoker was null!");
|
|
40
40
|
}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -58,4 +58,15 @@ Object.keys(_HybridView).forEach(function (key) {
|
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
|
+
var _getHostComponent = require("./views/getHostComponent");
|
|
62
|
+
Object.keys(_getHostComponent).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _getHostComponent[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _getHostComponent[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
61
72
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_HybridObject","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_NitroModules","_AnyMap","_Constructor","_HybridView"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,aAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,aAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,aAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,aAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,aAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,aAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,aAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,OAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,OAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,OAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,OAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,YAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,YAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,YAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,YAAA,CAAAP,GAAA;IAAA;EAAA;AAAA;
|
|
1
|
+
{"version":3,"names":["_HybridObject","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_NitroModules","_AnyMap","_Constructor","_HybridView","_getHostComponent"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,aAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,aAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,aAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,aAAA,GAAAT,OA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,CAAAD,GAAA,MAAAQ,WAAA,CAAAR,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAI,WAAA,CAAAR,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,iBAAA,GAAAb,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAW,iBAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAS,iBAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAK,iBAAA,CAAAT,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -3,15 +3,4 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var _getHostComponent = require("./getHostComponent");
|
|
7
|
-
Object.keys(_getHostComponent).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _getHostComponent[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _getHostComponent[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
6
|
//# sourceMappingURL=HybridView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["views/HybridView.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -11,7 +11,26 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
11
11
|
// @ts-expect-error this unfortunately isn't typed or default-exported.
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Represents all default props a Nitro HybridView has.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// Due to a React limitation, functions cannot be passed to native directly
|
|
18
|
+
// because RN converts them to booleans (`true`). Nitro knows this and just
|
|
19
|
+
// wraps functions as objects - the original function is stored in `f`.
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Represents a React Native view, implemented as a Nitro View, with the given props and methods.
|
|
23
|
+
*
|
|
24
|
+
* @note Every React Native view has a {@linkcode DefaultHybridViewProps.hybridRef hybridRef} which can be used to gain access
|
|
25
|
+
* to the underlying Nitro {@linkcode HybridView}.
|
|
26
|
+
* @note Every function/callback is wrapped as a `{ f: … }` object.
|
|
27
|
+
* @note Every method can be called on the Ref. Including setting properties directly.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Finds and returns a native view (aka "HostComponent") via the given {@linkcode name}.
|
|
32
|
+
*
|
|
33
|
+
* The view is bridged to a native Hybrid Object using Nitro Views.
|
|
15
34
|
*/
|
|
16
35
|
function getHostComponent(name, getViewConfig) {
|
|
17
36
|
if (NativeComponentRegistry == null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","NativeComponentRegistry","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","getHostComponent","name","getViewConfig","Error","Platform","OS"],"sourceRoot":"../../../src","sources":["views/getHostComponent.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,uBAAA,GAAAC,uBAAA,CAAAF,OAAA;AAAyG,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAF,wBAAAE,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAe,GAAA,CAAAlB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AADzG;;
|
|
1
|
+
{"version":3,"names":["_reactNative","require","NativeComponentRegistry","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","getHostComponent","name","getViewConfig","Error","Platform","OS"],"sourceRoot":"../../../src","sources":["views/getHostComponent.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IA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W,gBAAgBA,CAI9BC,IAAY,EACZC,aAAsC,EACL;EACjC,IAAIxB,uBAAuB,IAAI,IAAI,EAAE;IACnC,MAAM,IAAIyB,KAAK,CACb,+CAA+CC,qBAAQ,CAACC,EAAE,GAC5D,CAAC;EACH;EACA,OAAO3B,uBAAuB,CAACU,GAAG,CAACa,IAAI,EAAEC,aAAa,CAAC;AACzD","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,UAAU;AACxB,cAAc,eAAe;
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,UAAU;AACxB,cAAc,eAAe;AAE7B,cAAc,oBAAoB;AAClC,cAAc,0BAA0B","ignoreList":[]}
|
|
@@ -1,30 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Describes the languages this view will be implemented in.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Represents a Nitro `HybridView` which is implemented in a native language
|
|
9
|
-
* like Swift or Kotlin.
|
|
10
|
-
*
|
|
11
|
-
* `HybridViews`s use the Nitro Tunnel for efficient, low-overhead JS <-> Native communication.
|
|
12
|
-
*
|
|
13
|
-
* All `HybridViews`s have a C++ Fabric View base with a backing Shadow Node.
|
|
14
|
-
*
|
|
15
|
-
* - TypeScript Properties (`name: Type`) will be React Props
|
|
16
|
-
* - TypeScript Methods (`name(): Type`) will be Ref Methods
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```tsx
|
|
20
|
-
* export interface Camera extends HybridView {
|
|
21
|
-
* zoom: number
|
|
22
|
-
* flash: boolean
|
|
23
|
-
* takePhoto(): Image
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
export * from './getHostComponent';
|
|
29
3
|
export {};
|
|
30
4
|
//# sourceMappingURL=HybridView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["views/HybridView.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["views/HybridView.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -3,8 +3,28 @@
|
|
|
3
3
|
import { Platform } from 'react-native';
|
|
4
4
|
// @ts-expect-error this unfortunately isn't typed or default-exported.
|
|
5
5
|
import * as NativeComponentRegistry from 'react-native/Libraries/NativeComponent/NativeComponentRegistry';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents all default props a Nitro HybridView has.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Due to a React limitation, functions cannot be passed to native directly
|
|
12
|
+
// because RN converts them to booleans (`true`). Nitro knows this and just
|
|
13
|
+
// wraps functions as objects - the original function is stored in `f`.
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents a React Native view, implemented as a Nitro View, with the given props and methods.
|
|
17
|
+
*
|
|
18
|
+
* @note Every React Native view has a {@linkcode DefaultHybridViewProps.hybridRef hybridRef} which can be used to gain access
|
|
19
|
+
* to the underlying Nitro {@linkcode HybridView}.
|
|
20
|
+
* @note Every function/callback is wrapped as a `{ f: … }` object.
|
|
21
|
+
* @note Every method can be called on the Ref. Including setting properties directly.
|
|
22
|
+
*/
|
|
23
|
+
|
|
6
24
|
/**
|
|
7
|
-
* Finds and returns a native view (aka
|
|
25
|
+
* Finds and returns a native view (aka "HostComponent") via the given {@linkcode name}.
|
|
26
|
+
*
|
|
27
|
+
* The view is bridged to a native Hybrid Object using Nitro Views.
|
|
8
28
|
*/
|
|
9
29
|
export function getHostComponent(name, getViewConfig) {
|
|
10
30
|
if (NativeComponentRegistry == null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","NativeComponentRegistry","getHostComponent","name","getViewConfig","Error","OS","get"],"sourceRoot":"../../../src","sources":["views/getHostComponent.ts"],"mappings":";;AAAA,SAASA,QAAQ,
|
|
1
|
+
{"version":3,"names":["Platform","NativeComponentRegistry","getHostComponent","name","getViewConfig","Error","OS","get"],"sourceRoot":"../../../src","sources":["views/getHostComponent.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAA4C,cAAc;AAC3E;AACA,OAAO,KAAKC,uBAAuB,MAAM,gEAAgE;;AAezG;AACA;AACA;;AAsBA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAI9BC,IAAY,EACZC,aAAsC,EACL;EACjC,IAAIH,uBAAuB,IAAI,IAAI,EAAE;IACnC,MAAM,IAAII,KAAK,CACb,+CAA+CL,QAAQ,CAACM,EAAE,GAC5D,CAAC;EACH;EACA,OAAOL,uBAAuB,CAACM,GAAG,CAACJ,IAAI,EAAEC,aAAa,CAAC;AACzD","ignoreList":[]}
|