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
|
@@ -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
|
// Forward declaration of `GeolocationCoordinates` to properly resolve imports.
|
|
22
32
|
namespace margelo::nitro::nitrogeolocation { struct GeolocationCoordinates; }
|
|
@@ -28,7 +38,7 @@ namespace margelo::nitro::nitrogeolocation {
|
|
|
28
38
|
/**
|
|
29
39
|
* A struct which can be represented as a JavaScript object (GeolocationResponse).
|
|
30
40
|
*/
|
|
31
|
-
struct GeolocationResponse {
|
|
41
|
+
struct GeolocationResponse final {
|
|
32
42
|
public:
|
|
33
43
|
GeolocationCoordinates coords SWIFT_PRIVATE;
|
|
34
44
|
double timestamp SWIFT_PRIVATE;
|
|
@@ -36,6 +46,9 @@ namespace margelo::nitro::nitrogeolocation {
|
|
|
36
46
|
public:
|
|
37
47
|
GeolocationResponse() = default;
|
|
38
48
|
explicit GeolocationResponse(GeolocationCoordinates coords, double timestamp): coords(coords), timestamp(timestamp) {}
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
friend bool operator==(const GeolocationResponse& lhs, const GeolocationResponse& rhs) = default;
|
|
39
52
|
};
|
|
40
53
|
|
|
41
54
|
} // namespace margelo::nitro::nitrogeolocation
|
|
@@ -48,14 +61,14 @@ namespace margelo::nitro {
|
|
|
48
61
|
static inline margelo::nitro::nitrogeolocation::GeolocationResponse fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
49
62
|
jsi::Object obj = arg.asObject(runtime);
|
|
50
63
|
return margelo::nitro::nitrogeolocation::GeolocationResponse(
|
|
51
|
-
JSIConverter<margelo::nitro::nitrogeolocation::GeolocationCoordinates>::fromJSI(runtime, obj.getProperty(runtime, "coords")),
|
|
52
|
-
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "timestamp"))
|
|
64
|
+
JSIConverter<margelo::nitro::nitrogeolocation::GeolocationCoordinates>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "coords"))),
|
|
65
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timestamp")))
|
|
53
66
|
);
|
|
54
67
|
}
|
|
55
68
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrogeolocation::GeolocationResponse& arg) {
|
|
56
69
|
jsi::Object obj(runtime);
|
|
57
|
-
obj.setProperty(runtime, "coords", JSIConverter<margelo::nitro::nitrogeolocation::GeolocationCoordinates>::toJSI(runtime, arg.coords));
|
|
58
|
-
obj.setProperty(runtime, "timestamp", JSIConverter<double>::toJSI(runtime, arg.timestamp));
|
|
70
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "coords"), JSIConverter<margelo::nitro::nitrogeolocation::GeolocationCoordinates>::toJSI(runtime, arg.coords));
|
|
71
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "timestamp"), JSIConverter<double>::toJSI(runtime, arg.timestamp));
|
|
59
72
|
return obj;
|
|
60
73
|
}
|
|
61
74
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -63,8 +76,11 @@ namespace margelo::nitro {
|
|
|
63
76
|
return false;
|
|
64
77
|
}
|
|
65
78
|
jsi::Object obj = value.getObject(runtime);
|
|
66
|
-
if (!
|
|
67
|
-
|
|
79
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
if (!JSIConverter<margelo::nitro::nitrogeolocation::GeolocationCoordinates>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "coords")))) return false;
|
|
83
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timestamp")))) return false;
|
|
68
84
|
return true;
|
|
69
85
|
}
|
|
70
86
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroGeolocationCompatSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridNitroGeolocationCompatSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::nitrogeolocation {
|
|
11
|
+
|
|
12
|
+
void HybridNitroGeolocationCompatSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("setRNConfiguration", &HybridNitroGeolocationCompatSpec::setRNConfiguration);
|
|
18
|
+
prototype.registerHybridMethod("requestAuthorization", &HybridNitroGeolocationCompatSpec::requestAuthorization);
|
|
19
|
+
prototype.registerHybridMethod("getCurrentPosition", &HybridNitroGeolocationCompatSpec::getCurrentPosition);
|
|
20
|
+
prototype.registerHybridMethod("watchPosition", &HybridNitroGeolocationCompatSpec::watchPosition);
|
|
21
|
+
prototype.registerHybridMethod("clearWatch", &HybridNitroGeolocationCompatSpec::clearWatch);
|
|
22
|
+
prototype.registerHybridMethod("stopObserving", &HybridNitroGeolocationCompatSpec::stopObserving);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
} // namespace margelo::nitro::nitrogeolocation
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroGeolocationCompatSpec.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/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
// Forward declaration of `RNConfigurationInternal` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::nitrogeolocation { struct RNConfigurationInternal; }
|
|
18
|
+
// Forward declaration of `GeolocationError` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::nitrogeolocation { struct GeolocationError; }
|
|
20
|
+
// Forward declaration of `GeolocationResponse` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::nitrogeolocation { struct GeolocationResponse; }
|
|
22
|
+
// Forward declaration of `GeolocationOptions` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::nitrogeolocation { struct GeolocationOptions; }
|
|
24
|
+
|
|
25
|
+
#include "RNConfigurationInternal.hpp"
|
|
26
|
+
#include <functional>
|
|
27
|
+
#include <optional>
|
|
28
|
+
#include "GeolocationError.hpp"
|
|
29
|
+
#include "GeolocationResponse.hpp"
|
|
30
|
+
#include "GeolocationOptions.hpp"
|
|
31
|
+
|
|
32
|
+
namespace margelo::nitro::nitrogeolocation {
|
|
33
|
+
|
|
34
|
+
using namespace margelo::nitro;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* An abstract base class for `NitroGeolocationCompat`
|
|
38
|
+
* Inherit this class to create instances of `HybridNitroGeolocationCompatSpec` in C++.
|
|
39
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
40
|
+
* @example
|
|
41
|
+
* ```cpp
|
|
42
|
+
* class HybridNitroGeolocationCompat: public HybridNitroGeolocationCompatSpec {
|
|
43
|
+
* public:
|
|
44
|
+
* HybridNitroGeolocationCompat(...): HybridObject(TAG) { ... }
|
|
45
|
+
* // ...
|
|
46
|
+
* };
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
class HybridNitroGeolocationCompatSpec: public virtual HybridObject {
|
|
50
|
+
public:
|
|
51
|
+
// Constructor
|
|
52
|
+
explicit HybridNitroGeolocationCompatSpec(): HybridObject(TAG) { }
|
|
53
|
+
|
|
54
|
+
// Destructor
|
|
55
|
+
~HybridNitroGeolocationCompatSpec() override = default;
|
|
56
|
+
|
|
57
|
+
public:
|
|
58
|
+
// Properties
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
public:
|
|
62
|
+
// Methods
|
|
63
|
+
virtual void setRNConfiguration(const RNConfigurationInternal& config) = 0;
|
|
64
|
+
virtual void requestAuthorization(const std::optional<std::function<void()>>& success, const std::optional<std::function<void(const GeolocationError& /* error */)>>& error) = 0;
|
|
65
|
+
virtual void getCurrentPosition(const std::function<void(const GeolocationResponse& /* position */)>& success, const std::optional<std::function<void(const GeolocationError& /* error */)>>& error, const std::optional<GeolocationOptions>& options) = 0;
|
|
66
|
+
virtual double watchPosition(const std::function<void(const GeolocationResponse& /* position */)>& success, const std::optional<std::function<void(const GeolocationError& /* error */)>>& error, const std::optional<GeolocationOptions>& options) = 0;
|
|
67
|
+
virtual void clearWatch(double watchId) = 0;
|
|
68
|
+
virtual void stopObserving() = 0;
|
|
69
|
+
|
|
70
|
+
protected:
|
|
71
|
+
// Hybrid Setup
|
|
72
|
+
void loadHybridMethods() override;
|
|
73
|
+
|
|
74
|
+
protected:
|
|
75
|
+
// Tag for logging
|
|
76
|
+
static constexpr auto TAG = "NitroGeolocationCompat";
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
} // namespace margelo::nitro::nitrogeolocation
|
|
@@ -14,11 +14,12 @@ namespace margelo::nitro::nitrogeolocation {
|
|
|
14
14
|
HybridObject::loadHybridMethods();
|
|
15
15
|
// load custom methods/properties
|
|
16
16
|
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
-
prototype.registerHybridMethod("
|
|
18
|
-
prototype.registerHybridMethod("
|
|
17
|
+
prototype.registerHybridMethod("setConfiguration", &HybridNitroGeolocationSpec::setConfiguration);
|
|
18
|
+
prototype.registerHybridMethod("checkPermission", &HybridNitroGeolocationSpec::checkPermission);
|
|
19
|
+
prototype.registerHybridMethod("requestPermission", &HybridNitroGeolocationSpec::requestPermission);
|
|
19
20
|
prototype.registerHybridMethod("getCurrentPosition", &HybridNitroGeolocationSpec::getCurrentPosition);
|
|
20
21
|
prototype.registerHybridMethod("watchPosition", &HybridNitroGeolocationSpec::watchPosition);
|
|
21
|
-
prototype.registerHybridMethod("
|
|
22
|
+
prototype.registerHybridMethod("unwatch", &HybridNitroGeolocationSpec::unwatch);
|
|
22
23
|
prototype.registerHybridMethod("stopObserving", &HybridNitroGeolocationSpec::stopObserving);
|
|
23
24
|
});
|
|
24
25
|
}
|
|
@@ -13,21 +13,26 @@
|
|
|
13
13
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
14
|
#endif
|
|
15
15
|
|
|
16
|
-
// Forward declaration of `
|
|
17
|
-
namespace margelo::nitro::nitrogeolocation { struct
|
|
18
|
-
// Forward declaration of `
|
|
19
|
-
namespace margelo::nitro::nitrogeolocation {
|
|
16
|
+
// Forward declaration of `ModernGeolocationConfiguration` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::nitrogeolocation { struct ModernGeolocationConfiguration; }
|
|
18
|
+
// Forward declaration of `PermissionStatus` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::nitrogeolocation { enum class PermissionStatus; }
|
|
20
20
|
// Forward declaration of `GeolocationResponse` to properly resolve imports.
|
|
21
21
|
namespace margelo::nitro::nitrogeolocation { struct GeolocationResponse; }
|
|
22
|
-
// Forward declaration of `
|
|
23
|
-
namespace margelo::nitro::nitrogeolocation { struct
|
|
22
|
+
// Forward declaration of `LocationRequestOptions` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::nitrogeolocation { struct LocationRequestOptions; }
|
|
24
|
+
// Forward declaration of `LocationError` to properly resolve imports.
|
|
25
|
+
namespace margelo::nitro::nitrogeolocation { struct LocationError; }
|
|
24
26
|
|
|
25
|
-
#include "
|
|
26
|
-
#include
|
|
27
|
-
#include <
|
|
28
|
-
#include "GeolocationError.hpp"
|
|
27
|
+
#include "ModernGeolocationConfiguration.hpp"
|
|
28
|
+
#include "PermissionStatus.hpp"
|
|
29
|
+
#include <NitroModules/Promise.hpp>
|
|
29
30
|
#include "GeolocationResponse.hpp"
|
|
30
|
-
#include "
|
|
31
|
+
#include "LocationRequestOptions.hpp"
|
|
32
|
+
#include <optional>
|
|
33
|
+
#include <string>
|
|
34
|
+
#include <functional>
|
|
35
|
+
#include "LocationError.hpp"
|
|
31
36
|
|
|
32
37
|
namespace margelo::nitro::nitrogeolocation {
|
|
33
38
|
|
|
@@ -60,11 +65,12 @@ namespace margelo::nitro::nitrogeolocation {
|
|
|
60
65
|
|
|
61
66
|
public:
|
|
62
67
|
// Methods
|
|
63
|
-
virtual void
|
|
64
|
-
virtual
|
|
65
|
-
virtual
|
|
66
|
-
virtual
|
|
67
|
-
virtual void
|
|
68
|
+
virtual void setConfiguration(const ModernGeolocationConfiguration& config) = 0;
|
|
69
|
+
virtual std::shared_ptr<Promise<PermissionStatus>> checkPermission() = 0;
|
|
70
|
+
virtual std::shared_ptr<Promise<PermissionStatus>> requestPermission() = 0;
|
|
71
|
+
virtual std::shared_ptr<Promise<GeolocationResponse>> getCurrentPosition(const std::optional<LocationRequestOptions>& options) = 0;
|
|
72
|
+
virtual std::string watchPosition(const std::function<void(const GeolocationResponse& /* position */)>& success, const std::optional<std::function<void(const LocationError& /* error */)>>& error, const std::optional<LocationRequestOptions>& options) = 0;
|
|
73
|
+
virtual void unwatch(const std::string& token) = 0;
|
|
68
74
|
virtual void stopObserving() = 0;
|
|
69
75
|
|
|
70
76
|
protected:
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// LocationError.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#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
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
#include <string>
|
|
34
|
+
|
|
35
|
+
namespace margelo::nitro::nitrogeolocation {
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A struct which can be represented as a JavaScript object (LocationError).
|
|
39
|
+
*/
|
|
40
|
+
struct LocationError final {
|
|
41
|
+
public:
|
|
42
|
+
double code SWIFT_PRIVATE;
|
|
43
|
+
std::string message SWIFT_PRIVATE;
|
|
44
|
+
|
|
45
|
+
public:
|
|
46
|
+
LocationError() = default;
|
|
47
|
+
explicit LocationError(double code, std::string message): code(code), message(message) {}
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
friend bool operator==(const LocationError& lhs, const LocationError& rhs) = default;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
} // namespace margelo::nitro::nitrogeolocation
|
|
54
|
+
|
|
55
|
+
namespace margelo::nitro {
|
|
56
|
+
|
|
57
|
+
// C++ LocationError <> JS LocationError (object)
|
|
58
|
+
template <>
|
|
59
|
+
struct JSIConverter<margelo::nitro::nitrogeolocation::LocationError> final {
|
|
60
|
+
static inline margelo::nitro::nitrogeolocation::LocationError fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
61
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
62
|
+
return margelo::nitro::nitrogeolocation::LocationError(
|
|
63
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "code"))),
|
|
64
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "message")))
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrogeolocation::LocationError& arg) {
|
|
68
|
+
jsi::Object obj(runtime);
|
|
69
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "code"), JSIConverter<double>::toJSI(runtime, arg.code));
|
|
70
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "message"), JSIConverter<std::string>::toJSI(runtime, arg.message));
|
|
71
|
+
return obj;
|
|
72
|
+
}
|
|
73
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
74
|
+
if (!value.isObject()) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
jsi::Object obj = value.getObject(runtime);
|
|
78
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "code")))) return false;
|
|
82
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "message")))) return false;
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// LocationProvider.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 (LocationProvider).
|
|
30
|
+
*/
|
|
31
|
+
enum class LocationProvider {
|
|
32
|
+
AUTO SWIFT_NAME(auto) = 0,
|
|
33
|
+
PLAYSERVICES SWIFT_NAME(playservices) = 1,
|
|
34
|
+
ANDROID_PLATFORM SWIFT_NAME(androidPlatform) = 2,
|
|
35
|
+
} CLOSED_ENUM;
|
|
36
|
+
|
|
37
|
+
} // namespace margelo::nitro::nitrogeolocation
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro {
|
|
40
|
+
|
|
41
|
+
// C++ LocationProvider <> JS LocationProvider (union)
|
|
42
|
+
template <>
|
|
43
|
+
struct JSIConverter<margelo::nitro::nitrogeolocation::LocationProvider> final {
|
|
44
|
+
static inline margelo::nitro::nitrogeolocation::LocationProvider 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("auto"): return margelo::nitro::nitrogeolocation::LocationProvider::AUTO;
|
|
48
|
+
case hashString("playServices"): return margelo::nitro::nitrogeolocation::LocationProvider::PLAYSERVICES;
|
|
49
|
+
case hashString("android_platform"): return margelo::nitro::nitrogeolocation::LocationProvider::ANDROID_PLATFORM;
|
|
50
|
+
default: [[unlikely]]
|
|
51
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum LocationProvider - invalid value!");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitrogeolocation::LocationProvider arg) {
|
|
55
|
+
switch (arg) {
|
|
56
|
+
case margelo::nitro::nitrogeolocation::LocationProvider::AUTO: return JSIConverter<std::string>::toJSI(runtime, "auto");
|
|
57
|
+
case margelo::nitro::nitrogeolocation::LocationProvider::PLAYSERVICES: return JSIConverter<std::string>::toJSI(runtime, "playServices");
|
|
58
|
+
case margelo::nitro::nitrogeolocation::LocationProvider::ANDROID_PLATFORM: return JSIConverter<std::string>::toJSI(runtime, "android_platform");
|
|
59
|
+
default: [[unlikely]]
|
|
60
|
+
throw std::invalid_argument("Cannot convert LocationProvider 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("auto"):
|
|
71
|
+
case hashString("playServices"):
|
|
72
|
+
case hashString("android_platform"):
|
|
73
|
+
return true;
|
|
74
|
+
default:
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// LocationRequestOptions.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#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
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
#include <optional>
|
|
34
|
+
|
|
35
|
+
namespace margelo::nitro::nitrogeolocation {
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A struct which can be represented as a JavaScript object (LocationRequestOptions).
|
|
39
|
+
*/
|
|
40
|
+
struct LocationRequestOptions final {
|
|
41
|
+
public:
|
|
42
|
+
std::optional<double> timeout SWIFT_PRIVATE;
|
|
43
|
+
std::optional<double> maximumAge SWIFT_PRIVATE;
|
|
44
|
+
std::optional<bool> enableHighAccuracy SWIFT_PRIVATE;
|
|
45
|
+
std::optional<double> interval SWIFT_PRIVATE;
|
|
46
|
+
std::optional<double> fastestInterval SWIFT_PRIVATE;
|
|
47
|
+
std::optional<double> distanceFilter SWIFT_PRIVATE;
|
|
48
|
+
std::optional<bool> useSignificantChanges SWIFT_PRIVATE;
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
LocationRequestOptions() = default;
|
|
52
|
+
explicit LocationRequestOptions(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 LocationRequestOptions& lhs, const LocationRequestOptions& rhs) = default;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace margelo::nitro::nitrogeolocation
|
|
59
|
+
|
|
60
|
+
namespace margelo::nitro {
|
|
61
|
+
|
|
62
|
+
// C++ LocationRequestOptions <> JS LocationRequestOptions (object)
|
|
63
|
+
template <>
|
|
64
|
+
struct JSIConverter<margelo::nitro::nitrogeolocation::LocationRequestOptions> final {
|
|
65
|
+
static inline margelo::nitro::nitrogeolocation::LocationRequestOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
66
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
67
|
+
return margelo::nitro::nitrogeolocation::LocationRequestOptions(
|
|
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")))
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrogeolocation::LocationRequestOptions& arg) {
|
|
78
|
+
jsi::Object obj(runtime);
|
|
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));
|
|
86
|
+
return obj;
|
|
87
|
+
}
|
|
88
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
89
|
+
if (!value.isObject()) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
jsi::Object obj = value.getObject(runtime);
|
|
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;
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ModernGeolocationConfiguration.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#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
|
|
30
|
+
|
|
31
|
+
// Forward declaration of `AuthorizationLevel` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::nitrogeolocation { enum class AuthorizationLevel; }
|
|
33
|
+
// Forward declaration of `LocationProvider` to properly resolve imports.
|
|
34
|
+
namespace margelo::nitro::nitrogeolocation { enum class LocationProvider; }
|
|
35
|
+
|
|
36
|
+
#include <optional>
|
|
37
|
+
#include "AuthorizationLevel.hpp"
|
|
38
|
+
#include "LocationProvider.hpp"
|
|
39
|
+
|
|
40
|
+
namespace margelo::nitro::nitrogeolocation {
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A struct which can be represented as a JavaScript object (ModernGeolocationConfiguration).
|
|
44
|
+
*/
|
|
45
|
+
struct ModernGeolocationConfiguration final {
|
|
46
|
+
public:
|
|
47
|
+
std::optional<bool> autoRequestPermission SWIFT_PRIVATE;
|
|
48
|
+
std::optional<AuthorizationLevel> authorizationLevel SWIFT_PRIVATE;
|
|
49
|
+
std::optional<bool> enableBackgroundLocationUpdates SWIFT_PRIVATE;
|
|
50
|
+
std::optional<LocationProvider> locationProvider SWIFT_PRIVATE;
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
ModernGeolocationConfiguration() = default;
|
|
54
|
+
explicit ModernGeolocationConfiguration(std::optional<bool> autoRequestPermission, std::optional<AuthorizationLevel> authorizationLevel, std::optional<bool> enableBackgroundLocationUpdates, std::optional<LocationProvider> locationProvider): autoRequestPermission(autoRequestPermission), authorizationLevel(authorizationLevel), enableBackgroundLocationUpdates(enableBackgroundLocationUpdates), locationProvider(locationProvider) {}
|
|
55
|
+
|
|
56
|
+
public:
|
|
57
|
+
friend bool operator==(const ModernGeolocationConfiguration& lhs, const ModernGeolocationConfiguration& rhs) = default;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
} // namespace margelo::nitro::nitrogeolocation
|
|
61
|
+
|
|
62
|
+
namespace margelo::nitro {
|
|
63
|
+
|
|
64
|
+
// C++ ModernGeolocationConfiguration <> JS ModernGeolocationConfiguration (object)
|
|
65
|
+
template <>
|
|
66
|
+
struct JSIConverter<margelo::nitro::nitrogeolocation::ModernGeolocationConfiguration> final {
|
|
67
|
+
static inline margelo::nitro::nitrogeolocation::ModernGeolocationConfiguration fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
68
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
69
|
+
return margelo::nitro::nitrogeolocation::ModernGeolocationConfiguration(
|
|
70
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "autoRequestPermission"))),
|
|
71
|
+
JSIConverter<std::optional<margelo::nitro::nitrogeolocation::AuthorizationLevel>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "authorizationLevel"))),
|
|
72
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enableBackgroundLocationUpdates"))),
|
|
73
|
+
JSIConverter<std::optional<margelo::nitro::nitrogeolocation::LocationProvider>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "locationProvider")))
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrogeolocation::ModernGeolocationConfiguration& arg) {
|
|
77
|
+
jsi::Object obj(runtime);
|
|
78
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "autoRequestPermission"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.autoRequestPermission));
|
|
79
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "authorizationLevel"), JSIConverter<std::optional<margelo::nitro::nitrogeolocation::AuthorizationLevel>>::toJSI(runtime, arg.authorizationLevel));
|
|
80
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "enableBackgroundLocationUpdates"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.enableBackgroundLocationUpdates));
|
|
81
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "locationProvider"), JSIConverter<std::optional<margelo::nitro::nitrogeolocation::LocationProvider>>::toJSI(runtime, arg.locationProvider));
|
|
82
|
+
return obj;
|
|
83
|
+
}
|
|
84
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
85
|
+
if (!value.isObject()) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
jsi::Object obj = value.getObject(runtime);
|
|
89
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "autoRequestPermission")))) return false;
|
|
93
|
+
if (!JSIConverter<std::optional<margelo::nitro::nitrogeolocation::AuthorizationLevel>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "authorizationLevel")))) return false;
|
|
94
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enableBackgroundLocationUpdates")))) return false;
|
|
95
|
+
if (!JSIConverter<std::optional<margelo::nitro::nitrogeolocation::LocationProvider>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "locationProvider")))) return false;
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
} // namespace margelo::nitro
|