expo-location 58.0.21 → 58.0.23

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.
Files changed (88) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/expo/modules/location/LocationModule.kt +2 -5
  4. package/android/src/main/java/expo/modules/location/next/LocationModuleNext.kt +29 -0
  5. package/android/src/main/java/expo/modules/location/next/LocationRecords.kt +6 -2
  6. package/android/src/main/java/expo/modules/location/next/geocoding/Geocoding.kt +117 -0
  7. package/android/src/main/java/expo/modules/location/next/geocoding/GeocodingExceptions.kt +27 -0
  8. package/android/src/main/java/expo/modules/location/next/geocoding/GeocodingRecords.kt +24 -0
  9. package/build/Location.d.ts +5 -4
  10. package/build/Location.js +35 -17
  11. package/build/Location.js.map +1 -1
  12. package/build/Location.types.d.ts +12 -0
  13. package/build/next/Location.d.ts +1 -1
  14. package/build/next/Location.js +1 -1
  15. package/build/next/Location.js.map +1 -1
  16. package/build/next/index.d.ts +1 -1
  17. package/build/next/index.js.map +1 -1
  18. package/build/next/js/geocoding.d.ts +38 -0
  19. package/build/next/js/geocoding.js +49 -0
  20. package/build/next/js/geocoding.js.map +1 -0
  21. package/build/next/js/index.d.ts +1 -0
  22. package/build/next/js/index.js +1 -0
  23. package/build/next/js/index.js.map +1 -1
  24. package/build/next/native/types/NativeLocationModuleNextClass.types.d.ts +3 -1
  25. package/build/next/types/Geocoding.types.d.ts +74 -0
  26. package/build/next/types/Geocoding.types.js +7 -0
  27. package/build/next/types/Geocoding.types.js.map +1 -0
  28. package/build/next/types/index.d.ts +1 -0
  29. package/build/next/types/index.js +1 -0
  30. package/build/next/types/index.js.map +1 -1
  31. package/ios/next/Geocoding/Address.swift +11 -0
  32. package/ios/next/Geocoding/AddressNormalization.swift +8 -0
  33. package/ios/next/Geocoding/CompatibilityGeocoder.swift +73 -0
  34. package/ios/next/Geocoding/GeocodeOptions.swift +6 -0
  35. package/ios/next/Geocoding/GeocoderNext.swift +4 -0
  36. package/ios/next/Geocoding/MapKitGeocoder.swift +70 -0
  37. package/ios/next/Geocoding/ReverseGeocodeOptions.swift +6 -0
  38. package/ios/next/Geocoding/String+toLocale.swift +12 -0
  39. package/ios/next/LocationModuleNext.swift +15 -0
  40. package/ios/next/LocationNextExceptions.swift +19 -0
  41. package/ios/next/Position/Position.swift +13 -3
  42. package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.21/expo.modules.location-58.0.21-sources.jar → 58.0.23/expo.modules.location-58.0.23-sources.jar} +0 -0
  43. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23-sources.jar.md5 +1 -0
  44. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23-sources.jar.sha1 +1 -0
  45. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23-sources.jar.sha256 +1 -0
  46. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23-sources.jar.sha512 +1 -0
  47. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.aar +0 -0
  48. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.aar.md5 +1 -0
  49. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.aar.sha1 +1 -0
  50. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.aar.sha256 +1 -0
  51. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.aar.sha512 +1 -0
  52. package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.21/expo.modules.location-58.0.21.module → 58.0.23/expo.modules.location-58.0.23.module} +22 -22
  53. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.module.md5 +1 -0
  54. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.module.sha1 +1 -0
  55. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.module.sha256 +1 -0
  56. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.module.sha512 +1 -0
  57. package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.21/expo.modules.location-58.0.21.pom → 58.0.23/expo.modules.location-58.0.23.pom} +1 -1
  58. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.pom.md5 +1 -0
  59. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.pom.sha1 +1 -0
  60. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.pom.sha256 +1 -0
  61. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.23/expo.modules.location-58.0.23.pom.sha512 +1 -0
  62. package/package.json +2 -2
  63. package/src/Location.ts +50 -19
  64. package/src/Location.types.ts +13 -0
  65. package/src/next/Location.ts +2 -0
  66. package/src/next/index.ts +3 -0
  67. package/src/next/js/geocoding.ts +56 -0
  68. package/src/next/js/index.ts +1 -0
  69. package/src/next/native/types/NativeLocationModuleNextClass.types.ts +6 -0
  70. package/src/next/types/Geocoding.types.ts +77 -0
  71. package/src/next/types/index.ts +1 -0
  72. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21-sources.jar.md5 +0 -1
  73. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21-sources.jar.sha1 +0 -1
  74. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21-sources.jar.sha256 +0 -1
  75. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21-sources.jar.sha512 +0 -1
  76. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.aar +0 -0
  77. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.aar.md5 +0 -1
  78. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.aar.sha1 +0 -1
  79. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.aar.sha256 +0 -1
  80. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.aar.sha512 +0 -1
  81. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.module.md5 +0 -1
  82. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.module.sha1 +0 -1
  83. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.module.sha256 +0 -1
  84. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.module.sha512 +0 -1
  85. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.pom.md5 +0 -1
  86. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.pom.sha1 +0 -1
  87. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.pom.sha256 +0 -1
  88. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.21/expo.modules.location-58.0.21.pom.sha512 +0 -1
@@ -0,0 +1,74 @@
1
+ import type { Coordinates } from './Position.types';
2
+ /**
3
+ * An address paired with the coordinates it stands for. Fields the platform does not know for a
4
+ * given place are `null`.
5
+ * @example
6
+ * ```ts
7
+ * {
8
+ * coordinates: { latitude: 37.3317, longitude: -122.0301 },
9
+ * name: '1 Infinite Loop',
10
+ * formattedAddress: '1 Infinite Loop, Cupertino, CA 95014, United States',
11
+ * city: 'Cupertino',
12
+ * country: 'United States',
13
+ * isoCountryCode: 'US',
14
+ * }
15
+ * ```
16
+ * @platform android
17
+ * @platform ios
18
+ */
19
+ export type Address = {
20
+ /**
21
+ * The latitude and longitude of the place, in degrees, for example,
22
+ * `{ latitude: 37.3317, longitude: -122.0301 }`.
23
+ */
24
+ coordinates: Coordinates;
25
+ /**
26
+ * The name of the place, for example, `1 Infinite Loop`. Each platform reads this from its own
27
+ * field, so it can be a building, a street, a postcode or an administrative area.
28
+ */
29
+ name: string | null;
30
+ /**
31
+ * The whole address on one line, for example,
32
+ * `1 Infinite Loop, Cupertino, CA 95014, United States`.
33
+ */
34
+ formattedAddress: string | null;
35
+ /**
36
+ * The city name of the address, for example, `Cupertino`.
37
+ *
38
+ * This is `null` when the backend has no city for the place. That can happen even for a town you
39
+ * would name, in which case the city is often still part of `formattedAddress`.
40
+ */
41
+ city: string | null;
42
+ /**
43
+ * The country name of the address, for example, `United States`.
44
+ */
45
+ country: string | null;
46
+ /**
47
+ * The ISO 3166-1 alpha-2 country code of the address, for example, `US`.
48
+ */
49
+ isoCountryCode: string | null;
50
+ };
51
+ /**
52
+ * Options for [`geocode`](#geocodeaddress-options).
53
+ * @platform android
54
+ * @platform ios
55
+ */
56
+ export type GeocodeOptions = {
57
+ /**
58
+ * The language of the text fields in the result, as a BCP 47 tag such as `en-US`. Defaults to
59
+ * the device language.
60
+ */
61
+ locale?: string;
62
+ };
63
+ /**
64
+ * Options for [`reverseGeocode`](#reversegeocodecoordinates-options).
65
+ * @platform android
66
+ * @platform ios
67
+ */
68
+ export type ReverseGeocodeOptions = {
69
+ /**
70
+ * The language of the text fields in the result, as a BCP 47 tag such as `en-US`. Defaults to
71
+ * the device language.
72
+ */
73
+ locale?: string;
74
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Options for [`reverseGeocode`](#reversegeocodecoordinates-options).
3
+ * @platform android
4
+ * @platform ios
5
+ */ export { };
6
+
7
+ //# sourceMappingURL=Geocoding.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["next/types/Geocoding.types.ts"],"sourcesContent":[null],"names":[],"mappings":"AAiEA;;;;CAIC,GACD,WAME"}
@@ -4,3 +4,4 @@ export * from './LocationProvider.types';
4
4
  export * from './LocationTask.types';
5
5
  export * from './BackgroundSession.types';
6
6
  export * from './LocationUpdates.types';
7
+ export * from './Geocoding.types';
@@ -4,5 +4,6 @@ export * from './LocationProvider.types';
4
4
  export * from './LocationTask.types';
5
5
  export * from './BackgroundSession.types';
6
6
  export * from './LocationUpdates.types';
7
+ export * from './Geocoding.types';
7
8
 
8
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["next/types/index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA,cAAc,mBAAmB;AACjC,cAAc,sBAAsB;AACpC,cAAc,2BAA2B;AACzC,cAAc,uBAAuB;AACrC,cAAc,4BAA4B;AAC1C,cAAc,0BAA0B"}
1
+ {"version":3,"sources":["next/types/index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA,cAAc,mBAAmB;AACjC,cAAc,sBAAsB;AACpC,cAAc,2BAA2B;AACzC,cAAc,uBAAuB;AACrC,cAAc,4BAA4B;AAC1C,cAAc,0BAA0B;AACxC,cAAc,oBAAoB"}
@@ -0,0 +1,11 @@
1
+ import ExpoModulesCore
2
+
3
+ @Record
4
+ struct Address {
5
+ var coordinates: Coordinates
6
+ var name: String?
7
+ var formattedAddress: String?
8
+ var city: String?
9
+ var country: String?
10
+ var isoCountryCode: String?
11
+ }
@@ -0,0 +1,8 @@
1
+ import Foundation
2
+
3
+ func normalizeAddressString(_ value: String?) -> String? {
4
+ guard let value, !value.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
5
+ return nil
6
+ }
7
+ return value
8
+ }
@@ -0,0 +1,73 @@
1
+ import Contacts
2
+ import CoreLocation
3
+ import ExpoModulesCore
4
+
5
+ final class CompatibilityGeocoder: GeocoderNext {
6
+ var forwardPlacemarks: (_ address: String, _ locale: Locale?) async throws -> [CLPlacemark] = { address, locale in
7
+ try await CLGeocoder().geocodeAddressString(address, in: nil, preferredLocale: locale)
8
+ }
9
+
10
+ var reversePlacemarks: (_ location: CLLocation, _ locale: Locale?) async throws -> [CLPlacemark] = { location, locale in
11
+ try await CLGeocoder().reverseGeocodeLocation(location, preferredLocale: locale)
12
+ }
13
+
14
+ func geocode(_ address: String, options: GeocodeOptions) async throws -> [Address] {
15
+ do {
16
+ let placemarks = try await forwardPlacemarks(address, options.locale?.toLocale())
17
+ return placemarks.compactMap { $0.toAddress() }
18
+ } catch {
19
+ return try handleGeocodingError(error)
20
+ }
21
+ }
22
+
23
+ func reverseGeocode(_ coordinates: Coordinates, options: ReverseGeocodeOptions) async throws -> [Address] {
24
+ guard CLLocationCoordinate2DIsValid(
25
+ CLLocationCoordinate2D(latitude: coordinates.latitude, longitude: coordinates.longitude)
26
+ ) else {
27
+ throw InvalidCoordinatesException()
28
+ }
29
+ let location = CLLocation(latitude: coordinates.latitude, longitude: coordinates.longitude)
30
+ do {
31
+ let placemarks = try await reversePlacemarks(location, options.locale?.toLocale())
32
+ return placemarks.compactMap { $0.toAddress() }
33
+ } catch {
34
+ return try handleGeocodingError(error)
35
+ }
36
+ }
37
+
38
+ private func handleGeocodingError(_ error: Error) throws -> [Address] {
39
+ switch error {
40
+ case CLError.geocodeFoundNoResult, CLError.geocodeFoundPartialResult:
41
+ return []
42
+ case CLError.network:
43
+ throw GeocodingUnavailableException().causedBy(error)
44
+ default:
45
+ throw GeocodingFailedException().causedBy(error)
46
+ }
47
+ }
48
+ }
49
+
50
+ private extension CLPlacemark {
51
+ func toAddress() -> Address? {
52
+ guard let location else {
53
+ return nil
54
+ }
55
+ return Address(
56
+ coordinates: Coordinates(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude),
57
+ name: normalizeAddressString(name),
58
+ formattedAddress: normalizeAddressString(postalAddress.map(formatOnOneLine)),
59
+ city: normalizeAddressString(locality),
60
+ country: normalizeAddressString(country),
61
+ isoCountryCode: normalizeAddressString(isoCountryCode)
62
+ )
63
+ }
64
+ }
65
+
66
+ // Single line, comma-separated, like `MKAddress.fullAddress(includingRegion:singleLine:)` on iOS 26
67
+ // "1 Infinite Loop\nCupertino CA 95014\nUnited States" -> "1 Infinite Loop, Cupertino CA 95014, United States"
68
+ private func formatOnOneLine(_ postalAddress: CNPostalAddress) -> String {
69
+ return CNPostalAddressFormatter.string(from: postalAddress, style: .mailingAddress)
70
+ .components(separatedBy: .newlines)
71
+ .filter { !$0.isEmpty }
72
+ .joined(separator: ", ")
73
+ }
@@ -0,0 +1,6 @@
1
+ import ExpoModulesCore
2
+
3
+ @Record
4
+ struct GeocodeOptions {
5
+ var locale: String?
6
+ }
@@ -0,0 +1,4 @@
1
+ protocol GeocoderNext {
2
+ func geocode(_ address: String, options: GeocodeOptions) async throws -> [Address]
3
+ func reverseGeocode(_ coordinates: Coordinates, options: ReverseGeocodeOptions) async throws -> [Address]
4
+ }
@@ -0,0 +1,70 @@
1
+ import ExpoModulesCore
2
+ import MapKit
3
+
4
+ @available(iOS 26.0, *)
5
+ final class MapKitGeocoder: GeocoderNext {
6
+ var forwardMapItems: (_ address: String, _ locale: Locale?) async throws -> [MKMapItem] = { address, locale in
7
+ guard let request = MKGeocodingRequest(addressString: address) else {
8
+ return []
9
+ }
10
+ request.preferredLocale = locale
11
+ return try await request.mapItems
12
+ }
13
+
14
+ var reverseMapItems: (_ location: CLLocation, _ locale: Locale?) async throws -> [MKMapItem] = { location, locale in
15
+ guard let request = MKReverseGeocodingRequest(location: location) else {
16
+ return []
17
+ }
18
+ request.preferredLocale = locale
19
+ return try await request.mapItems
20
+ }
21
+
22
+ func geocode(_ address: String, options: GeocodeOptions) async throws -> [Address] {
23
+ do {
24
+ return try await forwardMapItems(address, options.locale?.toLocale()).map { $0.toAddress() }
25
+ } catch {
26
+ return try handleGeocodingError(error)
27
+ }
28
+ }
29
+
30
+ func reverseGeocode(_ coordinates: Coordinates, options: ReverseGeocodeOptions) async throws -> [Address] {
31
+ guard CLLocationCoordinate2DIsValid(
32
+ CLLocationCoordinate2D(latitude: coordinates.latitude, longitude: coordinates.longitude)
33
+ ) else {
34
+ throw InvalidCoordinatesException()
35
+ }
36
+ let location = CLLocation(latitude: coordinates.latitude, longitude: coordinates.longitude)
37
+ do {
38
+ return try await reverseMapItems(location, options.locale?.toLocale()).map { $0.toAddress() }
39
+ } catch {
40
+ return try handleGeocodingError(error)
41
+ }
42
+ }
43
+
44
+ private func handleGeocodingError(_ error: Error) throws -> [Address] {
45
+ switch error {
46
+ case MKError.placemarkNotFound:
47
+ return []
48
+ case MKError.loadingThrottled, MKError.serverFailure:
49
+ throw GeocodingUnavailableException().causedBy(error)
50
+ default:
51
+ throw GeocodingFailedException().causedBy(error)
52
+ }
53
+ }
54
+ }
55
+
56
+ @available(iOS 26.0, *)
57
+ private extension MKMapItem {
58
+ func toAddress() -> Address {
59
+ Address(
60
+ coordinates: Coordinates(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude),
61
+ name: normalizeAddressString(name),
62
+ formattedAddress: normalizeAddressString(
63
+ addressRepresentations?.fullAddress(includingRegion: true, singleLine: true)
64
+ ),
65
+ city: normalizeAddressString(addressRepresentations?.cityName),
66
+ country: normalizeAddressString(addressRepresentations?.regionName),
67
+ isoCountryCode: normalizeAddressString(addressRepresentations?.region?.identifier)
68
+ )
69
+ }
70
+ }
@@ -0,0 +1,6 @@
1
+ import ExpoModulesCore
2
+
3
+ @Record
4
+ struct ReverseGeocodeOptions {
5
+ var locale: String?
6
+ }
@@ -0,0 +1,12 @@
1
+ import ExpoModulesCore
2
+
3
+ extension String {
4
+ func toLocale() -> Locale {
5
+ let locale = Locale(identifier: self)
6
+ let isISOLanguage = locale.language.languageCode?.isISOLanguage ?? false
7
+ if !isISOLanguage {
8
+ log.warn("[expo-location] The locale '\(self)' has no recognized language code, so geocoding results use the device language. Pass a BCP 47 tag such as 'en-US'.")
9
+ }
10
+ return locale
11
+ }
12
+ }
@@ -5,6 +5,13 @@ public final class LocationModuleNext: Module {
5
5
  private lazy var permissions = LocationPermissionsDelegate(appContext: appContext)
6
6
  private lazy var accessGuard = LocationAccessGuard(appContext: appContext)
7
7
 
8
+ private lazy var geocoder: any GeocoderNext = {
9
+ if #available(iOS 26.0, *) {
10
+ return MapKitGeocoder()
11
+ }
12
+ return CompatibilityGeocoder()
13
+ }()
14
+
8
15
  public func definition() -> ModuleDefinition {
9
16
  Name("LocationModuleNext")
10
17
 
@@ -42,6 +49,14 @@ public final class LocationModuleNext: Module {
42
49
  return location?.toPosition()
43
50
  }
44
51
 
52
+ AsyncFunction("geocode") { (address: String, options: GeocodeOptions?) -> [Address] in
53
+ try await geocoder.geocode(address, options: options ?? GeocodeOptions())
54
+ }
55
+
56
+ AsyncFunction("reverseGeocode") { (coordinates: Coordinates, options: ReverseGeocodeOptions?) -> [Address] in
57
+ try await geocoder.reverseGeocode(coordinates, options: options ?? ReverseGeocodeOptions())
58
+ }
59
+
45
60
  Function("watchPosition") { (profile: Profile?) -> PositionWatcher in
46
61
  guard CLLocationManager.locationServicesEnabled() else {
47
62
  throw LocationServicesDisabledGlobally()
@@ -108,3 +108,22 @@ final class MissingPlistKeyException: GenericException<String>, @unchecked Senda
108
108
  "granted. Add the key via the expo-location config plugin or by hand, then rebuild the app"
109
109
  }
110
110
  }
111
+
112
+ final class InvalidCoordinatesException: Exception, @unchecked Sendable {
113
+ override var reason: String {
114
+ "Cannot reverse geocode invalid coordinates. Provide a finite latitude between -90 and 90 " +
115
+ "and a finite longitude between -180 and 180, in degrees"
116
+ }
117
+ }
118
+
119
+ final class GeocodingUnavailableException: Exception, @unchecked Sendable {
120
+ override var reason: String {
121
+ "Geocoding is unavailable."
122
+ }
123
+ }
124
+
125
+ final class GeocodingFailedException: Exception, @unchecked Sendable {
126
+ override var reason: String {
127
+ "Geocoding failed."
128
+ }
129
+ }
@@ -18,9 +18,19 @@ struct Position {
18
18
 
19
19
  extension Position {
20
20
  func toEventPayload() -> [String: Any] {
21
- var payload = toDictionary()
22
- payload["coordinates"] = coordinates.toDictionary()
23
- return payload
21
+ return [
22
+ "coordinates": coordinates.toDictionary(),
23
+ "horizontalAccuracy": horizontalAccuracy ?? NSNull(),
24
+ "timestamp": timestamp,
25
+ "altitude": altitude ?? NSNull(),
26
+ "mslAltitude": mslAltitude ?? NSNull(),
27
+ "verticalAccuracy": verticalAccuracy ?? NSNull(),
28
+ "mocked": mocked,
29
+ "heading": heading ?? NSNull(),
30
+ "headingAccuracy": headingAccuracy ?? NSNull(),
31
+ "speed": speed ?? NSNull(),
32
+ "speedAccuracy": speedAccuracy ?? NSNull()
33
+ ]
24
34
  }
25
35
  }
26
36
 
@@ -0,0 +1 @@
1
+ 120840a5003273d2755bdfd29ff879650c7ed3725bf899192bb847c3eb4bf57b
@@ -0,0 +1 @@
1
+ 9b6cdafb0d002d509907d0255b37108c43d26aa4749d1edb6aa69f096b0d2a57dddd97f8c9ca36432ae5a4e8b5f225b12ae22d1c6689ac30e5361caa2be11f4f
@@ -0,0 +1 @@
1
+ 73180f2d4ee8829dd5bafc903e6ac028ebbd3444f4e73798f77549fb770fc619
@@ -0,0 +1 @@
1
+ e8abae27e193a35dce8e74c07c389657ca97769a7d8a536aa17ec97ccb42732065342b368a247969d6e7d0dae3907cc6b8638e3757869d1bba0d69f25499e188
@@ -3,7 +3,7 @@
3
3
  "component": {
4
4
  "group": "host.exp.exponent",
5
5
  "module": "expo.modules.location",
6
- "version": "58.0.21",
6
+ "version": "58.0.23",
7
7
  "attributes": {
8
8
  "org.gradle.status": "release"
9
9
  }
@@ -33,13 +33,13 @@
33
33
  ],
34
34
  "files": [
35
35
  {
36
- "name": "expo.modules.location-58.0.21.aar",
37
- "url": "expo.modules.location-58.0.21.aar",
38
- "size": 581890,
39
- "sha512": "d3eb631b8bd28712b804810b901ec3fe51d1eb83366f189d7c65490b905b9d08cf99775a9d9f0cb5dea2b5d735a232488619c78c482220ebf1d04d9fd48c6d6f",
40
- "sha256": "d19b8691e52672f787c2f00f17b0bf4e134cd1af43cc3503f79c2c3bbb5bc8b8",
41
- "sha1": "e619441840ee48b895ef8deac3cfdf03db006d02",
42
- "md5": "88320df8c179b0f8fcb669f696ab0f96"
36
+ "name": "expo.modules.location-58.0.23.aar",
37
+ "url": "expo.modules.location-58.0.23.aar",
38
+ "size": 613416,
39
+ "sha512": "e8abae27e193a35dce8e74c07c389657ca97769a7d8a536aa17ec97ccb42732065342b368a247969d6e7d0dae3907cc6b8638e3757869d1bba0d69f25499e188",
40
+ "sha256": "73180f2d4ee8829dd5bafc903e6ac028ebbd3444f4e73798f77549fb770fc619",
41
+ "sha1": "31df893751449ac03d2fcd305bc5685d091a00bd",
42
+ "md5": "d38c27810685b53a0ac7e5b60b14a01d"
43
43
  }
44
44
  ]
45
45
  },
@@ -90,13 +90,13 @@
90
90
  ],
91
91
  "files": [
92
92
  {
93
- "name": "expo.modules.location-58.0.21.aar",
94
- "url": "expo.modules.location-58.0.21.aar",
95
- "size": 581890,
96
- "sha512": "d3eb631b8bd28712b804810b901ec3fe51d1eb83366f189d7c65490b905b9d08cf99775a9d9f0cb5dea2b5d735a232488619c78c482220ebf1d04d9fd48c6d6f",
97
- "sha256": "d19b8691e52672f787c2f00f17b0bf4e134cd1af43cc3503f79c2c3bbb5bc8b8",
98
- "sha1": "e619441840ee48b895ef8deac3cfdf03db006d02",
99
- "md5": "88320df8c179b0f8fcb669f696ab0f96"
93
+ "name": "expo.modules.location-58.0.23.aar",
94
+ "url": "expo.modules.location-58.0.23.aar",
95
+ "size": 613416,
96
+ "sha512": "e8abae27e193a35dce8e74c07c389657ca97769a7d8a536aa17ec97ccb42732065342b368a247969d6e7d0dae3907cc6b8638e3757869d1bba0d69f25499e188",
97
+ "sha256": "73180f2d4ee8829dd5bafc903e6ac028ebbd3444f4e73798f77549fb770fc619",
98
+ "sha1": "31df893751449ac03d2fcd305bc5685d091a00bd",
99
+ "md5": "d38c27810685b53a0ac7e5b60b14a01d"
100
100
  }
101
101
  ]
102
102
  },
@@ -110,13 +110,13 @@
110
110
  },
111
111
  "files": [
112
112
  {
113
- "name": "expo.modules.location-58.0.21-sources.jar",
114
- "url": "expo.modules.location-58.0.21-sources.jar",
115
- "size": 53194,
116
- "sha512": "18552c6609c50cfccd8b7cea5c9c1295a2df6e7080f4e8472681c4ea633376e94f43bcfbc70946391792d635dcd9c7c0688d4ab382b6b34f1add598d82916943",
117
- "sha256": "cd09575a93cfc2f28b138c1b4d479e407035cc991639a75e3da3e5a057170a28",
118
- "sha1": "2ab913e2508bb752970c222cf4906f023b772209",
119
- "md5": "9cd70fc8266a1f17601f49e84e3255d3"
113
+ "name": "expo.modules.location-58.0.23-sources.jar",
114
+ "url": "expo.modules.location-58.0.23-sources.jar",
115
+ "size": 56105,
116
+ "sha512": "9b6cdafb0d002d509907d0255b37108c43d26aa4749d1edb6aa69f096b0d2a57dddd97f8c9ca36432ae5a4e8b5f225b12ae22d1c6689ac30e5361caa2be11f4f",
117
+ "sha256": "120840a5003273d2755bdfd29ff879650c7ed3725bf899192bb847c3eb4bf57b",
118
+ "sha1": "9854725f1255998644e8b713de981e7552c737f9",
119
+ "md5": "d989805f93826516c8621b81d773c375"
120
120
  }
121
121
  ]
122
122
  }
@@ -0,0 +1 @@
1
+ 87920150711d78e8b9519efcdd993410498b1be21de735d6fc5e57adf0aaafd1
@@ -0,0 +1 @@
1
+ 5a5fed9641c43138327b7effac91997bf691464674e8cb279c277f8e53c45a14d9a53f6e4c6e39d522580748fc8874e3f1a55fb27e05e5fbe9f2775ffb58cada
@@ -9,7 +9,7 @@
9
9
  <modelVersion>4.0.0</modelVersion>
10
10
  <groupId>host.exp.exponent</groupId>
11
11
  <artifactId>expo.modules.location</artifactId>
12
- <version>58.0.21</version>
12
+ <version>58.0.23</version>
13
13
  <packaging>aar</packaging>
14
14
  <name>expo.modules.location</name>
15
15
  <url>https://github.com/expo/expo</url>
@@ -0,0 +1 @@
1
+ b14e536402a0d88516b195c5bb1c8b65eb7e25d93a09ff1e99eecc037f718977
@@ -0,0 +1 @@
1
+ 9a43939446ac8223b9dd77c7be76b450910945c163c65325379cc8ad2249c0339769a9c8a35c0bd02a07acfe4076c958fa46b485c7600ca5181fe87c8c66e004
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-location",
3
- "version": "58.0.21",
3
+ "version": "58.0.23",
4
4
  "description": "Allows reading geolocation information from the device. Your app can poll for the current location or subscribe to location update events.",
5
5
  "keywords": [
6
6
  "compass",
@@ -56,7 +56,7 @@
56
56
  "@types/jest": "^30.0.0",
57
57
  "@types/node": "^22.14.0",
58
58
  "@types/react": "~19.3.0",
59
- "expo": "58.0.24",
59
+ "expo": "58.1.0",
60
60
  "expo-task-manager": "~58.0.14"
61
61
  },
62
62
  "peerDependencies": {
package/src/Location.ts CHANGED
@@ -1,4 +1,10 @@
1
- import { createPermissionHook, isRunningInExpoGo, Platform, type PermissionResponse } from 'expo';
1
+ import {
2
+ CodedError,
3
+ createPermissionHook,
4
+ isRunningInExpoGo,
5
+ Platform,
6
+ type PermissionResponse,
7
+ } from 'expo';
2
8
 
3
9
  import ExpoLocation from './ExpoLocation';
4
10
  import type {
@@ -18,6 +24,7 @@ import type {
18
24
  LocationTaskOptions,
19
25
  MotionActivityCallback,
20
26
  MotionActivityObject,
27
+ MotionActivityOptions,
21
28
  } from './Location.types';
22
29
  import { LocationAccuracy } from './Location.types';
23
30
  import {
@@ -400,30 +407,54 @@ export const useMotionActivityPermissions = createPermissionHook({
400
407
  * On Android 10+, the `ACTIVITY_RECOGNITION` runtime permission must be granted beforehand.
401
408
  * On iOS, the system will prompt the user for Motion and Fitness access the first time this method is called.
402
409
  *
403
- *
404
- * @return a promise which fulfills with a [`MotionActivityObject`](#motionactivityobject).
410
+ * @param options Options for the call. See [`MotionActivityOptions`](#motionactivityoptions).
411
+ * @return A promise which fulfills with a [`MotionActivityObject`](#motionactivityobject), or
412
+ * rejects with `ERR_LOCATION_MOTION_ACTIVITY_TIMEOUT` when `timeout` passes first.
405
413
  *
406
414
  * @platform android
407
415
  * @platform ios
408
416
  */
409
- export async function getMotionActivityAsync(): Promise<MotionActivityObject> {
410
- return new Promise(async (resolve, reject) => {
411
- let subscriber: LocationSubscription | undefined;
412
- try {
413
- subscriber = await watchMotionActivityAsync(
414
- (activity) => {
415
- subscriber?.remove();
416
- resolve(activity);
417
- },
418
- (reason) => {
419
- subscriber?.remove();
420
- reject(new Error(reason));
421
- }
417
+ export async function getMotionActivityAsync({
418
+ timeout,
419
+ }: MotionActivityOptions = {}): Promise<MotionActivityObject> {
420
+ assertValidTimeout(timeout);
421
+ const { promise, resolve, reject } = Promise.withResolvers<MotionActivityObject>();
422
+ const subscriber = await watchMotionActivityAsync(resolve, (reason) => reject(new Error(reason)));
423
+ try {
424
+ return await withTimeout(promise, timeout);
425
+ } finally {
426
+ subscriber.remove();
427
+ }
428
+ }
429
+
430
+ function assertValidTimeout(timeout: number | undefined): void {
431
+ if (timeout === undefined) {
432
+ return;
433
+ }
434
+ if (!Number.isFinite(timeout) || timeout <= 0) {
435
+ throw new CodedError(
436
+ 'ERR_LOCATION_INVALID_TIMEOUT',
437
+ `\`timeout\` must be a positive, finite number of milliseconds. Got ${timeout} instead.`
438
+ );
439
+ }
440
+ }
441
+
442
+ function withTimeout<T>(promise: Promise<T>, timeout: number | undefined): Promise<T> {
443
+ if (timeout === undefined) {
444
+ return promise;
445
+ }
446
+ let timer: ReturnType<typeof setTimeout> | undefined;
447
+ const timedOut = new Promise<never>((_, reject) => {
448
+ timer = setTimeout(() => {
449
+ reject(
450
+ new CodedError(
451
+ 'ERR_LOCATION_MOTION_ACTIVITY_TIMEOUT',
452
+ `No motion activity update arrived within ${timeout} ms.`
453
+ )
422
454
  );
423
- } catch (e) {
424
- reject(e);
425
- }
455
+ }, timeout);
426
456
  });
457
+ return Promise.race([promise, timedOut]).finally(() => clearTimeout(timer));
427
458
  }
428
459
 
429
460
  /**