@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,161 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroSseSpecSwift.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 "HybridNitroSseSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridNitroSseSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace NitroSse { class HybridNitroSseSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
// Forward declaration of `SseConfig` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::nitrosse { struct SseConfig; }
|
|
17
|
+
// Forward declaration of `HttpMethod` to properly resolve imports.
|
|
18
|
+
namespace margelo::nitro::nitrosse { enum class HttpMethod; }
|
|
19
|
+
// Forward declaration of `SseMockConfig` to properly resolve imports.
|
|
20
|
+
namespace margelo::nitro::nitrosse { struct SseMockConfig; }
|
|
21
|
+
// Forward declaration of `SseMockMode` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::nitrosse { enum class SseMockMode; }
|
|
23
|
+
// Forward declaration of `SseMockEvent` to properly resolve imports.
|
|
24
|
+
namespace margelo::nitro::nitrosse { struct SseMockEvent; }
|
|
25
|
+
// Forward declaration of `SseEventType` to properly resolve imports.
|
|
26
|
+
namespace margelo::nitro::nitrosse { enum class SseEventType; }
|
|
27
|
+
// Forward declaration of `SseEvent` to properly resolve imports.
|
|
28
|
+
namespace margelo::nitro::nitrosse { struct SseEvent; }
|
|
29
|
+
// Forward declaration of `SseStats` to properly resolve imports.
|
|
30
|
+
namespace margelo::nitro::nitrosse { struct SseStats; }
|
|
31
|
+
|
|
32
|
+
#include "SseConfig.hpp"
|
|
33
|
+
#include <string>
|
|
34
|
+
#include "HttpMethod.hpp"
|
|
35
|
+
#include <optional>
|
|
36
|
+
#include <unordered_map>
|
|
37
|
+
#include <NitroModules/Promise.hpp>
|
|
38
|
+
#include <functional>
|
|
39
|
+
#include "SseMockConfig.hpp"
|
|
40
|
+
#include "SseMockMode.hpp"
|
|
41
|
+
#include "SseMockEvent.hpp"
|
|
42
|
+
#include <vector>
|
|
43
|
+
#include "SseEventType.hpp"
|
|
44
|
+
#include <NitroModules/AnyMap.hpp>
|
|
45
|
+
#include "SseEvent.hpp"
|
|
46
|
+
#include "SseStats.hpp"
|
|
47
|
+
|
|
48
|
+
#include "NitroSse-Swift-Cxx-Umbrella.hpp"
|
|
49
|
+
|
|
50
|
+
namespace margelo::nitro::nitrosse {
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The C++ part of HybridNitroSseSpec_cxx.swift.
|
|
54
|
+
*
|
|
55
|
+
* HybridNitroSseSpecSwift (C++) accesses HybridNitroSseSpec_cxx (Swift), and might
|
|
56
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
57
|
+
*
|
|
58
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
59
|
+
* the future, HybridNitroSseSpec_cxx can directly inherit from the C++ class HybridNitroSseSpec
|
|
60
|
+
* to simplify the whole structure and memory management.
|
|
61
|
+
*/
|
|
62
|
+
class HybridNitroSseSpecSwift: public virtual HybridNitroSseSpec {
|
|
63
|
+
public:
|
|
64
|
+
// Constructor from a Swift instance
|
|
65
|
+
explicit HybridNitroSseSpecSwift(const NitroSse::HybridNitroSseSpec_cxx& swiftPart):
|
|
66
|
+
HybridObject(HybridNitroSseSpec::TAG),
|
|
67
|
+
_swiftPart(swiftPart) { }
|
|
68
|
+
|
|
69
|
+
public:
|
|
70
|
+
// Get the Swift part
|
|
71
|
+
inline NitroSse::HybridNitroSseSpec_cxx& getSwiftPart() noexcept {
|
|
72
|
+
return _swiftPart;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public:
|
|
76
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
77
|
+
return _swiftPart.getMemorySize();
|
|
78
|
+
}
|
|
79
|
+
bool equals(const std::shared_ptr<HybridObject>& other) override {
|
|
80
|
+
if (auto otherCast = std::dynamic_pointer_cast<HybridNitroSseSpecSwift>(other)) {
|
|
81
|
+
return _swiftPart.equals(otherCast->_swiftPart);
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
void dispose() noexcept override {
|
|
86
|
+
_swiftPart.dispose();
|
|
87
|
+
}
|
|
88
|
+
std::string toString() override {
|
|
89
|
+
return _swiftPart.toString();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public:
|
|
93
|
+
// Properties
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
public:
|
|
97
|
+
// Methods
|
|
98
|
+
inline void setup(const SseConfig& config, const std::function<void(const std::vector<SseEvent>& /* events */)>& onEvent) override {
|
|
99
|
+
auto __result = _swiftPart.setup(std::forward<decltype(config)>(config), onEvent);
|
|
100
|
+
if (__result.hasError()) [[unlikely]] {
|
|
101
|
+
std::rethrow_exception(__result.error());
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
inline void start() override {
|
|
105
|
+
auto __result = _swiftPart.start();
|
|
106
|
+
if (__result.hasError()) [[unlikely]] {
|
|
107
|
+
std::rethrow_exception(__result.error());
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
inline void stop() override {
|
|
111
|
+
auto __result = _swiftPart.stop();
|
|
112
|
+
if (__result.hasError()) [[unlikely]] {
|
|
113
|
+
std::rethrow_exception(__result.error());
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
inline void setLastProcessedId(const std::string& id) override {
|
|
117
|
+
auto __result = _swiftPart.setLastProcessedId(id);
|
|
118
|
+
if (__result.hasError()) [[unlikely]] {
|
|
119
|
+
std::rethrow_exception(__result.error());
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
inline void updateHeaders(const std::unordered_map<std::string, std::string>& headers) override {
|
|
123
|
+
auto __result = _swiftPart.updateHeaders(headers);
|
|
124
|
+
if (__result.hasError()) [[unlikely]] {
|
|
125
|
+
std::rethrow_exception(__result.error());
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
inline SseStats getStats() override {
|
|
129
|
+
auto __result = _swiftPart.getStats();
|
|
130
|
+
if (__result.hasError()) [[unlikely]] {
|
|
131
|
+
std::rethrow_exception(__result.error());
|
|
132
|
+
}
|
|
133
|
+
auto __value = std::move(__result.value());
|
|
134
|
+
return __value;
|
|
135
|
+
}
|
|
136
|
+
inline void flush() override {
|
|
137
|
+
auto __result = _swiftPart.flush();
|
|
138
|
+
if (__result.hasError()) [[unlikely]] {
|
|
139
|
+
std::rethrow_exception(__result.error());
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
inline void restart() override {
|
|
143
|
+
auto __result = _swiftPart.restart();
|
|
144
|
+
if (__result.hasError()) [[unlikely]] {
|
|
145
|
+
std::rethrow_exception(__result.error());
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
inline bool isConnected() override {
|
|
149
|
+
auto __result = _swiftPart.isConnected();
|
|
150
|
+
if (__result.hasError()) [[unlikely]] {
|
|
151
|
+
std::rethrow_exception(__result.error());
|
|
152
|
+
}
|
|
153
|
+
auto __value = std::move(__result.value());
|
|
154
|
+
return __value;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private:
|
|
158
|
+
NitroSse::HybridNitroSseSpec_cxx _swiftPart;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
} // namespace margelo::nitro::nitrosse
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____.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
|
+
* Wraps a Swift `() -> Promise<Promise<Dictionary<String, String>>>` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____ {
|
|
15
|
+
public typealias bridge = margelo.nitro.nitrosse.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: () -> Promise<Promise<Dictionary<String, String>>>
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping () -> Promise<Promise<Dictionary<String, String>>>) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call() -> bridge.std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____ {
|
|
25
|
+
let __result: Promise<Promise<Dictionary<String, String>>> = self.closure()
|
|
26
|
+
return { () -> bridge.std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____ in
|
|
27
|
+
let __promise = bridge.create_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____()
|
|
28
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____(__promise)
|
|
29
|
+
__result
|
|
30
|
+
.then({ __result in __promiseHolder.resolve({ () -> bridge.std__shared_ptr_Promise_std__unordered_map_std__string__std__string___ in
|
|
31
|
+
let __promise = bridge.create_std__shared_ptr_Promise_std__unordered_map_std__string__std__string___()
|
|
32
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__unordered_map_std__string__std__string___(__promise)
|
|
33
|
+
__result
|
|
34
|
+
.then({ __result in __promiseHolder.resolve({ () -> bridge.std__unordered_map_std__string__std__string_ in
|
|
35
|
+
var __map = bridge.create_std__unordered_map_std__string__std__string_(__result.count)
|
|
36
|
+
for (__k, __v) in __result {
|
|
37
|
+
bridge.emplace_std__unordered_map_std__string__std__string_(&__map, std.string(__k), std.string(__v))
|
|
38
|
+
}
|
|
39
|
+
return __map
|
|
40
|
+
}()) })
|
|
41
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
42
|
+
return __promise
|
|
43
|
+
}()) })
|
|
44
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
45
|
+
return __promise
|
|
46
|
+
}()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
51
|
+
* This acquires one additional strong reference on the object!
|
|
52
|
+
*/
|
|
53
|
+
@inline(__always)
|
|
54
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
55
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Casts an unsafe pointer to a `Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____`.
|
|
60
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____>`.
|
|
61
|
+
* This removes one strong reference from the object!
|
|
62
|
+
*/
|
|
63
|
+
@inline(__always)
|
|
64
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____ {
|
|
65
|
+
return Unmanaged<Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__unordered_map_std__string__std__string_____>.fromOpaque(pointer).takeRetainedValue()
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__exception_ptr.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
|
+
* Wraps a Swift `(_ error: Error) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_std__exception_ptr {
|
|
15
|
+
public typealias bridge = margelo.nitro.nitrosse.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ error: Error) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ error: Error) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(error: std.exception_ptr) -> Void {
|
|
25
|
+
self.closure(RuntimeError.from(cppError: error))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
|
|
44
|
+
return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__shared_ptr_Promise_std__unordered_map_std__string__std__string___.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
|
+
* Wraps a Swift `(_ value: Promise<Dictionary<String, String>>) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_std__shared_ptr_Promise_std__unordered_map_std__string__std__string___ {
|
|
15
|
+
public typealias bridge = margelo.nitro.nitrosse.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ value: Promise<Dictionary<String, String>>) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ value: Promise<Dictionary<String, String>>) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(value: bridge.std__shared_ptr_Promise_std__unordered_map_std__string__std__string___) -> Void {
|
|
25
|
+
self.closure({ () -> Promise<Dictionary<String, String>> in
|
|
26
|
+
let __promise = Promise<Dictionary<String, String>>()
|
|
27
|
+
let __resolver = { (__result: Dictionary<String, String>) in
|
|
28
|
+
__promise.resolve(withResult: __result)
|
|
29
|
+
}
|
|
30
|
+
let __rejecter = { (__error: Error) in
|
|
31
|
+
__promise.reject(withError: __error)
|
|
32
|
+
}
|
|
33
|
+
let __resolverCpp = { () -> bridge.Func_void_std__unordered_map_std__string__std__string_ in
|
|
34
|
+
let __closureWrapper = Func_void_std__unordered_map_std__string__std__string_(__resolver)
|
|
35
|
+
return bridge.create_Func_void_std__unordered_map_std__string__std__string_(__closureWrapper.toUnsafe())
|
|
36
|
+
}()
|
|
37
|
+
let __rejecterCpp = { () -> bridge.Func_void_std__exception_ptr in
|
|
38
|
+
let __closureWrapper = Func_void_std__exception_ptr(__rejecter)
|
|
39
|
+
return bridge.create_Func_void_std__exception_ptr(__closureWrapper.toUnsafe())
|
|
40
|
+
}()
|
|
41
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__unordered_map_std__string__std__string___(value)
|
|
42
|
+
__promiseHolder.addOnResolvedListener(__resolverCpp)
|
|
43
|
+
__promiseHolder.addOnRejectedListener(__rejecterCpp)
|
|
44
|
+
return __promise
|
|
45
|
+
}())
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
50
|
+
* This acquires one additional strong reference on the object!
|
|
51
|
+
*/
|
|
52
|
+
@inline(__always)
|
|
53
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
54
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Casts an unsafe pointer to a `Func_void_std__shared_ptr_Promise_std__unordered_map_std__string__std__string___`.
|
|
59
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__shared_ptr_Promise_std__unordered_map_std__string__std__string___>`.
|
|
60
|
+
* This removes one strong reference from the object!
|
|
61
|
+
*/
|
|
62
|
+
@inline(__always)
|
|
63
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__shared_ptr_Promise_std__unordered_map_std__string__std__string___ {
|
|
64
|
+
return Unmanaged<Func_void_std__shared_ptr_Promise_std__unordered_map_std__string__std__string___>.fromOpaque(pointer).takeRetainedValue()
|
|
65
|
+
}
|
|
66
|
+
}
|
package/nitrogen/generated/ios/swift/Func_void_std__unordered_map_std__string__std__string_.swift
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__unordered_map_std__string__std__string_.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
|
+
* Wraps a Swift `(_ value: Dictionary<String, String>) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_std__unordered_map_std__string__std__string_ {
|
|
15
|
+
public typealias bridge = margelo.nitro.nitrosse.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ value: Dictionary<String, String>) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ value: Dictionary<String, String>) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(value: bridge.std__unordered_map_std__string__std__string_) -> Void {
|
|
25
|
+
self.closure({ () -> Dictionary<String, String> in
|
|
26
|
+
var __dictionary = Dictionary<String, String>(minimumCapacity: value.size())
|
|
27
|
+
let __keys = bridge.get_std__unordered_map_std__string__std__string__keys(value)
|
|
28
|
+
for __key in __keys {
|
|
29
|
+
let __value = bridge.get_std__unordered_map_std__string__std__string__value(value, __key)
|
|
30
|
+
__dictionary[String(__key)] = String(__value)
|
|
31
|
+
}
|
|
32
|
+
return __dictionary
|
|
33
|
+
}())
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
38
|
+
* This acquires one additional strong reference on the object!
|
|
39
|
+
*/
|
|
40
|
+
@inline(__always)
|
|
41
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
42
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Casts an unsafe pointer to a `Func_void_std__unordered_map_std__string__std__string_`.
|
|
47
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__unordered_map_std__string__std__string_>`.
|
|
48
|
+
* This removes one strong reference from the object!
|
|
49
|
+
*/
|
|
50
|
+
@inline(__always)
|
|
51
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__unordered_map_std__string__std__string_ {
|
|
52
|
+
return Unmanaged<Func_void_std__unordered_map_std__string__std__string_>.fromOpaque(pointer).takeRetainedValue()
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__vector_SseEvent_.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
|
+
* Wraps a Swift `(_ events: [SseEvent]) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_std__vector_SseEvent_ {
|
|
15
|
+
public typealias bridge = margelo.nitro.nitrosse.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ events: [SseEvent]) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ events: [SseEvent]) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(events: bridge.std__vector_SseEvent_) -> Void {
|
|
25
|
+
self.closure(events.map({ __item in __item }))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_std__vector_SseEvent_`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__vector_SseEvent_>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__vector_SseEvent_ {
|
|
44
|
+
return Unmanaged<Func_void_std__vector_SseEvent_>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HttpMethod.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 `HttpMethod`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias HttpMethod = margelo.nitro.nitrosse.HttpMethod
|
|
12
|
+
|
|
13
|
+
public extension HttpMethod {
|
|
14
|
+
/**
|
|
15
|
+
* Get a HttpMethod 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 "get":
|
|
21
|
+
self = .get
|
|
22
|
+
case "post":
|
|
23
|
+
self = .post
|
|
24
|
+
default:
|
|
25
|
+
return nil
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get the String value this HttpMethod represents.
|
|
31
|
+
*/
|
|
32
|
+
var stringValue: String {
|
|
33
|
+
switch self {
|
|
34
|
+
case .get:
|
|
35
|
+
return "get"
|
|
36
|
+
case .post:
|
|
37
|
+
return "post"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroSseSpec.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
|
+
/// See ``HybridNitroSseSpec``
|
|
11
|
+
public protocol HybridNitroSseSpec_protocol: HybridObject {
|
|
12
|
+
// Properties
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
// Methods
|
|
16
|
+
func setup(config: SseConfig, onEvent: @escaping (_ events: [SseEvent]) -> Void) throws -> Void
|
|
17
|
+
func start() throws -> Void
|
|
18
|
+
func stop() throws -> Void
|
|
19
|
+
func setLastProcessedId(id: String) throws -> Void
|
|
20
|
+
func updateHeaders(headers: Dictionary<String, String>) throws -> Void
|
|
21
|
+
func getStats() throws -> SseStats
|
|
22
|
+
func flush() throws -> Void
|
|
23
|
+
func restart() throws -> Void
|
|
24
|
+
func isConnected() throws -> Bool
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public extension HybridNitroSseSpec_protocol {
|
|
28
|
+
/// Default implementation of ``HybridObject.toString``
|
|
29
|
+
func toString() -> String {
|
|
30
|
+
return "[HybridObject NitroSse]"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/// See ``HybridNitroSseSpec``
|
|
35
|
+
open class HybridNitroSseSpec_base {
|
|
36
|
+
private weak var cxxWrapper: HybridNitroSseSpec_cxx? = nil
|
|
37
|
+
public init() { }
|
|
38
|
+
public func getCxxWrapper() -> HybridNitroSseSpec_cxx {
|
|
39
|
+
#if DEBUG
|
|
40
|
+
guard self is any HybridNitroSseSpec else {
|
|
41
|
+
fatalError("`self` is not a `HybridNitroSseSpec`! Did you accidentally inherit from `HybridNitroSseSpec_base` instead of `HybridNitroSseSpec`?")
|
|
42
|
+
}
|
|
43
|
+
#endif
|
|
44
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
45
|
+
return cxxWrapper
|
|
46
|
+
} else {
|
|
47
|
+
let cxxWrapper = HybridNitroSseSpec_cxx(self as! any HybridNitroSseSpec)
|
|
48
|
+
self.cxxWrapper = cxxWrapper
|
|
49
|
+
return cxxWrapper
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A Swift base-protocol representing the NitroSse HybridObject.
|
|
56
|
+
* Implement this protocol to create Swift-based instances of NitroSse.
|
|
57
|
+
* ```swift
|
|
58
|
+
* class HybridNitroSse : HybridNitroSseSpec {
|
|
59
|
+
* // ...
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
public typealias HybridNitroSseSpec = HybridNitroSseSpec_protocol & HybridNitroSseSpec_base
|