react-native-nitro-geolocation 0.1.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/GetCurrentPosition.kt +4 -4
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/NitroGeolocation.kt +642 -50
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/NitroGeolocationCompat.kt +81 -0
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/WatchPosition.kt +4 -4
- package/ios/LocationManager.swift +4 -4
- package/ios/NitroGeolocation.swift +543 -68
- package/ios/NitroGeolocationCompat.swift +109 -0
- package/nitrogen/generated/android/c++/JAuthorizationLevel.hpp +61 -0
- package/nitrogen/generated/android/c++/JAuthorizationLevelInternal.hpp +3 -4
- package/nitrogen/generated/android/c++/JFunc_void.hpp +2 -1
- package/nitrogen/generated/android/c++/JFunc_void_GeolocationError.hpp +2 -1
- package/nitrogen/generated/android/c++/JFunc_void_GeolocationResponse.hpp +6 -1
- package/nitrogen/generated/android/c++/JFunc_void_LocationError.hpp +78 -0
- package/nitrogen/generated/android/c++/JGeolocationCoordinates.hpp +25 -17
- package/nitrogen/generated/android/c++/JGeolocationError.hpp +5 -1
- package/nitrogen/generated/android/c++/JGeolocationOptions.hpp +5 -1
- package/nitrogen/generated/android/c++/JGeolocationResponse.hpp +9 -1
- package/nitrogen/generated/android/c++/JHybridNitroGeolocationCompatSpec.cpp +109 -0
- package/nitrogen/generated/android/c++/JHybridNitroGeolocationCompatSpec.hpp +70 -0
- package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.cpp +98 -42
- package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.hpp +7 -5
- package/nitrogen/generated/android/c++/JLocationError.hpp +61 -0
- package/nitrogen/generated/android/c++/JLocationProvider.hpp +61 -0
- package/nitrogen/generated/android/c++/JLocationProviderInternal.hpp +3 -4
- package/nitrogen/generated/android/c++/JLocationRequestOptions.hpp +81 -0
- package/nitrogen/generated/android/c++/JModernGeolocationConfiguration.hpp +73 -0
- package/nitrogen/generated/android/c++/JNullableDouble.cpp +26 -0
- package/nitrogen/generated/android/c++/JNullableDouble.hpp +69 -0
- package/nitrogen/generated/android/c++/JPermissionStatus.hpp +64 -0
- package/nitrogen/generated/android/c++/JRNConfigurationInternal.hpp +5 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AuthorizationLevel.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AuthorizationLevelInternal.kt +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void.kt +0 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_GeolocationError.kt +0 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_GeolocationResponse.kt +0 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_LocationError.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationCoordinates.kt +34 -25
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationError.kt +27 -18
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationOptions.kt +33 -24
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationResponse.kt +18 -9
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HybridNitroGeolocationCompatSpec.kt +92 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HybridNitroGeolocationSpec.kt +17 -17
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationError.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationProvider.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationProviderInternal.kt +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationRequestOptions.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/ModernGeolocationConfiguration.kt +47 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/NullableDouble.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/PermissionStatus.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/RNConfigurationInternal.kt +24 -15
- package/nitrogen/generated/android/nitrogeolocation+autolinking.cmake +3 -0
- package/nitrogen/generated/android/nitrogeolocationOnLoad.cpp +14 -2
- package/nitrogen/generated/ios/NitroGeolocation+autolinking.rb +1 -1
- package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.cpp +55 -13
- package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.hpp +325 -68
- package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Umbrella.hpp +26 -0
- package/nitrogen/generated/ios/NitroGeolocationAutolinking.mm +8 -0
- package/nitrogen/generated/ios/NitroGeolocationAutolinking.swift +15 -0
- package/nitrogen/generated/ios/c++/HybridNitroGeolocationCompatSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroGeolocationCompatSpecSwift.hpp +130 -0
- package/nitrogen/generated/ios/c++/HybridNitroGeolocationSpecSwift.hpp +47 -26
- package/nitrogen/generated/ios/swift/AuthorizationLevel.swift +44 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +1 -1
- package/nitrogen/generated/ios/swift/Func_void_GeolocationError.swift +1 -1
- package/nitrogen/generated/ios/swift/Func_void_GeolocationResponse.swift +1 -1
- package/nitrogen/generated/ios/swift/Func_void_LocationError.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_PermissionStatus.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/GeolocationCoordinates.swift +132 -93
- package/nitrogen/generated/ios/swift/GeolocationError.swift +11 -40
- package/nitrogen/generated/ios/swift/GeolocationOptions.swift +29 -98
- package/nitrogen/generated/ios/swift/GeolocationResponse.swift +5 -16
- package/nitrogen/generated/ios/swift/HybridNitroGeolocationCompatSpec.swift +61 -0
- package/nitrogen/generated/ios/swift/HybridNitroGeolocationCompatSpec_cxx.swift +244 -0
- package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec.swift +13 -5
- package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec_cxx.swift +66 -64
- package/nitrogen/generated/ios/swift/LocationError.swift +35 -0
- package/nitrogen/generated/ios/swift/LocationProvider.swift +44 -0
- package/nitrogen/generated/ios/swift/LocationRequestOptions.swift +116 -0
- package/nitrogen/generated/ios/swift/ModernGeolocationConfiguration.swift +83 -0
- package/nitrogen/generated/ios/swift/NullableDouble.swift +18 -0
- package/nitrogen/generated/ios/swift/PermissionStatus.swift +48 -0
- package/nitrogen/generated/ios/swift/RNConfigurationInternal.swift +16 -50
- package/nitrogen/generated/shared/c++/AuthorizationLevel.hpp +80 -0
- package/nitrogen/generated/shared/c++/GeolocationCoordinates.hpp +45 -27
- package/nitrogen/generated/shared/c++/GeolocationError.hpp +32 -16
- package/nitrogen/generated/shared/c++/GeolocationOptions.hpp +38 -22
- package/nitrogen/generated/shared/c++/GeolocationResponse.hpp +23 -7
- package/nitrogen/generated/shared/c++/HybridNitroGeolocationCompatSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridNitroGeolocationCompatSpec.hpp +79 -0
- package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.cpp +4 -3
- package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.hpp +22 -16
- package/nitrogen/generated/shared/c++/LocationError.hpp +87 -0
- package/nitrogen/generated/shared/c++/LocationProvider.hpp +80 -0
- package/nitrogen/generated/shared/c++/LocationRequestOptions.hpp +107 -0
- package/nitrogen/generated/shared/c++/ModernGeolocationConfiguration.hpp +100 -0
- package/nitrogen/generated/shared/c++/PermissionStatus.hpp +84 -0
- package/nitrogen/generated/shared/c++/RNConfigurationInternal.hpp +29 -13
- package/package.json +16 -7
- package/src/GeolocationClient.ts +116 -0
- package/src/NitroGeolocation.nitro.ts +177 -30
- package/src/NitroGeolocationCompat.nitro.ts +41 -0
- package/src/NitroGeolocationModule.ts +6 -0
- package/src/compat/clearWatch.ts +9 -0
- package/src/{getCurrentPosition.ts → compat/getCurrentPosition.ts} +7 -3
- package/src/compat/index.tsx +34 -0
- package/src/compat/requestAuthorization.ts +9 -0
- package/src/{setRNConfiguration.ts → compat/setRNConfiguration.ts} +6 -4
- package/src/{stopObserving.ts → compat/stopObserving.ts} +4 -2
- package/src/{watchPosition.ts → compat/watchPosition.ts} +7 -6
- package/src/components/GeolocationProvider.tsx +91 -0
- package/src/components/index.ts +13 -0
- package/src/hooks/index.ts +9 -0
- package/src/hooks/useCheckPermission.ts +46 -0
- package/src/hooks/useGetCurrentPosition.ts +140 -0
- package/src/hooks/useRequestPermission.ts +98 -0
- package/src/hooks/useWatchPosition.ts +130 -0
- package/src/index.tsx +72 -27
- package/src/types.ts +32 -4
- package/src/utils/cache.ts +25 -0
- package/src/utils/config.ts +93 -0
- package/src/utils/errors.ts +82 -0
- package/src/utils/index.ts +27 -0
- package/src/utils/provider.ts +61 -0
- package/src/utils/quality.ts +98 -0
- package/src/clearWatch.ts +0 -13
- package/src/requestAuthorization.ts +0 -9
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroGeolocationCompatSpec_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 HybridNitroGeolocationCompatSpec 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 HybridNitroGeolocationCompatSpec_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 `HybridNitroGeolocationCompatSpec` Swift protocol.
|
|
30
|
+
*/
|
|
31
|
+
private var __implementation: any HybridNitroGeolocationCompatSpec
|
|
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_HybridNitroGeolocationCompatSpec_
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create a new `HybridNitroGeolocationCompatSpec_cxx` that wraps the given `HybridNitroGeolocationCompatSpec`.
|
|
40
|
+
* All properties and methods bridge to C++ types.
|
|
41
|
+
*/
|
|
42
|
+
public init(_ implementation: any HybridNitroGeolocationCompatSpec) {
|
|
43
|
+
self.__implementation = implementation
|
|
44
|
+
self.__cxxPart = .init()
|
|
45
|
+
/* no base class */
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get the actual `HybridNitroGeolocationCompatSpec` instance this class wraps.
|
|
50
|
+
*/
|
|
51
|
+
@inline(__always)
|
|
52
|
+
public func getHybridNitroGeolocationCompatSpec() -> any HybridNitroGeolocationCompatSpec {
|
|
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 `HybridNitroGeolocationCompatSpec_cxx`.
|
|
66
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridNitroGeolocationCompatSpec_cxx>`.
|
|
67
|
+
* This removes one strong reference from the object!
|
|
68
|
+
*/
|
|
69
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridNitroGeolocationCompatSpec_cxx {
|
|
70
|
+
return Unmanaged<HybridNitroGeolocationCompatSpec_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<HybridNitroGeolocationCompatSpec>`.
|
|
76
|
+
*/
|
|
77
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridNitroGeolocationCompatSpec_ {
|
|
78
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
79
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
80
|
+
return cachedCxxPart
|
|
81
|
+
} else {
|
|
82
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridNitroGeolocationCompatSpec_(self.toUnsafe())
|
|
83
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridNitroGeolocationCompatSpec_(newCxxPart)
|
|
84
|
+
return newCxxPart
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
92
|
+
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
93
|
+
*/
|
|
94
|
+
@inline(__always)
|
|
95
|
+
public var memorySize: Int {
|
|
96
|
+
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Call dispose() on the Swift class.
|
|
101
|
+
* This _may_ be called manually from JS.
|
|
102
|
+
*/
|
|
103
|
+
@inline(__always)
|
|
104
|
+
public func dispose() {
|
|
105
|
+
self.__implementation.dispose()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Call toString() on the Swift class.
|
|
110
|
+
*/
|
|
111
|
+
@inline(__always)
|
|
112
|
+
public func toString() -> String {
|
|
113
|
+
return self.__implementation.toString()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Properties
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
// Methods
|
|
120
|
+
@inline(__always)
|
|
121
|
+
public final func setRNConfiguration(config: RNConfigurationInternal) -> bridge.Result_void_ {
|
|
122
|
+
do {
|
|
123
|
+
try self.__implementation.setRNConfiguration(config: config)
|
|
124
|
+
return bridge.create_Result_void_()
|
|
125
|
+
} catch (let __error) {
|
|
126
|
+
let __exceptionPtr = __error.toCpp()
|
|
127
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@inline(__always)
|
|
132
|
+
public final func requestAuthorization(success: bridge.std__optional_std__function_void____, error: bridge.std__optional_std__function_void_const_GeolocationError_____error______) -> bridge.Result_void_ {
|
|
133
|
+
do {
|
|
134
|
+
try self.__implementation.requestAuthorization(success: { () -> (() -> Void)? in
|
|
135
|
+
if bridge.has_value_std__optional_std__function_void____(success) {
|
|
136
|
+
let __unwrapped = bridge.get_std__optional_std__function_void____(success)
|
|
137
|
+
return { () -> () -> Void in
|
|
138
|
+
let __wrappedFunction = bridge.wrap_Func_void(__unwrapped)
|
|
139
|
+
return { () -> Void in
|
|
140
|
+
__wrappedFunction.call()
|
|
141
|
+
}
|
|
142
|
+
}()
|
|
143
|
+
} else {
|
|
144
|
+
return nil
|
|
145
|
+
}
|
|
146
|
+
}(), error: { () -> ((_ error: GeolocationError) -> Void)? in
|
|
147
|
+
if bridge.has_value_std__optional_std__function_void_const_GeolocationError_____error______(error) {
|
|
148
|
+
let __unwrapped = bridge.get_std__optional_std__function_void_const_GeolocationError_____error______(error)
|
|
149
|
+
return { () -> (GeolocationError) -> Void in
|
|
150
|
+
let __wrappedFunction = bridge.wrap_Func_void_GeolocationError(__unwrapped)
|
|
151
|
+
return { (__error: GeolocationError) -> Void in
|
|
152
|
+
__wrappedFunction.call(__error)
|
|
153
|
+
}
|
|
154
|
+
}()
|
|
155
|
+
} else {
|
|
156
|
+
return nil
|
|
157
|
+
}
|
|
158
|
+
}())
|
|
159
|
+
return bridge.create_Result_void_()
|
|
160
|
+
} catch (let __error) {
|
|
161
|
+
let __exceptionPtr = __error.toCpp()
|
|
162
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@inline(__always)
|
|
167
|
+
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_ {
|
|
168
|
+
do {
|
|
169
|
+
try self.__implementation.getCurrentPosition(success: { () -> (GeolocationResponse) -> Void in
|
|
170
|
+
let __wrappedFunction = bridge.wrap_Func_void_GeolocationResponse(success)
|
|
171
|
+
return { (__position: GeolocationResponse) -> Void in
|
|
172
|
+
__wrappedFunction.call(__position)
|
|
173
|
+
}
|
|
174
|
+
}(), error: { () -> ((_ error: GeolocationError) -> Void)? in
|
|
175
|
+
if bridge.has_value_std__optional_std__function_void_const_GeolocationError_____error______(error) {
|
|
176
|
+
let __unwrapped = bridge.get_std__optional_std__function_void_const_GeolocationError_____error______(error)
|
|
177
|
+
return { () -> (GeolocationError) -> Void in
|
|
178
|
+
let __wrappedFunction = bridge.wrap_Func_void_GeolocationError(__unwrapped)
|
|
179
|
+
return { (__error: GeolocationError) -> Void in
|
|
180
|
+
__wrappedFunction.call(__error)
|
|
181
|
+
}
|
|
182
|
+
}()
|
|
183
|
+
} else {
|
|
184
|
+
return nil
|
|
185
|
+
}
|
|
186
|
+
}(), options: options.value)
|
|
187
|
+
return bridge.create_Result_void_()
|
|
188
|
+
} catch (let __error) {
|
|
189
|
+
let __exceptionPtr = __error.toCpp()
|
|
190
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
@inline(__always)
|
|
195
|
+
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_ {
|
|
196
|
+
do {
|
|
197
|
+
let __result = try self.__implementation.watchPosition(success: { () -> (GeolocationResponse) -> Void in
|
|
198
|
+
let __wrappedFunction = bridge.wrap_Func_void_GeolocationResponse(success)
|
|
199
|
+
return { (__position: GeolocationResponse) -> Void in
|
|
200
|
+
__wrappedFunction.call(__position)
|
|
201
|
+
}
|
|
202
|
+
}(), error: { () -> ((_ error: GeolocationError) -> Void)? in
|
|
203
|
+
if bridge.has_value_std__optional_std__function_void_const_GeolocationError_____error______(error) {
|
|
204
|
+
let __unwrapped = bridge.get_std__optional_std__function_void_const_GeolocationError_____error______(error)
|
|
205
|
+
return { () -> (GeolocationError) -> Void in
|
|
206
|
+
let __wrappedFunction = bridge.wrap_Func_void_GeolocationError(__unwrapped)
|
|
207
|
+
return { (__error: GeolocationError) -> Void in
|
|
208
|
+
__wrappedFunction.call(__error)
|
|
209
|
+
}
|
|
210
|
+
}()
|
|
211
|
+
} else {
|
|
212
|
+
return nil
|
|
213
|
+
}
|
|
214
|
+
}(), options: options.value)
|
|
215
|
+
let __resultCpp = __result
|
|
216
|
+
return bridge.create_Result_double_(__resultCpp)
|
|
217
|
+
} catch (let __error) {
|
|
218
|
+
let __exceptionPtr = __error.toCpp()
|
|
219
|
+
return bridge.create_Result_double_(__exceptionPtr)
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
@inline(__always)
|
|
224
|
+
public final func clearWatch(watchId: Double) -> bridge.Result_void_ {
|
|
225
|
+
do {
|
|
226
|
+
try self.__implementation.clearWatch(watchId: watchId)
|
|
227
|
+
return bridge.create_Result_void_()
|
|
228
|
+
} catch (let __error) {
|
|
229
|
+
let __exceptionPtr = __error.toCpp()
|
|
230
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
@inline(__always)
|
|
235
|
+
public final func stopObserving() -> bridge.Result_void_ {
|
|
236
|
+
do {
|
|
237
|
+
try self.__implementation.stopObserving()
|
|
238
|
+
return bridge.create_Result_void_()
|
|
239
|
+
} catch (let __error) {
|
|
240
|
+
let __exceptionPtr = __error.toCpp()
|
|
241
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
@@ -14,14 +14,22 @@ public protocol HybridNitroGeolocationSpec_protocol: HybridObject {
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
// Methods
|
|
17
|
-
func
|
|
18
|
-
func
|
|
19
|
-
func
|
|
20
|
-
func
|
|
21
|
-
func
|
|
17
|
+
func setConfiguration(config: ModernGeolocationConfiguration) throws -> Void
|
|
18
|
+
func checkPermission() throws -> Promise<PermissionStatus>
|
|
19
|
+
func requestPermission() throws -> Promise<PermissionStatus>
|
|
20
|
+
func getCurrentPosition(options: LocationRequestOptions?) throws -> Promise<GeolocationResponse>
|
|
21
|
+
func watchPosition(success: @escaping (_ position: GeolocationResponse) -> Void, error: ((_ error: LocationError) -> Void)?, options: LocationRequestOptions?) throws -> String
|
|
22
|
+
func unwatch(token: String) throws -> Void
|
|
22
23
|
func stopObserving() throws -> Void
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
public extension HybridNitroGeolocationSpec_protocol {
|
|
27
|
+
/// Default implementation of ``HybridObject.toString``
|
|
28
|
+
func toString() -> String {
|
|
29
|
+
return "[HybridObject NitroGeolocation]"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
25
33
|
/// See ``HybridNitroGeolocationSpec``
|
|
26
34
|
open class HybridNitroGeolocationSpec_base {
|
|
27
35
|
private weak var cxxWrapper: HybridNitroGeolocationSpec_cxx? = nil
|
|
@@ -76,7 +76,7 @@ open class HybridNitroGeolocationSpec_cxx {
|
|
|
76
76
|
*/
|
|
77
77
|
public func getCxxPart() -> bridge.std__shared_ptr_HybridNitroGeolocationSpec_ {
|
|
78
78
|
let cachedCxxPart = self.__cxxPart.lock()
|
|
79
|
-
if cachedCxxPart
|
|
79
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
80
80
|
return cachedCxxPart
|
|
81
81
|
} else {
|
|
82
82
|
let newCxxPart = bridge.create_std__shared_ptr_HybridNitroGeolocationSpec_(self.toUnsafe())
|
|
@@ -105,14 +105,22 @@ open class HybridNitroGeolocationSpec_cxx {
|
|
|
105
105
|
self.__implementation.dispose()
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Call toString() on the Swift class.
|
|
110
|
+
*/
|
|
111
|
+
@inline(__always)
|
|
112
|
+
public func toString() -> String {
|
|
113
|
+
return self.__implementation.toString()
|
|
114
|
+
}
|
|
115
|
+
|
|
108
116
|
// Properties
|
|
109
117
|
|
|
110
118
|
|
|
111
119
|
// Methods
|
|
112
120
|
@inline(__always)
|
|
113
|
-
public final func
|
|
121
|
+
public final func setConfiguration(config: ModernGeolocationConfiguration) -> bridge.Result_void_ {
|
|
114
122
|
do {
|
|
115
|
-
try self.__implementation.
|
|
123
|
+
try self.__implementation.setConfiguration(config: config)
|
|
116
124
|
return bridge.create_Result_void_()
|
|
117
125
|
} catch (let __error) {
|
|
118
126
|
let __exceptionPtr = __error.toCpp()
|
|
@@ -121,82 +129,76 @@ open class HybridNitroGeolocationSpec_cxx {
|
|
|
121
129
|
}
|
|
122
130
|
|
|
123
131
|
@inline(__always)
|
|
124
|
-
public final func
|
|
132
|
+
public final func checkPermission() -> bridge.Result_std__shared_ptr_Promise_PermissionStatus___ {
|
|
125
133
|
do {
|
|
126
|
-
try self.__implementation.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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_()
|
|
134
|
+
let __result = try self.__implementation.checkPermission()
|
|
135
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_PermissionStatus__ in
|
|
136
|
+
let __promise = bridge.create_std__shared_ptr_Promise_PermissionStatus__()
|
|
137
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_PermissionStatus__(__promise)
|
|
138
|
+
__result
|
|
139
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
140
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
141
|
+
return __promise
|
|
142
|
+
}()
|
|
143
|
+
return bridge.create_Result_std__shared_ptr_Promise_PermissionStatus___(__resultCpp)
|
|
152
144
|
} catch (let __error) {
|
|
153
145
|
let __exceptionPtr = __error.toCpp()
|
|
154
|
-
return bridge.
|
|
146
|
+
return bridge.create_Result_std__shared_ptr_Promise_PermissionStatus___(__exceptionPtr)
|
|
155
147
|
}
|
|
156
148
|
}
|
|
157
149
|
|
|
158
150
|
@inline(__always)
|
|
159
|
-
public final func
|
|
151
|
+
public final func requestPermission() -> bridge.Result_std__shared_ptr_Promise_PermissionStatus___ {
|
|
160
152
|
do {
|
|
161
|
-
try self.__implementation.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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_()
|
|
153
|
+
let __result = try self.__implementation.requestPermission()
|
|
154
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_PermissionStatus__ in
|
|
155
|
+
let __promise = bridge.create_std__shared_ptr_Promise_PermissionStatus__()
|
|
156
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_PermissionStatus__(__promise)
|
|
157
|
+
__result
|
|
158
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
159
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
160
|
+
return __promise
|
|
161
|
+
}()
|
|
162
|
+
return bridge.create_Result_std__shared_ptr_Promise_PermissionStatus___(__resultCpp)
|
|
180
163
|
} catch (let __error) {
|
|
181
164
|
let __exceptionPtr = __error.toCpp()
|
|
182
|
-
return bridge.
|
|
165
|
+
return bridge.create_Result_std__shared_ptr_Promise_PermissionStatus___(__exceptionPtr)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@inline(__always)
|
|
170
|
+
public final func getCurrentPosition(options: bridge.std__optional_LocationRequestOptions_) -> bridge.Result_std__shared_ptr_Promise_GeolocationResponse___ {
|
|
171
|
+
do {
|
|
172
|
+
let __result = try self.__implementation.getCurrentPosition(options: options.value)
|
|
173
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_GeolocationResponse__ in
|
|
174
|
+
let __promise = bridge.create_std__shared_ptr_Promise_GeolocationResponse__()
|
|
175
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_GeolocationResponse__(__promise)
|
|
176
|
+
__result
|
|
177
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
178
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
179
|
+
return __promise
|
|
180
|
+
}()
|
|
181
|
+
return bridge.create_Result_std__shared_ptr_Promise_GeolocationResponse___(__resultCpp)
|
|
182
|
+
} catch (let __error) {
|
|
183
|
+
let __exceptionPtr = __error.toCpp()
|
|
184
|
+
return bridge.create_Result_std__shared_ptr_Promise_GeolocationResponse___(__exceptionPtr)
|
|
183
185
|
}
|
|
184
186
|
}
|
|
185
187
|
|
|
186
188
|
@inline(__always)
|
|
187
|
-
public final func watchPosition(success: bridge.Func_void_GeolocationResponse, error: bridge.
|
|
189
|
+
public final func watchPosition(success: bridge.Func_void_GeolocationResponse, error: bridge.std__optional_std__function_void_const_LocationError_____error______, options: bridge.std__optional_LocationRequestOptions_) -> bridge.Result_std__string_ {
|
|
188
190
|
do {
|
|
189
191
|
let __result = try self.__implementation.watchPosition(success: { () -> (GeolocationResponse) -> Void in
|
|
190
192
|
let __wrappedFunction = bridge.wrap_Func_void_GeolocationResponse(success)
|
|
191
193
|
return { (__position: GeolocationResponse) -> Void in
|
|
192
194
|
__wrappedFunction.call(__position)
|
|
193
195
|
}
|
|
194
|
-
}(), error: { () -> ((_ error:
|
|
195
|
-
if bridge.
|
|
196
|
-
let __unwrapped = bridge.
|
|
197
|
-
return { () -> (
|
|
198
|
-
let __wrappedFunction = bridge.
|
|
199
|
-
return { (__error:
|
|
196
|
+
}(), error: { () -> ((_ error: LocationError) -> Void)? in
|
|
197
|
+
if bridge.has_value_std__optional_std__function_void_const_LocationError_____error______(error) {
|
|
198
|
+
let __unwrapped = bridge.get_std__optional_std__function_void_const_LocationError_____error______(error)
|
|
199
|
+
return { () -> (LocationError) -> Void in
|
|
200
|
+
let __wrappedFunction = bridge.wrap_Func_void_LocationError(__unwrapped)
|
|
201
|
+
return { (__error: LocationError) -> Void in
|
|
200
202
|
__wrappedFunction.call(__error)
|
|
201
203
|
}
|
|
202
204
|
}()
|
|
@@ -204,18 +206,18 @@ open class HybridNitroGeolocationSpec_cxx {
|
|
|
204
206
|
return nil
|
|
205
207
|
}
|
|
206
208
|
}(), options: options.value)
|
|
207
|
-
let __resultCpp = __result
|
|
208
|
-
return bridge.
|
|
209
|
+
let __resultCpp = std.string(__result)
|
|
210
|
+
return bridge.create_Result_std__string_(__resultCpp)
|
|
209
211
|
} catch (let __error) {
|
|
210
212
|
let __exceptionPtr = __error.toCpp()
|
|
211
|
-
return bridge.
|
|
213
|
+
return bridge.create_Result_std__string_(__exceptionPtr)
|
|
212
214
|
}
|
|
213
215
|
}
|
|
214
216
|
|
|
215
217
|
@inline(__always)
|
|
216
|
-
public final func
|
|
218
|
+
public final func unwatch(token: std.string) -> bridge.Result_void_ {
|
|
217
219
|
do {
|
|
218
|
-
try self.__implementation.
|
|
220
|
+
try self.__implementation.unwatch(token: String(token))
|
|
219
221
|
return bridge.create_Result_void_()
|
|
220
222
|
} catch (let __error) {
|
|
221
223
|
let __exceptionPtr = __error.toCpp()
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// 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
|
+
* Represents an instance of `LocationError`, backed by a C++ struct.
|
|
13
|
+
*/
|
|
14
|
+
public typealias LocationError = margelo.nitro.nitrogeolocation.LocationError
|
|
15
|
+
|
|
16
|
+
public extension LocationError {
|
|
17
|
+
private typealias bridge = margelo.nitro.nitrogeolocation.bridge.swift
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a new instance of `LocationError`.
|
|
21
|
+
*/
|
|
22
|
+
init(code: Double, message: String) {
|
|
23
|
+
self.init(code, std.string(message))
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@inline(__always)
|
|
27
|
+
var code: Double {
|
|
28
|
+
return self.__code
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@inline(__always)
|
|
32
|
+
var message: String {
|
|
33
|
+
return String(self.__message)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// LocationProvider.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 `LocationProvider`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias LocationProvider = margelo.nitro.nitrogeolocation.LocationProvider
|
|
12
|
+
|
|
13
|
+
public extension LocationProvider {
|
|
14
|
+
/**
|
|
15
|
+
* Get a LocationProvider 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 LocationProvider 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,116 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// LocationRequestOptions.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Represents an instance of `LocationRequestOptions`, backed by a C++ struct.
|
|
13
|
+
*/
|
|
14
|
+
public typealias LocationRequestOptions = margelo.nitro.nitrogeolocation.LocationRequestOptions
|
|
15
|
+
|
|
16
|
+
public extension LocationRequestOptions {
|
|
17
|
+
private typealias bridge = margelo.nitro.nitrogeolocation.bridge.swift
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a new instance of `LocationRequestOptions`.
|
|
21
|
+
*/
|
|
22
|
+
init(timeout: Double?, maximumAge: Double?, enableHighAccuracy: Bool?, interval: Double?, fastestInterval: Double?, distanceFilter: Double?, useSignificantChanges: Bool?) {
|
|
23
|
+
self.init({ () -> bridge.std__optional_double_ in
|
|
24
|
+
if let __unwrappedValue = timeout {
|
|
25
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
26
|
+
} else {
|
|
27
|
+
return .init()
|
|
28
|
+
}
|
|
29
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
30
|
+
if let __unwrappedValue = maximumAge {
|
|
31
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
32
|
+
} else {
|
|
33
|
+
return .init()
|
|
34
|
+
}
|
|
35
|
+
}(), { () -> bridge.std__optional_bool_ in
|
|
36
|
+
if let __unwrappedValue = enableHighAccuracy {
|
|
37
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
38
|
+
} else {
|
|
39
|
+
return .init()
|
|
40
|
+
}
|
|
41
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
42
|
+
if let __unwrappedValue = interval {
|
|
43
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
44
|
+
} else {
|
|
45
|
+
return .init()
|
|
46
|
+
}
|
|
47
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
48
|
+
if let __unwrappedValue = fastestInterval {
|
|
49
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
50
|
+
} else {
|
|
51
|
+
return .init()
|
|
52
|
+
}
|
|
53
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
54
|
+
if let __unwrappedValue = distanceFilter {
|
|
55
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
56
|
+
} else {
|
|
57
|
+
return .init()
|
|
58
|
+
}
|
|
59
|
+
}(), { () -> bridge.std__optional_bool_ in
|
|
60
|
+
if let __unwrappedValue = useSignificantChanges {
|
|
61
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
62
|
+
} else {
|
|
63
|
+
return .init()
|
|
64
|
+
}
|
|
65
|
+
}())
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@inline(__always)
|
|
69
|
+
var timeout: Double? {
|
|
70
|
+
return self.__timeout.value
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@inline(__always)
|
|
74
|
+
var maximumAge: Double? {
|
|
75
|
+
return self.__maximumAge.value
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@inline(__always)
|
|
79
|
+
var enableHighAccuracy: Bool? {
|
|
80
|
+
return { () -> Bool? in
|
|
81
|
+
if bridge.has_value_std__optional_bool_(self.__enableHighAccuracy) {
|
|
82
|
+
let __unwrapped = bridge.get_std__optional_bool_(self.__enableHighAccuracy)
|
|
83
|
+
return __unwrapped
|
|
84
|
+
} else {
|
|
85
|
+
return nil
|
|
86
|
+
}
|
|
87
|
+
}()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@inline(__always)
|
|
91
|
+
var interval: Double? {
|
|
92
|
+
return self.__interval.value
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@inline(__always)
|
|
96
|
+
var fastestInterval: Double? {
|
|
97
|
+
return self.__fastestInterval.value
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@inline(__always)
|
|
101
|
+
var distanceFilter: Double? {
|
|
102
|
+
return self.__distanceFilter.value
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@inline(__always)
|
|
106
|
+
var useSignificantChanges: Bool? {
|
|
107
|
+
return { () -> Bool? in
|
|
108
|
+
if bridge.has_value_std__optional_bool_(self.__useSignificantChanges) {
|
|
109
|
+
let __unwrapped = bridge.get_std__optional_bool_(self.__useSignificantChanges)
|
|
110
|
+
return __unwrapped
|
|
111
|
+
} else {
|
|
112
|
+
return nil
|
|
113
|
+
}
|
|
114
|
+
}()
|
|
115
|
+
}
|
|
116
|
+
}
|