@dawidzawada/bonjour-zeroconf 1.0.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.
Files changed (125) hide show
  1. package/BonjourZeroconf.podspec +30 -0
  2. package/LICENSE +20 -0
  3. package/README.md +35 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +128 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourZeroconf+AddressResolver.kt +182 -0
  10. package/android/src/main/java/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourZeroconf+Listeners.kt +45 -0
  11. package/android/src/main/java/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourZeroconf.kt +183 -0
  12. package/android/src/main/java/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourZeroconfPackage.kt +22 -0
  13. package/ios/AddressResolverError.swift +20 -0
  14. package/ios/BonjourZeroconf+AddressResolver.swift +133 -0
  15. package/ios/BonjourZeroconf+Listeners.swift +26 -0
  16. package/ios/BonjourZeroconf.swift +201 -0
  17. package/ios/LocalNetworkAuthorization.swift +66 -0
  18. package/ios/LocalNetworkPermission+Listeners.swift +14 -0
  19. package/ios/LocalNetworkPermission.swift +41 -0
  20. package/ios/ServiceCache.swift +30 -0
  21. package/ios/Utils/Loggy.swift +37 -0
  22. package/lib/module/index.js +9 -0
  23. package/lib/module/index.js.map +1 -0
  24. package/lib/module/package.json +1 -0
  25. package/lib/module/permissions.ios.js +23 -0
  26. package/lib/module/permissions.ios.js.map +1 -0
  27. package/lib/module/permissions.js +9 -0
  28. package/lib/module/permissions.js.map +1 -0
  29. package/lib/module/specs/BonjourFail.js +9 -0
  30. package/lib/module/specs/BonjourFail.js.map +1 -0
  31. package/lib/module/specs/BonjourListener.js +2 -0
  32. package/lib/module/specs/BonjourListener.js.map +1 -0
  33. package/lib/module/specs/BonjourZeroconf.nitro.js +4 -0
  34. package/lib/module/specs/BonjourZeroconf.nitro.js.map +1 -0
  35. package/lib/module/specs/LocalNetworkPermission.nitro.js +4 -0
  36. package/lib/module/specs/LocalNetworkPermission.nitro.js.map +1 -0
  37. package/lib/module/specs/ScanResult.js +2 -0
  38. package/lib/module/specs/ScanResult.js.map +1 -0
  39. package/lib/module/useIsScanning.js +19 -0
  40. package/lib/module/useIsScanning.js.map +1 -0
  41. package/lib/typescript/package.json +1 -0
  42. package/lib/typescript/src/index.d.ts +9 -0
  43. package/lib/typescript/src/index.d.ts.map +1 -0
  44. package/lib/typescript/src/permissions.d.ts +3 -0
  45. package/lib/typescript/src/permissions.d.ts.map +1 -0
  46. package/lib/typescript/src/permissions.ios.d.ts +3 -0
  47. package/lib/typescript/src/permissions.ios.d.ts.map +1 -0
  48. package/lib/typescript/src/specs/BonjourFail.d.ts +6 -0
  49. package/lib/typescript/src/specs/BonjourFail.d.ts.map +1 -0
  50. package/lib/typescript/src/specs/BonjourListener.d.ts +4 -0
  51. package/lib/typescript/src/specs/BonjourListener.d.ts.map +1 -0
  52. package/lib/typescript/src/specs/BonjourZeroconf.nitro.d.ts +19 -0
  53. package/lib/typescript/src/specs/BonjourZeroconf.nitro.d.ts.map +1 -0
  54. package/lib/typescript/src/specs/LocalNetworkPermission.nitro.d.ts +9 -0
  55. package/lib/typescript/src/specs/LocalNetworkPermission.nitro.d.ts.map +1 -0
  56. package/lib/typescript/src/specs/ScanResult.d.ts +8 -0
  57. package/lib/typescript/src/specs/ScanResult.d.ts.map +1 -0
  58. package/lib/typescript/src/useIsScanning.d.ts +2 -0
  59. package/lib/typescript/src/useIsScanning.d.ts.map +1 -0
  60. package/nitro.json +20 -0
  61. package/nitrogen/generated/android/c++/JBonjourFail.hpp +62 -0
  62. package/nitrogen/generated/android/c++/JBonjourListener.hpp +68 -0
  63. package/nitrogen/generated/android/c++/JFunc_void.hpp +74 -0
  64. package/nitrogen/generated/android/c++/JFunc_void_BonjourFail.hpp +76 -0
  65. package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +74 -0
  66. package/nitrogen/generated/android/c++/JFunc_void_std__vector_ScanResult_.hpp +97 -0
  67. package/nitrogen/generated/android/c++/JHybridBonjourZeroconfSpec.cpp +96 -0
  68. package/nitrogen/generated/android/c++/JHybridBonjourZeroconfSpec.hpp +69 -0
  69. package/nitrogen/generated/android/c++/JScanOptions.hpp +57 -0
  70. package/nitrogen/generated/android/c++/JScanResult.hpp +74 -0
  71. package/nitrogen/generated/android/dawidzawada_bonjourzeroconf+autolinking.cmake +82 -0
  72. package/nitrogen/generated/android/dawidzawada_bonjourzeroconf+autolinking.gradle +27 -0
  73. package/nitrogen/generated/android/dawidzawada_bonjourzeroconfOnLoad.cpp +52 -0
  74. package/nitrogen/generated/android/dawidzawada_bonjourzeroconfOnLoad.hpp +25 -0
  75. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourFail.kt +22 -0
  76. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourListener.kt +42 -0
  77. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void.kt +80 -0
  78. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_BonjourFail.kt +80 -0
  79. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_bool.kt +80 -0
  80. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_std__vector_ScanResult_.kt +80 -0
  81. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/HybridBonjourZeroconfSpec.kt +90 -0
  82. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/ScanOptions.kt +38 -0
  83. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/ScanResult.kt +50 -0
  84. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/dawidzawada_bonjourzeroconfOnLoad.kt +35 -0
  85. package/nitrogen/generated/ios/BonjourZeroconf+autolinking.rb +60 -0
  86. package/nitrogen/generated/ios/BonjourZeroconf-Swift-Cxx-Bridge.cpp +90 -0
  87. package/nitrogen/generated/ios/BonjourZeroconf-Swift-Cxx-Bridge.hpp +282 -0
  88. package/nitrogen/generated/ios/BonjourZeroconf-Swift-Cxx-Umbrella.hpp +65 -0
  89. package/nitrogen/generated/ios/BonjourZeroconfAutolinking.mm +41 -0
  90. package/nitrogen/generated/ios/BonjourZeroconfAutolinking.swift +40 -0
  91. package/nitrogen/generated/ios/c++/HybridBonjourZeroconfSpecSwift.cpp +11 -0
  92. package/nitrogen/generated/ios/c++/HybridBonjourZeroconfSpecSwift.hpp +120 -0
  93. package/nitrogen/generated/ios/c++/HybridLocalNetworkPermissionSpecSwift.cpp +11 -0
  94. package/nitrogen/generated/ios/c++/HybridLocalNetworkPermissionSpecSwift.hpp +87 -0
  95. package/nitrogen/generated/ios/swift/BonjourFail.swift +44 -0
  96. package/nitrogen/generated/ios/swift/BonjourListener.swift +47 -0
  97. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  98. package/nitrogen/generated/ios/swift/Func_void_BonjourFail.swift +47 -0
  99. package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
  100. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  101. package/nitrogen/generated/ios/swift/Func_void_std__vector_ScanResult_.swift +47 -0
  102. package/nitrogen/generated/ios/swift/HybridBonjourZeroconfSpec.swift +60 -0
  103. package/nitrogen/generated/ios/swift/HybridBonjourZeroconfSpec_cxx.swift +203 -0
  104. package/nitrogen/generated/ios/swift/HybridLocalNetworkPermissionSpec.swift +57 -0
  105. package/nitrogen/generated/ios/swift/HybridLocalNetworkPermissionSpec_cxx.swift +155 -0
  106. package/nitrogen/generated/ios/swift/ScanOptions.swift +48 -0
  107. package/nitrogen/generated/ios/swift/ScanResult.swift +149 -0
  108. package/nitrogen/generated/shared/c++/BonjourFail.hpp +63 -0
  109. package/nitrogen/generated/shared/c++/BonjourListener.hpp +75 -0
  110. package/nitrogen/generated/shared/c++/HybridBonjourZeroconfSpec.cpp +26 -0
  111. package/nitrogen/generated/shared/c++/HybridBonjourZeroconfSpec.hpp +80 -0
  112. package/nitrogen/generated/shared/c++/HybridLocalNetworkPermissionSpec.cpp +22 -0
  113. package/nitrogen/generated/shared/c++/HybridLocalNetworkPermissionSpec.hpp +66 -0
  114. package/nitrogen/generated/shared/c++/ScanOptions.hpp +75 -0
  115. package/nitrogen/generated/shared/c++/ScanResult.hpp +92 -0
  116. package/package.json +169 -0
  117. package/src/index.ts +22 -0
  118. package/src/permissions.ios.ts +27 -0
  119. package/src/permissions.ts +7 -0
  120. package/src/specs/BonjourFail.ts +5 -0
  121. package/src/specs/BonjourListener.ts +3 -0
  122. package/src/specs/BonjourZeroconf.nitro.ts +20 -0
  123. package/src/specs/LocalNetworkPermission.nitro.ts +7 -0
  124. package/src/specs/ScanResult.ts +7 -0
  125. package/src/useIsScanning.ts +17 -0
@@ -0,0 +1,282 @@
1
+ ///
2
+ /// BonjourZeroconf-Swift-Cxx-Bridge.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `BonjourFail` to properly resolve imports.
12
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf { enum class BonjourFail; }
13
+ // Forward declaration of `BonjourListener` to properly resolve imports.
14
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf { struct BonjourListener; }
15
+ // Forward declaration of `HybridBonjourZeroconfSpec` to properly resolve imports.
16
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf { class HybridBonjourZeroconfSpec; }
17
+ // Forward declaration of `HybridLocalNetworkPermissionSpec` to properly resolve imports.
18
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf { class HybridLocalNetworkPermissionSpec; }
19
+ // Forward declaration of `ScanOptions` to properly resolve imports.
20
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf { struct ScanOptions; }
21
+ // Forward declaration of `ScanResult` to properly resolve imports.
22
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf { struct ScanResult; }
23
+
24
+ // Forward declarations of Swift defined types
25
+ // Forward declaration of `HybridBonjourZeroconfSpec_cxx` to properly resolve imports.
26
+ namespace BonjourZeroconf { class HybridBonjourZeroconfSpec_cxx; }
27
+ // Forward declaration of `HybridLocalNetworkPermissionSpec_cxx` to properly resolve imports.
28
+ namespace BonjourZeroconf { class HybridLocalNetworkPermissionSpec_cxx; }
29
+
30
+ // Include C++ defined types
31
+ #include "BonjourFail.hpp"
32
+ #include "BonjourListener.hpp"
33
+ #include "HybridBonjourZeroconfSpec.hpp"
34
+ #include "HybridLocalNetworkPermissionSpec.hpp"
35
+ #include "ScanOptions.hpp"
36
+ #include "ScanResult.hpp"
37
+ #include <NitroModules/Promise.hpp>
38
+ #include <NitroModules/PromiseHolder.hpp>
39
+ #include <NitroModules/Result.hpp>
40
+ #include <exception>
41
+ #include <functional>
42
+ #include <memory>
43
+ #include <optional>
44
+ #include <string>
45
+ #include <vector>
46
+
47
+ /**
48
+ * Contains specialized versions of C++ templated types so they can be accessed from Swift,
49
+ * as well as helper functions to interact with those C++ types from Swift.
50
+ */
51
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf::bridge::swift {
52
+
53
+ // pragma MARK: std::optional<double>
54
+ /**
55
+ * Specialized version of `std::optional<double>`.
56
+ */
57
+ using std__optional_double_ = std::optional<double>;
58
+ inline std::optional<double> create_std__optional_double_(const double& value) noexcept {
59
+ return std::optional<double>(value);
60
+ }
61
+ inline bool has_value_std__optional_double_(const std::optional<double>& optional) noexcept {
62
+ return optional.has_value();
63
+ }
64
+ inline double get_std__optional_double_(const std::optional<double>& optional) noexcept {
65
+ return *optional;
66
+ }
67
+
68
+ // pragma MARK: std::optional<ScanOptions>
69
+ /**
70
+ * Specialized version of `std::optional<ScanOptions>`.
71
+ */
72
+ using std__optional_ScanOptions_ = std::optional<ScanOptions>;
73
+ inline std::optional<ScanOptions> create_std__optional_ScanOptions_(const ScanOptions& value) noexcept {
74
+ return std::optional<ScanOptions>(value);
75
+ }
76
+ inline bool has_value_std__optional_ScanOptions_(const std::optional<ScanOptions>& optional) noexcept {
77
+ return optional.has_value();
78
+ }
79
+ inline ScanOptions get_std__optional_ScanOptions_(const std::optional<ScanOptions>& optional) noexcept {
80
+ return *optional;
81
+ }
82
+
83
+ // pragma MARK: std::function<void()>
84
+ /**
85
+ * Specialized version of `std::function<void()>`.
86
+ */
87
+ using Func_void = std::function<void()>;
88
+ /**
89
+ * Wrapper class for a `std::function<void()>`, this can be used from Swift.
90
+ */
91
+ class Func_void_Wrapper final {
92
+ public:
93
+ explicit Func_void_Wrapper(std::function<void()>&& func): _function(std::make_unique<std::function<void()>>(std::move(func))) {}
94
+ inline void call() const noexcept {
95
+ _function->operator()();
96
+ }
97
+ private:
98
+ std::unique_ptr<std::function<void()>> _function;
99
+ } SWIFT_NONCOPYABLE;
100
+ Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept;
101
+ inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept {
102
+ return Func_void_Wrapper(std::move(value));
103
+ }
104
+
105
+ // pragma MARK: std::optional<std::string>
106
+ /**
107
+ * Specialized version of `std::optional<std::string>`.
108
+ */
109
+ using std__optional_std__string_ = std::optional<std::string>;
110
+ inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
111
+ return std::optional<std::string>(value);
112
+ }
113
+ inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
114
+ return optional.has_value();
115
+ }
116
+ inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
117
+ return *optional;
118
+ }
119
+
120
+ // pragma MARK: std::vector<ScanResult>
121
+ /**
122
+ * Specialized version of `std::vector<ScanResult>`.
123
+ */
124
+ using std__vector_ScanResult_ = std::vector<ScanResult>;
125
+ inline std::vector<ScanResult> create_std__vector_ScanResult_(size_t size) noexcept {
126
+ std::vector<ScanResult> vector;
127
+ vector.reserve(size);
128
+ return vector;
129
+ }
130
+
131
+ // pragma MARK: std::function<void(const std::vector<ScanResult>& /* results */)>
132
+ /**
133
+ * Specialized version of `std::function<void(const std::vector<ScanResult>&)>`.
134
+ */
135
+ using Func_void_std__vector_ScanResult_ = std::function<void(const std::vector<ScanResult>& /* results */)>;
136
+ /**
137
+ * Wrapper class for a `std::function<void(const std::vector<ScanResult>& / * results * /)>`, this can be used from Swift.
138
+ */
139
+ class Func_void_std__vector_ScanResult__Wrapper final {
140
+ public:
141
+ explicit Func_void_std__vector_ScanResult__Wrapper(std::function<void(const std::vector<ScanResult>& /* results */)>&& func): _function(std::make_unique<std::function<void(const std::vector<ScanResult>& /* results */)>>(std::move(func))) {}
142
+ inline void call(std::vector<ScanResult> results) const noexcept {
143
+ _function->operator()(results);
144
+ }
145
+ private:
146
+ std::unique_ptr<std::function<void(const std::vector<ScanResult>& /* results */)>> _function;
147
+ } SWIFT_NONCOPYABLE;
148
+ Func_void_std__vector_ScanResult_ create_Func_void_std__vector_ScanResult_(void* NON_NULL swiftClosureWrapper) noexcept;
149
+ inline Func_void_std__vector_ScanResult__Wrapper wrap_Func_void_std__vector_ScanResult_(Func_void_std__vector_ScanResult_ value) noexcept {
150
+ return Func_void_std__vector_ScanResult__Wrapper(std::move(value));
151
+ }
152
+
153
+ // pragma MARK: std::function<void(bool /* isScanning */)>
154
+ /**
155
+ * Specialized version of `std::function<void(bool)>`.
156
+ */
157
+ using Func_void_bool = std::function<void(bool /* isScanning */)>;
158
+ /**
159
+ * Wrapper class for a `std::function<void(bool / * isScanning * /)>`, this can be used from Swift.
160
+ */
161
+ class Func_void_bool_Wrapper final {
162
+ public:
163
+ explicit Func_void_bool_Wrapper(std::function<void(bool /* isScanning */)>&& func): _function(std::make_unique<std::function<void(bool /* isScanning */)>>(std::move(func))) {}
164
+ inline void call(bool isScanning) const noexcept {
165
+ _function->operator()(isScanning);
166
+ }
167
+ private:
168
+ std::unique_ptr<std::function<void(bool /* isScanning */)>> _function;
169
+ } SWIFT_NONCOPYABLE;
170
+ Func_void_bool create_Func_void_bool(void* NON_NULL swiftClosureWrapper) noexcept;
171
+ inline Func_void_bool_Wrapper wrap_Func_void_bool(Func_void_bool value) noexcept {
172
+ return Func_void_bool_Wrapper(std::move(value));
173
+ }
174
+
175
+ // pragma MARK: std::function<void(BonjourFail /* fail */)>
176
+ /**
177
+ * Specialized version of `std::function<void(BonjourFail)>`.
178
+ */
179
+ using Func_void_BonjourFail = std::function<void(BonjourFail /* fail */)>;
180
+ /**
181
+ * Wrapper class for a `std::function<void(BonjourFail / * fail * /)>`, this can be used from Swift.
182
+ */
183
+ class Func_void_BonjourFail_Wrapper final {
184
+ public:
185
+ explicit Func_void_BonjourFail_Wrapper(std::function<void(BonjourFail /* fail */)>&& func): _function(std::make_unique<std::function<void(BonjourFail /* fail */)>>(std::move(func))) {}
186
+ inline void call(int fail) const noexcept {
187
+ _function->operator()(static_cast<BonjourFail>(fail));
188
+ }
189
+ private:
190
+ std::unique_ptr<std::function<void(BonjourFail /* fail */)>> _function;
191
+ } SWIFT_NONCOPYABLE;
192
+ Func_void_BonjourFail create_Func_void_BonjourFail(void* NON_NULL swiftClosureWrapper) noexcept;
193
+ inline Func_void_BonjourFail_Wrapper wrap_Func_void_BonjourFail(Func_void_BonjourFail value) noexcept {
194
+ return Func_void_BonjourFail_Wrapper(std::move(value));
195
+ }
196
+
197
+ // pragma MARK: std::shared_ptr<HybridBonjourZeroconfSpec>
198
+ /**
199
+ * Specialized version of `std::shared_ptr<HybridBonjourZeroconfSpec>`.
200
+ */
201
+ using std__shared_ptr_HybridBonjourZeroconfSpec_ = std::shared_ptr<HybridBonjourZeroconfSpec>;
202
+ std::shared_ptr<HybridBonjourZeroconfSpec> create_std__shared_ptr_HybridBonjourZeroconfSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
203
+ void* NON_NULL get_std__shared_ptr_HybridBonjourZeroconfSpec_(std__shared_ptr_HybridBonjourZeroconfSpec_ cppType);
204
+
205
+ // pragma MARK: std::weak_ptr<HybridBonjourZeroconfSpec>
206
+ using std__weak_ptr_HybridBonjourZeroconfSpec_ = std::weak_ptr<HybridBonjourZeroconfSpec>;
207
+ inline std__weak_ptr_HybridBonjourZeroconfSpec_ weakify_std__shared_ptr_HybridBonjourZeroconfSpec_(const std::shared_ptr<HybridBonjourZeroconfSpec>& strong) noexcept { return strong; }
208
+
209
+ // pragma MARK: Result<void>
210
+ using Result_void_ = Result<void>;
211
+ inline Result_void_ create_Result_void_() noexcept {
212
+ return Result<void>::withValue();
213
+ }
214
+ inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept {
215
+ return Result<void>::withError(error);
216
+ }
217
+
218
+ // pragma MARK: Result<BonjourListener>
219
+ using Result_BonjourListener_ = Result<BonjourListener>;
220
+ inline Result_BonjourListener_ create_Result_BonjourListener_(const BonjourListener& value) noexcept {
221
+ return Result<BonjourListener>::withValue(value);
222
+ }
223
+ inline Result_BonjourListener_ create_Result_BonjourListener_(const std::exception_ptr& error) noexcept {
224
+ return Result<BonjourListener>::withError(error);
225
+ }
226
+
227
+ // pragma MARK: std::shared_ptr<Promise<bool>>
228
+ /**
229
+ * Specialized version of `std::shared_ptr<Promise<bool>>`.
230
+ */
231
+ using std__shared_ptr_Promise_bool__ = std::shared_ptr<Promise<bool>>;
232
+ inline std::shared_ptr<Promise<bool>> create_std__shared_ptr_Promise_bool__() noexcept {
233
+ return Promise<bool>::create();
234
+ }
235
+ inline PromiseHolder<bool> wrap_std__shared_ptr_Promise_bool__(std::shared_ptr<Promise<bool>> promise) noexcept {
236
+ return PromiseHolder<bool>(std::move(promise));
237
+ }
238
+
239
+ // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
240
+ /**
241
+ * Specialized version of `std::function<void(const std::exception_ptr&)>`.
242
+ */
243
+ using Func_void_std__exception_ptr = std::function<void(const std::exception_ptr& /* error */)>;
244
+ /**
245
+ * Wrapper class for a `std::function<void(const std::exception_ptr& / * error * /)>`, this can be used from Swift.
246
+ */
247
+ class Func_void_std__exception_ptr_Wrapper final {
248
+ public:
249
+ explicit Func_void_std__exception_ptr_Wrapper(std::function<void(const std::exception_ptr& /* error */)>&& func): _function(std::make_unique<std::function<void(const std::exception_ptr& /* error */)>>(std::move(func))) {}
250
+ inline void call(std::exception_ptr error) const noexcept {
251
+ _function->operator()(error);
252
+ }
253
+ private:
254
+ std::unique_ptr<std::function<void(const std::exception_ptr& /* error */)>> _function;
255
+ } SWIFT_NONCOPYABLE;
256
+ Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept;
257
+ inline Func_void_std__exception_ptr_Wrapper wrap_Func_void_std__exception_ptr(Func_void_std__exception_ptr value) noexcept {
258
+ return Func_void_std__exception_ptr_Wrapper(std::move(value));
259
+ }
260
+
261
+ // pragma MARK: std::shared_ptr<HybridLocalNetworkPermissionSpec>
262
+ /**
263
+ * Specialized version of `std::shared_ptr<HybridLocalNetworkPermissionSpec>`.
264
+ */
265
+ using std__shared_ptr_HybridLocalNetworkPermissionSpec_ = std::shared_ptr<HybridLocalNetworkPermissionSpec>;
266
+ std::shared_ptr<HybridLocalNetworkPermissionSpec> create_std__shared_ptr_HybridLocalNetworkPermissionSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
267
+ void* NON_NULL get_std__shared_ptr_HybridLocalNetworkPermissionSpec_(std__shared_ptr_HybridLocalNetworkPermissionSpec_ cppType);
268
+
269
+ // pragma MARK: std::weak_ptr<HybridLocalNetworkPermissionSpec>
270
+ using std__weak_ptr_HybridLocalNetworkPermissionSpec_ = std::weak_ptr<HybridLocalNetworkPermissionSpec>;
271
+ inline std__weak_ptr_HybridLocalNetworkPermissionSpec_ weakify_std__shared_ptr_HybridLocalNetworkPermissionSpec_(const std::shared_ptr<HybridLocalNetworkPermissionSpec>& strong) noexcept { return strong; }
272
+
273
+ // pragma MARK: Result<std::shared_ptr<Promise<bool>>>
274
+ using Result_std__shared_ptr_Promise_bool___ = Result<std::shared_ptr<Promise<bool>>>;
275
+ inline Result_std__shared_ptr_Promise_bool___ create_Result_std__shared_ptr_Promise_bool___(const std::shared_ptr<Promise<bool>>& value) noexcept {
276
+ return Result<std::shared_ptr<Promise<bool>>>::withValue(value);
277
+ }
278
+ inline Result_std__shared_ptr_Promise_bool___ create_Result_std__shared_ptr_Promise_bool___(const std::exception_ptr& error) noexcept {
279
+ return Result<std::shared_ptr<Promise<bool>>>::withError(error);
280
+ }
281
+
282
+ } // namespace margelo::nitro::dawidzawada_bonjourzeroconf::bridge::swift
@@ -0,0 +1,65 @@
1
+ ///
2
+ /// BonjourZeroconf-Swift-Cxx-Umbrella.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `BonjourFail` to properly resolve imports.
12
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf { enum class BonjourFail; }
13
+ // Forward declaration of `BonjourListener` to properly resolve imports.
14
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf { struct BonjourListener; }
15
+ // Forward declaration of `HybridBonjourZeroconfSpec` to properly resolve imports.
16
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf { class HybridBonjourZeroconfSpec; }
17
+ // Forward declaration of `HybridLocalNetworkPermissionSpec` to properly resolve imports.
18
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf { class HybridLocalNetworkPermissionSpec; }
19
+ // Forward declaration of `ScanOptions` to properly resolve imports.
20
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf { struct ScanOptions; }
21
+ // Forward declaration of `ScanResult` to properly resolve imports.
22
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf { struct ScanResult; }
23
+
24
+ // Include C++ defined types
25
+ #include "BonjourFail.hpp"
26
+ #include "BonjourListener.hpp"
27
+ #include "HybridBonjourZeroconfSpec.hpp"
28
+ #include "HybridLocalNetworkPermissionSpec.hpp"
29
+ #include "ScanOptions.hpp"
30
+ #include "ScanResult.hpp"
31
+ #include <NitroModules/Promise.hpp>
32
+ #include <NitroModules/Result.hpp>
33
+ #include <exception>
34
+ #include <functional>
35
+ #include <memory>
36
+ #include <optional>
37
+ #include <string>
38
+ #include <vector>
39
+
40
+ // C++ helpers for Swift
41
+ #include "BonjourZeroconf-Swift-Cxx-Bridge.hpp"
42
+
43
+ // Common C++ types used in Swift
44
+ #include <NitroModules/ArrayBufferHolder.hpp>
45
+ #include <NitroModules/AnyMapUtils.hpp>
46
+ #include <NitroModules/RuntimeError.hpp>
47
+ #include <NitroModules/DateToChronoDate.hpp>
48
+
49
+ // Forward declarations of Swift defined types
50
+ // Forward declaration of `HybridBonjourZeroconfSpec_cxx` to properly resolve imports.
51
+ namespace BonjourZeroconf { class HybridBonjourZeroconfSpec_cxx; }
52
+ // Forward declaration of `HybridLocalNetworkPermissionSpec_cxx` to properly resolve imports.
53
+ namespace BonjourZeroconf { class HybridLocalNetworkPermissionSpec_cxx; }
54
+
55
+ // Include Swift defined types
56
+ #if __has_include("BonjourZeroconf-Swift.h")
57
+ // This header is generated by Xcode/Swift on every app build.
58
+ // If it cannot be found, make sure the Swift module's name (= podspec name) is actually "BonjourZeroconf".
59
+ #include "BonjourZeroconf-Swift.h"
60
+ // Same as above, but used when building with frameworks (`use_frameworks`)
61
+ #elif __has_include(<BonjourZeroconf/BonjourZeroconf-Swift.h>)
62
+ #include <BonjourZeroconf/BonjourZeroconf-Swift.h>
63
+ #else
64
+ #error BonjourZeroconf's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "BonjourZeroconf", and try building the app first.
65
+ #endif
@@ -0,0 +1,41 @@
1
+ ///
2
+ /// BonjourZeroconfAutolinking.mm
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <NitroModules/HybridObjectRegistry.hpp>
10
+ #import "BonjourZeroconf-Swift-Cxx-Umbrella.hpp"
11
+ #import <type_traits>
12
+
13
+ #include "HybridBonjourZeroconfSpecSwift.hpp"
14
+ #include "HybridLocalNetworkPermissionSpecSwift.hpp"
15
+
16
+ @interface BonjourZeroconfAutolinking : NSObject
17
+ @end
18
+
19
+ @implementation BonjourZeroconfAutolinking
20
+
21
+ + (void) load {
22
+ using namespace margelo::nitro;
23
+ using namespace margelo::nitro::dawidzawada_bonjourzeroconf;
24
+
25
+ HybridObjectRegistry::registerHybridObjectConstructor(
26
+ "BonjourZeroconf",
27
+ []() -> std::shared_ptr<HybridObject> {
28
+ std::shared_ptr<HybridBonjourZeroconfSpec> hybridObject = BonjourZeroconf::BonjourZeroconfAutolinking::createBonjourZeroconf();
29
+ return hybridObject;
30
+ }
31
+ );
32
+ HybridObjectRegistry::registerHybridObjectConstructor(
33
+ "LocalNetworkPermission",
34
+ []() -> std::shared_ptr<HybridObject> {
35
+ std::shared_ptr<HybridLocalNetworkPermissionSpec> hybridObject = BonjourZeroconf::BonjourZeroconfAutolinking::createLocalNetworkPermission();
36
+ return hybridObject;
37
+ }
38
+ );
39
+ }
40
+
41
+ @end
@@ -0,0 +1,40 @@
1
+ ///
2
+ /// BonjourZeroconfAutolinking.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ public final class BonjourZeroconfAutolinking {
9
+ public typealias bridge = margelo.nitro.dawidzawada_bonjourzeroconf.bridge.swift
10
+
11
+ /**
12
+ * Creates an instance of a Swift class that implements `HybridBonjourZeroconfSpec`,
13
+ * and wraps it in a Swift class that can directly interop with C++ (`HybridBonjourZeroconfSpec_cxx`)
14
+ *
15
+ * This is generated by Nitrogen and will initialize the class specified
16
+ * in the `"autolinking"` property of `nitro.json` (in this case, `BonjourZeroconf`).
17
+ */
18
+ public static func createBonjourZeroconf() -> bridge.std__shared_ptr_HybridBonjourZeroconfSpec_ {
19
+ let hybridObject = BonjourZeroconf()
20
+ return { () -> bridge.std__shared_ptr_HybridBonjourZeroconfSpec_ in
21
+ let __cxxWrapped = hybridObject.getCxxWrapper()
22
+ return __cxxWrapped.getCxxPart()
23
+ }()
24
+ }
25
+
26
+ /**
27
+ * Creates an instance of a Swift class that implements `HybridLocalNetworkPermissionSpec`,
28
+ * and wraps it in a Swift class that can directly interop with C++ (`HybridLocalNetworkPermissionSpec_cxx`)
29
+ *
30
+ * This is generated by Nitrogen and will initialize the class specified
31
+ * in the `"autolinking"` property of `nitro.json` (in this case, `LocalNetworkPermission`).
32
+ */
33
+ public static func createLocalNetworkPermission() -> bridge.std__shared_ptr_HybridLocalNetworkPermissionSpec_ {
34
+ let hybridObject = LocalNetworkPermission()
35
+ return { () -> bridge.std__shared_ptr_HybridLocalNetworkPermissionSpec_ in
36
+ let __cxxWrapped = hybridObject.getCxxWrapper()
37
+ return __cxxWrapped.getCxxPart()
38
+ }()
39
+ }
40
+ }
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridBonjourZeroconfSpecSwift.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridBonjourZeroconfSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf {
11
+ } // namespace margelo::nitro::dawidzawada_bonjourzeroconf
@@ -0,0 +1,120 @@
1
+ ///
2
+ /// HybridBonjourZeroconfSpecSwift.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include "HybridBonjourZeroconfSpec.hpp"
11
+
12
+ // Forward declaration of `HybridBonjourZeroconfSpec_cxx` to properly resolve imports.
13
+ namespace BonjourZeroconf { class HybridBonjourZeroconfSpec_cxx; }
14
+
15
+ // Forward declaration of `ScanOptions` to properly resolve imports.
16
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf { struct ScanOptions; }
17
+ // Forward declaration of `BonjourListener` to properly resolve imports.
18
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf { struct BonjourListener; }
19
+ // Forward declaration of `ScanResult` to properly resolve imports.
20
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf { struct ScanResult; }
21
+ // Forward declaration of `BonjourFail` to properly resolve imports.
22
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf { enum class BonjourFail; }
23
+
24
+ #include <string>
25
+ #include "ScanOptions.hpp"
26
+ #include <optional>
27
+ #include "BonjourListener.hpp"
28
+ #include <functional>
29
+ #include "ScanResult.hpp"
30
+ #include <vector>
31
+ #include "BonjourFail.hpp"
32
+
33
+ #include "BonjourZeroconf-Swift-Cxx-Umbrella.hpp"
34
+
35
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf {
36
+
37
+ /**
38
+ * The C++ part of HybridBonjourZeroconfSpec_cxx.swift.
39
+ *
40
+ * HybridBonjourZeroconfSpecSwift (C++) accesses HybridBonjourZeroconfSpec_cxx (Swift), and might
41
+ * contain some additional bridging code for C++ <> Swift interop.
42
+ *
43
+ * Since this obviously introduces an overhead, I hope at some point in
44
+ * the future, HybridBonjourZeroconfSpec_cxx can directly inherit from the C++ class HybridBonjourZeroconfSpec
45
+ * to simplify the whole structure and memory management.
46
+ */
47
+ class HybridBonjourZeroconfSpecSwift: public virtual HybridBonjourZeroconfSpec {
48
+ public:
49
+ // Constructor from a Swift instance
50
+ explicit HybridBonjourZeroconfSpecSwift(const BonjourZeroconf::HybridBonjourZeroconfSpec_cxx& swiftPart):
51
+ HybridObject(HybridBonjourZeroconfSpec::TAG),
52
+ _swiftPart(swiftPart) { }
53
+
54
+ public:
55
+ // Get the Swift part
56
+ inline BonjourZeroconf::HybridBonjourZeroconfSpec_cxx& getSwiftPart() noexcept {
57
+ return _swiftPart;
58
+ }
59
+
60
+ public:
61
+ inline size_t getExternalMemorySize() noexcept override {
62
+ return _swiftPart.getMemorySize();
63
+ }
64
+ void dispose() noexcept override {
65
+ _swiftPart.dispose();
66
+ }
67
+ std::string toString() override {
68
+ return _swiftPart.toString();
69
+ }
70
+
71
+ public:
72
+ // Properties
73
+ inline bool getIsScanning() noexcept override {
74
+ return _swiftPart.isScanning();
75
+ }
76
+
77
+ public:
78
+ // Methods
79
+ inline void scan(const std::string& type, const std::string& domain, const std::optional<ScanOptions>& options) override {
80
+ auto __result = _swiftPart.scan(type, domain, options);
81
+ if (__result.hasError()) [[unlikely]] {
82
+ std::rethrow_exception(__result.error());
83
+ }
84
+ }
85
+ inline void stop() override {
86
+ auto __result = _swiftPart.stop();
87
+ if (__result.hasError()) [[unlikely]] {
88
+ std::rethrow_exception(__result.error());
89
+ }
90
+ }
91
+ inline BonjourListener listenForScanResults(const std::function<void(const std::vector<ScanResult>& /* results */)>& onResult) override {
92
+ auto __result = _swiftPart.listenForScanResults(onResult);
93
+ if (__result.hasError()) [[unlikely]] {
94
+ std::rethrow_exception(__result.error());
95
+ }
96
+ auto __value = std::move(__result.value());
97
+ return __value;
98
+ }
99
+ inline BonjourListener listenForScanState(const std::function<void(bool /* isScanning */)>& onChange) override {
100
+ auto __result = _swiftPart.listenForScanState(onChange);
101
+ if (__result.hasError()) [[unlikely]] {
102
+ std::rethrow_exception(__result.error());
103
+ }
104
+ auto __value = std::move(__result.value());
105
+ return __value;
106
+ }
107
+ inline BonjourListener listenForScanFail(const std::function<void(BonjourFail /* fail */)>& onFail) override {
108
+ auto __result = _swiftPart.listenForScanFail(onFail);
109
+ if (__result.hasError()) [[unlikely]] {
110
+ std::rethrow_exception(__result.error());
111
+ }
112
+ auto __value = std::move(__result.value());
113
+ return __value;
114
+ }
115
+
116
+ private:
117
+ BonjourZeroconf::HybridBonjourZeroconfSpec_cxx _swiftPart;
118
+ };
119
+
120
+ } // namespace margelo::nitro::dawidzawada_bonjourzeroconf
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridLocalNetworkPermissionSpecSwift.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridLocalNetworkPermissionSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf {
11
+ } // namespace margelo::nitro::dawidzawada_bonjourzeroconf
@@ -0,0 +1,87 @@
1
+ ///
2
+ /// HybridLocalNetworkPermissionSpecSwift.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include "HybridLocalNetworkPermissionSpec.hpp"
11
+
12
+ // Forward declaration of `HybridLocalNetworkPermissionSpec_cxx` to properly resolve imports.
13
+ namespace BonjourZeroconf { class HybridLocalNetworkPermissionSpec_cxx; }
14
+
15
+ // Forward declaration of `BonjourListener` to properly resolve imports.
16
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf { struct BonjourListener; }
17
+
18
+ #include <NitroModules/Promise.hpp>
19
+ #include "BonjourListener.hpp"
20
+ #include <functional>
21
+
22
+ #include "BonjourZeroconf-Swift-Cxx-Umbrella.hpp"
23
+
24
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf {
25
+
26
+ /**
27
+ * The C++ part of HybridLocalNetworkPermissionSpec_cxx.swift.
28
+ *
29
+ * HybridLocalNetworkPermissionSpecSwift (C++) accesses HybridLocalNetworkPermissionSpec_cxx (Swift), and might
30
+ * contain some additional bridging code for C++ <> Swift interop.
31
+ *
32
+ * Since this obviously introduces an overhead, I hope at some point in
33
+ * the future, HybridLocalNetworkPermissionSpec_cxx can directly inherit from the C++ class HybridLocalNetworkPermissionSpec
34
+ * to simplify the whole structure and memory management.
35
+ */
36
+ class HybridLocalNetworkPermissionSpecSwift: public virtual HybridLocalNetworkPermissionSpec {
37
+ public:
38
+ // Constructor from a Swift instance
39
+ explicit HybridLocalNetworkPermissionSpecSwift(const BonjourZeroconf::HybridLocalNetworkPermissionSpec_cxx& swiftPart):
40
+ HybridObject(HybridLocalNetworkPermissionSpec::TAG),
41
+ _swiftPart(swiftPart) { }
42
+
43
+ public:
44
+ // Get the Swift part
45
+ inline BonjourZeroconf::HybridLocalNetworkPermissionSpec_cxx& getSwiftPart() noexcept {
46
+ return _swiftPart;
47
+ }
48
+
49
+ public:
50
+ inline size_t getExternalMemorySize() noexcept override {
51
+ return _swiftPart.getMemorySize();
52
+ }
53
+ void dispose() noexcept override {
54
+ _swiftPart.dispose();
55
+ }
56
+ std::string toString() override {
57
+ return _swiftPart.toString();
58
+ }
59
+
60
+ public:
61
+ // Properties
62
+
63
+
64
+ public:
65
+ // Methods
66
+ inline std::shared_ptr<Promise<bool>> requestPermission() override {
67
+ auto __result = _swiftPart.requestPermission();
68
+ if (__result.hasError()) [[unlikely]] {
69
+ std::rethrow_exception(__result.error());
70
+ }
71
+ auto __value = std::move(__result.value());
72
+ return __value;
73
+ }
74
+ inline BonjourListener listenForPermission(const std::function<void(bool /* granted */)>& onChange) override {
75
+ auto __result = _swiftPart.listenForPermission(onChange);
76
+ if (__result.hasError()) [[unlikely]] {
77
+ std::rethrow_exception(__result.error());
78
+ }
79
+ auto __value = std::move(__result.value());
80
+ return __value;
81
+ }
82
+
83
+ private:
84
+ BonjourZeroconf::HybridLocalNetworkPermissionSpec_cxx _swiftPart;
85
+ };
86
+
87
+ } // namespace margelo::nitro::dawidzawada_bonjourzeroconf