react-native-nitro-cookies 1.1.0 → 1.2.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/src/main/java/com/margelo/nitro/nitrocookies/NitroCookies.kt +69 -0
- package/ios/NitroCookies.swift +101 -0
- package/lib/module/index.js +96 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NitroCookies.nitro.d.ts +48 -0
- package/lib/typescript/src/NitroCookies.nitro.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +88 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JCookie.hpp +1 -1
- package/nitrogen/generated/android/c++/JHybridNitroCookiesSpec.cpp +76 -16
- package/nitrogen/generated/android/c++/JHybridNitroCookiesSpec.hpp +6 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocookies/Cookie.kt +27 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocookies/HybridNitroCookiesSpec.kt +16 -0
- package/nitrogen/generated/android/nitrocookiesOnLoad.cpp +2 -2
- package/nitrogen/generated/ios/NitroCookies+autolinking.rb +2 -0
- package/nitrogen/generated/ios/NitroCookies-Swift-Cxx-Bridge.cpp +8 -0
- package/nitrogen/generated/ios/NitroCookies-Swift-Cxx-Bridge.hpp +52 -0
- package/nitrogen/generated/ios/c++/HybridNitroCookiesSpecSwift.hpp +32 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridNitroCookiesSpec.swift +4 -0
- package/nitrogen/generated/ios/swift/HybridNitroCookiesSpec_cxx.swift +76 -0
- package/nitrogen/generated/shared/c++/HybridNitroCookiesSpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridNitroCookiesSpec.hpp +4 -0
- package/package.json +8 -7
- package/src/NitroCookies.nitro.ts +56 -0
- package/src/index.tsx +104 -0
|
@@ -55,16 +55,16 @@ namespace margelo::nitro::nitrocookies {
|
|
|
55
55
|
std::vector<Cookie> JHybridNitroCookiesSpec::getSync(const std::string& url) {
|
|
56
56
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JCookie>>(jni::alias_ref<jni::JString> /* url */)>("getSync");
|
|
57
57
|
auto __result = method(_javaPart, jni::make_jstring(url));
|
|
58
|
-
return [&]() {
|
|
59
|
-
size_t __size =
|
|
58
|
+
return [&](auto&& __input) {
|
|
59
|
+
size_t __size = __input->size();
|
|
60
60
|
std::vector<Cookie> __vector;
|
|
61
61
|
__vector.reserve(__size);
|
|
62
62
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
63
|
-
auto __element =
|
|
63
|
+
auto __element = __input->getElement(__i);
|
|
64
64
|
__vector.push_back(__element->toCpp());
|
|
65
65
|
}
|
|
66
66
|
return __vector;
|
|
67
|
-
}();
|
|
67
|
+
}(__result);
|
|
68
68
|
}
|
|
69
69
|
bool JHybridNitroCookiesSpec::setSync(const std::string& url, const Cookie& cookie) {
|
|
70
70
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean(jni::alias_ref<jni::JString> /* url */, jni::alias_ref<JCookie> /* cookie */)>("setSync");
|
|
@@ -81,6 +81,25 @@ namespace margelo::nitro::nitrocookies {
|
|
|
81
81
|
auto __result = method(_javaPart, jni::make_jstring(url), jni::make_jstring(name));
|
|
82
82
|
return static_cast<bool>(__result);
|
|
83
83
|
}
|
|
84
|
+
std::string JHybridNitroCookiesSpec::getCookieHeaderSync(const std::string& url) {
|
|
85
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>(jni::alias_ref<jni::JString> /* url */)>("getCookieHeaderSync");
|
|
86
|
+
auto __result = method(_javaPart, jni::make_jstring(url));
|
|
87
|
+
return __result->toStdString();
|
|
88
|
+
}
|
|
89
|
+
bool JHybridNitroCookiesSpec::setManySync(const std::string& url, const std::vector<Cookie>& cookies) {
|
|
90
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean(jni::alias_ref<jni::JString> /* url */, jni::alias_ref<jni::JArrayClass<JCookie>> /* cookies */)>("setManySync");
|
|
91
|
+
auto __result = method(_javaPart, jni::make_jstring(url), [&](auto&& __input) {
|
|
92
|
+
size_t __size = __input.size();
|
|
93
|
+
jni::local_ref<jni::JArrayClass<JCookie>> __array = jni::JArrayClass<JCookie>::newArray(__size);
|
|
94
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
95
|
+
const auto& __element = __input[__i];
|
|
96
|
+
auto __elementJni = JCookie::fromCpp(__element);
|
|
97
|
+
__array->setElement(__i, *__elementJni);
|
|
98
|
+
}
|
|
99
|
+
return __array;
|
|
100
|
+
}(cookies));
|
|
101
|
+
return static_cast<bool>(__result);
|
|
102
|
+
}
|
|
84
103
|
std::shared_ptr<Promise<bool>> JHybridNitroCookiesSpec::set(const std::string& url, const Cookie& cookie, std::optional<bool> useWebKit) {
|
|
85
104
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* url */, jni::alias_ref<JCookie> /* cookie */, jni::alias_ref<jni::JBoolean> /* useWebKit */)>("set");
|
|
86
105
|
auto __result = method(_javaPart, jni::make_jstring(url), JCookie::fromCpp(cookie), useWebKit.has_value() ? jni::JBoolean::valueOf(useWebKit.value()) : nullptr);
|
|
@@ -97,6 +116,47 @@ namespace margelo::nitro::nitrocookies {
|
|
|
97
116
|
return __promise;
|
|
98
117
|
}();
|
|
99
118
|
}
|
|
119
|
+
std::shared_ptr<Promise<bool>> JHybridNitroCookiesSpec::setMany(const std::string& url, const std::vector<Cookie>& cookies, std::optional<bool> useWebKit) {
|
|
120
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* url */, jni::alias_ref<jni::JArrayClass<JCookie>> /* cookies */, jni::alias_ref<jni::JBoolean> /* useWebKit */)>("setMany");
|
|
121
|
+
auto __result = method(_javaPart, jni::make_jstring(url), [&](auto&& __input) {
|
|
122
|
+
size_t __size = __input.size();
|
|
123
|
+
jni::local_ref<jni::JArrayClass<JCookie>> __array = jni::JArrayClass<JCookie>::newArray(__size);
|
|
124
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
125
|
+
const auto& __element = __input[__i];
|
|
126
|
+
auto __elementJni = JCookie::fromCpp(__element);
|
|
127
|
+
__array->setElement(__i, *__elementJni);
|
|
128
|
+
}
|
|
129
|
+
return __array;
|
|
130
|
+
}(cookies), useWebKit.has_value() ? jni::JBoolean::valueOf(useWebKit.value()) : nullptr);
|
|
131
|
+
return [&]() {
|
|
132
|
+
auto __promise = Promise<bool>::create();
|
|
133
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
134
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
135
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
136
|
+
});
|
|
137
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
138
|
+
jni::JniException __jniError(__throwable);
|
|
139
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
140
|
+
});
|
|
141
|
+
return __promise;
|
|
142
|
+
}();
|
|
143
|
+
}
|
|
144
|
+
std::shared_ptr<Promise<std::string>> JHybridNitroCookiesSpec::getCookieHeader(const std::string& url, std::optional<bool> useWebKit) {
|
|
145
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* url */, jni::alias_ref<jni::JBoolean> /* useWebKit */)>("getCookieHeader");
|
|
146
|
+
auto __result = method(_javaPart, jni::make_jstring(url), useWebKit.has_value() ? jni::JBoolean::valueOf(useWebKit.value()) : nullptr);
|
|
147
|
+
return [&]() {
|
|
148
|
+
auto __promise = Promise<std::string>::create();
|
|
149
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
150
|
+
auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
|
|
151
|
+
__promise->resolve(__result->toStdString());
|
|
152
|
+
});
|
|
153
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
154
|
+
jni::JniException __jniError(__throwable);
|
|
155
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
156
|
+
});
|
|
157
|
+
return __promise;
|
|
158
|
+
}();
|
|
159
|
+
}
|
|
100
160
|
std::shared_ptr<Promise<std::vector<Cookie>>> JHybridNitroCookiesSpec::get(const std::string& url, std::optional<bool> useWebKit) {
|
|
101
161
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* url */, jni::alias_ref<jni::JBoolean> /* useWebKit */)>("get");
|
|
102
162
|
auto __result = method(_javaPart, jni::make_jstring(url), useWebKit.has_value() ? jni::JBoolean::valueOf(useWebKit.value()) : nullptr);
|
|
@@ -104,16 +164,16 @@ namespace margelo::nitro::nitrocookies {
|
|
|
104
164
|
auto __promise = Promise<std::vector<Cookie>>::create();
|
|
105
165
|
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
106
166
|
auto __result = jni::static_ref_cast<jni::JArrayClass<JCookie>>(__boxedResult);
|
|
107
|
-
__promise->resolve([&]() {
|
|
108
|
-
size_t __size =
|
|
167
|
+
__promise->resolve([&](auto&& __input) {
|
|
168
|
+
size_t __size = __input->size();
|
|
109
169
|
std::vector<Cookie> __vector;
|
|
110
170
|
__vector.reserve(__size);
|
|
111
171
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
112
|
-
auto __element =
|
|
172
|
+
auto __element = __input->getElement(__i);
|
|
113
173
|
__vector.push_back(__element->toCpp());
|
|
114
174
|
}
|
|
115
175
|
return __vector;
|
|
116
|
-
}());
|
|
176
|
+
}(__result));
|
|
117
177
|
});
|
|
118
178
|
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
119
179
|
jni::JniException __jniError(__throwable);
|
|
@@ -161,16 +221,16 @@ namespace margelo::nitro::nitrocookies {
|
|
|
161
221
|
auto __promise = Promise<std::vector<Cookie>>::create();
|
|
162
222
|
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
163
223
|
auto __result = jni::static_ref_cast<jni::JArrayClass<JCookie>>(__boxedResult);
|
|
164
|
-
__promise->resolve([&]() {
|
|
165
|
-
size_t __size =
|
|
224
|
+
__promise->resolve([&](auto&& __input) {
|
|
225
|
+
size_t __size = __input->size();
|
|
166
226
|
std::vector<Cookie> __vector;
|
|
167
227
|
__vector.reserve(__size);
|
|
168
228
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
169
|
-
auto __element =
|
|
229
|
+
auto __element = __input->getElement(__i);
|
|
170
230
|
__vector.push_back(__element->toCpp());
|
|
171
231
|
}
|
|
172
232
|
return __vector;
|
|
173
|
-
}());
|
|
233
|
+
}(__result));
|
|
174
234
|
});
|
|
175
235
|
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
176
236
|
jni::JniException __jniError(__throwable);
|
|
@@ -186,16 +246,16 @@ namespace margelo::nitro::nitrocookies {
|
|
|
186
246
|
auto __promise = Promise<std::vector<Cookie>>::create();
|
|
187
247
|
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
188
248
|
auto __result = jni::static_ref_cast<jni::JArrayClass<JCookie>>(__boxedResult);
|
|
189
|
-
__promise->resolve([&]() {
|
|
190
|
-
size_t __size =
|
|
249
|
+
__promise->resolve([&](auto&& __input) {
|
|
250
|
+
size_t __size = __input->size();
|
|
191
251
|
std::vector<Cookie> __vector;
|
|
192
252
|
__vector.reserve(__size);
|
|
193
253
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
194
|
-
auto __element =
|
|
254
|
+
auto __element = __input->getElement(__i);
|
|
195
255
|
__vector.push_back(__element->toCpp());
|
|
196
256
|
}
|
|
197
257
|
return __vector;
|
|
198
|
-
}());
|
|
258
|
+
}(__result));
|
|
199
259
|
});
|
|
200
260
|
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
201
261
|
jni::JniException __jniError(__throwable);
|
|
@@ -21,11 +21,11 @@ namespace margelo::nitro::nitrocookies {
|
|
|
21
21
|
class JHybridNitroCookiesSpec: public virtual HybridNitroCookiesSpec, public virtual JHybridObject {
|
|
22
22
|
public:
|
|
23
23
|
struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
|
|
24
|
-
static auto
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrocookies/HybridNitroCookiesSpec;";
|
|
25
25
|
std::shared_ptr<JHybridNitroCookiesSpec> getJHybridNitroCookiesSpec();
|
|
26
26
|
};
|
|
27
27
|
struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
|
|
28
|
-
static auto
|
|
28
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrocookies/HybridNitroCookiesSpec$CxxPart;";
|
|
29
29
|
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
30
30
|
static void registerNatives();
|
|
31
31
|
using HybridBase::HybridBase;
|
|
@@ -58,7 +58,11 @@ namespace margelo::nitro::nitrocookies {
|
|
|
58
58
|
bool setSync(const std::string& url, const Cookie& cookie) override;
|
|
59
59
|
bool setFromResponseSync(const std::string& url, const std::string& value) override;
|
|
60
60
|
bool clearByNameSync(const std::string& url, const std::string& name) override;
|
|
61
|
+
std::string getCookieHeaderSync(const std::string& url) override;
|
|
62
|
+
bool setManySync(const std::string& url, const std::vector<Cookie>& cookies) override;
|
|
61
63
|
std::shared_ptr<Promise<bool>> set(const std::string& url, const Cookie& cookie, std::optional<bool> useWebKit) override;
|
|
64
|
+
std::shared_ptr<Promise<bool>> setMany(const std::string& url, const std::vector<Cookie>& cookies, std::optional<bool> useWebKit) override;
|
|
65
|
+
std::shared_ptr<Promise<std::string>> getCookieHeader(const std::string& url, std::optional<bool> useWebKit) override;
|
|
62
66
|
std::shared_ptr<Promise<std::vector<Cookie>>> get(const std::string& url, std::optional<bool> useWebKit) override;
|
|
63
67
|
std::shared_ptr<Promise<bool>> clearAll(std::optional<bool> useWebKit) override;
|
|
64
68
|
std::shared_ptr<Promise<bool>> setFromResponse(const std::string& url, const std::string& value) override;
|
|
@@ -9,6 +9,7 @@ package com.margelo.nitro.nitrocookies
|
|
|
9
9
|
|
|
10
10
|
import androidx.annotation.Keep
|
|
11
11
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import java.util.Objects
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -44,6 +45,32 @@ data class Cookie(
|
|
|
44
45
|
) {
|
|
45
46
|
/* primary constructor */
|
|
46
47
|
|
|
48
|
+
override fun equals(other: Any?): Boolean {
|
|
49
|
+
if (this === other) return true
|
|
50
|
+
if (other !is Cookie) return false
|
|
51
|
+
return Objects.deepEquals(this.name, other.name)
|
|
52
|
+
&& Objects.deepEquals(this.value, other.value)
|
|
53
|
+
&& Objects.deepEquals(this.path, other.path)
|
|
54
|
+
&& Objects.deepEquals(this.domain, other.domain)
|
|
55
|
+
&& Objects.deepEquals(this.version, other.version)
|
|
56
|
+
&& Objects.deepEquals(this.expires, other.expires)
|
|
57
|
+
&& Objects.deepEquals(this.secure, other.secure)
|
|
58
|
+
&& Objects.deepEquals(this.httpOnly, other.httpOnly)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
override fun hashCode(): Int {
|
|
62
|
+
return arrayOf<Any?>(
|
|
63
|
+
name,
|
|
64
|
+
value,
|
|
65
|
+
path,
|
|
66
|
+
domain,
|
|
67
|
+
version,
|
|
68
|
+
expires,
|
|
69
|
+
secure,
|
|
70
|
+
httpOnly
|
|
71
|
+
).contentDeepHashCode()
|
|
72
|
+
}
|
|
73
|
+
|
|
47
74
|
companion object {
|
|
48
75
|
/**
|
|
49
76
|
* Constructor called from C++
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocookies/HybridNitroCookiesSpec.kt
CHANGED
|
@@ -45,10 +45,26 @@ abstract class HybridNitroCookiesSpec: HybridObject() {
|
|
|
45
45
|
@Keep
|
|
46
46
|
abstract fun clearByNameSync(url: String, name: String): Boolean
|
|
47
47
|
|
|
48
|
+
@DoNotStrip
|
|
49
|
+
@Keep
|
|
50
|
+
abstract fun getCookieHeaderSync(url: String): String
|
|
51
|
+
|
|
52
|
+
@DoNotStrip
|
|
53
|
+
@Keep
|
|
54
|
+
abstract fun setManySync(url: String, cookies: Array<Cookie>): Boolean
|
|
55
|
+
|
|
48
56
|
@DoNotStrip
|
|
49
57
|
@Keep
|
|
50
58
|
abstract fun set(url: String, cookie: Cookie, useWebKit: Boolean?): Promise<Boolean>
|
|
51
59
|
|
|
60
|
+
@DoNotStrip
|
|
61
|
+
@Keep
|
|
62
|
+
abstract fun setMany(url: String, cookies: Array<Cookie>, useWebKit: Boolean?): Promise<Boolean>
|
|
63
|
+
|
|
64
|
+
@DoNotStrip
|
|
65
|
+
@Keep
|
|
66
|
+
abstract fun getCookieHeader(url: String, useWebKit: Boolean?): Promise<String>
|
|
67
|
+
|
|
52
68
|
@DoNotStrip
|
|
53
69
|
@Keep
|
|
54
70
|
abstract fun get(url: String, useWebKit: Boolean?): Promise<Array<Cookie>>
|
|
@@ -27,9 +27,9 @@ int initialize(JavaVM* vm) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
struct JHybridNitroCookiesSpecImpl: public jni::JavaClass<JHybridNitroCookiesSpecImpl, JHybridNitroCookiesSpec::JavaPart> {
|
|
30
|
-
static auto
|
|
30
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrocookies/NitroCookies;";
|
|
31
31
|
static std::shared_ptr<JHybridNitroCookiesSpec> create() {
|
|
32
|
-
static auto constructorFn = javaClassStatic()->getConstructor<JHybridNitroCookiesSpecImpl::javaobject()>();
|
|
32
|
+
static const auto constructorFn = javaClassStatic()->getConstructor<JHybridNitroCookiesSpecImpl::javaobject()>();
|
|
33
33
|
jni::local_ref<JHybridNitroCookiesSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
|
|
34
34
|
return javaPart->getJHybridNitroCookiesSpec();
|
|
35
35
|
}
|
|
@@ -56,5 +56,7 @@ def add_nitrogen_files(spec)
|
|
|
56
56
|
"SWIFT_OBJC_INTEROP_MODE" => "objcxx",
|
|
57
57
|
# Enables stricter modular headers
|
|
58
58
|
"DEFINES_MODULE" => "YES",
|
|
59
|
+
# Disable auto-generated ObjC header for Swift (Static linkage on Xcode 26.4 breaks here)
|
|
60
|
+
"SWIFT_INSTALL_OBJC_HEADER" => "NO",
|
|
59
61
|
})
|
|
60
62
|
end
|
|
@@ -30,6 +30,14 @@ namespace margelo::nitro::nitrocookies::bridge::swift {
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
// pragma MARK: std::function<void(const std::string& /* result */)>
|
|
34
|
+
Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
35
|
+
auto swiftClosure = NitroCookies::Func_void_std__string::fromUnsafe(swiftClosureWrapper);
|
|
36
|
+
return [swiftClosure = std::move(swiftClosure)](const std::string& result) mutable -> void {
|
|
37
|
+
swiftClosure.call(result);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
33
41
|
// pragma MARK: std::function<void(const std::vector<Cookie>& /* result */)>
|
|
34
42
|
Func_void_std__vector_Cookie_ create_Func_void_std__vector_Cookie_(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
35
43
|
auto swiftClosure = NitroCookies::Func_void_std__vector_Cookie_::fromUnsafe(swiftClosureWrapper);
|
|
@@ -133,6 +133,40 @@ namespace margelo::nitro::nitrocookies::bridge::swift {
|
|
|
133
133
|
return Func_void_std__exception_ptr_Wrapper(std::move(value));
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
// pragma MARK: std::shared_ptr<Promise<std::string>>
|
|
137
|
+
/**
|
|
138
|
+
* Specialized version of `std::shared_ptr<Promise<std::string>>`.
|
|
139
|
+
*/
|
|
140
|
+
using std__shared_ptr_Promise_std__string__ = std::shared_ptr<Promise<std::string>>;
|
|
141
|
+
inline std::shared_ptr<Promise<std::string>> create_std__shared_ptr_Promise_std__string__() noexcept {
|
|
142
|
+
return Promise<std::string>::create();
|
|
143
|
+
}
|
|
144
|
+
inline PromiseHolder<std::string> wrap_std__shared_ptr_Promise_std__string__(std::shared_ptr<Promise<std::string>> promise) noexcept {
|
|
145
|
+
return PromiseHolder<std::string>(std::move(promise));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// pragma MARK: std::function<void(const std::string& /* result */)>
|
|
149
|
+
/**
|
|
150
|
+
* Specialized version of `std::function<void(const std::string&)>`.
|
|
151
|
+
*/
|
|
152
|
+
using Func_void_std__string = std::function<void(const std::string& /* result */)>;
|
|
153
|
+
/**
|
|
154
|
+
* Wrapper class for a `std::function<void(const std::string& / * result * /)>`, this can be used from Swift.
|
|
155
|
+
*/
|
|
156
|
+
class Func_void_std__string_Wrapper final {
|
|
157
|
+
public:
|
|
158
|
+
explicit Func_void_std__string_Wrapper(std::function<void(const std::string& /* result */)>&& func): _function(std::make_unique<std::function<void(const std::string& /* result */)>>(std::move(func))) {}
|
|
159
|
+
inline void call(std::string result) const noexcept {
|
|
160
|
+
_function->operator()(result);
|
|
161
|
+
}
|
|
162
|
+
private:
|
|
163
|
+
std::unique_ptr<std::function<void(const std::string& /* result */)>> _function;
|
|
164
|
+
} SWIFT_NONCOPYABLE;
|
|
165
|
+
Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
166
|
+
inline Func_void_std__string_Wrapper wrap_Func_void_std__string(Func_void_std__string value) noexcept {
|
|
167
|
+
return Func_void_std__string_Wrapper(std::move(value));
|
|
168
|
+
}
|
|
169
|
+
|
|
136
170
|
// pragma MARK: std::shared_ptr<Promise<std::vector<Cookie>>>
|
|
137
171
|
/**
|
|
138
172
|
* Specialized version of `std::shared_ptr<Promise<std::vector<Cookie>>>`.
|
|
@@ -231,6 +265,15 @@ namespace margelo::nitro::nitrocookies::bridge::swift {
|
|
|
231
265
|
return Result<bool>::withError(error);
|
|
232
266
|
}
|
|
233
267
|
|
|
268
|
+
// pragma MARK: Result<std::string>
|
|
269
|
+
using Result_std__string_ = Result<std::string>;
|
|
270
|
+
inline Result_std__string_ create_Result_std__string_(const std::string& value) noexcept {
|
|
271
|
+
return Result<std::string>::withValue(value);
|
|
272
|
+
}
|
|
273
|
+
inline Result_std__string_ create_Result_std__string_(const std::exception_ptr& error) noexcept {
|
|
274
|
+
return Result<std::string>::withError(error);
|
|
275
|
+
}
|
|
276
|
+
|
|
234
277
|
// pragma MARK: Result<std::shared_ptr<Promise<bool>>>
|
|
235
278
|
using Result_std__shared_ptr_Promise_bool___ = Result<std::shared_ptr<Promise<bool>>>;
|
|
236
279
|
inline Result_std__shared_ptr_Promise_bool___ create_Result_std__shared_ptr_Promise_bool___(const std::shared_ptr<Promise<bool>>& value) noexcept {
|
|
@@ -240,6 +283,15 @@ namespace margelo::nitro::nitrocookies::bridge::swift {
|
|
|
240
283
|
return Result<std::shared_ptr<Promise<bool>>>::withError(error);
|
|
241
284
|
}
|
|
242
285
|
|
|
286
|
+
// pragma MARK: Result<std::shared_ptr<Promise<std::string>>>
|
|
287
|
+
using Result_std__shared_ptr_Promise_std__string___ = Result<std::shared_ptr<Promise<std::string>>>;
|
|
288
|
+
inline Result_std__shared_ptr_Promise_std__string___ create_Result_std__shared_ptr_Promise_std__string___(const std::shared_ptr<Promise<std::string>>& value) noexcept {
|
|
289
|
+
return Result<std::shared_ptr<Promise<std::string>>>::withValue(value);
|
|
290
|
+
}
|
|
291
|
+
inline Result_std__shared_ptr_Promise_std__string___ create_Result_std__shared_ptr_Promise_std__string___(const std::exception_ptr& error) noexcept {
|
|
292
|
+
return Result<std::shared_ptr<Promise<std::string>>>::withError(error);
|
|
293
|
+
}
|
|
294
|
+
|
|
243
295
|
// pragma MARK: Result<std::shared_ptr<Promise<std::vector<Cookie>>>>
|
|
244
296
|
using Result_std__shared_ptr_Promise_std__vector_Cookie____ = Result<std::shared_ptr<Promise<std::vector<Cookie>>>>;
|
|
245
297
|
inline Result_std__shared_ptr_Promise_std__vector_Cookie____ create_Result_std__shared_ptr_Promise_std__vector_Cookie____(const std::shared_ptr<Promise<std::vector<Cookie>>>& value) noexcept {
|
|
@@ -103,6 +103,22 @@ namespace margelo::nitro::nitrocookies {
|
|
|
103
103
|
auto __value = std::move(__result.value());
|
|
104
104
|
return __value;
|
|
105
105
|
}
|
|
106
|
+
inline std::string getCookieHeaderSync(const std::string& url) override {
|
|
107
|
+
auto __result = _swiftPart.getCookieHeaderSync(url);
|
|
108
|
+
if (__result.hasError()) [[unlikely]] {
|
|
109
|
+
std::rethrow_exception(__result.error());
|
|
110
|
+
}
|
|
111
|
+
auto __value = std::move(__result.value());
|
|
112
|
+
return __value;
|
|
113
|
+
}
|
|
114
|
+
inline bool setManySync(const std::string& url, const std::vector<Cookie>& cookies) override {
|
|
115
|
+
auto __result = _swiftPart.setManySync(url, cookies);
|
|
116
|
+
if (__result.hasError()) [[unlikely]] {
|
|
117
|
+
std::rethrow_exception(__result.error());
|
|
118
|
+
}
|
|
119
|
+
auto __value = std::move(__result.value());
|
|
120
|
+
return __value;
|
|
121
|
+
}
|
|
106
122
|
inline std::shared_ptr<Promise<bool>> set(const std::string& url, const Cookie& cookie, std::optional<bool> useWebKit) override {
|
|
107
123
|
auto __result = _swiftPart.set(url, std::forward<decltype(cookie)>(cookie), useWebKit);
|
|
108
124
|
if (__result.hasError()) [[unlikely]] {
|
|
@@ -111,6 +127,22 @@ namespace margelo::nitro::nitrocookies {
|
|
|
111
127
|
auto __value = std::move(__result.value());
|
|
112
128
|
return __value;
|
|
113
129
|
}
|
|
130
|
+
inline std::shared_ptr<Promise<bool>> setMany(const std::string& url, const std::vector<Cookie>& cookies, std::optional<bool> useWebKit) override {
|
|
131
|
+
auto __result = _swiftPart.setMany(url, cookies, useWebKit);
|
|
132
|
+
if (__result.hasError()) [[unlikely]] {
|
|
133
|
+
std::rethrow_exception(__result.error());
|
|
134
|
+
}
|
|
135
|
+
auto __value = std::move(__result.value());
|
|
136
|
+
return __value;
|
|
137
|
+
}
|
|
138
|
+
inline std::shared_ptr<Promise<std::string>> getCookieHeader(const std::string& url, std::optional<bool> useWebKit) override {
|
|
139
|
+
auto __result = _swiftPart.getCookieHeader(url, useWebKit);
|
|
140
|
+
if (__result.hasError()) [[unlikely]] {
|
|
141
|
+
std::rethrow_exception(__result.error());
|
|
142
|
+
}
|
|
143
|
+
auto __value = std::move(__result.value());
|
|
144
|
+
return __value;
|
|
145
|
+
}
|
|
114
146
|
inline std::shared_ptr<Promise<std::vector<Cookie>>> get(const std::string& url, std::optional<bool> useWebKit) override {
|
|
115
147
|
auto __result = _swiftPart.get(url, useWebKit);
|
|
116
148
|
if (__result.hasError()) [[unlikely]] {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__string.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a Swift `(_ value: String) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_std__string {
|
|
15
|
+
public typealias bridge = margelo.nitro.nitrocookies.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ value: String) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ value: String) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(value: std.string) -> Void {
|
|
25
|
+
self.closure(String(value))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_std__string`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__string>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__string {
|
|
44
|
+
return Unmanaged<Func_void_std__string>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -17,7 +17,11 @@ public protocol HybridNitroCookiesSpec_protocol: HybridObject {
|
|
|
17
17
|
func setSync(url: String, cookie: Cookie) throws -> Bool
|
|
18
18
|
func setFromResponseSync(url: String, value: String) throws -> Bool
|
|
19
19
|
func clearByNameSync(url: String, name: String) throws -> Bool
|
|
20
|
+
func getCookieHeaderSync(url: String) throws -> String
|
|
21
|
+
func setManySync(url: String, cookies: [Cookie]) throws -> Bool
|
|
20
22
|
func set(url: String, cookie: Cookie, useWebKit: Bool?) throws -> Promise<Bool>
|
|
23
|
+
func setMany(url: String, cookies: [Cookie], useWebKit: Bool?) throws -> Promise<Bool>
|
|
24
|
+
func getCookieHeader(url: String, useWebKit: Bool?) throws -> Promise<String>
|
|
21
25
|
func get(url: String, useWebKit: Bool?) throws -> Promise<[Cookie]>
|
|
22
26
|
func clearAll(useWebKit: Bool?) throws -> Promise<Bool>
|
|
23
27
|
func setFromResponse(url: String, value: String) throws -> Promise<Bool>
|
|
@@ -178,6 +178,30 @@ open class HybridNitroCookiesSpec_cxx {
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
@inline(__always)
|
|
182
|
+
public final func getCookieHeaderSync(url: std.string) -> bridge.Result_std__string_ {
|
|
183
|
+
do {
|
|
184
|
+
let __result = try self.__implementation.getCookieHeaderSync(url: String(url))
|
|
185
|
+
let __resultCpp = std.string(__result)
|
|
186
|
+
return bridge.create_Result_std__string_(__resultCpp)
|
|
187
|
+
} catch (let __error) {
|
|
188
|
+
let __exceptionPtr = __error.toCpp()
|
|
189
|
+
return bridge.create_Result_std__string_(__exceptionPtr)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
@inline(__always)
|
|
194
|
+
public final func setManySync(url: std.string, cookies: bridge.std__vector_Cookie_) -> bridge.Result_bool_ {
|
|
195
|
+
do {
|
|
196
|
+
let __result = try self.__implementation.setManySync(url: String(url), cookies: cookies.map({ __item in __item }))
|
|
197
|
+
let __resultCpp = __result
|
|
198
|
+
return bridge.create_Result_bool_(__resultCpp)
|
|
199
|
+
} catch (let __error) {
|
|
200
|
+
let __exceptionPtr = __error.toCpp()
|
|
201
|
+
return bridge.create_Result_bool_(__exceptionPtr)
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
181
205
|
@inline(__always)
|
|
182
206
|
public final func set(url: std.string, cookie: Cookie, useWebKit: bridge.std__optional_bool_) -> bridge.Result_std__shared_ptr_Promise_bool___ {
|
|
183
207
|
do {
|
|
@@ -204,6 +228,58 @@ open class HybridNitroCookiesSpec_cxx {
|
|
|
204
228
|
}
|
|
205
229
|
}
|
|
206
230
|
|
|
231
|
+
@inline(__always)
|
|
232
|
+
public final func setMany(url: std.string, cookies: bridge.std__vector_Cookie_, useWebKit: bridge.std__optional_bool_) -> bridge.Result_std__shared_ptr_Promise_bool___ {
|
|
233
|
+
do {
|
|
234
|
+
let __result = try self.__implementation.setMany(url: String(url), cookies: cookies.map({ __item in __item }), useWebKit: { () -> Bool? in
|
|
235
|
+
if bridge.has_value_std__optional_bool_(useWebKit) {
|
|
236
|
+
let __unwrapped = bridge.get_std__optional_bool_(useWebKit)
|
|
237
|
+
return __unwrapped
|
|
238
|
+
} else {
|
|
239
|
+
return nil
|
|
240
|
+
}
|
|
241
|
+
}())
|
|
242
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
|
|
243
|
+
let __promise = bridge.create_std__shared_ptr_Promise_bool__()
|
|
244
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
|
|
245
|
+
__result
|
|
246
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
247
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
248
|
+
return __promise
|
|
249
|
+
}()
|
|
250
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
|
|
251
|
+
} catch (let __error) {
|
|
252
|
+
let __exceptionPtr = __error.toCpp()
|
|
253
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
@inline(__always)
|
|
258
|
+
public final func getCookieHeader(url: std.string, useWebKit: bridge.std__optional_bool_) -> bridge.Result_std__shared_ptr_Promise_std__string___ {
|
|
259
|
+
do {
|
|
260
|
+
let __result = try self.__implementation.getCookieHeader(url: String(url), useWebKit: { () -> Bool? in
|
|
261
|
+
if bridge.has_value_std__optional_bool_(useWebKit) {
|
|
262
|
+
let __unwrapped = bridge.get_std__optional_bool_(useWebKit)
|
|
263
|
+
return __unwrapped
|
|
264
|
+
} else {
|
|
265
|
+
return nil
|
|
266
|
+
}
|
|
267
|
+
}())
|
|
268
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__string__ in
|
|
269
|
+
let __promise = bridge.create_std__shared_ptr_Promise_std__string__()
|
|
270
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__string__(__promise)
|
|
271
|
+
__result
|
|
272
|
+
.then({ __result in __promiseHolder.resolve(std.string(__result)) })
|
|
273
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
274
|
+
return __promise
|
|
275
|
+
}()
|
|
276
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__string___(__resultCpp)
|
|
277
|
+
} catch (let __error) {
|
|
278
|
+
let __exceptionPtr = __error.toCpp()
|
|
279
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
207
283
|
@inline(__always)
|
|
208
284
|
public final func get(url: std.string, useWebKit: bridge.std__optional_bool_) -> bridge.Result_std__shared_ptr_Promise_std__vector_Cookie____ {
|
|
209
285
|
do {
|
|
@@ -18,7 +18,11 @@ namespace margelo::nitro::nitrocookies {
|
|
|
18
18
|
prototype.registerHybridMethod("setSync", &HybridNitroCookiesSpec::setSync);
|
|
19
19
|
prototype.registerHybridMethod("setFromResponseSync", &HybridNitroCookiesSpec::setFromResponseSync);
|
|
20
20
|
prototype.registerHybridMethod("clearByNameSync", &HybridNitroCookiesSpec::clearByNameSync);
|
|
21
|
+
prototype.registerHybridMethod("getCookieHeaderSync", &HybridNitroCookiesSpec::getCookieHeaderSync);
|
|
22
|
+
prototype.registerHybridMethod("setManySync", &HybridNitroCookiesSpec::setManySync);
|
|
21
23
|
prototype.registerHybridMethod("set", &HybridNitroCookiesSpec::set);
|
|
24
|
+
prototype.registerHybridMethod("setMany", &HybridNitroCookiesSpec::setMany);
|
|
25
|
+
prototype.registerHybridMethod("getCookieHeader", &HybridNitroCookiesSpec::getCookieHeader);
|
|
22
26
|
prototype.registerHybridMethod("get", &HybridNitroCookiesSpec::get);
|
|
23
27
|
prototype.registerHybridMethod("clearAll", &HybridNitroCookiesSpec::clearAll);
|
|
24
28
|
prototype.registerHybridMethod("setFromResponse", &HybridNitroCookiesSpec::setFromResponse);
|
|
@@ -57,7 +57,11 @@ namespace margelo::nitro::nitrocookies {
|
|
|
57
57
|
virtual bool setSync(const std::string& url, const Cookie& cookie) = 0;
|
|
58
58
|
virtual bool setFromResponseSync(const std::string& url, const std::string& value) = 0;
|
|
59
59
|
virtual bool clearByNameSync(const std::string& url, const std::string& name) = 0;
|
|
60
|
+
virtual std::string getCookieHeaderSync(const std::string& url) = 0;
|
|
61
|
+
virtual bool setManySync(const std::string& url, const std::vector<Cookie>& cookies) = 0;
|
|
60
62
|
virtual std::shared_ptr<Promise<bool>> set(const std::string& url, const Cookie& cookie, std::optional<bool> useWebKit) = 0;
|
|
63
|
+
virtual std::shared_ptr<Promise<bool>> setMany(const std::string& url, const std::vector<Cookie>& cookies, std::optional<bool> useWebKit) = 0;
|
|
64
|
+
virtual std::shared_ptr<Promise<std::string>> getCookieHeader(const std::string& url, std::optional<bool> useWebKit) = 0;
|
|
61
65
|
virtual std::shared_ptr<Promise<std::vector<Cookie>>> get(const std::string& url, std::optional<bool> useWebKit) = 0;
|
|
62
66
|
virtual std::shared_ptr<Promise<bool>> clearAll(std::optional<bool> useWebKit) = 0;
|
|
63
67
|
virtual std::shared_ptr<Promise<bool>> setFromResponse(const std::string& url, const std::string& value) = 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-cookies",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Fetch, Get Cookies 🍪 at the Speed of Nitro",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -72,16 +72,17 @@
|
|
|
72
72
|
"registry": "https://registry.npmjs.org/"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@react-native/babel-preset": "0.
|
|
75
|
+
"@react-native/babel-preset": "0.85.3",
|
|
76
|
+
"@react-native/jest-preset": "0.85.3",
|
|
76
77
|
"@types/jest": "30.0.0",
|
|
77
|
-
"@types/react": "19.2.
|
|
78
|
+
"@types/react": "19.2.17",
|
|
78
79
|
"del-cli": "6.0.0",
|
|
79
80
|
"jest": "30.2.0",
|
|
80
|
-
"nitrogen": "0.35.
|
|
81
|
-
"react": "19.2.
|
|
82
|
-
"react-native": "0.
|
|
81
|
+
"nitrogen": "0.35.9",
|
|
82
|
+
"react": "19.2.7",
|
|
83
|
+
"react-native": "0.85.3",
|
|
83
84
|
"react-native-builder-bob": "0.40.18",
|
|
84
|
-
"react-native-nitro-modules": "0.35.
|
|
85
|
+
"react-native-nitro-modules": "0.35.9",
|
|
85
86
|
"typescript": "5.9.3"
|
|
86
87
|
},
|
|
87
88
|
"peerDependencies": {
|