@inoxialabs/react-native-nitro-location-geocoder 0.1.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/LICENSE +201 -0
- package/NitroLocationGeocoder.podspec +28 -0
- package/README.md +80 -0
- package/android/CMakeLists.txt +25 -0
- package/android/build.gradle +129 -0
- package/android/fix-prefab.gradle +44 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/locationgeocoder/HybridLocationGeocoder.kt +95 -0
- package/android/src/main/java/com/margelo/nitro/locationgeocoder/NitroLocationGeocoderPackage.kt +18 -0
- package/ios/Bridge.h +1 -0
- package/ios/HybridLocationGeocoder.swift +49 -0
- package/nitro.json +24 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroLocationGeocoder+autolinking.cmake +81 -0
- package/nitrogen/generated/android/NitroLocationGeocoder+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroLocationGeocoderOnLoad.cpp +54 -0
- package/nitrogen/generated/android/NitroLocationGeocoderOnLoad.hpp +34 -0
- package/nitrogen/generated/android/c++/JHybridLocationGeocoderSpec.cpp +69 -0
- package/nitrogen/generated/android/c++/JHybridLocationGeocoderSpec.hpp +63 -0
- package/nitrogen/generated/android/c++/JLocationGeocoderResult.hpp +77 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/locationgeocoder/HybridLocationGeocoderSpec.kt +55 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/locationgeocoder/LocationGeocoderResult.kt +53 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/locationgeocoder/NitroLocationGeocoderOnLoad.kt +35 -0
- package/nitrogen/generated/ios/NitroLocationGeocoder+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroLocationGeocoder-Swift-Cxx-Bridge.cpp +49 -0
- package/nitrogen/generated/ios/NitroLocationGeocoder-Swift-Cxx-Bridge.hpp +114 -0
- package/nitrogen/generated/ios/NitroLocationGeocoder-Swift-Cxx-Umbrella.hpp +48 -0
- package/nitrogen/generated/ios/NitroLocationGeocoderAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroLocationGeocoderAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridLocationGeocoderSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridLocationGeocoderSpecSwift.hpp +85 -0
- package/nitrogen/generated/ios/swift/Func_void_LocationGeocoderResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridLocationGeocoderSpec.swift +55 -0
- package/nitrogen/generated/ios/swift/HybridLocationGeocoderSpec_cxx.swift +145 -0
- package/nitrogen/generated/ios/swift/LocationGeocoderResult.swift +54 -0
- package/nitrogen/generated/shared/c++/HybridLocationGeocoderSpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridLocationGeocoderSpec.hpp +65 -0
- package/nitrogen/generated/shared/c++/LocationGeocoderResult.hpp +103 -0
- package/package.json +65 -0
- package/react-native.config.js +8 -0
- package/src/index.ts +21 -0
- package/src/specs/LocationGeocoder.nitro.ts +14 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridLocationGeocoderSpec_cxx.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A class implementation that bridges HybridLocationGeocoderSpec over to C++.
|
|
12
|
+
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
13
|
+
*
|
|
14
|
+
* Also, some Swift types need to be bridged with special handling:
|
|
15
|
+
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
16
|
+
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
17
|
+
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
18
|
+
*/
|
|
19
|
+
open class HybridLocationGeocoderSpec_cxx {
|
|
20
|
+
/**
|
|
21
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::locationgeocoder::bridge::swift`)
|
|
22
|
+
* from `NitroLocationGeocoder-Swift-Cxx-Bridge.hpp`.
|
|
23
|
+
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
24
|
+
*/
|
|
25
|
+
public typealias bridge = margelo.nitro.locationgeocoder.bridge.swift
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Holds an instance of the `HybridLocationGeocoderSpec` Swift protocol.
|
|
29
|
+
*/
|
|
30
|
+
private var __implementation: any HybridLocationGeocoderSpec
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
34
|
+
*/
|
|
35
|
+
private var __cxxPart: bridge.std__weak_ptr_HybridLocationGeocoderSpec_
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create a new `HybridLocationGeocoderSpec_cxx` that wraps the given `HybridLocationGeocoderSpec`.
|
|
39
|
+
* All properties and methods bridge to C++ types.
|
|
40
|
+
*/
|
|
41
|
+
public init(_ implementation: any HybridLocationGeocoderSpec) {
|
|
42
|
+
self.__implementation = implementation
|
|
43
|
+
self.__cxxPart = .init()
|
|
44
|
+
/* no base class */
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Get the actual `HybridLocationGeocoderSpec` instance this class wraps.
|
|
49
|
+
*/
|
|
50
|
+
@inline(__always)
|
|
51
|
+
public func getHybridLocationGeocoderSpec() -> any HybridLocationGeocoderSpec {
|
|
52
|
+
return __implementation
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
57
|
+
* This acquires one additional strong reference on the object!
|
|
58
|
+
*/
|
|
59
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
60
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Casts an unsafe pointer to a `HybridLocationGeocoderSpec_cxx`.
|
|
65
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridLocationGeocoderSpec_cxx>`.
|
|
66
|
+
* This removes one strong reference from the object!
|
|
67
|
+
*/
|
|
68
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridLocationGeocoderSpec_cxx {
|
|
69
|
+
return Unmanaged<HybridLocationGeocoderSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
74
|
+
* The C++ part is a `std::shared_ptr<HybridLocationGeocoderSpec>`.
|
|
75
|
+
*/
|
|
76
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridLocationGeocoderSpec_ {
|
|
77
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
78
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
79
|
+
return cachedCxxPart
|
|
80
|
+
} else {
|
|
81
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridLocationGeocoderSpec_(self.toUnsafe())
|
|
82
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridLocationGeocoderSpec_(newCxxPart)
|
|
83
|
+
return newCxxPart
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
91
|
+
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
92
|
+
*/
|
|
93
|
+
@inline(__always)
|
|
94
|
+
public var memorySize: Int {
|
|
95
|
+
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Compares this object with the given [other] object for reference equality.
|
|
100
|
+
*/
|
|
101
|
+
@inline(__always)
|
|
102
|
+
public func equals(other: HybridLocationGeocoderSpec_cxx) -> Bool {
|
|
103
|
+
return self.__implementation === other.__implementation
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Call dispose() on the Swift class.
|
|
108
|
+
* This _may_ be called manually from JS.
|
|
109
|
+
*/
|
|
110
|
+
@inline(__always)
|
|
111
|
+
public func dispose() {
|
|
112
|
+
self.__implementation.dispose()
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Call toString() on the Swift class.
|
|
117
|
+
*/
|
|
118
|
+
@inline(__always)
|
|
119
|
+
public func toString() -> String {
|
|
120
|
+
return self.__implementation.toString()
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Properties
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
// Methods
|
|
127
|
+
@inline(__always)
|
|
128
|
+
public final func reverseGeocode(latitude: Double, longitude: Double, locale: std.string) -> bridge.Result_std__shared_ptr_Promise_LocationGeocoderResult___ {
|
|
129
|
+
do {
|
|
130
|
+
let __result = try self.__implementation.reverseGeocode(latitude: latitude, longitude: longitude, locale: String(locale))
|
|
131
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_LocationGeocoderResult__ in
|
|
132
|
+
let __promise = bridge.create_std__shared_ptr_Promise_LocationGeocoderResult__()
|
|
133
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_LocationGeocoderResult__(__promise)
|
|
134
|
+
__result
|
|
135
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
136
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
137
|
+
return __promise
|
|
138
|
+
}()
|
|
139
|
+
return bridge.create_Result_std__shared_ptr_Promise_LocationGeocoderResult___(__resultCpp)
|
|
140
|
+
} catch (let __error) {
|
|
141
|
+
let __exceptionPtr = __error.toCpp()
|
|
142
|
+
return bridge.create_Result_std__shared_ptr_Promise_LocationGeocoderResult___(__exceptionPtr)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// LocationGeocoderResult.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `LocationGeocoderResult`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias LocationGeocoderResult = margelo.nitro.locationgeocoder.LocationGeocoderResult
|
|
14
|
+
|
|
15
|
+
public extension LocationGeocoderResult {
|
|
16
|
+
private typealias bridge = margelo.nitro.locationgeocoder.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `LocationGeocoderResult`.
|
|
20
|
+
*/
|
|
21
|
+
init(countryCode: String, country: String, locality: String, administrativeArea: String, subAdministrativeArea: String, subLocality: String) {
|
|
22
|
+
self.init(std.string(countryCode), std.string(country), std.string(locality), std.string(administrativeArea), std.string(subAdministrativeArea), std.string(subLocality))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@inline(__always)
|
|
26
|
+
var countryCode: String {
|
|
27
|
+
return String(self.__countryCode)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@inline(__always)
|
|
31
|
+
var country: String {
|
|
32
|
+
return String(self.__country)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@inline(__always)
|
|
36
|
+
var locality: String {
|
|
37
|
+
return String(self.__locality)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@inline(__always)
|
|
41
|
+
var administrativeArea: String {
|
|
42
|
+
return String(self.__administrativeArea)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@inline(__always)
|
|
46
|
+
var subAdministrativeArea: String {
|
|
47
|
+
return String(self.__subAdministrativeArea)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@inline(__always)
|
|
51
|
+
var subLocality: String {
|
|
52
|
+
return String(self.__subLocality)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridLocationGeocoderSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridLocationGeocoderSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::locationgeocoder {
|
|
11
|
+
|
|
12
|
+
void HybridLocationGeocoderSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("reverseGeocode", &HybridLocationGeocoderSpec::reverseGeocode);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
} // namespace margelo::nitro::locationgeocoder
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridLocationGeocoderSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 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 `LocationGeocoderResult` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::locationgeocoder { struct LocationGeocoderResult; }
|
|
18
|
+
|
|
19
|
+
#include "LocationGeocoderResult.hpp"
|
|
20
|
+
#include <NitroModules/Promise.hpp>
|
|
21
|
+
#include <string>
|
|
22
|
+
|
|
23
|
+
namespace margelo::nitro::locationgeocoder {
|
|
24
|
+
|
|
25
|
+
using namespace margelo::nitro;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* An abstract base class for `LocationGeocoder`
|
|
29
|
+
* Inherit this class to create instances of `HybridLocationGeocoderSpec` in C++.
|
|
30
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
31
|
+
* @example
|
|
32
|
+
* ```cpp
|
|
33
|
+
* class HybridLocationGeocoder: public HybridLocationGeocoderSpec {
|
|
34
|
+
* public:
|
|
35
|
+
* HybridLocationGeocoder(...): HybridObject(TAG) { ... }
|
|
36
|
+
* // ...
|
|
37
|
+
* };
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
class HybridLocationGeocoderSpec: public virtual HybridObject {
|
|
41
|
+
public:
|
|
42
|
+
// Constructor
|
|
43
|
+
explicit HybridLocationGeocoderSpec(): HybridObject(TAG) { }
|
|
44
|
+
|
|
45
|
+
// Destructor
|
|
46
|
+
~HybridLocationGeocoderSpec() override = default;
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
// Properties
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
// Methods
|
|
54
|
+
virtual std::shared_ptr<Promise<LocationGeocoderResult>> reverseGeocode(double latitude, double longitude, const std::string& locale) = 0;
|
|
55
|
+
|
|
56
|
+
protected:
|
|
57
|
+
// Hybrid Setup
|
|
58
|
+
void loadHybridMethods() override;
|
|
59
|
+
|
|
60
|
+
protected:
|
|
61
|
+
// Tag for logging
|
|
62
|
+
static constexpr auto TAG = "LocationGeocoder";
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
} // namespace margelo::nitro::locationgeocoder
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// LocationGeocoderResult.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 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::locationgeocoder {
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A struct which can be represented as a JavaScript object (LocationGeocoderResult).
|
|
39
|
+
*/
|
|
40
|
+
struct LocationGeocoderResult final {
|
|
41
|
+
public:
|
|
42
|
+
std::string countryCode SWIFT_PRIVATE;
|
|
43
|
+
std::string country SWIFT_PRIVATE;
|
|
44
|
+
std::string locality SWIFT_PRIVATE;
|
|
45
|
+
std::string administrativeArea SWIFT_PRIVATE;
|
|
46
|
+
std::string subAdministrativeArea SWIFT_PRIVATE;
|
|
47
|
+
std::string subLocality SWIFT_PRIVATE;
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
LocationGeocoderResult() = default;
|
|
51
|
+
explicit LocationGeocoderResult(std::string countryCode, std::string country, std::string locality, std::string administrativeArea, std::string subAdministrativeArea, std::string subLocality): countryCode(countryCode), country(country), locality(locality), administrativeArea(administrativeArea), subAdministrativeArea(subAdministrativeArea), subLocality(subLocality) {}
|
|
52
|
+
|
|
53
|
+
public:
|
|
54
|
+
friend bool operator==(const LocationGeocoderResult& lhs, const LocationGeocoderResult& rhs) = default;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
} // namespace margelo::nitro::locationgeocoder
|
|
58
|
+
|
|
59
|
+
namespace margelo::nitro {
|
|
60
|
+
|
|
61
|
+
// C++ LocationGeocoderResult <> JS LocationGeocoderResult (object)
|
|
62
|
+
template <>
|
|
63
|
+
struct JSIConverter<margelo::nitro::locationgeocoder::LocationGeocoderResult> final {
|
|
64
|
+
static inline margelo::nitro::locationgeocoder::LocationGeocoderResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
65
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
66
|
+
return margelo::nitro::locationgeocoder::LocationGeocoderResult(
|
|
67
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "countryCode"))),
|
|
68
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "country"))),
|
|
69
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "locality"))),
|
|
70
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "administrativeArea"))),
|
|
71
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subAdministrativeArea"))),
|
|
72
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subLocality")))
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::locationgeocoder::LocationGeocoderResult& arg) {
|
|
76
|
+
jsi::Object obj(runtime);
|
|
77
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "countryCode"), JSIConverter<std::string>::toJSI(runtime, arg.countryCode));
|
|
78
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "country"), JSIConverter<std::string>::toJSI(runtime, arg.country));
|
|
79
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "locality"), JSIConverter<std::string>::toJSI(runtime, arg.locality));
|
|
80
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "administrativeArea"), JSIConverter<std::string>::toJSI(runtime, arg.administrativeArea));
|
|
81
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "subAdministrativeArea"), JSIConverter<std::string>::toJSI(runtime, arg.subAdministrativeArea));
|
|
82
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "subLocality"), JSIConverter<std::string>::toJSI(runtime, arg.subLocality));
|
|
83
|
+
return obj;
|
|
84
|
+
}
|
|
85
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
86
|
+
if (!value.isObject()) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
jsi::Object obj = value.getObject(runtime);
|
|
90
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "countryCode")))) return false;
|
|
94
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "country")))) return false;
|
|
95
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "locality")))) return false;
|
|
96
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "administrativeArea")))) return false;
|
|
97
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subAdministrativeArea")))) return false;
|
|
98
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subLocality")))) return false;
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
} // namespace margelo::nitro
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@inoxialabs/react-native-nitro-location-geocoder",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React Native Nitro module for reverse geocoding coordinates into country and locality context.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Inoxia Labs",
|
|
7
|
+
"main": "src/index",
|
|
8
|
+
"source": "src/index",
|
|
9
|
+
"types": "src/index.ts",
|
|
10
|
+
"react-native": "src/index",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/inoxIALabs/react-native-nitro-location-geocoder.git"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/inoxIALabs/react-native-nitro-location-geocoder#readme",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/inoxIALabs/react-native-nitro-location-geocoder/issues"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"react-native",
|
|
24
|
+
"nitro",
|
|
25
|
+
"geocoder",
|
|
26
|
+
"location",
|
|
27
|
+
"country",
|
|
28
|
+
"locality",
|
|
29
|
+
"reverse-geocoding",
|
|
30
|
+
"ios",
|
|
31
|
+
"android"
|
|
32
|
+
],
|
|
33
|
+
"files": [
|
|
34
|
+
"src",
|
|
35
|
+
"react-native.config.js",
|
|
36
|
+
"nitro.json",
|
|
37
|
+
"nitrogen",
|
|
38
|
+
"android/build.gradle",
|
|
39
|
+
"android/fix-prefab.gradle",
|
|
40
|
+
"android/gradle.properties",
|
|
41
|
+
"android/CMakeLists.txt",
|
|
42
|
+
"android/src/**/*",
|
|
43
|
+
"ios/**/*.h",
|
|
44
|
+
"ios/**/*.m",
|
|
45
|
+
"ios/**/*.mm",
|
|
46
|
+
"ios/**/*.cpp",
|
|
47
|
+
"ios/**/*.swift",
|
|
48
|
+
"*.podspec",
|
|
49
|
+
"README.md",
|
|
50
|
+
"LICENSE"
|
|
51
|
+
],
|
|
52
|
+
"scripts": {
|
|
53
|
+
"specs": "nitrogen --logLevel=debug",
|
|
54
|
+
"test": "vitest run"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"react": "*",
|
|
58
|
+
"react-native": "*",
|
|
59
|
+
"react-native-nitro-modules": "^0.35.0"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"nitrogen": "^0.35.0",
|
|
63
|
+
"vitest": "^3.2.4"
|
|
64
|
+
}
|
|
65
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
|
+
import type { LocationGeocoder, LocationGeocoderResult } from './specs/LocationGeocoder.nitro';
|
|
3
|
+
|
|
4
|
+
const createGeocoder = (): LocationGeocoder => {
|
|
5
|
+
return NitroModules.createHybridObject<LocationGeocoder>('LocationGeocoder');
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const Geocoder = createGeocoder();
|
|
9
|
+
|
|
10
|
+
export const reverseGeocode = (
|
|
11
|
+
latitude: number,
|
|
12
|
+
longitude: number,
|
|
13
|
+
locale: string,
|
|
14
|
+
): Promise<LocationGeocoderResult> => {
|
|
15
|
+
return Geocoder.reverseGeocode(latitude, longitude, locale);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { Geocoder };
|
|
19
|
+
export type { LocationGeocoder, LocationGeocoderResult };
|
|
20
|
+
|
|
21
|
+
export default Geocoder;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
|
|
3
|
+
export interface LocationGeocoderResult {
|
|
4
|
+
countryCode: string;
|
|
5
|
+
country: string;
|
|
6
|
+
locality: string;
|
|
7
|
+
administrativeArea: string;
|
|
8
|
+
subAdministrativeArea: string;
|
|
9
|
+
subLocality: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface LocationGeocoder extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
|
|
13
|
+
reverseGeocode(latitude: number, longitude: number, locale: string): Promise<LocationGeocoderResult>;
|
|
14
|
+
}
|