react-native-nitro-modules 0.35.1 → 0.35.3
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 +1 -0
- package/cpp/core/Promise.cpp +1 -1
- package/cpp/core/Promise.hpp +3 -3
- package/cpp/utils/NitroDefines.hpp +1 -1
- package/cpp/utils/ReferenceState.hpp +1 -1
- package/cpp/utils/WeakReference.hpp +17 -0
- package/ios/core/RuntimeError.swift +7 -0
- package/package.json +1 -1
package/NitroModules.podspec
CHANGED
package/cpp/core/Promise.cpp
CHANGED
|
@@ -121,7 +121,7 @@ std::future<void> Promise<void>::await() {
|
|
|
121
121
|
return promise->get_future();
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
const std::exception_ptr& Promise<void>::getError() {
|
|
124
|
+
const std::exception_ptr& Promise<void>::getError() const {
|
|
125
125
|
if (!isRejected()) {
|
|
126
126
|
throw std::runtime_error("Cannot get error when Promise<void> is not yet rejected!");
|
|
127
127
|
}
|
package/cpp/core/Promise.hpp
CHANGED
|
@@ -206,7 +206,7 @@ public:
|
|
|
206
206
|
* Get the result of the Promise if it has been resolved.
|
|
207
207
|
* If the Promise is not resolved, this will throw.
|
|
208
208
|
*/
|
|
209
|
-
inline const TResult& getResult() {
|
|
209
|
+
inline const TResult& getResult() const {
|
|
210
210
|
if (!isResolved()) {
|
|
211
211
|
std::string typeName = TypeInfo::getFriendlyTypename<TResult>(true);
|
|
212
212
|
throw std::runtime_error("Cannot get result when Promise<" + typeName + "> is not yet resolved!");
|
|
@@ -217,7 +217,7 @@ public:
|
|
|
217
217
|
* Get the error of the Promise if it has been rejected.
|
|
218
218
|
* If the Promise is not rejected, this will throw.
|
|
219
219
|
*/
|
|
220
|
-
inline const std::exception_ptr& getError() {
|
|
220
|
+
inline const std::exception_ptr& getError() const {
|
|
221
221
|
if (!isRejected()) {
|
|
222
222
|
std::string typeName = TypeInfo::getFriendlyTypename<TResult>(true);
|
|
223
223
|
throw std::runtime_error("Cannot get error when Promise<" + typeName + "> is not yet rejected!");
|
|
@@ -297,7 +297,7 @@ public:
|
|
|
297
297
|
std::future<void> await();
|
|
298
298
|
|
|
299
299
|
public:
|
|
300
|
-
const std::exception_ptr& getError();
|
|
300
|
+
const std::exception_ptr& getError() const;
|
|
301
301
|
|
|
302
302
|
public:
|
|
303
303
|
inline bool isResolved() const noexcept {
|
|
@@ -44,6 +44,23 @@ public:
|
|
|
44
44
|
ref._state = nullptr;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
WeakReference& operator=(WeakReference&& ref) noexcept {
|
|
48
|
+
if (this == &ref)
|
|
49
|
+
return *this;
|
|
50
|
+
|
|
51
|
+
if (_state != nullptr) {
|
|
52
|
+
_state->weakRefCount--;
|
|
53
|
+
maybeDestroy();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
_value = ref._value;
|
|
57
|
+
_state = ref._state;
|
|
58
|
+
ref._value = nullptr;
|
|
59
|
+
ref._state = nullptr;
|
|
60
|
+
|
|
61
|
+
return *this;
|
|
62
|
+
}
|
|
63
|
+
|
|
47
64
|
WeakReference& operator=(const WeakReference& ref) {
|
|
48
65
|
if (this == &ref)
|
|
49
66
|
return *this;
|
|
@@ -18,6 +18,13 @@ public enum RuntimeError: Error, CustomStringConvertible {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new `RuntimeError` with the given `message`.
|
|
23
|
+
*/
|
|
24
|
+
public init(_ message: String) {
|
|
25
|
+
self = .error(withMessage: message)
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
/**
|
|
22
29
|
* Creates a new `RuntimeError` from the given C++ `std::exception`.
|
|
23
30
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-modules",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.3",
|
|
4
4
|
"description": "Insanely fast native C++, Swift or Kotlin modules with a statically compiled binding layer to JSI.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|