@shamilovtim/react-native-nitro-sse 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/LICENSE +21 -0
- package/NitroSse.podspec +37 -0
- package/README.md +144 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +124 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/cpp/cpp-adapter.cpp +10 -0
- package/android/src/main/java/com/margelo/nitro/nitrosse/NetworkInspector.kt +94 -0
- package/android/src/main/java/com/margelo/nitro/nitrosse/NitroSse.kt +889 -0
- package/android/src/main/java/com/margelo/nitro/nitrosse/NitroSsePackage.kt +22 -0
- package/ios/NitroSse.swift +760 -0
- package/ios/NitroSseNetworkInspector.h +24 -0
- package/ios/NitroSseNetworkInspector.mm +68 -0
- package/lib/module/NitroSse.nitro.js +4 -0
- package/lib/module/NitroSse.nitro.js.map +1 -0
- package/lib/module/NitroSseClient.js +244 -0
- package/lib/module/NitroSseClient.js.map +1 -0
- package/lib/module/SseInterface.js +4 -0
- package/lib/module/SseInterface.js.map +1 -0
- package/lib/module/index.js +26 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NitroSse.nitro.d.ts +48 -0
- package/lib/typescript/src/NitroSse.nitro.d.ts.map +1 -0
- package/lib/typescript/src/NitroSseClient.d.ts +26 -0
- package/lib/typescript/src/NitroSseClient.d.ts.map +1 -0
- package/lib/typescript/src/SseInterface.d.ts +237 -0
- package/lib/typescript/src/SseInterface.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +11 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +23 -0
- package/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____.hpp +138 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_SseEvent_.hpp +102 -0
- package/nitrogen/generated/android/c++/JHttpMethod.hpp +58 -0
- package/nitrogen/generated/android/c++/JHybridNitroSseSpec.cpp +134 -0
- package/nitrogen/generated/android/c++/JHybridNitroSseSpec.hpp +71 -0
- package/nitrogen/generated/android/c++/JSseConfig.hpp +162 -0
- package/nitrogen/generated/android/c++/JSseEvent.hpp +90 -0
- package/nitrogen/generated/android/c++/JSseEventType.hpp +67 -0
- 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/c++/JSseStats.hpp +70 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/Func_void_std__vector_SseEvent_.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/HttpMethod.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/HybridNitroSseSpec.kt +91 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/SseConfig.kt +135 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/SseEvent.kt +86 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/SseEventType.kt +26 -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 +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrosse/nitrosseOnLoad.kt +35 -0
- package/nitrogen/generated/android/nitrosse+autolinking.cmake +81 -0
- package/nitrogen/generated/android/nitrosse+autolinking.gradle +27 -0
- package/nitrogen/generated/android/nitrosseOnLoad.cpp +58 -0
- package/nitrogen/generated/android/nitrosseOnLoad.hpp +34 -0
- package/nitrogen/generated/ios/NitroSse+autolinking.rb +62 -0
- package/nitrogen/generated/ios/NitroSse-Swift-Cxx-Bridge.cpp +74 -0
- package/nitrogen/generated/ios/NitroSse-Swift-Cxx-Bridge.hpp +415 -0
- package/nitrogen/generated/ios/NitroSse-Swift-Cxx-Umbrella.hpp +74 -0
- package/nitrogen/generated/ios/NitroSseAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroSseAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridNitroSseSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroSseSpecSwift.hpp +161 -0
- package/nitrogen/generated/ios/swift/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____.swift +67 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__shared_ptr_Promise_std__unordered_map_std__string__std__string___.swift +66 -0
- package/nitrogen/generated/ios/swift/Func_void_std__unordered_map_std__string__std__string_.swift +54 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_SseEvent_.swift +46 -0
- package/nitrogen/generated/ios/swift/HttpMethod.swift +40 -0
- package/nitrogen/generated/ios/swift/HybridNitroSseSpec.swift +63 -0
- package/nitrogen/generated/ios/swift/HybridNitroSseSpec_cxx.swift +246 -0
- package/nitrogen/generated/ios/swift/SseConfig.swift +346 -0
- package/nitrogen/generated/ios/swift/SseEvent.swift +155 -0
- package/nitrogen/generated/ios/swift/SseEventType.swift +52 -0
- 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/ios/swift/SseStats.swift +70 -0
- package/nitrogen/generated/shared/c++/HttpMethod.hpp +76 -0
- package/nitrogen/generated/shared/c++/HybridNitroSseSpec.cpp +29 -0
- package/nitrogen/generated/shared/c++/HybridNitroSseSpec.hpp +81 -0
- package/nitrogen/generated/shared/c++/SseConfig.hpp +156 -0
- package/nitrogen/generated/shared/c++/SseEvent.hpp +115 -0
- package/nitrogen/generated/shared/c++/SseEventType.hpp +88 -0
- 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/nitrogen/generated/shared/c++/SseStats.hpp +96 -0
- package/package.json +186 -0
- package/src/NitroSse.nitro.ts +53 -0
- package/src/NitroSseClient.ts +297 -0
- package/src/SseInterface.ts +248 -0
- package/src/index.ts +31 -0
|
@@ -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
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JSseStats.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 "SseStats.hpp"
|
|
12
|
+
|
|
13
|
+
#include <optional>
|
|
14
|
+
#include <string>
|
|
15
|
+
|
|
16
|
+
namespace margelo::nitro::nitrosse {
|
|
17
|
+
|
|
18
|
+
using namespace facebook;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The C++ JNI bridge between the C++ struct "SseStats" and the the Kotlin data class "SseStats".
|
|
22
|
+
*/
|
|
23
|
+
struct JSseStats final: public jni::JavaClass<JSseStats> {
|
|
24
|
+
public:
|
|
25
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrosse/SseStats;";
|
|
26
|
+
|
|
27
|
+
public:
|
|
28
|
+
/**
|
|
29
|
+
* Convert this Java/Kotlin-based struct to the C++ struct SseStats by copying all values to C++.
|
|
30
|
+
*/
|
|
31
|
+
[[maybe_unused]]
|
|
32
|
+
[[nodiscard]]
|
|
33
|
+
SseStats toCpp() const {
|
|
34
|
+
static const auto clazz = javaClassStatic();
|
|
35
|
+
static const auto fieldTotalBytesReceived = clazz->getField<double>("totalBytesReceived");
|
|
36
|
+
double totalBytesReceived = this->getFieldValue(fieldTotalBytesReceived);
|
|
37
|
+
static const auto fieldReconnectCount = clazz->getField<double>("reconnectCount");
|
|
38
|
+
double reconnectCount = this->getFieldValue(fieldReconnectCount);
|
|
39
|
+
static const auto fieldLastErrorTime = clazz->getField<jni::JDouble>("lastErrorTime");
|
|
40
|
+
jni::local_ref<jni::JDouble> lastErrorTime = this->getFieldValue(fieldLastErrorTime);
|
|
41
|
+
static const auto fieldLastErrorCode = clazz->getField<jni::JString>("lastErrorCode");
|
|
42
|
+
jni::local_ref<jni::JString> lastErrorCode = this->getFieldValue(fieldLastErrorCode);
|
|
43
|
+
return SseStats(
|
|
44
|
+
totalBytesReceived,
|
|
45
|
+
reconnectCount,
|
|
46
|
+
lastErrorTime != nullptr ? std::make_optional(lastErrorTime->value()) : std::nullopt,
|
|
47
|
+
lastErrorCode != nullptr ? std::make_optional(lastErrorCode->toStdString()) : std::nullopt
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
/**
|
|
53
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
54
|
+
*/
|
|
55
|
+
[[maybe_unused]]
|
|
56
|
+
static jni::local_ref<JSseStats::javaobject> fromCpp(const SseStats& value) {
|
|
57
|
+
using JSignature = JSseStats(double, double, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JString>);
|
|
58
|
+
static const auto clazz = javaClassStatic();
|
|
59
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
60
|
+
return create(
|
|
61
|
+
clazz,
|
|
62
|
+
value.totalBytesReceived,
|
|
63
|
+
value.reconnectCount,
|
|
64
|
+
value.lastErrorTime.has_value() ? jni::JDouble::valueOf(value.lastErrorTime.value()) : nullptr,
|
|
65
|
+
value.lastErrorCode.has_value() ? jni::make_jstring(value.lastErrorCode.value()) : nullptr
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
} // namespace margelo::nitro::nitrosse
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____.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.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import dalvik.annotation.optimization.FastNative
|
|
14
|
+
import com.margelo.nitro.core.Promise
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represents the JavaScript callback `() => std::shared_ptr<Promise<std::shared_ptr<Promise<std::unordered_map<std::string, std::string>>>>>`.
|
|
18
|
+
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
19
|
+
* or in Kotlin/Java (in which case it is a native callback).
|
|
20
|
+
*/
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
@Suppress("ClassName", "RedundantUnitReturnType")
|
|
24
|
+
fun interface Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____: () -> Promise<Promise<Map<String, String>>> {
|
|
25
|
+
/**
|
|
26
|
+
* Call the given JS callback.
|
|
27
|
+
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
|
28
|
+
*/
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
@Keep
|
|
31
|
+
override fun invoke(): Promise<Promise<Map<String, String>>>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Represents the JavaScript callback `() => std::shared_ptr<Promise<std::shared_ptr<Promise<std::unordered_map<std::string, std::string>>>>>`.
|
|
36
|
+
* This is implemented in C++, via a `std::function<...>`.
|
|
37
|
+
* The callback might be coming from JS.
|
|
38
|
+
*/
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
@Suppress(
|
|
42
|
+
"KotlinJniMissingFunction", "unused",
|
|
43
|
+
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
|
44
|
+
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
|
45
|
+
)
|
|
46
|
+
class Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string______cxx: Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____ {
|
|
47
|
+
@DoNotStrip
|
|
48
|
+
@Keep
|
|
49
|
+
private val mHybridData: HybridData
|
|
50
|
+
|
|
51
|
+
@DoNotStrip
|
|
52
|
+
@Keep
|
|
53
|
+
private constructor(hybridData: HybridData) {
|
|
54
|
+
mHybridData = hybridData
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@DoNotStrip
|
|
58
|
+
@Keep
|
|
59
|
+
override fun invoke(): Promise<Promise<Map<String, String>>>
|
|
60
|
+
= invoke_cxx()
|
|
61
|
+
|
|
62
|
+
@FastNative
|
|
63
|
+
private external fun invoke_cxx(): Promise<Promise<Map<String, String>>>
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Represents the JavaScript callback `() => std::shared_ptr<Promise<std::shared_ptr<Promise<std::unordered_map<std::string, std::string>>>>>`.
|
|
68
|
+
* This is implemented in Java/Kotlin, via a `() -> Promise<Promise<Map<String, String>>>`.
|
|
69
|
+
* The callback is always coming from native.
|
|
70
|
+
*/
|
|
71
|
+
@DoNotStrip
|
|
72
|
+
@Keep
|
|
73
|
+
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
74
|
+
class Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string______java(private val function: () -> Promise<Promise<Map<String, String>>>): Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____ {
|
|
75
|
+
@DoNotStrip
|
|
76
|
+
@Keep
|
|
77
|
+
override fun invoke(): Promise<Promise<Map<String, String>>> {
|
|
78
|
+
return this.function()
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__vector_SseEvent_.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.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import dalvik.annotation.optimization.FastNative
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represents the JavaScript callback `(events: array) => void`.
|
|
18
|
+
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
19
|
+
* or in Kotlin/Java (in which case it is a native callback).
|
|
20
|
+
*/
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
@Suppress("ClassName", "RedundantUnitReturnType")
|
|
24
|
+
fun interface Func_void_std__vector_SseEvent_: (Array<SseEvent>) -> Unit {
|
|
25
|
+
/**
|
|
26
|
+
* Call the given JS callback.
|
|
27
|
+
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
|
28
|
+
*/
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
@Keep
|
|
31
|
+
override fun invoke(events: Array<SseEvent>): Unit
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Represents the JavaScript callback `(events: array) => void`.
|
|
36
|
+
* This is implemented in C++, via a `std::function<...>`.
|
|
37
|
+
* The callback might be coming from JS.
|
|
38
|
+
*/
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
@Suppress(
|
|
42
|
+
"KotlinJniMissingFunction", "unused",
|
|
43
|
+
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
|
44
|
+
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
|
45
|
+
)
|
|
46
|
+
class Func_void_std__vector_SseEvent__cxx: Func_void_std__vector_SseEvent_ {
|
|
47
|
+
@DoNotStrip
|
|
48
|
+
@Keep
|
|
49
|
+
private val mHybridData: HybridData
|
|
50
|
+
|
|
51
|
+
@DoNotStrip
|
|
52
|
+
@Keep
|
|
53
|
+
private constructor(hybridData: HybridData) {
|
|
54
|
+
mHybridData = hybridData
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@DoNotStrip
|
|
58
|
+
@Keep
|
|
59
|
+
override fun invoke(events: Array<SseEvent>): Unit
|
|
60
|
+
= invoke_cxx(events)
|
|
61
|
+
|
|
62
|
+
@FastNative
|
|
63
|
+
private external fun invoke_cxx(events: Array<SseEvent>): Unit
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Represents the JavaScript callback `(events: array) => void`.
|
|
68
|
+
* This is implemented in Java/Kotlin, via a `(Array<SseEvent>) -> Unit`.
|
|
69
|
+
* The callback is always coming from native.
|
|
70
|
+
*/
|
|
71
|
+
@DoNotStrip
|
|
72
|
+
@Keep
|
|
73
|
+
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
74
|
+
class Func_void_std__vector_SseEvent__java(private val function: (Array<SseEvent>) -> Unit): Func_void_std__vector_SseEvent_ {
|
|
75
|
+
@DoNotStrip
|
|
76
|
+
@Keep
|
|
77
|
+
override fun invoke(events: Array<SseEvent>): Unit {
|
|
78
|
+
return this.function(events)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HttpMethod.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 "HttpMethod".
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
@Keep
|
|
18
|
+
enum class HttpMethod(@DoNotStrip @Keep val value: Int) {
|
|
19
|
+
GET(0),
|
|
20
|
+
POST(1);
|
|
21
|
+
|
|
22
|
+
companion object
|
|
23
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroSseSpec.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.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import com.margelo.nitro.core.HybridObject
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A Kotlin class representing the NitroSse HybridObject.
|
|
17
|
+
* Implement this abstract class to create Kotlin-based instances of NitroSse.
|
|
18
|
+
*/
|
|
19
|
+
@DoNotStrip
|
|
20
|
+
@Keep
|
|
21
|
+
@Suppress(
|
|
22
|
+
"KotlinJniMissingFunction", "unused",
|
|
23
|
+
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
|
|
24
|
+
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
25
|
+
)
|
|
26
|
+
abstract class HybridNitroSseSpec: HybridObject() {
|
|
27
|
+
// Properties
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
// Methods
|
|
31
|
+
abstract fun setup(config: SseConfig, onEvent: (events: Array<SseEvent>) -> Unit): Unit
|
|
32
|
+
|
|
33
|
+
@DoNotStrip
|
|
34
|
+
@Keep
|
|
35
|
+
private fun setup_cxx(config: SseConfig, onEvent: Func_void_std__vector_SseEvent_): Unit {
|
|
36
|
+
val __result = setup(config, onEvent)
|
|
37
|
+
return __result
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@DoNotStrip
|
|
41
|
+
@Keep
|
|
42
|
+
abstract fun start(): Unit
|
|
43
|
+
|
|
44
|
+
@DoNotStrip
|
|
45
|
+
@Keep
|
|
46
|
+
abstract fun stop(): Unit
|
|
47
|
+
|
|
48
|
+
@DoNotStrip
|
|
49
|
+
@Keep
|
|
50
|
+
abstract fun setLastProcessedId(id: String): Unit
|
|
51
|
+
|
|
52
|
+
@DoNotStrip
|
|
53
|
+
@Keep
|
|
54
|
+
abstract fun updateHeaders(headers: Map<String, String>): Unit
|
|
55
|
+
|
|
56
|
+
@DoNotStrip
|
|
57
|
+
@Keep
|
|
58
|
+
abstract fun getStats(): SseStats
|
|
59
|
+
|
|
60
|
+
@DoNotStrip
|
|
61
|
+
@Keep
|
|
62
|
+
abstract fun flush(): Unit
|
|
63
|
+
|
|
64
|
+
@DoNotStrip
|
|
65
|
+
@Keep
|
|
66
|
+
abstract fun restart(): Unit
|
|
67
|
+
|
|
68
|
+
@DoNotStrip
|
|
69
|
+
@Keep
|
|
70
|
+
abstract fun isConnected(): Boolean
|
|
71
|
+
|
|
72
|
+
// Default implementation of `HybridObject.toString()`
|
|
73
|
+
override fun toString(): String {
|
|
74
|
+
return "[HybridObject NitroSse]"
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// C++ backing class
|
|
78
|
+
@DoNotStrip
|
|
79
|
+
@Keep
|
|
80
|
+
protected open class CxxPart(javaPart: HybridNitroSseSpec): HybridObject.CxxPart(javaPart) {
|
|
81
|
+
// C++ JHybridNitroSseSpec::CxxPart::initHybrid(...)
|
|
82
|
+
external override fun initHybrid(): HybridData
|
|
83
|
+
}
|
|
84
|
+
override fun createCxxPart(): CxxPart {
|
|
85
|
+
return CxxPart(this)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
companion object {
|
|
89
|
+
protected const val TAG = "HybridNitroSseSpec"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SseConfig.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.Promise
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript object/struct "SseConfig".
|
|
17
|
+
*/
|
|
18
|
+
@DoNotStrip
|
|
19
|
+
@Keep
|
|
20
|
+
data class SseConfig(
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
val url: String,
|
|
24
|
+
@DoNotStrip
|
|
25
|
+
@Keep
|
|
26
|
+
val method: HttpMethod?,
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
@Keep
|
|
29
|
+
val headers: Map<String, String>?,
|
|
30
|
+
@DoNotStrip
|
|
31
|
+
@Keep
|
|
32
|
+
val body: String?,
|
|
33
|
+
@DoNotStrip
|
|
34
|
+
@Keep
|
|
35
|
+
val backgroundExecution: Boolean?,
|
|
36
|
+
@DoNotStrip
|
|
37
|
+
@Keep
|
|
38
|
+
val batchingIntervalMs: Double?,
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
val maxBufferSize: Double?,
|
|
42
|
+
@DoNotStrip
|
|
43
|
+
@Keep
|
|
44
|
+
val connectionTimeoutMs: Double?,
|
|
45
|
+
@DoNotStrip
|
|
46
|
+
@Keep
|
|
47
|
+
val readTimeoutMs: Double?,
|
|
48
|
+
@DoNotStrip
|
|
49
|
+
@Keep
|
|
50
|
+
val retryIntervalMs: Double?,
|
|
51
|
+
@DoNotStrip
|
|
52
|
+
@Keep
|
|
53
|
+
val maxRetryIntervalMs: Double?,
|
|
54
|
+
@DoNotStrip
|
|
55
|
+
@Keep
|
|
56
|
+
val jitterFactor: Double?,
|
|
57
|
+
@DoNotStrip
|
|
58
|
+
@Keep
|
|
59
|
+
val maxReconnectAttempts: Double?,
|
|
60
|
+
@DoNotStrip
|
|
61
|
+
@Keep
|
|
62
|
+
val autoParseJSON: Boolean?,
|
|
63
|
+
@DoNotStrip
|
|
64
|
+
@Keep
|
|
65
|
+
val monitorNetwork: Boolean?,
|
|
66
|
+
@DoNotStrip
|
|
67
|
+
@Keep
|
|
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?
|
|
72
|
+
) {
|
|
73
|
+
/**
|
|
74
|
+
* Create a new instance of SseConfig from Kotlin
|
|
75
|
+
*/
|
|
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(
|
|
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
|
+
}
|
|
122
|
+
|
|
123
|
+
companion object {
|
|
124
|
+
/**
|
|
125
|
+
* Constructor called from C++
|
|
126
|
+
*/
|
|
127
|
+
@DoNotStrip
|
|
128
|
+
@Keep
|
|
129
|
+
@Suppress("unused")
|
|
130
|
+
@JvmStatic
|
|
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)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|