react-native-nitro-geolocation 0.0.1 → 0.1.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 (79) hide show
  1. package/LICENSE +4 -1
  2. package/README.md +598 -0
  3. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/GetCurrentPosition.kt +341 -0
  4. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/NitroGeolocation.kt +76 -5
  5. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/RequestAuthorization.kt +164 -0
  6. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/WatchPosition.kt +228 -0
  7. package/ios/LocationManager.swift +529 -0
  8. package/ios/NitroGeolocation.swift +96 -2
  9. package/nitrogen/generated/.gitattributes +1 -0
  10. package/nitrogen/generated/android/c++/JAuthorizationLevelInternal.hpp +62 -0
  11. package/nitrogen/generated/android/c++/JFunc_void.hpp +74 -0
  12. package/nitrogen/generated/android/c++/JFunc_void_GeolocationError.hpp +77 -0
  13. package/nitrogen/generated/android/c++/JFunc_void_GeolocationResponse.hpp +79 -0
  14. package/nitrogen/generated/android/c++/JGeolocationCoordinates.hpp +77 -0
  15. package/nitrogen/generated/android/c++/JGeolocationError.hpp +69 -0
  16. package/nitrogen/generated/android/c++/JGeolocationOptions.hpp +77 -0
  17. package/nitrogen/generated/android/c++/JGeolocationResponse.hpp +59 -0
  18. package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.cpp +98 -0
  19. package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.hpp +69 -0
  20. package/nitrogen/generated/android/c++/JLocationProviderInternal.hpp +62 -0
  21. package/nitrogen/generated/android/c++/JRNConfigurationInternal.hpp +69 -0
  22. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AuthorizationLevelInternal.kt +22 -0
  23. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void.kt +81 -0
  24. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_GeolocationError.kt +81 -0
  25. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_GeolocationResponse.kt +81 -0
  26. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationCoordinates.kt +47 -0
  27. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationError.kt +41 -0
  28. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationOptions.kt +47 -0
  29. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationResponse.kt +32 -0
  30. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HybridNitroGeolocationSpec.kt +87 -0
  31. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationProviderInternal.kt +22 -0
  32. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/RNConfigurationInternal.kt +38 -0
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/nitrogeolocationOnLoad.kt +35 -0
  34. package/nitrogen/generated/android/nitrogeolocation+autolinking.cmake +81 -0
  35. package/nitrogen/generated/android/nitrogeolocation+autolinking.gradle +27 -0
  36. package/nitrogen/generated/android/nitrogeolocationOnLoad.cpp +50 -0
  37. package/nitrogen/generated/android/nitrogeolocationOnLoad.hpp +25 -0
  38. package/nitrogen/generated/ios/NitroGeolocation+autolinking.rb +60 -0
  39. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.cpp +56 -0
  40. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.hpp +252 -0
  41. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Umbrella.hpp +67 -0
  42. package/nitrogen/generated/ios/NitroGeolocationAutolinking.mm +33 -0
  43. package/nitrogen/generated/ios/NitroGeolocationAutolinking.swift +25 -0
  44. package/nitrogen/generated/ios/c++/HybridNitroGeolocationSpecSwift.cpp +11 -0
  45. package/nitrogen/generated/ios/c++/HybridNitroGeolocationSpecSwift.hpp +125 -0
  46. package/nitrogen/generated/ios/swift/AuthorizationLevelInternal.swift +44 -0
  47. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  48. package/nitrogen/generated/ios/swift/Func_void_GeolocationError.swift +47 -0
  49. package/nitrogen/generated/ios/swift/Func_void_GeolocationResponse.swift +47 -0
  50. package/nitrogen/generated/ios/swift/GeolocationCoordinates.swift +149 -0
  51. package/nitrogen/generated/ios/swift/GeolocationError.swift +79 -0
  52. package/nitrogen/generated/ios/swift/GeolocationOptions.swift +185 -0
  53. package/nitrogen/generated/ios/swift/GeolocationResponse.swift +46 -0
  54. package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec.swift +54 -0
  55. package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec_cxx.swift +236 -0
  56. package/nitrogen/generated/ios/swift/LocationProviderInternal.swift +44 -0
  57. package/nitrogen/generated/ios/swift/RNConfigurationInternal.swift +104 -0
  58. package/nitrogen/generated/shared/c++/AuthorizationLevelInternal.hpp +80 -0
  59. package/nitrogen/generated/shared/c++/GeolocationCoordinates.hpp +91 -0
  60. package/nitrogen/generated/shared/c++/GeolocationError.hpp +83 -0
  61. package/nitrogen/generated/shared/c++/GeolocationOptions.hpp +91 -0
  62. package/nitrogen/generated/shared/c++/GeolocationResponse.hpp +72 -0
  63. package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.cpp +26 -0
  64. package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.hpp +79 -0
  65. package/nitrogen/generated/shared/c++/LocationProviderInternal.hpp +80 -0
  66. package/nitrogen/generated/shared/c++/RNConfigurationInternal.hpp +84 -0
  67. package/package.json +34 -10
  68. package/src/NitroGeolocation.nitro.ts +38 -3
  69. package/src/NitroGeolocationModule.ts +5 -0
  70. package/src/clearWatch.ts +13 -0
  71. package/src/getCurrentPosition.ts +14 -0
  72. package/src/index.tsx +32 -7
  73. package/src/requestAuthorization.ts +9 -0
  74. package/src/setRNConfiguration.ts +22 -0
  75. package/src/stopObserving.ts +12 -0
  76. package/src/types.ts +43 -0
  77. package/src/watchPosition.ts +26 -0
  78. package/nitro.json +0 -17
  79. package/turbo.json +0 -42
@@ -0,0 +1,252 @@
1
+ ///
2
+ /// NitroGeolocation-Swift-Cxx-Bridge.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `AuthorizationLevelInternal` to properly resolve imports.
12
+ namespace margelo::nitro::nitrogeolocation { enum class AuthorizationLevelInternal; }
13
+ // Forward declaration of `GeolocationCoordinates` to properly resolve imports.
14
+ namespace margelo::nitro::nitrogeolocation { struct GeolocationCoordinates; }
15
+ // Forward declaration of `GeolocationError` to properly resolve imports.
16
+ namespace margelo::nitro::nitrogeolocation { struct GeolocationError; }
17
+ // Forward declaration of `GeolocationOptions` to properly resolve imports.
18
+ namespace margelo::nitro::nitrogeolocation { struct GeolocationOptions; }
19
+ // Forward declaration of `GeolocationResponse` to properly resolve imports.
20
+ namespace margelo::nitro::nitrogeolocation { struct GeolocationResponse; }
21
+ // Forward declaration of `HybridNitroGeolocationSpec` to properly resolve imports.
22
+ namespace margelo::nitro::nitrogeolocation { class HybridNitroGeolocationSpec; }
23
+ // Forward declaration of `LocationProviderInternal` to properly resolve imports.
24
+ namespace margelo::nitro::nitrogeolocation { enum class LocationProviderInternal; }
25
+
26
+ // Forward declarations of Swift defined types
27
+ // Forward declaration of `HybridNitroGeolocationSpec_cxx` to properly resolve imports.
28
+ namespace NitroGeolocation { class HybridNitroGeolocationSpec_cxx; }
29
+
30
+ // Include C++ defined types
31
+ #include "AuthorizationLevelInternal.hpp"
32
+ #include "GeolocationCoordinates.hpp"
33
+ #include "GeolocationError.hpp"
34
+ #include "GeolocationOptions.hpp"
35
+ #include "GeolocationResponse.hpp"
36
+ #include "HybridNitroGeolocationSpec.hpp"
37
+ #include "LocationProviderInternal.hpp"
38
+ #include <NitroModules/Result.hpp>
39
+ #include <exception>
40
+ #include <functional>
41
+ #include <memory>
42
+ #include <optional>
43
+ #include <string>
44
+
45
+ /**
46
+ * Contains specialized versions of C++ templated types so they can be accessed from Swift,
47
+ * as well as helper functions to interact with those C++ types from Swift.
48
+ */
49
+ namespace margelo::nitro::nitrogeolocation::bridge::swift {
50
+
51
+ // pragma MARK: std::optional<AuthorizationLevelInternal>
52
+ /**
53
+ * Specialized version of `std::optional<AuthorizationLevelInternal>`.
54
+ */
55
+ using std__optional_AuthorizationLevelInternal_ = std::optional<AuthorizationLevelInternal>;
56
+ inline std::optional<AuthorizationLevelInternal> create_std__optional_AuthorizationLevelInternal_(const AuthorizationLevelInternal& value) noexcept {
57
+ return std::optional<AuthorizationLevelInternal>(value);
58
+ }
59
+ inline bool has_value_std__optional_AuthorizationLevelInternal_(const std::optional<AuthorizationLevelInternal>& optional) noexcept {
60
+ return optional.has_value();
61
+ }
62
+ inline AuthorizationLevelInternal get_std__optional_AuthorizationLevelInternal_(const std::optional<AuthorizationLevelInternal>& optional) noexcept {
63
+ return *optional;
64
+ }
65
+
66
+ // pragma MARK: std::optional<bool>
67
+ /**
68
+ * Specialized version of `std::optional<bool>`.
69
+ */
70
+ using std__optional_bool_ = std::optional<bool>;
71
+ inline std::optional<bool> create_std__optional_bool_(const bool& value) noexcept {
72
+ return std::optional<bool>(value);
73
+ }
74
+ inline bool has_value_std__optional_bool_(const std::optional<bool>& optional) noexcept {
75
+ return optional.has_value();
76
+ }
77
+ inline bool get_std__optional_bool_(const std::optional<bool>& optional) noexcept {
78
+ return *optional;
79
+ }
80
+
81
+ // pragma MARK: std::optional<LocationProviderInternal>
82
+ /**
83
+ * Specialized version of `std::optional<LocationProviderInternal>`.
84
+ */
85
+ using std__optional_LocationProviderInternal_ = std::optional<LocationProviderInternal>;
86
+ inline std::optional<LocationProviderInternal> create_std__optional_LocationProviderInternal_(const LocationProviderInternal& value) noexcept {
87
+ return std::optional<LocationProviderInternal>(value);
88
+ }
89
+ inline bool has_value_std__optional_LocationProviderInternal_(const std::optional<LocationProviderInternal>& optional) noexcept {
90
+ return optional.has_value();
91
+ }
92
+ inline LocationProviderInternal get_std__optional_LocationProviderInternal_(const std::optional<LocationProviderInternal>& optional) noexcept {
93
+ return *optional;
94
+ }
95
+
96
+ // pragma MARK: std::function<void()>
97
+ /**
98
+ * Specialized version of `std::function<void()>`.
99
+ */
100
+ using Func_void = std::function<void()>;
101
+ /**
102
+ * Wrapper class for a `std::function<void()>`, this can be used from Swift.
103
+ */
104
+ class Func_void_Wrapper final {
105
+ public:
106
+ explicit Func_void_Wrapper(std::function<void()>&& func): _function(std::make_unique<std::function<void()>>(std::move(func))) {}
107
+ inline void call() const noexcept {
108
+ _function->operator()();
109
+ }
110
+ private:
111
+ std::unique_ptr<std::function<void()>> _function;
112
+ } SWIFT_NONCOPYABLE;
113
+ Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept;
114
+ inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept {
115
+ return Func_void_Wrapper(std::move(value));
116
+ }
117
+
118
+ // pragma MARK: std::optional<std::function<void()>>
119
+ /**
120
+ * Specialized version of `std::optional<std::function<void()>>`.
121
+ */
122
+ using std__optional_std__function_void____ = std::optional<std::function<void()>>;
123
+ inline std::optional<std::function<void()>> create_std__optional_std__function_void____(const std::function<void()>& value) noexcept {
124
+ return std::optional<std::function<void()>>(value);
125
+ }
126
+ inline bool has_value_std__optional_std__function_void____(const std::optional<std::function<void()>>& optional) noexcept {
127
+ return optional.has_value();
128
+ }
129
+ inline std::function<void()> get_std__optional_std__function_void____(const std::optional<std::function<void()>>& optional) noexcept {
130
+ return *optional;
131
+ }
132
+
133
+ // pragma MARK: std::function<void(const GeolocationError& /* error */)>
134
+ /**
135
+ * Specialized version of `std::function<void(const GeolocationError&)>`.
136
+ */
137
+ using Func_void_GeolocationError = std::function<void(const GeolocationError& /* error */)>;
138
+ /**
139
+ * Wrapper class for a `std::function<void(const GeolocationError& / * error * /)>`, this can be used from Swift.
140
+ */
141
+ class Func_void_GeolocationError_Wrapper final {
142
+ public:
143
+ explicit Func_void_GeolocationError_Wrapper(std::function<void(const GeolocationError& /* error */)>&& func): _function(std::make_unique<std::function<void(const GeolocationError& /* error */)>>(std::move(func))) {}
144
+ inline void call(GeolocationError error) const noexcept {
145
+ _function->operator()(error);
146
+ }
147
+ private:
148
+ std::unique_ptr<std::function<void(const GeolocationError& /* error */)>> _function;
149
+ } SWIFT_NONCOPYABLE;
150
+ Func_void_GeolocationError create_Func_void_GeolocationError(void* NON_NULL swiftClosureWrapper) noexcept;
151
+ inline Func_void_GeolocationError_Wrapper wrap_Func_void_GeolocationError(Func_void_GeolocationError value) noexcept {
152
+ return Func_void_GeolocationError_Wrapper(std::move(value));
153
+ }
154
+
155
+ // pragma MARK: std::optional<std::function<void(const GeolocationError& /* error */)>>
156
+ /**
157
+ * Specialized version of `std::optional<std::function<void(const GeolocationError& / * error * /)>>`.
158
+ */
159
+ using std__optional_std__function_void_const_GeolocationError_____error______ = std::optional<std::function<void(const GeolocationError& /* error */)>>;
160
+ inline std::optional<std::function<void(const GeolocationError& /* error */)>> create_std__optional_std__function_void_const_GeolocationError_____error______(const std::function<void(const GeolocationError& /* error */)>& value) noexcept {
161
+ return std::optional<std::function<void(const GeolocationError& /* error */)>>(value);
162
+ }
163
+ inline bool has_value_std__optional_std__function_void_const_GeolocationError_____error______(const std::optional<std::function<void(const GeolocationError& /* error */)>>& optional) noexcept {
164
+ return optional.has_value();
165
+ }
166
+ inline std::function<void(const GeolocationError& /* error */)> get_std__optional_std__function_void_const_GeolocationError_____error______(const std::optional<std::function<void(const GeolocationError& /* error */)>>& optional) noexcept {
167
+ return *optional;
168
+ }
169
+
170
+ // pragma MARK: std::optional<double>
171
+ /**
172
+ * Specialized version of `std::optional<double>`.
173
+ */
174
+ using std__optional_double_ = std::optional<double>;
175
+ inline std::optional<double> create_std__optional_double_(const double& value) noexcept {
176
+ return std::optional<double>(value);
177
+ }
178
+ inline bool has_value_std__optional_double_(const std::optional<double>& optional) noexcept {
179
+ return optional.has_value();
180
+ }
181
+ inline double get_std__optional_double_(const std::optional<double>& optional) noexcept {
182
+ return *optional;
183
+ }
184
+
185
+ // pragma MARK: std::function<void(const GeolocationResponse& /* position */)>
186
+ /**
187
+ * Specialized version of `std::function<void(const GeolocationResponse&)>`.
188
+ */
189
+ using Func_void_GeolocationResponse = std::function<void(const GeolocationResponse& /* position */)>;
190
+ /**
191
+ * Wrapper class for a `std::function<void(const GeolocationResponse& / * position * /)>`, this can be used from Swift.
192
+ */
193
+ class Func_void_GeolocationResponse_Wrapper final {
194
+ public:
195
+ explicit Func_void_GeolocationResponse_Wrapper(std::function<void(const GeolocationResponse& /* position */)>&& func): _function(std::make_unique<std::function<void(const GeolocationResponse& /* position */)>>(std::move(func))) {}
196
+ inline void call(GeolocationResponse position) const noexcept {
197
+ _function->operator()(position);
198
+ }
199
+ private:
200
+ std::unique_ptr<std::function<void(const GeolocationResponse& /* position */)>> _function;
201
+ } SWIFT_NONCOPYABLE;
202
+ Func_void_GeolocationResponse create_Func_void_GeolocationResponse(void* NON_NULL swiftClosureWrapper) noexcept;
203
+ inline Func_void_GeolocationResponse_Wrapper wrap_Func_void_GeolocationResponse(Func_void_GeolocationResponse value) noexcept {
204
+ return Func_void_GeolocationResponse_Wrapper(std::move(value));
205
+ }
206
+
207
+ // pragma MARK: std::optional<GeolocationOptions>
208
+ /**
209
+ * Specialized version of `std::optional<GeolocationOptions>`.
210
+ */
211
+ using std__optional_GeolocationOptions_ = std::optional<GeolocationOptions>;
212
+ inline std::optional<GeolocationOptions> create_std__optional_GeolocationOptions_(const GeolocationOptions& value) noexcept {
213
+ return std::optional<GeolocationOptions>(value);
214
+ }
215
+ inline bool has_value_std__optional_GeolocationOptions_(const std::optional<GeolocationOptions>& optional) noexcept {
216
+ return optional.has_value();
217
+ }
218
+ inline GeolocationOptions get_std__optional_GeolocationOptions_(const std::optional<GeolocationOptions>& optional) noexcept {
219
+ return *optional;
220
+ }
221
+
222
+ // pragma MARK: std::shared_ptr<HybridNitroGeolocationSpec>
223
+ /**
224
+ * Specialized version of `std::shared_ptr<HybridNitroGeolocationSpec>`.
225
+ */
226
+ using std__shared_ptr_HybridNitroGeolocationSpec_ = std::shared_ptr<HybridNitroGeolocationSpec>;
227
+ std::shared_ptr<HybridNitroGeolocationSpec> create_std__shared_ptr_HybridNitroGeolocationSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
228
+ void* NON_NULL get_std__shared_ptr_HybridNitroGeolocationSpec_(std__shared_ptr_HybridNitroGeolocationSpec_ cppType) noexcept;
229
+
230
+ // pragma MARK: std::weak_ptr<HybridNitroGeolocationSpec>
231
+ using std__weak_ptr_HybridNitroGeolocationSpec_ = std::weak_ptr<HybridNitroGeolocationSpec>;
232
+ inline std__weak_ptr_HybridNitroGeolocationSpec_ weakify_std__shared_ptr_HybridNitroGeolocationSpec_(const std::shared_ptr<HybridNitroGeolocationSpec>& strong) noexcept { return strong; }
233
+
234
+ // pragma MARK: Result<void>
235
+ using Result_void_ = Result<void>;
236
+ inline Result_void_ create_Result_void_() noexcept {
237
+ return Result<void>::withValue();
238
+ }
239
+ inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept {
240
+ return Result<void>::withError(error);
241
+ }
242
+
243
+ // pragma MARK: Result<double>
244
+ using Result_double_ = Result<double>;
245
+ inline Result_double_ create_Result_double_(double value) noexcept {
246
+ return Result<double>::withValue(std::move(value));
247
+ }
248
+ inline Result_double_ create_Result_double_(const std::exception_ptr& error) noexcept {
249
+ return Result<double>::withError(error);
250
+ }
251
+
252
+ } // namespace margelo::nitro::nitrogeolocation::bridge::swift
@@ -0,0 +1,67 @@
1
+ ///
2
+ /// NitroGeolocation-Swift-Cxx-Umbrella.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `AuthorizationLevelInternal` to properly resolve imports.
12
+ namespace margelo::nitro::nitrogeolocation { enum class AuthorizationLevelInternal; }
13
+ // Forward declaration of `GeolocationCoordinates` to properly resolve imports.
14
+ namespace margelo::nitro::nitrogeolocation { struct GeolocationCoordinates; }
15
+ // Forward declaration of `GeolocationError` to properly resolve imports.
16
+ namespace margelo::nitro::nitrogeolocation { struct GeolocationError; }
17
+ // Forward declaration of `GeolocationOptions` to properly resolve imports.
18
+ namespace margelo::nitro::nitrogeolocation { struct GeolocationOptions; }
19
+ // Forward declaration of `GeolocationResponse` to properly resolve imports.
20
+ namespace margelo::nitro::nitrogeolocation { struct GeolocationResponse; }
21
+ // Forward declaration of `HybridNitroGeolocationSpec` to properly resolve imports.
22
+ namespace margelo::nitro::nitrogeolocation { class HybridNitroGeolocationSpec; }
23
+ // Forward declaration of `LocationProviderInternal` to properly resolve imports.
24
+ namespace margelo::nitro::nitrogeolocation { enum class LocationProviderInternal; }
25
+ // Forward declaration of `RNConfigurationInternal` to properly resolve imports.
26
+ namespace margelo::nitro::nitrogeolocation { struct RNConfigurationInternal; }
27
+
28
+ // Include C++ defined types
29
+ #include "AuthorizationLevelInternal.hpp"
30
+ #include "GeolocationCoordinates.hpp"
31
+ #include "GeolocationError.hpp"
32
+ #include "GeolocationOptions.hpp"
33
+ #include "GeolocationResponse.hpp"
34
+ #include "HybridNitroGeolocationSpec.hpp"
35
+ #include "LocationProviderInternal.hpp"
36
+ #include "RNConfigurationInternal.hpp"
37
+ #include <NitroModules/Result.hpp>
38
+ #include <exception>
39
+ #include <functional>
40
+ #include <memory>
41
+ #include <optional>
42
+ #include <string>
43
+
44
+ // C++ helpers for Swift
45
+ #include "NitroGeolocation-Swift-Cxx-Bridge.hpp"
46
+
47
+ // Common C++ types used in Swift
48
+ #include <NitroModules/ArrayBufferHolder.hpp>
49
+ #include <NitroModules/AnyMapUtils.hpp>
50
+ #include <NitroModules/RuntimeError.hpp>
51
+ #include <NitroModules/DateToChronoDate.hpp>
52
+
53
+ // Forward declarations of Swift defined types
54
+ // Forward declaration of `HybridNitroGeolocationSpec_cxx` to properly resolve imports.
55
+ namespace NitroGeolocation { class HybridNitroGeolocationSpec_cxx; }
56
+
57
+ // Include Swift defined types
58
+ #if __has_include("NitroGeolocation-Swift.h")
59
+ // This header is generated by Xcode/Swift on every app build.
60
+ // If it cannot be found, make sure the Swift module's name (= podspec name) is actually "NitroGeolocation".
61
+ #include "NitroGeolocation-Swift.h"
62
+ // Same as above, but used when building with frameworks (`use_frameworks`)
63
+ #elif __has_include(<NitroGeolocation/NitroGeolocation-Swift.h>)
64
+ #include <NitroGeolocation/NitroGeolocation-Swift.h>
65
+ #else
66
+ #error NitroGeolocation's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "NitroGeolocation", and try building the app first.
67
+ #endif
@@ -0,0 +1,33 @@
1
+ ///
2
+ /// NitroGeolocationAutolinking.mm
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <NitroModules/HybridObjectRegistry.hpp>
10
+ #import "NitroGeolocation-Swift-Cxx-Umbrella.hpp"
11
+ #import <type_traits>
12
+
13
+ #include "HybridNitroGeolocationSpecSwift.hpp"
14
+
15
+ @interface NitroGeolocationAutolinking : NSObject
16
+ @end
17
+
18
+ @implementation NitroGeolocationAutolinking
19
+
20
+ + (void) load {
21
+ using namespace margelo::nitro;
22
+ using namespace margelo::nitro::nitrogeolocation;
23
+
24
+ HybridObjectRegistry::registerHybridObjectConstructor(
25
+ "NitroGeolocation",
26
+ []() -> std::shared_ptr<HybridObject> {
27
+ std::shared_ptr<HybridNitroGeolocationSpec> hybridObject = NitroGeolocation::NitroGeolocationAutolinking::createNitroGeolocation();
28
+ return hybridObject;
29
+ }
30
+ );
31
+ }
32
+
33
+ @end
@@ -0,0 +1,25 @@
1
+ ///
2
+ /// NitroGeolocationAutolinking.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ public final class NitroGeolocationAutolinking {
9
+ public typealias bridge = margelo.nitro.nitrogeolocation.bridge.swift
10
+
11
+ /**
12
+ * Creates an instance of a Swift class that implements `HybridNitroGeolocationSpec`,
13
+ * and wraps it in a Swift class that can directly interop with C++ (`HybridNitroGeolocationSpec_cxx`)
14
+ *
15
+ * This is generated by Nitrogen and will initialize the class specified
16
+ * in the `"autolinking"` property of `nitro.json` (in this case, `NitroGeolocation`).
17
+ */
18
+ public static func createNitroGeolocation() -> bridge.std__shared_ptr_HybridNitroGeolocationSpec_ {
19
+ let hybridObject = NitroGeolocation()
20
+ return { () -> bridge.std__shared_ptr_HybridNitroGeolocationSpec_ in
21
+ let __cxxWrapped = hybridObject.getCxxWrapper()
22
+ return __cxxWrapped.getCxxPart()
23
+ }()
24
+ }
25
+ }
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridNitroGeolocationSpecSwift.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridNitroGeolocationSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::nitrogeolocation {
11
+ } // namespace margelo::nitro::nitrogeolocation
@@ -0,0 +1,125 @@
1
+ ///
2
+ /// HybridNitroGeolocationSpecSwift.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 "HybridNitroGeolocationSpec.hpp"
11
+
12
+ // Forward declaration of `HybridNitroGeolocationSpec_cxx` to properly resolve imports.
13
+ namespace NitroGeolocation { class HybridNitroGeolocationSpec_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 "GeolocationOptions.hpp"
40
+
41
+ #include "NitroGeolocation-Swift-Cxx-Umbrella.hpp"
42
+
43
+ namespace margelo::nitro::nitrogeolocation {
44
+
45
+ /**
46
+ * The C++ part of HybridNitroGeolocationSpec_cxx.swift.
47
+ *
48
+ * HybridNitroGeolocationSpecSwift (C++) accesses HybridNitroGeolocationSpec_cxx (Swift), and might
49
+ * contain some additional bridging code for C++ <> Swift interop.
50
+ *
51
+ * Since this obviously introduces an overhead, I hope at some point in
52
+ * the future, HybridNitroGeolocationSpec_cxx can directly inherit from the C++ class HybridNitroGeolocationSpec
53
+ * to simplify the whole structure and memory management.
54
+ */
55
+ class HybridNitroGeolocationSpecSwift: public virtual HybridNitroGeolocationSpec {
56
+ public:
57
+ // Constructor from a Swift instance
58
+ explicit HybridNitroGeolocationSpecSwift(const NitroGeolocation::HybridNitroGeolocationSpec_cxx& swiftPart):
59
+ HybridObject(HybridNitroGeolocationSpec::TAG),
60
+ _swiftPart(swiftPart) { }
61
+
62
+ public:
63
+ // Get the Swift part
64
+ inline NitroGeolocation::HybridNitroGeolocationSpec_cxx& getSwiftPart() noexcept {
65
+ return _swiftPart;
66
+ }
67
+
68
+ public:
69
+ inline size_t getExternalMemorySize() noexcept override {
70
+ return _swiftPart.getMemorySize();
71
+ }
72
+ void dispose() noexcept override {
73
+ _swiftPart.dispose();
74
+ }
75
+
76
+ public:
77
+ // Properties
78
+
79
+
80
+ public:
81
+ // Methods
82
+ inline void setRNConfiguration(const RNConfigurationInternal& config) override {
83
+ auto __result = _swiftPart.setRNConfiguration(std::forward<decltype(config)>(config));
84
+ if (__result.hasError()) [[unlikely]] {
85
+ std::rethrow_exception(__result.error());
86
+ }
87
+ }
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);
90
+ if (__result.hasError()) [[unlikely]] {
91
+ std::rethrow_exception(__result.error());
92
+ }
93
+ }
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);
96
+ if (__result.hasError()) [[unlikely]] {
97
+ std::rethrow_exception(__result.error());
98
+ }
99
+ }
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 {
101
+ auto __result = _swiftPart.watchPosition(success, error, options);
102
+ if (__result.hasError()) [[unlikely]] {
103
+ std::rethrow_exception(__result.error());
104
+ }
105
+ auto __value = std::move(__result.value());
106
+ return __value;
107
+ }
108
+ inline void clearWatch(double watchId) override {
109
+ auto __result = _swiftPart.clearWatch(std::forward<decltype(watchId)>(watchId));
110
+ if (__result.hasError()) [[unlikely]] {
111
+ std::rethrow_exception(__result.error());
112
+ }
113
+ }
114
+ inline void stopObserving() override {
115
+ auto __result = _swiftPart.stopObserving();
116
+ if (__result.hasError()) [[unlikely]] {
117
+ std::rethrow_exception(__result.error());
118
+ }
119
+ }
120
+
121
+ private:
122
+ NitroGeolocation::HybridNitroGeolocationSpec_cxx _swiftPart;
123
+ };
124
+
125
+ } // namespace margelo::nitro::nitrogeolocation
@@ -0,0 +1,44 @@
1
+ ///
2
+ /// AuthorizationLevelInternal.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 `AuthorizationLevelInternal`, backed by a C++ enum.
10
+ */
11
+ public typealias AuthorizationLevelInternal = margelo.nitro.nitrogeolocation.AuthorizationLevelInternal
12
+
13
+ public extension AuthorizationLevelInternal {
14
+ /**
15
+ * Get a AuthorizationLevelInternal 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 AuthorizationLevelInternal 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
+ }
@@ -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 NitroModules
9
+
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.nitrogeolocation.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_GeolocationError.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 NitroModules
9
+
10
+
11
+ /**
12
+ * Wraps a Swift `(_ error: GeolocationError) -> 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_GeolocationError {
16
+ public typealias bridge = margelo.nitro.nitrogeolocation.bridge.swift
17
+
18
+ private let closure: (_ error: GeolocationError) -> Void
19
+
20
+ public init(_ closure: @escaping (_ error: GeolocationError) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(error: GeolocationError) -> 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_GeolocationError`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_GeolocationError>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_GeolocationError {
45
+ return Unmanaged<Func_void_GeolocationError>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }