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.
@@ -17,6 +17,7 @@ Pod::Spec.new do |s|
17
17
  :ios => min_ios_version_supported,
18
18
  :visionos => 1.0,
19
19
  :macos => 10.13,
20
+ :osx => 10.13,
20
21
  :tvos => 13.4,
21
22
  }
22
23
 
@@ -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
  }
@@ -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 {
@@ -9,7 +9,7 @@
9
9
  #define NitroDefines_h
10
10
 
11
11
  // Sets the version of the native Nitro core library
12
- #define NITRO_VERSION "0.35.1"
12
+ #define NITRO_VERSION "0.35.3"
13
13
 
14
14
  // Sets whether to use debug or optimized production build flags
15
15
  #ifdef DEBUG
@@ -23,7 +23,7 @@ namespace margelo::nitro {
23
23
  struct ReferenceState {
24
24
  std::atomic_size_t strongRefCount;
25
25
  std::atomic_size_t weakRefCount;
26
- bool isDeleted;
26
+ std::atomic<bool> isDeleted;
27
27
  std::mutex mutex;
28
28
 
29
29
  /**
@@ -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.1",
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",