react-native-zeroconf 0.17.4 → 0.17.5

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.
@@ -12,8 +12,19 @@
12
12
  #import <dns_sd.h>
13
13
  #import <net/if.h>
14
14
 
15
- // dns_sd callbacks are delivered on the main queue, and refs must be deallocated on it
16
- #define RNZ_QUEUE dispatch_get_main_queue()
15
+ // Creating a dns_sd ref is a synchronous round trip to mDNSResponder, so everything runs on a private
16
+ // serial queue instead of the main one. Callbacks are delivered on it, and refs must be deallocated on it.
17
+ static dispatch_queue_t RNZQueue(void)
18
+ {
19
+ static dispatch_queue_t queue;
20
+ static dispatch_once_t once;
21
+ dispatch_once(&once, ^{
22
+ queue = dispatch_queue_create("com.balthazargronon.rnzeroconf", DISPATCH_QUEUE_SERIAL);
23
+ });
24
+ return queue;
25
+ }
26
+
27
+ #define RNZ_QUEUE RNZQueue()
17
28
 
18
29
  #pragma mark - State
19
30
 
@@ -166,7 +177,7 @@ RCT_EXPORT_MODULE()
166
177
 
167
178
  + (BOOL)requiresMainQueueSetup
168
179
  {
169
- return YES;
180
+ return NO;
170
181
  }
171
182
 
172
183
  - (instancetype) init
@@ -0,0 +1,140 @@
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: GenerateModuleObjCpp
8
+ *
9
+ * We create an umbrella header (and corresponding implementation) here since
10
+ * Cxx compilation in BUCK has a limitation: source-code producing genrule()s
11
+ * must have a single output. More files => more genrule()s => slower builds.
12
+ */
13
+
14
+ #import "RNZeroconfSpec.h"
15
+
16
+
17
+ @implementation NativeZeroconfSpecBase
18
+ - (void)emitOnStart:(NSDictionary *)value
19
+ {
20
+ _eventEmitterCallback("onStart", value);
21
+ }
22
+ - (void)emitOnStop:(NSDictionary *)value
23
+ {
24
+ _eventEmitterCallback("onStop", value);
25
+ }
26
+ - (void)emitOnFound:(NSDictionary *)value
27
+ {
28
+ _eventEmitterCallback("onFound", value);
29
+ }
30
+ - (void)emitOnRemove:(NSDictionary *)value
31
+ {
32
+ _eventEmitterCallback("onRemove", value);
33
+ }
34
+ - (void)emitOnResolved:(NSDictionary *)value
35
+ {
36
+ _eventEmitterCallback("onResolved", value);
37
+ }
38
+ - (void)emitOnError:(NSDictionary *)value
39
+ {
40
+ _eventEmitterCallback("onError", value);
41
+ }
42
+ - (void)emitOnPublished:(NSDictionary *)value
43
+ {
44
+ _eventEmitterCallback("onPublished", value);
45
+ }
46
+ - (void)emitOnUnpublished:(NSDictionary *)value
47
+ {
48
+ _eventEmitterCallback("onUnpublished", value);
49
+ }
50
+
51
+ - (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper
52
+ {
53
+ _eventEmitterCallback = std::move(eventEmitterCallbackWrapper->_eventEmitterCallback);
54
+ }
55
+ @end
56
+
57
+ @implementation RCTCxxConvert (NativeZeroconf_NativeScanOptions)
58
+ + (RCTManagedPointer *)JS_NativeZeroconf_NativeScanOptions:(id)json
59
+ {
60
+ return facebook::react::managedPointer<JS::NativeZeroconf::NativeScanOptions>(json);
61
+ }
62
+ @end
63
+ @implementation RCTCxxConvert (NativeZeroconf_NativePublishOptions)
64
+ + (RCTManagedPointer *)JS_NativeZeroconf_NativePublishOptions:(id)json
65
+ {
66
+ return facebook::react::managedPointer<JS::NativeZeroconf::NativePublishOptions>(json);
67
+ }
68
+ @end
69
+ @implementation RCTCxxConvert (NativeZeroconf_NativeResolveOptions)
70
+ + (RCTManagedPointer *)JS_NativeZeroconf_NativeResolveOptions:(id)json
71
+ {
72
+ return facebook::react::managedPointer<JS::NativeZeroconf::NativeResolveOptions>(json);
73
+ }
74
+ @end
75
+ namespace facebook::react {
76
+
77
+ static facebook::jsi::Value __hostFunction_NativeZeroconfSpecJSI_scan(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
78
+ return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "scan", @selector(scan:type:protocol:domain:implType:options:), args, count);
79
+ }
80
+
81
+ static facebook::jsi::Value __hostFunction_NativeZeroconfSpecJSI_stop(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
82
+ return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "stop", @selector(stop:implType:), args, count);
83
+ }
84
+
85
+ static facebook::jsi::Value __hostFunction_NativeZeroconfSpecJSI_registerService(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
86
+ return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "registerService", @selector(registerService:protocol:domain:name:port:txt:implType:options:resolve:reject:), args, count);
87
+ }
88
+
89
+ static facebook::jsi::Value __hostFunction_NativeZeroconfSpecJSI_updateService(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
90
+ return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "updateService", @selector(updateService:txt:implType:resolve:reject:), args, count);
91
+ }
92
+
93
+ static facebook::jsi::Value __hostFunction_NativeZeroconfSpecJSI_unregisterService(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
94
+ return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "unregisterService", @selector(unregisterService:implType:resolve:reject:), args, count);
95
+ }
96
+
97
+ static facebook::jsi::Value __hostFunction_NativeZeroconfSpecJSI_resolveService(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
98
+ return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "resolveService", @selector(resolveService:type:protocol:domain:implType:options:resolve:reject:), args, count);
99
+ }
100
+
101
+ static facebook::jsi::Value __hostFunction_NativeZeroconfSpecJSI_checkLocalNetworkAccess(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
102
+ return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "checkLocalNetworkAccess", @selector(checkLocalNetworkAccess:timeout:resolve:reject:), args, count);
103
+ }
104
+
105
+ NativeZeroconfSpecJSI::NativeZeroconfSpecJSI(const ObjCTurboModule::InitParams &params)
106
+ : ObjCTurboModule(params) {
107
+
108
+ methodMap_["scan"] = MethodMetadata {6, __hostFunction_NativeZeroconfSpecJSI_scan};
109
+ setMethodArgConversionSelector(@"scan", 5, @"JS_NativeZeroconf_NativeScanOptions:");
110
+
111
+ methodMap_["stop"] = MethodMetadata {2, __hostFunction_NativeZeroconfSpecJSI_stop};
112
+
113
+
114
+ methodMap_["registerService"] = MethodMetadata {8, __hostFunction_NativeZeroconfSpecJSI_registerService};
115
+ setMethodArgConversionSelector(@"registerService", 7, @"JS_NativeZeroconf_NativePublishOptions:");
116
+
117
+ methodMap_["updateService"] = MethodMetadata {3, __hostFunction_NativeZeroconfSpecJSI_updateService};
118
+
119
+
120
+ methodMap_["unregisterService"] = MethodMetadata {2, __hostFunction_NativeZeroconfSpecJSI_unregisterService};
121
+
122
+
123
+ methodMap_["resolveService"] = MethodMetadata {6, __hostFunction_NativeZeroconfSpecJSI_resolveService};
124
+ setMethodArgConversionSelector(@"resolveService", 5, @"JS_NativeZeroconf_NativeResolveOptions:");
125
+
126
+ methodMap_["checkLocalNetworkAccess"] = MethodMetadata {2, __hostFunction_NativeZeroconfSpecJSI_checkLocalNetworkAccess};
127
+
128
+ eventEmitterMap_["onStart"] = std::make_shared<AsyncEventEmitter<id>>();
129
+ eventEmitterMap_["onStop"] = std::make_shared<AsyncEventEmitter<id>>();
130
+ eventEmitterMap_["onFound"] = std::make_shared<AsyncEventEmitter<id>>();
131
+ eventEmitterMap_["onRemove"] = std::make_shared<AsyncEventEmitter<id>>();
132
+ eventEmitterMap_["onResolved"] = std::make_shared<AsyncEventEmitter<id>>();
133
+ eventEmitterMap_["onError"] = std::make_shared<AsyncEventEmitter<id>>();
134
+ eventEmitterMap_["onPublished"] = std::make_shared<AsyncEventEmitter<id>>();
135
+ eventEmitterMap_["onUnpublished"] = std::make_shared<AsyncEventEmitter<id>>();
136
+ setEventEmitterCallback([&](const std::string &name, id value) {
137
+ static_cast<AsyncEventEmitter<id> &>(*eventEmitterMap_[name]).emit(value);
138
+ });
139
+ }
140
+ } // namespace facebook::react
@@ -0,0 +1,189 @@
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: GenerateModuleObjCpp
8
+ *
9
+ * We create an umbrella header (and corresponding implementation) here since
10
+ * Cxx compilation in BUCK has a limitation: source-code producing genrule()s
11
+ * must have a single output. More files => more genrule()s => slower builds.
12
+ */
13
+
14
+ #ifndef __cplusplus
15
+ #error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
16
+ #endif
17
+
18
+ // Avoid multiple includes of RNZeroconfSpec symbols
19
+ #ifndef RNZeroconfSpec_H
20
+ #define RNZeroconfSpec_H
21
+
22
+ #import <Foundation/Foundation.h>
23
+ #import <RCTRequired/RCTRequired.h>
24
+ #import <RCTTypeSafety/RCTConvertHelpers.h>
25
+ #import <RCTTypeSafety/RCTTypedModuleConstants.h>
26
+ #import <React/RCTBridgeModule.h>
27
+ #import <React/RCTCxxConvert.h>
28
+ #import <React/RCTManagedPointer.h>
29
+ #import <ReactCommon/RCTTurboModule.h>
30
+ #import <optional>
31
+ #import <vector>
32
+
33
+
34
+ NS_ASSUME_NONNULL_BEGIN
35
+ namespace JS {
36
+ namespace NativeZeroconf {
37
+ struct NativeScanOptions {
38
+ std::optional<double> resolveTimeout() const;
39
+ NSString *subtype() const;
40
+ NSString *networkInterface() const;
41
+
42
+ NativeScanOptions(NSDictionary *const v) : _v(v) {}
43
+ private:
44
+ NSDictionary *_v;
45
+ };
46
+ }
47
+ }
48
+
49
+ @interface RCTCxxConvert (NativeZeroconf_NativeScanOptions)
50
+ + (RCTManagedPointer *)JS_NativeZeroconf_NativeScanOptions:(id)json;
51
+ @end
52
+ namespace JS {
53
+ namespace NativeZeroconf {
54
+ struct NativePublishOptions {
55
+ std::optional<facebook::react::LazyVector<NSString *>> subtypes() const;
56
+ NSString *networkInterface() const;
57
+
58
+ NativePublishOptions(NSDictionary *const v) : _v(v) {}
59
+ private:
60
+ NSDictionary *_v;
61
+ };
62
+ }
63
+ }
64
+
65
+ @interface RCTCxxConvert (NativeZeroconf_NativePublishOptions)
66
+ + (RCTManagedPointer *)JS_NativeZeroconf_NativePublishOptions:(id)json;
67
+ @end
68
+ namespace JS {
69
+ namespace NativeZeroconf {
70
+ struct NativeResolveOptions {
71
+ std::optional<double> timeout() const;
72
+ NSString *networkInterface() const;
73
+
74
+ NativeResolveOptions(NSDictionary *const v) : _v(v) {}
75
+ private:
76
+ NSDictionary *_v;
77
+ };
78
+ }
79
+ }
80
+
81
+ @interface RCTCxxConvert (NativeZeroconf_NativeResolveOptions)
82
+ + (RCTManagedPointer *)JS_NativeZeroconf_NativeResolveOptions:(id)json;
83
+ @end
84
+ @protocol NativeZeroconfSpec <RCTBridgeModule, RCTTurboModule>
85
+
86
+ - (void)scan:(NSString *)scanId
87
+ type:(NSString *)type
88
+ protocol:(NSString *)protocol
89
+ domain:(NSString *)domain
90
+ implType:(NSString *)implType
91
+ options:(JS::NativeZeroconf::NativeScanOptions &)options;
92
+ - (void)stop:(NSString *)scanId
93
+ implType:(NSString *)implType;
94
+ - (void)registerService:(NSString *)type
95
+ protocol:(NSString *)protocol
96
+ domain:(NSString *)domain
97
+ name:(NSString *)name
98
+ port:(double)port
99
+ txt:(NSArray *)txt
100
+ implType:(NSString *)implType
101
+ options:(JS::NativeZeroconf::NativePublishOptions &)options
102
+ resolve:(RCTPromiseResolveBlock)resolve
103
+ reject:(RCTPromiseRejectBlock)reject;
104
+ - (void)updateService:(NSString *)name
105
+ txt:(NSArray *)txt
106
+ implType:(NSString *)implType
107
+ resolve:(RCTPromiseResolveBlock)resolve
108
+ reject:(RCTPromiseRejectBlock)reject;
109
+ - (void)unregisterService:(NSString *)name
110
+ implType:(NSString *)implType
111
+ resolve:(RCTPromiseResolveBlock)resolve
112
+ reject:(RCTPromiseRejectBlock)reject;
113
+ - (void)resolveService:(NSString *)name
114
+ type:(NSString *)type
115
+ protocol:(NSString *)protocol
116
+ domain:(NSString *)domain
117
+ implType:(NSString *)implType
118
+ options:(JS::NativeZeroconf::NativeResolveOptions &)options
119
+ resolve:(RCTPromiseResolveBlock)resolve
120
+ reject:(RCTPromiseRejectBlock)reject;
121
+ - (void)checkLocalNetworkAccess:(NSString *)type
122
+ timeout:(double)timeout
123
+ resolve:(RCTPromiseResolveBlock)resolve
124
+ reject:(RCTPromiseRejectBlock)reject;
125
+
126
+ @end
127
+
128
+ @interface NativeZeroconfSpecBase : NSObject {
129
+ @protected
130
+ facebook::react::EventEmitterCallback _eventEmitterCallback;
131
+ }
132
+ - (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper;
133
+
134
+ - (void)emitOnStart:(NSDictionary *)value;
135
+ - (void)emitOnStop:(NSDictionary *)value;
136
+ - (void)emitOnFound:(NSDictionary *)value;
137
+ - (void)emitOnRemove:(NSDictionary *)value;
138
+ - (void)emitOnResolved:(NSDictionary *)value;
139
+ - (void)emitOnError:(NSDictionary *)value;
140
+ - (void)emitOnPublished:(NSDictionary *)value;
141
+ - (void)emitOnUnpublished:(NSDictionary *)value;
142
+ @end
143
+
144
+ namespace facebook::react {
145
+ /**
146
+ * ObjC++ class for module 'NativeZeroconf'
147
+ */
148
+ class JSI_EXPORT NativeZeroconfSpecJSI : public ObjCTurboModule {
149
+ public:
150
+ NativeZeroconfSpecJSI(const ObjCTurboModule::InitParams &params);
151
+ };
152
+ } // namespace facebook::react
153
+ inline std::optional<double> JS::NativeZeroconf::NativeScanOptions::resolveTimeout() const
154
+ {
155
+ id const p = _v[@"resolveTimeout"];
156
+ return RCTBridgingToOptionalDouble(p);
157
+ }
158
+ inline NSString *JS::NativeZeroconf::NativeScanOptions::subtype() const
159
+ {
160
+ id const p = _v[@"subtype"];
161
+ return RCTBridgingToOptionalString(p);
162
+ }
163
+ inline NSString *JS::NativeZeroconf::NativeScanOptions::networkInterface() const
164
+ {
165
+ id const p = _v[@"networkInterface"];
166
+ return RCTBridgingToOptionalString(p);
167
+ }
168
+ inline std::optional<facebook::react::LazyVector<NSString *>> JS::NativeZeroconf::NativePublishOptions::subtypes() const
169
+ {
170
+ id const p = _v[@"subtypes"];
171
+ return RCTBridgingToOptionalVec(p, ^NSString *(id itemValue_0) { return RCTBridgingToString(itemValue_0); });
172
+ }
173
+ inline NSString *JS::NativeZeroconf::NativePublishOptions::networkInterface() const
174
+ {
175
+ id const p = _v[@"networkInterface"];
176
+ return RCTBridgingToOptionalString(p);
177
+ }
178
+ inline std::optional<double> JS::NativeZeroconf::NativeResolveOptions::timeout() const
179
+ {
180
+ id const p = _v[@"timeout"];
181
+ return RCTBridgingToOptionalDouble(p);
182
+ }
183
+ inline NSString *JS::NativeZeroconf::NativeResolveOptions::networkInterface() const
184
+ {
185
+ id const p = _v[@"networkInterface"];
186
+ return RCTBridgingToOptionalString(p);
187
+ }
188
+ NS_ASSUME_NONNULL_END
189
+ #endif // RNZeroconfSpec_H