react-native-nitro-sse 2.2.3 → 2.3.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/ios/NitroSse.swift +4 -2
- package/lib/module/NitroSseClient.js +171 -2
- package/lib/module/NitroSseClient.js.map +1 -1
- package/lib/typescript/src/NitroSseClient.d.ts +5 -0
- package/lib/typescript/src/NitroSseClient.d.ts.map +1 -1
- package/lib/typescript/src/SseInterface.d.ts +61 -0
- package/lib/typescript/src/SseInterface.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_SseEvent_.hpp +14 -14
- package/nitrogen/generated/android/c++/JHybridNitroSseSpec.cpp +17 -5
- package/nitrogen/generated/android/c++/JSseConfig.hpp +18 -3
- package/nitrogen/generated/android/c++/JSseMockConfig.hpp +101 -0
- package/nitrogen/generated/android/c++/JSseMockEvent.hpp +94 -0
- package/nitrogen/generated/android/c++/JSseMockMode.hpp +58 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/SseConfig.kt +53 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/SseEvent.kt +27 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/SseMockConfig.kt +71 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/SseMockEvent.kt +91 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/SseMockMode.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/SseStats.kt +19 -0
- package/nitrogen/generated/ios/NitroSse-Swift-Cxx-Bridge.hpp +50 -0
- package/nitrogen/generated/ios/NitroSse-Swift-Cxx-Umbrella.hpp +9 -0
- package/nitrogen/generated/ios/c++/HybridNitroSseSpecSwift.hpp +12 -3
- package/nitrogen/generated/ios/swift/SseConfig.swift +12 -1
- package/nitrogen/generated/ios/swift/SseMockConfig.swift +94 -0
- package/nitrogen/generated/ios/swift/SseMockEvent.swift +179 -0
- package/nitrogen/generated/ios/swift/SseMockMode.swift +40 -0
- package/nitrogen/generated/shared/c++/SseConfig.hpp +9 -2
- package/nitrogen/generated/shared/c++/SseMockConfig.hpp +105 -0
- package/nitrogen/generated/shared/c++/SseMockEvent.hpp +119 -0
- package/nitrogen/generated/shared/c++/SseMockMode.hpp +76 -0
- package/package.json +4 -4
- package/src/NitroSseClient.ts +203 -2
- package/src/SseInterface.ts +64 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SseMockConfig.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `SseMockConfig`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias SseMockConfig = margelo.nitro.nitrosse.SseMockConfig
|
|
14
|
+
|
|
15
|
+
public extension SseMockConfig {
|
|
16
|
+
private typealias bridge = margelo.nitro.nitrosse.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `SseMockConfig`.
|
|
20
|
+
*/
|
|
21
|
+
init(mode: SseMockMode, data: [SseMockEvent], eventsPerSecond: Double?, loop: Bool?, errorRate: Double?) {
|
|
22
|
+
self.init(mode, { () -> bridge.std__vector_SseMockEvent_ in
|
|
23
|
+
var __vector = bridge.create_std__vector_SseMockEvent_(data.count)
|
|
24
|
+
for __item in data {
|
|
25
|
+
__vector.push_back(__item)
|
|
26
|
+
}
|
|
27
|
+
return __vector
|
|
28
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
29
|
+
if let __unwrappedValue = eventsPerSecond {
|
|
30
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
31
|
+
} else {
|
|
32
|
+
return .init()
|
|
33
|
+
}
|
|
34
|
+
}(), { () -> bridge.std__optional_bool_ in
|
|
35
|
+
if let __unwrappedValue = loop {
|
|
36
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
37
|
+
} else {
|
|
38
|
+
return .init()
|
|
39
|
+
}
|
|
40
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
41
|
+
if let __unwrappedValue = errorRate {
|
|
42
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
43
|
+
} else {
|
|
44
|
+
return .init()
|
|
45
|
+
}
|
|
46
|
+
}())
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@inline(__always)
|
|
50
|
+
var mode: SseMockMode {
|
|
51
|
+
return self.__mode
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@inline(__always)
|
|
55
|
+
var data: [SseMockEvent] {
|
|
56
|
+
return self.__data.map({ __item in __item })
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@inline(__always)
|
|
60
|
+
var eventsPerSecond: Double? {
|
|
61
|
+
return { () -> Double? in
|
|
62
|
+
if bridge.has_value_std__optional_double_(self.__eventsPerSecond) {
|
|
63
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__eventsPerSecond)
|
|
64
|
+
return __unwrapped
|
|
65
|
+
} else {
|
|
66
|
+
return nil
|
|
67
|
+
}
|
|
68
|
+
}()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@inline(__always)
|
|
72
|
+
var loop: Bool? {
|
|
73
|
+
return { () -> Bool? in
|
|
74
|
+
if bridge.has_value_std__optional_bool_(self.__loop) {
|
|
75
|
+
let __unwrapped = bridge.get_std__optional_bool_(self.__loop)
|
|
76
|
+
return __unwrapped
|
|
77
|
+
} else {
|
|
78
|
+
return nil
|
|
79
|
+
}
|
|
80
|
+
}()
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@inline(__always)
|
|
84
|
+
var errorRate: Double? {
|
|
85
|
+
return { () -> Double? in
|
|
86
|
+
if bridge.has_value_std__optional_double_(self.__errorRate) {
|
|
87
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__errorRate)
|
|
88
|
+
return __unwrapped
|
|
89
|
+
} else {
|
|
90
|
+
return nil
|
|
91
|
+
}
|
|
92
|
+
}()
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SseMockEvent.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `SseMockEvent`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias SseMockEvent = margelo.nitro.nitrosse.SseMockEvent
|
|
14
|
+
|
|
15
|
+
public extension SseMockEvent {
|
|
16
|
+
private typealias bridge = margelo.nitro.nitrosse.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `SseMockEvent`.
|
|
20
|
+
*/
|
|
21
|
+
init(type: SseEventType?, data: String?, parsedData: AnyMap?, id: String?, event: String?, message: String?, statusCode: Double?, retry: Double?, delayMs: Double?) {
|
|
22
|
+
self.init({ () -> bridge.std__optional_SseEventType_ in
|
|
23
|
+
if let __unwrappedValue = type {
|
|
24
|
+
return bridge.create_std__optional_SseEventType_(__unwrappedValue)
|
|
25
|
+
} else {
|
|
26
|
+
return .init()
|
|
27
|
+
}
|
|
28
|
+
}(), { () -> bridge.std__optional_std__string_ in
|
|
29
|
+
if let __unwrappedValue = data {
|
|
30
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
31
|
+
} else {
|
|
32
|
+
return .init()
|
|
33
|
+
}
|
|
34
|
+
}(), { () -> bridge.std__optional_std__shared_ptr_AnyMap__ in
|
|
35
|
+
if let __unwrappedValue = parsedData {
|
|
36
|
+
return bridge.create_std__optional_std__shared_ptr_AnyMap__(__unwrappedValue.cppPart)
|
|
37
|
+
} else {
|
|
38
|
+
return .init()
|
|
39
|
+
}
|
|
40
|
+
}(), { () -> bridge.std__optional_std__string_ in
|
|
41
|
+
if let __unwrappedValue = id {
|
|
42
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
43
|
+
} else {
|
|
44
|
+
return .init()
|
|
45
|
+
}
|
|
46
|
+
}(), { () -> bridge.std__optional_std__string_ in
|
|
47
|
+
if let __unwrappedValue = event {
|
|
48
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
49
|
+
} else {
|
|
50
|
+
return .init()
|
|
51
|
+
}
|
|
52
|
+
}(), { () -> bridge.std__optional_std__string_ in
|
|
53
|
+
if let __unwrappedValue = message {
|
|
54
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
55
|
+
} else {
|
|
56
|
+
return .init()
|
|
57
|
+
}
|
|
58
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
59
|
+
if let __unwrappedValue = statusCode {
|
|
60
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
61
|
+
} else {
|
|
62
|
+
return .init()
|
|
63
|
+
}
|
|
64
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
65
|
+
if let __unwrappedValue = retry {
|
|
66
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
67
|
+
} else {
|
|
68
|
+
return .init()
|
|
69
|
+
}
|
|
70
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
71
|
+
if let __unwrappedValue = delayMs {
|
|
72
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
73
|
+
} else {
|
|
74
|
+
return .init()
|
|
75
|
+
}
|
|
76
|
+
}())
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@inline(__always)
|
|
80
|
+
var type: SseEventType? {
|
|
81
|
+
return self.__type.value
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@inline(__always)
|
|
85
|
+
var data: String? {
|
|
86
|
+
return { () -> String? in
|
|
87
|
+
if bridge.has_value_std__optional_std__string_(self.__data) {
|
|
88
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__data)
|
|
89
|
+
return String(__unwrapped)
|
|
90
|
+
} else {
|
|
91
|
+
return nil
|
|
92
|
+
}
|
|
93
|
+
}()
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@inline(__always)
|
|
97
|
+
var parsedData: AnyMap? {
|
|
98
|
+
return { () -> AnyMap? in
|
|
99
|
+
if bridge.has_value_std__optional_std__shared_ptr_AnyMap__(self.__parsedData) {
|
|
100
|
+
let __unwrapped = bridge.get_std__optional_std__shared_ptr_AnyMap__(self.__parsedData)
|
|
101
|
+
return AnyMap(withCppPart: __unwrapped)
|
|
102
|
+
} else {
|
|
103
|
+
return nil
|
|
104
|
+
}
|
|
105
|
+
}()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@inline(__always)
|
|
109
|
+
var id: String? {
|
|
110
|
+
return { () -> String? in
|
|
111
|
+
if bridge.has_value_std__optional_std__string_(self.__id) {
|
|
112
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__id)
|
|
113
|
+
return String(__unwrapped)
|
|
114
|
+
} else {
|
|
115
|
+
return nil
|
|
116
|
+
}
|
|
117
|
+
}()
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@inline(__always)
|
|
121
|
+
var event: String? {
|
|
122
|
+
return { () -> String? in
|
|
123
|
+
if bridge.has_value_std__optional_std__string_(self.__event) {
|
|
124
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__event)
|
|
125
|
+
return String(__unwrapped)
|
|
126
|
+
} else {
|
|
127
|
+
return nil
|
|
128
|
+
}
|
|
129
|
+
}()
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@inline(__always)
|
|
133
|
+
var message: String? {
|
|
134
|
+
return { () -> String? in
|
|
135
|
+
if bridge.has_value_std__optional_std__string_(self.__message) {
|
|
136
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__message)
|
|
137
|
+
return String(__unwrapped)
|
|
138
|
+
} else {
|
|
139
|
+
return nil
|
|
140
|
+
}
|
|
141
|
+
}()
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@inline(__always)
|
|
145
|
+
var statusCode: Double? {
|
|
146
|
+
return { () -> Double? in
|
|
147
|
+
if bridge.has_value_std__optional_double_(self.__statusCode) {
|
|
148
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__statusCode)
|
|
149
|
+
return __unwrapped
|
|
150
|
+
} else {
|
|
151
|
+
return nil
|
|
152
|
+
}
|
|
153
|
+
}()
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@inline(__always)
|
|
157
|
+
var retry: Double? {
|
|
158
|
+
return { () -> Double? in
|
|
159
|
+
if bridge.has_value_std__optional_double_(self.__retry) {
|
|
160
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__retry)
|
|
161
|
+
return __unwrapped
|
|
162
|
+
} else {
|
|
163
|
+
return nil
|
|
164
|
+
}
|
|
165
|
+
}()
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
@inline(__always)
|
|
169
|
+
var delayMs: Double? {
|
|
170
|
+
return { () -> Double? in
|
|
171
|
+
if bridge.has_value_std__optional_double_(self.__delayMs) {
|
|
172
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__delayMs)
|
|
173
|
+
return __unwrapped
|
|
174
|
+
} else {
|
|
175
|
+
return nil
|
|
176
|
+
}
|
|
177
|
+
}()
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SseMockMode.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 `SseMockMode`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias SseMockMode = margelo.nitro.nitrosse.SseMockMode
|
|
12
|
+
|
|
13
|
+
public extension SseMockMode {
|
|
14
|
+
/**
|
|
15
|
+
* Get a SseMockMode 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 "replace":
|
|
21
|
+
self = .replace
|
|
22
|
+
case "inject":
|
|
23
|
+
self = .inject
|
|
24
|
+
default:
|
|
25
|
+
return nil
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get the String value this SseMockMode represents.
|
|
31
|
+
*/
|
|
32
|
+
var stringValue: String {
|
|
33
|
+
switch self {
|
|
34
|
+
case .replace:
|
|
35
|
+
return "replace"
|
|
36
|
+
case .inject:
|
|
37
|
+
return "inject"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -30,6 +30,8 @@
|
|
|
30
30
|
|
|
31
31
|
// Forward declaration of `HttpMethod` to properly resolve imports.
|
|
32
32
|
namespace margelo::nitro::nitrosse { enum class HttpMethod; }
|
|
33
|
+
// Forward declaration of `SseMockConfig` to properly resolve imports.
|
|
34
|
+
namespace margelo::nitro::nitrosse { struct SseMockConfig; }
|
|
33
35
|
|
|
34
36
|
#include <string>
|
|
35
37
|
#include "HttpMethod.hpp"
|
|
@@ -37,6 +39,7 @@ namespace margelo::nitro::nitrosse { enum class HttpMethod; }
|
|
|
37
39
|
#include <unordered_map>
|
|
38
40
|
#include <NitroModules/Promise.hpp>
|
|
39
41
|
#include <functional>
|
|
42
|
+
#include "SseMockConfig.hpp"
|
|
40
43
|
|
|
41
44
|
namespace margelo::nitro::nitrosse {
|
|
42
45
|
|
|
@@ -61,10 +64,11 @@ namespace margelo::nitro::nitrosse {
|
|
|
61
64
|
std::optional<bool> autoParseJSON SWIFT_PRIVATE;
|
|
62
65
|
std::optional<bool> monitorNetwork SWIFT_PRIVATE;
|
|
63
66
|
std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::unordered_map<std::string, std::string>>>>>()>> onBeforeRequest SWIFT_PRIVATE;
|
|
67
|
+
std::optional<SseMockConfig> mock SWIFT_PRIVATE;
|
|
64
68
|
|
|
65
69
|
public:
|
|
66
70
|
SseConfig() = default;
|
|
67
|
-
explicit SseConfig(std::string url, std::optional<HttpMethod> method, std::optional<std::unordered_map<std::string, std::string>> headers, std::optional<std::string> body, std::optional<bool> backgroundExecution, std::optional<double> batchingIntervalMs, std::optional<double> maxBufferSize, std::optional<double> connectionTimeoutMs, std::optional<double> readTimeoutMs, std::optional<double> retryIntervalMs, std::optional<double> maxRetryIntervalMs, std::optional<double> jitterFactor, std::optional<double> maxReconnectAttempts, std::optional<bool> autoParseJSON, std::optional<bool> monitorNetwork, std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::unordered_map<std::string, std::string>>>>>()>> onBeforeRequest): url(url), method(method), headers(headers), body(body), backgroundExecution(backgroundExecution), batchingIntervalMs(batchingIntervalMs), maxBufferSize(maxBufferSize), connectionTimeoutMs(connectionTimeoutMs), readTimeoutMs(readTimeoutMs), retryIntervalMs(retryIntervalMs), maxRetryIntervalMs(maxRetryIntervalMs), jitterFactor(jitterFactor), maxReconnectAttempts(maxReconnectAttempts), autoParseJSON(autoParseJSON), monitorNetwork(monitorNetwork), onBeforeRequest(onBeforeRequest) {}
|
|
71
|
+
explicit SseConfig(std::string url, std::optional<HttpMethod> method, std::optional<std::unordered_map<std::string, std::string>> headers, std::optional<std::string> body, std::optional<bool> backgroundExecution, std::optional<double> batchingIntervalMs, std::optional<double> maxBufferSize, std::optional<double> connectionTimeoutMs, std::optional<double> readTimeoutMs, std::optional<double> retryIntervalMs, std::optional<double> maxRetryIntervalMs, std::optional<double> jitterFactor, std::optional<double> maxReconnectAttempts, std::optional<bool> autoParseJSON, std::optional<bool> monitorNetwork, std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::unordered_map<std::string, std::string>>>>>()>> onBeforeRequest, std::optional<SseMockConfig> mock): url(url), method(method), headers(headers), body(body), backgroundExecution(backgroundExecution), batchingIntervalMs(batchingIntervalMs), maxBufferSize(maxBufferSize), connectionTimeoutMs(connectionTimeoutMs), readTimeoutMs(readTimeoutMs), retryIntervalMs(retryIntervalMs), maxRetryIntervalMs(maxRetryIntervalMs), jitterFactor(jitterFactor), maxReconnectAttempts(maxReconnectAttempts), autoParseJSON(autoParseJSON), monitorNetwork(monitorNetwork), onBeforeRequest(onBeforeRequest), mock(mock) {}
|
|
68
72
|
|
|
69
73
|
public:
|
|
70
74
|
// SseConfig is not equatable because these properties are not equatable: onBeforeRequest
|
|
@@ -95,7 +99,8 @@ namespace margelo::nitro {
|
|
|
95
99
|
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxReconnectAttempts"))),
|
|
96
100
|
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "autoParseJSON"))),
|
|
97
101
|
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "monitorNetwork"))),
|
|
98
|
-
JSIConverter<std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::unordered_map<std::string, std::string>>>>>()>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onBeforeRequest")))
|
|
102
|
+
JSIConverter<std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::unordered_map<std::string, std::string>>>>>()>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onBeforeRequest"))),
|
|
103
|
+
JSIConverter<std::optional<margelo::nitro::nitrosse::SseMockConfig>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mock")))
|
|
99
104
|
);
|
|
100
105
|
}
|
|
101
106
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrosse::SseConfig& arg) {
|
|
@@ -116,6 +121,7 @@ namespace margelo::nitro {
|
|
|
116
121
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "autoParseJSON"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.autoParseJSON));
|
|
117
122
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "monitorNetwork"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.monitorNetwork));
|
|
118
123
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "onBeforeRequest"), JSIConverter<std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::unordered_map<std::string, std::string>>>>>()>>>::toJSI(runtime, arg.onBeforeRequest));
|
|
124
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "mock"), JSIConverter<std::optional<margelo::nitro::nitrosse::SseMockConfig>>::toJSI(runtime, arg.mock));
|
|
119
125
|
return obj;
|
|
120
126
|
}
|
|
121
127
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -142,6 +148,7 @@ namespace margelo::nitro {
|
|
|
142
148
|
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "autoParseJSON")))) return false;
|
|
143
149
|
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "monitorNetwork")))) return false;
|
|
144
150
|
if (!JSIConverter<std::optional<std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::unordered_map<std::string, std::string>>>>>()>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onBeforeRequest")))) return false;
|
|
151
|
+
if (!JSIConverter<std::optional<margelo::nitro::nitrosse::SseMockConfig>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mock")))) return false;
|
|
145
152
|
return true;
|
|
146
153
|
}
|
|
147
154
|
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SseMockConfig.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/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
// Forward declaration of `SseMockMode` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::nitrosse { enum class SseMockMode; }
|
|
33
|
+
// Forward declaration of `SseMockEvent` to properly resolve imports.
|
|
34
|
+
namespace margelo::nitro::nitrosse { struct SseMockEvent; }
|
|
35
|
+
|
|
36
|
+
#include "SseMockMode.hpp"
|
|
37
|
+
#include "SseMockEvent.hpp"
|
|
38
|
+
#include <vector>
|
|
39
|
+
#include <optional>
|
|
40
|
+
|
|
41
|
+
namespace margelo::nitro::nitrosse {
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A struct which can be represented as a JavaScript object (SseMockConfig).
|
|
45
|
+
*/
|
|
46
|
+
struct SseMockConfig final {
|
|
47
|
+
public:
|
|
48
|
+
SseMockMode mode SWIFT_PRIVATE;
|
|
49
|
+
std::vector<SseMockEvent> data SWIFT_PRIVATE;
|
|
50
|
+
std::optional<double> eventsPerSecond SWIFT_PRIVATE;
|
|
51
|
+
std::optional<bool> loop SWIFT_PRIVATE;
|
|
52
|
+
std::optional<double> errorRate SWIFT_PRIVATE;
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
SseMockConfig() = default;
|
|
56
|
+
explicit SseMockConfig(SseMockMode mode, std::vector<SseMockEvent> data, std::optional<double> eventsPerSecond, std::optional<bool> loop, std::optional<double> errorRate): mode(mode), data(data), eventsPerSecond(eventsPerSecond), loop(loop), errorRate(errorRate) {}
|
|
57
|
+
|
|
58
|
+
public:
|
|
59
|
+
friend bool operator==(const SseMockConfig& lhs, const SseMockConfig& rhs) = default;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
} // namespace margelo::nitro::nitrosse
|
|
63
|
+
|
|
64
|
+
namespace margelo::nitro {
|
|
65
|
+
|
|
66
|
+
// C++ SseMockConfig <> JS SseMockConfig (object)
|
|
67
|
+
template <>
|
|
68
|
+
struct JSIConverter<margelo::nitro::nitrosse::SseMockConfig> final {
|
|
69
|
+
static inline margelo::nitro::nitrosse::SseMockConfig fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
70
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
71
|
+
return margelo::nitro::nitrosse::SseMockConfig(
|
|
72
|
+
JSIConverter<margelo::nitro::nitrosse::SseMockMode>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mode"))),
|
|
73
|
+
JSIConverter<std::vector<margelo::nitro::nitrosse::SseMockEvent>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "data"))),
|
|
74
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "eventsPerSecond"))),
|
|
75
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "loop"))),
|
|
76
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "errorRate")))
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrosse::SseMockConfig& arg) {
|
|
80
|
+
jsi::Object obj(runtime);
|
|
81
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "mode"), JSIConverter<margelo::nitro::nitrosse::SseMockMode>::toJSI(runtime, arg.mode));
|
|
82
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "data"), JSIConverter<std::vector<margelo::nitro::nitrosse::SseMockEvent>>::toJSI(runtime, arg.data));
|
|
83
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "eventsPerSecond"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.eventsPerSecond));
|
|
84
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "loop"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.loop));
|
|
85
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "errorRate"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.errorRate));
|
|
86
|
+
return obj;
|
|
87
|
+
}
|
|
88
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
89
|
+
if (!value.isObject()) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
jsi::Object obj = value.getObject(runtime);
|
|
93
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
if (!JSIConverter<margelo::nitro::nitrosse::SseMockMode>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mode")))) return false;
|
|
97
|
+
if (!JSIConverter<std::vector<margelo::nitro::nitrosse::SseMockEvent>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "data")))) return false;
|
|
98
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "eventsPerSecond")))) return false;
|
|
99
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "loop")))) return false;
|
|
100
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "errorRate")))) return false;
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SseMockEvent.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/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
// Forward declaration of `SseEventType` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::nitrosse { enum class SseEventType; }
|
|
33
|
+
|
|
34
|
+
#include "SseEventType.hpp"
|
|
35
|
+
#include <optional>
|
|
36
|
+
#include <string>
|
|
37
|
+
#include <NitroModules/AnyMap.hpp>
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro::nitrosse {
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A struct which can be represented as a JavaScript object (SseMockEvent).
|
|
43
|
+
*/
|
|
44
|
+
struct SseMockEvent final {
|
|
45
|
+
public:
|
|
46
|
+
std::optional<SseEventType> type SWIFT_PRIVATE;
|
|
47
|
+
std::optional<std::string> data SWIFT_PRIVATE;
|
|
48
|
+
std::optional<std::shared_ptr<AnyMap>> parsedData SWIFT_PRIVATE;
|
|
49
|
+
std::optional<std::string> id SWIFT_PRIVATE;
|
|
50
|
+
std::optional<std::string> event SWIFT_PRIVATE;
|
|
51
|
+
std::optional<std::string> message SWIFT_PRIVATE;
|
|
52
|
+
std::optional<double> statusCode SWIFT_PRIVATE;
|
|
53
|
+
std::optional<double> retry SWIFT_PRIVATE;
|
|
54
|
+
std::optional<double> delayMs SWIFT_PRIVATE;
|
|
55
|
+
|
|
56
|
+
public:
|
|
57
|
+
SseMockEvent() = default;
|
|
58
|
+
explicit SseMockEvent(std::optional<SseEventType> type, std::optional<std::string> data, std::optional<std::shared_ptr<AnyMap>> parsedData, std::optional<std::string> id, std::optional<std::string> event, std::optional<std::string> message, std::optional<double> statusCode, std::optional<double> retry, std::optional<double> delayMs): type(type), data(data), parsedData(parsedData), id(id), event(event), message(message), statusCode(statusCode), retry(retry), delayMs(delayMs) {}
|
|
59
|
+
|
|
60
|
+
public:
|
|
61
|
+
friend bool operator==(const SseMockEvent& lhs, const SseMockEvent& rhs) = default;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
} // namespace margelo::nitro::nitrosse
|
|
65
|
+
|
|
66
|
+
namespace margelo::nitro {
|
|
67
|
+
|
|
68
|
+
// C++ SseMockEvent <> JS SseMockEvent (object)
|
|
69
|
+
template <>
|
|
70
|
+
struct JSIConverter<margelo::nitro::nitrosse::SseMockEvent> final {
|
|
71
|
+
static inline margelo::nitro::nitrosse::SseMockEvent fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
72
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
73
|
+
return margelo::nitro::nitrosse::SseMockEvent(
|
|
74
|
+
JSIConverter<std::optional<margelo::nitro::nitrosse::SseEventType>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type"))),
|
|
75
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "data"))),
|
|
76
|
+
JSIConverter<std::optional<std::shared_ptr<AnyMap>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "parsedData"))),
|
|
77
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id"))),
|
|
78
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "event"))),
|
|
79
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "message"))),
|
|
80
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "statusCode"))),
|
|
81
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "retry"))),
|
|
82
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "delayMs")))
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrosse::SseMockEvent& arg) {
|
|
86
|
+
jsi::Object obj(runtime);
|
|
87
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "type"), JSIConverter<std::optional<margelo::nitro::nitrosse::SseEventType>>::toJSI(runtime, arg.type));
|
|
88
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "data"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.data));
|
|
89
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "parsedData"), JSIConverter<std::optional<std::shared_ptr<AnyMap>>>::toJSI(runtime, arg.parsedData));
|
|
90
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "id"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.id));
|
|
91
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "event"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.event));
|
|
92
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "message"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.message));
|
|
93
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "statusCode"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.statusCode));
|
|
94
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "retry"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.retry));
|
|
95
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "delayMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.delayMs));
|
|
96
|
+
return obj;
|
|
97
|
+
}
|
|
98
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
99
|
+
if (!value.isObject()) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
jsi::Object obj = value.getObject(runtime);
|
|
103
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
if (!JSIConverter<std::optional<margelo::nitro::nitrosse::SseEventType>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type")))) return false;
|
|
107
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "data")))) return false;
|
|
108
|
+
if (!JSIConverter<std::optional<std::shared_ptr<AnyMap>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "parsedData")))) return false;
|
|
109
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id")))) return false;
|
|
110
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "event")))) return false;
|
|
111
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "message")))) return false;
|
|
112
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "statusCode")))) return false;
|
|
113
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "retry")))) return false;
|
|
114
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "delayMs")))) return false;
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SseMockMode.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 (SseMockMode).
|
|
30
|
+
*/
|
|
31
|
+
enum class SseMockMode {
|
|
32
|
+
REPLACE SWIFT_NAME(replace) = 0,
|
|
33
|
+
INJECT SWIFT_NAME(inject) = 1,
|
|
34
|
+
} CLOSED_ENUM;
|
|
35
|
+
|
|
36
|
+
} // namespace margelo::nitro::nitrosse
|
|
37
|
+
|
|
38
|
+
namespace margelo::nitro {
|
|
39
|
+
|
|
40
|
+
// C++ SseMockMode <> JS SseMockMode (union)
|
|
41
|
+
template <>
|
|
42
|
+
struct JSIConverter<margelo::nitro::nitrosse::SseMockMode> final {
|
|
43
|
+
static inline margelo::nitro::nitrosse::SseMockMode fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
44
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
45
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
46
|
+
case hashString("replace"): return margelo::nitro::nitrosse::SseMockMode::REPLACE;
|
|
47
|
+
case hashString("inject"): return margelo::nitro::nitrosse::SseMockMode::INJECT;
|
|
48
|
+
default: [[unlikely]]
|
|
49
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum SseMockMode - invalid value!");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitrosse::SseMockMode arg) {
|
|
53
|
+
switch (arg) {
|
|
54
|
+
case margelo::nitro::nitrosse::SseMockMode::REPLACE: return JSIConverter<std::string>::toJSI(runtime, "replace");
|
|
55
|
+
case margelo::nitro::nitrosse::SseMockMode::INJECT: return JSIConverter<std::string>::toJSI(runtime, "inject");
|
|
56
|
+
default: [[unlikely]]
|
|
57
|
+
throw std::invalid_argument("Cannot convert SseMockMode to JS - invalid value: "
|
|
58
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
62
|
+
if (!value.isString()) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
66
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
67
|
+
case hashString("replace"):
|
|
68
|
+
case hashString("inject"):
|
|
69
|
+
return true;
|
|
70
|
+
default:
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
} // namespace margelo::nitro
|