react-native-nitro-sse 2.2.3 → 2.3.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/ios/NitroSse.swift +55 -9
- 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 +12 -10
- package/src/NitroSseClient.ts +203 -2
- package/src/SseInterface.ts +64 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JSseMockConfig.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 "SseMockConfig.hpp"
|
|
12
|
+
|
|
13
|
+
#include "JSseEventType.hpp"
|
|
14
|
+
#include "JSseMockEvent.hpp"
|
|
15
|
+
#include "JSseMockMode.hpp"
|
|
16
|
+
#include "SseEventType.hpp"
|
|
17
|
+
#include "SseMockEvent.hpp"
|
|
18
|
+
#include "SseMockMode.hpp"
|
|
19
|
+
#include <NitroModules/AnyMap.hpp>
|
|
20
|
+
#include <NitroModules/JAnyMap.hpp>
|
|
21
|
+
#include <optional>
|
|
22
|
+
#include <string>
|
|
23
|
+
#include <vector>
|
|
24
|
+
|
|
25
|
+
namespace margelo::nitro::nitrosse {
|
|
26
|
+
|
|
27
|
+
using namespace facebook;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The C++ JNI bridge between the C++ struct "SseMockConfig" and the the Kotlin data class "SseMockConfig".
|
|
31
|
+
*/
|
|
32
|
+
struct JSseMockConfig final: public jni::JavaClass<JSseMockConfig> {
|
|
33
|
+
public:
|
|
34
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrosse/SseMockConfig;";
|
|
35
|
+
|
|
36
|
+
public:
|
|
37
|
+
/**
|
|
38
|
+
* Convert this Java/Kotlin-based struct to the C++ struct SseMockConfig by copying all values to C++.
|
|
39
|
+
*/
|
|
40
|
+
[[maybe_unused]]
|
|
41
|
+
[[nodiscard]]
|
|
42
|
+
SseMockConfig toCpp() const {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
static const auto fieldMode = clazz->getField<JSseMockMode>("mode");
|
|
45
|
+
jni::local_ref<JSseMockMode> mode = this->getFieldValue(fieldMode);
|
|
46
|
+
static const auto fieldData = clazz->getField<jni::JArrayClass<JSseMockEvent>>("data");
|
|
47
|
+
jni::local_ref<jni::JArrayClass<JSseMockEvent>> data = this->getFieldValue(fieldData);
|
|
48
|
+
static const auto fieldEventsPerSecond = clazz->getField<jni::JDouble>("eventsPerSecond");
|
|
49
|
+
jni::local_ref<jni::JDouble> eventsPerSecond = this->getFieldValue(fieldEventsPerSecond);
|
|
50
|
+
static const auto fieldLoop = clazz->getField<jni::JBoolean>("loop");
|
|
51
|
+
jni::local_ref<jni::JBoolean> loop = this->getFieldValue(fieldLoop);
|
|
52
|
+
static const auto fieldErrorRate = clazz->getField<jni::JDouble>("errorRate");
|
|
53
|
+
jni::local_ref<jni::JDouble> errorRate = this->getFieldValue(fieldErrorRate);
|
|
54
|
+
return SseMockConfig(
|
|
55
|
+
mode->toCpp(),
|
|
56
|
+
[&](auto&& __input) {
|
|
57
|
+
size_t __size = __input->size();
|
|
58
|
+
std::vector<SseMockEvent> __vector;
|
|
59
|
+
__vector.reserve(__size);
|
|
60
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
61
|
+
auto __element = __input->getElement(__i);
|
|
62
|
+
__vector.push_back(__element->toCpp());
|
|
63
|
+
}
|
|
64
|
+
return __vector;
|
|
65
|
+
}(data),
|
|
66
|
+
eventsPerSecond != nullptr ? std::make_optional(eventsPerSecond->value()) : std::nullopt,
|
|
67
|
+
loop != nullptr ? std::make_optional(static_cast<bool>(loop->value())) : std::nullopt,
|
|
68
|
+
errorRate != nullptr ? std::make_optional(errorRate->value()) : std::nullopt
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public:
|
|
73
|
+
/**
|
|
74
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
75
|
+
*/
|
|
76
|
+
[[maybe_unused]]
|
|
77
|
+
static jni::local_ref<JSseMockConfig::javaobject> fromCpp(const SseMockConfig& value) {
|
|
78
|
+
using JSignature = JSseMockConfig(jni::alias_ref<JSseMockMode>, jni::alias_ref<jni::JArrayClass<JSseMockEvent>>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JDouble>);
|
|
79
|
+
static const auto clazz = javaClassStatic();
|
|
80
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
81
|
+
return create(
|
|
82
|
+
clazz,
|
|
83
|
+
JSseMockMode::fromCpp(value.mode),
|
|
84
|
+
[&](auto&& __input) {
|
|
85
|
+
size_t __size = __input.size();
|
|
86
|
+
jni::local_ref<jni::JArrayClass<JSseMockEvent>> __array = jni::JArrayClass<JSseMockEvent>::newArray(__size);
|
|
87
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
88
|
+
const auto& __element = __input[__i];
|
|
89
|
+
auto __elementJni = JSseMockEvent::fromCpp(__element);
|
|
90
|
+
__array->setElement(__i, *__elementJni);
|
|
91
|
+
}
|
|
92
|
+
return __array;
|
|
93
|
+
}(value.data),
|
|
94
|
+
value.eventsPerSecond.has_value() ? jni::JDouble::valueOf(value.eventsPerSecond.value()) : nullptr,
|
|
95
|
+
value.loop.has_value() ? jni::JBoolean::valueOf(value.loop.value()) : nullptr,
|
|
96
|
+
value.errorRate.has_value() ? jni::JDouble::valueOf(value.errorRate.value()) : nullptr
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
} // namespace margelo::nitro::nitrosse
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JSseMockEvent.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 "SseMockEvent.hpp"
|
|
12
|
+
|
|
13
|
+
#include "JSseEventType.hpp"
|
|
14
|
+
#include "SseEventType.hpp"
|
|
15
|
+
#include <NitroModules/AnyMap.hpp>
|
|
16
|
+
#include <NitroModules/JAnyMap.hpp>
|
|
17
|
+
#include <optional>
|
|
18
|
+
#include <string>
|
|
19
|
+
|
|
20
|
+
namespace margelo::nitro::nitrosse {
|
|
21
|
+
|
|
22
|
+
using namespace facebook;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The C++ JNI bridge between the C++ struct "SseMockEvent" and the the Kotlin data class "SseMockEvent".
|
|
26
|
+
*/
|
|
27
|
+
struct JSseMockEvent final: public jni::JavaClass<JSseMockEvent> {
|
|
28
|
+
public:
|
|
29
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrosse/SseMockEvent;";
|
|
30
|
+
|
|
31
|
+
public:
|
|
32
|
+
/**
|
|
33
|
+
* Convert this Java/Kotlin-based struct to the C++ struct SseMockEvent by copying all values to C++.
|
|
34
|
+
*/
|
|
35
|
+
[[maybe_unused]]
|
|
36
|
+
[[nodiscard]]
|
|
37
|
+
SseMockEvent toCpp() const {
|
|
38
|
+
static const auto clazz = javaClassStatic();
|
|
39
|
+
static const auto fieldType = clazz->getField<JSseEventType>("type");
|
|
40
|
+
jni::local_ref<JSseEventType> type = this->getFieldValue(fieldType);
|
|
41
|
+
static const auto fieldData = clazz->getField<jni::JString>("data");
|
|
42
|
+
jni::local_ref<jni::JString> data = this->getFieldValue(fieldData);
|
|
43
|
+
static const auto fieldParsedData = clazz->getField<JAnyMap::javaobject>("parsedData");
|
|
44
|
+
jni::local_ref<JAnyMap::javaobject> parsedData = this->getFieldValue(fieldParsedData);
|
|
45
|
+
static const auto fieldId = clazz->getField<jni::JString>("id");
|
|
46
|
+
jni::local_ref<jni::JString> id = this->getFieldValue(fieldId);
|
|
47
|
+
static const auto fieldEvent = clazz->getField<jni::JString>("event");
|
|
48
|
+
jni::local_ref<jni::JString> event = this->getFieldValue(fieldEvent);
|
|
49
|
+
static const auto fieldMessage = clazz->getField<jni::JString>("message");
|
|
50
|
+
jni::local_ref<jni::JString> message = this->getFieldValue(fieldMessage);
|
|
51
|
+
static const auto fieldStatusCode = clazz->getField<jni::JDouble>("statusCode");
|
|
52
|
+
jni::local_ref<jni::JDouble> statusCode = this->getFieldValue(fieldStatusCode);
|
|
53
|
+
static const auto fieldRetry = clazz->getField<jni::JDouble>("retry");
|
|
54
|
+
jni::local_ref<jni::JDouble> retry = this->getFieldValue(fieldRetry);
|
|
55
|
+
static const auto fieldDelayMs = clazz->getField<jni::JDouble>("delayMs");
|
|
56
|
+
jni::local_ref<jni::JDouble> delayMs = this->getFieldValue(fieldDelayMs);
|
|
57
|
+
return SseMockEvent(
|
|
58
|
+
type != nullptr ? std::make_optional(type->toCpp()) : std::nullopt,
|
|
59
|
+
data != nullptr ? std::make_optional(data->toStdString()) : std::nullopt,
|
|
60
|
+
parsedData != nullptr ? std::make_optional(parsedData->cthis()->getMap()) : std::nullopt,
|
|
61
|
+
id != nullptr ? std::make_optional(id->toStdString()) : std::nullopt,
|
|
62
|
+
event != nullptr ? std::make_optional(event->toStdString()) : std::nullopt,
|
|
63
|
+
message != nullptr ? std::make_optional(message->toStdString()) : std::nullopt,
|
|
64
|
+
statusCode != nullptr ? std::make_optional(statusCode->value()) : std::nullopt,
|
|
65
|
+
retry != nullptr ? std::make_optional(retry->value()) : std::nullopt,
|
|
66
|
+
delayMs != nullptr ? std::make_optional(delayMs->value()) : std::nullopt
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public:
|
|
71
|
+
/**
|
|
72
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
73
|
+
*/
|
|
74
|
+
[[maybe_unused]]
|
|
75
|
+
static jni::local_ref<JSseMockEvent::javaobject> fromCpp(const SseMockEvent& value) {
|
|
76
|
+
using JSignature = JSseMockEvent(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<jni::JDouble>);
|
|
77
|
+
static const auto clazz = javaClassStatic();
|
|
78
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
79
|
+
return create(
|
|
80
|
+
clazz,
|
|
81
|
+
value.type.has_value() ? JSseEventType::fromCpp(value.type.value()) : nullptr,
|
|
82
|
+
value.data.has_value() ? jni::make_jstring(value.data.value()) : nullptr,
|
|
83
|
+
value.parsedData.has_value() ? JAnyMap::create(value.parsedData.value()) : nullptr,
|
|
84
|
+
value.id.has_value() ? jni::make_jstring(value.id.value()) : nullptr,
|
|
85
|
+
value.event.has_value() ? jni::make_jstring(value.event.value()) : nullptr,
|
|
86
|
+
value.message.has_value() ? jni::make_jstring(value.message.value()) : nullptr,
|
|
87
|
+
value.statusCode.has_value() ? jni::JDouble::valueOf(value.statusCode.value()) : nullptr,
|
|
88
|
+
value.retry.has_value() ? jni::JDouble::valueOf(value.retry.value()) : nullptr,
|
|
89
|
+
value.delayMs.has_value() ? jni::JDouble::valueOf(value.delayMs.value()) : nullptr
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
} // namespace margelo::nitro::nitrosse
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JSseMockMode.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 "SseMockMode.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::nitrosse {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "SseMockMode" and the the Kotlin enum "SseMockMode".
|
|
19
|
+
*/
|
|
20
|
+
struct JSseMockMode final: public jni::JavaClass<JSseMockMode> {
|
|
21
|
+
public:
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrosse/SseMockMode;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum SseMockMode.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
SseMockMode 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<SseMockMode>(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<JSseMockMode> fromCpp(SseMockMode value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case SseMockMode::REPLACE:
|
|
46
|
+
static const auto fieldREPLACE = clazz->getStaticField<JSseMockMode>("REPLACE");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldREPLACE);
|
|
48
|
+
case SseMockMode::INJECT:
|
|
49
|
+
static const auto fieldINJECT = clazz->getStaticField<JSseMockMode>("INJECT");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldINJECT);
|
|
51
|
+
default:
|
|
52
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
53
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace margelo::nitro::nitrosse
|
|
@@ -9,6 +9,7 @@ package com.margelo.nitro.nitrosse
|
|
|
9
9
|
|
|
10
10
|
import androidx.annotation.Keep
|
|
11
11
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import java.util.Objects
|
|
12
13
|
import com.margelo.nitro.core.Promise
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -64,13 +65,60 @@ data class SseConfig(
|
|
|
64
65
|
val monitorNetwork: Boolean?,
|
|
65
66
|
@DoNotStrip
|
|
66
67
|
@Keep
|
|
67
|
-
val onBeforeRequest: Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____
|
|
68
|
+
val onBeforeRequest: Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____?,
|
|
69
|
+
@DoNotStrip
|
|
70
|
+
@Keep
|
|
71
|
+
val mock: SseMockConfig?
|
|
68
72
|
) {
|
|
69
73
|
/**
|
|
70
74
|
* Create a new instance of SseConfig from Kotlin
|
|
71
75
|
*/
|
|
72
|
-
constructor(url: String, method: HttpMethod?, headers: Map<String, String>?, body: String?, backgroundExecution: Boolean?, batchingIntervalMs: Double?, maxBufferSize: Double?, connectionTimeoutMs: Double?, readTimeoutMs: Double?, retryIntervalMs: Double?, maxRetryIntervalMs: Double?, jitterFactor: Double?, maxReconnectAttempts: Double?, autoParseJSON: Boolean?, monitorNetwork: Boolean?, onBeforeRequest: (() -> Promise<Promise<Map<String, String>>>)?):
|
|
73
|
-
this(url, method, headers, body, backgroundExecution, batchingIntervalMs, maxBufferSize, connectionTimeoutMs, readTimeoutMs, retryIntervalMs, maxRetryIntervalMs, jitterFactor, maxReconnectAttempts, autoParseJSON, monitorNetwork, onBeforeRequest?.let { Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string______java(it) })
|
|
76
|
+
constructor(url: String, method: HttpMethod?, headers: Map<String, String>?, body: String?, backgroundExecution: Boolean?, batchingIntervalMs: Double?, maxBufferSize: Double?, connectionTimeoutMs: Double?, readTimeoutMs: Double?, retryIntervalMs: Double?, maxRetryIntervalMs: Double?, jitterFactor: Double?, maxReconnectAttempts: Double?, autoParseJSON: Boolean?, monitorNetwork: Boolean?, onBeforeRequest: (() -> Promise<Promise<Map<String, String>>>)?, mock: SseMockConfig?):
|
|
77
|
+
this(url, method, headers, body, backgroundExecution, batchingIntervalMs, maxBufferSize, connectionTimeoutMs, readTimeoutMs, retryIntervalMs, maxRetryIntervalMs, jitterFactor, maxReconnectAttempts, autoParseJSON, monitorNetwork, onBeforeRequest?.let { Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string______java(it) }, mock)
|
|
78
|
+
|
|
79
|
+
override fun equals(other: Any?): Boolean {
|
|
80
|
+
if (this === other) return true
|
|
81
|
+
if (other !is SseConfig) return false
|
|
82
|
+
return Objects.deepEquals(this.url, other.url)
|
|
83
|
+
&& Objects.deepEquals(this.method, other.method)
|
|
84
|
+
&& Objects.deepEquals(this.headers, other.headers)
|
|
85
|
+
&& Objects.deepEquals(this.body, other.body)
|
|
86
|
+
&& Objects.deepEquals(this.backgroundExecution, other.backgroundExecution)
|
|
87
|
+
&& Objects.deepEquals(this.batchingIntervalMs, other.batchingIntervalMs)
|
|
88
|
+
&& Objects.deepEquals(this.maxBufferSize, other.maxBufferSize)
|
|
89
|
+
&& Objects.deepEquals(this.connectionTimeoutMs, other.connectionTimeoutMs)
|
|
90
|
+
&& Objects.deepEquals(this.readTimeoutMs, other.readTimeoutMs)
|
|
91
|
+
&& Objects.deepEquals(this.retryIntervalMs, other.retryIntervalMs)
|
|
92
|
+
&& Objects.deepEquals(this.maxRetryIntervalMs, other.maxRetryIntervalMs)
|
|
93
|
+
&& Objects.deepEquals(this.jitterFactor, other.jitterFactor)
|
|
94
|
+
&& Objects.deepEquals(this.maxReconnectAttempts, other.maxReconnectAttempts)
|
|
95
|
+
&& Objects.deepEquals(this.autoParseJSON, other.autoParseJSON)
|
|
96
|
+
&& Objects.deepEquals(this.monitorNetwork, other.monitorNetwork)
|
|
97
|
+
&& Objects.deepEquals(this.onBeforeRequest, other.onBeforeRequest)
|
|
98
|
+
&& Objects.deepEquals(this.mock, other.mock)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
override fun hashCode(): Int {
|
|
102
|
+
return arrayOf<Any?>(
|
|
103
|
+
url,
|
|
104
|
+
method,
|
|
105
|
+
headers,
|
|
106
|
+
body,
|
|
107
|
+
backgroundExecution,
|
|
108
|
+
batchingIntervalMs,
|
|
109
|
+
maxBufferSize,
|
|
110
|
+
connectionTimeoutMs,
|
|
111
|
+
readTimeoutMs,
|
|
112
|
+
retryIntervalMs,
|
|
113
|
+
maxRetryIntervalMs,
|
|
114
|
+
jitterFactor,
|
|
115
|
+
maxReconnectAttempts,
|
|
116
|
+
autoParseJSON,
|
|
117
|
+
monitorNetwork,
|
|
118
|
+
onBeforeRequest,
|
|
119
|
+
mock
|
|
120
|
+
).contentDeepHashCode()
|
|
121
|
+
}
|
|
74
122
|
|
|
75
123
|
companion object {
|
|
76
124
|
/**
|
|
@@ -80,8 +128,8 @@ data class SseConfig(
|
|
|
80
128
|
@Keep
|
|
81
129
|
@Suppress("unused")
|
|
82
130
|
@JvmStatic
|
|
83
|
-
private fun fromCpp(url: String, method: HttpMethod?, headers: Map<String, String>?, body: String?, backgroundExecution: Boolean?, batchingIntervalMs: Double?, maxBufferSize: Double?, connectionTimeoutMs: Double?, readTimeoutMs: Double?, retryIntervalMs: Double?, maxRetryIntervalMs: Double?, jitterFactor: Double?, maxReconnectAttempts: Double?, autoParseJSON: Boolean?, monitorNetwork: Boolean?, onBeforeRequest: Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____?): SseConfig {
|
|
84
|
-
return SseConfig(url, method, headers, body, backgroundExecution, batchingIntervalMs, maxBufferSize, connectionTimeoutMs, readTimeoutMs, retryIntervalMs, maxRetryIntervalMs, jitterFactor, maxReconnectAttempts, autoParseJSON, monitorNetwork, onBeforeRequest)
|
|
131
|
+
private fun fromCpp(url: String, method: HttpMethod?, headers: Map<String, String>?, body: String?, backgroundExecution: Boolean?, batchingIntervalMs: Double?, maxBufferSize: Double?, connectionTimeoutMs: Double?, readTimeoutMs: Double?, retryIntervalMs: Double?, maxRetryIntervalMs: Double?, jitterFactor: Double?, maxReconnectAttempts: Double?, autoParseJSON: Boolean?, monitorNetwork: Boolean?, onBeforeRequest: Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____?, mock: SseMockConfig?): SseConfig {
|
|
132
|
+
return SseConfig(url, method, headers, body, backgroundExecution, batchingIntervalMs, maxBufferSize, connectionTimeoutMs, readTimeoutMs, retryIntervalMs, maxRetryIntervalMs, jitterFactor, maxReconnectAttempts, autoParseJSON, monitorNetwork, onBeforeRequest, mock)
|
|
85
133
|
}
|
|
86
134
|
}
|
|
87
135
|
}
|
|
@@ -9,6 +9,7 @@ package com.margelo.nitro.nitrosse
|
|
|
9
9
|
|
|
10
10
|
import androidx.annotation.Keep
|
|
11
11
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import java.util.Objects
|
|
12
13
|
import com.margelo.nitro.core.AnyMap
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -44,6 +45,32 @@ data class SseEvent(
|
|
|
44
45
|
) {
|
|
45
46
|
/* primary constructor */
|
|
46
47
|
|
|
48
|
+
override fun equals(other: Any?): Boolean {
|
|
49
|
+
if (this === other) return true
|
|
50
|
+
if (other !is SseEvent) return false
|
|
51
|
+
return Objects.deepEquals(this.type, other.type)
|
|
52
|
+
&& Objects.deepEquals(this.data, other.data)
|
|
53
|
+
&& Objects.deepEquals(this.parsedData, other.parsedData)
|
|
54
|
+
&& Objects.deepEquals(this.id, other.id)
|
|
55
|
+
&& Objects.deepEquals(this.event, other.event)
|
|
56
|
+
&& Objects.deepEquals(this.message, other.message)
|
|
57
|
+
&& Objects.deepEquals(this.statusCode, other.statusCode)
|
|
58
|
+
&& Objects.deepEquals(this.retry, other.retry)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
override fun hashCode(): Int {
|
|
62
|
+
return arrayOf<Any?>(
|
|
63
|
+
type,
|
|
64
|
+
data,
|
|
65
|
+
parsedData,
|
|
66
|
+
id,
|
|
67
|
+
event,
|
|
68
|
+
message,
|
|
69
|
+
statusCode,
|
|
70
|
+
retry
|
|
71
|
+
).contentDeepHashCode()
|
|
72
|
+
}
|
|
73
|
+
|
|
47
74
|
companion object {
|
|
48
75
|
/**
|
|
49
76
|
* Constructor called from C++
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SseMockConfig.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
|
+
import java.util.Objects
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript object/struct "SseMockConfig".
|
|
17
|
+
*/
|
|
18
|
+
@DoNotStrip
|
|
19
|
+
@Keep
|
|
20
|
+
data class SseMockConfig(
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
val mode: SseMockMode,
|
|
24
|
+
@DoNotStrip
|
|
25
|
+
@Keep
|
|
26
|
+
val data: Array<SseMockEvent>,
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
@Keep
|
|
29
|
+
val eventsPerSecond: Double?,
|
|
30
|
+
@DoNotStrip
|
|
31
|
+
@Keep
|
|
32
|
+
val loop: Boolean?,
|
|
33
|
+
@DoNotStrip
|
|
34
|
+
@Keep
|
|
35
|
+
val errorRate: Double?
|
|
36
|
+
) {
|
|
37
|
+
/* primary constructor */
|
|
38
|
+
|
|
39
|
+
override fun equals(other: Any?): Boolean {
|
|
40
|
+
if (this === other) return true
|
|
41
|
+
if (other !is SseMockConfig) return false
|
|
42
|
+
return Objects.deepEquals(this.mode, other.mode)
|
|
43
|
+
&& Objects.deepEquals(this.data, other.data)
|
|
44
|
+
&& Objects.deepEquals(this.eventsPerSecond, other.eventsPerSecond)
|
|
45
|
+
&& Objects.deepEquals(this.loop, other.loop)
|
|
46
|
+
&& Objects.deepEquals(this.errorRate, other.errorRate)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
override fun hashCode(): Int {
|
|
50
|
+
return arrayOf<Any?>(
|
|
51
|
+
mode,
|
|
52
|
+
data,
|
|
53
|
+
eventsPerSecond,
|
|
54
|
+
loop,
|
|
55
|
+
errorRate
|
|
56
|
+
).contentDeepHashCode()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
companion object {
|
|
60
|
+
/**
|
|
61
|
+
* Constructor called from C++
|
|
62
|
+
*/
|
|
63
|
+
@DoNotStrip
|
|
64
|
+
@Keep
|
|
65
|
+
@Suppress("unused")
|
|
66
|
+
@JvmStatic
|
|
67
|
+
private fun fromCpp(mode: SseMockMode, data: Array<SseMockEvent>, eventsPerSecond: Double?, loop: Boolean?, errorRate: Double?): SseMockConfig {
|
|
68
|
+
return SseMockConfig(mode, data, eventsPerSecond, loop, errorRate)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SseMockEvent.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
|
+
import java.util.Objects
|
|
13
|
+
import com.margelo.nitro.core.AnyMap
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript object/struct "SseMockEvent".
|
|
17
|
+
*/
|
|
18
|
+
@DoNotStrip
|
|
19
|
+
@Keep
|
|
20
|
+
data class SseMockEvent(
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
val type: SseEventType?,
|
|
24
|
+
@DoNotStrip
|
|
25
|
+
@Keep
|
|
26
|
+
val data: String?,
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
@Keep
|
|
29
|
+
val parsedData: AnyMap?,
|
|
30
|
+
@DoNotStrip
|
|
31
|
+
@Keep
|
|
32
|
+
val id: String?,
|
|
33
|
+
@DoNotStrip
|
|
34
|
+
@Keep
|
|
35
|
+
val event: String?,
|
|
36
|
+
@DoNotStrip
|
|
37
|
+
@Keep
|
|
38
|
+
val message: String?,
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
val statusCode: Double?,
|
|
42
|
+
@DoNotStrip
|
|
43
|
+
@Keep
|
|
44
|
+
val retry: Double?,
|
|
45
|
+
@DoNotStrip
|
|
46
|
+
@Keep
|
|
47
|
+
val delayMs: Double?
|
|
48
|
+
) {
|
|
49
|
+
/* primary constructor */
|
|
50
|
+
|
|
51
|
+
override fun equals(other: Any?): Boolean {
|
|
52
|
+
if (this === other) return true
|
|
53
|
+
if (other !is SseMockEvent) return false
|
|
54
|
+
return Objects.deepEquals(this.type, other.type)
|
|
55
|
+
&& Objects.deepEquals(this.data, other.data)
|
|
56
|
+
&& Objects.deepEquals(this.parsedData, other.parsedData)
|
|
57
|
+
&& Objects.deepEquals(this.id, other.id)
|
|
58
|
+
&& Objects.deepEquals(this.event, other.event)
|
|
59
|
+
&& Objects.deepEquals(this.message, other.message)
|
|
60
|
+
&& Objects.deepEquals(this.statusCode, other.statusCode)
|
|
61
|
+
&& Objects.deepEquals(this.retry, other.retry)
|
|
62
|
+
&& Objects.deepEquals(this.delayMs, other.delayMs)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
override fun hashCode(): Int {
|
|
66
|
+
return arrayOf<Any?>(
|
|
67
|
+
type,
|
|
68
|
+
data,
|
|
69
|
+
parsedData,
|
|
70
|
+
id,
|
|
71
|
+
event,
|
|
72
|
+
message,
|
|
73
|
+
statusCode,
|
|
74
|
+
retry,
|
|
75
|
+
delayMs
|
|
76
|
+
).contentDeepHashCode()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
companion object {
|
|
80
|
+
/**
|
|
81
|
+
* Constructor called from C++
|
|
82
|
+
*/
|
|
83
|
+
@DoNotStrip
|
|
84
|
+
@Keep
|
|
85
|
+
@Suppress("unused")
|
|
86
|
+
@JvmStatic
|
|
87
|
+
private fun fromCpp(type: SseEventType?, data: String?, parsedData: AnyMap?, id: String?, event: String?, message: String?, statusCode: Double?, retry: Double?, delayMs: Double?): SseMockEvent {
|
|
88
|
+
return SseMockEvent(type, data, parsedData, id, event, message, statusCode, retry, delayMs)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SseMockMode.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 "SseMockMode".
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
@Keep
|
|
18
|
+
enum class SseMockMode(@DoNotStrip @Keep val value: Int) {
|
|
19
|
+
REPLACE(0),
|
|
20
|
+
INJECT(1);
|
|
21
|
+
|
|
22
|
+
companion object
|
|
23
|
+
}
|
|
@@ -9,6 +9,7 @@ package com.margelo.nitro.nitrosse
|
|
|
9
9
|
|
|
10
10
|
import androidx.annotation.Keep
|
|
11
11
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import java.util.Objects
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -32,6 +33,24 @@ data class SseStats(
|
|
|
32
33
|
) {
|
|
33
34
|
/* primary constructor */
|
|
34
35
|
|
|
36
|
+
override fun equals(other: Any?): Boolean {
|
|
37
|
+
if (this === other) return true
|
|
38
|
+
if (other !is SseStats) return false
|
|
39
|
+
return Objects.deepEquals(this.totalBytesReceived, other.totalBytesReceived)
|
|
40
|
+
&& Objects.deepEquals(this.reconnectCount, other.reconnectCount)
|
|
41
|
+
&& Objects.deepEquals(this.lastErrorTime, other.lastErrorTime)
|
|
42
|
+
&& Objects.deepEquals(this.lastErrorCode, other.lastErrorCode)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
override fun hashCode(): Int {
|
|
46
|
+
return arrayOf<Any?>(
|
|
47
|
+
totalBytesReceived,
|
|
48
|
+
reconnectCount,
|
|
49
|
+
lastErrorTime,
|
|
50
|
+
lastErrorCode
|
|
51
|
+
).contentDeepHashCode()
|
|
52
|
+
}
|
|
53
|
+
|
|
35
54
|
companion object {
|
|
36
55
|
/**
|
|
37
56
|
* Constructor called from C++
|
|
@@ -16,6 +16,12 @@ namespace margelo::nitro::nitrosse { class HybridNitroSseSpec; }
|
|
|
16
16
|
namespace margelo::nitro::nitrosse { enum class SseEventType; }
|
|
17
17
|
// Forward declaration of `SseEvent` to properly resolve imports.
|
|
18
18
|
namespace margelo::nitro::nitrosse { struct SseEvent; }
|
|
19
|
+
// Forward declaration of `SseMockConfig` to properly resolve imports.
|
|
20
|
+
namespace margelo::nitro::nitrosse { struct SseMockConfig; }
|
|
21
|
+
// Forward declaration of `SseMockEvent` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::nitrosse { struct SseMockEvent; }
|
|
23
|
+
// Forward declaration of `SseMockMode` to properly resolve imports.
|
|
24
|
+
namespace margelo::nitro::nitrosse { enum class SseMockMode; }
|
|
19
25
|
// Forward declaration of `SseStats` to properly resolve imports.
|
|
20
26
|
namespace margelo::nitro::nitrosse { struct SseStats; }
|
|
21
27
|
|
|
@@ -28,6 +34,9 @@ namespace NitroSse { class HybridNitroSseSpec_cxx; }
|
|
|
28
34
|
#include "HybridNitroSseSpec.hpp"
|
|
29
35
|
#include "SseEvent.hpp"
|
|
30
36
|
#include "SseEventType.hpp"
|
|
37
|
+
#include "SseMockConfig.hpp"
|
|
38
|
+
#include "SseMockEvent.hpp"
|
|
39
|
+
#include "SseMockMode.hpp"
|
|
31
40
|
#include "SseStats.hpp"
|
|
32
41
|
#include <NitroModules/AnyMap.hpp>
|
|
33
42
|
#include <NitroModules/Promise.hpp>
|
|
@@ -275,6 +284,21 @@ namespace margelo::nitro::nitrosse::bridge::swift {
|
|
|
275
284
|
return optional.value();
|
|
276
285
|
}
|
|
277
286
|
|
|
287
|
+
// pragma MARK: std::optional<SseEventType>
|
|
288
|
+
/**
|
|
289
|
+
* Specialized version of `std::optional<SseEventType>`.
|
|
290
|
+
*/
|
|
291
|
+
using std__optional_SseEventType_ = std::optional<SseEventType>;
|
|
292
|
+
inline std::optional<SseEventType> create_std__optional_SseEventType_(const SseEventType& value) noexcept {
|
|
293
|
+
return std::optional<SseEventType>(value);
|
|
294
|
+
}
|
|
295
|
+
inline bool has_value_std__optional_SseEventType_(const std::optional<SseEventType>& optional) noexcept {
|
|
296
|
+
return optional.has_value();
|
|
297
|
+
}
|
|
298
|
+
inline SseEventType get_std__optional_SseEventType_(const std::optional<SseEventType>& optional) noexcept {
|
|
299
|
+
return optional.value();
|
|
300
|
+
}
|
|
301
|
+
|
|
278
302
|
// pragma MARK: std::optional<std::shared_ptr<AnyMap>>
|
|
279
303
|
/**
|
|
280
304
|
* Specialized version of `std::optional<std::shared_ptr<AnyMap>>`.
|
|
@@ -290,6 +314,32 @@ namespace margelo::nitro::nitrosse::bridge::swift {
|
|
|
290
314
|
return optional.value();
|
|
291
315
|
}
|
|
292
316
|
|
|
317
|
+
// pragma MARK: std::vector<SseMockEvent>
|
|
318
|
+
/**
|
|
319
|
+
* Specialized version of `std::vector<SseMockEvent>`.
|
|
320
|
+
*/
|
|
321
|
+
using std__vector_SseMockEvent_ = std::vector<SseMockEvent>;
|
|
322
|
+
inline std::vector<SseMockEvent> create_std__vector_SseMockEvent_(size_t size) noexcept {
|
|
323
|
+
std::vector<SseMockEvent> vector;
|
|
324
|
+
vector.reserve(size);
|
|
325
|
+
return vector;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// pragma MARK: std::optional<SseMockConfig>
|
|
329
|
+
/**
|
|
330
|
+
* Specialized version of `std::optional<SseMockConfig>`.
|
|
331
|
+
*/
|
|
332
|
+
using std__optional_SseMockConfig_ = std::optional<SseMockConfig>;
|
|
333
|
+
inline std::optional<SseMockConfig> create_std__optional_SseMockConfig_(const SseMockConfig& value) noexcept {
|
|
334
|
+
return std::optional<SseMockConfig>(value);
|
|
335
|
+
}
|
|
336
|
+
inline bool has_value_std__optional_SseMockConfig_(const std::optional<SseMockConfig>& optional) noexcept {
|
|
337
|
+
return optional.has_value();
|
|
338
|
+
}
|
|
339
|
+
inline SseMockConfig get_std__optional_SseMockConfig_(const std::optional<SseMockConfig>& optional) noexcept {
|
|
340
|
+
return optional.value();
|
|
341
|
+
}
|
|
342
|
+
|
|
293
343
|
// pragma MARK: std::vector<SseEvent>
|
|
294
344
|
/**
|
|
295
345
|
* Specialized version of `std::vector<SseEvent>`.
|