react-native-nitro-sse 3.0.0-beta.1 → 3.0.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/README.md +43 -23
- package/android/build.gradle +4 -1
- package/android/src/main/java/com/margelo/nitro/nitrosse/NitroSse.kt +110 -64
- package/android/src/main/java/com/margelo/nitro/nitrosse/SseConnectionHandler.kt +32 -23
- package/android/src/main/java/com/margelo/nitro/nitrosse/SseEventBuffer.kt +3 -0
- package/android/src/main/java/com/margelo/nitro/nitrosse/SseNetworkMonitor.kt +29 -2
- package/ios/NitroSse.swift +53 -17
- package/ios/SseConfig+CopyWith.swift +35 -19
- package/lib/module/MockSseEngine.js +0 -5
- package/lib/module/NitroSseClient.js +55 -7
- package/lib/module/createNitroSse.js +24 -0
- package/lib/module/index.js +1 -22
- package/lib/module/useNitroSse.js +22 -5
- package/lib/typescript/src/NitroSse.nitro.d.ts +2 -2
- package/lib/typescript/src/NitroSseClient.d.ts +7 -3
- package/lib/typescript/src/SseInterface.d.ts +14 -7
- package/lib/typescript/src/createNitroSse.d.ts +9 -0
- package/lib/typescript/src/index.d.ts +1 -8
- package/lib/typescript/src/useNitroSse.d.ts +2 -2
- package/nitrogen/generated/android/c++/JHybridNitroSseSpec.cpp +8 -8
- package/nitrogen/generated/android/c++/JHybridNitroSseSpec.hpp +1 -1
- package/nitrogen/generated/android/c++/JSseConfig.hpp +1 -18
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/HybridNitroSseSpec.kt +4 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/SseConfig.kt +4 -13
- package/nitrogen/generated/android/nitrosseOnLoad.cpp +2 -2
- package/nitrogen/generated/ios/NitroSse-Swift-Cxx-Bridge.cpp +8 -8
- package/nitrogen/generated/ios/NitroSse-Swift-Cxx-Bridge.hpp +104 -104
- package/nitrogen/generated/ios/c++/HybridNitroSseSpecSwift.hpp +4 -4
- package/nitrogen/generated/ios/swift/HybridNitroSseSpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridNitroSseSpec_cxx.swift +34 -1
- package/nitrogen/generated/ios/swift/SseConfig.swift +1 -48
- package/nitrogen/generated/shared/c++/HybridNitroSseSpec.hpp +3 -1
- package/nitrogen/generated/shared/c++/SseConfig.hpp +2 -8
- package/package.json +1 -1
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import type { SseClient } from './SseInterface';
|
|
2
1
|
export * from './SseInterface';
|
|
3
2
|
export * from './useNitroSse';
|
|
4
3
|
export * from './NitroSseClient';
|
|
5
4
|
export * from './NitroSseError';
|
|
6
|
-
|
|
7
|
-
* Creates a high-performance SSE client that supports typed event listeners (`addEventListener`) and legacy batching.
|
|
8
|
-
*
|
|
9
|
-
* @returns An SseClient instance wrapping the native NitroSse implementation.
|
|
10
|
-
* @throws {NitroSseModuleNotFoundError} If the native NitroSse module cannot be found. Ensure the library is linked and the app is built for iOS/Android.
|
|
11
|
-
*/
|
|
12
|
-
export declare function createNitroSse(): SseClient;
|
|
5
|
+
export * from './createNitroSse';
|
|
13
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { SseClient,
|
|
1
|
+
import type { SseClient, SseClientOptions, SseEvent, SseState, SseStats } from './SseInterface';
|
|
2
2
|
import type { AnyMap } from 'react-native-nitro-modules';
|
|
3
3
|
type SseEventMap = object;
|
|
4
|
-
export interface UseNitroSseOptions<TEvents extends SseEventMap = Record<string, AnyMap>, TMessage = AnyMap> extends
|
|
4
|
+
export interface UseNitroSseOptions<TEvents extends SseEventMap = Record<string, AnyMap>, TMessage = AnyMap> extends SseClientOptions {
|
|
5
5
|
/**
|
|
6
6
|
* Whether to automatically start streaming on mount or when URL changes.
|
|
7
7
|
* @default true
|
|
@@ -37,11 +37,6 @@ namespace margelo::nitro::nitrosse { struct SseEvent; }
|
|
|
37
37
|
#include "HttpMethod.hpp"
|
|
38
38
|
#include "JHttpMethod.hpp"
|
|
39
39
|
#include <unordered_map>
|
|
40
|
-
#include <NitroModules/Promise.hpp>
|
|
41
|
-
#include <functional>
|
|
42
|
-
#include "JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____.hpp"
|
|
43
|
-
#include <NitroModules/JNICallable.hpp>
|
|
44
|
-
#include <NitroModules/JPromise.hpp>
|
|
45
40
|
#include "SseMockConfig.hpp"
|
|
46
41
|
#include "JSseMockConfig.hpp"
|
|
47
42
|
#include "SseMockMode.hpp"
|
|
@@ -54,8 +49,13 @@ namespace margelo::nitro::nitrosse { struct SseEvent; }
|
|
|
54
49
|
#include <NitroModules/AnyMap.hpp>
|
|
55
50
|
#include <NitroModules/JAnyMap.hpp>
|
|
56
51
|
#include "SseEvent.hpp"
|
|
52
|
+
#include <functional>
|
|
57
53
|
#include "JFunc_void_std__vector_SseEvent_.hpp"
|
|
54
|
+
#include <NitroModules/JNICallable.hpp>
|
|
58
55
|
#include "JSseEvent.hpp"
|
|
56
|
+
#include <NitroModules/Promise.hpp>
|
|
57
|
+
#include "JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____.hpp"
|
|
58
|
+
#include <NitroModules/JPromise.hpp>
|
|
59
59
|
|
|
60
60
|
namespace margelo::nitro::nitrosse {
|
|
61
61
|
|
|
@@ -90,9 +90,9 @@ namespace margelo::nitro::nitrosse {
|
|
|
90
90
|
|
|
91
91
|
|
|
92
92
|
// Methods
|
|
93
|
-
void JHybridNitroSseSpec::setup(const SseConfig& config, const std::function<void(const std::vector<SseEvent>& /* events */)>& onEvent) {
|
|
94
|
-
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JSseConfig> /* config */, jni::alias_ref<JFunc_void_std__vector_SseEvent_::javaobject> /* onEvent */)>("setup_cxx");
|
|
95
|
-
method(_javaPart, JSseConfig::fromCpp(config), JFunc_void_std__vector_SseEvent__cxx::fromCpp(onEvent));
|
|
93
|
+
void JHybridNitroSseSpec::setup(const SseConfig& config, const std::function<void(const std::vector<SseEvent>& /* events */)>& onEvent, const std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::unordered_map<std::string, std::string>>>>>()>>& onBeforeRequest) {
|
|
94
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JSseConfig> /* config */, jni::alias_ref<JFunc_void_std__vector_SseEvent_::javaobject> /* onEvent */, jni::alias_ref<JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____::javaobject> /* onBeforeRequest */)>("setup_cxx");
|
|
95
|
+
method(_javaPart, JSseConfig::fromCpp(config), JFunc_void_std__vector_SseEvent__cxx::fromCpp(onEvent), onBeforeRequest.has_value() ? JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string______cxx::fromCpp(onBeforeRequest.value()) : nullptr);
|
|
96
96
|
}
|
|
97
97
|
void JHybridNitroSseSpec::start() {
|
|
98
98
|
static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("start");
|
|
@@ -54,7 +54,7 @@ namespace margelo::nitro::nitrosse {
|
|
|
54
54
|
|
|
55
55
|
public:
|
|
56
56
|
// Methods
|
|
57
|
-
void setup(const SseConfig& config, const std::function<void(const std::vector<SseEvent>& /* events */)>& onEvent) override;
|
|
57
|
+
void setup(const SseConfig& config, const std::function<void(const std::vector<SseEvent>& /* events */)>& onEvent, const std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::unordered_map<std::string, std::string>>>>>()>>& onBeforeRequest) override;
|
|
58
58
|
void start() override;
|
|
59
59
|
void stop() override;
|
|
60
60
|
void setLastProcessedId(const std::string& id) override;
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
#include "SseConfig.hpp"
|
|
12
12
|
|
|
13
13
|
#include "HttpMethod.hpp"
|
|
14
|
-
#include "JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____.hpp"
|
|
15
14
|
#include "JHttpMethod.hpp"
|
|
16
15
|
#include "JSseEventType.hpp"
|
|
17
16
|
#include "JSseMockConfig.hpp"
|
|
@@ -25,10 +24,6 @@
|
|
|
25
24
|
#include "SseState.hpp"
|
|
26
25
|
#include <NitroModules/AnyMap.hpp>
|
|
27
26
|
#include <NitroModules/JAnyMap.hpp>
|
|
28
|
-
#include <NitroModules/JNICallable.hpp>
|
|
29
|
-
#include <NitroModules/JPromise.hpp>
|
|
30
|
-
#include <NitroModules/Promise.hpp>
|
|
31
|
-
#include <functional>
|
|
32
27
|
#include <optional>
|
|
33
28
|
#include <string>
|
|
34
29
|
#include <unordered_map>
|
|
@@ -85,8 +80,6 @@ namespace margelo::nitro::nitrosse {
|
|
|
85
80
|
jni::local_ref<jni::JBoolean> autoParseJSON = this->getFieldValue(fieldAutoParseJSON);
|
|
86
81
|
static const auto fieldMonitorNetwork = clazz->getField<jni::JBoolean>("monitorNetwork");
|
|
87
82
|
jni::local_ref<jni::JBoolean> monitorNetwork = this->getFieldValue(fieldMonitorNetwork);
|
|
88
|
-
static const auto fieldOnBeforeRequest = clazz->getField<JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____::javaobject>("onBeforeRequest");
|
|
89
|
-
jni::local_ref<JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____::javaobject> onBeforeRequest = this->getFieldValue(fieldOnBeforeRequest);
|
|
90
83
|
static const auto fieldMock = clazz->getField<JSseMockConfig>("mock");
|
|
91
84
|
jni::local_ref<JSseMockConfig> mock = this->getFieldValue(fieldMock);
|
|
92
85
|
return SseConfig(
|
|
@@ -113,15 +106,6 @@ namespace margelo::nitro::nitrosse {
|
|
|
113
106
|
maxAuthRetries != nullptr ? std::make_optional(maxAuthRetries->value()) : std::nullopt,
|
|
114
107
|
autoParseJSON != nullptr ? std::make_optional(static_cast<bool>(autoParseJSON->value())) : std::nullopt,
|
|
115
108
|
monitorNetwork != nullptr ? std::make_optional(static_cast<bool>(monitorNetwork->value())) : std::nullopt,
|
|
116
|
-
onBeforeRequest != nullptr ? std::make_optional([&]() -> std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::unordered_map<std::string, std::string>>>>>()> {
|
|
117
|
-
if (onBeforeRequest->isInstanceOf(JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string______cxx::javaClassStatic())) [[likely]] {
|
|
118
|
-
auto downcast = jni::static_ref_cast<JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string______cxx::javaobject>(onBeforeRequest);
|
|
119
|
-
return downcast->cthis()->getFunction();
|
|
120
|
-
} else {
|
|
121
|
-
auto onBeforeRequestRef = jni::make_global(onBeforeRequest);
|
|
122
|
-
return JNICallable<JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____, std::shared_ptr<Promise<std::shared_ptr<Promise<std::unordered_map<std::string, std::string>>>>>()>(std::move(onBeforeRequestRef));
|
|
123
|
-
}
|
|
124
|
-
}()) : std::nullopt,
|
|
125
109
|
mock != nullptr ? std::make_optional(mock->toCpp()) : std::nullopt
|
|
126
110
|
);
|
|
127
111
|
}
|
|
@@ -132,7 +116,7 @@ namespace margelo::nitro::nitrosse {
|
|
|
132
116
|
*/
|
|
133
117
|
[[maybe_unused]]
|
|
134
118
|
static jni::local_ref<JSseConfig::javaobject> fromCpp(const SseConfig& value) {
|
|
135
|
-
using JSignature = JSseConfig(jni::alias_ref<jni::JString>, jni::alias_ref<JHttpMethod>, jni::alias_ref<jni::JMap<jni::JString, jni::JString>>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<
|
|
119
|
+
using JSignature = JSseConfig(jni::alias_ref<jni::JString>, jni::alias_ref<JHttpMethod>, jni::alias_ref<jni::JMap<jni::JString, jni::JString>>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<JSseMockConfig>);
|
|
136
120
|
static const auto clazz = javaClassStatic();
|
|
137
121
|
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
138
122
|
return create(
|
|
@@ -159,7 +143,6 @@ namespace margelo::nitro::nitrosse {
|
|
|
159
143
|
value.maxAuthRetries.has_value() ? jni::JDouble::valueOf(value.maxAuthRetries.value()) : nullptr,
|
|
160
144
|
value.autoParseJSON.has_value() ? jni::JBoolean::valueOf(value.autoParseJSON.value()) : nullptr,
|
|
161
145
|
value.monitorNetwork.has_value() ? jni::JBoolean::valueOf(value.monitorNetwork.value()) : nullptr,
|
|
162
|
-
value.onBeforeRequest.has_value() ? JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string______cxx::fromCpp(value.onBeforeRequest.value()) : nullptr,
|
|
163
146
|
value.mock.has_value() ? JSseMockConfig::fromCpp(value.mock.value()) : nullptr
|
|
164
147
|
);
|
|
165
148
|
}
|
|
@@ -11,6 +11,7 @@ import androidx.annotation.Keep
|
|
|
11
11
|
import com.facebook.jni.HybridData
|
|
12
12
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
13
|
import dalvik.annotation.optimization.FastNative
|
|
14
|
+
import com.margelo.nitro.core.Promise
|
|
14
15
|
import com.margelo.nitro.core.HybridObject
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -29,12 +30,12 @@ abstract class HybridNitroSseSpec: HybridObject() {
|
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
// Methods
|
|
32
|
-
abstract fun setup(config: SseConfig, onEvent: (events: Array<SseEvent>) -> Unit): Unit
|
|
33
|
+
abstract fun setup(config: SseConfig, onEvent: (events: Array<SseEvent>) -> Unit, onBeforeRequest: (() -> Promise<Promise<Map<String, String>>>)?): Unit
|
|
33
34
|
|
|
34
35
|
@DoNotStrip
|
|
35
36
|
@Keep
|
|
36
|
-
private fun setup_cxx(config: SseConfig, onEvent: Func_void_std__vector_SseEvent_): Unit {
|
|
37
|
-
val __result = setup(config, onEvent)
|
|
37
|
+
private fun setup_cxx(config: SseConfig, onEvent: Func_void_std__vector_SseEvent_, onBeforeRequest: Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____?): Unit {
|
|
38
|
+
val __result = setup(config, onEvent, onBeforeRequest?.let { it })
|
|
38
39
|
return __result
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -10,7 +10,7 @@ package com.margelo.nitro.nitrosse
|
|
|
10
10
|
import androidx.annotation.Keep
|
|
11
11
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
12
|
import java.util.Objects
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Represents the JavaScript object/struct "SseConfig".
|
|
@@ -68,16 +68,9 @@ data class SseConfig(
|
|
|
68
68
|
val monitorNetwork: Boolean?,
|
|
69
69
|
@DoNotStrip
|
|
70
70
|
@Keep
|
|
71
|
-
val onBeforeRequest: Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____?,
|
|
72
|
-
@DoNotStrip
|
|
73
|
-
@Keep
|
|
74
71
|
val mock: SseMockConfig?
|
|
75
72
|
) {
|
|
76
|
-
|
|
77
|
-
* Create a new instance of SseConfig from Kotlin
|
|
78
|
-
*/
|
|
79
|
-
constructor(url: String, method: HttpMethod?, headers: Map<String, String>?, body: String?, backgroundExecution: Boolean?, batchingIntervalMs: Double?, maxBufferSize: Double?, connectionTimeoutMs: Double?, readTimeoutMs: Double?, retryIntervalMs: Double?, maxRetryIntervalMs: Double?, jitterFactor: Double?, maxReconnectAttempts: Double?, maxAuthRetries: Double?, autoParseJSON: Boolean?, monitorNetwork: Boolean?, onBeforeRequest: (() -> Promise<Promise<Map<String, String>>>)?, mock: SseMockConfig?):
|
|
80
|
-
this(url, method, headers, body, backgroundExecution, batchingIntervalMs, maxBufferSize, connectionTimeoutMs, readTimeoutMs, retryIntervalMs, maxRetryIntervalMs, jitterFactor, maxReconnectAttempts, maxAuthRetries, autoParseJSON, monitorNetwork, onBeforeRequest?.let { Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string______java(it) }, mock)
|
|
73
|
+
/* primary constructor */
|
|
81
74
|
|
|
82
75
|
override fun equals(other: Any?): Boolean {
|
|
83
76
|
if (this === other) return true
|
|
@@ -98,7 +91,6 @@ data class SseConfig(
|
|
|
98
91
|
&& Objects.deepEquals(this.maxAuthRetries, other.maxAuthRetries)
|
|
99
92
|
&& Objects.deepEquals(this.autoParseJSON, other.autoParseJSON)
|
|
100
93
|
&& Objects.deepEquals(this.monitorNetwork, other.monitorNetwork)
|
|
101
|
-
&& Objects.deepEquals(this.onBeforeRequest, other.onBeforeRequest)
|
|
102
94
|
&& Objects.deepEquals(this.mock, other.mock)
|
|
103
95
|
}
|
|
104
96
|
|
|
@@ -120,7 +112,6 @@ data class SseConfig(
|
|
|
120
112
|
maxAuthRetries,
|
|
121
113
|
autoParseJSON,
|
|
122
114
|
monitorNetwork,
|
|
123
|
-
onBeforeRequest,
|
|
124
115
|
mock
|
|
125
116
|
).contentDeepHashCode()
|
|
126
117
|
}
|
|
@@ -133,8 +124,8 @@ data class SseConfig(
|
|
|
133
124
|
@Keep
|
|
134
125
|
@Suppress("unused")
|
|
135
126
|
@JvmStatic
|
|
136
|
-
private fun fromCpp(url: String, method: HttpMethod?, headers: Map<String, String>?, body: String?, backgroundExecution: Boolean?, batchingIntervalMs: Double?, maxBufferSize: Double?, connectionTimeoutMs: Double?, readTimeoutMs: Double?, retryIntervalMs: Double?, maxRetryIntervalMs: Double?, jitterFactor: Double?, maxReconnectAttempts: Double?, maxAuthRetries: Double?, autoParseJSON: Boolean?, monitorNetwork: Boolean?,
|
|
137
|
-
return SseConfig(url, method, headers, body, backgroundExecution, batchingIntervalMs, maxBufferSize, connectionTimeoutMs, readTimeoutMs, retryIntervalMs, maxRetryIntervalMs, jitterFactor, maxReconnectAttempts, maxAuthRetries, autoParseJSON, monitorNetwork,
|
|
127
|
+
private fun fromCpp(url: String, method: HttpMethod?, headers: Map<String, String>?, body: String?, backgroundExecution: Boolean?, batchingIntervalMs: Double?, maxBufferSize: Double?, connectionTimeoutMs: Double?, readTimeoutMs: Double?, retryIntervalMs: Double?, maxRetryIntervalMs: Double?, jitterFactor: Double?, maxReconnectAttempts: Double?, maxAuthRetries: Double?, autoParseJSON: Boolean?, monitorNetwork: Boolean?, mock: SseMockConfig?): SseConfig {
|
|
128
|
+
return SseConfig(url, method, headers, body, backgroundExecution, batchingIntervalMs, maxBufferSize, connectionTimeoutMs, readTimeoutMs, retryIntervalMs, maxRetryIntervalMs, jitterFactor, maxReconnectAttempts, maxAuthRetries, autoParseJSON, monitorNetwork, mock)
|
|
138
129
|
}
|
|
139
130
|
}
|
|
140
131
|
}
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
#include <NitroModules/HybridObjectRegistry.hpp>
|
|
17
17
|
|
|
18
18
|
#include "JHybridNitroSseSpec.hpp"
|
|
19
|
-
#include "JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____.hpp"
|
|
20
19
|
#include "JFunc_void_std__vector_SseEvent_.hpp"
|
|
20
|
+
#include "JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____.hpp"
|
|
21
21
|
#include <NitroModules/DefaultConstructableObject.hpp>
|
|
22
22
|
|
|
23
23
|
namespace margelo::nitro::nitrosse {
|
|
@@ -43,8 +43,8 @@ void registerAllNatives() {
|
|
|
43
43
|
|
|
44
44
|
// Register native JNI methods
|
|
45
45
|
margelo::nitro::nitrosse::JHybridNitroSseSpec::CxxPart::registerNatives();
|
|
46
|
-
margelo::nitro::nitrosse::JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string______cxx::registerNatives();
|
|
47
46
|
margelo::nitro::nitrosse::JFunc_void_std__vector_SseEvent__cxx::registerNatives();
|
|
47
|
+
margelo::nitro::nitrosse::JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string______cxx::registerNatives();
|
|
48
48
|
|
|
49
49
|
// Register Nitro Hybrid Objects
|
|
50
50
|
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
@@ -14,6 +14,14 @@
|
|
|
14
14
|
|
|
15
15
|
namespace margelo::nitro::nitrosse::bridge::swift {
|
|
16
16
|
|
|
17
|
+
// pragma MARK: std::function<void(const std::vector<SseEvent>& /* events */)>
|
|
18
|
+
Func_void_std__vector_SseEvent_ create_Func_void_std__vector_SseEvent_(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
19
|
+
auto swiftClosure = NitroSse::Func_void_std__vector_SseEvent_::fromUnsafe(swiftClosureWrapper);
|
|
20
|
+
return [swiftClosure = std::move(swiftClosure)](const std::vector<SseEvent>& events) mutable -> void {
|
|
21
|
+
swiftClosure.call(events);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
// pragma MARK: std::function<void(const std::unordered_map<std::string, std::string>& /* result */)>
|
|
18
26
|
Func_void_std__unordered_map_std__string__std__string_ create_Func_void_std__unordered_map_std__string__std__string_(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
19
27
|
auto swiftClosure = NitroSse::Func_void_std__unordered_map_std__string__std__string_::fromUnsafe(swiftClosureWrapper);
|
|
@@ -47,14 +55,6 @@ namespace margelo::nitro::nitrosse::bridge::swift {
|
|
|
47
55
|
};
|
|
48
56
|
}
|
|
49
57
|
|
|
50
|
-
// pragma MARK: std::function<void(const std::vector<SseEvent>& /* events */)>
|
|
51
|
-
Func_void_std__vector_SseEvent_ create_Func_void_std__vector_SseEvent_(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
52
|
-
auto swiftClosure = NitroSse::Func_void_std__vector_SseEvent_::fromUnsafe(swiftClosureWrapper);
|
|
53
|
-
return [swiftClosure = std::move(swiftClosure)](const std::vector<SseEvent>& events) mutable -> void {
|
|
54
|
-
swiftClosure.call(events);
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
58
|
// pragma MARK: std::shared_ptr<HybridNitroSseSpec>
|
|
59
59
|
std::shared_ptr<HybridNitroSseSpec> create_std__shared_ptr_HybridNitroSseSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
60
60
|
NitroSse::HybridNitroSseSpec_cxx swiftPart = NitroSse::HybridNitroSseSpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
@@ -159,6 +159,110 @@ namespace margelo::nitro::nitrosse::bridge::swift {
|
|
|
159
159
|
return optional.value();
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
// pragma MARK: std::optional<SseEventType>
|
|
163
|
+
/**
|
|
164
|
+
* Specialized version of `std::optional<SseEventType>`.
|
|
165
|
+
*/
|
|
166
|
+
using std__optional_SseEventType_ = std::optional<SseEventType>;
|
|
167
|
+
inline std::optional<SseEventType> create_std__optional_SseEventType_(const SseEventType& value) noexcept {
|
|
168
|
+
return std::optional<SseEventType>(value);
|
|
169
|
+
}
|
|
170
|
+
inline bool has_value_std__optional_SseEventType_(const std::optional<SseEventType>& optional) noexcept {
|
|
171
|
+
return optional.has_value();
|
|
172
|
+
}
|
|
173
|
+
inline SseEventType get_std__optional_SseEventType_(const std::optional<SseEventType>& optional) noexcept {
|
|
174
|
+
return optional.value();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// pragma MARK: std::optional<std::shared_ptr<AnyMap>>
|
|
178
|
+
/**
|
|
179
|
+
* Specialized version of `std::optional<std::shared_ptr<AnyMap>>`.
|
|
180
|
+
*/
|
|
181
|
+
using std__optional_std__shared_ptr_AnyMap__ = std::optional<std::shared_ptr<AnyMap>>;
|
|
182
|
+
inline std::optional<std::shared_ptr<AnyMap>> create_std__optional_std__shared_ptr_AnyMap__(const std::shared_ptr<AnyMap>& value) noexcept {
|
|
183
|
+
return std::optional<std::shared_ptr<AnyMap>>(value);
|
|
184
|
+
}
|
|
185
|
+
inline bool has_value_std__optional_std__shared_ptr_AnyMap__(const std::optional<std::shared_ptr<AnyMap>>& optional) noexcept {
|
|
186
|
+
return optional.has_value();
|
|
187
|
+
}
|
|
188
|
+
inline std::shared_ptr<AnyMap> get_std__optional_std__shared_ptr_AnyMap__(const std::optional<std::shared_ptr<AnyMap>>& optional) noexcept {
|
|
189
|
+
return optional.value();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// pragma MARK: std::optional<SseState>
|
|
193
|
+
/**
|
|
194
|
+
* Specialized version of `std::optional<SseState>`.
|
|
195
|
+
*/
|
|
196
|
+
using std__optional_SseState_ = std::optional<SseState>;
|
|
197
|
+
inline std::optional<SseState> create_std__optional_SseState_(const SseState& value) noexcept {
|
|
198
|
+
return std::optional<SseState>(value);
|
|
199
|
+
}
|
|
200
|
+
inline bool has_value_std__optional_SseState_(const std::optional<SseState>& optional) noexcept {
|
|
201
|
+
return optional.has_value();
|
|
202
|
+
}
|
|
203
|
+
inline SseState get_std__optional_SseState_(const std::optional<SseState>& optional) noexcept {
|
|
204
|
+
return optional.value();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// pragma MARK: std::vector<SseMockEvent>
|
|
208
|
+
/**
|
|
209
|
+
* Specialized version of `std::vector<SseMockEvent>`.
|
|
210
|
+
*/
|
|
211
|
+
using std__vector_SseMockEvent_ = std::vector<SseMockEvent>;
|
|
212
|
+
inline std::vector<SseMockEvent> create_std__vector_SseMockEvent_(size_t size) noexcept {
|
|
213
|
+
std::vector<SseMockEvent> vector;
|
|
214
|
+
vector.reserve(size);
|
|
215
|
+
return vector;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// pragma MARK: std::optional<SseMockConfig>
|
|
219
|
+
/**
|
|
220
|
+
* Specialized version of `std::optional<SseMockConfig>`.
|
|
221
|
+
*/
|
|
222
|
+
using std__optional_SseMockConfig_ = std::optional<SseMockConfig>;
|
|
223
|
+
inline std::optional<SseMockConfig> create_std__optional_SseMockConfig_(const SseMockConfig& value) noexcept {
|
|
224
|
+
return std::optional<SseMockConfig>(value);
|
|
225
|
+
}
|
|
226
|
+
inline bool has_value_std__optional_SseMockConfig_(const std::optional<SseMockConfig>& optional) noexcept {
|
|
227
|
+
return optional.has_value();
|
|
228
|
+
}
|
|
229
|
+
inline SseMockConfig get_std__optional_SseMockConfig_(const std::optional<SseMockConfig>& optional) noexcept {
|
|
230
|
+
return optional.value();
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// pragma MARK: std::vector<SseEvent>
|
|
234
|
+
/**
|
|
235
|
+
* Specialized version of `std::vector<SseEvent>`.
|
|
236
|
+
*/
|
|
237
|
+
using std__vector_SseEvent_ = std::vector<SseEvent>;
|
|
238
|
+
inline std::vector<SseEvent> create_std__vector_SseEvent_(size_t size) noexcept {
|
|
239
|
+
std::vector<SseEvent> vector;
|
|
240
|
+
vector.reserve(size);
|
|
241
|
+
return vector;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// pragma MARK: std::function<void(const std::vector<SseEvent>& /* events */)>
|
|
245
|
+
/**
|
|
246
|
+
* Specialized version of `std::function<void(const std::vector<SseEvent>&)>`.
|
|
247
|
+
*/
|
|
248
|
+
using Func_void_std__vector_SseEvent_ = std::function<void(const std::vector<SseEvent>& /* events */)>;
|
|
249
|
+
/**
|
|
250
|
+
* Wrapper class for a `std::function<void(const std::vector<SseEvent>& / * events * /)>`, this can be used from Swift.
|
|
251
|
+
*/
|
|
252
|
+
class Func_void_std__vector_SseEvent__Wrapper final {
|
|
253
|
+
public:
|
|
254
|
+
explicit Func_void_std__vector_SseEvent__Wrapper(std::function<void(const std::vector<SseEvent>& /* events */)>&& func): _function(std::make_unique<std::function<void(const std::vector<SseEvent>& /* events */)>>(std::move(func))) {}
|
|
255
|
+
inline void call(std::vector<SseEvent> events) const noexcept {
|
|
256
|
+
_function->operator()(events);
|
|
257
|
+
}
|
|
258
|
+
private:
|
|
259
|
+
std::unique_ptr<std::function<void(const std::vector<SseEvent>& /* events */)>> _function;
|
|
260
|
+
} SWIFT_NONCOPYABLE;
|
|
261
|
+
Func_void_std__vector_SseEvent_ create_Func_void_std__vector_SseEvent_(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
262
|
+
inline Func_void_std__vector_SseEvent__Wrapper wrap_Func_void_std__vector_SseEvent_(Func_void_std__vector_SseEvent_ value) noexcept {
|
|
263
|
+
return Func_void_std__vector_SseEvent__Wrapper(std::move(value));
|
|
264
|
+
}
|
|
265
|
+
|
|
162
266
|
// pragma MARK: std::shared_ptr<Promise<std::unordered_map<std::string, std::string>>>
|
|
163
267
|
/**
|
|
164
268
|
* Specialized version of `std::shared_ptr<Promise<std::unordered_map<std::string, std::string>>>`.
|
|
@@ -287,110 +391,6 @@ namespace margelo::nitro::nitrosse::bridge::swift {
|
|
|
287
391
|
return optional.value();
|
|
288
392
|
}
|
|
289
393
|
|
|
290
|
-
// pragma MARK: std::optional<SseEventType>
|
|
291
|
-
/**
|
|
292
|
-
* Specialized version of `std::optional<SseEventType>`.
|
|
293
|
-
*/
|
|
294
|
-
using std__optional_SseEventType_ = std::optional<SseEventType>;
|
|
295
|
-
inline std::optional<SseEventType> create_std__optional_SseEventType_(const SseEventType& value) noexcept {
|
|
296
|
-
return std::optional<SseEventType>(value);
|
|
297
|
-
}
|
|
298
|
-
inline bool has_value_std__optional_SseEventType_(const std::optional<SseEventType>& optional) noexcept {
|
|
299
|
-
return optional.has_value();
|
|
300
|
-
}
|
|
301
|
-
inline SseEventType get_std__optional_SseEventType_(const std::optional<SseEventType>& optional) noexcept {
|
|
302
|
-
return optional.value();
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// pragma MARK: std::optional<std::shared_ptr<AnyMap>>
|
|
306
|
-
/**
|
|
307
|
-
* Specialized version of `std::optional<std::shared_ptr<AnyMap>>`.
|
|
308
|
-
*/
|
|
309
|
-
using std__optional_std__shared_ptr_AnyMap__ = std::optional<std::shared_ptr<AnyMap>>;
|
|
310
|
-
inline std::optional<std::shared_ptr<AnyMap>> create_std__optional_std__shared_ptr_AnyMap__(const std::shared_ptr<AnyMap>& value) noexcept {
|
|
311
|
-
return std::optional<std::shared_ptr<AnyMap>>(value);
|
|
312
|
-
}
|
|
313
|
-
inline bool has_value_std__optional_std__shared_ptr_AnyMap__(const std::optional<std::shared_ptr<AnyMap>>& optional) noexcept {
|
|
314
|
-
return optional.has_value();
|
|
315
|
-
}
|
|
316
|
-
inline std::shared_ptr<AnyMap> get_std__optional_std__shared_ptr_AnyMap__(const std::optional<std::shared_ptr<AnyMap>>& optional) noexcept {
|
|
317
|
-
return optional.value();
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
// pragma MARK: std::optional<SseState>
|
|
321
|
-
/**
|
|
322
|
-
* Specialized version of `std::optional<SseState>`.
|
|
323
|
-
*/
|
|
324
|
-
using std__optional_SseState_ = std::optional<SseState>;
|
|
325
|
-
inline std::optional<SseState> create_std__optional_SseState_(const SseState& value) noexcept {
|
|
326
|
-
return std::optional<SseState>(value);
|
|
327
|
-
}
|
|
328
|
-
inline bool has_value_std__optional_SseState_(const std::optional<SseState>& optional) noexcept {
|
|
329
|
-
return optional.has_value();
|
|
330
|
-
}
|
|
331
|
-
inline SseState get_std__optional_SseState_(const std::optional<SseState>& optional) noexcept {
|
|
332
|
-
return optional.value();
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
// pragma MARK: std::vector<SseMockEvent>
|
|
336
|
-
/**
|
|
337
|
-
* Specialized version of `std::vector<SseMockEvent>`.
|
|
338
|
-
*/
|
|
339
|
-
using std__vector_SseMockEvent_ = std::vector<SseMockEvent>;
|
|
340
|
-
inline std::vector<SseMockEvent> create_std__vector_SseMockEvent_(size_t size) noexcept {
|
|
341
|
-
std::vector<SseMockEvent> vector;
|
|
342
|
-
vector.reserve(size);
|
|
343
|
-
return vector;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
// pragma MARK: std::optional<SseMockConfig>
|
|
347
|
-
/**
|
|
348
|
-
* Specialized version of `std::optional<SseMockConfig>`.
|
|
349
|
-
*/
|
|
350
|
-
using std__optional_SseMockConfig_ = std::optional<SseMockConfig>;
|
|
351
|
-
inline std::optional<SseMockConfig> create_std__optional_SseMockConfig_(const SseMockConfig& value) noexcept {
|
|
352
|
-
return std::optional<SseMockConfig>(value);
|
|
353
|
-
}
|
|
354
|
-
inline bool has_value_std__optional_SseMockConfig_(const std::optional<SseMockConfig>& optional) noexcept {
|
|
355
|
-
return optional.has_value();
|
|
356
|
-
}
|
|
357
|
-
inline SseMockConfig get_std__optional_SseMockConfig_(const std::optional<SseMockConfig>& optional) noexcept {
|
|
358
|
-
return optional.value();
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// pragma MARK: std::vector<SseEvent>
|
|
362
|
-
/**
|
|
363
|
-
* Specialized version of `std::vector<SseEvent>`.
|
|
364
|
-
*/
|
|
365
|
-
using std__vector_SseEvent_ = std::vector<SseEvent>;
|
|
366
|
-
inline std::vector<SseEvent> create_std__vector_SseEvent_(size_t size) noexcept {
|
|
367
|
-
std::vector<SseEvent> vector;
|
|
368
|
-
vector.reserve(size);
|
|
369
|
-
return vector;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
// pragma MARK: std::function<void(const std::vector<SseEvent>& /* events */)>
|
|
373
|
-
/**
|
|
374
|
-
* Specialized version of `std::function<void(const std::vector<SseEvent>&)>`.
|
|
375
|
-
*/
|
|
376
|
-
using Func_void_std__vector_SseEvent_ = std::function<void(const std::vector<SseEvent>& /* events */)>;
|
|
377
|
-
/**
|
|
378
|
-
* Wrapper class for a `std::function<void(const std::vector<SseEvent>& / * events * /)>`, this can be used from Swift.
|
|
379
|
-
*/
|
|
380
|
-
class Func_void_std__vector_SseEvent__Wrapper final {
|
|
381
|
-
public:
|
|
382
|
-
explicit Func_void_std__vector_SseEvent__Wrapper(std::function<void(const std::vector<SseEvent>& /* events */)>&& func): _function(std::make_unique<std::function<void(const std::vector<SseEvent>& /* events */)>>(std::move(func))) {}
|
|
383
|
-
inline void call(std::vector<SseEvent> events) const noexcept {
|
|
384
|
-
_function->operator()(events);
|
|
385
|
-
}
|
|
386
|
-
private:
|
|
387
|
-
std::unique_ptr<std::function<void(const std::vector<SseEvent>& /* events */)>> _function;
|
|
388
|
-
} SWIFT_NONCOPYABLE;
|
|
389
|
-
Func_void_std__vector_SseEvent_ create_Func_void_std__vector_SseEvent_(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
390
|
-
inline Func_void_std__vector_SseEvent__Wrapper wrap_Func_void_std__vector_SseEvent_(Func_void_std__vector_SseEvent_ value) noexcept {
|
|
391
|
-
return Func_void_std__vector_SseEvent__Wrapper(std::move(value));
|
|
392
|
-
}
|
|
393
|
-
|
|
394
394
|
// pragma MARK: std::shared_ptr<HybridNitroSseSpec>
|
|
395
395
|
/**
|
|
396
396
|
* Specialized version of `std::shared_ptr<HybridNitroSseSpec>`.
|
|
@@ -36,8 +36,6 @@ namespace margelo::nitro::nitrosse { struct SseStats; }
|
|
|
36
36
|
#include "HttpMethod.hpp"
|
|
37
37
|
#include <optional>
|
|
38
38
|
#include <unordered_map>
|
|
39
|
-
#include <NitroModules/Promise.hpp>
|
|
40
|
-
#include <functional>
|
|
41
39
|
#include "SseMockConfig.hpp"
|
|
42
40
|
#include "SseMockMode.hpp"
|
|
43
41
|
#include "SseMockEvent.hpp"
|
|
@@ -46,6 +44,8 @@ namespace margelo::nitro::nitrosse { struct SseStats; }
|
|
|
46
44
|
#include <NitroModules/AnyMap.hpp>
|
|
47
45
|
#include "SseState.hpp"
|
|
48
46
|
#include "SseEvent.hpp"
|
|
47
|
+
#include <functional>
|
|
48
|
+
#include <NitroModules/Promise.hpp>
|
|
49
49
|
#include "SseStats.hpp"
|
|
50
50
|
|
|
51
51
|
#include "NitroSse-Swift-Cxx-Umbrella.hpp"
|
|
@@ -98,8 +98,8 @@ namespace margelo::nitro::nitrosse {
|
|
|
98
98
|
|
|
99
99
|
public:
|
|
100
100
|
// Methods
|
|
101
|
-
inline void setup(const SseConfig& config, const std::function<void(const std::vector<SseEvent>& /* events */)>& onEvent) override {
|
|
102
|
-
auto __result = _swiftPart.setup(std::forward<decltype(config)>(config), onEvent);
|
|
101
|
+
inline void setup(const SseConfig& config, const std::function<void(const std::vector<SseEvent>& /* events */)>& onEvent, const std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::unordered_map<std::string, std::string>>>>>()>>& onBeforeRequest) override {
|
|
102
|
+
auto __result = _swiftPart.setup(std::forward<decltype(config)>(config), onEvent, onBeforeRequest);
|
|
103
103
|
if (__result.hasError()) [[unlikely]] {
|
|
104
104
|
std::rethrow_exception(__result.error());
|
|
105
105
|
}
|
|
@@ -13,7 +13,7 @@ public protocol HybridNitroSseSpec_protocol: HybridObject {
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
// Methods
|
|
16
|
-
func setup(config: SseConfig, onEvent: @escaping (_ events: [SseEvent]) -> Void) throws -> Void
|
|
16
|
+
func setup(config: SseConfig, onEvent: @escaping (_ events: [SseEvent]) -> Void, onBeforeRequest: (() -> Promise<Promise<Dictionary<String, String>>>)?) throws -> Void
|
|
17
17
|
func start() throws -> Void
|
|
18
18
|
func stop() throws -> Void
|
|
19
19
|
func setLastProcessedId(id: String) throws -> Void
|
|
@@ -125,7 +125,7 @@ open class HybridNitroSseSpec_cxx {
|
|
|
125
125
|
|
|
126
126
|
// Methods
|
|
127
127
|
@inline(__always)
|
|
128
|
-
public final func setup(config: SseConfig, onEvent: bridge.Func_void_std__vector_SseEvent_) -> bridge.Result_void_ {
|
|
128
|
+
public final func setup(config: SseConfig, onEvent: bridge.Func_void_std__vector_SseEvent_, onBeforeRequest: bridge.std__optional_std__function_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_________) -> bridge.Result_void_ {
|
|
129
129
|
do {
|
|
130
130
|
try self.__implementation.setup(config: config, onEvent: { () -> ([SseEvent]) -> Void in
|
|
131
131
|
let __wrappedFunction = bridge.wrap_Func_void_std__vector_SseEvent_(onEvent)
|
|
@@ -138,6 +138,39 @@ open class HybridNitroSseSpec_cxx {
|
|
|
138
138
|
return __vector
|
|
139
139
|
}())
|
|
140
140
|
}
|
|
141
|
+
}(), onBeforeRequest: { () -> (() -> Promise<Promise<Dictionary<String, String>>>)? in
|
|
142
|
+
if bridge.has_value_std__optional_std__function_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_________(onBeforeRequest) {
|
|
143
|
+
let __unwrapped = bridge.get_std__optional_std__function_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_________(onBeforeRequest)
|
|
144
|
+
return { () -> () -> Promise<Promise<Dictionary<String, String>>> in
|
|
145
|
+
let __wrappedFunction = bridge.wrap_Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____(__unwrapped)
|
|
146
|
+
return { () -> Promise<Promise<Dictionary<String, String>>> in
|
|
147
|
+
let __result = __wrappedFunction.call()
|
|
148
|
+
return { () -> Promise<Promise<Dictionary<String, String>>> in
|
|
149
|
+
let __promise = Promise<Promise<Dictionary<String, String>>>()
|
|
150
|
+
let __resolver = { (__result: Promise<Dictionary<String, String>>) in
|
|
151
|
+
__promise.resolve(withResult: __result)
|
|
152
|
+
}
|
|
153
|
+
let __rejecter = { (__error: Error) in
|
|
154
|
+
__promise.reject(withError: __error)
|
|
155
|
+
}
|
|
156
|
+
let __resolverCpp = { () -> bridge.Func_void_std__shared_ptr_Promise_std__unordered_map_std__string__std__string___ in
|
|
157
|
+
let __closureWrapper = Func_void_std__shared_ptr_Promise_std__unordered_map_std__string__std__string___(__resolver)
|
|
158
|
+
return bridge.create_Func_void_std__shared_ptr_Promise_std__unordered_map_std__string__std__string___(__closureWrapper.toUnsafe())
|
|
159
|
+
}()
|
|
160
|
+
let __rejecterCpp = { () -> bridge.Func_void_std__exception_ptr in
|
|
161
|
+
let __closureWrapper = Func_void_std__exception_ptr(__rejecter)
|
|
162
|
+
return bridge.create_Func_void_std__exception_ptr(__closureWrapper.toUnsafe())
|
|
163
|
+
}()
|
|
164
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____(__result)
|
|
165
|
+
__promiseHolder.addOnResolvedListener(__resolverCpp)
|
|
166
|
+
__promiseHolder.addOnRejectedListener(__rejecterCpp)
|
|
167
|
+
return __promise
|
|
168
|
+
}()
|
|
169
|
+
}
|
|
170
|
+
}()
|
|
171
|
+
} else {
|
|
172
|
+
return nil
|
|
173
|
+
}
|
|
141
174
|
}())
|
|
142
175
|
return bridge.create_Result_void_()
|
|
143
176
|
} catch (let __error) {
|