munim-wifi 0.1.0 → 0.1.2

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 (37) hide show
  1. package/README.md +132 -8
  2. package/ios/HybridMunimWifi.swift +248 -155
  3. package/lib/typescript/src/specs/munim-wifi.nitro.d.ts +47 -5
  4. package/lib/typescript/src/specs/munim-wifi.nitro.d.ts.map +1 -1
  5. package/nitrogen/generated/android/MunimWifi+autolinking.cmake +1 -0
  6. package/nitrogen/generated/android/c++/JConnectionOptions.hpp +66 -0
  7. package/nitrogen/generated/android/c++/JCurrentNetworkInfo.hpp +97 -0
  8. package/nitrogen/generated/android/c++/JHybridMunimWifiSpec.cpp +72 -0
  9. package/nitrogen/generated/android/c++/JHybridMunimWifiSpec.hpp +4 -0
  10. package/nitrogen/generated/android/c++/JVariant_NullType_CurrentNetworkInfo.cpp +26 -0
  11. package/nitrogen/generated/android/c++/JVariant_NullType_CurrentNetworkInfo.hpp +74 -0
  12. package/nitrogen/generated/android/c++/JWifiNetwork.hpp +9 -9
  13. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/ConnectionOptions.kt +44 -0
  14. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/CurrentNetworkInfo.kt +53 -0
  15. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/HybridMunimWifiSpec.kt +16 -0
  16. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/Variant_NullType_CurrentNetworkInfo.kt +59 -0
  17. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/WifiNetwork.kt +3 -3
  18. package/nitrogen/generated/ios/MunimWifi-Swift-Cxx-Bridge.cpp +16 -0
  19. package/nitrogen/generated/ios/MunimWifi-Swift-Cxx-Bridge.hpp +133 -0
  20. package/nitrogen/generated/ios/MunimWifi-Swift-Cxx-Umbrella.hpp +6 -0
  21. package/nitrogen/generated/ios/c++/HybridMunimWifiSpecSwift.hpp +38 -0
  22. package/nitrogen/generated/ios/swift/ConnectionOptions.swift +66 -0
  23. package/nitrogen/generated/ios/swift/CurrentNetworkInfo.swift +113 -0
  24. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  25. package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__CurrentNetworkInfo_.swift +59 -0
  26. package/nitrogen/generated/ios/swift/HybridMunimWifiSpec.swift +4 -0
  27. package/nitrogen/generated/ios/swift/HybridMunimWifiSpec_cxx.swift +90 -0
  28. package/nitrogen/generated/ios/swift/Variant_NullType_CurrentNetworkInfo.swift +18 -0
  29. package/nitrogen/generated/ios/swift/WifiNetwork.swift +18 -6
  30. package/nitrogen/generated/shared/c++/ConnectionOptions.hpp +92 -0
  31. package/nitrogen/generated/shared/c++/CurrentNetworkInfo.hpp +105 -0
  32. package/nitrogen/generated/shared/c++/HybridMunimWifiSpec.cpp +4 -0
  33. package/nitrogen/generated/shared/c++/HybridMunimWifiSpec.hpp +10 -0
  34. package/nitrogen/generated/shared/c++/WifiNetwork.hpp +9 -9
  35. package/package.json +2 -2
  36. package/src/index.ts +45 -0
  37. package/src/specs/munim-wifi.nitro.ts +56 -6
@@ -0,0 +1,59 @@
1
+ ///
2
+ /// Variant_NullType_CurrentNetworkInfo.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.munimwifi
9
+
10
+ import com.facebook.proguard.annotations.DoNotStrip
11
+ import com.margelo.nitro.core.NullType
12
+
13
+ /**
14
+ * Represents the TypeScript variant "NullType | CurrentNetworkInfo".
15
+ */
16
+ @Suppress("ClassName")
17
+ @DoNotStrip
18
+ sealed class Variant_NullType_CurrentNetworkInfo {
19
+ @DoNotStrip
20
+ data class First(@DoNotStrip val value: NullType): Variant_NullType_CurrentNetworkInfo()
21
+ @DoNotStrip
22
+ data class Second(@DoNotStrip val value: CurrentNetworkInfo): Variant_NullType_CurrentNetworkInfo()
23
+
24
+ @Deprecated("getAs() is not type-safe. Use fold/asFirstOrNull/asSecondOrNull instead.", level = DeprecationLevel.ERROR)
25
+ inline fun <reified T> getAs(): T? = when (this) {
26
+ is First -> value as? T
27
+ is Second -> value as? T
28
+ }
29
+
30
+ val isFirst: Boolean
31
+ get() = this is First
32
+ val isSecond: Boolean
33
+ get() = this is Second
34
+
35
+ fun asFirstOrNull(): NullType? {
36
+ val value = (this as? First)?.value ?: return null
37
+ return value
38
+ }
39
+ fun asSecondOrNull(): CurrentNetworkInfo? {
40
+ val value = (this as? Second)?.value ?: return null
41
+ return value
42
+ }
43
+
44
+ inline fun <R> match(first: (NullType) -> R, second: (CurrentNetworkInfo) -> R): R {
45
+ return when (this) {
46
+ is First -> first(value)
47
+ is Second -> second(value)
48
+ }
49
+ }
50
+
51
+ companion object {
52
+ @JvmStatic
53
+ @DoNotStrip
54
+ fun create(value: NullType): Variant_NullType_CurrentNetworkInfo = First(value)
55
+ @JvmStatic
56
+ @DoNotStrip
57
+ fun create(value: CurrentNetworkInfo): Variant_NullType_CurrentNetworkInfo = Second(value)
58
+ }
59
+ }
@@ -25,10 +25,10 @@ data class WifiNetwork(
25
25
  val bssid: String,
26
26
  @DoNotStrip
27
27
  @Keep
28
- val rssi: Double,
28
+ val rssi: Double?,
29
29
  @DoNotStrip
30
30
  @Keep
31
- val frequency: Double,
31
+ val frequency: Double?,
32
32
  @DoNotStrip
33
33
  @Keep
34
34
  val channel: Double?,
@@ -52,7 +52,7 @@ data class WifiNetwork(
52
52
  @Keep
53
53
  @Suppress("unused")
54
54
  @JvmStatic
55
- private fun fromCpp(ssid: String, bssid: String, rssi: Double, frequency: Double, channel: Double?, capabilities: String?, isSecure: Boolean?, timestamp: Double?): WifiNetwork {
55
+ private fun fromCpp(ssid: String, bssid: String, rssi: Double?, frequency: Double?, channel: Double?, capabilities: String?, isSecure: Boolean?, timestamp: Double?): WifiNetwork {
56
56
  return WifiNetwork(ssid, bssid, rssi, frequency, channel, capabilities, isSecure, timestamp)
57
57
  }
58
58
  }
@@ -86,6 +86,22 @@ namespace margelo::nitro::munimwifi::bridge::swift {
86
86
  };
87
87
  }
88
88
 
89
+ // pragma MARK: std::function<void(const std::variant<nitro::NullType, CurrentNetworkInfo>& /* result */)>
90
+ Func_void_std__variant_nitro__NullType__CurrentNetworkInfo_ create_Func_void_std__variant_nitro__NullType__CurrentNetworkInfo_(void* NON_NULL swiftClosureWrapper) noexcept {
91
+ auto swiftClosure = MunimWifi::Func_void_std__variant_nitro__NullType__CurrentNetworkInfo_::fromUnsafe(swiftClosureWrapper);
92
+ return [swiftClosure = std::move(swiftClosure)](const std::variant<nitro::NullType, CurrentNetworkInfo>& result) mutable -> void {
93
+ swiftClosure.call(result);
94
+ };
95
+ }
96
+
97
+ // pragma MARK: std::function<void()>
98
+ Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
99
+ auto swiftClosure = MunimWifi::Func_void::fromUnsafe(swiftClosureWrapper);
100
+ return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
101
+ swiftClosure.call();
102
+ };
103
+ }
104
+
89
105
  // pragma MARK: std::shared_ptr<HybridMunimWifiSpec>
90
106
  std::shared_ptr<HybridMunimWifiSpec> create_std__shared_ptr_HybridMunimWifiSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
91
107
  MunimWifi::HybridMunimWifiSpec_cxx swiftPart = MunimWifi::HybridMunimWifiSpec_cxx::fromUnsafe(swiftUnsafePointer);
@@ -10,6 +10,8 @@
10
10
  // Forward declarations of C++ defined types
11
11
  // Forward declaration of `ChannelInfo` to properly resolve imports.
12
12
  namespace margelo::nitro::munimwifi { struct ChannelInfo; }
13
+ // Forward declaration of `CurrentNetworkInfo` to properly resolve imports.
14
+ namespace margelo::nitro::munimwifi { struct CurrentNetworkInfo; }
13
15
  // Forward declaration of `HybridMunimWifiSpec` to properly resolve imports.
14
16
  namespace margelo::nitro::munimwifi { class HybridMunimWifiSpec; }
15
17
  // Forward declaration of `Location` to properly resolve imports.
@@ -27,6 +29,7 @@ namespace MunimWifi { class HybridMunimWifiSpec_cxx; }
27
29
 
28
30
  // Include C++ defined types
29
31
  #include "ChannelInfo.hpp"
32
+ #include "CurrentNetworkInfo.hpp"
30
33
  #include "HybridMunimWifiSpec.hpp"
31
34
  #include "Location.hpp"
32
35
  #include "ScanOptions.hpp"
@@ -557,6 +560,118 @@ namespace margelo::nitro::munimwifi::bridge::swift {
557
560
  return Func_void_std__variant_nitro__NullType__WifiNetwork__Wrapper(std::move(value));
558
561
  }
559
562
 
563
+ // pragma MARK: std::optional<std::vector<std::string>>
564
+ /**
565
+ * Specialized version of `std::optional<std::vector<std::string>>`.
566
+ */
567
+ using std__optional_std__vector_std__string__ = std::optional<std::vector<std::string>>;
568
+ inline std::optional<std::vector<std::string>> create_std__optional_std__vector_std__string__(const std::vector<std::string>& value) noexcept {
569
+ return std::optional<std::vector<std::string>>(value);
570
+ }
571
+ inline bool has_value_std__optional_std__vector_std__string__(const std::optional<std::vector<std::string>>& optional) noexcept {
572
+ return optional.has_value();
573
+ }
574
+ inline std::vector<std::string> get_std__optional_std__vector_std__string__(const std::optional<std::vector<std::string>>& optional) noexcept {
575
+ return *optional;
576
+ }
577
+
578
+ // pragma MARK: std::variant<nitro::NullType, CurrentNetworkInfo>
579
+ /**
580
+ * Wrapper struct for `std::variant<nitro::NullType, CurrentNetworkInfo>`.
581
+ * std::variant cannot be used in Swift because of a Swift bug.
582
+ * Not even specializing it works. So we create a wrapper struct.
583
+ */
584
+ struct std__variant_nitro__NullType__CurrentNetworkInfo_ final {
585
+ std::variant<nitro::NullType, CurrentNetworkInfo> variant;
586
+ std__variant_nitro__NullType__CurrentNetworkInfo_(std::variant<nitro::NullType, CurrentNetworkInfo> variant): variant(variant) { }
587
+ operator std::variant<nitro::NullType, CurrentNetworkInfo>() const noexcept {
588
+ return variant;
589
+ }
590
+ inline size_t index() const noexcept {
591
+ return variant.index();
592
+ }
593
+ inline nitro::NullType get_0() const noexcept {
594
+ return std::get<0>(variant);
595
+ }
596
+ inline CurrentNetworkInfo get_1() const noexcept {
597
+ return std::get<1>(variant);
598
+ }
599
+ };
600
+ inline std__variant_nitro__NullType__CurrentNetworkInfo_ create_std__variant_nitro__NullType__CurrentNetworkInfo_(nitro::NullType value) noexcept {
601
+ return std__variant_nitro__NullType__CurrentNetworkInfo_(value);
602
+ }
603
+ inline std__variant_nitro__NullType__CurrentNetworkInfo_ create_std__variant_nitro__NullType__CurrentNetworkInfo_(const CurrentNetworkInfo& value) noexcept {
604
+ return std__variant_nitro__NullType__CurrentNetworkInfo_(value);
605
+ }
606
+
607
+ // pragma MARK: std::shared_ptr<Promise<std::variant<nitro::NullType, CurrentNetworkInfo>>>
608
+ /**
609
+ * Specialized version of `std::shared_ptr<Promise<std::variant<nitro::NullType, CurrentNetworkInfo>>>`.
610
+ */
611
+ using std__shared_ptr_Promise_std__variant_nitro__NullType__CurrentNetworkInfo___ = std::shared_ptr<Promise<std::variant<nitro::NullType, CurrentNetworkInfo>>>;
612
+ inline std::shared_ptr<Promise<std::variant<nitro::NullType, CurrentNetworkInfo>>> create_std__shared_ptr_Promise_std__variant_nitro__NullType__CurrentNetworkInfo___() noexcept {
613
+ return Promise<std::variant<nitro::NullType, CurrentNetworkInfo>>::create();
614
+ }
615
+ inline PromiseHolder<std::variant<nitro::NullType, CurrentNetworkInfo>> wrap_std__shared_ptr_Promise_std__variant_nitro__NullType__CurrentNetworkInfo___(std::shared_ptr<Promise<std::variant<nitro::NullType, CurrentNetworkInfo>>> promise) noexcept {
616
+ return PromiseHolder<std::variant<nitro::NullType, CurrentNetworkInfo>>(std::move(promise));
617
+ }
618
+
619
+ // pragma MARK: std::function<void(const std::variant<nitro::NullType, CurrentNetworkInfo>& /* result */)>
620
+ /**
621
+ * Specialized version of `std::function<void(const std::variant<nitro::NullType, CurrentNetworkInfo>&)>`.
622
+ */
623
+ using Func_void_std__variant_nitro__NullType__CurrentNetworkInfo_ = std::function<void(const std::variant<nitro::NullType, CurrentNetworkInfo>& /* result */)>;
624
+ /**
625
+ * Wrapper class for a `std::function<void(const std::variant<nitro::NullType, CurrentNetworkInfo>& / * result * /)>`, this can be used from Swift.
626
+ */
627
+ class Func_void_std__variant_nitro__NullType__CurrentNetworkInfo__Wrapper final {
628
+ public:
629
+ explicit Func_void_std__variant_nitro__NullType__CurrentNetworkInfo__Wrapper(std::function<void(const std::variant<nitro::NullType, CurrentNetworkInfo>& /* result */)>&& func): _function(std::make_unique<std::function<void(const std::variant<nitro::NullType, CurrentNetworkInfo>& /* result */)>>(std::move(func))) {}
630
+ inline void call(std::variant<nitro::NullType, CurrentNetworkInfo> result) const noexcept {
631
+ _function->operator()(result);
632
+ }
633
+ private:
634
+ std::unique_ptr<std::function<void(const std::variant<nitro::NullType, CurrentNetworkInfo>& /* result */)>> _function;
635
+ } SWIFT_NONCOPYABLE;
636
+ Func_void_std__variant_nitro__NullType__CurrentNetworkInfo_ create_Func_void_std__variant_nitro__NullType__CurrentNetworkInfo_(void* NON_NULL swiftClosureWrapper) noexcept;
637
+ inline Func_void_std__variant_nitro__NullType__CurrentNetworkInfo__Wrapper wrap_Func_void_std__variant_nitro__NullType__CurrentNetworkInfo_(Func_void_std__variant_nitro__NullType__CurrentNetworkInfo_ value) noexcept {
638
+ return Func_void_std__variant_nitro__NullType__CurrentNetworkInfo__Wrapper(std::move(value));
639
+ }
640
+
641
+ // pragma MARK: std::shared_ptr<Promise<void>>
642
+ /**
643
+ * Specialized version of `std::shared_ptr<Promise<void>>`.
644
+ */
645
+ using std__shared_ptr_Promise_void__ = std::shared_ptr<Promise<void>>;
646
+ inline std::shared_ptr<Promise<void>> create_std__shared_ptr_Promise_void__() noexcept {
647
+ return Promise<void>::create();
648
+ }
649
+ inline PromiseHolder<void> wrap_std__shared_ptr_Promise_void__(std::shared_ptr<Promise<void>> promise) noexcept {
650
+ return PromiseHolder<void>(std::move(promise));
651
+ }
652
+
653
+ // pragma MARK: std::function<void()>
654
+ /**
655
+ * Specialized version of `std::function<void()>`.
656
+ */
657
+ using Func_void = std::function<void()>;
658
+ /**
659
+ * Wrapper class for a `std::function<void()>`, this can be used from Swift.
660
+ */
661
+ class Func_void_Wrapper final {
662
+ public:
663
+ explicit Func_void_Wrapper(std::function<void()>&& func): _function(std::make_unique<std::function<void()>>(std::move(func))) {}
664
+ inline void call() const noexcept {
665
+ _function->operator()();
666
+ }
667
+ private:
668
+ std::unique_ptr<std::function<void()>> _function;
669
+ } SWIFT_NONCOPYABLE;
670
+ Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept;
671
+ inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept {
672
+ return Func_void_Wrapper(std::move(value));
673
+ }
674
+
560
675
  // pragma MARK: std::shared_ptr<HybridMunimWifiSpec>
561
676
  /**
562
677
  * Specialized version of `std::shared_ptr<HybridMunimWifiSpec>`.
@@ -649,5 +764,23 @@ namespace margelo::nitro::munimwifi::bridge::swift {
649
764
  inline Result_std__shared_ptr_Promise_std__variant_nitro__NullType__WifiNetwork____ create_Result_std__shared_ptr_Promise_std__variant_nitro__NullType__WifiNetwork____(const std::exception_ptr& error) noexcept {
650
765
  return Result<std::shared_ptr<Promise<std::variant<nitro::NullType, WifiNetwork>>>>::withError(error);
651
766
  }
767
+
768
+ // pragma MARK: Result<std::shared_ptr<Promise<std::variant<nitro::NullType, CurrentNetworkInfo>>>>
769
+ using Result_std__shared_ptr_Promise_std__variant_nitro__NullType__CurrentNetworkInfo____ = Result<std::shared_ptr<Promise<std::variant<nitro::NullType, CurrentNetworkInfo>>>>;
770
+ inline Result_std__shared_ptr_Promise_std__variant_nitro__NullType__CurrentNetworkInfo____ create_Result_std__shared_ptr_Promise_std__variant_nitro__NullType__CurrentNetworkInfo____(const std::shared_ptr<Promise<std::variant<nitro::NullType, CurrentNetworkInfo>>>& value) noexcept {
771
+ return Result<std::shared_ptr<Promise<std::variant<nitro::NullType, CurrentNetworkInfo>>>>::withValue(value);
772
+ }
773
+ inline Result_std__shared_ptr_Promise_std__variant_nitro__NullType__CurrentNetworkInfo____ create_Result_std__shared_ptr_Promise_std__variant_nitro__NullType__CurrentNetworkInfo____(const std::exception_ptr& error) noexcept {
774
+ return Result<std::shared_ptr<Promise<std::variant<nitro::NullType, CurrentNetworkInfo>>>>::withError(error);
775
+ }
776
+
777
+ // pragma MARK: Result<std::shared_ptr<Promise<void>>>
778
+ using Result_std__shared_ptr_Promise_void___ = Result<std::shared_ptr<Promise<void>>>;
779
+ inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::shared_ptr<Promise<void>>& value) noexcept {
780
+ return Result<std::shared_ptr<Promise<void>>>::withValue(value);
781
+ }
782
+ inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::exception_ptr& error) noexcept {
783
+ return Result<std::shared_ptr<Promise<void>>>::withError(error);
784
+ }
652
785
 
653
786
  } // namespace margelo::nitro::munimwifi::bridge::swift
@@ -10,6 +10,10 @@
10
10
  // Forward declarations of C++ defined types
11
11
  // Forward declaration of `ChannelInfo` to properly resolve imports.
12
12
  namespace margelo::nitro::munimwifi { struct ChannelInfo; }
13
+ // Forward declaration of `ConnectionOptions` to properly resolve imports.
14
+ namespace margelo::nitro::munimwifi { struct ConnectionOptions; }
15
+ // Forward declaration of `CurrentNetworkInfo` to properly resolve imports.
16
+ namespace margelo::nitro::munimwifi { struct CurrentNetworkInfo; }
13
17
  // Forward declaration of `HybridMunimWifiSpec` to properly resolve imports.
14
18
  namespace margelo::nitro::munimwifi { class HybridMunimWifiSpec; }
15
19
  // Forward declaration of `Location` to properly resolve imports.
@@ -23,6 +27,8 @@ namespace margelo::nitro::munimwifi { struct WifiNetwork; }
23
27
 
24
28
  // Include C++ defined types
25
29
  #include "ChannelInfo.hpp"
30
+ #include "ConnectionOptions.hpp"
31
+ #include "CurrentNetworkInfo.hpp"
26
32
  #include "HybridMunimWifiSpec.hpp"
27
33
  #include "Location.hpp"
28
34
  #include "ScanOptions.hpp"
@@ -22,6 +22,10 @@ namespace margelo::nitro::munimwifi { struct WifiFingerprint; }
22
22
  namespace margelo::nitro::munimwifi { struct Location; }
23
23
  // Forward declaration of `ChannelInfo` to properly resolve imports.
24
24
  namespace margelo::nitro::munimwifi { struct ChannelInfo; }
25
+ // Forward declaration of `CurrentNetworkInfo` to properly resolve imports.
26
+ namespace margelo::nitro::munimwifi { struct CurrentNetworkInfo; }
27
+ // Forward declaration of `ConnectionOptions` to properly resolve imports.
28
+ namespace margelo::nitro::munimwifi { struct ConnectionOptions; }
25
29
 
26
30
  #include <NitroModules/Promise.hpp>
27
31
  #include "WifiNetwork.hpp"
@@ -34,6 +38,8 @@ namespace margelo::nitro::munimwifi { struct ChannelInfo; }
34
38
  #include <NitroModules/Null.hpp>
35
39
  #include <variant>
36
40
  #include "ChannelInfo.hpp"
41
+ #include "CurrentNetworkInfo.hpp"
42
+ #include "ConnectionOptions.hpp"
37
43
 
38
44
  #include "MunimWifi-Swift-Cxx-Umbrella.hpp"
39
45
 
@@ -169,6 +175,38 @@ namespace margelo::nitro::munimwifi {
169
175
  auto __value = std::move(__result.value());
170
176
  return __value;
171
177
  }
178
+ inline std::shared_ptr<Promise<std::variant<nitro::NullType, CurrentNetworkInfo>>> getCurrentNetwork() override {
179
+ auto __result = _swiftPart.getCurrentNetwork();
180
+ if (__result.hasError()) [[unlikely]] {
181
+ std::rethrow_exception(__result.error());
182
+ }
183
+ auto __value = std::move(__result.value());
184
+ return __value;
185
+ }
186
+ inline std::shared_ptr<Promise<void>> connectToNetwork(const ConnectionOptions& options) override {
187
+ auto __result = _swiftPart.connectToNetwork(std::forward<decltype(options)>(options));
188
+ if (__result.hasError()) [[unlikely]] {
189
+ std::rethrow_exception(__result.error());
190
+ }
191
+ auto __value = std::move(__result.value());
192
+ return __value;
193
+ }
194
+ inline std::shared_ptr<Promise<void>> disconnect() override {
195
+ auto __result = _swiftPart.disconnect();
196
+ if (__result.hasError()) [[unlikely]] {
197
+ std::rethrow_exception(__result.error());
198
+ }
199
+ auto __value = std::move(__result.value());
200
+ return __value;
201
+ }
202
+ inline std::shared_ptr<Promise<std::variant<nitro::NullType, std::string>>> getIPAddress() override {
203
+ auto __result = _swiftPart.getIPAddress();
204
+ if (__result.hasError()) [[unlikely]] {
205
+ std::rethrow_exception(__result.error());
206
+ }
207
+ auto __value = std::move(__result.value());
208
+ return __value;
209
+ }
172
210
  inline void addListener(const std::string& eventName) override {
173
211
  auto __result = _swiftPart.addListener(eventName);
174
212
  if (__result.hasError()) [[unlikely]] {
@@ -0,0 +1,66 @@
1
+ ///
2
+ /// ConnectionOptions.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Represents an instance of `ConnectionOptions`, backed by a C++ struct.
13
+ */
14
+ public typealias ConnectionOptions = margelo.nitro.munimwifi.ConnectionOptions
15
+
16
+ public extension ConnectionOptions {
17
+ private typealias bridge = margelo.nitro.munimwifi.bridge.swift
18
+
19
+ /**
20
+ * Create a new instance of `ConnectionOptions`.
21
+ */
22
+ init(ssid: String, password: String?, isWEP: Bool?) {
23
+ self.init(std.string(ssid), { () -> bridge.std__optional_std__string_ in
24
+ if let __unwrappedValue = password {
25
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
26
+ } else {
27
+ return .init()
28
+ }
29
+ }(), { () -> bridge.std__optional_bool_ in
30
+ if let __unwrappedValue = isWEP {
31
+ return bridge.create_std__optional_bool_(__unwrappedValue)
32
+ } else {
33
+ return .init()
34
+ }
35
+ }())
36
+ }
37
+
38
+ @inline(__always)
39
+ var ssid: String {
40
+ return String(self.__ssid)
41
+ }
42
+
43
+ @inline(__always)
44
+ var password: String? {
45
+ return { () -> String? in
46
+ if bridge.has_value_std__optional_std__string_(self.__password) {
47
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__password)
48
+ return String(__unwrapped)
49
+ } else {
50
+ return nil
51
+ }
52
+ }()
53
+ }
54
+
55
+ @inline(__always)
56
+ var isWEP: Bool? {
57
+ return { () -> Bool? in
58
+ if bridge.has_value_std__optional_bool_(self.__isWEP) {
59
+ let __unwrapped = bridge.get_std__optional_bool_(self.__isWEP)
60
+ return __unwrapped
61
+ } else {
62
+ return nil
63
+ }
64
+ }()
65
+ }
66
+ }
@@ -0,0 +1,113 @@
1
+ ///
2
+ /// CurrentNetworkInfo.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Represents an instance of `CurrentNetworkInfo`, backed by a C++ struct.
13
+ */
14
+ public typealias CurrentNetworkInfo = margelo.nitro.munimwifi.CurrentNetworkInfo
15
+
16
+ public extension CurrentNetworkInfo {
17
+ private typealias bridge = margelo.nitro.munimwifi.bridge.swift
18
+
19
+ /**
20
+ * Create a new instance of `CurrentNetworkInfo`.
21
+ */
22
+ init(ssid: String, bssid: String, ipAddress: String?, subnetMask: String?, gateway: String?, dnsServers: [String]?) {
23
+ self.init(std.string(ssid), std.string(bssid), { () -> bridge.std__optional_std__string_ in
24
+ if let __unwrappedValue = ipAddress {
25
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
26
+ } else {
27
+ return .init()
28
+ }
29
+ }(), { () -> bridge.std__optional_std__string_ in
30
+ if let __unwrappedValue = subnetMask {
31
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
32
+ } else {
33
+ return .init()
34
+ }
35
+ }(), { () -> bridge.std__optional_std__string_ in
36
+ if let __unwrappedValue = gateway {
37
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
38
+ } else {
39
+ return .init()
40
+ }
41
+ }(), { () -> bridge.std__optional_std__vector_std__string__ in
42
+ if let __unwrappedValue = dnsServers {
43
+ return bridge.create_std__optional_std__vector_std__string__({ () -> bridge.std__vector_std__string_ in
44
+ var __vector = bridge.create_std__vector_std__string_(__unwrappedValue.count)
45
+ for __item in __unwrappedValue {
46
+ __vector.push_back(std.string(__item))
47
+ }
48
+ return __vector
49
+ }())
50
+ } else {
51
+ return .init()
52
+ }
53
+ }())
54
+ }
55
+
56
+ @inline(__always)
57
+ var ssid: String {
58
+ return String(self.__ssid)
59
+ }
60
+
61
+ @inline(__always)
62
+ var bssid: String {
63
+ return String(self.__bssid)
64
+ }
65
+
66
+ @inline(__always)
67
+ var ipAddress: String? {
68
+ return { () -> String? in
69
+ if bridge.has_value_std__optional_std__string_(self.__ipAddress) {
70
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__ipAddress)
71
+ return String(__unwrapped)
72
+ } else {
73
+ return nil
74
+ }
75
+ }()
76
+ }
77
+
78
+ @inline(__always)
79
+ var subnetMask: String? {
80
+ return { () -> String? in
81
+ if bridge.has_value_std__optional_std__string_(self.__subnetMask) {
82
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__subnetMask)
83
+ return String(__unwrapped)
84
+ } else {
85
+ return nil
86
+ }
87
+ }()
88
+ }
89
+
90
+ @inline(__always)
91
+ var gateway: String? {
92
+ return { () -> String? in
93
+ if bridge.has_value_std__optional_std__string_(self.__gateway) {
94
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__gateway)
95
+ return String(__unwrapped)
96
+ } else {
97
+ return nil
98
+ }
99
+ }()
100
+ }
101
+
102
+ @inline(__always)
103
+ var dnsServers: [String]? {
104
+ return { () -> [String]? in
105
+ if bridge.has_value_std__optional_std__vector_std__string__(self.__dnsServers) {
106
+ let __unwrapped = bridge.get_std__optional_std__vector_std__string__(self.__dnsServers)
107
+ return __unwrapped.map({ __item in String(__item) })
108
+ } else {
109
+ return nil
110
+ }
111
+ }()
112
+ }
113
+ }
@@ -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 © 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.munimwifi.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,59 @@
1
+ ///
2
+ /// Func_void_std__variant_nitro__NullType__CurrentNetworkInfo_.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Wraps a Swift `(_ value: Variant_NullType_CurrentNetworkInfo) -> 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__variant_nitro__NullType__CurrentNetworkInfo_ {
16
+ public typealias bridge = margelo.nitro.munimwifi.bridge.swift
17
+
18
+ private let closure: (_ value: Variant_NullType_CurrentNetworkInfo) -> Void
19
+
20
+ public init(_ closure: @escaping (_ value: Variant_NullType_CurrentNetworkInfo) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(value: bridge.std__variant_nitro__NullType__CurrentNetworkInfo_) -> Void {
26
+ self.closure({ () -> Variant_NullType_CurrentNetworkInfo in
27
+ let __variant = value
28
+ switch __variant.index() {
29
+ case 0:
30
+ let __actual = __variant.get_0()
31
+ return .first(NullType.null)
32
+ case 1:
33
+ let __actual = __variant.get_1()
34
+ return .second(__actual)
35
+ default:
36
+ fatalError("Variant can never have index \(__variant.index())!")
37
+ }
38
+ }())
39
+ }
40
+
41
+ /**
42
+ * Casts this instance to a retained unsafe raw pointer.
43
+ * This acquires one additional strong reference on the object!
44
+ */
45
+ @inline(__always)
46
+ public func toUnsafe() -> UnsafeMutableRawPointer {
47
+ return Unmanaged.passRetained(self).toOpaque()
48
+ }
49
+
50
+ /**
51
+ * Casts an unsafe pointer to a `Func_void_std__variant_nitro__NullType__CurrentNetworkInfo_`.
52
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__variant_nitro__NullType__CurrentNetworkInfo_>`.
53
+ * This removes one strong reference from the object!
54
+ */
55
+ @inline(__always)
56
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__variant_nitro__NullType__CurrentNetworkInfo_ {
57
+ return Unmanaged<Func_void_std__variant_nitro__NullType__CurrentNetworkInfo_>.fromOpaque(pointer).takeRetainedValue()
58
+ }
59
+ }
@@ -25,6 +25,10 @@ public protocol HybridMunimWifiSpec_protocol: HybridObject {
25
25
  func getBSSID(ssid: String) throws -> Promise<Variant_NullType_String>
26
26
  func getChannelInfo(ssid: String) throws -> Promise<Variant_NullType_ChannelInfo>
27
27
  func getNetworkInfo(ssid: String) throws -> Promise<Variant_NullType_WifiNetwork>
28
+ func getCurrentNetwork() throws -> Promise<Variant_NullType_CurrentNetworkInfo>
29
+ func connectToNetwork(options: ConnectionOptions) throws -> Promise<Void>
30
+ func disconnect() throws -> Promise<Void>
31
+ func getIPAddress() throws -> Promise<Variant_NullType_String>
28
32
  func addListener(eventName: String) throws -> Void
29
33
  func removeListeners(count: Double) throws -> Void
30
34
  }