react-native-nitro-geolocation 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +113 -128
- package/ios/NitroGeolocation.swift +546 -61
- 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/README.md +0 -318
- package/src/clearWatch.ts +0 -13
- package/src/requestAuthorization.ts +0 -9
package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationProvider.kt
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// LocationProvider.kt
|
|
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
|
+
package com.margelo.nitro.nitrogeolocation
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the JavaScript enum/union "LocationProvider".
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
@Keep
|
|
18
|
+
enum class LocationProvider(@DoNotStrip @Keep val value: Int) {
|
|
19
|
+
AUTO(0),
|
|
20
|
+
PLAYSERVICES(1),
|
|
21
|
+
ANDROID_PLATFORM(2);
|
|
22
|
+
|
|
23
|
+
companion object
|
|
24
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// LocationRequestOptions.kt
|
|
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
|
+
package com.margelo.nitro.nitrogeolocation
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents the JavaScript object/struct "LocationRequestOptions".
|
|
16
|
+
*/
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
@Keep
|
|
19
|
+
data class LocationRequestOptions(
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
val timeout: Double?,
|
|
23
|
+
@DoNotStrip
|
|
24
|
+
@Keep
|
|
25
|
+
val maximumAge: Double?,
|
|
26
|
+
@DoNotStrip
|
|
27
|
+
@Keep
|
|
28
|
+
val enableHighAccuracy: Boolean?,
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
@Keep
|
|
31
|
+
val interval: Double?,
|
|
32
|
+
@DoNotStrip
|
|
33
|
+
@Keep
|
|
34
|
+
val fastestInterval: Double?,
|
|
35
|
+
@DoNotStrip
|
|
36
|
+
@Keep
|
|
37
|
+
val distanceFilter: Double?,
|
|
38
|
+
@DoNotStrip
|
|
39
|
+
@Keep
|
|
40
|
+
val useSignificantChanges: Boolean?
|
|
41
|
+
) {
|
|
42
|
+
/* primary constructor */
|
|
43
|
+
|
|
44
|
+
companion object {
|
|
45
|
+
/**
|
|
46
|
+
* Constructor called from C++
|
|
47
|
+
*/
|
|
48
|
+
@DoNotStrip
|
|
49
|
+
@Keep
|
|
50
|
+
@Suppress("unused")
|
|
51
|
+
@JvmStatic
|
|
52
|
+
private fun fromCpp(timeout: Double?, maximumAge: Double?, enableHighAccuracy: Boolean?, interval: Double?, fastestInterval: Double?, distanceFilter: Double?, useSignificantChanges: Boolean?): LocationRequestOptions {
|
|
53
|
+
return LocationRequestOptions(timeout, maximumAge, enableHighAccuracy, interval, fastestInterval, distanceFilter, useSignificantChanges)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ModernGeolocationConfiguration.kt
|
|
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
|
+
package com.margelo.nitro.nitrogeolocation
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents the JavaScript object/struct "ModernGeolocationConfiguration".
|
|
16
|
+
*/
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
@Keep
|
|
19
|
+
data class ModernGeolocationConfiguration(
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
val autoRequestPermission: Boolean?,
|
|
23
|
+
@DoNotStrip
|
|
24
|
+
@Keep
|
|
25
|
+
val authorizationLevel: AuthorizationLevel?,
|
|
26
|
+
@DoNotStrip
|
|
27
|
+
@Keep
|
|
28
|
+
val enableBackgroundLocationUpdates: Boolean?,
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
@Keep
|
|
31
|
+
val locationProvider: LocationProvider?
|
|
32
|
+
) {
|
|
33
|
+
/* primary constructor */
|
|
34
|
+
|
|
35
|
+
companion object {
|
|
36
|
+
/**
|
|
37
|
+
* Constructor called from C++
|
|
38
|
+
*/
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
@Suppress("unused")
|
|
42
|
+
@JvmStatic
|
|
43
|
+
private fun fromCpp(autoRequestPermission: Boolean?, authorizationLevel: AuthorizationLevel?, enableBackgroundLocationUpdates: Boolean?, locationProvider: LocationProvider?): ModernGeolocationConfiguration {
|
|
44
|
+
return ModernGeolocationConfiguration(autoRequestPermission, authorizationLevel, enableBackgroundLocationUpdates, locationProvider)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/NullableDouble.kt
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NullableDouble.kt
|
|
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
|
+
package com.margelo.nitro.nitrogeolocation
|
|
9
|
+
|
|
10
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
11
|
+
import com.margelo.nitro.core.NullType
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the TypeScript variant "NullType | Double".
|
|
15
|
+
*/
|
|
16
|
+
@Suppress("ClassName")
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
sealed class NullableDouble {
|
|
19
|
+
@DoNotStrip
|
|
20
|
+
data class First(@DoNotStrip val value: NullType): NullableDouble()
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
data class Second(@DoNotStrip val value: Double): NullableDouble()
|
|
23
|
+
|
|
24
|
+
@Deprecated("getAs() is not type-safe. Use fold/asFirstOrNull/asSecondOrNull instead.", level = DeprecationLevel.ERROR)
|
|
25
|
+
inline fun <reified T> getAs(): T? = when (this) {
|
|
26
|
+
is First -> value as? T
|
|
27
|
+
is Second -> value as? T
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
val isFirst: Boolean
|
|
31
|
+
get() = this is First
|
|
32
|
+
val isSecond: Boolean
|
|
33
|
+
get() = this is Second
|
|
34
|
+
|
|
35
|
+
fun asFirstOrNull(): NullType? {
|
|
36
|
+
val value = (this as? First)?.value ?: return null
|
|
37
|
+
return value
|
|
38
|
+
}
|
|
39
|
+
fun asSecondOrNull(): Double? {
|
|
40
|
+
val value = (this as? Second)?.value ?: return null
|
|
41
|
+
return value
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
inline fun <R> match(first: (NullType) -> R, second: (Double) -> R): R {
|
|
45
|
+
return when (this) {
|
|
46
|
+
is First -> first(value)
|
|
47
|
+
is Second -> second(value)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
companion object {
|
|
52
|
+
@JvmStatic
|
|
53
|
+
@DoNotStrip
|
|
54
|
+
fun create(value: NullType): NullableDouble = First(value)
|
|
55
|
+
@JvmStatic
|
|
56
|
+
@DoNotStrip
|
|
57
|
+
fun create(value: Double): NullableDouble = Second(value)
|
|
58
|
+
}
|
|
59
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/PermissionStatus.kt
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PermissionStatus.kt
|
|
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
|
+
package com.margelo.nitro.nitrogeolocation
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the JavaScript enum/union "PermissionStatus".
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
@Keep
|
|
18
|
+
enum class PermissionStatus(@DoNotStrip @Keep val value: Int) {
|
|
19
|
+
GRANTED(0),
|
|
20
|
+
DENIED(1),
|
|
21
|
+
RESTRICTED(2),
|
|
22
|
+
UNDETERMINED(3);
|
|
23
|
+
|
|
24
|
+
companion object
|
|
25
|
+
}
|
|
@@ -9,7 +9,6 @@ package com.margelo.nitro.nitrogeolocation
|
|
|
9
9
|
|
|
10
10
|
import androidx.annotation.Keep
|
|
11
11
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
-
import com.margelo.nitro.core.*
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
/**
|
|
@@ -17,22 +16,32 @@ import com.margelo.nitro.core.*
|
|
|
17
16
|
*/
|
|
18
17
|
@DoNotStrip
|
|
19
18
|
@Keep
|
|
20
|
-
data class RNConfigurationInternal
|
|
19
|
+
data class RNConfigurationInternal(
|
|
21
20
|
@DoNotStrip
|
|
22
21
|
@Keep
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
val skipPermissionRequests: Boolean,
|
|
23
|
+
@DoNotStrip
|
|
24
|
+
@Keep
|
|
25
|
+
val authorizationLevel: AuthorizationLevelInternal?,
|
|
26
|
+
@DoNotStrip
|
|
27
|
+
@Keep
|
|
28
|
+
val enableBackgroundLocationUpdates: Boolean?,
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
@Keep
|
|
31
|
+
val locationProvider: LocationProviderInternal?
|
|
32
|
+
) {
|
|
33
|
+
/* primary constructor */
|
|
34
|
+
|
|
35
|
+
companion object {
|
|
36
|
+
/**
|
|
37
|
+
* Constructor called from C++
|
|
38
|
+
*/
|
|
33
39
|
@DoNotStrip
|
|
34
40
|
@Keep
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
@Suppress("unused")
|
|
42
|
+
@JvmStatic
|
|
43
|
+
private fun fromCpp(skipPermissionRequests: Boolean, authorizationLevel: AuthorizationLevelInternal?, enableBackgroundLocationUpdates: Boolean?, locationProvider: LocationProviderInternal?): RNConfigurationInternal {
|
|
44
|
+
return RNConfigurationInternal(skipPermissionRequests, authorizationLevel, enableBackgroundLocationUpdates, locationProvider)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
38
47
|
}
|
|
@@ -34,8 +34,11 @@ target_sources(
|
|
|
34
34
|
../nitrogen/generated/android/nitrogeolocationOnLoad.cpp
|
|
35
35
|
# Shared Nitrogen C++ sources
|
|
36
36
|
../nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.cpp
|
|
37
|
+
../nitrogen/generated/shared/c++/HybridNitroGeolocationCompatSpec.cpp
|
|
37
38
|
# Android-specific Nitrogen C++ sources
|
|
38
39
|
../nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.cpp
|
|
40
|
+
../nitrogen/generated/android/c++/JNullableDouble.cpp
|
|
41
|
+
../nitrogen/generated/android/c++/JHybridNitroGeolocationCompatSpec.cpp
|
|
39
42
|
)
|
|
40
43
|
|
|
41
44
|
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
@@ -16,9 +16,11 @@
|
|
|
16
16
|
#include <NitroModules/HybridObjectRegistry.hpp>
|
|
17
17
|
|
|
18
18
|
#include "JHybridNitroGeolocationSpec.hpp"
|
|
19
|
+
#include "JFunc_void_GeolocationResponse.hpp"
|
|
20
|
+
#include "JFunc_void_LocationError.hpp"
|
|
21
|
+
#include "JHybridNitroGeolocationCompatSpec.hpp"
|
|
19
22
|
#include "JFunc_void.hpp"
|
|
20
23
|
#include "JFunc_void_GeolocationError.hpp"
|
|
21
|
-
#include "JFunc_void_GeolocationResponse.hpp"
|
|
22
24
|
#include <NitroModules/DefaultConstructableObject.hpp>
|
|
23
25
|
|
|
24
26
|
namespace margelo::nitro::nitrogeolocation {
|
|
@@ -31,9 +33,11 @@ int initialize(JavaVM* vm) {
|
|
|
31
33
|
return facebook::jni::initialize(vm, [] {
|
|
32
34
|
// Register native JNI methods
|
|
33
35
|
margelo::nitro::nitrogeolocation::JHybridNitroGeolocationSpec::registerNatives();
|
|
36
|
+
margelo::nitro::nitrogeolocation::JFunc_void_GeolocationResponse_cxx::registerNatives();
|
|
37
|
+
margelo::nitro::nitrogeolocation::JFunc_void_LocationError_cxx::registerNatives();
|
|
38
|
+
margelo::nitro::nitrogeolocation::JHybridNitroGeolocationCompatSpec::registerNatives();
|
|
34
39
|
margelo::nitro::nitrogeolocation::JFunc_void_cxx::registerNatives();
|
|
35
40
|
margelo::nitro::nitrogeolocation::JFunc_void_GeolocationError_cxx::registerNatives();
|
|
36
|
-
margelo::nitro::nitrogeolocation::JFunc_void_GeolocationResponse_cxx::registerNatives();
|
|
37
41
|
|
|
38
42
|
// Register Nitro Hybrid Objects
|
|
39
43
|
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
@@ -44,6 +48,14 @@ int initialize(JavaVM* vm) {
|
|
|
44
48
|
return instance->cthis()->shared();
|
|
45
49
|
}
|
|
46
50
|
);
|
|
51
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
52
|
+
"NitroGeolocationCompat",
|
|
53
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
54
|
+
static DefaultConstructableObject<JHybridNitroGeolocationCompatSpec::javaobject> object("com/margelo/nitro/nitrogeolocation/NitroGeolocationCompat");
|
|
55
|
+
auto instance = object.create();
|
|
56
|
+
return instance->cthis()->shared();
|
|
57
|
+
}
|
|
58
|
+
);
|
|
47
59
|
});
|
|
48
60
|
}
|
|
49
61
|
|
|
@@ -52,7 +52,7 @@ def add_nitrogen_files(spec)
|
|
|
52
52
|
spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
|
|
53
53
|
# Use C++ 20
|
|
54
54
|
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
|
55
|
-
# Enables C++ <-> Swift interop (by default it's only
|
|
55
|
+
# Enables C++ <-> Swift interop (by default it's only ObjC)
|
|
56
56
|
"SWIFT_OBJC_INTEROP_MODE" => "objcxx",
|
|
57
57
|
# Enables stricter modular headers
|
|
58
58
|
"DEFINES_MODULE" => "YES",
|
|
@@ -8,32 +8,42 @@
|
|
|
8
8
|
#include "NitroGeolocation-Swift-Cxx-Bridge.hpp"
|
|
9
9
|
|
|
10
10
|
// Include C++ implementation defined types
|
|
11
|
+
#include "HybridNitroGeolocationCompatSpecSwift.hpp"
|
|
11
12
|
#include "HybridNitroGeolocationSpecSwift.hpp"
|
|
12
13
|
#include "NitroGeolocation-Swift-Cxx-Umbrella.hpp"
|
|
14
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
13
15
|
|
|
14
16
|
namespace margelo::nitro::nitrogeolocation::bridge::swift {
|
|
15
17
|
|
|
16
|
-
// pragma MARK: std::function<void()>
|
|
17
|
-
|
|
18
|
-
auto swiftClosure = NitroGeolocation::
|
|
19
|
-
return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
|
|
20
|
-
swiftClosure.call();
|
|
18
|
+
// pragma MARK: std::function<void(PermissionStatus /* result */)>
|
|
19
|
+
Func_void_PermissionStatus create_Func_void_PermissionStatus(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
20
|
+
auto swiftClosure = NitroGeolocation::Func_void_PermissionStatus::fromUnsafe(swiftClosureWrapper);
|
|
21
|
+
return [swiftClosure = std::move(swiftClosure)](PermissionStatus result) mutable -> void {
|
|
22
|
+
swiftClosure.call(static_cast<int>(result));
|
|
21
23
|
};
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
// pragma MARK: std::function<void(const
|
|
25
|
-
|
|
26
|
-
auto swiftClosure = NitroGeolocation::
|
|
27
|
-
return [swiftClosure = std::move(swiftClosure)](const
|
|
26
|
+
// pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
|
|
27
|
+
Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
28
|
+
auto swiftClosure = NitroGeolocation::Func_void_std__exception_ptr::fromUnsafe(swiftClosureWrapper);
|
|
29
|
+
return [swiftClosure = std::move(swiftClosure)](const std::exception_ptr& error) mutable -> void {
|
|
28
30
|
swiftClosure.call(error);
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
// pragma MARK: std::function<void(const GeolocationResponse& /*
|
|
34
|
+
// pragma MARK: std::function<void(const GeolocationResponse& /* result */)>
|
|
33
35
|
Func_void_GeolocationResponse create_Func_void_GeolocationResponse(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
34
36
|
auto swiftClosure = NitroGeolocation::Func_void_GeolocationResponse::fromUnsafe(swiftClosureWrapper);
|
|
35
|
-
return [swiftClosure = std::move(swiftClosure)](const GeolocationResponse&
|
|
36
|
-
swiftClosure.call(
|
|
37
|
+
return [swiftClosure = std::move(swiftClosure)](const GeolocationResponse& result) mutable -> void {
|
|
38
|
+
swiftClosure.call(result);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// pragma MARK: std::function<void(const LocationError& /* error */)>
|
|
43
|
+
Func_void_LocationError create_Func_void_LocationError(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
44
|
+
auto swiftClosure = NitroGeolocation::Func_void_LocationError::fromUnsafe(swiftClosureWrapper);
|
|
45
|
+
return [swiftClosure = std::move(swiftClosure)](const LocationError& error) mutable -> void {
|
|
46
|
+
swiftClosure.call(error);
|
|
37
47
|
};
|
|
38
48
|
}
|
|
39
49
|
|
|
@@ -42,7 +52,7 @@ namespace margelo::nitro::nitrogeolocation::bridge::swift {
|
|
|
42
52
|
NitroGeolocation::HybridNitroGeolocationSpec_cxx swiftPart = NitroGeolocation::HybridNitroGeolocationSpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
43
53
|
return std::make_shared<margelo::nitro::nitrogeolocation::HybridNitroGeolocationSpecSwift>(swiftPart);
|
|
44
54
|
}
|
|
45
|
-
void* NON_NULL get_std__shared_ptr_HybridNitroGeolocationSpec_(std__shared_ptr_HybridNitroGeolocationSpec_ cppType)
|
|
55
|
+
void* NON_NULL get_std__shared_ptr_HybridNitroGeolocationSpec_(std__shared_ptr_HybridNitroGeolocationSpec_ cppType) {
|
|
46
56
|
std::shared_ptr<margelo::nitro::nitrogeolocation::HybridNitroGeolocationSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::nitrogeolocation::HybridNitroGeolocationSpecSwift>(cppType);
|
|
47
57
|
#ifdef NITRO_DEBUG
|
|
48
58
|
if (swiftWrapper == nullptr) [[unlikely]] {
|
|
@@ -52,5 +62,37 @@ namespace margelo::nitro::nitrogeolocation::bridge::swift {
|
|
|
52
62
|
NitroGeolocation::HybridNitroGeolocationSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
|
|
53
63
|
return swiftPart.toUnsafe();
|
|
54
64
|
}
|
|
65
|
+
|
|
66
|
+
// pragma MARK: std::function<void()>
|
|
67
|
+
Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
68
|
+
auto swiftClosure = NitroGeolocation::Func_void::fromUnsafe(swiftClosureWrapper);
|
|
69
|
+
return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
|
|
70
|
+
swiftClosure.call();
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// pragma MARK: std::function<void(const GeolocationError& /* error */)>
|
|
75
|
+
Func_void_GeolocationError create_Func_void_GeolocationError(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
76
|
+
auto swiftClosure = NitroGeolocation::Func_void_GeolocationError::fromUnsafe(swiftClosureWrapper);
|
|
77
|
+
return [swiftClosure = std::move(swiftClosure)](const GeolocationError& error) mutable -> void {
|
|
78
|
+
swiftClosure.call(error);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// pragma MARK: std::shared_ptr<HybridNitroGeolocationCompatSpec>
|
|
83
|
+
std::shared_ptr<HybridNitroGeolocationCompatSpec> create_std__shared_ptr_HybridNitroGeolocationCompatSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
84
|
+
NitroGeolocation::HybridNitroGeolocationCompatSpec_cxx swiftPart = NitroGeolocation::HybridNitroGeolocationCompatSpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
85
|
+
return std::make_shared<margelo::nitro::nitrogeolocation::HybridNitroGeolocationCompatSpecSwift>(swiftPart);
|
|
86
|
+
}
|
|
87
|
+
void* NON_NULL get_std__shared_ptr_HybridNitroGeolocationCompatSpec_(std__shared_ptr_HybridNitroGeolocationCompatSpec_ cppType) {
|
|
88
|
+
std::shared_ptr<margelo::nitro::nitrogeolocation::HybridNitroGeolocationCompatSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::nitrogeolocation::HybridNitroGeolocationCompatSpecSwift>(cppType);
|
|
89
|
+
#ifdef NITRO_DEBUG
|
|
90
|
+
if (swiftWrapper == nullptr) [[unlikely]] {
|
|
91
|
+
throw std::runtime_error("Class \"HybridNitroGeolocationCompatSpec\" is not implemented in Swift!");
|
|
92
|
+
}
|
|
93
|
+
#endif
|
|
94
|
+
NitroGeolocation::HybridNitroGeolocationCompatSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
|
|
95
|
+
return swiftPart.toUnsafe();
|
|
96
|
+
}
|
|
55
97
|
|
|
56
98
|
} // namespace margelo::nitro::nitrogeolocation::bridge::swift
|