react-native-nitro-modules 0.26.0 → 0.26.2
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/src/main/cpp/core/JAnyMap.hpp +13 -1
- package/android/src/main/java/com/margelo/nitro/core/AnyMap.kt +1 -0
- package/cpp/core/AnyMap.cpp +8 -0
- package/cpp/core/AnyMap.hpp +4 -0
- package/cpp/core/Promise.hpp +17 -0
- package/cpp/utils/NitroDefines.hpp +1 -1
- package/ios/core/AnyMapHolder.swift +13 -0
- package/package.json +1 -1
package/android/build.gradle
CHANGED
|
@@ -51,7 +51,7 @@ android {
|
|
|
51
51
|
externalNativeBuild {
|
|
52
52
|
cmake {
|
|
53
53
|
cppFlags "-frtti -fexceptions -Wall -Wextra -fstack-protector-all"
|
|
54
|
-
arguments "-DANDROID_STL=c++_shared"
|
|
54
|
+
arguments "-DANDROID_STL=c++_shared", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
|
|
55
55
|
abiFilters (*reactNativeArchitectures())
|
|
56
56
|
|
|
57
57
|
buildTypes {
|
|
@@ -40,7 +40,7 @@ private:
|
|
|
40
40
|
JAnyMap() {
|
|
41
41
|
_map = std::make_shared<AnyMap>();
|
|
42
42
|
}
|
|
43
|
-
JAnyMap(const std::shared_ptr<AnyMap>& map) : _map(map) {}
|
|
43
|
+
explicit JAnyMap(const std::shared_ptr<AnyMap>& map) : _map(map) {}
|
|
44
44
|
|
|
45
45
|
protected:
|
|
46
46
|
bool contains(const std::string& key) {
|
|
@@ -52,6 +52,17 @@ protected:
|
|
|
52
52
|
void clear() {
|
|
53
53
|
_map->clear();
|
|
54
54
|
}
|
|
55
|
+
jni::local_ref<jni::JArrayClass<jni::JString>> getAllKeys() {
|
|
56
|
+
auto& map = _map->getMap();
|
|
57
|
+
auto array = jni::JArrayClass<jni::JString>::newArray(map.size());
|
|
58
|
+
size_t index = 0;
|
|
59
|
+
for (const auto& pair : map) {
|
|
60
|
+
auto jKey = jni::make_jstring(pair.first);
|
|
61
|
+
array->setElement(index, *jKey);
|
|
62
|
+
index++;
|
|
63
|
+
}
|
|
64
|
+
return array;
|
|
65
|
+
}
|
|
55
66
|
|
|
56
67
|
protected:
|
|
57
68
|
bool isNull(const std::string& key) {
|
|
@@ -163,6 +174,7 @@ public:
|
|
|
163
174
|
makeNativeMethod("contains", JAnyMap::contains),
|
|
164
175
|
makeNativeMethod("remove", JAnyMap::remove),
|
|
165
176
|
makeNativeMethod("clear", JAnyMap::clear),
|
|
177
|
+
makeNativeMethod("getAllKeys", JAnyMap::getAllKeys),
|
|
166
178
|
// is
|
|
167
179
|
makeNativeMethod("isNull", JAnyMap::isNull),
|
|
168
180
|
makeNativeMethod("isDouble", JAnyMap::isDouble),
|
package/cpp/core/AnyMap.cpp
CHANGED
|
@@ -16,6 +16,14 @@ void AnyMap::remove(const std::string& key) {
|
|
|
16
16
|
void AnyMap::clear() noexcept {
|
|
17
17
|
_map.clear();
|
|
18
18
|
}
|
|
19
|
+
std::vector<std::string> AnyMap::getAllKeys() const {
|
|
20
|
+
std::vector<std::string> keys;
|
|
21
|
+
keys.reserve(_map.size());
|
|
22
|
+
for (const auto& pair : _map) {
|
|
23
|
+
keys.push_back(pair.first);
|
|
24
|
+
}
|
|
25
|
+
return keys;
|
|
26
|
+
}
|
|
19
27
|
|
|
20
28
|
// Is
|
|
21
29
|
bool AnyMap::isNull(const std::string& key) const {
|
package/cpp/core/AnyMap.hpp
CHANGED
package/cpp/core/Promise.hpp
CHANGED
|
@@ -106,6 +106,7 @@ public:
|
|
|
106
106
|
for (const auto& onResolved : _onResolvedListeners) {
|
|
107
107
|
onResolved(std::get<TResult>(_state));
|
|
108
108
|
}
|
|
109
|
+
didFinish();
|
|
109
110
|
}
|
|
110
111
|
void resolve(const TResult& result) {
|
|
111
112
|
std::unique_lock lock(_mutex);
|
|
@@ -116,6 +117,7 @@ public:
|
|
|
116
117
|
for (const auto& onResolved : _onResolvedListeners) {
|
|
117
118
|
onResolved(std::get<TResult>(_state));
|
|
118
119
|
}
|
|
120
|
+
didFinish();
|
|
119
121
|
}
|
|
120
122
|
/**
|
|
121
123
|
* Rejects this Promise with the given error, and calls any pending listeners.
|
|
@@ -134,6 +136,7 @@ public:
|
|
|
134
136
|
for (const auto& onRejected : _onRejectedListeners) {
|
|
135
137
|
onRejected(exception);
|
|
136
138
|
}
|
|
139
|
+
didFinish();
|
|
137
140
|
}
|
|
138
141
|
|
|
139
142
|
public:
|
|
@@ -245,6 +248,12 @@ public:
|
|
|
245
248
|
return std::holds_alternative<std::monostate>(_state);
|
|
246
249
|
}
|
|
247
250
|
|
|
251
|
+
private:
|
|
252
|
+
void didFinish() noexcept {
|
|
253
|
+
_onResolvedListeners.clear();
|
|
254
|
+
_onRejectedListeners.clear();
|
|
255
|
+
}
|
|
256
|
+
|
|
248
257
|
private:
|
|
249
258
|
std::variant<std::monostate, TResult, std::exception_ptr> _state;
|
|
250
259
|
std::vector<OnResolvedFunc> _onResolvedListeners;
|
|
@@ -319,6 +328,7 @@ public:
|
|
|
319
328
|
for (const auto& onResolved : _onResolvedListeners) {
|
|
320
329
|
onResolved();
|
|
321
330
|
}
|
|
331
|
+
didFinish();
|
|
322
332
|
}
|
|
323
333
|
void reject(const std::exception_ptr& exception) {
|
|
324
334
|
if (exception == nullptr) [[unlikely]] {
|
|
@@ -333,6 +343,7 @@ public:
|
|
|
333
343
|
for (const auto& onRejected : _onRejectedListeners) {
|
|
334
344
|
onRejected(exception);
|
|
335
345
|
}
|
|
346
|
+
didFinish();
|
|
336
347
|
}
|
|
337
348
|
|
|
338
349
|
public:
|
|
@@ -401,6 +412,12 @@ public:
|
|
|
401
412
|
return !isResolved() && !isRejected();
|
|
402
413
|
}
|
|
403
414
|
|
|
415
|
+
private:
|
|
416
|
+
void didFinish() noexcept {
|
|
417
|
+
_onResolvedListeners.clear();
|
|
418
|
+
_onRejectedListeners.clear();
|
|
419
|
+
}
|
|
420
|
+
|
|
404
421
|
private:
|
|
405
422
|
std::mutex _mutex;
|
|
406
423
|
bool _isResolved = false;
|
|
@@ -82,6 +82,19 @@ public final class AnyMapHolder {
|
|
|
82
82
|
cppPart.pointee.clear()
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Get all keys in this map.
|
|
87
|
+
*/
|
|
88
|
+
public func getAllKeys() -> [String] {
|
|
89
|
+
let cppKeys = cppPart.pointee.getAllKeys()
|
|
90
|
+
var keys = [String]()
|
|
91
|
+
keys.reserveCapacity(cppKeys.count)
|
|
92
|
+
for cppKey in cppKeys {
|
|
93
|
+
keys.append(String(cppKey))
|
|
94
|
+
}
|
|
95
|
+
return keys
|
|
96
|
+
}
|
|
97
|
+
|
|
85
98
|
// pragma MARK: Getters
|
|
86
99
|
|
|
87
100
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-modules",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.2",
|
|
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",
|