@dawidzawada/bonjour-zeroconf 1.0.1 → 1.2.0-alpha.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 (66) hide show
  1. package/README.md +30 -0
  2. package/android/src/main/java/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourZeroconf+AddressResolver.kt +14 -0
  3. package/android/src/main/java/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourZeroconf.kt +25 -1
  4. package/ios/AddressResolverError.swift +13 -10
  5. package/ios/BonjourZeroconf+AddressResolver.swift +58 -21
  6. package/ios/BonjourZeroconf.swift +21 -0
  7. package/ios/LocalNetworkAuthorization.swift +0 -1
  8. package/lib/typescript/src/specs/BonjourZeroconf.nitro.d.ts +1 -0
  9. package/lib/typescript/src/specs/BonjourZeroconf.nitro.d.ts.map +1 -1
  10. package/nitrogen/generated/android/c++/JBonjourFail.hpp +4 -5
  11. package/nitrogen/generated/android/c++/JBonjourListener.hpp +3 -4
  12. package/nitrogen/generated/android/c++/JFunc_void.hpp +3 -2
  13. package/nitrogen/generated/android/c++/JFunc_void_BonjourFail.hpp +3 -2
  14. package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +3 -2
  15. package/nitrogen/generated/android/c++/JFunc_void_std__vector_ScanResult_.hpp +3 -2
  16. package/nitrogen/generated/android/c++/JHybridBonjourZeroconfSpec.cpp +43 -8
  17. package/nitrogen/generated/android/c++/JHybridBonjourZeroconfSpec.hpp +3 -1
  18. package/nitrogen/generated/android/c++/JScanOptions.hpp +1 -1
  19. package/nitrogen/generated/android/c++/JScanResult.hpp +1 -1
  20. package/nitrogen/generated/android/dawidzawada_bonjourzeroconf+autolinking.cmake +1 -1
  21. package/nitrogen/generated/android/dawidzawada_bonjourzeroconf+autolinking.gradle +1 -1
  22. package/nitrogen/generated/android/dawidzawada_bonjourzeroconfOnLoad.cpp +1 -1
  23. package/nitrogen/generated/android/dawidzawada_bonjourzeroconfOnLoad.hpp +1 -1
  24. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourFail.kt +3 -1
  25. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourListener.kt +2 -2
  26. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void.kt +1 -1
  27. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_BonjourFail.kt +1 -1
  28. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_bool.kt +1 -1
  29. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_std__vector_ScanResult_.kt +1 -1
  30. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/HybridBonjourZeroconfSpec.kt +6 -1
  31. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/ScanOptions.kt +2 -2
  32. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/ScanResult.kt +2 -2
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/dawidzawada_bonjourzeroconfOnLoad.kt +1 -1
  34. package/nitrogen/generated/ios/BonjourZeroconf+autolinking.rb +2 -2
  35. package/nitrogen/generated/ios/BonjourZeroconf-Swift-Cxx-Bridge.cpp +17 -17
  36. package/nitrogen/generated/ios/BonjourZeroconf-Swift-Cxx-Bridge.hpp +73 -52
  37. package/nitrogen/generated/ios/BonjourZeroconf-Swift-Cxx-Umbrella.hpp +1 -1
  38. package/nitrogen/generated/ios/BonjourZeroconfAutolinking.mm +1 -1
  39. package/nitrogen/generated/ios/BonjourZeroconfAutolinking.swift +1 -1
  40. package/nitrogen/generated/ios/c++/HybridBonjourZeroconfSpecSwift.cpp +1 -1
  41. package/nitrogen/generated/ios/c++/HybridBonjourZeroconfSpecSwift.hpp +20 -5
  42. package/nitrogen/generated/ios/c++/HybridLocalNetworkPermissionSpecSwift.cpp +1 -1
  43. package/nitrogen/generated/ios/c++/HybridLocalNetworkPermissionSpecSwift.hpp +7 -1
  44. package/nitrogen/generated/ios/swift/BonjourFail.swift +1 -1
  45. package/nitrogen/generated/ios/swift/BonjourListener.swift +8 -17
  46. package/nitrogen/generated/ios/swift/Func_void.swift +1 -1
  47. package/nitrogen/generated/ios/swift/Func_void_BonjourFail.swift +1 -1
  48. package/nitrogen/generated/ios/swift/Func_void_bool.swift +1 -1
  49. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +1 -1
  50. package/nitrogen/generated/ios/swift/Func_void_std__vector_ScanResult_.swift +6 -6
  51. package/nitrogen/generated/ios/swift/HybridBonjourZeroconfSpec.swift +2 -1
  52. package/nitrogen/generated/ios/swift/HybridBonjourZeroconfSpec_cxx.swift +34 -1
  53. package/nitrogen/generated/ios/swift/HybridLocalNetworkPermissionSpec.swift +1 -1
  54. package/nitrogen/generated/ios/swift/HybridLocalNetworkPermissionSpec_cxx.swift +9 -1
  55. package/nitrogen/generated/ios/swift/ScanOptions.swift +3 -15
  56. package/nitrogen/generated/ios/swift/ScanResult.swift +32 -86
  57. package/nitrogen/generated/shared/c++/BonjourFail.hpp +1 -1
  58. package/nitrogen/generated/shared/c++/BonjourListener.hpp +13 -5
  59. package/nitrogen/generated/shared/c++/HybridBonjourZeroconfSpec.cpp +2 -1
  60. package/nitrogen/generated/shared/c++/HybridBonjourZeroconfSpec.hpp +6 -4
  61. package/nitrogen/generated/shared/c++/HybridLocalNetworkPermissionSpec.cpp +1 -1
  62. package/nitrogen/generated/shared/c++/HybridLocalNetworkPermissionSpec.hpp +1 -1
  63. package/nitrogen/generated/shared/c++/ScanOptions.hpp +13 -5
  64. package/nitrogen/generated/shared/c++/ScanResult.hpp +25 -17
  65. package/package.json +5 -6
  66. package/src/specs/BonjourZeroconf.nitro.ts +7 -0
@@ -2,7 +2,7 @@
2
2
  /// Func_void_bool.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  import Foundation
@@ -2,7 +2,7 @@
2
2
  /// Func_void_std__exception_ptr.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  import Foundation
@@ -2,28 +2,28 @@
2
2
  /// Func_void_std__vector_ScanResult_.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  import Foundation
9
9
  import NitroModules
10
10
 
11
11
  /**
12
- * Wraps a Swift `(_ results: [ScanResult]) -> Void` as a class.
12
+ * Wraps a Swift `(_ value: [ScanResult]) -> Void` as a class.
13
13
  * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14
14
  */
15
15
  public final class Func_void_std__vector_ScanResult_ {
16
16
  public typealias bridge = margelo.nitro.dawidzawada_bonjourzeroconf.bridge.swift
17
17
 
18
- private let closure: (_ results: [ScanResult]) -> Void
18
+ private let closure: (_ value: [ScanResult]) -> Void
19
19
 
20
- public init(_ closure: @escaping (_ results: [ScanResult]) -> Void) {
20
+ public init(_ closure: @escaping (_ value: [ScanResult]) -> Void) {
21
21
  self.closure = closure
22
22
  }
23
23
 
24
24
  @inline(__always)
25
- public func call(results: bridge.std__vector_ScanResult_) -> Void {
26
- self.closure(results.map({ __item in __item }))
25
+ public func call(value: bridge.std__vector_ScanResult_) -> Void {
26
+ self.closure(value.map({ __item in __item }))
27
27
  }
28
28
 
29
29
  /**
@@ -2,7 +2,7 @@
2
2
  /// HybridBonjourZeroconfSpec.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  import Foundation
@@ -15,6 +15,7 @@ public protocol HybridBonjourZeroconfSpec_protocol: HybridObject {
15
15
 
16
16
  // Methods
17
17
  func scan(type: String, domain: String, options: ScanOptions?) throws -> Void
18
+ func scanFor(time: Double, type: String, domain: String, options: ScanOptions?) throws -> Promise<[ScanResult]>
18
19
  func stop() throws -> Void
19
20
  func listenForScanResults(onResult: @escaping (_ results: [ScanResult]) -> Void) throws -> BonjourListener
20
21
  func listenForScanState(onChange: @escaping (_ isScanning: Bool) -> Void) throws -> BonjourListener
@@ -2,7 +2,7 @@
2
2
  /// HybridBonjourZeroconfSpec_cxx.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  import Foundation
@@ -96,6 +96,14 @@ open class HybridBonjourZeroconfSpec_cxx {
96
96
  return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
97
97
  }
98
98
 
99
+ /**
100
+ * Compares this object with the given [other] object for reference equality.
101
+ */
102
+ @inline(__always)
103
+ public func equals(other: HybridBonjourZeroconfSpec_cxx) -> Bool {
104
+ return self.__implementation === other.__implementation
105
+ }
106
+
99
107
  /**
100
108
  * Call dispose() on the Swift class.
101
109
  * This _may_ be called manually from JS.
@@ -133,6 +141,31 @@ open class HybridBonjourZeroconfSpec_cxx {
133
141
  }
134
142
  }
135
143
 
144
+ @inline(__always)
145
+ public final func scanFor(time: Double, type: std.string, domain: std.string, options: bridge.std__optional_ScanOptions_) -> bridge.Result_std__shared_ptr_Promise_std__vector_ScanResult____ {
146
+ do {
147
+ let __result = try self.__implementation.scanFor(time: time, type: String(type), domain: String(domain), options: options.value)
148
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__vector_ScanResult___ in
149
+ let __promise = bridge.create_std__shared_ptr_Promise_std__vector_ScanResult___()
150
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__vector_ScanResult___(__promise)
151
+ __result
152
+ .then({ __result in __promiseHolder.resolve({ () -> bridge.std__vector_ScanResult_ in
153
+ var __vector = bridge.create_std__vector_ScanResult_(__result.count)
154
+ for __item in __result {
155
+ __vector.push_back(__item)
156
+ }
157
+ return __vector
158
+ }()) })
159
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
160
+ return __promise
161
+ }()
162
+ return bridge.create_Result_std__shared_ptr_Promise_std__vector_ScanResult____(__resultCpp)
163
+ } catch (let __error) {
164
+ let __exceptionPtr = __error.toCpp()
165
+ return bridge.create_Result_std__shared_ptr_Promise_std__vector_ScanResult____(__exceptionPtr)
166
+ }
167
+ }
168
+
136
169
  @inline(__always)
137
170
  public final func stop() -> bridge.Result_void_ {
138
171
  do {
@@ -2,7 +2,7 @@
2
2
  /// HybridLocalNetworkPermissionSpec.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  import Foundation
@@ -2,7 +2,7 @@
2
2
  /// HybridLocalNetworkPermissionSpec_cxx.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  import Foundation
@@ -96,6 +96,14 @@ open class HybridLocalNetworkPermissionSpec_cxx {
96
96
  return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
97
97
  }
98
98
 
99
+ /**
100
+ * Compares this object with the given [other] object for reference equality.
101
+ */
102
+ @inline(__always)
103
+ public func equals(other: HybridLocalNetworkPermissionSpec_cxx) -> Bool {
104
+ return self.__implementation === other.__implementation
105
+ }
106
+
99
107
  /**
100
108
  * Call dispose() on the Swift class.
101
109
  * This _may_ be called manually from JS.
@@ -2,7 +2,7 @@
2
2
  /// ScanOptions.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  import Foundation
@@ -29,20 +29,8 @@ public extension ScanOptions {
29
29
  }())
30
30
  }
31
31
 
32
+ @inline(__always)
32
33
  var addressResolveTimeout: Double? {
33
- @inline(__always)
34
- get {
35
- return self.__addressResolveTimeout.value
36
- }
37
- @inline(__always)
38
- set {
39
- self.__addressResolveTimeout = { () -> bridge.std__optional_double_ in
40
- if let __unwrappedValue = newValue {
41
- return bridge.create_std__optional_double_(__unwrappedValue)
42
- } else {
43
- return .init()
44
- }
45
- }()
46
- }
34
+ return self.__addressResolveTimeout.value
47
35
  }
48
36
  }
@@ -2,7 +2,7 @@
2
2
  /// ScanResult.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  import Foundation
@@ -47,103 +47,49 @@ public extension ScanResult {
47
47
  }())
48
48
  }
49
49
 
50
+ @inline(__always)
50
51
  var name: String {
51
- @inline(__always)
52
- get {
53
- return String(self.__name)
54
- }
55
- @inline(__always)
56
- set {
57
- self.__name = std.string(newValue)
58
- }
52
+ return String(self.__name)
59
53
  }
60
54
 
55
+ @inline(__always)
61
56
  var ipv4: String? {
62
- @inline(__always)
63
- get {
64
- return { () -> String? in
65
- if bridge.has_value_std__optional_std__string_(self.__ipv4) {
66
- let __unwrapped = bridge.get_std__optional_std__string_(self.__ipv4)
67
- return String(__unwrapped)
68
- } else {
69
- return nil
70
- }
71
- }()
72
- }
73
- @inline(__always)
74
- set {
75
- self.__ipv4 = { () -> bridge.std__optional_std__string_ in
76
- if let __unwrappedValue = newValue {
77
- return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
78
- } else {
79
- return .init()
80
- }
81
- }()
82
- }
57
+ return { () -> String? in
58
+ if bridge.has_value_std__optional_std__string_(self.__ipv4) {
59
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__ipv4)
60
+ return String(__unwrapped)
61
+ } else {
62
+ return nil
63
+ }
64
+ }()
83
65
  }
84
66
 
67
+ @inline(__always)
85
68
  var ipv6: String? {
86
- @inline(__always)
87
- get {
88
- return { () -> String? in
89
- if bridge.has_value_std__optional_std__string_(self.__ipv6) {
90
- let __unwrapped = bridge.get_std__optional_std__string_(self.__ipv6)
91
- return String(__unwrapped)
92
- } else {
93
- return nil
94
- }
95
- }()
96
- }
97
- @inline(__always)
98
- set {
99
- self.__ipv6 = { () -> bridge.std__optional_std__string_ in
100
- if let __unwrappedValue = newValue {
101
- return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
102
- } else {
103
- return .init()
104
- }
105
- }()
106
- }
69
+ return { () -> String? in
70
+ if bridge.has_value_std__optional_std__string_(self.__ipv6) {
71
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__ipv6)
72
+ return String(__unwrapped)
73
+ } else {
74
+ return nil
75
+ }
76
+ }()
107
77
  }
108
78
 
79
+ @inline(__always)
109
80
  var hostname: String? {
110
- @inline(__always)
111
- get {
112
- return { () -> String? in
113
- if bridge.has_value_std__optional_std__string_(self.__hostname) {
114
- let __unwrapped = bridge.get_std__optional_std__string_(self.__hostname)
115
- return String(__unwrapped)
116
- } else {
117
- return nil
118
- }
119
- }()
120
- }
121
- @inline(__always)
122
- set {
123
- self.__hostname = { () -> bridge.std__optional_std__string_ in
124
- if let __unwrappedValue = newValue {
125
- return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
126
- } else {
127
- return .init()
128
- }
129
- }()
130
- }
81
+ return { () -> String? in
82
+ if bridge.has_value_std__optional_std__string_(self.__hostname) {
83
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__hostname)
84
+ return String(__unwrapped)
85
+ } else {
86
+ return nil
87
+ }
88
+ }()
131
89
  }
132
90
 
91
+ @inline(__always)
133
92
  var port: Double? {
134
- @inline(__always)
135
- get {
136
- return self.__port.value
137
- }
138
- @inline(__always)
139
- set {
140
- self.__port = { () -> bridge.std__optional_double_ in
141
- if let __unwrappedValue = newValue {
142
- return bridge.create_std__optional_double_(__unwrappedValue)
143
- } else {
144
- return .init()
145
- }
146
- }()
147
- }
93
+ return self.__port.value
148
94
  }
149
95
  }
@@ -2,7 +2,7 @@
2
2
  /// BonjourFail.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
@@ -2,7 +2,7 @@
2
2
  /// BonjourListener.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
@@ -22,6 +22,11 @@
22
22
  #else
23
23
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
24
  #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
25
30
 
26
31
 
27
32
 
@@ -32,13 +37,16 @@ namespace margelo::nitro::dawidzawada_bonjourzeroconf {
32
37
  /**
33
38
  * A struct which can be represented as a JavaScript object (BonjourListener).
34
39
  */
35
- struct BonjourListener {
40
+ struct BonjourListener final {
36
41
  public:
37
42
  std::function<void()> remove SWIFT_PRIVATE;
38
43
 
39
44
  public:
40
45
  BonjourListener() = default;
41
46
  explicit BonjourListener(std::function<void()> remove): remove(remove) {}
47
+
48
+ public:
49
+ // BonjourListener is not equatable because these properties are not equatable: remove
42
50
  };
43
51
 
44
52
  } // namespace margelo::nitro::dawidzawada_bonjourzeroconf
@@ -51,12 +59,12 @@ namespace margelo::nitro {
51
59
  static inline margelo::nitro::dawidzawada_bonjourzeroconf::BonjourListener fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
52
60
  jsi::Object obj = arg.asObject(runtime);
53
61
  return margelo::nitro::dawidzawada_bonjourzeroconf::BonjourListener(
54
- JSIConverter<std::function<void()>>::fromJSI(runtime, obj.getProperty(runtime, "remove"))
62
+ JSIConverter<std::function<void()>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "remove")))
55
63
  );
56
64
  }
57
65
  static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::dawidzawada_bonjourzeroconf::BonjourListener& arg) {
58
66
  jsi::Object obj(runtime);
59
- obj.setProperty(runtime, "remove", JSIConverter<std::function<void()>>::toJSI(runtime, arg.remove));
67
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "remove"), JSIConverter<std::function<void()>>::toJSI(runtime, arg.remove));
60
68
  return obj;
61
69
  }
62
70
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -67,7 +75,7 @@ namespace margelo::nitro {
67
75
  if (!nitro::isPlainObject(runtime, obj)) {
68
76
  return false;
69
77
  }
70
- if (!JSIConverter<std::function<void()>>::canConvert(runtime, obj.getProperty(runtime, "remove"))) return false;
78
+ if (!JSIConverter<std::function<void()>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "remove")))) return false;
71
79
  return true;
72
80
  }
73
81
  };
@@ -2,7 +2,7 @@
2
2
  /// HybridBonjourZeroconfSpec.cpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #include "HybridBonjourZeroconfSpec.hpp"
@@ -16,6 +16,7 @@ namespace margelo::nitro::dawidzawada_bonjourzeroconf {
16
16
  registerHybrids(this, [](Prototype& prototype) {
17
17
  prototype.registerHybridGetter("isScanning", &HybridBonjourZeroconfSpec::getIsScanning);
18
18
  prototype.registerHybridMethod("scan", &HybridBonjourZeroconfSpec::scan);
19
+ prototype.registerHybridMethod("scanFor", &HybridBonjourZeroconfSpec::scanFor);
19
20
  prototype.registerHybridMethod("stop", &HybridBonjourZeroconfSpec::stop);
20
21
  prototype.registerHybridMethod("listenForScanResults", &HybridBonjourZeroconfSpec::listenForScanResults);
21
22
  prototype.registerHybridMethod("listenForScanState", &HybridBonjourZeroconfSpec::listenForScanState);
@@ -2,7 +2,7 @@
2
2
  /// HybridBonjourZeroconfSpec.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
@@ -15,19 +15,20 @@
15
15
 
16
16
  // Forward declaration of `ScanOptions` to properly resolve imports.
17
17
  namespace margelo::nitro::dawidzawada_bonjourzeroconf { struct ScanOptions; }
18
- // Forward declaration of `BonjourListener` to properly resolve imports.
19
- namespace margelo::nitro::dawidzawada_bonjourzeroconf { struct BonjourListener; }
20
18
  // Forward declaration of `ScanResult` to properly resolve imports.
21
19
  namespace margelo::nitro::dawidzawada_bonjourzeroconf { struct ScanResult; }
20
+ // Forward declaration of `BonjourListener` to properly resolve imports.
21
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf { struct BonjourListener; }
22
22
  // Forward declaration of `BonjourFail` to properly resolve imports.
23
23
  namespace margelo::nitro::dawidzawada_bonjourzeroconf { enum class BonjourFail; }
24
24
 
25
25
  #include <string>
26
26
  #include "ScanOptions.hpp"
27
27
  #include <optional>
28
- #include "BonjourListener.hpp"
29
28
  #include "ScanResult.hpp"
30
29
  #include <vector>
30
+ #include <NitroModules/Promise.hpp>
31
+ #include "BonjourListener.hpp"
31
32
  #include <functional>
32
33
  #include "BonjourFail.hpp"
33
34
 
@@ -63,6 +64,7 @@ namespace margelo::nitro::dawidzawada_bonjourzeroconf {
63
64
  public:
64
65
  // Methods
65
66
  virtual void scan(const std::string& type, const std::string& domain, const std::optional<ScanOptions>& options) = 0;
67
+ virtual std::shared_ptr<Promise<std::vector<ScanResult>>> scanFor(double time, const std::string& type, const std::string& domain, const std::optional<ScanOptions>& options) = 0;
66
68
  virtual void stop() = 0;
67
69
  virtual BonjourListener listenForScanResults(const std::function<void(const std::vector<ScanResult>& /* results */)>& onResult) = 0;
68
70
  virtual BonjourListener listenForScanState(const std::function<void(bool /* isScanning */)>& onChange) = 0;
@@ -2,7 +2,7 @@
2
2
  /// HybridLocalNetworkPermissionSpec.cpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #include "HybridLocalNetworkPermissionSpec.hpp"
@@ -2,7 +2,7 @@
2
2
  /// HybridLocalNetworkPermissionSpec.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
@@ -2,7 +2,7 @@
2
2
  /// ScanOptions.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
@@ -22,6 +22,11 @@
22
22
  #else
23
23
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
24
  #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
25
30
 
26
31
 
27
32
 
@@ -32,13 +37,16 @@ namespace margelo::nitro::dawidzawada_bonjourzeroconf {
32
37
  /**
33
38
  * A struct which can be represented as a JavaScript object (ScanOptions).
34
39
  */
35
- struct ScanOptions {
40
+ struct ScanOptions final {
36
41
  public:
37
42
  std::optional<double> addressResolveTimeout SWIFT_PRIVATE;
38
43
 
39
44
  public:
40
45
  ScanOptions() = default;
41
46
  explicit ScanOptions(std::optional<double> addressResolveTimeout): addressResolveTimeout(addressResolveTimeout) {}
47
+
48
+ public:
49
+ friend bool operator==(const ScanOptions& lhs, const ScanOptions& rhs) = default;
42
50
  };
43
51
 
44
52
  } // namespace margelo::nitro::dawidzawada_bonjourzeroconf
@@ -51,12 +59,12 @@ namespace margelo::nitro {
51
59
  static inline margelo::nitro::dawidzawada_bonjourzeroconf::ScanOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
52
60
  jsi::Object obj = arg.asObject(runtime);
53
61
  return margelo::nitro::dawidzawada_bonjourzeroconf::ScanOptions(
54
- JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "addressResolveTimeout"))
62
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "addressResolveTimeout")))
55
63
  );
56
64
  }
57
65
  static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::dawidzawada_bonjourzeroconf::ScanOptions& arg) {
58
66
  jsi::Object obj(runtime);
59
- obj.setProperty(runtime, "addressResolveTimeout", JSIConverter<std::optional<double>>::toJSI(runtime, arg.addressResolveTimeout));
67
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "addressResolveTimeout"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.addressResolveTimeout));
60
68
  return obj;
61
69
  }
62
70
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -67,7 +75,7 @@ namespace margelo::nitro {
67
75
  if (!nitro::isPlainObject(runtime, obj)) {
68
76
  return false;
69
77
  }
70
- if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "addressResolveTimeout"))) return false;
78
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "addressResolveTimeout")))) return false;
71
79
  return true;
72
80
  }
73
81
  };
@@ -2,7 +2,7 @@
2
2
  /// ScanResult.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
@@ -22,6 +22,11 @@
22
22
  #else
23
23
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
24
  #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
25
30
 
26
31
 
27
32
 
@@ -33,7 +38,7 @@ namespace margelo::nitro::dawidzawada_bonjourzeroconf {
33
38
  /**
34
39
  * A struct which can be represented as a JavaScript object (ScanResult).
35
40
  */
36
- struct ScanResult {
41
+ struct ScanResult final {
37
42
  public:
38
43
  std::string name SWIFT_PRIVATE;
39
44
  std::optional<std::string> ipv4 SWIFT_PRIVATE;
@@ -44,6 +49,9 @@ namespace margelo::nitro::dawidzawada_bonjourzeroconf {
44
49
  public:
45
50
  ScanResult() = default;
46
51
  explicit ScanResult(std::string name, std::optional<std::string> ipv4, std::optional<std::string> ipv6, std::optional<std::string> hostname, std::optional<double> port): name(name), ipv4(ipv4), ipv6(ipv6), hostname(hostname), port(port) {}
52
+
53
+ public:
54
+ friend bool operator==(const ScanResult& lhs, const ScanResult& rhs) = default;
47
55
  };
48
56
 
49
57
  } // namespace margelo::nitro::dawidzawada_bonjourzeroconf
@@ -56,20 +64,20 @@ namespace margelo::nitro {
56
64
  static inline margelo::nitro::dawidzawada_bonjourzeroconf::ScanResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
57
65
  jsi::Object obj = arg.asObject(runtime);
58
66
  return margelo::nitro::dawidzawada_bonjourzeroconf::ScanResult(
59
- JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "name")),
60
- JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "ipv4")),
61
- JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "ipv6")),
62
- JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "hostname")),
63
- JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "port"))
67
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
68
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ipv4"))),
69
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ipv6"))),
70
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hostname"))),
71
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "port")))
64
72
  );
65
73
  }
66
74
  static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::dawidzawada_bonjourzeroconf::ScanResult& arg) {
67
75
  jsi::Object obj(runtime);
68
- obj.setProperty(runtime, "name", JSIConverter<std::string>::toJSI(runtime, arg.name));
69
- obj.setProperty(runtime, "ipv4", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.ipv4));
70
- obj.setProperty(runtime, "ipv6", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.ipv6));
71
- obj.setProperty(runtime, "hostname", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.hostname));
72
- obj.setProperty(runtime, "port", JSIConverter<std::optional<double>>::toJSI(runtime, arg.port));
76
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "name"), JSIConverter<std::string>::toJSI(runtime, arg.name));
77
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "ipv4"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.ipv4));
78
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "ipv6"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.ipv6));
79
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "hostname"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.hostname));
80
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "port"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.port));
73
81
  return obj;
74
82
  }
75
83
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -80,11 +88,11 @@ namespace margelo::nitro {
80
88
  if (!nitro::isPlainObject(runtime, obj)) {
81
89
  return false;
82
90
  }
83
- if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "name"))) return false;
84
- if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "ipv4"))) return false;
85
- if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "ipv6"))) return false;
86
- if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "hostname"))) return false;
87
- if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "port"))) return false;
91
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name")))) return false;
92
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ipv4")))) return false;
93
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ipv6")))) return false;
94
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hostname")))) return false;
95
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "port")))) return false;
88
96
  return true;
89
97
  }
90
98
  };