react-native-nitro-sse 2.3.2 → 2.4.0-beta.1
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 +1 -1
- package/android/build.gradle +11 -0
- package/android/jacoco.gradle +33 -0
- package/android/src/main/java/com/margelo/nitro/nitrosse/AndroidSseDispatcher.kt +27 -0
- package/android/src/main/java/com/margelo/nitro/nitrosse/JsonUtils.kt +66 -0
- package/android/src/main/java/com/margelo/nitro/nitrosse/NetworkInspector.kt +6 -3
- package/android/src/main/java/com/margelo/nitro/nitrosse/NitroSse.kt +306 -655
- package/android/src/main/java/com/margelo/nitro/nitrosse/NitroSsePackage.kt +4 -0
- package/android/src/main/java/com/margelo/nitro/nitrosse/SseConnectionHandler.kt +108 -0
- package/android/src/main/java/com/margelo/nitro/nitrosse/SseDispatcher.kt +14 -0
- package/android/src/main/java/com/margelo/nitro/nitrosse/SseEventBuffer.kt +99 -0
- package/android/src/main/java/com/margelo/nitro/nitrosse/SseLifecycleManager.kt +52 -0
- package/android/src/main/java/com/margelo/nitro/nitrosse/SseNetworkMonitor.kt +81 -0
- package/android/src/main/java/com/margelo/nitro/nitrosse/SseReconnectStrategy.kt +80 -0
- package/ios/NitroSse.swift +413 -613
- package/ios/SseConfig+CopyWith.swift +46 -0
- package/ios/SseConnectionHandler.swift +113 -0
- package/ios/SseDispatchQueueDispatcher.swift +38 -0
- package/ios/SseDispatcher.swift +18 -0
- package/ios/SseEventBuffer.swift +75 -0
- package/ios/SseLifecycleManager.swift +118 -0
- package/ios/SseNetworkMonitor.swift +79 -0
- package/ios/SseReconnectStrategy.swift +76 -0
- package/lib/module/NitroSseClient.js +8 -1
- package/lib/module/NitroSseClient.js.map +1 -1
- package/lib/typescript/src/NitroSse.nitro.d.ts +5 -1
- package/lib/typescript/src/NitroSse.nitro.d.ts.map +1 -1
- package/lib/typescript/src/NitroSseClient.d.ts +2 -1
- package/lib/typescript/src/NitroSseClient.d.ts.map +1 -1
- package/lib/typescript/src/SseInterface.d.ts +10 -1
- package/lib/typescript/src/SseInterface.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_SseEvent_.hpp +2 -0
- package/nitrogen/generated/android/c++/JHybridNitroSseSpec.cpp +9 -0
- package/nitrogen/generated/android/c++/JHybridNitroSseSpec.hpp +1 -0
- package/nitrogen/generated/android/c++/JSseEvent.hpp +9 -3
- package/nitrogen/generated/android/c++/JSseEventType.hpp +3 -0
- package/nitrogen/generated/android/c++/JSseState.hpp +76 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/Func_void_std__vector_SseEvent_.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/HybridNitroSseSpec.kt +6 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/SseEvent.kt +9 -4
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/SseEventType.kt +2 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/SseState.kt +29 -0
- package/nitrogen/generated/ios/NitroSse-Swift-Cxx-Bridge.hpp +27 -0
- package/nitrogen/generated/ios/NitroSse-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridNitroSseSpecSwift.hpp +11 -0
- package/nitrogen/generated/ios/swift/HybridNitroSseSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridNitroSseSpec_cxx.swift +12 -0
- package/nitrogen/generated/ios/swift/SseEvent.swift +12 -1
- package/nitrogen/generated/ios/swift/SseEventType.swift +4 -0
- package/nitrogen/generated/ios/swift/SseState.swift +64 -0
- package/nitrogen/generated/shared/c++/HybridNitroSseSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridNitroSseSpec.hpp +4 -0
- package/nitrogen/generated/shared/c++/SseEvent.hpp +9 -2
- package/nitrogen/generated/shared/c++/SseEventType.hpp +4 -0
- package/nitrogen/generated/shared/c++/SseState.hpp +100 -0
- package/package.json +3 -3
- package/src/NitroSse.nitro.ts +6 -1
- package/src/NitroSseClient.ts +9 -0
- package/src/SseInterface.ts +25 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NitroSse } from './NitroSse.nitro';
|
|
2
|
-
import type { SseClient, SseConfig, SseEvent, SseListener, SseStats } from './SseInterface';
|
|
2
|
+
import type { SseClient, SseConfig, SseEvent, SseListener, SseStats, SseState } from './SseInterface';
|
|
3
3
|
export declare class NitroSseClient implements SseClient {
|
|
4
4
|
private _native;
|
|
5
5
|
private _listeners;
|
|
@@ -19,6 +19,7 @@ export declare class NitroSseClient implements SseClient {
|
|
|
19
19
|
flush(): void;
|
|
20
20
|
isConnected(): boolean;
|
|
21
21
|
getStats(): SseStats;
|
|
22
|
+
getState(): SseState;
|
|
22
23
|
updateHeaders(headers: Record<string, string>): void;
|
|
23
24
|
setLastProcessedId(id: string): void;
|
|
24
25
|
injectMockEvent(event: Partial<SseEvent>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NitroSseClient.d.ts","sourceRoot":"","sources":["../../../src/NitroSseClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,QAAQ,EACR,WAAW,EACX,QAAQ,EACT,MAAM,gBAAgB,CAAC;AAIxB,qBAAa,cAAe,YAAW,SAAS;IAC9C,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,UAAU,CAA4C;IAC9D,OAAO,CAAC,eAAe,CAAC,CAA+B;IACvD,OAAO,CAAC,OAAO,CAAC,CAAY;IAC5B,OAAO,CAAC,eAAe,CAAC,CAAM;IAC9B,OAAO,CAAC,UAAU,CAAa;gBAEnB,MAAM,EAAE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,OAAO,IAAI,IAAI;IASf,KAAK,IAAI,IAAI;IAIb,WAAW,IAAI,OAAO;IAOtB,QAAQ,IAAI,QAAQ;IAUpB,QAAQ,IAAI,QAAQ;IAOpB,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAIpD,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAIpC,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI;CAQhD"}
|
|
@@ -10,8 +10,13 @@ export type HttpMethod = 'get' | 'post';
|
|
|
10
10
|
* - `error`: Connection error or other failure.
|
|
11
11
|
* - `close`: Connection closed (not typical for SSE, but used for cleanup).
|
|
12
12
|
* - `heartbeat`: Ping/Keep-alive signal.
|
|
13
|
+
* - `state`: Connection state change.
|
|
13
14
|
*/
|
|
14
|
-
export type SseEventType = 'open' | 'message' | 'error' | 'close' | 'heartbeat';
|
|
15
|
+
export type SseEventType = 'open' | 'message' | 'error' | 'close' | 'heartbeat' | 'state';
|
|
16
|
+
/**
|
|
17
|
+
* State of the SSE connection.
|
|
18
|
+
*/
|
|
19
|
+
export type SseState = 'idle' | 'connecting' | 'open' | 'stale' | 'reconnecting' | 'paused' | 'closed' | 'failed';
|
|
15
20
|
/**
|
|
16
21
|
* Configuration for the SSE connection.
|
|
17
22
|
*/
|
|
@@ -178,6 +183,8 @@ export interface SseEvent {
|
|
|
178
183
|
statusCode?: number;
|
|
179
184
|
/** Server-requested retry delay in milliseconds. */
|
|
180
185
|
retry?: number;
|
|
186
|
+
/** The current connection state (only available if type is 'state'). */
|
|
187
|
+
state?: SseState;
|
|
181
188
|
}
|
|
182
189
|
/**
|
|
183
190
|
* Statistics about the SSE connection.
|
|
@@ -233,5 +240,7 @@ export interface SseClient {
|
|
|
233
240
|
setLastProcessedId(id: string): void;
|
|
234
241
|
/** Manually inject a mock event into the stream (for testing/debugging). */
|
|
235
242
|
injectMockEvent(event: Partial<SseEvent>): void;
|
|
243
|
+
/** Get current connection state. */
|
|
244
|
+
getState(): SseState;
|
|
236
245
|
}
|
|
237
246
|
//# sourceMappingURL=SseInterface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SseInterface.d.ts","sourceRoot":"","sources":["../../../src/SseInterface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,CAAC;AAExC
|
|
1
|
+
{"version":3,"file":"SseInterface.d.ts","sourceRoot":"","sources":["../../../src/SseInterface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,CAAC;AAExC;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,SAAS,GACT,OAAO,GACP,OAAO,GACP,WAAW,GACX,OAAO,CAAC;AAEZ;;GAEG;AACH,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,YAAY,GACZ,MAAM,GACN,OAAO,GACP,cAAc,GACd,QAAQ,GACR,QAAQ,GACR,QAAQ,CAAC;AAEb;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,oCAAoC;IACpC,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,8BAA8B;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAA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,EAAE,WAAW,GAAG,IAAI,CAAC;IAE5D;;OAEG;IACH,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC;IAE/D,4BAA4B;IAC5B,KAAK,IAAI,IAAI,CAAC;IACd,2BAA2B;IAC3B,IAAI,IAAI,IAAI,CAAC;IACb,6CAA6C;IAC7C,OAAO,IAAI,IAAI,CAAC;IAChB,yCAAyC;IACzC,KAAK,IAAI,IAAI,CAAC;IACd,uBAAuB;IACvB,WAAW,IAAI,OAAO,CAAC;IACvB,iBAAiB;IACjB,QAAQ,IAAI,QAAQ,CAAC;IACrB,+BAA+B;IAC/B,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IACrD,yBAAyB;IACzB,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,4EAA4E;IAC5E,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;IAChD,oCAAoC;IACpC,QAAQ,IAAI,QAAQ,CAAC;CACtB"}
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
// Forward declaration of `SseStats` to properly resolve imports.
|
|
11
11
|
namespace margelo::nitro::nitrosse { struct SseStats; }
|
|
12
|
+
// Forward declaration of `SseState` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::nitrosse { enum class SseState; }
|
|
12
14
|
// Forward declaration of `SseConfig` to properly resolve imports.
|
|
13
15
|
namespace margelo::nitro::nitrosse { struct SseConfig; }
|
|
14
16
|
// Forward declaration of `HttpMethod` to properly resolve imports.
|
|
@@ -28,6 +30,8 @@ namespace margelo::nitro::nitrosse { struct SseEvent; }
|
|
|
28
30
|
#include "JSseStats.hpp"
|
|
29
31
|
#include <optional>
|
|
30
32
|
#include <string>
|
|
33
|
+
#include "SseState.hpp"
|
|
34
|
+
#include "JSseState.hpp"
|
|
31
35
|
#include "SseConfig.hpp"
|
|
32
36
|
#include "JSseConfig.hpp"
|
|
33
37
|
#include "HttpMethod.hpp"
|
|
@@ -130,5 +134,10 @@ namespace margelo::nitro::nitrosse {
|
|
|
130
134
|
auto __result = method(_javaPart);
|
|
131
135
|
return static_cast<bool>(__result);
|
|
132
136
|
}
|
|
137
|
+
SseState JHybridNitroSseSpec::getState() {
|
|
138
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JSseState>()>("getState");
|
|
139
|
+
auto __result = method(_javaPart);
|
|
140
|
+
return __result->toCpp();
|
|
141
|
+
}
|
|
133
142
|
|
|
134
143
|
} // namespace margelo::nitro::nitrosse
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
#include "SseEvent.hpp"
|
|
12
12
|
|
|
13
13
|
#include "JSseEventType.hpp"
|
|
14
|
+
#include "JSseState.hpp"
|
|
14
15
|
#include "SseEventType.hpp"
|
|
16
|
+
#include "SseState.hpp"
|
|
15
17
|
#include <NitroModules/AnyMap.hpp>
|
|
16
18
|
#include <NitroModules/JAnyMap.hpp>
|
|
17
19
|
#include <optional>
|
|
@@ -52,6 +54,8 @@ namespace margelo::nitro::nitrosse {
|
|
|
52
54
|
jni::local_ref<jni::JDouble> statusCode = this->getFieldValue(fieldStatusCode);
|
|
53
55
|
static const auto fieldRetry = clazz->getField<jni::JDouble>("retry");
|
|
54
56
|
jni::local_ref<jni::JDouble> retry = this->getFieldValue(fieldRetry);
|
|
57
|
+
static const auto fieldState = clazz->getField<JSseState>("state");
|
|
58
|
+
jni::local_ref<JSseState> state = this->getFieldValue(fieldState);
|
|
55
59
|
return SseEvent(
|
|
56
60
|
type->toCpp(),
|
|
57
61
|
data != nullptr ? std::make_optional(data->toStdString()) : std::nullopt,
|
|
@@ -60,7 +64,8 @@ namespace margelo::nitro::nitrosse {
|
|
|
60
64
|
event != nullptr ? std::make_optional(event->toStdString()) : std::nullopt,
|
|
61
65
|
message != nullptr ? std::make_optional(message->toStdString()) : std::nullopt,
|
|
62
66
|
statusCode != nullptr ? std::make_optional(statusCode->value()) : std::nullopt,
|
|
63
|
-
retry != nullptr ? std::make_optional(retry->value()) : std::nullopt
|
|
67
|
+
retry != nullptr ? std::make_optional(retry->value()) : std::nullopt,
|
|
68
|
+
state != nullptr ? std::make_optional(state->toCpp()) : std::nullopt
|
|
64
69
|
);
|
|
65
70
|
}
|
|
66
71
|
|
|
@@ -70,7 +75,7 @@ namespace margelo::nitro::nitrosse {
|
|
|
70
75
|
*/
|
|
71
76
|
[[maybe_unused]]
|
|
72
77
|
static jni::local_ref<JSseEvent::javaobject> fromCpp(const SseEvent& value) {
|
|
73
|
-
using JSignature = JSseEvent(jni::alias_ref<JSseEventType>, jni::alias_ref<jni::JString>, jni::alias_ref<JAnyMap::javaobject>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>);
|
|
78
|
+
using JSignature = JSseEvent(jni::alias_ref<JSseEventType>, jni::alias_ref<jni::JString>, jni::alias_ref<JAnyMap::javaobject>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<JSseState>);
|
|
74
79
|
static const auto clazz = javaClassStatic();
|
|
75
80
|
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
76
81
|
return create(
|
|
@@ -82,7 +87,8 @@ namespace margelo::nitro::nitrosse {
|
|
|
82
87
|
value.event.has_value() ? jni::make_jstring(value.event.value()) : nullptr,
|
|
83
88
|
value.message.has_value() ? jni::make_jstring(value.message.value()) : nullptr,
|
|
84
89
|
value.statusCode.has_value() ? jni::JDouble::valueOf(value.statusCode.value()) : nullptr,
|
|
85
|
-
value.retry.has_value() ? jni::JDouble::valueOf(value.retry.value()) : nullptr
|
|
90
|
+
value.retry.has_value() ? jni::JDouble::valueOf(value.retry.value()) : nullptr,
|
|
91
|
+
value.state.has_value() ? JSseState::fromCpp(value.state.value()) : nullptr
|
|
86
92
|
);
|
|
87
93
|
}
|
|
88
94
|
};
|
|
@@ -57,6 +57,9 @@ namespace margelo::nitro::nitrosse {
|
|
|
57
57
|
case SseEventType::HEARTBEAT:
|
|
58
58
|
static const auto fieldHEARTBEAT = clazz->getStaticField<JSseEventType>("HEARTBEAT");
|
|
59
59
|
return clazz->getStaticFieldValue(fieldHEARTBEAT);
|
|
60
|
+
case SseEventType::STATE:
|
|
61
|
+
static const auto fieldSTATE = clazz->getStaticField<JSseEventType>("STATE");
|
|
62
|
+
return clazz->getStaticFieldValue(fieldSTATE);
|
|
60
63
|
default:
|
|
61
64
|
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
62
65
|
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JSseState.hpp
|
|
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
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "SseState.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::nitrosse {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "SseState" and the Kotlin enum "SseState".
|
|
19
|
+
*/
|
|
20
|
+
struct JSseState final: public jni::JavaClass<JSseState> {
|
|
21
|
+
public:
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrosse/SseState;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum SseState.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
SseState toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<SseState>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JSseState> fromCpp(SseState value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case SseState::OPEN:
|
|
46
|
+
static const auto fieldOPEN = clazz->getStaticField<JSseState>("OPEN");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldOPEN);
|
|
48
|
+
case SseState::IDLE:
|
|
49
|
+
static const auto fieldIDLE = clazz->getStaticField<JSseState>("IDLE");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldIDLE);
|
|
51
|
+
case SseState::CONNECTING:
|
|
52
|
+
static const auto fieldCONNECTING = clazz->getStaticField<JSseState>("CONNECTING");
|
|
53
|
+
return clazz->getStaticFieldValue(fieldCONNECTING);
|
|
54
|
+
case SseState::STALE:
|
|
55
|
+
static const auto fieldSTALE = clazz->getStaticField<JSseState>("STALE");
|
|
56
|
+
return clazz->getStaticFieldValue(fieldSTALE);
|
|
57
|
+
case SseState::RECONNECTING:
|
|
58
|
+
static const auto fieldRECONNECTING = clazz->getStaticField<JSseState>("RECONNECTING");
|
|
59
|
+
return clazz->getStaticFieldValue(fieldRECONNECTING);
|
|
60
|
+
case SseState::PAUSED:
|
|
61
|
+
static const auto fieldPAUSED = clazz->getStaticField<JSseState>("PAUSED");
|
|
62
|
+
return clazz->getStaticFieldValue(fieldPAUSED);
|
|
63
|
+
case SseState::CLOSED:
|
|
64
|
+
static const auto fieldCLOSED = clazz->getStaticField<JSseState>("CLOSED");
|
|
65
|
+
return clazz->getStaticFieldValue(fieldCLOSED);
|
|
66
|
+
case SseState::FAILED:
|
|
67
|
+
static const auto fieldFAILED = clazz->getStaticField<JSseState>("FAILED");
|
|
68
|
+
return clazz->getStaticFieldValue(fieldFAILED);
|
|
69
|
+
default:
|
|
70
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
71
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
} // namespace margelo::nitro::nitrosse
|
|
@@ -10,7 +10,6 @@ package com.margelo.nitro.nitrosse
|
|
|
10
10
|
import androidx.annotation.Keep
|
|
11
11
|
import com.facebook.jni.HybridData
|
|
12
12
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
-
import dalvik.annotation.optimization.FastNative
|
|
14
13
|
import com.margelo.nitro.core.Promise
|
|
15
14
|
|
|
16
15
|
/**
|
|
@@ -59,7 +58,6 @@ class Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_st
|
|
|
59
58
|
override fun invoke(): Promise<Promise<Map<String, String>>>
|
|
60
59
|
= invoke_cxx()
|
|
61
60
|
|
|
62
|
-
@FastNative
|
|
63
61
|
private external fun invoke_cxx(): Promise<Promise<Map<String, String>>>
|
|
64
62
|
}
|
|
65
63
|
|
|
@@ -10,7 +10,6 @@ package com.margelo.nitro.nitrosse
|
|
|
10
10
|
import androidx.annotation.Keep
|
|
11
11
|
import com.facebook.jni.HybridData
|
|
12
12
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
-
import dalvik.annotation.optimization.FastNative
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
/**
|
|
@@ -59,7 +58,6 @@ class Func_void_std__vector_SseEvent__cxx: Func_void_std__vector_SseEvent_ {
|
|
|
59
58
|
override fun invoke(events: Array<SseEvent>): Unit
|
|
60
59
|
= invoke_cxx(events)
|
|
61
60
|
|
|
62
|
-
@FastNative
|
|
63
61
|
private external fun invoke_cxx(events: Array<SseEvent>): Unit
|
|
64
62
|
}
|
|
65
63
|
|
|
@@ -10,6 +10,7 @@ package com.margelo.nitro.nitrosse
|
|
|
10
10
|
import androidx.annotation.Keep
|
|
11
11
|
import com.facebook.jni.HybridData
|
|
12
12
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import dalvik.annotation.optimization.FastNative
|
|
13
14
|
import com.margelo.nitro.core.HybridObject
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -68,6 +69,10 @@ abstract class HybridNitroSseSpec: HybridObject() {
|
|
|
68
69
|
@DoNotStrip
|
|
69
70
|
@Keep
|
|
70
71
|
abstract fun isConnected(): Boolean
|
|
72
|
+
|
|
73
|
+
@DoNotStrip
|
|
74
|
+
@Keep
|
|
75
|
+
abstract fun getState(): SseState
|
|
71
76
|
|
|
72
77
|
// Default implementation of `HybridObject.toString()`
|
|
73
78
|
override fun toString(): String {
|
|
@@ -79,6 +84,7 @@ abstract class HybridNitroSseSpec: HybridObject() {
|
|
|
79
84
|
@Keep
|
|
80
85
|
protected open class CxxPart(javaPart: HybridNitroSseSpec): HybridObject.CxxPart(javaPart) {
|
|
81
86
|
// C++ JHybridNitroSseSpec::CxxPart::initHybrid(...)
|
|
87
|
+
@FastNative
|
|
82
88
|
external override fun initHybrid(): HybridData
|
|
83
89
|
}
|
|
84
90
|
override fun createCxxPart(): CxxPart {
|
|
@@ -41,7 +41,10 @@ data class SseEvent(
|
|
|
41
41
|
val statusCode: Double?,
|
|
42
42
|
@DoNotStrip
|
|
43
43
|
@Keep
|
|
44
|
-
val retry: Double
|
|
44
|
+
val retry: Double?,
|
|
45
|
+
@DoNotStrip
|
|
46
|
+
@Keep
|
|
47
|
+
val state: SseState?
|
|
45
48
|
) {
|
|
46
49
|
/* primary constructor */
|
|
47
50
|
|
|
@@ -56,6 +59,7 @@ data class SseEvent(
|
|
|
56
59
|
&& Objects.deepEquals(this.message, other.message)
|
|
57
60
|
&& Objects.deepEquals(this.statusCode, other.statusCode)
|
|
58
61
|
&& Objects.deepEquals(this.retry, other.retry)
|
|
62
|
+
&& Objects.deepEquals(this.state, other.state)
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
override fun hashCode(): Int {
|
|
@@ -67,7 +71,8 @@ data class SseEvent(
|
|
|
67
71
|
event,
|
|
68
72
|
message,
|
|
69
73
|
statusCode,
|
|
70
|
-
retry
|
|
74
|
+
retry,
|
|
75
|
+
state
|
|
71
76
|
).contentDeepHashCode()
|
|
72
77
|
}
|
|
73
78
|
|
|
@@ -79,8 +84,8 @@ data class SseEvent(
|
|
|
79
84
|
@Keep
|
|
80
85
|
@Suppress("unused")
|
|
81
86
|
@JvmStatic
|
|
82
|
-
private fun fromCpp(type: SseEventType, data: String?, parsedData: AnyMap?, id: String?, event: String?, message: String?, statusCode: Double?, retry: Double?): SseEvent {
|
|
83
|
-
return SseEvent(type, data, parsedData, id, event, message, statusCode, retry)
|
|
87
|
+
private fun fromCpp(type: SseEventType, data: String?, parsedData: AnyMap?, id: String?, event: String?, message: String?, statusCode: Double?, retry: Double?, state: SseState?): SseEvent {
|
|
88
|
+
return SseEvent(type, data, parsedData, id, event, message, statusCode, retry, state)
|
|
84
89
|
}
|
|
85
90
|
}
|
|
86
91
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SseState.kt
|
|
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
|
+
package com.margelo.nitro.nitrosse
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the JavaScript enum/union "SseState".
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
@Keep
|
|
18
|
+
enum class SseState(@DoNotStrip @Keep val value: Int) {
|
|
19
|
+
OPEN(0),
|
|
20
|
+
IDLE(1),
|
|
21
|
+
CONNECTING(2),
|
|
22
|
+
STALE(3),
|
|
23
|
+
RECONNECTING(4),
|
|
24
|
+
PAUSED(5),
|
|
25
|
+
CLOSED(6),
|
|
26
|
+
FAILED(7);
|
|
27
|
+
|
|
28
|
+
companion object
|
|
29
|
+
}
|
|
@@ -22,6 +22,8 @@ namespace margelo::nitro::nitrosse { struct SseMockConfig; }
|
|
|
22
22
|
namespace margelo::nitro::nitrosse { struct SseMockEvent; }
|
|
23
23
|
// Forward declaration of `SseMockMode` to properly resolve imports.
|
|
24
24
|
namespace margelo::nitro::nitrosse { enum class SseMockMode; }
|
|
25
|
+
// Forward declaration of `SseState` to properly resolve imports.
|
|
26
|
+
namespace margelo::nitro::nitrosse { enum class SseState; }
|
|
25
27
|
// Forward declaration of `SseStats` to properly resolve imports.
|
|
26
28
|
namespace margelo::nitro::nitrosse { struct SseStats; }
|
|
27
29
|
|
|
@@ -37,6 +39,7 @@ namespace NitroSse { class HybridNitroSseSpec_cxx; }
|
|
|
37
39
|
#include "SseMockConfig.hpp"
|
|
38
40
|
#include "SseMockEvent.hpp"
|
|
39
41
|
#include "SseMockMode.hpp"
|
|
42
|
+
#include "SseState.hpp"
|
|
40
43
|
#include "SseStats.hpp"
|
|
41
44
|
#include <NitroModules/AnyMap.hpp>
|
|
42
45
|
#include <NitroModules/Promise.hpp>
|
|
@@ -340,6 +343,21 @@ namespace margelo::nitro::nitrosse::bridge::swift {
|
|
|
340
343
|
return optional.value();
|
|
341
344
|
}
|
|
342
345
|
|
|
346
|
+
// pragma MARK: std::optional<SseState>
|
|
347
|
+
/**
|
|
348
|
+
* Specialized version of `std::optional<SseState>`.
|
|
349
|
+
*/
|
|
350
|
+
using std__optional_SseState_ = std::optional<SseState>;
|
|
351
|
+
inline std::optional<SseState> create_std__optional_SseState_(const SseState& value) noexcept {
|
|
352
|
+
return std::optional<SseState>(value);
|
|
353
|
+
}
|
|
354
|
+
inline bool has_value_std__optional_SseState_(const std::optional<SseState>& optional) noexcept {
|
|
355
|
+
return optional.has_value();
|
|
356
|
+
}
|
|
357
|
+
inline SseState get_std__optional_SseState_(const std::optional<SseState>& optional) noexcept {
|
|
358
|
+
return optional.value();
|
|
359
|
+
}
|
|
360
|
+
|
|
343
361
|
// pragma MARK: std::vector<SseEvent>
|
|
344
362
|
/**
|
|
345
363
|
* Specialized version of `std::vector<SseEvent>`.
|
|
@@ -411,5 +429,14 @@ namespace margelo::nitro::nitrosse::bridge::swift {
|
|
|
411
429
|
inline Result_bool_ create_Result_bool_(const std::exception_ptr& error) noexcept {
|
|
412
430
|
return Result<bool>::withError(error);
|
|
413
431
|
}
|
|
432
|
+
|
|
433
|
+
// pragma MARK: Result<SseState>
|
|
434
|
+
using Result_SseState_ = Result<SseState>;
|
|
435
|
+
inline Result_SseState_ create_Result_SseState_(SseState value) noexcept {
|
|
436
|
+
return Result<SseState>::withValue(std::move(value));
|
|
437
|
+
}
|
|
438
|
+
inline Result_SseState_ create_Result_SseState_(const std::exception_ptr& error) noexcept {
|
|
439
|
+
return Result<SseState>::withError(error);
|
|
440
|
+
}
|
|
414
441
|
|
|
415
442
|
} // namespace margelo::nitro::nitrosse::bridge::swift
|
|
@@ -24,6 +24,8 @@ namespace margelo::nitro::nitrosse { struct SseMockConfig; }
|
|
|
24
24
|
namespace margelo::nitro::nitrosse { struct SseMockEvent; }
|
|
25
25
|
// Forward declaration of `SseMockMode` to properly resolve imports.
|
|
26
26
|
namespace margelo::nitro::nitrosse { enum class SseMockMode; }
|
|
27
|
+
// Forward declaration of `SseState` to properly resolve imports.
|
|
28
|
+
namespace margelo::nitro::nitrosse { enum class SseState; }
|
|
27
29
|
// Forward declaration of `SseStats` to properly resolve imports.
|
|
28
30
|
namespace margelo::nitro::nitrosse { struct SseStats; }
|
|
29
31
|
|
|
@@ -36,6 +38,7 @@ namespace margelo::nitro::nitrosse { struct SseStats; }
|
|
|
36
38
|
#include "SseMockConfig.hpp"
|
|
37
39
|
#include "SseMockEvent.hpp"
|
|
38
40
|
#include "SseMockMode.hpp"
|
|
41
|
+
#include "SseState.hpp"
|
|
39
42
|
#include "SseStats.hpp"
|
|
40
43
|
#include <NitroModules/AnyMap.hpp>
|
|
41
44
|
#include <NitroModules/Promise.hpp>
|
|
@@ -26,6 +26,8 @@ namespace margelo::nitro::nitrosse { struct SseMockEvent; }
|
|
|
26
26
|
namespace margelo::nitro::nitrosse { enum class SseEventType; }
|
|
27
27
|
// Forward declaration of `SseEvent` to properly resolve imports.
|
|
28
28
|
namespace margelo::nitro::nitrosse { struct SseEvent; }
|
|
29
|
+
// Forward declaration of `SseState` to properly resolve imports.
|
|
30
|
+
namespace margelo::nitro::nitrosse { enum class SseState; }
|
|
29
31
|
// Forward declaration of `SseStats` to properly resolve imports.
|
|
30
32
|
namespace margelo::nitro::nitrosse { struct SseStats; }
|
|
31
33
|
|
|
@@ -43,6 +45,7 @@ namespace margelo::nitro::nitrosse { struct SseStats; }
|
|
|
43
45
|
#include "SseEventType.hpp"
|
|
44
46
|
#include <NitroModules/AnyMap.hpp>
|
|
45
47
|
#include "SseEvent.hpp"
|
|
48
|
+
#include "SseState.hpp"
|
|
46
49
|
#include "SseStats.hpp"
|
|
47
50
|
|
|
48
51
|
#include "NitroSse-Swift-Cxx-Umbrella.hpp"
|
|
@@ -153,6 +156,14 @@ namespace margelo::nitro::nitrosse {
|
|
|
153
156
|
auto __value = std::move(__result.value());
|
|
154
157
|
return __value;
|
|
155
158
|
}
|
|
159
|
+
inline SseState getState() override {
|
|
160
|
+
auto __result = _swiftPart.getState();
|
|
161
|
+
if (__result.hasError()) [[unlikely]] {
|
|
162
|
+
std::rethrow_exception(__result.error());
|
|
163
|
+
}
|
|
164
|
+
auto __value = std::move(__result.value());
|
|
165
|
+
return __value;
|
|
166
|
+
}
|
|
156
167
|
|
|
157
168
|
private:
|
|
158
169
|
NitroSse::HybridNitroSseSpec_cxx _swiftPart;
|
|
@@ -243,4 +243,16 @@ open class HybridNitroSseSpec_cxx {
|
|
|
243
243
|
return bridge.create_Result_bool_(__exceptionPtr)
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
+
|
|
247
|
+
@inline(__always)
|
|
248
|
+
public final func getState() -> bridge.Result_SseState_ {
|
|
249
|
+
do {
|
|
250
|
+
let __result = try self.__implementation.getState()
|
|
251
|
+
let __resultCpp = __result
|
|
252
|
+
return bridge.create_Result_SseState_(__resultCpp)
|
|
253
|
+
} catch (let __error) {
|
|
254
|
+
let __exceptionPtr = __error.toCpp()
|
|
255
|
+
return bridge.create_Result_SseState_(__exceptionPtr)
|
|
256
|
+
}
|
|
257
|
+
}
|
|
246
258
|
}
|
|
@@ -18,7 +18,7 @@ public extension SseEvent {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a new instance of `SseEvent`.
|
|
20
20
|
*/
|
|
21
|
-
init(type: SseEventType, data: String?, parsedData: AnyMap?, id: String?, event: String?, message: String?, statusCode: Double?, retry: Double?) {
|
|
21
|
+
init(type: SseEventType, data: String?, parsedData: AnyMap?, id: String?, event: String?, message: String?, statusCode: Double?, retry: Double?, state: SseState?) {
|
|
22
22
|
self.init(type, { () -> bridge.std__optional_std__string_ in
|
|
23
23
|
if let __unwrappedValue = data {
|
|
24
24
|
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
@@ -61,6 +61,12 @@ public extension SseEvent {
|
|
|
61
61
|
} else {
|
|
62
62
|
return .init()
|
|
63
63
|
}
|
|
64
|
+
}(), { () -> bridge.std__optional_SseState_ in
|
|
65
|
+
if let __unwrappedValue = state {
|
|
66
|
+
return bridge.create_std__optional_SseState_(__unwrappedValue)
|
|
67
|
+
} else {
|
|
68
|
+
return .init()
|
|
69
|
+
}
|
|
64
70
|
}())
|
|
65
71
|
}
|
|
66
72
|
|
|
@@ -152,4 +158,9 @@ public extension SseEvent {
|
|
|
152
158
|
}
|
|
153
159
|
}()
|
|
154
160
|
}
|
|
161
|
+
|
|
162
|
+
@inline(__always)
|
|
163
|
+
var state: SseState? {
|
|
164
|
+
return self.__state.value
|
|
165
|
+
}
|
|
155
166
|
}
|
|
@@ -27,6 +27,8 @@ public extension SseEventType {
|
|
|
27
27
|
self = .close
|
|
28
28
|
case "heartbeat":
|
|
29
29
|
self = .heartbeat
|
|
30
|
+
case "state":
|
|
31
|
+
self = .state
|
|
30
32
|
default:
|
|
31
33
|
return nil
|
|
32
34
|
}
|
|
@@ -47,6 +49,8 @@ public extension SseEventType {
|
|
|
47
49
|
return "close"
|
|
48
50
|
case .heartbeat:
|
|
49
51
|
return "heartbeat"
|
|
52
|
+
case .state:
|
|
53
|
+
return "state"
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SseState.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
|
+
/**
|
|
9
|
+
* Represents the JS union `SseState`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias SseState = margelo.nitro.nitrosse.SseState
|
|
12
|
+
|
|
13
|
+
public extension SseState {
|
|
14
|
+
/**
|
|
15
|
+
* Get a SseState for the given String value, or
|
|
16
|
+
* return `nil` if the given value was invalid/unknown.
|
|
17
|
+
*/
|
|
18
|
+
init?(fromString string: String) {
|
|
19
|
+
switch string {
|
|
20
|
+
case "open":
|
|
21
|
+
self = .open
|
|
22
|
+
case "idle":
|
|
23
|
+
self = .idle
|
|
24
|
+
case "connecting":
|
|
25
|
+
self = .connecting
|
|
26
|
+
case "stale":
|
|
27
|
+
self = .stale
|
|
28
|
+
case "reconnecting":
|
|
29
|
+
self = .reconnecting
|
|
30
|
+
case "paused":
|
|
31
|
+
self = .paused
|
|
32
|
+
case "closed":
|
|
33
|
+
self = .closed
|
|
34
|
+
case "failed":
|
|
35
|
+
self = .failed
|
|
36
|
+
default:
|
|
37
|
+
return nil
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Get the String value this SseState represents.
|
|
43
|
+
*/
|
|
44
|
+
var stringValue: String {
|
|
45
|
+
switch self {
|
|
46
|
+
case .open:
|
|
47
|
+
return "open"
|
|
48
|
+
case .idle:
|
|
49
|
+
return "idle"
|
|
50
|
+
case .connecting:
|
|
51
|
+
return "connecting"
|
|
52
|
+
case .stale:
|
|
53
|
+
return "stale"
|
|
54
|
+
case .reconnecting:
|
|
55
|
+
return "reconnecting"
|
|
56
|
+
case .paused:
|
|
57
|
+
return "paused"
|
|
58
|
+
case .closed:
|
|
59
|
+
return "closed"
|
|
60
|
+
case .failed:
|
|
61
|
+
return "failed"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -23,6 +23,7 @@ namespace margelo::nitro::nitrosse {
|
|
|
23
23
|
prototype.registerHybridMethod("flush", &HybridNitroSseSpec::flush);
|
|
24
24
|
prototype.registerHybridMethod("restart", &HybridNitroSseSpec::restart);
|
|
25
25
|
prototype.registerHybridMethod("isConnected", &HybridNitroSseSpec::isConnected);
|
|
26
|
+
prototype.registerHybridMethod("getState", &HybridNitroSseSpec::getState);
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
29
|
|