react-native-nitro-geolocation 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +44 -0
- package/src/hooks/useRequestPermission.ts +38 -0
- package/src/hooks/useWatchPosition.ts +127 -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,83 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ModernGeolocationConfiguration.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 `ModernGeolocationConfiguration`, backed by a C++ struct.
|
|
13
|
+
*/
|
|
14
|
+
public typealias ModernGeolocationConfiguration = margelo.nitro.nitrogeolocation.ModernGeolocationConfiguration
|
|
15
|
+
|
|
16
|
+
public extension ModernGeolocationConfiguration {
|
|
17
|
+
private typealias bridge = margelo.nitro.nitrogeolocation.bridge.swift
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a new instance of `ModernGeolocationConfiguration`.
|
|
21
|
+
*/
|
|
22
|
+
init(autoRequestPermission: Bool?, authorizationLevel: AuthorizationLevel?, enableBackgroundLocationUpdates: Bool?, locationProvider: LocationProvider?) {
|
|
23
|
+
self.init({ () -> bridge.std__optional_bool_ in
|
|
24
|
+
if let __unwrappedValue = autoRequestPermission {
|
|
25
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
26
|
+
} else {
|
|
27
|
+
return .init()
|
|
28
|
+
}
|
|
29
|
+
}(), { () -> bridge.std__optional_AuthorizationLevel_ in
|
|
30
|
+
if let __unwrappedValue = authorizationLevel {
|
|
31
|
+
return bridge.create_std__optional_AuthorizationLevel_(__unwrappedValue)
|
|
32
|
+
} else {
|
|
33
|
+
return .init()
|
|
34
|
+
}
|
|
35
|
+
}(), { () -> bridge.std__optional_bool_ in
|
|
36
|
+
if let __unwrappedValue = enableBackgroundLocationUpdates {
|
|
37
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
38
|
+
} else {
|
|
39
|
+
return .init()
|
|
40
|
+
}
|
|
41
|
+
}(), { () -> bridge.std__optional_LocationProvider_ in
|
|
42
|
+
if let __unwrappedValue = locationProvider {
|
|
43
|
+
return bridge.create_std__optional_LocationProvider_(__unwrappedValue)
|
|
44
|
+
} else {
|
|
45
|
+
return .init()
|
|
46
|
+
}
|
|
47
|
+
}())
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@inline(__always)
|
|
51
|
+
var autoRequestPermission: Bool? {
|
|
52
|
+
return { () -> Bool? in
|
|
53
|
+
if bridge.has_value_std__optional_bool_(self.__autoRequestPermission) {
|
|
54
|
+
let __unwrapped = bridge.get_std__optional_bool_(self.__autoRequestPermission)
|
|
55
|
+
return __unwrapped
|
|
56
|
+
} else {
|
|
57
|
+
return nil
|
|
58
|
+
}
|
|
59
|
+
}()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@inline(__always)
|
|
63
|
+
var authorizationLevel: AuthorizationLevel? {
|
|
64
|
+
return self.__authorizationLevel.value
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@inline(__always)
|
|
68
|
+
var enableBackgroundLocationUpdates: Bool? {
|
|
69
|
+
return { () -> Bool? in
|
|
70
|
+
if bridge.has_value_std__optional_bool_(self.__enableBackgroundLocationUpdates) {
|
|
71
|
+
let __unwrapped = bridge.get_std__optional_bool_(self.__enableBackgroundLocationUpdates)
|
|
72
|
+
return __unwrapped
|
|
73
|
+
} else {
|
|
74
|
+
return nil
|
|
75
|
+
}
|
|
76
|
+
}()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@inline(__always)
|
|
80
|
+
var locationProvider: LocationProvider? {
|
|
81
|
+
return self.__locationProvider.value
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NullableDouble.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
|
+
* An Swift enum with associated values representing a Variant/Union type.
|
|
12
|
+
* JS type: `null | number`
|
|
13
|
+
*/
|
|
14
|
+
@frozen
|
|
15
|
+
public enum NullableDouble {
|
|
16
|
+
case first(NullType)
|
|
17
|
+
case second(Double)
|
|
18
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PermissionStatus.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Represents the JS union `PermissionStatus`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias PermissionStatus = margelo.nitro.nitrogeolocation.PermissionStatus
|
|
12
|
+
|
|
13
|
+
public extension PermissionStatus {
|
|
14
|
+
/**
|
|
15
|
+
* Get a PermissionStatus 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 "granted":
|
|
21
|
+
self = .granted
|
|
22
|
+
case "denied":
|
|
23
|
+
self = .denied
|
|
24
|
+
case "restricted":
|
|
25
|
+
self = .restricted
|
|
26
|
+
case "undetermined":
|
|
27
|
+
self = .undetermined
|
|
28
|
+
default:
|
|
29
|
+
return nil
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get the String value this PermissionStatus represents.
|
|
35
|
+
*/
|
|
36
|
+
var stringValue: String {
|
|
37
|
+
switch self {
|
|
38
|
+
case .granted:
|
|
39
|
+
return "granted"
|
|
40
|
+
case .denied:
|
|
41
|
+
return "denied"
|
|
42
|
+
case .restricted:
|
|
43
|
+
return "restricted"
|
|
44
|
+
case .undetermined:
|
|
45
|
+
return "undetermined"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
|
+
import Foundation
|
|
8
9
|
import NitroModules
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -40,65 +41,30 @@ public extension RNConfigurationInternal {
|
|
|
40
41
|
}())
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
@inline(__always)
|
|
43
45
|
var skipPermissionRequests: Bool {
|
|
44
|
-
|
|
45
|
-
get {
|
|
46
|
-
return self.__skipPermissionRequests
|
|
47
|
-
}
|
|
48
|
-
@inline(__always)
|
|
49
|
-
set {
|
|
50
|
-
self.__skipPermissionRequests = newValue
|
|
51
|
-
}
|
|
46
|
+
return self.__skipPermissionRequests
|
|
52
47
|
}
|
|
53
48
|
|
|
49
|
+
@inline(__always)
|
|
54
50
|
var authorizationLevel: AuthorizationLevelInternal? {
|
|
55
|
-
|
|
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
|
-
}
|
|
51
|
+
return self.__authorizationLevel.value
|
|
69
52
|
}
|
|
70
53
|
|
|
54
|
+
@inline(__always)
|
|
71
55
|
var enableBackgroundLocationUpdates: Bool? {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
81
|
-
} else {
|
|
82
|
-
return .init()
|
|
83
|
-
}
|
|
84
|
-
}()
|
|
85
|
-
}
|
|
56
|
+
return { () -> Bool? in
|
|
57
|
+
if bridge.has_value_std__optional_bool_(self.__enableBackgroundLocationUpdates) {
|
|
58
|
+
let __unwrapped = bridge.get_std__optional_bool_(self.__enableBackgroundLocationUpdates)
|
|
59
|
+
return __unwrapped
|
|
60
|
+
} else {
|
|
61
|
+
return nil
|
|
62
|
+
}
|
|
63
|
+
}()
|
|
86
64
|
}
|
|
87
65
|
|
|
66
|
+
@inline(__always)
|
|
88
67
|
var locationProvider: LocationProviderInternal? {
|
|
89
|
-
|
|
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
|
-
}
|
|
68
|
+
return self.__locationProvider.value
|
|
103
69
|
}
|
|
104
70
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// AuthorizationLevel.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 (AuthorizationLevel).
|
|
30
|
+
*/
|
|
31
|
+
enum class AuthorizationLevel {
|
|
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++ AuthorizationLevel <> JS AuthorizationLevel (union)
|
|
42
|
+
template <>
|
|
43
|
+
struct JSIConverter<margelo::nitro::nitrogeolocation::AuthorizationLevel> final {
|
|
44
|
+
static inline margelo::nitro::nitrogeolocation::AuthorizationLevel 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::AuthorizationLevel::ALWAYS;
|
|
48
|
+
case hashString("whenInUse"): return margelo::nitro::nitrogeolocation::AuthorizationLevel::WHENINUSE;
|
|
49
|
+
case hashString("auto"): return margelo::nitro::nitrogeolocation::AuthorizationLevel::AUTO;
|
|
50
|
+
default: [[unlikely]]
|
|
51
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum AuthorizationLevel - invalid value!");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitrogeolocation::AuthorizationLevel arg) {
|
|
55
|
+
switch (arg) {
|
|
56
|
+
case margelo::nitro::nitrogeolocation::AuthorizationLevel::ALWAYS: return JSIConverter<std::string>::toJSI(runtime, "always");
|
|
57
|
+
case margelo::nitro::nitrogeolocation::AuthorizationLevel::WHENINUSE: return JSIConverter<std::string>::toJSI(runtime, "whenInUse");
|
|
58
|
+
case margelo::nitro::nitrogeolocation::AuthorizationLevel::AUTO: return JSIConverter<std::string>::toJSI(runtime, "auto");
|
|
59
|
+
default: [[unlikely]]
|
|
60
|
+
throw std::invalid_argument("Cannot convert AuthorizationLevel 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
|
|
@@ -17,9 +17,21 @@
|
|
|
17
17
|
#else
|
|
18
18
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
19
|
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
20
30
|
|
|
21
31
|
|
|
22
32
|
|
|
33
|
+
#include <NitroModules/Null.hpp>
|
|
34
|
+
#include <variant>
|
|
23
35
|
#include <optional>
|
|
24
36
|
|
|
25
37
|
namespace margelo::nitro::nitrogeolocation {
|
|
@@ -27,19 +39,22 @@ namespace margelo::nitro::nitrogeolocation {
|
|
|
27
39
|
/**
|
|
28
40
|
* A struct which can be represented as a JavaScript object (GeolocationCoordinates).
|
|
29
41
|
*/
|
|
30
|
-
struct GeolocationCoordinates {
|
|
42
|
+
struct GeolocationCoordinates final {
|
|
31
43
|
public:
|
|
32
44
|
double latitude SWIFT_PRIVATE;
|
|
33
45
|
double longitude SWIFT_PRIVATE;
|
|
34
|
-
std::optional<double
|
|
46
|
+
std::optional<std::variant<nitro::NullType, double>> altitude SWIFT_PRIVATE;
|
|
35
47
|
double accuracy SWIFT_PRIVATE;
|
|
36
|
-
std::optional<double
|
|
37
|
-
std::optional<double
|
|
38
|
-
std::optional<double
|
|
48
|
+
std::optional<std::variant<nitro::NullType, double>> altitudeAccuracy SWIFT_PRIVATE;
|
|
49
|
+
std::optional<std::variant<nitro::NullType, double>> heading SWIFT_PRIVATE;
|
|
50
|
+
std::optional<std::variant<nitro::NullType, double>> speed SWIFT_PRIVATE;
|
|
39
51
|
|
|
40
52
|
public:
|
|
41
53
|
GeolocationCoordinates() = default;
|
|
42
|
-
explicit GeolocationCoordinates(double latitude, double longitude, std::optional<double
|
|
54
|
+
explicit GeolocationCoordinates(double latitude, double longitude, std::optional<std::variant<nitro::NullType, double>> altitude, double accuracy, std::optional<std::variant<nitro::NullType, double>> altitudeAccuracy, std::optional<std::variant<nitro::NullType, double>> heading, std::optional<std::variant<nitro::NullType, double>> speed): latitude(latitude), longitude(longitude), altitude(altitude), accuracy(accuracy), altitudeAccuracy(altitudeAccuracy), heading(heading), speed(speed) {}
|
|
55
|
+
|
|
56
|
+
public:
|
|
57
|
+
friend bool operator==(const GeolocationCoordinates& lhs, const GeolocationCoordinates& rhs) = default;
|
|
43
58
|
};
|
|
44
59
|
|
|
45
60
|
} // namespace margelo::nitro::nitrogeolocation
|
|
@@ -52,24 +67,24 @@ namespace margelo::nitro {
|
|
|
52
67
|
static inline margelo::nitro::nitrogeolocation::GeolocationCoordinates fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
53
68
|
jsi::Object obj = arg.asObject(runtime);
|
|
54
69
|
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
|
|
58
|
-
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "accuracy")),
|
|
59
|
-
JSIConverter<std::optional<double
|
|
60
|
-
JSIConverter<std::optional<double
|
|
61
|
-
JSIConverter<std::optional<double
|
|
70
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "latitude"))),
|
|
71
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "longitude"))),
|
|
72
|
+
JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "altitude"))),
|
|
73
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accuracy"))),
|
|
74
|
+
JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "altitudeAccuracy"))),
|
|
75
|
+
JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "heading"))),
|
|
76
|
+
JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speed")))
|
|
62
77
|
);
|
|
63
78
|
}
|
|
64
79
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrogeolocation::GeolocationCoordinates& arg) {
|
|
65
80
|
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
|
|
69
|
-
obj.setProperty(runtime, "accuracy", JSIConverter<double>::toJSI(runtime, arg.accuracy));
|
|
70
|
-
obj.setProperty(runtime, "altitudeAccuracy", JSIConverter<std::optional<double
|
|
71
|
-
obj.setProperty(runtime, "heading", JSIConverter<std::optional<double
|
|
72
|
-
obj.setProperty(runtime, "speed", JSIConverter<std::optional<double
|
|
81
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "latitude"), JSIConverter<double>::toJSI(runtime, arg.latitude));
|
|
82
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "longitude"), JSIConverter<double>::toJSI(runtime, arg.longitude));
|
|
83
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "altitude"), JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::toJSI(runtime, arg.altitude));
|
|
84
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "accuracy"), JSIConverter<double>::toJSI(runtime, arg.accuracy));
|
|
85
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "altitudeAccuracy"), JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::toJSI(runtime, arg.altitudeAccuracy));
|
|
86
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "heading"), JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::toJSI(runtime, arg.heading));
|
|
87
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "speed"), JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::toJSI(runtime, arg.speed));
|
|
73
88
|
return obj;
|
|
74
89
|
}
|
|
75
90
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -77,13 +92,16 @@ namespace margelo::nitro {
|
|
|
77
92
|
return false;
|
|
78
93
|
}
|
|
79
94
|
jsi::Object obj = value.getObject(runtime);
|
|
80
|
-
if (!
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "
|
|
84
|
-
if (!JSIConverter<
|
|
85
|
-
if (!JSIConverter<std::optional<double
|
|
86
|
-
if (!JSIConverter<
|
|
95
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "latitude")))) return false;
|
|
99
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "longitude")))) return false;
|
|
100
|
+
if (!JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "altitude")))) return false;
|
|
101
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accuracy")))) return false;
|
|
102
|
+
if (!JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "altitudeAccuracy")))) return false;
|
|
103
|
+
if (!JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "heading")))) return false;
|
|
104
|
+
if (!JSIConverter<std::optional<std::variant<nitro::NullType, double>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speed")))) return false;
|
|
87
105
|
return true;
|
|
88
106
|
}
|
|
89
107
|
};
|
|
@@ -17,6 +17,16 @@
|
|
|
17
17
|
#else
|
|
18
18
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
19
|
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
20
30
|
|
|
21
31
|
|
|
22
32
|
|
|
@@ -27,7 +37,7 @@ namespace margelo::nitro::nitrogeolocation {
|
|
|
27
37
|
/**
|
|
28
38
|
* A struct which can be represented as a JavaScript object (GeolocationError).
|
|
29
39
|
*/
|
|
30
|
-
struct GeolocationError {
|
|
40
|
+
struct GeolocationError final {
|
|
31
41
|
public:
|
|
32
42
|
double code SWIFT_PRIVATE;
|
|
33
43
|
std::string message SWIFT_PRIVATE;
|
|
@@ -38,6 +48,9 @@ namespace margelo::nitro::nitrogeolocation {
|
|
|
38
48
|
public:
|
|
39
49
|
GeolocationError() = default;
|
|
40
50
|
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) {}
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
friend bool operator==(const GeolocationError& lhs, const GeolocationError& rhs) = default;
|
|
41
54
|
};
|
|
42
55
|
|
|
43
56
|
} // namespace margelo::nitro::nitrogeolocation
|
|
@@ -50,20 +63,20 @@ namespace margelo::nitro {
|
|
|
50
63
|
static inline margelo::nitro::nitrogeolocation::GeolocationError fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
51
64
|
jsi::Object obj = arg.asObject(runtime);
|
|
52
65
|
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"))
|
|
66
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "code"))),
|
|
67
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "message"))),
|
|
68
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "PERMISSION_DENIED"))),
|
|
69
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "POSITION_UNAVAILABLE"))),
|
|
70
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "TIMEOUT")))
|
|
58
71
|
);
|
|
59
72
|
}
|
|
60
73
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrogeolocation::GeolocationError& arg) {
|
|
61
74
|
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));
|
|
75
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "code"), JSIConverter<double>::toJSI(runtime, arg.code));
|
|
76
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "message"), JSIConverter<std::string>::toJSI(runtime, arg.message));
|
|
77
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "PERMISSION_DENIED"), JSIConverter<double>::toJSI(runtime, arg.PERMISSION_DENIED));
|
|
78
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "POSITION_UNAVAILABLE"), JSIConverter<double>::toJSI(runtime, arg.POSITION_UNAVAILABLE));
|
|
79
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "TIMEOUT"), JSIConverter<double>::toJSI(runtime, arg.TIMEOUT));
|
|
67
80
|
return obj;
|
|
68
81
|
}
|
|
69
82
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -71,11 +84,14 @@ namespace margelo::nitro {
|
|
|
71
84
|
return false;
|
|
72
85
|
}
|
|
73
86
|
jsi::Object obj = value.getObject(runtime);
|
|
74
|
-
if (!
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "
|
|
78
|
-
if (!JSIConverter<
|
|
87
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "code")))) return false;
|
|
91
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "message")))) return false;
|
|
92
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "PERMISSION_DENIED")))) return false;
|
|
93
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "POSITION_UNAVAILABLE")))) return false;
|
|
94
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "TIMEOUT")))) return false;
|
|
79
95
|
return true;
|
|
80
96
|
}
|
|
81
97
|
};
|
|
@@ -17,6 +17,16 @@
|
|
|
17
17
|
#else
|
|
18
18
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
19
|
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
20
30
|
|
|
21
31
|
|
|
22
32
|
|
|
@@ -27,7 +37,7 @@ namespace margelo::nitro::nitrogeolocation {
|
|
|
27
37
|
/**
|
|
28
38
|
* A struct which can be represented as a JavaScript object (GeolocationOptions).
|
|
29
39
|
*/
|
|
30
|
-
struct GeolocationOptions {
|
|
40
|
+
struct GeolocationOptions final {
|
|
31
41
|
public:
|
|
32
42
|
std::optional<double> timeout SWIFT_PRIVATE;
|
|
33
43
|
std::optional<double> maximumAge SWIFT_PRIVATE;
|
|
@@ -40,6 +50,9 @@ namespace margelo::nitro::nitrogeolocation {
|
|
|
40
50
|
public:
|
|
41
51
|
GeolocationOptions() = default;
|
|
42
52
|
explicit GeolocationOptions(std::optional<double> timeout, std::optional<double> maximumAge, std::optional<bool> enableHighAccuracy, std::optional<double> interval, std::optional<double> fastestInterval, std::optional<double> distanceFilter, std::optional<bool> useSignificantChanges): timeout(timeout), maximumAge(maximumAge), enableHighAccuracy(enableHighAccuracy), interval(interval), fastestInterval(fastestInterval), distanceFilter(distanceFilter), useSignificantChanges(useSignificantChanges) {}
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
friend bool operator==(const GeolocationOptions& lhs, const GeolocationOptions& rhs) = default;
|
|
43
56
|
};
|
|
44
57
|
|
|
45
58
|
} // namespace margelo::nitro::nitrogeolocation
|
|
@@ -52,24 +65,24 @@ namespace margelo::nitro {
|
|
|
52
65
|
static inline margelo::nitro::nitrogeolocation::GeolocationOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
53
66
|
jsi::Object obj = arg.asObject(runtime);
|
|
54
67
|
return margelo::nitro::nitrogeolocation::GeolocationOptions(
|
|
55
|
-
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "timeout")),
|
|
56
|
-
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "maximumAge")),
|
|
57
|
-
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, "enableHighAccuracy")),
|
|
58
|
-
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "interval")),
|
|
59
|
-
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "fastestInterval")),
|
|
60
|
-
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "distanceFilter")),
|
|
61
|
-
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, "useSignificantChanges"))
|
|
68
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timeout"))),
|
|
69
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maximumAge"))),
|
|
70
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enableHighAccuracy"))),
|
|
71
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "interval"))),
|
|
72
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fastestInterval"))),
|
|
73
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "distanceFilter"))),
|
|
74
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "useSignificantChanges")))
|
|
62
75
|
);
|
|
63
76
|
}
|
|
64
77
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrogeolocation::GeolocationOptions& arg) {
|
|
65
78
|
jsi::Object obj(runtime);
|
|
66
|
-
obj.setProperty(runtime, "timeout", JSIConverter<std::optional<double>>::toJSI(runtime, arg.timeout));
|
|
67
|
-
obj.setProperty(runtime, "maximumAge", JSIConverter<std::optional<double>>::toJSI(runtime, arg.maximumAge));
|
|
68
|
-
obj.setProperty(runtime, "enableHighAccuracy", JSIConverter<std::optional<bool>>::toJSI(runtime, arg.enableHighAccuracy));
|
|
69
|
-
obj.setProperty(runtime, "interval", JSIConverter<std::optional<double>>::toJSI(runtime, arg.interval));
|
|
70
|
-
obj.setProperty(runtime, "fastestInterval", JSIConverter<std::optional<double>>::toJSI(runtime, arg.fastestInterval));
|
|
71
|
-
obj.setProperty(runtime, "distanceFilter", JSIConverter<std::optional<double>>::toJSI(runtime, arg.distanceFilter));
|
|
72
|
-
obj.setProperty(runtime, "useSignificantChanges", JSIConverter<std::optional<bool>>::toJSI(runtime, arg.useSignificantChanges));
|
|
79
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "timeout"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.timeout));
|
|
80
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "maximumAge"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.maximumAge));
|
|
81
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "enableHighAccuracy"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.enableHighAccuracy));
|
|
82
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "interval"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.interval));
|
|
83
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "fastestInterval"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.fastestInterval));
|
|
84
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "distanceFilter"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.distanceFilter));
|
|
85
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "useSignificantChanges"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.useSignificantChanges));
|
|
73
86
|
return obj;
|
|
74
87
|
}
|
|
75
88
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -77,13 +90,16 @@ namespace margelo::nitro {
|
|
|
77
90
|
return false;
|
|
78
91
|
}
|
|
79
92
|
jsi::Object obj = value.getObject(runtime);
|
|
80
|
-
if (!
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "
|
|
84
|
-
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "
|
|
85
|
-
if (!JSIConverter<std::optional<
|
|
86
|
-
if (!JSIConverter<std::optional<
|
|
93
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timeout")))) return false;
|
|
97
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maximumAge")))) return false;
|
|
98
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enableHighAccuracy")))) return false;
|
|
99
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "interval")))) return false;
|
|
100
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fastestInterval")))) return false;
|
|
101
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "distanceFilter")))) return false;
|
|
102
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "useSignificantChanges")))) return false;
|
|
87
103
|
return true;
|
|
88
104
|
}
|
|
89
105
|
};
|