react-native-nitro-sse 3.0.0 → 3.1.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/NitroSse.podspec +0 -1
- package/README.md +1 -1
- package/android/build.gradle +0 -1
- package/android/src/main/java/com/margelo/nitro/nitrosse/JsonUtils.kt +33 -10
- package/android/src/main/java/com/margelo/nitro/nitrosse/NitroSse.kt +366 -78
- package/android/src/main/java/com/margelo/nitro/nitrosse/SseConnectionHandler.kt +417 -94
- package/android/src/main/java/com/margelo/nitro/nitrosse/SseEventBuffer.kt +20 -0
- package/android/src/main/java/com/margelo/nitro/nitrosse/SseReconnectStrategy.kt +9 -0
- package/ios/NitroSse.swift +302 -49
- package/ios/SseConnectionHandler.swift +647 -97
- package/ios/SseEventBuffer.swift +19 -1
- package/ios/SseReconnectStrategy.swift +26 -7
- package/lib/module/MockSseEngine.js +72 -3
- package/lib/module/NitroSseClient.js +24 -1
- package/lib/typescript/src/MockSseEngine.d.ts +16 -0
- package/lib/typescript/src/SseInterface.d.ts +46 -3
- package/nitrogen/generated/android/c++/JHybridNitroSseSpec.cpp +4 -0
- package/nitrogen/generated/android/c++/JSseDisconnectReason.hpp +67 -0
- package/nitrogen/generated/android/c++/JSseStats.hpp +87 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/SseDisconnectReason.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/SseStats.kt +108 -3
- package/nitrogen/generated/ios/NitroSse-Swift-Cxx-Bridge.hpp +18 -0
- package/nitrogen/generated/ios/NitroSse-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridNitroSseSpecSwift.hpp +3 -0
- package/nitrogen/generated/ios/swift/SseDisconnectReason.swift +52 -0
- package/nitrogen/generated/ios/swift/SseStats.swift +217 -2
- package/nitrogen/generated/shared/c++/SseDisconnectReason.hpp +88 -0
- package/nitrogen/generated/shared/c++/SseStats.hpp +88 -2
- package/package.json +2 -2
|
@@ -18,14 +18,77 @@ import java.util.Objects
|
|
|
18
18
|
@DoNotStrip
|
|
19
19
|
@Keep
|
|
20
20
|
data class SseStats(
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
val rawBytesReceived: Double,
|
|
24
|
+
@DoNotStrip
|
|
25
|
+
@Keep
|
|
26
|
+
val decompressedBytesReceived: Double?,
|
|
21
27
|
@DoNotStrip
|
|
22
28
|
@Keep
|
|
23
29
|
val totalBytesReceived: Double,
|
|
24
30
|
@DoNotStrip
|
|
25
31
|
@Keep
|
|
32
|
+
val chunksReceived: Double,
|
|
33
|
+
@DoNotStrip
|
|
34
|
+
@Keep
|
|
35
|
+
val lastStatusCode: Double?,
|
|
36
|
+
@DoNotStrip
|
|
37
|
+
@Keep
|
|
38
|
+
val totalEventsReceived: Double,
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
val commentsReceived: Double,
|
|
42
|
+
@DoNotStrip
|
|
43
|
+
@Keep
|
|
44
|
+
val linesParsed: Double,
|
|
45
|
+
@DoNotStrip
|
|
46
|
+
@Keep
|
|
47
|
+
val parseErrors: Double,
|
|
48
|
+
@DoNotStrip
|
|
49
|
+
@Keep
|
|
50
|
+
val serverRetryDelayMs: Double?,
|
|
51
|
+
@DoNotStrip
|
|
52
|
+
@Keep
|
|
53
|
+
val connectedAt: Double?,
|
|
54
|
+
@DoNotStrip
|
|
55
|
+
@Keep
|
|
56
|
+
val timeToFirstByteMs: Double?,
|
|
57
|
+
@DoNotStrip
|
|
58
|
+
@Keep
|
|
59
|
+
val lastEventTime: Double?,
|
|
60
|
+
@DoNotStrip
|
|
61
|
+
@Keep
|
|
62
|
+
val lastHeartbeatTime: Double?,
|
|
63
|
+
@DoNotStrip
|
|
64
|
+
@Keep
|
|
65
|
+
val maxEventGapMs: Double,
|
|
66
|
+
@DoNotStrip
|
|
67
|
+
@Keep
|
|
68
|
+
val eventsBuffered: Double,
|
|
69
|
+
@DoNotStrip
|
|
70
|
+
@Keep
|
|
71
|
+
val peakBufferedEvents: Double,
|
|
72
|
+
@DoNotStrip
|
|
73
|
+
@Keep
|
|
74
|
+
val bufferFlushCount: Double,
|
|
75
|
+
@DoNotStrip
|
|
76
|
+
@Keep
|
|
77
|
+
val bufferOverflowCount: Double,
|
|
78
|
+
@DoNotStrip
|
|
79
|
+
@Keep
|
|
80
|
+
val connectionAttempts: Double,
|
|
81
|
+
@DoNotStrip
|
|
82
|
+
@Keep
|
|
26
83
|
val reconnectCount: Double,
|
|
27
84
|
@DoNotStrip
|
|
28
85
|
@Keep
|
|
86
|
+
val lastReconnectDelayMs: Double?,
|
|
87
|
+
@DoNotStrip
|
|
88
|
+
@Keep
|
|
89
|
+
val disconnectReason: SseDisconnectReason?,
|
|
90
|
+
@DoNotStrip
|
|
91
|
+
@Keep
|
|
29
92
|
val lastErrorTime: Double?,
|
|
30
93
|
@DoNotStrip
|
|
31
94
|
@Keep
|
|
@@ -36,16 +99,58 @@ data class SseStats(
|
|
|
36
99
|
override fun equals(other: Any?): Boolean {
|
|
37
100
|
if (this === other) return true
|
|
38
101
|
if (other !is SseStats) return false
|
|
39
|
-
return Objects.deepEquals(this.
|
|
102
|
+
return Objects.deepEquals(this.rawBytesReceived, other.rawBytesReceived)
|
|
103
|
+
&& Objects.deepEquals(this.decompressedBytesReceived, other.decompressedBytesReceived)
|
|
104
|
+
&& Objects.deepEquals(this.totalBytesReceived, other.totalBytesReceived)
|
|
105
|
+
&& Objects.deepEquals(this.chunksReceived, other.chunksReceived)
|
|
106
|
+
&& Objects.deepEquals(this.lastStatusCode, other.lastStatusCode)
|
|
107
|
+
&& Objects.deepEquals(this.totalEventsReceived, other.totalEventsReceived)
|
|
108
|
+
&& Objects.deepEquals(this.commentsReceived, other.commentsReceived)
|
|
109
|
+
&& Objects.deepEquals(this.linesParsed, other.linesParsed)
|
|
110
|
+
&& Objects.deepEquals(this.parseErrors, other.parseErrors)
|
|
111
|
+
&& Objects.deepEquals(this.serverRetryDelayMs, other.serverRetryDelayMs)
|
|
112
|
+
&& Objects.deepEquals(this.connectedAt, other.connectedAt)
|
|
113
|
+
&& Objects.deepEquals(this.timeToFirstByteMs, other.timeToFirstByteMs)
|
|
114
|
+
&& Objects.deepEquals(this.lastEventTime, other.lastEventTime)
|
|
115
|
+
&& Objects.deepEquals(this.lastHeartbeatTime, other.lastHeartbeatTime)
|
|
116
|
+
&& Objects.deepEquals(this.maxEventGapMs, other.maxEventGapMs)
|
|
117
|
+
&& Objects.deepEquals(this.eventsBuffered, other.eventsBuffered)
|
|
118
|
+
&& Objects.deepEquals(this.peakBufferedEvents, other.peakBufferedEvents)
|
|
119
|
+
&& Objects.deepEquals(this.bufferFlushCount, other.bufferFlushCount)
|
|
120
|
+
&& Objects.deepEquals(this.bufferOverflowCount, other.bufferOverflowCount)
|
|
121
|
+
&& Objects.deepEquals(this.connectionAttempts, other.connectionAttempts)
|
|
40
122
|
&& Objects.deepEquals(this.reconnectCount, other.reconnectCount)
|
|
123
|
+
&& Objects.deepEquals(this.lastReconnectDelayMs, other.lastReconnectDelayMs)
|
|
124
|
+
&& Objects.deepEquals(this.disconnectReason, other.disconnectReason)
|
|
41
125
|
&& Objects.deepEquals(this.lastErrorTime, other.lastErrorTime)
|
|
42
126
|
&& Objects.deepEquals(this.lastErrorCode, other.lastErrorCode)
|
|
43
127
|
}
|
|
44
128
|
|
|
45
129
|
override fun hashCode(): Int {
|
|
46
130
|
return arrayOf<Any?>(
|
|
131
|
+
rawBytesReceived,
|
|
132
|
+
decompressedBytesReceived,
|
|
47
133
|
totalBytesReceived,
|
|
134
|
+
chunksReceived,
|
|
135
|
+
lastStatusCode,
|
|
136
|
+
totalEventsReceived,
|
|
137
|
+
commentsReceived,
|
|
138
|
+
linesParsed,
|
|
139
|
+
parseErrors,
|
|
140
|
+
serverRetryDelayMs,
|
|
141
|
+
connectedAt,
|
|
142
|
+
timeToFirstByteMs,
|
|
143
|
+
lastEventTime,
|
|
144
|
+
lastHeartbeatTime,
|
|
145
|
+
maxEventGapMs,
|
|
146
|
+
eventsBuffered,
|
|
147
|
+
peakBufferedEvents,
|
|
148
|
+
bufferFlushCount,
|
|
149
|
+
bufferOverflowCount,
|
|
150
|
+
connectionAttempts,
|
|
48
151
|
reconnectCount,
|
|
152
|
+
lastReconnectDelayMs,
|
|
153
|
+
disconnectReason,
|
|
49
154
|
lastErrorTime,
|
|
50
155
|
lastErrorCode
|
|
51
156
|
).contentDeepHashCode()
|
|
@@ -59,8 +164,8 @@ data class SseStats(
|
|
|
59
164
|
@Keep
|
|
60
165
|
@Suppress("unused")
|
|
61
166
|
@JvmStatic
|
|
62
|
-
private fun fromCpp(totalBytesReceived: Double, reconnectCount: Double, lastErrorTime: Double?, lastErrorCode: String?): SseStats {
|
|
63
|
-
return SseStats(totalBytesReceived, reconnectCount, lastErrorTime, lastErrorCode)
|
|
167
|
+
private fun fromCpp(rawBytesReceived: Double, decompressedBytesReceived: Double?, totalBytesReceived: Double, chunksReceived: Double, lastStatusCode: Double?, totalEventsReceived: Double, commentsReceived: Double, linesParsed: Double, parseErrors: Double, serverRetryDelayMs: Double?, connectedAt: Double?, timeToFirstByteMs: Double?, lastEventTime: Double?, lastHeartbeatTime: Double?, maxEventGapMs: Double, eventsBuffered: Double, peakBufferedEvents: Double, bufferFlushCount: Double, bufferOverflowCount: Double, connectionAttempts: Double, reconnectCount: Double, lastReconnectDelayMs: Double?, disconnectReason: SseDisconnectReason?, lastErrorTime: Double?, lastErrorCode: String?): SseStats {
|
|
168
|
+
return SseStats(rawBytesReceived, decompressedBytesReceived, totalBytesReceived, chunksReceived, lastStatusCode, totalEventsReceived, commentsReceived, linesParsed, parseErrors, serverRetryDelayMs, connectedAt, timeToFirstByteMs, lastEventTime, lastHeartbeatTime, maxEventGapMs, eventsBuffered, peakBufferedEvents, bufferFlushCount, bufferOverflowCount, connectionAttempts, reconnectCount, lastReconnectDelayMs, disconnectReason, lastErrorTime, lastErrorCode)
|
|
64
169
|
}
|
|
65
170
|
}
|
|
66
171
|
}
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
namespace margelo::nitro::nitrosse { enum class HttpMethod; }
|
|
13
13
|
// Forward declaration of `HybridNitroSseSpec` to properly resolve imports.
|
|
14
14
|
namespace margelo::nitro::nitrosse { class HybridNitroSseSpec; }
|
|
15
|
+
// Forward declaration of `SseDisconnectReason` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::nitrosse { enum class SseDisconnectReason; }
|
|
15
17
|
// Forward declaration of `SseEventType` to properly resolve imports.
|
|
16
18
|
namespace margelo::nitro::nitrosse { enum class SseEventType; }
|
|
17
19
|
// Forward declaration of `SseEvent` to properly resolve imports.
|
|
@@ -34,6 +36,7 @@ namespace NitroSse { class HybridNitroSseSpec_cxx; }
|
|
|
34
36
|
// Include C++ defined types
|
|
35
37
|
#include "HttpMethod.hpp"
|
|
36
38
|
#include "HybridNitroSseSpec.hpp"
|
|
39
|
+
#include "SseDisconnectReason.hpp"
|
|
37
40
|
#include "SseEvent.hpp"
|
|
38
41
|
#include "SseEventType.hpp"
|
|
39
42
|
#include "SseMockConfig.hpp"
|
|
@@ -391,6 +394,21 @@ namespace margelo::nitro::nitrosse::bridge::swift {
|
|
|
391
394
|
return optional.value();
|
|
392
395
|
}
|
|
393
396
|
|
|
397
|
+
// pragma MARK: std::optional<SseDisconnectReason>
|
|
398
|
+
/**
|
|
399
|
+
* Specialized version of `std::optional<SseDisconnectReason>`.
|
|
400
|
+
*/
|
|
401
|
+
using std__optional_SseDisconnectReason_ = std::optional<SseDisconnectReason>;
|
|
402
|
+
inline std::optional<SseDisconnectReason> create_std__optional_SseDisconnectReason_(const SseDisconnectReason& value) noexcept {
|
|
403
|
+
return std::optional<SseDisconnectReason>(value);
|
|
404
|
+
}
|
|
405
|
+
inline bool has_value_std__optional_SseDisconnectReason_(const std::optional<SseDisconnectReason>& optional) noexcept {
|
|
406
|
+
return optional.has_value();
|
|
407
|
+
}
|
|
408
|
+
inline SseDisconnectReason get_std__optional_SseDisconnectReason_(const std::optional<SseDisconnectReason>& optional) noexcept {
|
|
409
|
+
return optional.value();
|
|
410
|
+
}
|
|
411
|
+
|
|
394
412
|
// pragma MARK: std::shared_ptr<HybridNitroSseSpec>
|
|
395
413
|
/**
|
|
396
414
|
* Specialized version of `std::shared_ptr<HybridNitroSseSpec>`.
|
|
@@ -14,6 +14,8 @@ namespace margelo::nitro::nitrosse { enum class HttpMethod; }
|
|
|
14
14
|
namespace margelo::nitro::nitrosse { class HybridNitroSseSpec; }
|
|
15
15
|
// Forward declaration of `SseConfig` to properly resolve imports.
|
|
16
16
|
namespace margelo::nitro::nitrosse { struct SseConfig; }
|
|
17
|
+
// Forward declaration of `SseDisconnectReason` to properly resolve imports.
|
|
18
|
+
namespace margelo::nitro::nitrosse { enum class SseDisconnectReason; }
|
|
17
19
|
// Forward declaration of `SseEventType` to properly resolve imports.
|
|
18
20
|
namespace margelo::nitro::nitrosse { enum class SseEventType; }
|
|
19
21
|
// Forward declaration of `SseEvent` to properly resolve imports.
|
|
@@ -33,6 +35,7 @@ namespace margelo::nitro::nitrosse { struct SseStats; }
|
|
|
33
35
|
#include "HttpMethod.hpp"
|
|
34
36
|
#include "HybridNitroSseSpec.hpp"
|
|
35
37
|
#include "SseConfig.hpp"
|
|
38
|
+
#include "SseDisconnectReason.hpp"
|
|
36
39
|
#include "SseEvent.hpp"
|
|
37
40
|
#include "SseEventType.hpp"
|
|
38
41
|
#include "SseMockConfig.hpp"
|
|
@@ -30,6 +30,8 @@ namespace margelo::nitro::nitrosse { enum class SseState; }
|
|
|
30
30
|
namespace margelo::nitro::nitrosse { struct SseEvent; }
|
|
31
31
|
// Forward declaration of `SseStats` to properly resolve imports.
|
|
32
32
|
namespace margelo::nitro::nitrosse { struct SseStats; }
|
|
33
|
+
// Forward declaration of `SseDisconnectReason` to properly resolve imports.
|
|
34
|
+
namespace margelo::nitro::nitrosse { enum class SseDisconnectReason; }
|
|
33
35
|
|
|
34
36
|
#include "SseConfig.hpp"
|
|
35
37
|
#include <string>
|
|
@@ -47,6 +49,7 @@ namespace margelo::nitro::nitrosse { struct SseStats; }
|
|
|
47
49
|
#include <functional>
|
|
48
50
|
#include <NitroModules/Promise.hpp>
|
|
49
51
|
#include "SseStats.hpp"
|
|
52
|
+
#include "SseDisconnectReason.hpp"
|
|
50
53
|
|
|
51
54
|
#include "NitroSse-Swift-Cxx-Umbrella.hpp"
|
|
52
55
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SseDisconnectReason.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 `SseDisconnectReason`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias SseDisconnectReason = margelo.nitro.nitrosse.SseDisconnectReason
|
|
12
|
+
|
|
13
|
+
public extension SseDisconnectReason {
|
|
14
|
+
/**
|
|
15
|
+
* Get a SseDisconnectReason 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 "user_stop":
|
|
21
|
+
self = .userStop
|
|
22
|
+
case "network_error":
|
|
23
|
+
self = .networkError
|
|
24
|
+
case "server_error":
|
|
25
|
+
self = .serverError
|
|
26
|
+
case "parser_error":
|
|
27
|
+
self = .parserError
|
|
28
|
+
case "timeout":
|
|
29
|
+
self = .timeout
|
|
30
|
+
default:
|
|
31
|
+
return nil
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get the String value this SseDisconnectReason represents.
|
|
37
|
+
*/
|
|
38
|
+
var stringValue: String {
|
|
39
|
+
switch self {
|
|
40
|
+
case .userStop:
|
|
41
|
+
return "user_stop"
|
|
42
|
+
case .networkError:
|
|
43
|
+
return "network_error"
|
|
44
|
+
case .serverError:
|
|
45
|
+
return "server_error"
|
|
46
|
+
case .parserError:
|
|
47
|
+
return "parser_error"
|
|
48
|
+
case .timeout:
|
|
49
|
+
return "timeout"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -18,8 +18,62 @@ public extension SseStats {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a new instance of `SseStats`.
|
|
20
20
|
*/
|
|
21
|
-
init(totalBytesReceived: Double, reconnectCount: Double, lastErrorTime: Double?, lastErrorCode: String?) {
|
|
22
|
-
self.init(
|
|
21
|
+
init(rawBytesReceived: Double, decompressedBytesReceived: Double?, totalBytesReceived: Double, chunksReceived: Double, lastStatusCode: Double?, totalEventsReceived: Double, commentsReceived: Double, linesParsed: Double, parseErrors: Double, serverRetryDelayMs: Double?, connectedAt: Double?, timeToFirstByteMs: Double?, lastEventTime: Double?, lastHeartbeatTime: Double?, maxEventGapMs: Double, eventsBuffered: Double, peakBufferedEvents: Double, bufferFlushCount: Double, bufferOverflowCount: Double, connectionAttempts: Double, reconnectCount: Double, lastReconnectDelayMs: Double?, disconnectReason: SseDisconnectReason?, lastErrorTime: Double?, lastErrorCode: String?) {
|
|
22
|
+
self.init(rawBytesReceived, { () -> bridge.std__optional_double_ in
|
|
23
|
+
if let __unwrappedValue = decompressedBytesReceived {
|
|
24
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
25
|
+
} else {
|
|
26
|
+
return .init()
|
|
27
|
+
}
|
|
28
|
+
}(), totalBytesReceived, chunksReceived, { () -> bridge.std__optional_double_ in
|
|
29
|
+
if let __unwrappedValue = lastStatusCode {
|
|
30
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
31
|
+
} else {
|
|
32
|
+
return .init()
|
|
33
|
+
}
|
|
34
|
+
}(), totalEventsReceived, commentsReceived, linesParsed, parseErrors, { () -> bridge.std__optional_double_ in
|
|
35
|
+
if let __unwrappedValue = serverRetryDelayMs {
|
|
36
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
37
|
+
} else {
|
|
38
|
+
return .init()
|
|
39
|
+
}
|
|
40
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
41
|
+
if let __unwrappedValue = connectedAt {
|
|
42
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
43
|
+
} else {
|
|
44
|
+
return .init()
|
|
45
|
+
}
|
|
46
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
47
|
+
if let __unwrappedValue = timeToFirstByteMs {
|
|
48
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
49
|
+
} else {
|
|
50
|
+
return .init()
|
|
51
|
+
}
|
|
52
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
53
|
+
if let __unwrappedValue = lastEventTime {
|
|
54
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
55
|
+
} else {
|
|
56
|
+
return .init()
|
|
57
|
+
}
|
|
58
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
59
|
+
if let __unwrappedValue = lastHeartbeatTime {
|
|
60
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
61
|
+
} else {
|
|
62
|
+
return .init()
|
|
63
|
+
}
|
|
64
|
+
}(), maxEventGapMs, eventsBuffered, peakBufferedEvents, bufferFlushCount, bufferOverflowCount, connectionAttempts, reconnectCount, { () -> bridge.std__optional_double_ in
|
|
65
|
+
if let __unwrappedValue = lastReconnectDelayMs {
|
|
66
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
67
|
+
} else {
|
|
68
|
+
return .init()
|
|
69
|
+
}
|
|
70
|
+
}(), { () -> bridge.std__optional_SseDisconnectReason_ in
|
|
71
|
+
if let __unwrappedValue = disconnectReason {
|
|
72
|
+
return bridge.create_std__optional_SseDisconnectReason_(__unwrappedValue)
|
|
73
|
+
} else {
|
|
74
|
+
return .init()
|
|
75
|
+
}
|
|
76
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
23
77
|
if let __unwrappedValue = lastErrorTime {
|
|
24
78
|
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
25
79
|
} else {
|
|
@@ -34,16 +88,177 @@ public extension SseStats {
|
|
|
34
88
|
}())
|
|
35
89
|
}
|
|
36
90
|
|
|
91
|
+
@inline(__always)
|
|
92
|
+
var rawBytesReceived: Double {
|
|
93
|
+
return self.__rawBytesReceived
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@inline(__always)
|
|
97
|
+
var decompressedBytesReceived: Double? {
|
|
98
|
+
return { () -> Double? in
|
|
99
|
+
if bridge.has_value_std__optional_double_(self.__decompressedBytesReceived) {
|
|
100
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__decompressedBytesReceived)
|
|
101
|
+
return __unwrapped
|
|
102
|
+
} else {
|
|
103
|
+
return nil
|
|
104
|
+
}
|
|
105
|
+
}()
|
|
106
|
+
}
|
|
107
|
+
|
|
37
108
|
@inline(__always)
|
|
38
109
|
var totalBytesReceived: Double {
|
|
39
110
|
return self.__totalBytesReceived
|
|
40
111
|
}
|
|
41
112
|
|
|
113
|
+
@inline(__always)
|
|
114
|
+
var chunksReceived: Double {
|
|
115
|
+
return self.__chunksReceived
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@inline(__always)
|
|
119
|
+
var lastStatusCode: Double? {
|
|
120
|
+
return { () -> Double? in
|
|
121
|
+
if bridge.has_value_std__optional_double_(self.__lastStatusCode) {
|
|
122
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__lastStatusCode)
|
|
123
|
+
return __unwrapped
|
|
124
|
+
} else {
|
|
125
|
+
return nil
|
|
126
|
+
}
|
|
127
|
+
}()
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@inline(__always)
|
|
131
|
+
var totalEventsReceived: Double {
|
|
132
|
+
return self.__totalEventsReceived
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@inline(__always)
|
|
136
|
+
var commentsReceived: Double {
|
|
137
|
+
return self.__commentsReceived
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@inline(__always)
|
|
141
|
+
var linesParsed: Double {
|
|
142
|
+
return self.__linesParsed
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@inline(__always)
|
|
146
|
+
var parseErrors: Double {
|
|
147
|
+
return self.__parseErrors
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
@inline(__always)
|
|
151
|
+
var serverRetryDelayMs: Double? {
|
|
152
|
+
return { () -> Double? in
|
|
153
|
+
if bridge.has_value_std__optional_double_(self.__serverRetryDelayMs) {
|
|
154
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__serverRetryDelayMs)
|
|
155
|
+
return __unwrapped
|
|
156
|
+
} else {
|
|
157
|
+
return nil
|
|
158
|
+
}
|
|
159
|
+
}()
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@inline(__always)
|
|
163
|
+
var connectedAt: Double? {
|
|
164
|
+
return { () -> Double? in
|
|
165
|
+
if bridge.has_value_std__optional_double_(self.__connectedAt) {
|
|
166
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__connectedAt)
|
|
167
|
+
return __unwrapped
|
|
168
|
+
} else {
|
|
169
|
+
return nil
|
|
170
|
+
}
|
|
171
|
+
}()
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
@inline(__always)
|
|
175
|
+
var timeToFirstByteMs: Double? {
|
|
176
|
+
return { () -> Double? in
|
|
177
|
+
if bridge.has_value_std__optional_double_(self.__timeToFirstByteMs) {
|
|
178
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__timeToFirstByteMs)
|
|
179
|
+
return __unwrapped
|
|
180
|
+
} else {
|
|
181
|
+
return nil
|
|
182
|
+
}
|
|
183
|
+
}()
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
@inline(__always)
|
|
187
|
+
var lastEventTime: Double? {
|
|
188
|
+
return { () -> Double? in
|
|
189
|
+
if bridge.has_value_std__optional_double_(self.__lastEventTime) {
|
|
190
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__lastEventTime)
|
|
191
|
+
return __unwrapped
|
|
192
|
+
} else {
|
|
193
|
+
return nil
|
|
194
|
+
}
|
|
195
|
+
}()
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
@inline(__always)
|
|
199
|
+
var lastHeartbeatTime: Double? {
|
|
200
|
+
return { () -> Double? in
|
|
201
|
+
if bridge.has_value_std__optional_double_(self.__lastHeartbeatTime) {
|
|
202
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__lastHeartbeatTime)
|
|
203
|
+
return __unwrapped
|
|
204
|
+
} else {
|
|
205
|
+
return nil
|
|
206
|
+
}
|
|
207
|
+
}()
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
@inline(__always)
|
|
211
|
+
var maxEventGapMs: Double {
|
|
212
|
+
return self.__maxEventGapMs
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
@inline(__always)
|
|
216
|
+
var eventsBuffered: Double {
|
|
217
|
+
return self.__eventsBuffered
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@inline(__always)
|
|
221
|
+
var peakBufferedEvents: Double {
|
|
222
|
+
return self.__peakBufferedEvents
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
@inline(__always)
|
|
226
|
+
var bufferFlushCount: Double {
|
|
227
|
+
return self.__bufferFlushCount
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
@inline(__always)
|
|
231
|
+
var bufferOverflowCount: Double {
|
|
232
|
+
return self.__bufferOverflowCount
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
@inline(__always)
|
|
236
|
+
var connectionAttempts: Double {
|
|
237
|
+
return self.__connectionAttempts
|
|
238
|
+
}
|
|
239
|
+
|
|
42
240
|
@inline(__always)
|
|
43
241
|
var reconnectCount: Double {
|
|
44
242
|
return self.__reconnectCount
|
|
45
243
|
}
|
|
46
244
|
|
|
245
|
+
@inline(__always)
|
|
246
|
+
var lastReconnectDelayMs: Double? {
|
|
247
|
+
return { () -> Double? in
|
|
248
|
+
if bridge.has_value_std__optional_double_(self.__lastReconnectDelayMs) {
|
|
249
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__lastReconnectDelayMs)
|
|
250
|
+
return __unwrapped
|
|
251
|
+
} else {
|
|
252
|
+
return nil
|
|
253
|
+
}
|
|
254
|
+
}()
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
@inline(__always)
|
|
258
|
+
var disconnectReason: SseDisconnectReason? {
|
|
259
|
+
return self.__disconnectReason.value
|
|
260
|
+
}
|
|
261
|
+
|
|
47
262
|
@inline(__always)
|
|
48
263
|
var lastErrorTime: Double? {
|
|
49
264
|
return { () -> Double? in
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SseDisconnectReason.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
|
+
#if __has_include(<NitroModules/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::nitrosse {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (SseDisconnectReason).
|
|
30
|
+
*/
|
|
31
|
+
enum class SseDisconnectReason {
|
|
32
|
+
USER_STOP SWIFT_NAME(userStop) = 0,
|
|
33
|
+
NETWORK_ERROR SWIFT_NAME(networkError) = 1,
|
|
34
|
+
SERVER_ERROR SWIFT_NAME(serverError) = 2,
|
|
35
|
+
PARSER_ERROR SWIFT_NAME(parserError) = 3,
|
|
36
|
+
TIMEOUT SWIFT_NAME(timeout) = 4,
|
|
37
|
+
} CLOSED_ENUM;
|
|
38
|
+
|
|
39
|
+
} // namespace margelo::nitro::nitrosse
|
|
40
|
+
|
|
41
|
+
namespace margelo::nitro {
|
|
42
|
+
|
|
43
|
+
// C++ SseDisconnectReason <> JS SseDisconnectReason (union)
|
|
44
|
+
template <>
|
|
45
|
+
struct JSIConverter<margelo::nitro::nitrosse::SseDisconnectReason> final {
|
|
46
|
+
static inline margelo::nitro::nitrosse::SseDisconnectReason fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
47
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
48
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
49
|
+
case hashString("user_stop"): return margelo::nitro::nitrosse::SseDisconnectReason::USER_STOP;
|
|
50
|
+
case hashString("network_error"): return margelo::nitro::nitrosse::SseDisconnectReason::NETWORK_ERROR;
|
|
51
|
+
case hashString("server_error"): return margelo::nitro::nitrosse::SseDisconnectReason::SERVER_ERROR;
|
|
52
|
+
case hashString("parser_error"): return margelo::nitro::nitrosse::SseDisconnectReason::PARSER_ERROR;
|
|
53
|
+
case hashString("timeout"): return margelo::nitro::nitrosse::SseDisconnectReason::TIMEOUT;
|
|
54
|
+
default: [[unlikely]]
|
|
55
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum SseDisconnectReason - invalid value!");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitrosse::SseDisconnectReason arg) {
|
|
59
|
+
switch (arg) {
|
|
60
|
+
case margelo::nitro::nitrosse::SseDisconnectReason::USER_STOP: return JSIConverter<std::string>::toJSI(runtime, "user_stop");
|
|
61
|
+
case margelo::nitro::nitrosse::SseDisconnectReason::NETWORK_ERROR: return JSIConverter<std::string>::toJSI(runtime, "network_error");
|
|
62
|
+
case margelo::nitro::nitrosse::SseDisconnectReason::SERVER_ERROR: return JSIConverter<std::string>::toJSI(runtime, "server_error");
|
|
63
|
+
case margelo::nitro::nitrosse::SseDisconnectReason::PARSER_ERROR: return JSIConverter<std::string>::toJSI(runtime, "parser_error");
|
|
64
|
+
case margelo::nitro::nitrosse::SseDisconnectReason::TIMEOUT: return JSIConverter<std::string>::toJSI(runtime, "timeout");
|
|
65
|
+
default: [[unlikely]]
|
|
66
|
+
throw std::invalid_argument("Cannot convert SseDisconnectReason to JS - invalid value: "
|
|
67
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
71
|
+
if (!value.isString()) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
75
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
76
|
+
case hashString("user_stop"):
|
|
77
|
+
case hashString("network_error"):
|
|
78
|
+
case hashString("server_error"):
|
|
79
|
+
case hashString("parser_error"):
|
|
80
|
+
case hashString("timeout"):
|
|
81
|
+
return true;
|
|
82
|
+
default:
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
} // namespace margelo::nitro
|