@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.
- package/BonjourZeroconf.podspec +30 -0
- package/LICENSE +20 -0
- package/README.md +35 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +128 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourZeroconf+AddressResolver.kt +182 -0
- package/android/src/main/java/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourZeroconf+Listeners.kt +45 -0
- package/android/src/main/java/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourZeroconf.kt +183 -0
- package/android/src/main/java/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourZeroconfPackage.kt +22 -0
- package/ios/AddressResolverError.swift +20 -0
- package/ios/BonjourZeroconf+AddressResolver.swift +133 -0
- package/ios/BonjourZeroconf+Listeners.swift +26 -0
- package/ios/BonjourZeroconf.swift +201 -0
- package/ios/LocalNetworkAuthorization.swift +66 -0
- package/ios/LocalNetworkPermission+Listeners.swift +14 -0
- package/ios/LocalNetworkPermission.swift +41 -0
- package/ios/ServiceCache.swift +30 -0
- package/ios/Utils/Loggy.swift +37 -0
- package/lib/module/index.js +9 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/permissions.ios.js +23 -0
- package/lib/module/permissions.ios.js.map +1 -0
- package/lib/module/permissions.js +9 -0
- package/lib/module/permissions.js.map +1 -0
- package/lib/module/specs/BonjourFail.js +9 -0
- package/lib/module/specs/BonjourFail.js.map +1 -0
- package/lib/module/specs/BonjourListener.js +2 -0
- package/lib/module/specs/BonjourListener.js.map +1 -0
- package/lib/module/specs/BonjourZeroconf.nitro.js +4 -0
- package/lib/module/specs/BonjourZeroconf.nitro.js.map +1 -0
- package/lib/module/specs/LocalNetworkPermission.nitro.js +4 -0
- package/lib/module/specs/LocalNetworkPermission.nitro.js.map +1 -0
- package/lib/module/specs/ScanResult.js +2 -0
- package/lib/module/specs/ScanResult.js.map +1 -0
- package/lib/module/useIsScanning.js +19 -0
- package/lib/module/useIsScanning.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/index.d.ts +9 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/permissions.d.ts +3 -0
- package/lib/typescript/src/permissions.d.ts.map +1 -0
- package/lib/typescript/src/permissions.ios.d.ts +3 -0
- package/lib/typescript/src/permissions.ios.d.ts.map +1 -0
- package/lib/typescript/src/specs/BonjourFail.d.ts +6 -0
- package/lib/typescript/src/specs/BonjourFail.d.ts.map +1 -0
- package/lib/typescript/src/specs/BonjourListener.d.ts +4 -0
- package/lib/typescript/src/specs/BonjourListener.d.ts.map +1 -0
- package/lib/typescript/src/specs/BonjourZeroconf.nitro.d.ts +19 -0
- package/lib/typescript/src/specs/BonjourZeroconf.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/LocalNetworkPermission.nitro.d.ts +9 -0
- package/lib/typescript/src/specs/LocalNetworkPermission.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/ScanResult.d.ts +8 -0
- package/lib/typescript/src/specs/ScanResult.d.ts.map +1 -0
- package/lib/typescript/src/useIsScanning.d.ts +2 -0
- package/lib/typescript/src/useIsScanning.d.ts.map +1 -0
- package/nitro.json +20 -0
- package/nitrogen/generated/android/c++/JBonjourFail.hpp +62 -0
- package/nitrogen/generated/android/c++/JBonjourListener.hpp +68 -0
- package/nitrogen/generated/android/c++/JFunc_void.hpp +74 -0
- package/nitrogen/generated/android/c++/JFunc_void_BonjourFail.hpp +76 -0
- package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +74 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_ScanResult_.hpp +97 -0
- package/nitrogen/generated/android/c++/JHybridBonjourZeroconfSpec.cpp +96 -0
- package/nitrogen/generated/android/c++/JHybridBonjourZeroconfSpec.hpp +69 -0
- package/nitrogen/generated/android/c++/JScanOptions.hpp +57 -0
- package/nitrogen/generated/android/c++/JScanResult.hpp +74 -0
- package/nitrogen/generated/android/dawidzawada_bonjourzeroconf+autolinking.cmake +82 -0
- package/nitrogen/generated/android/dawidzawada_bonjourzeroconf+autolinking.gradle +27 -0
- package/nitrogen/generated/android/dawidzawada_bonjourzeroconfOnLoad.cpp +52 -0
- package/nitrogen/generated/android/dawidzawada_bonjourzeroconfOnLoad.hpp +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourFail.kt +22 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourListener.kt +42 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_BonjourFail.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_bool.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_std__vector_ScanResult_.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/HybridBonjourZeroconfSpec.kt +90 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/ScanOptions.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/ScanResult.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/dawidzawada_bonjourzeroconfOnLoad.kt +35 -0
- package/nitrogen/generated/ios/BonjourZeroconf+autolinking.rb +60 -0
- package/nitrogen/generated/ios/BonjourZeroconf-Swift-Cxx-Bridge.cpp +90 -0
- package/nitrogen/generated/ios/BonjourZeroconf-Swift-Cxx-Bridge.hpp +282 -0
- package/nitrogen/generated/ios/BonjourZeroconf-Swift-Cxx-Umbrella.hpp +65 -0
- package/nitrogen/generated/ios/BonjourZeroconfAutolinking.mm +41 -0
- package/nitrogen/generated/ios/BonjourZeroconfAutolinking.swift +40 -0
- package/nitrogen/generated/ios/c++/HybridBonjourZeroconfSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridBonjourZeroconfSpecSwift.hpp +120 -0
- package/nitrogen/generated/ios/c++/HybridLocalNetworkPermissionSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridLocalNetworkPermissionSpecSwift.hpp +87 -0
- package/nitrogen/generated/ios/swift/BonjourFail.swift +44 -0
- package/nitrogen/generated/ios/swift/BonjourListener.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_BonjourFail.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_ScanResult_.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridBonjourZeroconfSpec.swift +60 -0
- package/nitrogen/generated/ios/swift/HybridBonjourZeroconfSpec_cxx.swift +203 -0
- package/nitrogen/generated/ios/swift/HybridLocalNetworkPermissionSpec.swift +57 -0
- package/nitrogen/generated/ios/swift/HybridLocalNetworkPermissionSpec_cxx.swift +155 -0
- package/nitrogen/generated/ios/swift/ScanOptions.swift +48 -0
- package/nitrogen/generated/ios/swift/ScanResult.swift +149 -0
- package/nitrogen/generated/shared/c++/BonjourFail.hpp +63 -0
- package/nitrogen/generated/shared/c++/BonjourListener.hpp +75 -0
- package/nitrogen/generated/shared/c++/HybridBonjourZeroconfSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridBonjourZeroconfSpec.hpp +80 -0
- package/nitrogen/generated/shared/c++/HybridLocalNetworkPermissionSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridLocalNetworkPermissionSpec.hpp +66 -0
- package/nitrogen/generated/shared/c++/ScanOptions.hpp +75 -0
- package/nitrogen/generated/shared/c++/ScanResult.hpp +92 -0
- package/package.json +169 -0
- package/src/index.ts +22 -0
- package/src/permissions.ios.ts +27 -0
- package/src/permissions.ts +7 -0
- package/src/specs/BonjourFail.ts +5 -0
- package/src/specs/BonjourListener.ts +3 -0
- package/src/specs/BonjourZeroconf.nitro.ts +20 -0
- package/src/specs/LocalNetworkPermission.nitro.ts +7 -0
- package/src/specs/ScanResult.ts +7 -0
- package/src/useIsScanning.ts +17 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// BonjourFail.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
|
+
/**
|
|
9
|
+
* Represents the JS enum `BonjourFail`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias BonjourFail = margelo.nitro.dawidzawada_bonjourzeroconf.BonjourFail
|
|
12
|
+
|
|
13
|
+
public extension BonjourFail {
|
|
14
|
+
/**
|
|
15
|
+
* Get a BonjourFail for the given String value, or
|
|
16
|
+
* return `nil` if the given value was invalid/unknown.
|
|
17
|
+
*/
|
|
18
|
+
init?(fromString string: String) {
|
|
19
|
+
switch string {
|
|
20
|
+
case "RESOLVE_FAILED":
|
|
21
|
+
self = .resolveFailed
|
|
22
|
+
case "EXTRACTION_FAILED":
|
|
23
|
+
self = .extractionFailed
|
|
24
|
+
case "DISCOVERY_FAILED":
|
|
25
|
+
self = .discoveryFailed
|
|
26
|
+
default:
|
|
27
|
+
return nil
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get the String value this BonjourFail represents.
|
|
33
|
+
*/
|
|
34
|
+
var stringValue: String {
|
|
35
|
+
switch self {
|
|
36
|
+
case .resolveFailed:
|
|
37
|
+
return "RESOLVE_FAILED"
|
|
38
|
+
case .extractionFailed:
|
|
39
|
+
return "EXTRACTION_FAILED"
|
|
40
|
+
case .discoveryFailed:
|
|
41
|
+
return "DISCOVERY_FAILED"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// BonjourListener.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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Represents an instance of `BonjourListener`, backed by a C++ struct.
|
|
13
|
+
*/
|
|
14
|
+
public typealias BonjourListener = margelo.nitro.dawidzawada_bonjourzeroconf.BonjourListener
|
|
15
|
+
|
|
16
|
+
public extension BonjourListener {
|
|
17
|
+
private typealias bridge = margelo.nitro.dawidzawada_bonjourzeroconf.bridge.swift
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a new instance of `BonjourListener`.
|
|
21
|
+
*/
|
|
22
|
+
init(remove: @escaping () -> Void) {
|
|
23
|
+
self.init({ () -> bridge.Func_void in
|
|
24
|
+
let __closureWrapper = Func_void(remove)
|
|
25
|
+
return bridge.create_Func_void(__closureWrapper.toUnsafe())
|
|
26
|
+
}())
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var remove: () -> Void {
|
|
30
|
+
@inline(__always)
|
|
31
|
+
get {
|
|
32
|
+
return { () -> () -> Void in
|
|
33
|
+
let __wrappedFunction = bridge.wrap_Func_void(self.__remove)
|
|
34
|
+
return { () -> Void in
|
|
35
|
+
__wrappedFunction.call()
|
|
36
|
+
}
|
|
37
|
+
}()
|
|
38
|
+
}
|
|
39
|
+
@inline(__always)
|
|
40
|
+
set {
|
|
41
|
+
self.__remove = { () -> bridge.Func_void in
|
|
42
|
+
let __closureWrapper = Func_void(newValue)
|
|
43
|
+
return bridge.create_Func_void(__closureWrapper.toUnsafe())
|
|
44
|
+
}()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void.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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `() -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void {
|
|
16
|
+
public typealias bridge = margelo.nitro.dawidzawada_bonjourzeroconf.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: () -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping () -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call() -> Void {
|
|
26
|
+
self.closure()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
31
|
+
* This acquires one additional strong reference on the object!
|
|
32
|
+
*/
|
|
33
|
+
@inline(__always)
|
|
34
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
35
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Casts an unsafe pointer to a `Func_void`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void {
|
|
45
|
+
return Unmanaged<Func_void>.fromOpaque(pointer).takeRetainedValue()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_BonjourFail.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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ fail: BonjourFail) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_BonjourFail {
|
|
16
|
+
public typealias bridge = margelo.nitro.dawidzawada_bonjourzeroconf.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ fail: BonjourFail) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ fail: BonjourFail) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(fail: Int32) -> Void {
|
|
26
|
+
self.closure(margelo.nitro.dawidzawada_bonjourzeroconf.BonjourFail(rawValue: fail)!)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
31
|
+
* This acquires one additional strong reference on the object!
|
|
32
|
+
*/
|
|
33
|
+
@inline(__always)
|
|
34
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
35
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Casts an unsafe pointer to a `Func_void_BonjourFail`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_BonjourFail>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_BonjourFail {
|
|
45
|
+
return Unmanaged<Func_void_BonjourFail>.fromOpaque(pointer).takeRetainedValue()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_bool.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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ value: Bool) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_bool {
|
|
16
|
+
public typealias bridge = margelo.nitro.dawidzawada_bonjourzeroconf.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ value: Bool) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ value: Bool) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(value: Bool) -> Void {
|
|
26
|
+
self.closure(value)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
31
|
+
* This acquires one additional strong reference on the object!
|
|
32
|
+
*/
|
|
33
|
+
@inline(__always)
|
|
34
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
35
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Casts an unsafe pointer to a `Func_void_bool`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_bool>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_bool {
|
|
45
|
+
return Unmanaged<Func_void_bool>.fromOpaque(pointer).takeRetainedValue()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__exception_ptr.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ error: Error) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_std__exception_ptr {
|
|
16
|
+
public typealias bridge = margelo.nitro.dawidzawada_bonjourzeroconf.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ error: Error) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ error: Error) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(error: std.exception_ptr) -> Void {
|
|
26
|
+
self.closure(RuntimeError.from(cppError: error))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
31
|
+
* This acquires one additional strong reference on the object!
|
|
32
|
+
*/
|
|
33
|
+
@inline(__always)
|
|
34
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
35
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
|
|
45
|
+
return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__vector_ScanResult_.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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ results: [ScanResult]) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_std__vector_ScanResult_ {
|
|
16
|
+
public typealias bridge = margelo.nitro.dawidzawada_bonjourzeroconf.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ results: [ScanResult]) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ results: [ScanResult]) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(results: bridge.std__vector_ScanResult_) -> Void {
|
|
26
|
+
self.closure(results.map({ __item in __item }))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
31
|
+
* This acquires one additional strong reference on the object!
|
|
32
|
+
*/
|
|
33
|
+
@inline(__always)
|
|
34
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
35
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Casts an unsafe pointer to a `Func_void_std__vector_ScanResult_`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__vector_ScanResult_>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__vector_ScanResult_ {
|
|
45
|
+
return Unmanaged<Func_void_std__vector_ScanResult_>.fromOpaque(pointer).takeRetainedValue()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridBonjourZeroconfSpec.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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/// See ``HybridBonjourZeroconfSpec``
|
|
12
|
+
public protocol HybridBonjourZeroconfSpec_protocol: HybridObject {
|
|
13
|
+
// Properties
|
|
14
|
+
var isScanning: Bool { get }
|
|
15
|
+
|
|
16
|
+
// Methods
|
|
17
|
+
func scan(type: String, domain: String, options: ScanOptions?) throws -> Void
|
|
18
|
+
func stop() throws -> Void
|
|
19
|
+
func listenForScanResults(onResult: @escaping (_ results: [ScanResult]) -> Void) throws -> BonjourListener
|
|
20
|
+
func listenForScanState(onChange: @escaping (_ isScanning: Bool) -> Void) throws -> BonjourListener
|
|
21
|
+
func listenForScanFail(onFail: @escaping (_ fail: BonjourFail) -> Void) throws -> BonjourListener
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public extension HybridBonjourZeroconfSpec_protocol {
|
|
25
|
+
/// Default implementation of ``HybridObject.toString``
|
|
26
|
+
func toString() -> String {
|
|
27
|
+
return "[HybridObject BonjourZeroconf]"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// See ``HybridBonjourZeroconfSpec``
|
|
32
|
+
open class HybridBonjourZeroconfSpec_base {
|
|
33
|
+
private weak var cxxWrapper: HybridBonjourZeroconfSpec_cxx? = nil
|
|
34
|
+
public init() { }
|
|
35
|
+
public func getCxxWrapper() -> HybridBonjourZeroconfSpec_cxx {
|
|
36
|
+
#if DEBUG
|
|
37
|
+
guard self is HybridBonjourZeroconfSpec else {
|
|
38
|
+
fatalError("`self` is not a `HybridBonjourZeroconfSpec`! Did you accidentally inherit from `HybridBonjourZeroconfSpec_base` instead of `HybridBonjourZeroconfSpec`?")
|
|
39
|
+
}
|
|
40
|
+
#endif
|
|
41
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
42
|
+
return cxxWrapper
|
|
43
|
+
} else {
|
|
44
|
+
let cxxWrapper = HybridBonjourZeroconfSpec_cxx(self as! HybridBonjourZeroconfSpec)
|
|
45
|
+
self.cxxWrapper = cxxWrapper
|
|
46
|
+
return cxxWrapper
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A Swift base-protocol representing the BonjourZeroconf HybridObject.
|
|
53
|
+
* Implement this protocol to create Swift-based instances of BonjourZeroconf.
|
|
54
|
+
* ```swift
|
|
55
|
+
* class HybridBonjourZeroconf : HybridBonjourZeroconfSpec {
|
|
56
|
+
* // ...
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
public typealias HybridBonjourZeroconfSpec = HybridBonjourZeroconfSpec_protocol & HybridBonjourZeroconfSpec_base
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridBonjourZeroconfSpec_cxx.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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A class implementation that bridges HybridBonjourZeroconfSpec over to C++.
|
|
13
|
+
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
14
|
+
*
|
|
15
|
+
* Also, some Swift types need to be bridged with special handling:
|
|
16
|
+
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
17
|
+
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
18
|
+
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
19
|
+
*/
|
|
20
|
+
open class HybridBonjourZeroconfSpec_cxx {
|
|
21
|
+
/**
|
|
22
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::dawidzawada_bonjourzeroconf::bridge::swift`)
|
|
23
|
+
* from `BonjourZeroconf-Swift-Cxx-Bridge.hpp`.
|
|
24
|
+
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
25
|
+
*/
|
|
26
|
+
public typealias bridge = margelo.nitro.dawidzawada_bonjourzeroconf.bridge.swift
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Holds an instance of the `HybridBonjourZeroconfSpec` Swift protocol.
|
|
30
|
+
*/
|
|
31
|
+
private var __implementation: any HybridBonjourZeroconfSpec
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
35
|
+
*/
|
|
36
|
+
private var __cxxPart: bridge.std__weak_ptr_HybridBonjourZeroconfSpec_
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create a new `HybridBonjourZeroconfSpec_cxx` that wraps the given `HybridBonjourZeroconfSpec`.
|
|
40
|
+
* All properties and methods bridge to C++ types.
|
|
41
|
+
*/
|
|
42
|
+
public init(_ implementation: any HybridBonjourZeroconfSpec) {
|
|
43
|
+
self.__implementation = implementation
|
|
44
|
+
self.__cxxPart = .init()
|
|
45
|
+
/* no base class */
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get the actual `HybridBonjourZeroconfSpec` instance this class wraps.
|
|
50
|
+
*/
|
|
51
|
+
@inline(__always)
|
|
52
|
+
public func getHybridBonjourZeroconfSpec() -> any HybridBonjourZeroconfSpec {
|
|
53
|
+
return __implementation
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
58
|
+
* This acquires one additional strong reference on the object!
|
|
59
|
+
*/
|
|
60
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
61
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Casts an unsafe pointer to a `HybridBonjourZeroconfSpec_cxx`.
|
|
66
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridBonjourZeroconfSpec_cxx>`.
|
|
67
|
+
* This removes one strong reference from the object!
|
|
68
|
+
*/
|
|
69
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridBonjourZeroconfSpec_cxx {
|
|
70
|
+
return Unmanaged<HybridBonjourZeroconfSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
75
|
+
* The C++ part is a `std::shared_ptr<HybridBonjourZeroconfSpec>`.
|
|
76
|
+
*/
|
|
77
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridBonjourZeroconfSpec_ {
|
|
78
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
79
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
80
|
+
return cachedCxxPart
|
|
81
|
+
} else {
|
|
82
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridBonjourZeroconfSpec_(self.toUnsafe())
|
|
83
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridBonjourZeroconfSpec_(newCxxPart)
|
|
84
|
+
return newCxxPart
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
92
|
+
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
93
|
+
*/
|
|
94
|
+
@inline(__always)
|
|
95
|
+
public var memorySize: Int {
|
|
96
|
+
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Call dispose() on the Swift class.
|
|
101
|
+
* This _may_ be called manually from JS.
|
|
102
|
+
*/
|
|
103
|
+
@inline(__always)
|
|
104
|
+
public func dispose() {
|
|
105
|
+
self.__implementation.dispose()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Call toString() on the Swift class.
|
|
110
|
+
*/
|
|
111
|
+
@inline(__always)
|
|
112
|
+
public func toString() -> String {
|
|
113
|
+
return self.__implementation.toString()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Properties
|
|
117
|
+
public final var isScanning: Bool {
|
|
118
|
+
@inline(__always)
|
|
119
|
+
get {
|
|
120
|
+
return self.__implementation.isScanning
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Methods
|
|
125
|
+
@inline(__always)
|
|
126
|
+
public final func scan(type: std.string, domain: std.string, options: bridge.std__optional_ScanOptions_) -> bridge.Result_void_ {
|
|
127
|
+
do {
|
|
128
|
+
try self.__implementation.scan(type: String(type), domain: String(domain), options: options.value)
|
|
129
|
+
return bridge.create_Result_void_()
|
|
130
|
+
} catch (let __error) {
|
|
131
|
+
let __exceptionPtr = __error.toCpp()
|
|
132
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@inline(__always)
|
|
137
|
+
public final func stop() -> bridge.Result_void_ {
|
|
138
|
+
do {
|
|
139
|
+
try self.__implementation.stop()
|
|
140
|
+
return bridge.create_Result_void_()
|
|
141
|
+
} catch (let __error) {
|
|
142
|
+
let __exceptionPtr = __error.toCpp()
|
|
143
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@inline(__always)
|
|
148
|
+
public final func listenForScanResults(onResult: bridge.Func_void_std__vector_ScanResult_) -> bridge.Result_BonjourListener_ {
|
|
149
|
+
do {
|
|
150
|
+
let __result = try self.__implementation.listenForScanResults(onResult: { () -> ([ScanResult]) -> Void in
|
|
151
|
+
let __wrappedFunction = bridge.wrap_Func_void_std__vector_ScanResult_(onResult)
|
|
152
|
+
return { (__results: [ScanResult]) -> Void in
|
|
153
|
+
__wrappedFunction.call({ () -> bridge.std__vector_ScanResult_ in
|
|
154
|
+
var __vector = bridge.create_std__vector_ScanResult_(__results.count)
|
|
155
|
+
for __item in __results {
|
|
156
|
+
__vector.push_back(__item)
|
|
157
|
+
}
|
|
158
|
+
return __vector
|
|
159
|
+
}())
|
|
160
|
+
}
|
|
161
|
+
}())
|
|
162
|
+
let __resultCpp = __result
|
|
163
|
+
return bridge.create_Result_BonjourListener_(__resultCpp)
|
|
164
|
+
} catch (let __error) {
|
|
165
|
+
let __exceptionPtr = __error.toCpp()
|
|
166
|
+
return bridge.create_Result_BonjourListener_(__exceptionPtr)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
@inline(__always)
|
|
171
|
+
public final func listenForScanState(onChange: bridge.Func_void_bool) -> bridge.Result_BonjourListener_ {
|
|
172
|
+
do {
|
|
173
|
+
let __result = try self.__implementation.listenForScanState(onChange: { () -> (Bool) -> Void in
|
|
174
|
+
let __wrappedFunction = bridge.wrap_Func_void_bool(onChange)
|
|
175
|
+
return { (__isScanning: Bool) -> Void in
|
|
176
|
+
__wrappedFunction.call(__isScanning)
|
|
177
|
+
}
|
|
178
|
+
}())
|
|
179
|
+
let __resultCpp = __result
|
|
180
|
+
return bridge.create_Result_BonjourListener_(__resultCpp)
|
|
181
|
+
} catch (let __error) {
|
|
182
|
+
let __exceptionPtr = __error.toCpp()
|
|
183
|
+
return bridge.create_Result_BonjourListener_(__exceptionPtr)
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
@inline(__always)
|
|
188
|
+
public final func listenForScanFail(onFail: bridge.Func_void_BonjourFail) -> bridge.Result_BonjourListener_ {
|
|
189
|
+
do {
|
|
190
|
+
let __result = try self.__implementation.listenForScanFail(onFail: { () -> (BonjourFail) -> Void in
|
|
191
|
+
let __wrappedFunction = bridge.wrap_Func_void_BonjourFail(onFail)
|
|
192
|
+
return { (__fail: BonjourFail) -> Void in
|
|
193
|
+
__wrappedFunction.call(__fail.rawValue)
|
|
194
|
+
}
|
|
195
|
+
}())
|
|
196
|
+
let __resultCpp = __result
|
|
197
|
+
return bridge.create_Result_BonjourListener_(__resultCpp)
|
|
198
|
+
} catch (let __error) {
|
|
199
|
+
let __exceptionPtr = __error.toCpp()
|
|
200
|
+
return bridge.create_Result_BonjourListener_(__exceptionPtr)
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridLocalNetworkPermissionSpec.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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/// See ``HybridLocalNetworkPermissionSpec``
|
|
12
|
+
public protocol HybridLocalNetworkPermissionSpec_protocol: HybridObject {
|
|
13
|
+
// Properties
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// Methods
|
|
17
|
+
func requestPermission() throws -> Promise<Bool>
|
|
18
|
+
func listenForPermission(onChange: @escaping (_ granted: Bool) -> Void) throws -> BonjourListener
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public extension HybridLocalNetworkPermissionSpec_protocol {
|
|
22
|
+
/// Default implementation of ``HybridObject.toString``
|
|
23
|
+
func toString() -> String {
|
|
24
|
+
return "[HybridObject LocalNetworkPermission]"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/// See ``HybridLocalNetworkPermissionSpec``
|
|
29
|
+
open class HybridLocalNetworkPermissionSpec_base {
|
|
30
|
+
private weak var cxxWrapper: HybridLocalNetworkPermissionSpec_cxx? = nil
|
|
31
|
+
public init() { }
|
|
32
|
+
public func getCxxWrapper() -> HybridLocalNetworkPermissionSpec_cxx {
|
|
33
|
+
#if DEBUG
|
|
34
|
+
guard self is HybridLocalNetworkPermissionSpec else {
|
|
35
|
+
fatalError("`self` is not a `HybridLocalNetworkPermissionSpec`! Did you accidentally inherit from `HybridLocalNetworkPermissionSpec_base` instead of `HybridLocalNetworkPermissionSpec`?")
|
|
36
|
+
}
|
|
37
|
+
#endif
|
|
38
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
39
|
+
return cxxWrapper
|
|
40
|
+
} else {
|
|
41
|
+
let cxxWrapper = HybridLocalNetworkPermissionSpec_cxx(self as! HybridLocalNetworkPermissionSpec)
|
|
42
|
+
self.cxxWrapper = cxxWrapper
|
|
43
|
+
return cxxWrapper
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A Swift base-protocol representing the LocalNetworkPermission HybridObject.
|
|
50
|
+
* Implement this protocol to create Swift-based instances of LocalNetworkPermission.
|
|
51
|
+
* ```swift
|
|
52
|
+
* class HybridLocalNetworkPermission : HybridLocalNetworkPermissionSpec {
|
|
53
|
+
* // ...
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
public typealias HybridLocalNetworkPermissionSpec = HybridLocalNetworkPermissionSpec_protocol & HybridLocalNetworkPermissionSpec_base
|