react-native-nitro-geolocation 0.1.1 → 0.2.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 (128) hide show
  1. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/GetCurrentPosition.kt +4 -4
  2. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/NitroGeolocation.kt +642 -50
  3. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/NitroGeolocationCompat.kt +81 -0
  4. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/WatchPosition.kt +4 -4
  5. package/ios/LocationManager.swift +113 -128
  6. package/ios/NitroGeolocation.swift +546 -61
  7. package/ios/NitroGeolocationCompat.swift +109 -0
  8. package/nitrogen/generated/android/c++/JAuthorizationLevel.hpp +61 -0
  9. package/nitrogen/generated/android/c++/JAuthorizationLevelInternal.hpp +3 -4
  10. package/nitrogen/generated/android/c++/JFunc_void.hpp +2 -1
  11. package/nitrogen/generated/android/c++/JFunc_void_GeolocationError.hpp +2 -1
  12. package/nitrogen/generated/android/c++/JFunc_void_GeolocationResponse.hpp +6 -1
  13. package/nitrogen/generated/android/c++/JFunc_void_LocationError.hpp +78 -0
  14. package/nitrogen/generated/android/c++/JGeolocationCoordinates.hpp +25 -17
  15. package/nitrogen/generated/android/c++/JGeolocationError.hpp +5 -1
  16. package/nitrogen/generated/android/c++/JGeolocationOptions.hpp +5 -1
  17. package/nitrogen/generated/android/c++/JGeolocationResponse.hpp +9 -1
  18. package/nitrogen/generated/android/c++/JHybridNitroGeolocationCompatSpec.cpp +109 -0
  19. package/nitrogen/generated/android/c++/JHybridNitroGeolocationCompatSpec.hpp +70 -0
  20. package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.cpp +98 -42
  21. package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.hpp +7 -5
  22. package/nitrogen/generated/android/c++/JLocationError.hpp +61 -0
  23. package/nitrogen/generated/android/c++/JLocationProvider.hpp +61 -0
  24. package/nitrogen/generated/android/c++/JLocationProviderInternal.hpp +3 -4
  25. package/nitrogen/generated/android/c++/JLocationRequestOptions.hpp +81 -0
  26. package/nitrogen/generated/android/c++/JModernGeolocationConfiguration.hpp +73 -0
  27. package/nitrogen/generated/android/c++/JNullableDouble.cpp +26 -0
  28. package/nitrogen/generated/android/c++/JNullableDouble.hpp +69 -0
  29. package/nitrogen/generated/android/c++/JPermissionStatus.hpp +64 -0
  30. package/nitrogen/generated/android/c++/JRNConfigurationInternal.hpp +5 -1
  31. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AuthorizationLevel.kt +24 -0
  32. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AuthorizationLevelInternal.kt +2 -0
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void.kt +0 -1
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_GeolocationError.kt +0 -1
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_GeolocationResponse.kt +0 -1
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_LocationError.kt +80 -0
  37. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationCoordinates.kt +34 -25
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationError.kt +27 -18
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationOptions.kt +33 -24
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationResponse.kt +18 -9
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HybridNitroGeolocationCompatSpec.kt +92 -0
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HybridNitroGeolocationSpec.kt +17 -17
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationError.kt +41 -0
  44. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationProvider.kt +24 -0
  45. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationProviderInternal.kt +2 -0
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationRequestOptions.kt +56 -0
  47. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/ModernGeolocationConfiguration.kt +47 -0
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/NullableDouble.kt +59 -0
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/PermissionStatus.kt +25 -0
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/RNConfigurationInternal.kt +24 -15
  51. package/nitrogen/generated/android/nitrogeolocation+autolinking.cmake +3 -0
  52. package/nitrogen/generated/android/nitrogeolocationOnLoad.cpp +14 -2
  53. package/nitrogen/generated/ios/NitroGeolocation+autolinking.rb +1 -1
  54. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.cpp +55 -13
  55. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.hpp +325 -68
  56. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Umbrella.hpp +26 -0
  57. package/nitrogen/generated/ios/NitroGeolocationAutolinking.mm +8 -0
  58. package/nitrogen/generated/ios/NitroGeolocationAutolinking.swift +15 -0
  59. package/nitrogen/generated/ios/c++/HybridNitroGeolocationCompatSpecSwift.cpp +11 -0
  60. package/nitrogen/generated/ios/c++/HybridNitroGeolocationCompatSpecSwift.hpp +130 -0
  61. package/nitrogen/generated/ios/c++/HybridNitroGeolocationSpecSwift.hpp +47 -26
  62. package/nitrogen/generated/ios/swift/AuthorizationLevel.swift +44 -0
  63. package/nitrogen/generated/ios/swift/Func_void.swift +1 -1
  64. package/nitrogen/generated/ios/swift/Func_void_GeolocationError.swift +1 -1
  65. package/nitrogen/generated/ios/swift/Func_void_GeolocationResponse.swift +1 -1
  66. package/nitrogen/generated/ios/swift/Func_void_LocationError.swift +47 -0
  67. package/nitrogen/generated/ios/swift/Func_void_PermissionStatus.swift +47 -0
  68. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  69. package/nitrogen/generated/ios/swift/GeolocationCoordinates.swift +132 -93
  70. package/nitrogen/generated/ios/swift/GeolocationError.swift +11 -40
  71. package/nitrogen/generated/ios/swift/GeolocationOptions.swift +29 -98
  72. package/nitrogen/generated/ios/swift/GeolocationResponse.swift +5 -16
  73. package/nitrogen/generated/ios/swift/HybridNitroGeolocationCompatSpec.swift +61 -0
  74. package/nitrogen/generated/ios/swift/HybridNitroGeolocationCompatSpec_cxx.swift +244 -0
  75. package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec.swift +13 -5
  76. package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec_cxx.swift +66 -64
  77. package/nitrogen/generated/ios/swift/LocationError.swift +35 -0
  78. package/nitrogen/generated/ios/swift/LocationProvider.swift +44 -0
  79. package/nitrogen/generated/ios/swift/LocationRequestOptions.swift +116 -0
  80. package/nitrogen/generated/ios/swift/ModernGeolocationConfiguration.swift +83 -0
  81. package/nitrogen/generated/ios/swift/NullableDouble.swift +18 -0
  82. package/nitrogen/generated/ios/swift/PermissionStatus.swift +48 -0
  83. package/nitrogen/generated/ios/swift/RNConfigurationInternal.swift +16 -50
  84. package/nitrogen/generated/shared/c++/AuthorizationLevel.hpp +80 -0
  85. package/nitrogen/generated/shared/c++/GeolocationCoordinates.hpp +45 -27
  86. package/nitrogen/generated/shared/c++/GeolocationError.hpp +32 -16
  87. package/nitrogen/generated/shared/c++/GeolocationOptions.hpp +38 -22
  88. package/nitrogen/generated/shared/c++/GeolocationResponse.hpp +23 -7
  89. package/nitrogen/generated/shared/c++/HybridNitroGeolocationCompatSpec.cpp +26 -0
  90. package/nitrogen/generated/shared/c++/HybridNitroGeolocationCompatSpec.hpp +79 -0
  91. package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.cpp +4 -3
  92. package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.hpp +22 -16
  93. package/nitrogen/generated/shared/c++/LocationError.hpp +87 -0
  94. package/nitrogen/generated/shared/c++/LocationProvider.hpp +80 -0
  95. package/nitrogen/generated/shared/c++/LocationRequestOptions.hpp +107 -0
  96. package/nitrogen/generated/shared/c++/ModernGeolocationConfiguration.hpp +100 -0
  97. package/nitrogen/generated/shared/c++/PermissionStatus.hpp +84 -0
  98. package/nitrogen/generated/shared/c++/RNConfigurationInternal.hpp +29 -13
  99. package/package.json +16 -7
  100. package/src/GeolocationClient.ts +116 -0
  101. package/src/NitroGeolocation.nitro.ts +177 -30
  102. package/src/NitroGeolocationCompat.nitro.ts +41 -0
  103. package/src/NitroGeolocationModule.ts +6 -0
  104. package/src/compat/clearWatch.ts +9 -0
  105. package/src/{getCurrentPosition.ts → compat/getCurrentPosition.ts} +7 -3
  106. package/src/compat/index.tsx +34 -0
  107. package/src/compat/requestAuthorization.ts +9 -0
  108. package/src/{setRNConfiguration.ts → compat/setRNConfiguration.ts} +6 -4
  109. package/src/{stopObserving.ts → compat/stopObserving.ts} +4 -2
  110. package/src/{watchPosition.ts → compat/watchPosition.ts} +7 -6
  111. package/src/components/GeolocationProvider.tsx +91 -0
  112. package/src/components/index.ts +13 -0
  113. package/src/hooks/index.ts +9 -0
  114. package/src/hooks/useCheckPermission.ts +46 -0
  115. package/src/hooks/useGetCurrentPosition.ts +44 -0
  116. package/src/hooks/useRequestPermission.ts +38 -0
  117. package/src/hooks/useWatchPosition.ts +127 -0
  118. package/src/index.tsx +72 -27
  119. package/src/types.ts +32 -4
  120. package/src/utils/cache.ts +25 -0
  121. package/src/utils/config.ts +93 -0
  122. package/src/utils/errors.ts +82 -0
  123. package/src/utils/index.ts +27 -0
  124. package/src/utils/provider.ts +61 -0
  125. package/src/utils/quality.ts +98 -0
  126. package/README.md +0 -318
  127. package/src/clearWatch.ts +0 -13
  128. package/src/requestAuthorization.ts +0 -9
@@ -0,0 +1,130 @@
1
+ ///
2
+ /// HybridNitroGeolocationCompatSpecSwift.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include "HybridNitroGeolocationCompatSpec.hpp"
11
+
12
+ // Forward declaration of `HybridNitroGeolocationCompatSpec_cxx` to properly resolve imports.
13
+ namespace NitroGeolocation { class HybridNitroGeolocationCompatSpec_cxx; }
14
+
15
+ // Forward declaration of `RNConfigurationInternal` to properly resolve imports.
16
+ namespace margelo::nitro::nitrogeolocation { struct RNConfigurationInternal; }
17
+ // Forward declaration of `AuthorizationLevelInternal` to properly resolve imports.
18
+ namespace margelo::nitro::nitrogeolocation { enum class AuthorizationLevelInternal; }
19
+ // Forward declaration of `LocationProviderInternal` to properly resolve imports.
20
+ namespace margelo::nitro::nitrogeolocation { enum class LocationProviderInternal; }
21
+ // Forward declaration of `GeolocationError` to properly resolve imports.
22
+ namespace margelo::nitro::nitrogeolocation { struct GeolocationError; }
23
+ // Forward declaration of `GeolocationResponse` to properly resolve imports.
24
+ namespace margelo::nitro::nitrogeolocation { struct GeolocationResponse; }
25
+ // Forward declaration of `GeolocationCoordinates` to properly resolve imports.
26
+ namespace margelo::nitro::nitrogeolocation { struct GeolocationCoordinates; }
27
+ // Forward declaration of `GeolocationOptions` to properly resolve imports.
28
+ namespace margelo::nitro::nitrogeolocation { struct GeolocationOptions; }
29
+
30
+ #include "RNConfigurationInternal.hpp"
31
+ #include "AuthorizationLevelInternal.hpp"
32
+ #include <optional>
33
+ #include "LocationProviderInternal.hpp"
34
+ #include <functional>
35
+ #include "GeolocationError.hpp"
36
+ #include <string>
37
+ #include "GeolocationResponse.hpp"
38
+ #include "GeolocationCoordinates.hpp"
39
+ #include <NitroModules/Null.hpp>
40
+ #include <variant>
41
+ #include "GeolocationOptions.hpp"
42
+
43
+ #include "NitroGeolocation-Swift-Cxx-Umbrella.hpp"
44
+
45
+ namespace margelo::nitro::nitrogeolocation {
46
+
47
+ /**
48
+ * The C++ part of HybridNitroGeolocationCompatSpec_cxx.swift.
49
+ *
50
+ * HybridNitroGeolocationCompatSpecSwift (C++) accesses HybridNitroGeolocationCompatSpec_cxx (Swift), and might
51
+ * contain some additional bridging code for C++ <> Swift interop.
52
+ *
53
+ * Since this obviously introduces an overhead, I hope at some point in
54
+ * the future, HybridNitroGeolocationCompatSpec_cxx can directly inherit from the C++ class HybridNitroGeolocationCompatSpec
55
+ * to simplify the whole structure and memory management.
56
+ */
57
+ class HybridNitroGeolocationCompatSpecSwift: public virtual HybridNitroGeolocationCompatSpec {
58
+ public:
59
+ // Constructor from a Swift instance
60
+ explicit HybridNitroGeolocationCompatSpecSwift(const NitroGeolocation::HybridNitroGeolocationCompatSpec_cxx& swiftPart):
61
+ HybridObject(HybridNitroGeolocationCompatSpec::TAG),
62
+ _swiftPart(swiftPart) { }
63
+
64
+ public:
65
+ // Get the Swift part
66
+ inline NitroGeolocation::HybridNitroGeolocationCompatSpec_cxx& getSwiftPart() noexcept {
67
+ return _swiftPart;
68
+ }
69
+
70
+ public:
71
+ inline size_t getExternalMemorySize() noexcept override {
72
+ return _swiftPart.getMemorySize();
73
+ }
74
+ void dispose() noexcept override {
75
+ _swiftPart.dispose();
76
+ }
77
+ std::string toString() override {
78
+ return _swiftPart.toString();
79
+ }
80
+
81
+ public:
82
+ // Properties
83
+
84
+
85
+ public:
86
+ // Methods
87
+ inline void setRNConfiguration(const RNConfigurationInternal& config) override {
88
+ auto __result = _swiftPart.setRNConfiguration(std::forward<decltype(config)>(config));
89
+ if (__result.hasError()) [[unlikely]] {
90
+ std::rethrow_exception(__result.error());
91
+ }
92
+ }
93
+ inline void requestAuthorization(const std::optional<std::function<void()>>& success, const std::optional<std::function<void(const GeolocationError& /* error */)>>& error) override {
94
+ auto __result = _swiftPart.requestAuthorization(success, error);
95
+ if (__result.hasError()) [[unlikely]] {
96
+ std::rethrow_exception(__result.error());
97
+ }
98
+ }
99
+ inline void getCurrentPosition(const std::function<void(const GeolocationResponse& /* position */)>& success, const std::optional<std::function<void(const GeolocationError& /* error */)>>& error, const std::optional<GeolocationOptions>& options) override {
100
+ auto __result = _swiftPart.getCurrentPosition(success, error, options);
101
+ if (__result.hasError()) [[unlikely]] {
102
+ std::rethrow_exception(__result.error());
103
+ }
104
+ }
105
+ inline double watchPosition(const std::function<void(const GeolocationResponse& /* position */)>& success, const std::optional<std::function<void(const GeolocationError& /* error */)>>& error, const std::optional<GeolocationOptions>& options) override {
106
+ auto __result = _swiftPart.watchPosition(success, error, options);
107
+ if (__result.hasError()) [[unlikely]] {
108
+ std::rethrow_exception(__result.error());
109
+ }
110
+ auto __value = std::move(__result.value());
111
+ return __value;
112
+ }
113
+ inline void clearWatch(double watchId) override {
114
+ auto __result = _swiftPart.clearWatch(std::forward<decltype(watchId)>(watchId));
115
+ if (__result.hasError()) [[unlikely]] {
116
+ std::rethrow_exception(__result.error());
117
+ }
118
+ }
119
+ inline void stopObserving() override {
120
+ auto __result = _swiftPart.stopObserving();
121
+ if (__result.hasError()) [[unlikely]] {
122
+ std::rethrow_exception(__result.error());
123
+ }
124
+ }
125
+
126
+ private:
127
+ NitroGeolocation::HybridNitroGeolocationCompatSpec_cxx _swiftPart;
128
+ };
129
+
130
+ } // namespace margelo::nitro::nitrogeolocation
@@ -12,31 +12,37 @@
12
12
  // Forward declaration of `HybridNitroGeolocationSpec_cxx` to properly resolve imports.
13
13
  namespace NitroGeolocation { class HybridNitroGeolocationSpec_cxx; }
14
14
 
15
- // Forward declaration of `RNConfigurationInternal` to properly resolve imports.
16
- namespace margelo::nitro::nitrogeolocation { struct RNConfigurationInternal; }
17
- // Forward declaration of `AuthorizationLevelInternal` to properly resolve imports.
18
- namespace margelo::nitro::nitrogeolocation { enum class AuthorizationLevelInternal; }
19
- // Forward declaration of `LocationProviderInternal` to properly resolve imports.
20
- namespace margelo::nitro::nitrogeolocation { enum class LocationProviderInternal; }
21
- // Forward declaration of `GeolocationError` to properly resolve imports.
22
- namespace margelo::nitro::nitrogeolocation { struct GeolocationError; }
15
+ // Forward declaration of `ModernGeolocationConfiguration` to properly resolve imports.
16
+ namespace margelo::nitro::nitrogeolocation { struct ModernGeolocationConfiguration; }
17
+ // Forward declaration of `AuthorizationLevel` to properly resolve imports.
18
+ namespace margelo::nitro::nitrogeolocation { enum class AuthorizationLevel; }
19
+ // Forward declaration of `LocationProvider` to properly resolve imports.
20
+ namespace margelo::nitro::nitrogeolocation { enum class LocationProvider; }
21
+ // Forward declaration of `PermissionStatus` to properly resolve imports.
22
+ namespace margelo::nitro::nitrogeolocation { enum class PermissionStatus; }
23
23
  // Forward declaration of `GeolocationResponse` to properly resolve imports.
24
24
  namespace margelo::nitro::nitrogeolocation { struct GeolocationResponse; }
25
25
  // Forward declaration of `GeolocationCoordinates` to properly resolve imports.
26
26
  namespace margelo::nitro::nitrogeolocation { struct GeolocationCoordinates; }
27
- // Forward declaration of `GeolocationOptions` to properly resolve imports.
28
- namespace margelo::nitro::nitrogeolocation { struct GeolocationOptions; }
27
+ // Forward declaration of `LocationRequestOptions` to properly resolve imports.
28
+ namespace margelo::nitro::nitrogeolocation { struct LocationRequestOptions; }
29
+ // Forward declaration of `LocationError` to properly resolve imports.
30
+ namespace margelo::nitro::nitrogeolocation { struct LocationError; }
29
31
 
30
- #include "RNConfigurationInternal.hpp"
31
- #include "AuthorizationLevelInternal.hpp"
32
+ #include "ModernGeolocationConfiguration.hpp"
32
33
  #include <optional>
33
- #include "LocationProviderInternal.hpp"
34
- #include <functional>
35
- #include "GeolocationError.hpp"
36
- #include <string>
34
+ #include "AuthorizationLevel.hpp"
35
+ #include "LocationProvider.hpp"
36
+ #include "PermissionStatus.hpp"
37
+ #include <NitroModules/Promise.hpp>
37
38
  #include "GeolocationResponse.hpp"
38
39
  #include "GeolocationCoordinates.hpp"
39
- #include "GeolocationOptions.hpp"
40
+ #include <NitroModules/Null.hpp>
41
+ #include <variant>
42
+ #include "LocationRequestOptions.hpp"
43
+ #include <string>
44
+ #include <functional>
45
+ #include "LocationError.hpp"
40
46
 
41
47
  #include "NitroGeolocation-Swift-Cxx-Umbrella.hpp"
42
48
 
@@ -72,6 +78,9 @@ namespace margelo::nitro::nitrogeolocation {
72
78
  void dispose() noexcept override {
73
79
  _swiftPart.dispose();
74
80
  }
81
+ std::string toString() override {
82
+ return _swiftPart.toString();
83
+ }
75
84
 
76
85
  public:
77
86
  // Properties
@@ -79,25 +88,37 @@ namespace margelo::nitro::nitrogeolocation {
79
88
 
80
89
  public:
81
90
  // Methods
82
- inline void setRNConfiguration(const RNConfigurationInternal& config) override {
83
- auto __result = _swiftPart.setRNConfiguration(std::forward<decltype(config)>(config));
91
+ inline void setConfiguration(const ModernGeolocationConfiguration& config) override {
92
+ auto __result = _swiftPart.setConfiguration(std::forward<decltype(config)>(config));
84
93
  if (__result.hasError()) [[unlikely]] {
85
94
  std::rethrow_exception(__result.error());
86
95
  }
87
96
  }
88
- inline void requestAuthorization(const std::optional<std::function<void()>>& success, const std::optional<std::function<void(const GeolocationError& /* error */)>>& error) override {
89
- auto __result = _swiftPart.requestAuthorization(success, error);
97
+ inline std::shared_ptr<Promise<PermissionStatus>> checkPermission() override {
98
+ auto __result = _swiftPart.checkPermission();
90
99
  if (__result.hasError()) [[unlikely]] {
91
100
  std::rethrow_exception(__result.error());
92
101
  }
102
+ auto __value = std::move(__result.value());
103
+ return __value;
93
104
  }
94
- inline void getCurrentPosition(const std::function<void(const GeolocationResponse& /* position */)>& success, const std::optional<std::function<void(const GeolocationError& /* error */)>>& error, const std::optional<GeolocationOptions>& options) override {
95
- auto __result = _swiftPart.getCurrentPosition(success, error, options);
105
+ inline std::shared_ptr<Promise<PermissionStatus>> requestPermission() override {
106
+ auto __result = _swiftPart.requestPermission();
96
107
  if (__result.hasError()) [[unlikely]] {
97
108
  std::rethrow_exception(__result.error());
98
109
  }
110
+ auto __value = std::move(__result.value());
111
+ return __value;
112
+ }
113
+ inline std::shared_ptr<Promise<GeolocationResponse>> getCurrentPosition(const std::optional<LocationRequestOptions>& options) override {
114
+ auto __result = _swiftPart.getCurrentPosition(options);
115
+ if (__result.hasError()) [[unlikely]] {
116
+ std::rethrow_exception(__result.error());
117
+ }
118
+ auto __value = std::move(__result.value());
119
+ return __value;
99
120
  }
100
- inline double watchPosition(const std::function<void(const GeolocationResponse& /* position */)>& success, const std::optional<std::function<void(const GeolocationError& /* error */)>>& error, const std::optional<GeolocationOptions>& options) override {
121
+ inline std::string watchPosition(const std::function<void(const GeolocationResponse& /* position */)>& success, const std::optional<std::function<void(const LocationError& /* error */)>>& error, const std::optional<LocationRequestOptions>& options) override {
101
122
  auto __result = _swiftPart.watchPosition(success, error, options);
102
123
  if (__result.hasError()) [[unlikely]] {
103
124
  std::rethrow_exception(__result.error());
@@ -105,8 +126,8 @@ namespace margelo::nitro::nitrogeolocation {
105
126
  auto __value = std::move(__result.value());
106
127
  return __value;
107
128
  }
108
- inline void clearWatch(double watchId) override {
109
- auto __result = _swiftPart.clearWatch(std::forward<decltype(watchId)>(watchId));
129
+ inline void unwatch(const std::string& token) override {
130
+ auto __result = _swiftPart.unwatch(token);
110
131
  if (__result.hasError()) [[unlikely]] {
111
132
  std::rethrow_exception(__result.error());
112
133
  }
@@ -0,0 +1,44 @@
1
+ ///
2
+ /// AuthorizationLevel.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 union `AuthorizationLevel`, backed by a C++ enum.
10
+ */
11
+ public typealias AuthorizationLevel = margelo.nitro.nitrogeolocation.AuthorizationLevel
12
+
13
+ public extension AuthorizationLevel {
14
+ /**
15
+ * Get a AuthorizationLevel 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 "always":
21
+ self = .always
22
+ case "whenInUse":
23
+ self = .wheninuse
24
+ case "auto":
25
+ self = .auto
26
+ default:
27
+ return nil
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Get the String value this AuthorizationLevel represents.
33
+ */
34
+ var stringValue: String {
35
+ switch self {
36
+ case .always:
37
+ return "always"
38
+ case .wheninuse:
39
+ return "whenInUse"
40
+ case .auto:
41
+ return "auto"
42
+ }
43
+ }
44
+ }
@@ -5,9 +5,9 @@
5
5
  /// Copyright © 2025 Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
+ import Foundation
8
9
  import NitroModules
9
10
 
10
-
11
11
  /**
12
12
  * Wraps a Swift `() -> Void` as a class.
13
13
  * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
@@ -5,9 +5,9 @@
5
5
  /// Copyright © 2025 Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
+ import Foundation
8
9
  import NitroModules
9
10
 
10
-
11
11
  /**
12
12
  * Wraps a Swift `(_ error: GeolocationError) -> Void` as a class.
13
13
  * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
@@ -5,9 +5,9 @@
5
5
  /// Copyright © 2025 Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
+ import Foundation
8
9
  import NitroModules
9
10
 
10
-
11
11
  /**
12
12
  * Wraps a Swift `(_ position: GeolocationResponse) -> Void` as a class.
13
13
  * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// Func_void_LocationError.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: LocationError) -> 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_LocationError {
16
+ public typealias bridge = margelo.nitro.nitrogeolocation.bridge.swift
17
+
18
+ private let closure: (_ error: LocationError) -> Void
19
+
20
+ public init(_ closure: @escaping (_ error: LocationError) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(error: LocationError) -> Void {
26
+ self.closure(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_LocationError`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_LocationError>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_LocationError {
45
+ return Unmanaged<Func_void_LocationError>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// Func_void_PermissionStatus.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: PermissionStatus) -> 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_PermissionStatus {
16
+ public typealias bridge = margelo.nitro.nitrogeolocation.bridge.swift
17
+
18
+ private let closure: (_ value: PermissionStatus) -> Void
19
+
20
+ public init(_ closure: @escaping (_ value: PermissionStatus) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(value: Int32) -> Void {
26
+ self.closure(margelo.nitro.nitrogeolocation.PermissionStatus(rawValue: 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_PermissionStatus`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_PermissionStatus>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_PermissionStatus {
45
+ return Unmanaged<Func_void_PermissionStatus>.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.nitrogeolocation.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
+ }