react-native-zeroconf 0.17.2 → 1.0.0-rc.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/NOTICE +2 -6
- package/README.md +1 -1
- package/android/CMakeLists.txt +64 -0
- package/android/build.gradle +1 -13
- package/android/generated/java/com/balthazargronon/RCTZeroconf/NativeZeroconfSpec.java +96 -0
- package/android/generated/jni/CMakeLists.txt +28 -0
- package/android/generated/jni/RNZeroconfSpec-generated.cpp +77 -0
- package/android/generated/jni/RNZeroconfSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNZeroconfSpec/RNZeroconfSpecJSI.h +798 -0
- package/android/src/main/java/com/balthazargronon/RCTZeroconf/{ZeroconfModule.java → NsdHost.java} +97 -140
- package/android/src/main/java/com/balthazargronon/RCTZeroconf/NsdPayload.java +87 -0
- package/android/src/main/java/com/balthazargronon/RCTZeroconf/NsdPromise.java +40 -0
- package/android/src/main/java/com/balthazargronon/RCTZeroconf/Zeroconf.java +4 -6
- package/android/src/main/java/com/balthazargronon/RCTZeroconf/ZeroconfNativeSupport.java +60 -0
- package/android/src/main/java/com/balthazargronon/RCTZeroconf/ZeroconfOptions.java +15 -26
- package/android/src/main/java/com/balthazargronon/RCTZeroconf/ZeroconfReactPackage.java +5 -15
- package/android/src/main/java/com/balthazargronon/RCTZeroconf/nsd/NsdServiceImpl.java +90 -96
- package/android/src/main/jni/mdnsresponder/mDNSPosix/PosixDaemon.c +19 -1
- package/android/src/main/jni/mdnsresponder/mDNSPosix/mDNSPosix.c +104 -1
- package/android/src/main/jni/mdnsresponder/mDNSPosix/mDNSPosix.h +7 -0
- package/android/src/main/jni/mdnsresponder/mDNSShared/dnssd_clientshim.c +34 -9
- package/cpp/Backend.cpp +16 -0
- package/cpp/Backend.h +116 -0
- package/cpp/ZeroconfModule.cpp +280 -0
- package/cpp/ZeroconfModule.h +144 -0
- package/cpp/android/NsdBackend.cpp +462 -0
- package/cpp/android/NsdBackend.h +61 -0
- package/cpp/android/ZeroconfAndroidModule.cpp +49 -0
- package/cpp/android/ZeroconfAndroidModule.h +15 -0
- package/cpp/apple/DispatchExecutor.cpp +66 -0
- package/cpp/apple/DispatchExecutor.h +37 -0
- package/cpp/apple/LocalNetworkAccess.h +19 -0
- package/cpp/apple/LocalNetworkAccess.mm +87 -0
- package/cpp/dnssd/DnssdBackend.cpp +976 -0
- package/cpp/dnssd/DnssdBackend.h +114 -0
- package/cpp/dnssd/Executor.h +28 -0
- package/cpp/embedded/EmbeddedExecutor.cpp +124 -0
- package/cpp/embedded/EmbeddedExecutor.h +57 -0
- package/ios/ZeroconfOnLoad.mm +34 -0
- package/ios/generated/ReactCodegen/RNZeroconfSpec/RNZeroconfSpec-generated.mm +140 -0
- package/ios/generated/ReactCodegen/RNZeroconfSpec/RNZeroconfSpec.h +189 -0
- package/ios/generated/ReactCodegen/RNZeroconfSpecJSI.h +798 -0
- package/lib/module/NativeZeroconf.js +15 -0
- package/lib/module/NativeZeroconf.js.map +1 -0
- package/lib/module/bridge.js +124 -0
- package/lib/module/bridge.js.map +1 -0
- package/{dist → lib/module}/index.js +149 -149
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +24 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeZeroconf.d.ts +75 -0
- package/lib/typescript/src/NativeZeroconf.d.ts.map +1 -0
- package/lib/typescript/src/bridge.d.ts +22 -0
- package/lib/typescript/src/bridge.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +111 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +175 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +65 -29
- package/react-native-zeroconf.podspec +2 -1
- package/react-native.config.js +17 -0
- package/src/NativeZeroconf.ts +120 -0
- package/src/bridge.ts +153 -0
- package/src/index.ts +607 -0
- package/{index.d.ts → src/types.ts} +5 -99
- package/windows/RNZeroconf/RNZeroconf.vcxproj +17 -2
- package/windows/RNZeroconf/RNZeroconf.vcxproj.filters +0 -6
- package/windows/RNZeroconf/ReactPackageProvider.cpp +23 -20
- package/windows/RNZeroconf/WindowsBackend.cpp +156 -0
- package/windows/RNZeroconf/WindowsBackend.h +13 -0
- package/windows/RNZeroconf/ZeroconfCore.cpp +2 -2
- package/windows/RNZeroconf/ZeroconfCore.h +2 -2
- package/windows/RNZeroconf/ZeroconfWindowsModule.cpp +22 -0
- package/windows/RNZeroconf/ZeroconfWindowsModule.h +14 -0
- package/android/src/main/java/com/balthazargronon/RCTZeroconf/ZeroConfImplFactory.java +0 -56
- package/android/src/main/java/com/balthazargronon/RCTZeroconf/dnssd/DnssdImpl.java +0 -654
- package/android/src/main/java/com/github/druk/dnssd/BaseListener.java +0 -33
- package/android/src/main/java/com/github/druk/dnssd/BrowseListener.java +0 -67
- package/android/src/main/java/com/github/druk/dnssd/DNSRecord.java +0 -47
- package/android/src/main/java/com/github/druk/dnssd/DNSSD.java +0 -650
- package/android/src/main/java/com/github/druk/dnssd/DNSSDEmbedded.java +0 -135
- package/android/src/main/java/com/github/druk/dnssd/DNSSDException.java +0 -66
- package/android/src/main/java/com/github/druk/dnssd/DNSSDRecordRegistrar.java +0 -55
- package/android/src/main/java/com/github/druk/dnssd/DNSSDRegistration.java +0 -54
- package/android/src/main/java/com/github/druk/dnssd/DNSSDService.java +0 -35
- package/android/src/main/java/com/github/druk/dnssd/DomainListener.java +0 -57
- package/android/src/main/java/com/github/druk/dnssd/InternalBrowseListener.java +0 -76
- package/android/src/main/java/com/github/druk/dnssd/InternalDNSSD.java +0 -870
- package/android/src/main/java/com/github/druk/dnssd/InternalDNSSDRecordRegistrar.java +0 -30
- package/android/src/main/java/com/github/druk/dnssd/InternalDNSSDRegistration.java +0 -34
- package/android/src/main/java/com/github/druk/dnssd/InternalDNSSDService.java +0 -29
- package/android/src/main/java/com/github/druk/dnssd/InternalDomainListener.java +0 -62
- package/android/src/main/java/com/github/druk/dnssd/InternalQueryListener.java +0 -61
- package/android/src/main/java/com/github/druk/dnssd/InternalRegisterListener.java +0 -51
- package/android/src/main/java/com/github/druk/dnssd/InternalResolveListener.java +0 -58
- package/android/src/main/java/com/github/druk/dnssd/NSClass.java +0 -16
- package/android/src/main/java/com/github/druk/dnssd/NSType.java +0 -58
- package/android/src/main/java/com/github/druk/dnssd/QueryListener.java +0 -54
- package/android/src/main/java/com/github/druk/dnssd/RegisterListener.java +0 -46
- package/android/src/main/java/com/github/druk/dnssd/RegisterRecordListener.java +0 -35
- package/android/src/main/java/com/github/druk/dnssd/ResolveListener.java +0 -55
- package/android/src/main/java/com/github/druk/dnssd/TXTRecord.java +0 -293
- package/android/src/main/jni/Android.mk +0 -73
- package/android/src/main/jni/Application.mk +0 -3
- package/android/src/main/jni/DNSSD.java.h +0 -290
- package/android/src/main/jni/JNISupport.c +0 -1140
- package/ios/RNZeroconf/RNNetServiceSerializer.h +0 -31
- package/ios/RNZeroconf/RNNetServiceSerializer.m +0 -84
- package/ios/RNZeroconf/RNZeroconf.h +0 -17
- package/ios/RNZeroconf/RNZeroconf.m +0 -1025
- package/ios/RNZeroconf.xcodeproj/project.pbxproj +0 -261
- package/ios/RNZeroconf.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/src/index.js +0 -563
- package/windows/RNZeroconf/RNZeroconf.cpp +0 -228
- package/windows/RNZeroconf/RNZeroconf.h +0 -70
|
@@ -0,0 +1,798 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <ReactCommon/TurboModule.h>
|
|
13
|
+
#include <react/bridging/Bridging.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
#pragma mark - NativeZeroconfErrorEvent
|
|
19
|
+
|
|
20
|
+
template <typename P0, typename P1>
|
|
21
|
+
struct NativeZeroconfErrorEvent {
|
|
22
|
+
P0 scanId{};
|
|
23
|
+
P1 error;
|
|
24
|
+
bool operator==(const NativeZeroconfErrorEvent &other) const {
|
|
25
|
+
return scanId == other.scanId && error == other.error;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
template <typename T>
|
|
30
|
+
struct NativeZeroconfErrorEventBridging {
|
|
31
|
+
static T types;
|
|
32
|
+
|
|
33
|
+
static T fromJs(
|
|
34
|
+
jsi::Runtime &rt,
|
|
35
|
+
const jsi::Object &value,
|
|
36
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
37
|
+
T result{
|
|
38
|
+
bridging::fromJs<decltype(types.scanId)>(rt, value.getProperty(rt, "scanId"), jsInvoker),
|
|
39
|
+
bridging::fromJs<decltype(types.error)>(rt, value.getProperty(rt, "error"), jsInvoker)};
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#ifdef DEBUG
|
|
44
|
+
static jsi::String scanIdToJs(jsi::Runtime &rt, decltype(types.scanId) value) {
|
|
45
|
+
return bridging::toJs(rt, value);
|
|
46
|
+
}
|
|
47
|
+
static jsi::Object errorToJs(jsi::Runtime &rt, decltype(types.error) value) {
|
|
48
|
+
return bridging::toJs(rt, value);
|
|
49
|
+
}
|
|
50
|
+
#endif
|
|
51
|
+
|
|
52
|
+
static jsi::Object toJs(
|
|
53
|
+
jsi::Runtime &rt,
|
|
54
|
+
const T &value,
|
|
55
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
56
|
+
auto result = facebook::jsi::Object(rt);
|
|
57
|
+
result.setProperty(rt, "scanId", bridging::toJs(rt, value.scanId, jsInvoker));
|
|
58
|
+
result.setProperty(rt, "error", bridging::toJs(rt, value.error, jsInvoker));
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
#pragma mark - NativeZeroconfNameEvent
|
|
66
|
+
|
|
67
|
+
template <typename P0, typename P1>
|
|
68
|
+
struct NativeZeroconfNameEvent {
|
|
69
|
+
P0 scanId{};
|
|
70
|
+
P1 name;
|
|
71
|
+
bool operator==(const NativeZeroconfNameEvent &other) const {
|
|
72
|
+
return scanId == other.scanId && name == other.name;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
template <typename T>
|
|
77
|
+
struct NativeZeroconfNameEventBridging {
|
|
78
|
+
static T types;
|
|
79
|
+
|
|
80
|
+
static T fromJs(
|
|
81
|
+
jsi::Runtime &rt,
|
|
82
|
+
const jsi::Object &value,
|
|
83
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
84
|
+
T result{
|
|
85
|
+
bridging::fromJs<decltype(types.scanId)>(rt, value.getProperty(rt, "scanId"), jsInvoker),
|
|
86
|
+
bridging::fromJs<decltype(types.name)>(rt, value.getProperty(rt, "name"), jsInvoker)};
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
#ifdef DEBUG
|
|
91
|
+
static jsi::String scanIdToJs(jsi::Runtime &rt, decltype(types.scanId) value) {
|
|
92
|
+
return bridging::toJs(rt, value);
|
|
93
|
+
}
|
|
94
|
+
static jsi::String nameToJs(jsi::Runtime &rt, decltype(types.name) value) {
|
|
95
|
+
return bridging::toJs(rt, value);
|
|
96
|
+
}
|
|
97
|
+
#endif
|
|
98
|
+
|
|
99
|
+
static jsi::Object toJs(
|
|
100
|
+
jsi::Runtime &rt,
|
|
101
|
+
const T &value,
|
|
102
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
103
|
+
auto result = facebook::jsi::Object(rt);
|
|
104
|
+
result.setProperty(rt, "scanId", bridging::toJs(rt, value.scanId, jsInvoker));
|
|
105
|
+
result.setProperty(rt, "name", bridging::toJs(rt, value.name, jsInvoker));
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
#pragma mark - NativeZeroconfNativeAccessResult
|
|
113
|
+
|
|
114
|
+
template <typename P0, typename P1>
|
|
115
|
+
struct NativeZeroconfNativeAccessResult {
|
|
116
|
+
P0 status{};
|
|
117
|
+
P1 error;
|
|
118
|
+
bool operator==(const NativeZeroconfNativeAccessResult &other) const {
|
|
119
|
+
return status == other.status && error == other.error;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
template <typename T>
|
|
124
|
+
struct NativeZeroconfNativeAccessResultBridging {
|
|
125
|
+
static T types;
|
|
126
|
+
|
|
127
|
+
static T fromJs(
|
|
128
|
+
jsi::Runtime &rt,
|
|
129
|
+
const jsi::Object &value,
|
|
130
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
131
|
+
T result{
|
|
132
|
+
bridging::fromJs<decltype(types.status)>(rt, value.getProperty(rt, "status"), jsInvoker),
|
|
133
|
+
bridging::fromJs<decltype(types.error)>(rt, value.getProperty(rt, "error"), jsInvoker)};
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
#ifdef DEBUG
|
|
138
|
+
static jsi::String statusToJs(jsi::Runtime &rt, decltype(types.status) value) {
|
|
139
|
+
return bridging::toJs(rt, value);
|
|
140
|
+
}
|
|
141
|
+
static jsi::Object errorToJs(jsi::Runtime &rt, decltype(types.error) value) {
|
|
142
|
+
return bridging::toJs(rt, value);
|
|
143
|
+
}
|
|
144
|
+
#endif
|
|
145
|
+
|
|
146
|
+
static jsi::Object toJs(
|
|
147
|
+
jsi::Runtime &rt,
|
|
148
|
+
const T &value,
|
|
149
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
150
|
+
auto result = facebook::jsi::Object(rt);
|
|
151
|
+
if (value.status) {
|
|
152
|
+
result.setProperty(rt, "status", bridging::toJs(rt, value.status.value(), jsInvoker));
|
|
153
|
+
}
|
|
154
|
+
if (value.error) {
|
|
155
|
+
result.setProperty(rt, "error", bridging::toJs(rt, value.error.value(), jsInvoker));
|
|
156
|
+
}
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
#pragma mark - NativeZeroconfNativeError
|
|
164
|
+
|
|
165
|
+
template <typename P0, typename P1, typename P2, typename P3>
|
|
166
|
+
struct NativeZeroconfNativeError {
|
|
167
|
+
P0 message{};
|
|
168
|
+
P1 code{};
|
|
169
|
+
P2 domain{};
|
|
170
|
+
P3 serviceName;
|
|
171
|
+
bool operator==(const NativeZeroconfNativeError &other) const {
|
|
172
|
+
return message == other.message && code == other.code && domain == other.domain && serviceName == other.serviceName;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
template <typename T>
|
|
177
|
+
struct NativeZeroconfNativeErrorBridging {
|
|
178
|
+
static T types;
|
|
179
|
+
|
|
180
|
+
static T fromJs(
|
|
181
|
+
jsi::Runtime &rt,
|
|
182
|
+
const jsi::Object &value,
|
|
183
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
184
|
+
T result{
|
|
185
|
+
bridging::fromJs<decltype(types.message)>(rt, value.getProperty(rt, "message"), jsInvoker),
|
|
186
|
+
bridging::fromJs<decltype(types.code)>(rt, value.getProperty(rt, "code"), jsInvoker),
|
|
187
|
+
bridging::fromJs<decltype(types.domain)>(rt, value.getProperty(rt, "domain"), jsInvoker),
|
|
188
|
+
bridging::fromJs<decltype(types.serviceName)>(rt, value.getProperty(rt, "serviceName"), jsInvoker)};
|
|
189
|
+
return result;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
#ifdef DEBUG
|
|
193
|
+
static jsi::String messageToJs(jsi::Runtime &rt, decltype(types.message) value) {
|
|
194
|
+
return bridging::toJs(rt, value);
|
|
195
|
+
}
|
|
196
|
+
static jsi::String codeToJs(jsi::Runtime &rt, decltype(types.code) value) {
|
|
197
|
+
return bridging::toJs(rt, value);
|
|
198
|
+
}
|
|
199
|
+
static jsi::String domainToJs(jsi::Runtime &rt, decltype(types.domain) value) {
|
|
200
|
+
return bridging::toJs(rt, value);
|
|
201
|
+
}
|
|
202
|
+
static jsi::String serviceNameToJs(jsi::Runtime &rt, decltype(types.serviceName) value) {
|
|
203
|
+
return bridging::toJs(rt, value);
|
|
204
|
+
}
|
|
205
|
+
#endif
|
|
206
|
+
|
|
207
|
+
static jsi::Object toJs(
|
|
208
|
+
jsi::Runtime &rt,
|
|
209
|
+
const T &value,
|
|
210
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
211
|
+
auto result = facebook::jsi::Object(rt);
|
|
212
|
+
result.setProperty(rt, "message", bridging::toJs(rt, value.message, jsInvoker));
|
|
213
|
+
result.setProperty(rt, "code", bridging::toJs(rt, value.code, jsInvoker));
|
|
214
|
+
result.setProperty(rt, "domain", bridging::toJs(rt, value.domain, jsInvoker));
|
|
215
|
+
result.setProperty(rt, "serviceName", bridging::toJs(rt, value.serviceName, jsInvoker));
|
|
216
|
+
return result;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
#pragma mark - NativeZeroconfNativePublishOptions
|
|
223
|
+
|
|
224
|
+
template <typename P0, typename P1>
|
|
225
|
+
struct NativeZeroconfNativePublishOptions {
|
|
226
|
+
P0 subtypes{};
|
|
227
|
+
P1 networkInterface;
|
|
228
|
+
bool operator==(const NativeZeroconfNativePublishOptions &other) const {
|
|
229
|
+
return subtypes == other.subtypes && networkInterface == other.networkInterface;
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
template <typename T>
|
|
234
|
+
struct NativeZeroconfNativePublishOptionsBridging {
|
|
235
|
+
static T types;
|
|
236
|
+
|
|
237
|
+
static T fromJs(
|
|
238
|
+
jsi::Runtime &rt,
|
|
239
|
+
const jsi::Object &value,
|
|
240
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
241
|
+
T result{
|
|
242
|
+
bridging::fromJs<decltype(types.subtypes)>(rt, value.getProperty(rt, "subtypes"), jsInvoker),
|
|
243
|
+
bridging::fromJs<decltype(types.networkInterface)>(rt, value.getProperty(rt, "networkInterface"), jsInvoker)};
|
|
244
|
+
return result;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
#ifdef DEBUG
|
|
248
|
+
static jsi::Array subtypesToJs(jsi::Runtime &rt, decltype(types.subtypes) value) {
|
|
249
|
+
return bridging::toJs(rt, value);
|
|
250
|
+
}
|
|
251
|
+
static jsi::String networkInterfaceToJs(jsi::Runtime &rt, decltype(types.networkInterface) value) {
|
|
252
|
+
return bridging::toJs(rt, value);
|
|
253
|
+
}
|
|
254
|
+
#endif
|
|
255
|
+
|
|
256
|
+
static jsi::Object toJs(
|
|
257
|
+
jsi::Runtime &rt,
|
|
258
|
+
const T &value,
|
|
259
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
260
|
+
auto result = facebook::jsi::Object(rt);
|
|
261
|
+
if (value.subtypes) {
|
|
262
|
+
result.setProperty(rt, "subtypes", bridging::toJs(rt, value.subtypes.value(), jsInvoker));
|
|
263
|
+
}
|
|
264
|
+
if (value.networkInterface) {
|
|
265
|
+
result.setProperty(rt, "networkInterface", bridging::toJs(rt, value.networkInterface.value(), jsInvoker));
|
|
266
|
+
}
|
|
267
|
+
return result;
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
#pragma mark - NativeZeroconfNativeResolveOptions
|
|
274
|
+
|
|
275
|
+
template <typename P0, typename P1>
|
|
276
|
+
struct NativeZeroconfNativeResolveOptions {
|
|
277
|
+
P0 timeout{};
|
|
278
|
+
P1 networkInterface;
|
|
279
|
+
bool operator==(const NativeZeroconfNativeResolveOptions &other) const {
|
|
280
|
+
return timeout == other.timeout && networkInterface == other.networkInterface;
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
template <typename T>
|
|
285
|
+
struct NativeZeroconfNativeResolveOptionsBridging {
|
|
286
|
+
static T types;
|
|
287
|
+
|
|
288
|
+
static T fromJs(
|
|
289
|
+
jsi::Runtime &rt,
|
|
290
|
+
const jsi::Object &value,
|
|
291
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
292
|
+
T result{
|
|
293
|
+
bridging::fromJs<decltype(types.timeout)>(rt, value.getProperty(rt, "timeout"), jsInvoker),
|
|
294
|
+
bridging::fromJs<decltype(types.networkInterface)>(rt, value.getProperty(rt, "networkInterface"), jsInvoker)};
|
|
295
|
+
return result;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
#ifdef DEBUG
|
|
299
|
+
static double timeoutToJs(jsi::Runtime &rt, decltype(types.timeout) value) {
|
|
300
|
+
return bridging::toJs(rt, value);
|
|
301
|
+
}
|
|
302
|
+
static jsi::String networkInterfaceToJs(jsi::Runtime &rt, decltype(types.networkInterface) value) {
|
|
303
|
+
return bridging::toJs(rt, value);
|
|
304
|
+
}
|
|
305
|
+
#endif
|
|
306
|
+
|
|
307
|
+
static jsi::Object toJs(
|
|
308
|
+
jsi::Runtime &rt,
|
|
309
|
+
const T &value,
|
|
310
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
311
|
+
auto result = facebook::jsi::Object(rt);
|
|
312
|
+
if (value.timeout) {
|
|
313
|
+
result.setProperty(rt, "timeout", bridging::toJs(rt, value.timeout.value(), jsInvoker));
|
|
314
|
+
}
|
|
315
|
+
if (value.networkInterface) {
|
|
316
|
+
result.setProperty(rt, "networkInterface", bridging::toJs(rt, value.networkInterface.value(), jsInvoker));
|
|
317
|
+
}
|
|
318
|
+
return result;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
#pragma mark - NativeZeroconfNativeResult
|
|
325
|
+
|
|
326
|
+
template <typename P0, typename P1>
|
|
327
|
+
struct NativeZeroconfNativeResult {
|
|
328
|
+
P0 service{};
|
|
329
|
+
P1 error;
|
|
330
|
+
bool operator==(const NativeZeroconfNativeResult &other) const {
|
|
331
|
+
return service == other.service && error == other.error;
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
template <typename T>
|
|
336
|
+
struct NativeZeroconfNativeResultBridging {
|
|
337
|
+
static T types;
|
|
338
|
+
|
|
339
|
+
static T fromJs(
|
|
340
|
+
jsi::Runtime &rt,
|
|
341
|
+
const jsi::Object &value,
|
|
342
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
343
|
+
T result{
|
|
344
|
+
bridging::fromJs<decltype(types.service)>(rt, value.getProperty(rt, "service"), jsInvoker),
|
|
345
|
+
bridging::fromJs<decltype(types.error)>(rt, value.getProperty(rt, "error"), jsInvoker)};
|
|
346
|
+
return result;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
#ifdef DEBUG
|
|
350
|
+
static jsi::Object serviceToJs(jsi::Runtime &rt, decltype(types.service) value) {
|
|
351
|
+
return bridging::toJs(rt, value);
|
|
352
|
+
}
|
|
353
|
+
static jsi::Object errorToJs(jsi::Runtime &rt, decltype(types.error) value) {
|
|
354
|
+
return bridging::toJs(rt, value);
|
|
355
|
+
}
|
|
356
|
+
#endif
|
|
357
|
+
|
|
358
|
+
static jsi::Object toJs(
|
|
359
|
+
jsi::Runtime &rt,
|
|
360
|
+
const T &value,
|
|
361
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
362
|
+
auto result = facebook::jsi::Object(rt);
|
|
363
|
+
if (value.service) {
|
|
364
|
+
result.setProperty(rt, "service", bridging::toJs(rt, value.service.value(), jsInvoker));
|
|
365
|
+
}
|
|
366
|
+
if (value.error) {
|
|
367
|
+
result.setProperty(rt, "error", bridging::toJs(rt, value.error.value(), jsInvoker));
|
|
368
|
+
}
|
|
369
|
+
return result;
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
#pragma mark - NativeZeroconfNativeScanOptions
|
|
376
|
+
|
|
377
|
+
template <typename P0, typename P1, typename P2>
|
|
378
|
+
struct NativeZeroconfNativeScanOptions {
|
|
379
|
+
P0 resolveTimeout{};
|
|
380
|
+
P1 subtype{};
|
|
381
|
+
P2 networkInterface;
|
|
382
|
+
bool operator==(const NativeZeroconfNativeScanOptions &other) const {
|
|
383
|
+
return resolveTimeout == other.resolveTimeout && subtype == other.subtype && networkInterface == other.networkInterface;
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
template <typename T>
|
|
388
|
+
struct NativeZeroconfNativeScanOptionsBridging {
|
|
389
|
+
static T types;
|
|
390
|
+
|
|
391
|
+
static T fromJs(
|
|
392
|
+
jsi::Runtime &rt,
|
|
393
|
+
const jsi::Object &value,
|
|
394
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
395
|
+
T result{
|
|
396
|
+
bridging::fromJs<decltype(types.resolveTimeout)>(rt, value.getProperty(rt, "resolveTimeout"), jsInvoker),
|
|
397
|
+
bridging::fromJs<decltype(types.subtype)>(rt, value.getProperty(rt, "subtype"), jsInvoker),
|
|
398
|
+
bridging::fromJs<decltype(types.networkInterface)>(rt, value.getProperty(rt, "networkInterface"), jsInvoker)};
|
|
399
|
+
return result;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
#ifdef DEBUG
|
|
403
|
+
static double resolveTimeoutToJs(jsi::Runtime &rt, decltype(types.resolveTimeout) value) {
|
|
404
|
+
return bridging::toJs(rt, value);
|
|
405
|
+
}
|
|
406
|
+
static jsi::String subtypeToJs(jsi::Runtime &rt, decltype(types.subtype) value) {
|
|
407
|
+
return bridging::toJs(rt, value);
|
|
408
|
+
}
|
|
409
|
+
static jsi::String networkInterfaceToJs(jsi::Runtime &rt, decltype(types.networkInterface) value) {
|
|
410
|
+
return bridging::toJs(rt, value);
|
|
411
|
+
}
|
|
412
|
+
#endif
|
|
413
|
+
|
|
414
|
+
static jsi::Object toJs(
|
|
415
|
+
jsi::Runtime &rt,
|
|
416
|
+
const T &value,
|
|
417
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
418
|
+
auto result = facebook::jsi::Object(rt);
|
|
419
|
+
if (value.resolveTimeout) {
|
|
420
|
+
result.setProperty(rt, "resolveTimeout", bridging::toJs(rt, value.resolveTimeout.value(), jsInvoker));
|
|
421
|
+
}
|
|
422
|
+
if (value.subtype) {
|
|
423
|
+
result.setProperty(rt, "subtype", bridging::toJs(rt, value.subtype.value(), jsInvoker));
|
|
424
|
+
}
|
|
425
|
+
if (value.networkInterface) {
|
|
426
|
+
result.setProperty(rt, "networkInterface", bridging::toJs(rt, value.networkInterface.value(), jsInvoker));
|
|
427
|
+
}
|
|
428
|
+
return result;
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
#pragma mark - NativeZeroconfNativeService
|
|
435
|
+
|
|
436
|
+
template <typename P0, typename P1, typename P2, typename P3, typename P4, typename P5>
|
|
437
|
+
struct NativeZeroconfNativeService {
|
|
438
|
+
P0 name{};
|
|
439
|
+
P1 fullName{};
|
|
440
|
+
P2 host{};
|
|
441
|
+
P3 port{};
|
|
442
|
+
P4 addresses{};
|
|
443
|
+
P5 txt;
|
|
444
|
+
bool operator==(const NativeZeroconfNativeService &other) const {
|
|
445
|
+
return name == other.name && fullName == other.fullName && host == other.host && port == other.port && addresses == other.addresses && txt == other.txt;
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
template <typename T>
|
|
450
|
+
struct NativeZeroconfNativeServiceBridging {
|
|
451
|
+
static T types;
|
|
452
|
+
|
|
453
|
+
static T fromJs(
|
|
454
|
+
jsi::Runtime &rt,
|
|
455
|
+
const jsi::Object &value,
|
|
456
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
457
|
+
T result{
|
|
458
|
+
bridging::fromJs<decltype(types.name)>(rt, value.getProperty(rt, "name"), jsInvoker),
|
|
459
|
+
bridging::fromJs<decltype(types.fullName)>(rt, value.getProperty(rt, "fullName"), jsInvoker),
|
|
460
|
+
bridging::fromJs<decltype(types.host)>(rt, value.getProperty(rt, "host"), jsInvoker),
|
|
461
|
+
bridging::fromJs<decltype(types.port)>(rt, value.getProperty(rt, "port"), jsInvoker),
|
|
462
|
+
bridging::fromJs<decltype(types.addresses)>(rt, value.getProperty(rt, "addresses"), jsInvoker),
|
|
463
|
+
bridging::fromJs<decltype(types.txt)>(rt, value.getProperty(rt, "txt"), jsInvoker)};
|
|
464
|
+
return result;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
#ifdef DEBUG
|
|
468
|
+
static jsi::String nameToJs(jsi::Runtime &rt, decltype(types.name) value) {
|
|
469
|
+
return bridging::toJs(rt, value);
|
|
470
|
+
}
|
|
471
|
+
static jsi::String fullNameToJs(jsi::Runtime &rt, decltype(types.fullName) value) {
|
|
472
|
+
return bridging::toJs(rt, value);
|
|
473
|
+
}
|
|
474
|
+
static jsi::String hostToJs(jsi::Runtime &rt, decltype(types.host) value) {
|
|
475
|
+
return bridging::toJs(rt, value);
|
|
476
|
+
}
|
|
477
|
+
static double portToJs(jsi::Runtime &rt, decltype(types.port) value) {
|
|
478
|
+
return bridging::toJs(rt, value);
|
|
479
|
+
}
|
|
480
|
+
static jsi::Array addressesToJs(jsi::Runtime &rt, decltype(types.addresses) value) {
|
|
481
|
+
return bridging::toJs(rt, value);
|
|
482
|
+
}
|
|
483
|
+
static jsi::Array txtToJs(jsi::Runtime &rt, decltype(types.txt) value) {
|
|
484
|
+
return bridging::toJs(rt, value);
|
|
485
|
+
}
|
|
486
|
+
#endif
|
|
487
|
+
|
|
488
|
+
static jsi::Object toJs(
|
|
489
|
+
jsi::Runtime &rt,
|
|
490
|
+
const T &value,
|
|
491
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
492
|
+
auto result = facebook::jsi::Object(rt);
|
|
493
|
+
result.setProperty(rt, "name", bridging::toJs(rt, value.name, jsInvoker));
|
|
494
|
+
result.setProperty(rt, "fullName", bridging::toJs(rt, value.fullName, jsInvoker));
|
|
495
|
+
result.setProperty(rt, "host", bridging::toJs(rt, value.host, jsInvoker));
|
|
496
|
+
result.setProperty(rt, "port", bridging::toJs(rt, value.port, jsInvoker));
|
|
497
|
+
result.setProperty(rt, "addresses", bridging::toJs(rt, value.addresses, jsInvoker));
|
|
498
|
+
result.setProperty(rt, "txt", bridging::toJs(rt, value.txt, jsInvoker));
|
|
499
|
+
return result;
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
#pragma mark - NativeZeroconfResolvedEvent
|
|
506
|
+
|
|
507
|
+
template <typename P0, typename P1>
|
|
508
|
+
struct NativeZeroconfResolvedEvent {
|
|
509
|
+
P0 scanId{};
|
|
510
|
+
P1 service;
|
|
511
|
+
bool operator==(const NativeZeroconfResolvedEvent &other) const {
|
|
512
|
+
return scanId == other.scanId && service == other.service;
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
template <typename T>
|
|
517
|
+
struct NativeZeroconfResolvedEventBridging {
|
|
518
|
+
static T types;
|
|
519
|
+
|
|
520
|
+
static T fromJs(
|
|
521
|
+
jsi::Runtime &rt,
|
|
522
|
+
const jsi::Object &value,
|
|
523
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
524
|
+
T result{
|
|
525
|
+
bridging::fromJs<decltype(types.scanId)>(rt, value.getProperty(rt, "scanId"), jsInvoker),
|
|
526
|
+
bridging::fromJs<decltype(types.service)>(rt, value.getProperty(rt, "service"), jsInvoker)};
|
|
527
|
+
return result;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
#ifdef DEBUG
|
|
531
|
+
static jsi::String scanIdToJs(jsi::Runtime &rt, decltype(types.scanId) value) {
|
|
532
|
+
return bridging::toJs(rt, value);
|
|
533
|
+
}
|
|
534
|
+
static jsi::Object serviceToJs(jsi::Runtime &rt, decltype(types.service) value) {
|
|
535
|
+
return bridging::toJs(rt, value);
|
|
536
|
+
}
|
|
537
|
+
#endif
|
|
538
|
+
|
|
539
|
+
static jsi::Object toJs(
|
|
540
|
+
jsi::Runtime &rt,
|
|
541
|
+
const T &value,
|
|
542
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
543
|
+
auto result = facebook::jsi::Object(rt);
|
|
544
|
+
result.setProperty(rt, "scanId", bridging::toJs(rt, value.scanId, jsInvoker));
|
|
545
|
+
result.setProperty(rt, "service", bridging::toJs(rt, value.service, jsInvoker));
|
|
546
|
+
return result;
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
#pragma mark - NativeZeroconfScanEvent
|
|
553
|
+
|
|
554
|
+
template <typename P0>
|
|
555
|
+
struct NativeZeroconfScanEvent {
|
|
556
|
+
P0 scanId;
|
|
557
|
+
bool operator==(const NativeZeroconfScanEvent &other) const {
|
|
558
|
+
return scanId == other.scanId;
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
template <typename T>
|
|
563
|
+
struct NativeZeroconfScanEventBridging {
|
|
564
|
+
static T types;
|
|
565
|
+
|
|
566
|
+
static T fromJs(
|
|
567
|
+
jsi::Runtime &rt,
|
|
568
|
+
const jsi::Object &value,
|
|
569
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
570
|
+
T result{
|
|
571
|
+
bridging::fromJs<decltype(types.scanId)>(rt, value.getProperty(rt, "scanId"), jsInvoker)};
|
|
572
|
+
return result;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
#ifdef DEBUG
|
|
576
|
+
static jsi::String scanIdToJs(jsi::Runtime &rt, decltype(types.scanId) value) {
|
|
577
|
+
return bridging::toJs(rt, value);
|
|
578
|
+
}
|
|
579
|
+
#endif
|
|
580
|
+
|
|
581
|
+
static jsi::Object toJs(
|
|
582
|
+
jsi::Runtime &rt,
|
|
583
|
+
const T &value,
|
|
584
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
585
|
+
auto result = facebook::jsi::Object(rt);
|
|
586
|
+
result.setProperty(rt, "scanId", bridging::toJs(rt, value.scanId, jsInvoker));
|
|
587
|
+
return result;
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
#pragma mark - NativeZeroconfTxtEntry
|
|
594
|
+
|
|
595
|
+
template <typename P0, typename P1>
|
|
596
|
+
struct NativeZeroconfTxtEntry {
|
|
597
|
+
P0 key{};
|
|
598
|
+
P1 value;
|
|
599
|
+
bool operator==(const NativeZeroconfTxtEntry &other) const {
|
|
600
|
+
return key == other.key && value == other.value;
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
template <typename T>
|
|
605
|
+
struct NativeZeroconfTxtEntryBridging {
|
|
606
|
+
static T types;
|
|
607
|
+
|
|
608
|
+
static T fromJs(
|
|
609
|
+
jsi::Runtime &rt,
|
|
610
|
+
const jsi::Object &value,
|
|
611
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
612
|
+
T result{
|
|
613
|
+
bridging::fromJs<decltype(types.key)>(rt, value.getProperty(rt, "key"), jsInvoker),
|
|
614
|
+
bridging::fromJs<decltype(types.value)>(rt, value.getProperty(rt, "value"), jsInvoker)};
|
|
615
|
+
return result;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
#ifdef DEBUG
|
|
619
|
+
static jsi::String keyToJs(jsi::Runtime &rt, decltype(types.key) value) {
|
|
620
|
+
return bridging::toJs(rt, value);
|
|
621
|
+
}
|
|
622
|
+
static jsi::String valueToJs(jsi::Runtime &rt, decltype(types.value) value) {
|
|
623
|
+
return bridging::toJs(rt, value);
|
|
624
|
+
}
|
|
625
|
+
#endif
|
|
626
|
+
|
|
627
|
+
static jsi::Object toJs(
|
|
628
|
+
jsi::Runtime &rt,
|
|
629
|
+
const T &value,
|
|
630
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
631
|
+
auto result = facebook::jsi::Object(rt);
|
|
632
|
+
result.setProperty(rt, "key", bridging::toJs(rt, value.key, jsInvoker));
|
|
633
|
+
result.setProperty(rt, "value", bridging::toJs(rt, value.value, jsInvoker));
|
|
634
|
+
return result;
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
template <typename T>
|
|
640
|
+
class JSI_EXPORT NativeZeroconfCxxSpec : public TurboModule {
|
|
641
|
+
public:
|
|
642
|
+
static constexpr std::string_view kModuleName = "Zeroconf";
|
|
643
|
+
|
|
644
|
+
protected:
|
|
645
|
+
NativeZeroconfCxxSpec(std::shared_ptr<CallInvoker> jsInvoker) : TurboModule(std::string{NativeZeroconfCxxSpec::kModuleName}, jsInvoker) {
|
|
646
|
+
methodMap_["scan"] = MethodMetadata {.argCount = 6, .invoker = __scan};
|
|
647
|
+
methodMap_["stop"] = MethodMetadata {.argCount = 2, .invoker = __stop};
|
|
648
|
+
methodMap_["registerService"] = MethodMetadata {.argCount = 8, .invoker = __registerService};
|
|
649
|
+
methodMap_["updateService"] = MethodMetadata {.argCount = 3, .invoker = __updateService};
|
|
650
|
+
methodMap_["unregisterService"] = MethodMetadata {.argCount = 2, .invoker = __unregisterService};
|
|
651
|
+
methodMap_["resolveService"] = MethodMetadata {.argCount = 6, .invoker = __resolveService};
|
|
652
|
+
methodMap_["checkLocalNetworkAccess"] = MethodMetadata {.argCount = 2, .invoker = __checkLocalNetworkAccess};
|
|
653
|
+
eventEmitterMap_["onStart"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
654
|
+
eventEmitterMap_["onStop"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
655
|
+
eventEmitterMap_["onFound"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
656
|
+
eventEmitterMap_["onRemove"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
657
|
+
eventEmitterMap_["onResolved"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
658
|
+
eventEmitterMap_["onError"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
659
|
+
eventEmitterMap_["onPublished"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
660
|
+
eventEmitterMap_["onUnpublished"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
template <typename OnStartType> void emitOnStart(OnStartType value) {
|
|
664
|
+
static_assert(bridging::supportsFromJs<OnStartType, jsi::Object>, "value cannnot be converted to jsi::Object");
|
|
665
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*eventEmitterMap_["onStart"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
666
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
template <typename OnStopType> void emitOnStop(OnStopType value) {
|
|
671
|
+
static_assert(bridging::supportsFromJs<OnStopType, jsi::Object>, "value cannnot be converted to jsi::Object");
|
|
672
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*eventEmitterMap_["onStop"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
673
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
template <typename OnFoundType> void emitOnFound(OnFoundType value) {
|
|
678
|
+
static_assert(bridging::supportsFromJs<OnFoundType, jsi::Object>, "value cannnot be converted to jsi::Object");
|
|
679
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*eventEmitterMap_["onFound"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
680
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
template <typename OnRemoveType> void emitOnRemove(OnRemoveType value) {
|
|
685
|
+
static_assert(bridging::supportsFromJs<OnRemoveType, jsi::Object>, "value cannnot be converted to jsi::Object");
|
|
686
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*eventEmitterMap_["onRemove"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
687
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
template <typename OnResolvedType> void emitOnResolved(OnResolvedType value) {
|
|
692
|
+
static_assert(bridging::supportsFromJs<OnResolvedType, jsi::Object>, "value cannnot be converted to jsi::Object");
|
|
693
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*eventEmitterMap_["onResolved"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
694
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
template <typename OnErrorType> void emitOnError(OnErrorType value) {
|
|
699
|
+
static_assert(bridging::supportsFromJs<OnErrorType, jsi::Object>, "value cannnot be converted to jsi::Object");
|
|
700
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*eventEmitterMap_["onError"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
701
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
template <typename OnPublishedType> void emitOnPublished(OnPublishedType value) {
|
|
706
|
+
static_assert(bridging::supportsFromJs<OnPublishedType, jsi::Object>, "value cannnot be converted to jsi::Object");
|
|
707
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*eventEmitterMap_["onPublished"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
708
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
template <typename OnUnpublishedType> void emitOnUnpublished(OnUnpublishedType value) {
|
|
713
|
+
static_assert(bridging::supportsFromJs<OnUnpublishedType, jsi::Object>, "value cannnot be converted to jsi::Object");
|
|
714
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*eventEmitterMap_["onUnpublished"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
715
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
private:
|
|
719
|
+
static jsi::Value __scan(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
720
|
+
static_assert(
|
|
721
|
+
bridging::getParameterCount(&T::scan) == 7,
|
|
722
|
+
"Expected scan(...) to have 7 parameters");
|
|
723
|
+
bridging::callFromJs<void>(rt, &T::scan, static_cast<NativeZeroconfCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule),
|
|
724
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
725
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt),
|
|
726
|
+
count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asString(rt),
|
|
727
|
+
count <= 3 ? throw jsi::JSError(rt, "Expected argument in position 3 to be passed") : args[3].asString(rt),
|
|
728
|
+
count <= 4 ? throw jsi::JSError(rt, "Expected argument in position 4 to be passed") : args[4].asString(rt),
|
|
729
|
+
count <= 5 ? throw jsi::JSError(rt, "Expected argument in position 5 to be passed") : args[5].asObject(rt));return jsi::Value::undefined();
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
static jsi::Value __stop(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
733
|
+
static_assert(
|
|
734
|
+
bridging::getParameterCount(&T::stop) == 3,
|
|
735
|
+
"Expected stop(...) to have 3 parameters");
|
|
736
|
+
bridging::callFromJs<void>(rt, &T::stop, static_cast<NativeZeroconfCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule),
|
|
737
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
738
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt));return jsi::Value::undefined();
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
static jsi::Value __registerService(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
742
|
+
static_assert(
|
|
743
|
+
bridging::getParameterCount(&T::registerService) == 9,
|
|
744
|
+
"Expected registerService(...) to have 9 parameters");
|
|
745
|
+
return bridging::callFromJs<jsi::Value>(rt, &T::registerService, static_cast<NativeZeroconfCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule),
|
|
746
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
747
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt),
|
|
748
|
+
count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asString(rt),
|
|
749
|
+
count <= 3 ? throw jsi::JSError(rt, "Expected argument in position 3 to be passed") : args[3].asString(rt),
|
|
750
|
+
count <= 4 ? throw jsi::JSError(rt, "Expected argument in position 4 to be passed") : args[4].asNumber(),
|
|
751
|
+
count <= 5 ? throw jsi::JSError(rt, "Expected argument in position 5 to be passed") : args[5].asObject(rt).asArray(rt),
|
|
752
|
+
count <= 6 ? throw jsi::JSError(rt, "Expected argument in position 6 to be passed") : args[6].asString(rt),
|
|
753
|
+
count <= 7 ? throw jsi::JSError(rt, "Expected argument in position 7 to be passed") : args[7].asObject(rt));
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
static jsi::Value __updateService(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
757
|
+
static_assert(
|
|
758
|
+
bridging::getParameterCount(&T::updateService) == 4,
|
|
759
|
+
"Expected updateService(...) to have 4 parameters");
|
|
760
|
+
return bridging::callFromJs<jsi::Value>(rt, &T::updateService, static_cast<NativeZeroconfCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule),
|
|
761
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
762
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asObject(rt).asArray(rt),
|
|
763
|
+
count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asString(rt));
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
static jsi::Value __unregisterService(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
767
|
+
static_assert(
|
|
768
|
+
bridging::getParameterCount(&T::unregisterService) == 3,
|
|
769
|
+
"Expected unregisterService(...) to have 3 parameters");
|
|
770
|
+
return bridging::callFromJs<jsi::Value>(rt, &T::unregisterService, static_cast<NativeZeroconfCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule),
|
|
771
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
772
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt));
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
static jsi::Value __resolveService(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
776
|
+
static_assert(
|
|
777
|
+
bridging::getParameterCount(&T::resolveService) == 7,
|
|
778
|
+
"Expected resolveService(...) to have 7 parameters");
|
|
779
|
+
return bridging::callFromJs<jsi::Value>(rt, &T::resolveService, static_cast<NativeZeroconfCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule),
|
|
780
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
781
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt),
|
|
782
|
+
count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asString(rt),
|
|
783
|
+
count <= 3 ? throw jsi::JSError(rt, "Expected argument in position 3 to be passed") : args[3].asString(rt),
|
|
784
|
+
count <= 4 ? throw jsi::JSError(rt, "Expected argument in position 4 to be passed") : args[4].asString(rt),
|
|
785
|
+
count <= 5 ? throw jsi::JSError(rt, "Expected argument in position 5 to be passed") : args[5].asObject(rt));
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
static jsi::Value __checkLocalNetworkAccess(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
789
|
+
static_assert(
|
|
790
|
+
bridging::getParameterCount(&T::checkLocalNetworkAccess) == 3,
|
|
791
|
+
"Expected checkLocalNetworkAccess(...) to have 3 parameters");
|
|
792
|
+
return bridging::callFromJs<jsi::Value>(rt, &T::checkLocalNetworkAccess, static_cast<NativeZeroconfCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule),
|
|
793
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
794
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asNumber());
|
|
795
|
+
}
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
} // namespace facebook::react
|