react-native-nitro-geolocation 0.0.1 → 0.1.1

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 +318 -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,236 @@
1
+ ///
2
+ /// HybridNitroGeolocationSpec_cxx.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * A class implementation that bridges HybridNitroGeolocationSpec over to C++.
13
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
14
+ *
15
+ * Also, some Swift types need to be bridged with special handling:
16
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
17
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
18
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
19
+ */
20
+ open class HybridNitroGeolocationSpec_cxx {
21
+ /**
22
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::nitrogeolocation::bridge::swift`)
23
+ * from `NitroGeolocation-Swift-Cxx-Bridge.hpp`.
24
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
25
+ */
26
+ public typealias bridge = margelo.nitro.nitrogeolocation.bridge.swift
27
+
28
+ /**
29
+ * Holds an instance of the `HybridNitroGeolocationSpec` Swift protocol.
30
+ */
31
+ private var __implementation: any HybridNitroGeolocationSpec
32
+
33
+ /**
34
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
35
+ */
36
+ private var __cxxPart: bridge.std__weak_ptr_HybridNitroGeolocationSpec_
37
+
38
+ /**
39
+ * Create a new `HybridNitroGeolocationSpec_cxx` that wraps the given `HybridNitroGeolocationSpec`.
40
+ * All properties and methods bridge to C++ types.
41
+ */
42
+ public init(_ implementation: any HybridNitroGeolocationSpec) {
43
+ self.__implementation = implementation
44
+ self.__cxxPart = .init()
45
+ /* no base class */
46
+ }
47
+
48
+ /**
49
+ * Get the actual `HybridNitroGeolocationSpec` instance this class wraps.
50
+ */
51
+ @inline(__always)
52
+ public func getHybridNitroGeolocationSpec() -> any HybridNitroGeolocationSpec {
53
+ return __implementation
54
+ }
55
+
56
+ /**
57
+ * Casts this instance to a retained unsafe raw pointer.
58
+ * This acquires one additional strong reference on the object!
59
+ */
60
+ public func toUnsafe() -> UnsafeMutableRawPointer {
61
+ return Unmanaged.passRetained(self).toOpaque()
62
+ }
63
+
64
+ /**
65
+ * Casts an unsafe pointer to a `HybridNitroGeolocationSpec_cxx`.
66
+ * The pointer has to be a retained opaque `Unmanaged<HybridNitroGeolocationSpec_cxx>`.
67
+ * This removes one strong reference from the object!
68
+ */
69
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridNitroGeolocationSpec_cxx {
70
+ return Unmanaged<HybridNitroGeolocationSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
71
+ }
72
+
73
+ /**
74
+ * Gets (or creates) the C++ part of this Hybrid Object.
75
+ * The C++ part is a `std::shared_ptr<HybridNitroGeolocationSpec>`.
76
+ */
77
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridNitroGeolocationSpec_ {
78
+ let cachedCxxPart = self.__cxxPart.lock()
79
+ if cachedCxxPart.__convertToBool() {
80
+ return cachedCxxPart
81
+ } else {
82
+ let newCxxPart = bridge.create_std__shared_ptr_HybridNitroGeolocationSpec_(self.toUnsafe())
83
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridNitroGeolocationSpec_(newCxxPart)
84
+ return newCxxPart
85
+ }
86
+ }
87
+
88
+
89
+
90
+ /**
91
+ * Get the memory size of the Swift class (plus size of any other allocations)
92
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
93
+ */
94
+ @inline(__always)
95
+ public var memorySize: Int {
96
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
97
+ }
98
+
99
+ /**
100
+ * Call dispose() on the Swift class.
101
+ * This _may_ be called manually from JS.
102
+ */
103
+ @inline(__always)
104
+ public func dispose() {
105
+ self.__implementation.dispose()
106
+ }
107
+
108
+ // Properties
109
+
110
+
111
+ // Methods
112
+ @inline(__always)
113
+ public final func setRNConfiguration(config: RNConfigurationInternal) -> bridge.Result_void_ {
114
+ do {
115
+ try self.__implementation.setRNConfiguration(config: config)
116
+ return bridge.create_Result_void_()
117
+ } catch (let __error) {
118
+ let __exceptionPtr = __error.toCpp()
119
+ return bridge.create_Result_void_(__exceptionPtr)
120
+ }
121
+ }
122
+
123
+ @inline(__always)
124
+ public final func requestAuthorization(success: bridge.std__optional_std__function_void____, error: bridge.std__optional_std__function_void_const_GeolocationError_____error______) -> bridge.Result_void_ {
125
+ do {
126
+ try self.__implementation.requestAuthorization(success: { () -> (() -> Void)? in
127
+ if bridge.has_value_std__optional_std__function_void____(success) {
128
+ let __unwrapped = bridge.get_std__optional_std__function_void____(success)
129
+ return { () -> () -> Void in
130
+ let __wrappedFunction = bridge.wrap_Func_void(__unwrapped)
131
+ return { () -> Void in
132
+ __wrappedFunction.call()
133
+ }
134
+ }()
135
+ } else {
136
+ return nil
137
+ }
138
+ }(), error: { () -> ((_ error: GeolocationError) -> Void)? in
139
+ if bridge.has_value_std__optional_std__function_void_const_GeolocationError_____error______(error) {
140
+ let __unwrapped = bridge.get_std__optional_std__function_void_const_GeolocationError_____error______(error)
141
+ return { () -> (GeolocationError) -> Void in
142
+ let __wrappedFunction = bridge.wrap_Func_void_GeolocationError(__unwrapped)
143
+ return { (__error: GeolocationError) -> Void in
144
+ __wrappedFunction.call(__error)
145
+ }
146
+ }()
147
+ } else {
148
+ return nil
149
+ }
150
+ }())
151
+ return bridge.create_Result_void_()
152
+ } catch (let __error) {
153
+ let __exceptionPtr = __error.toCpp()
154
+ return bridge.create_Result_void_(__exceptionPtr)
155
+ }
156
+ }
157
+
158
+ @inline(__always)
159
+ public final func getCurrentPosition(success: bridge.Func_void_GeolocationResponse, error: bridge.std__optional_std__function_void_const_GeolocationError_____error______, options: bridge.std__optional_GeolocationOptions_) -> bridge.Result_void_ {
160
+ do {
161
+ try self.__implementation.getCurrentPosition(success: { () -> (GeolocationResponse) -> Void in
162
+ let __wrappedFunction = bridge.wrap_Func_void_GeolocationResponse(success)
163
+ return { (__position: GeolocationResponse) -> Void in
164
+ __wrappedFunction.call(__position)
165
+ }
166
+ }(), error: { () -> ((_ error: GeolocationError) -> Void)? in
167
+ if bridge.has_value_std__optional_std__function_void_const_GeolocationError_____error______(error) {
168
+ let __unwrapped = bridge.get_std__optional_std__function_void_const_GeolocationError_____error______(error)
169
+ return { () -> (GeolocationError) -> Void in
170
+ let __wrappedFunction = bridge.wrap_Func_void_GeolocationError(__unwrapped)
171
+ return { (__error: GeolocationError) -> Void in
172
+ __wrappedFunction.call(__error)
173
+ }
174
+ }()
175
+ } else {
176
+ return nil
177
+ }
178
+ }(), options: options.value)
179
+ return bridge.create_Result_void_()
180
+ } catch (let __error) {
181
+ let __exceptionPtr = __error.toCpp()
182
+ return bridge.create_Result_void_(__exceptionPtr)
183
+ }
184
+ }
185
+
186
+ @inline(__always)
187
+ public final func watchPosition(success: bridge.Func_void_GeolocationResponse, error: bridge.std__optional_std__function_void_const_GeolocationError_____error______, options: bridge.std__optional_GeolocationOptions_) -> bridge.Result_double_ {
188
+ do {
189
+ let __result = try self.__implementation.watchPosition(success: { () -> (GeolocationResponse) -> Void in
190
+ let __wrappedFunction = bridge.wrap_Func_void_GeolocationResponse(success)
191
+ return { (__position: GeolocationResponse) -> Void in
192
+ __wrappedFunction.call(__position)
193
+ }
194
+ }(), error: { () -> ((_ error: GeolocationError) -> Void)? in
195
+ if bridge.has_value_std__optional_std__function_void_const_GeolocationError_____error______(error) {
196
+ let __unwrapped = bridge.get_std__optional_std__function_void_const_GeolocationError_____error______(error)
197
+ return { () -> (GeolocationError) -> Void in
198
+ let __wrappedFunction = bridge.wrap_Func_void_GeolocationError(__unwrapped)
199
+ return { (__error: GeolocationError) -> Void in
200
+ __wrappedFunction.call(__error)
201
+ }
202
+ }()
203
+ } else {
204
+ return nil
205
+ }
206
+ }(), options: options.value)
207
+ let __resultCpp = __result
208
+ return bridge.create_Result_double_(__resultCpp)
209
+ } catch (let __error) {
210
+ let __exceptionPtr = __error.toCpp()
211
+ return bridge.create_Result_double_(__exceptionPtr)
212
+ }
213
+ }
214
+
215
+ @inline(__always)
216
+ public final func clearWatch(watchId: Double) -> bridge.Result_void_ {
217
+ do {
218
+ try self.__implementation.clearWatch(watchId: watchId)
219
+ return bridge.create_Result_void_()
220
+ } catch (let __error) {
221
+ let __exceptionPtr = __error.toCpp()
222
+ return bridge.create_Result_void_(__exceptionPtr)
223
+ }
224
+ }
225
+
226
+ @inline(__always)
227
+ public final func stopObserving() -> bridge.Result_void_ {
228
+ do {
229
+ try self.__implementation.stopObserving()
230
+ return bridge.create_Result_void_()
231
+ } catch (let __error) {
232
+ let __exceptionPtr = __error.toCpp()
233
+ return bridge.create_Result_void_(__exceptionPtr)
234
+ }
235
+ }
236
+ }
@@ -0,0 +1,44 @@
1
+ ///
2
+ /// LocationProviderInternal.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 `LocationProviderInternal`, backed by a C++ enum.
10
+ */
11
+ public typealias LocationProviderInternal = margelo.nitro.nitrogeolocation.LocationProviderInternal
12
+
13
+ public extension LocationProviderInternal {
14
+ /**
15
+ * Get a LocationProviderInternal 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 "auto":
21
+ self = .auto
22
+ case "playServices":
23
+ self = .playservices
24
+ case "android_platform":
25
+ self = .androidPlatform
26
+ default:
27
+ return nil
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Get the String value this LocationProviderInternal represents.
33
+ */
34
+ var stringValue: String {
35
+ switch self {
36
+ case .auto:
37
+ return "auto"
38
+ case .playservices:
39
+ return "playServices"
40
+ case .androidPlatform:
41
+ return "android_platform"
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,104 @@
1
+ ///
2
+ /// RNConfigurationInternal.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
+ * Represents an instance of `RNConfigurationInternal`, backed by a C++ struct.
12
+ */
13
+ public typealias RNConfigurationInternal = margelo.nitro.nitrogeolocation.RNConfigurationInternal
14
+
15
+ public extension RNConfigurationInternal {
16
+ private typealias bridge = margelo.nitro.nitrogeolocation.bridge.swift
17
+
18
+ /**
19
+ * Create a new instance of `RNConfigurationInternal`.
20
+ */
21
+ init(skipPermissionRequests: Bool, authorizationLevel: AuthorizationLevelInternal?, enableBackgroundLocationUpdates: Bool?, locationProvider: LocationProviderInternal?) {
22
+ self.init(skipPermissionRequests, { () -> bridge.std__optional_AuthorizationLevelInternal_ in
23
+ if let __unwrappedValue = authorizationLevel {
24
+ return bridge.create_std__optional_AuthorizationLevelInternal_(__unwrappedValue)
25
+ } else {
26
+ return .init()
27
+ }
28
+ }(), { () -> bridge.std__optional_bool_ in
29
+ if let __unwrappedValue = enableBackgroundLocationUpdates {
30
+ return bridge.create_std__optional_bool_(__unwrappedValue)
31
+ } else {
32
+ return .init()
33
+ }
34
+ }(), { () -> bridge.std__optional_LocationProviderInternal_ in
35
+ if let __unwrappedValue = locationProvider {
36
+ return bridge.create_std__optional_LocationProviderInternal_(__unwrappedValue)
37
+ } else {
38
+ return .init()
39
+ }
40
+ }())
41
+ }
42
+
43
+ var skipPermissionRequests: Bool {
44
+ @inline(__always)
45
+ get {
46
+ return self.__skipPermissionRequests
47
+ }
48
+ @inline(__always)
49
+ set {
50
+ self.__skipPermissionRequests = newValue
51
+ }
52
+ }
53
+
54
+ var authorizationLevel: AuthorizationLevelInternal? {
55
+ @inline(__always)
56
+ get {
57
+ return self.__authorizationLevel.value
58
+ }
59
+ @inline(__always)
60
+ set {
61
+ self.__authorizationLevel = { () -> bridge.std__optional_AuthorizationLevelInternal_ in
62
+ if let __unwrappedValue = newValue {
63
+ return bridge.create_std__optional_AuthorizationLevelInternal_(__unwrappedValue)
64
+ } else {
65
+ return .init()
66
+ }
67
+ }()
68
+ }
69
+ }
70
+
71
+ var enableBackgroundLocationUpdates: Bool? {
72
+ @inline(__always)
73
+ get {
74
+ return self.__enableBackgroundLocationUpdates.value
75
+ }
76
+ @inline(__always)
77
+ set {
78
+ self.__enableBackgroundLocationUpdates = { () -> bridge.std__optional_bool_ in
79
+ if let __unwrappedValue = newValue {
80
+ return bridge.create_std__optional_bool_(__unwrappedValue)
81
+ } else {
82
+ return .init()
83
+ }
84
+ }()
85
+ }
86
+ }
87
+
88
+ var locationProvider: LocationProviderInternal? {
89
+ @inline(__always)
90
+ get {
91
+ return self.__locationProvider.value
92
+ }
93
+ @inline(__always)
94
+ set {
95
+ self.__locationProvider = { () -> bridge.std__optional_LocationProviderInternal_ in
96
+ if let __unwrappedValue = newValue {
97
+ return bridge.create_std__optional_LocationProviderInternal_(__unwrappedValue)
98
+ } else {
99
+ return .init()
100
+ }
101
+ }()
102
+ }
103
+ }
104
+ }
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// AuthorizationLevelInternal.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
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::nitrogeolocation {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (AuthorizationLevelInternal).
30
+ */
31
+ enum class AuthorizationLevelInternal {
32
+ ALWAYS SWIFT_NAME(always) = 0,
33
+ WHENINUSE SWIFT_NAME(wheninuse) = 1,
34
+ AUTO SWIFT_NAME(auto) = 2,
35
+ } CLOSED_ENUM;
36
+
37
+ } // namespace margelo::nitro::nitrogeolocation
38
+
39
+ namespace margelo::nitro {
40
+
41
+ // C++ AuthorizationLevelInternal <> JS AuthorizationLevelInternal (union)
42
+ template <>
43
+ struct JSIConverter<margelo::nitro::nitrogeolocation::AuthorizationLevelInternal> final {
44
+ static inline margelo::nitro::nitrogeolocation::AuthorizationLevelInternal fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
45
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
46
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
47
+ case hashString("always"): return margelo::nitro::nitrogeolocation::AuthorizationLevelInternal::ALWAYS;
48
+ case hashString("whenInUse"): return margelo::nitro::nitrogeolocation::AuthorizationLevelInternal::WHENINUSE;
49
+ case hashString("auto"): return margelo::nitro::nitrogeolocation::AuthorizationLevelInternal::AUTO;
50
+ default: [[unlikely]]
51
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum AuthorizationLevelInternal - invalid value!");
52
+ }
53
+ }
54
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitrogeolocation::AuthorizationLevelInternal arg) {
55
+ switch (arg) {
56
+ case margelo::nitro::nitrogeolocation::AuthorizationLevelInternal::ALWAYS: return JSIConverter<std::string>::toJSI(runtime, "always");
57
+ case margelo::nitro::nitrogeolocation::AuthorizationLevelInternal::WHENINUSE: return JSIConverter<std::string>::toJSI(runtime, "whenInUse");
58
+ case margelo::nitro::nitrogeolocation::AuthorizationLevelInternal::AUTO: return JSIConverter<std::string>::toJSI(runtime, "auto");
59
+ default: [[unlikely]]
60
+ throw std::invalid_argument("Cannot convert AuthorizationLevelInternal to JS - invalid value: "
61
+ + std::to_string(static_cast<int>(arg)) + "!");
62
+ }
63
+ }
64
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
65
+ if (!value.isString()) {
66
+ return false;
67
+ }
68
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
69
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
70
+ case hashString("always"):
71
+ case hashString("whenInUse"):
72
+ case hashString("auto"):
73
+ return true;
74
+ default:
75
+ return false;
76
+ }
77
+ }
78
+ };
79
+
80
+ } // namespace margelo::nitro
@@ -0,0 +1,91 @@
1
+ ///
2
+ /// GeolocationCoordinates.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
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+
21
+
22
+
23
+ #include <optional>
24
+
25
+ namespace margelo::nitro::nitrogeolocation {
26
+
27
+ /**
28
+ * A struct which can be represented as a JavaScript object (GeolocationCoordinates).
29
+ */
30
+ struct GeolocationCoordinates {
31
+ public:
32
+ double latitude SWIFT_PRIVATE;
33
+ double longitude SWIFT_PRIVATE;
34
+ std::optional<double> altitude SWIFT_PRIVATE;
35
+ double accuracy SWIFT_PRIVATE;
36
+ std::optional<double> altitudeAccuracy SWIFT_PRIVATE;
37
+ std::optional<double> heading SWIFT_PRIVATE;
38
+ std::optional<double> speed SWIFT_PRIVATE;
39
+
40
+ public:
41
+ GeolocationCoordinates() = default;
42
+ explicit GeolocationCoordinates(double latitude, double longitude, std::optional<double> altitude, double accuracy, std::optional<double> altitudeAccuracy, std::optional<double> heading, std::optional<double> speed): latitude(latitude), longitude(longitude), altitude(altitude), accuracy(accuracy), altitudeAccuracy(altitudeAccuracy), heading(heading), speed(speed) {}
43
+ };
44
+
45
+ } // namespace margelo::nitro::nitrogeolocation
46
+
47
+ namespace margelo::nitro {
48
+
49
+ // C++ GeolocationCoordinates <> JS GeolocationCoordinates (object)
50
+ template <>
51
+ struct JSIConverter<margelo::nitro::nitrogeolocation::GeolocationCoordinates> final {
52
+ static inline margelo::nitro::nitrogeolocation::GeolocationCoordinates fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
53
+ jsi::Object obj = arg.asObject(runtime);
54
+ return margelo::nitro::nitrogeolocation::GeolocationCoordinates(
55
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "latitude")),
56
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "longitude")),
57
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "altitude")),
58
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "accuracy")),
59
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "altitudeAccuracy")),
60
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "heading")),
61
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "speed"))
62
+ );
63
+ }
64
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrogeolocation::GeolocationCoordinates& arg) {
65
+ jsi::Object obj(runtime);
66
+ obj.setProperty(runtime, "latitude", JSIConverter<double>::toJSI(runtime, arg.latitude));
67
+ obj.setProperty(runtime, "longitude", JSIConverter<double>::toJSI(runtime, arg.longitude));
68
+ obj.setProperty(runtime, "altitude", JSIConverter<std::optional<double>>::toJSI(runtime, arg.altitude));
69
+ obj.setProperty(runtime, "accuracy", JSIConverter<double>::toJSI(runtime, arg.accuracy));
70
+ obj.setProperty(runtime, "altitudeAccuracy", JSIConverter<std::optional<double>>::toJSI(runtime, arg.altitudeAccuracy));
71
+ obj.setProperty(runtime, "heading", JSIConverter<std::optional<double>>::toJSI(runtime, arg.heading));
72
+ obj.setProperty(runtime, "speed", JSIConverter<std::optional<double>>::toJSI(runtime, arg.speed));
73
+ return obj;
74
+ }
75
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
76
+ if (!value.isObject()) {
77
+ return false;
78
+ }
79
+ jsi::Object obj = value.getObject(runtime);
80
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "latitude"))) return false;
81
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "longitude"))) return false;
82
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "altitude"))) return false;
83
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "accuracy"))) return false;
84
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "altitudeAccuracy"))) return false;
85
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "heading"))) return false;
86
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "speed"))) return false;
87
+ return true;
88
+ }
89
+ };
90
+
91
+ } // namespace margelo::nitro
@@ -0,0 +1,83 @@
1
+ ///
2
+ /// GeolocationError.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
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+
21
+
22
+
23
+ #include <string>
24
+
25
+ namespace margelo::nitro::nitrogeolocation {
26
+
27
+ /**
28
+ * A struct which can be represented as a JavaScript object (GeolocationError).
29
+ */
30
+ struct GeolocationError {
31
+ public:
32
+ double code SWIFT_PRIVATE;
33
+ std::string message SWIFT_PRIVATE;
34
+ double PERMISSION_DENIED SWIFT_PRIVATE;
35
+ double POSITION_UNAVAILABLE SWIFT_PRIVATE;
36
+ double TIMEOUT SWIFT_PRIVATE;
37
+
38
+ public:
39
+ GeolocationError() = default;
40
+ explicit GeolocationError(double code, std::string message, double PERMISSION_DENIED, double POSITION_UNAVAILABLE, double TIMEOUT): code(code), message(message), PERMISSION_DENIED(PERMISSION_DENIED), POSITION_UNAVAILABLE(POSITION_UNAVAILABLE), TIMEOUT(TIMEOUT) {}
41
+ };
42
+
43
+ } // namespace margelo::nitro::nitrogeolocation
44
+
45
+ namespace margelo::nitro {
46
+
47
+ // C++ GeolocationError <> JS GeolocationError (object)
48
+ template <>
49
+ struct JSIConverter<margelo::nitro::nitrogeolocation::GeolocationError> final {
50
+ static inline margelo::nitro::nitrogeolocation::GeolocationError fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
51
+ jsi::Object obj = arg.asObject(runtime);
52
+ return margelo::nitro::nitrogeolocation::GeolocationError(
53
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "code")),
54
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "message")),
55
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "PERMISSION_DENIED")),
56
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "POSITION_UNAVAILABLE")),
57
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "TIMEOUT"))
58
+ );
59
+ }
60
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrogeolocation::GeolocationError& arg) {
61
+ jsi::Object obj(runtime);
62
+ obj.setProperty(runtime, "code", JSIConverter<double>::toJSI(runtime, arg.code));
63
+ obj.setProperty(runtime, "message", JSIConverter<std::string>::toJSI(runtime, arg.message));
64
+ obj.setProperty(runtime, "PERMISSION_DENIED", JSIConverter<double>::toJSI(runtime, arg.PERMISSION_DENIED));
65
+ obj.setProperty(runtime, "POSITION_UNAVAILABLE", JSIConverter<double>::toJSI(runtime, arg.POSITION_UNAVAILABLE));
66
+ obj.setProperty(runtime, "TIMEOUT", JSIConverter<double>::toJSI(runtime, arg.TIMEOUT));
67
+ return obj;
68
+ }
69
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
70
+ if (!value.isObject()) {
71
+ return false;
72
+ }
73
+ jsi::Object obj = value.getObject(runtime);
74
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "code"))) return false;
75
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "message"))) return false;
76
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "PERMISSION_DENIED"))) return false;
77
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "POSITION_UNAVAILABLE"))) return false;
78
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "TIMEOUT"))) return false;
79
+ return true;
80
+ }
81
+ };
82
+
83
+ } // namespace margelo::nitro