expo-location 18.1.1-canary-20250408-7f0ab53 → 18.1.2
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/CHANGELOG.md +8 -0
- package/android/build.gradle +2 -2
- package/build/ExpoLocation.web.d.ts +3 -3
- package/build/ExpoLocation.web.d.ts.map +1 -1
- package/build/ExpoLocation.web.js +2 -3
- package/build/ExpoLocation.web.js.map +1 -1
- package/build/GeolocationPolyfill.js.map +1 -1
- package/build/Location.js.map +1 -1
- package/build/LocationSubscribers.js.map +1 -1
- package/expo-module.config.json +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/{18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53.module → 18.1.2/expo.modules.location-18.1.2.module} +7 -7
- package/local-maven-repo/host/exp/exponent/expo.modules.location/18.1.2/expo.modules.location-18.1.2.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/18.1.2/expo.modules.location-18.1.2.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/18.1.2/expo.modules.location-18.1.2.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/18.1.2/expo.modules.location-18.1.2.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/{18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53.pom → 18.1.2/expo.modules.location-18.1.2.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/18.1.2/expo.modules.location-18.1.2.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/18.1.2/expo.modules.location-18.1.2.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/18.1.2/expo.modules.location-18.1.2.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/18.1.2/expo.modules.location-18.1.2.pom.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/maven-metadata.xml +4 -4
- package/local-maven-repo/host/exp/exponent/expo.modules.location/maven-metadata.xml.md5 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/maven-metadata.xml.sha1 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/maven-metadata.xml.sha256 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/maven-metadata.xml.sha512 +1 -1
- package/package.json +5 -4
- package/plugin/build/withLocation.d.ts +6 -6
- package/src/ExpoLocation.web.ts +6 -7
- package/src/GeolocationPolyfill.ts +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53.pom.sha512 +0 -1
- /package/local-maven-repo/host/exp/exponent/expo.modules.location/{18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53-sources.jar → 18.1.2/expo.modules.location-18.1.2-sources.jar} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.location/{18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53-sources.jar.md5 → 18.1.2/expo.modules.location-18.1.2-sources.jar.md5} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.location/{18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53-sources.jar.sha1 → 18.1.2/expo.modules.location-18.1.2-sources.jar.sha1} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.location/{18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53-sources.jar.sha256 → 18.1.2/expo.modules.location-18.1.2-sources.jar.sha256} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.location/{18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53-sources.jar.sha512 → 18.1.2/expo.modules.location-18.1.2-sources.jar.sha512} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.location/{18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53.aar → 18.1.2/expo.modules.location-18.1.2.aar} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.location/{18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53.aar.md5 → 18.1.2/expo.modules.location-18.1.2.aar.md5} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.location/{18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53.aar.sha1 → 18.1.2/expo.modules.location-18.1.2.aar.sha1} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.location/{18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53.aar.sha256 → 18.1.2/expo.modules.location-18.1.2.aar.sha256} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.location/{18.1.1-canary-20250408-7f0ab53/expo.modules.location-18.1.1-canary-20250408-7f0ab53.aar.sha512 → 18.1.2/expo.modules.location-18.1.2.aar.sha512} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 18.1.2 — 2025-04-14
|
|
14
|
+
|
|
15
|
+
_This version does not introduce any user-facing changes._
|
|
16
|
+
|
|
17
|
+
## 18.1.1 — 2025-04-09
|
|
18
|
+
|
|
19
|
+
_This version does not introduce any user-facing changes._
|
|
20
|
+
|
|
13
21
|
## 18.1.0 — 2025-04-04
|
|
14
22
|
|
|
15
23
|
### 🐛 Bug fixes
|
package/android/build.gradle
CHANGED
|
@@ -4,13 +4,13 @@ plugins {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
group = 'host.exp.exponent'
|
|
7
|
-
version = '18.1.
|
|
7
|
+
version = '18.1.2'
|
|
8
8
|
|
|
9
9
|
android {
|
|
10
10
|
namespace "expo.modules.location"
|
|
11
11
|
defaultConfig {
|
|
12
12
|
versionCode 29
|
|
13
|
-
versionName "18.1.
|
|
13
|
+
versionName "18.1.2"
|
|
14
14
|
consumerProguardFiles("proguard-rules.pro")
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -6,12 +6,12 @@ declare const _default: {
|
|
|
6
6
|
}>;
|
|
7
7
|
getLastKnownPositionAsync(options?: LocationLastKnownOptions): Promise<LocationObject | null>;
|
|
8
8
|
getCurrentPositionAsync(options: LocationOptions): Promise<LocationObject>;
|
|
9
|
-
removeWatchAsync(watchId:
|
|
10
|
-
watchDeviceHeading(
|
|
9
|
+
removeWatchAsync(watchId: number): Promise<void>;
|
|
10
|
+
watchDeviceHeading(_headingId: number): Promise<void>;
|
|
11
11
|
hasServicesEnabledAsync(): Promise<boolean>;
|
|
12
12
|
geocodeAsync(): Promise<any[]>;
|
|
13
13
|
reverseGeocodeAsync(): Promise<any[]>;
|
|
14
|
-
watchPositionImplAsync(watchId:
|
|
14
|
+
watchPositionImplAsync(watchId: number, options: PositionOptions): Promise<number>;
|
|
15
15
|
requestForegroundPermissionsAsync(): Promise<PermissionResponse>;
|
|
16
16
|
requestBackgroundPermissionsAsync(): Promise<PermissionResponse>;
|
|
17
17
|
getForegroundPermissionsAsync(): Promise<PermissionResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoLocation.web.d.ts","sourceRoot":"","sources":["../src/ExpoLocation.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAyC,MAAM,mBAAmB,CAAC;AAE9F,OAAO,EAEL,wBAAwB,EACxB,cAAc,EACd,eAAe,EAChB,MAAM,kBAAkB,CAAC;;8BAuHQ,
|
|
1
|
+
{"version":3,"file":"ExpoLocation.web.d.ts","sourceRoot":"","sources":["../src/ExpoLocation.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAyC,MAAM,mBAAmB,CAAC;AAE9F,OAAO,EAEL,wBAAwB,EACxB,cAAc,EACd,eAAe,EAChB,MAAM,kBAAkB,CAAC;;8BAuHQ,OAAO,CAAC;QAAE,uBAAuB,EAAE,OAAO,CAAA;KAAE,CAAC;wCAMlE,wBAAwB,GAChC,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;qCAMM,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;8BAahD,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;mCAGjB,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;+BAG1B,OAAO,CAAC,OAAO,CAAC;oBAG3B,OAAO,CAAC,GAAG,EAAE,CAAC;2BAGP,OAAO,CAAC,GAAG,EAAE,CAAC;oCAGL,MAAM,WAAW,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;yCAiB7C,OAAO,CAAC,kBAAkB,CAAC;yCAG3B,OAAO,CAAC,kBAAkB,CAAC;qCAG/B,OAAO,CAAC,kBAAkB,CAAC;qCAG3B,OAAO,CAAC,kBAAkB,CAAC;;AApEpE,wBAuEE"}
|
|
@@ -127,7 +127,7 @@ export default {
|
|
|
127
127
|
async removeWatchAsync(watchId) {
|
|
128
128
|
navigator.geolocation.clearWatch(watchId);
|
|
129
129
|
},
|
|
130
|
-
async watchDeviceHeading(
|
|
130
|
+
async watchDeviceHeading(_headingId) {
|
|
131
131
|
console.warn('Location.watchDeviceHeading: is not supported on web');
|
|
132
132
|
},
|
|
133
133
|
async hasServicesEnabledAsync() {
|
|
@@ -141,8 +141,7 @@ export default {
|
|
|
141
141
|
},
|
|
142
142
|
async watchPositionImplAsync(watchId, options) {
|
|
143
143
|
return new Promise((resolve) => {
|
|
144
|
-
|
|
145
|
-
watchId = global.navigator.geolocation.watchPosition((position) => {
|
|
144
|
+
watchId = navigator.geolocation.watchPosition((position) => {
|
|
146
145
|
lastKnownPosition = geolocationPositionToJSON(position);
|
|
147
146
|
LocationEventEmitter.emit('Expo.locationChanged', {
|
|
148
147
|
watchId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoLocation.web.js","sourceRoot":"","sources":["../src/ExpoLocation.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE9F,OAAO,EACL,gBAAgB,GAIjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,MAAM,aAAc,SAAQ,KAAK;IAC/B,IAAI,CAAS;IAEb;QACE,KAAK,CAAC,oDAAoD,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED;;GAEG;AACH,SAAS,yBAAyB,CAAC,QAAwB;IACzD,MAAM,EAA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AAa,EAAE,CAAC;IAC5B,CAAC;IACD,KAAK,CAAC,mBAAmB;QACvB,MAAM,IAAI,aAAa,EAAE,CAAC;IAC5B,CAAC;IACD,KAAK,CAAC,sBAAsB,CAAC,OAAe,EAAE,OAAwB;QACpE,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,EAAE;YACrC,8CAA8C;YAC9C,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAClD,CAAC,QAAQ,EAAE,EAAE;gBACX,iBAAiB,GAAG,yBAAyB,CAAC,QAAQ,CAAC,CAAC;gBACxD,oBAAoB,CAAC,IAAI,CAAC,sBAAsB,EAAE;oBAChD,OAAO;oBACP,QAAQ,EAAE,iBAAiB;iBAC5B,CAAC,CAAC;YACL,CAAC,EACD,SAAS,EACT,OAAO,CACR,CAAC;YACF,OAAO,CAAC,OAAO,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,iCAAiC;QACrC,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IACD,KAAK,CAAC,iCAAiC;QACrC,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IACD,KAAK,CAAC,6BAA6B;QACjC,OAAO,mBAAmB,EAAE,CAAC;IAC/B,CAAC;IACD,KAAK,CAAC,6BAA6B;QACjC,OAAO,mBAAmB,EAAE,CAAC;IAC/B,CAAC;CACF,CAAC","sourcesContent":["import { PermissionResponse, PermissionStatus, UnavailabilityError } from 'expo-modules-core';\n\nimport {\n LocationAccuracy,\n LocationLastKnownOptions,\n LocationObject,\n LocationOptions,\n} from './Location.types';\nimport { LocationEventEmitter } from './LocationEventEmitter';\n\nclass GeocoderError extends Error {\n code: string;\n\n constructor() {\n super('Geocoder service is not available for this device.');\n this.code = 'E_NO_GEOCODER';\n }\n}\n\n/**\n * Converts `GeolocationPosition` to JavaScript object.\n */\nfunction geolocationPositionToJSON(position: LocationObject): LocationObject {\n const { coords, timestamp } = position;\n return {\n coords: {\n latitude: coords.latitude,\n longitude: coords.longitude,\n altitude: coords.altitude,\n accuracy: coords.accuracy,\n altitudeAccuracy: coords.altitudeAccuracy,\n heading: coords.heading,\n speed: coords.speed,\n },\n timestamp,\n };\n}\n\n/**\n * Checks whether given location didn't exceed given `maxAge` and fits in the required accuracy.\n */\nfunction isLocationValid(location: LocationObject, options: LocationLastKnownOptions): boolean {\n const maxAge = typeof options.maxAge === 'number' ? options.maxAge : Infinity;\n const requiredAccuracy =\n typeof options.requiredAccuracy === 'number' ? options.requiredAccuracy : Infinity;\n const locationAccuracy = location.coords.accuracy ?? Infinity;\n\n return Date.now() - location.timestamp <= maxAge && locationAccuracy <= requiredAccuracy;\n}\n\n/**\n * Gets the permission details. The implementation is not very good as it's not\n * possible to query for permission on all browsers, apparently only the\n * latest versions will support this.\n */\nasync function getPermissionsAsync(shouldAsk = false): Promise<PermissionResponse> {\n if (!navigator?.permissions?.query) {\n throw new UnavailabilityError('expo-location', 'navigator.permissions API is not available');\n }\n\n const permission = await navigator.permissions.query({ name: 'geolocation' });\n\n if (permission.state === 'granted') {\n return {\n status: PermissionStatus.GRANTED,\n granted: true,\n canAskAgain: true,\n expires: 0,\n };\n }\n\n if (permission.state === 'denied') {\n return {\n status: PermissionStatus.DENIED,\n granted: false,\n canAskAgain: true,\n expires: 0,\n };\n }\n\n if (shouldAsk) {\n return new Promise((resolve) => {\n navigator.geolocation.getCurrentPosition(\n () => {\n resolve({\n status: PermissionStatus.GRANTED,\n granted: true,\n canAskAgain: true,\n expires: 0,\n });\n },\n (positionError: GeolocationPositionError) => {\n if (positionError.code === positionError.PERMISSION_DENIED) {\n resolve({\n status: PermissionStatus.DENIED,\n granted: false,\n canAskAgain: true,\n expires: 0,\n });\n return;\n }\n\n resolve({\n status: PermissionStatus.GRANTED,\n granted: false,\n canAskAgain: true,\n expires: 0,\n });\n }\n );\n });\n }\n\n // The permission state is 'prompt' when the permission has not been requested\n // yet, tested on Chrome.\n return {\n status: PermissionStatus.UNDETERMINED,\n granted: false,\n canAskAgain: true,\n expires: 0,\n };\n}\n\nlet lastKnownPosition: LocationObject | null = null;\n\nexport default {\n async getProviderStatusAsync(): Promise<{ locationServicesEnabled: boolean }> {\n return {\n locationServicesEnabled: 'geolocation' in navigator,\n };\n },\n async getLastKnownPositionAsync(\n options: LocationLastKnownOptions = {}\n ): Promise<LocationObject | null> {\n if (lastKnownPosition && isLocationValid(lastKnownPosition, options)) {\n return lastKnownPosition;\n }\n return null;\n },\n async getCurrentPositionAsync(options: LocationOptions): Promise<LocationObject> {\n return new Promise<LocationObject>((resolve, reject) => {\n const resolver = (position) => {\n lastKnownPosition = geolocationPositionToJSON(position);\n resolve(lastKnownPosition);\n };\n navigator.geolocation.getCurrentPosition(resolver, reject, {\n maximumAge: Infinity,\n enableHighAccuracy: (options.accuracy ?? 0) > LocationAccuracy.Balanced,\n ...options,\n });\n });\n },\n async removeWatchAsync(watchId): Promise<void> {\n navigator.geolocation.clearWatch(watchId);\n },\n async watchDeviceHeading(headingId): Promise<void> {\n console.warn('Location.watchDeviceHeading: is not supported on web');\n },\n async hasServicesEnabledAsync(): Promise<boolean> {\n return 'geolocation' in navigator;\n },\n async geocodeAsync(): Promise<any[]> {\n throw new GeocoderError();\n },\n async reverseGeocodeAsync(): Promise<any[]> {\n throw new GeocoderError();\n },\n async watchPositionImplAsync(watchId: string, options: LocationOptions): Promise<string> {\n return new Promise<string>((resolve) => {\n // @ts-ignore: the types here need to be fixed\n watchId = global.navigator.geolocation.watchPosition(\n (position) => {\n lastKnownPosition = geolocationPositionToJSON(position);\n LocationEventEmitter.emit('Expo.locationChanged', {\n watchId,\n location: lastKnownPosition,\n });\n },\n undefined,\n options\n );\n resolve(watchId);\n });\n },\n\n async requestForegroundPermissionsAsync(): Promise<PermissionResponse> {\n return getPermissionsAsync(true);\n },\n async requestBackgroundPermissionsAsync(): Promise<PermissionResponse> {\n return getPermissionsAsync(true);\n },\n async getForegroundPermissionsAsync(): Promise<PermissionResponse> {\n return getPermissionsAsync();\n },\n async getBackgroundPermissionsAsync(): Promise<PermissionResponse> {\n return getPermissionsAsync();\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ExpoLocation.web.js","sourceRoot":"","sources":["../src/ExpoLocation.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE9F,OAAO,EACL,gBAAgB,GAIjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,MAAM,aAAc,SAAQ,KAAK;IAC/B,IAAI,CAAS;IAEb;QACE,KAAK,CAAC,oDAAoD,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED;;GAEG;AACH,SAAS,yBAAyB,CAAC,QAAwB;IACzD,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;IACvC,OAAO;QACL,MAAM,EAAE;YACN,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;YACzC,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB;QACD,SAAS;KACV,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,QAAwB,EAAE,OAAiC;IAClF,MAAM,MAAM,GAAG,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC9E,MAAM,gBAAgB,GACpB,OAAO,OAAO,CAAC,gBAAgB,KAAK,QAAQ,CAA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L,CAAC;IAED,KAAK,CAAC,iCAAiC;QACrC,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IACD,KAAK,CAAC,iCAAiC;QACrC,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IACD,KAAK,CAAC,6BAA6B;QACjC,OAAO,mBAAmB,EAAE,CAAC;IAC/B,CAAC;IACD,KAAK,CAAC,6BAA6B;QACjC,OAAO,mBAAmB,EAAE,CAAC;IAC/B,CAAC;CACF,CAAC","sourcesContent":["import { PermissionResponse, PermissionStatus, UnavailabilityError } from 'expo-modules-core';\n\nimport {\n LocationAccuracy,\n LocationLastKnownOptions,\n LocationObject,\n LocationOptions,\n} from './Location.types';\nimport { LocationEventEmitter } from './LocationEventEmitter';\n\nclass GeocoderError extends Error {\n code: string;\n\n constructor() {\n super('Geocoder service is not available for this device.');\n this.code = 'E_NO_GEOCODER';\n }\n}\n\n/**\n * Converts `GeolocationPosition` to JavaScript object.\n */\nfunction geolocationPositionToJSON(position: LocationObject): LocationObject {\n const { coords, timestamp } = position;\n return {\n coords: {\n latitude: coords.latitude,\n longitude: coords.longitude,\n altitude: coords.altitude,\n accuracy: coords.accuracy,\n altitudeAccuracy: coords.altitudeAccuracy,\n heading: coords.heading,\n speed: coords.speed,\n },\n timestamp,\n };\n}\n\n/**\n * Checks whether given location didn't exceed given `maxAge` and fits in the required accuracy.\n */\nfunction isLocationValid(location: LocationObject, options: LocationLastKnownOptions): boolean {\n const maxAge = typeof options.maxAge === 'number' ? options.maxAge : Infinity;\n const requiredAccuracy =\n typeof options.requiredAccuracy === 'number' ? options.requiredAccuracy : Infinity;\n const locationAccuracy = location.coords.accuracy ?? Infinity;\n\n return Date.now() - location.timestamp <= maxAge && locationAccuracy <= requiredAccuracy;\n}\n\n/**\n * Gets the permission details. The implementation is not very good as it's not\n * possible to query for permission on all browsers, apparently only the\n * latest versions will support this.\n */\nasync function getPermissionsAsync(shouldAsk = false): Promise<PermissionResponse> {\n if (!navigator?.permissions?.query) {\n throw new UnavailabilityError('expo-location', 'navigator.permissions API is not available');\n }\n\n const permission = await navigator.permissions.query({ name: 'geolocation' });\n\n if (permission.state === 'granted') {\n return {\n status: PermissionStatus.GRANTED,\n granted: true,\n canAskAgain: true,\n expires: 0,\n };\n }\n\n if (permission.state === 'denied') {\n return {\n status: PermissionStatus.DENIED,\n granted: false,\n canAskAgain: true,\n expires: 0,\n };\n }\n\n if (shouldAsk) {\n return new Promise((resolve) => {\n navigator.geolocation.getCurrentPosition(\n () => {\n resolve({\n status: PermissionStatus.GRANTED,\n granted: true,\n canAskAgain: true,\n expires: 0,\n });\n },\n (positionError: GeolocationPositionError) => {\n if (positionError.code === positionError.PERMISSION_DENIED) {\n resolve({\n status: PermissionStatus.DENIED,\n granted: false,\n canAskAgain: true,\n expires: 0,\n });\n return;\n }\n\n resolve({\n status: PermissionStatus.GRANTED,\n granted: false,\n canAskAgain: true,\n expires: 0,\n });\n }\n );\n });\n }\n\n // The permission state is 'prompt' when the permission has not been requested\n // yet, tested on Chrome.\n return {\n status: PermissionStatus.UNDETERMINED,\n granted: false,\n canAskAgain: true,\n expires: 0,\n };\n}\n\nlet lastKnownPosition: LocationObject | null = null;\n\nexport default {\n async getProviderStatusAsync(): Promise<{ locationServicesEnabled: boolean }> {\n return {\n locationServicesEnabled: 'geolocation' in navigator,\n };\n },\n async getLastKnownPositionAsync(\n options: LocationLastKnownOptions = {}\n ): Promise<LocationObject | null> {\n if (lastKnownPosition && isLocationValid(lastKnownPosition, options)) {\n return lastKnownPosition;\n }\n return null;\n },\n async getCurrentPositionAsync(options: LocationOptions): Promise<LocationObject> {\n return new Promise<LocationObject>((resolve, reject) => {\n const resolver: PositionCallback = (position) => {\n lastKnownPosition = geolocationPositionToJSON(position);\n resolve(lastKnownPosition);\n };\n navigator.geolocation.getCurrentPosition(resolver, reject, {\n maximumAge: Infinity,\n enableHighAccuracy: (options.accuracy ?? 0) > LocationAccuracy.Balanced,\n ...options,\n });\n });\n },\n async removeWatchAsync(watchId: number): Promise<void> {\n navigator.geolocation.clearWatch(watchId);\n },\n async watchDeviceHeading(_headingId: number): Promise<void> {\n console.warn('Location.watchDeviceHeading: is not supported on web');\n },\n async hasServicesEnabledAsync(): Promise<boolean> {\n return 'geolocation' in navigator;\n },\n async geocodeAsync(): Promise<any[]> {\n throw new GeocoderError();\n },\n async reverseGeocodeAsync(): Promise<any[]> {\n throw new GeocoderError();\n },\n async watchPositionImplAsync(watchId: number, options: PositionOptions): Promise<number> {\n return new Promise((resolve) => {\n watchId = navigator.geolocation.watchPosition(\n (position) => {\n lastKnownPosition = geolocationPositionToJSON(position);\n LocationEventEmitter.emit('Expo.locationChanged', {\n watchId,\n location: lastKnownPosition,\n });\n },\n undefined,\n options\n );\n resolve(watchId);\n });\n },\n\n async requestForegroundPermissionsAsync(): Promise<PermissionResponse> {\n return getPermissionsAsync(true);\n },\n async requestBackgroundPermissionsAsync(): Promise<PermissionResponse> {\n return getPermissionsAsync(true);\n },\n async getForegroundPermissionsAsync(): Promise<PermissionResponse> {\n return getPermissionsAsync();\n },\n async getBackgroundPermissionsAsync(): Promise<PermissionResponse> {\n return getPermissionsAsync();\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeolocationPolyfill.js","sourceRoot":"","sources":["../src/GeolocationPolyfill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAkB,gBAAgB,EAAmB,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAW3D,cAAc;AACd;;GAEG;AACH,MAAM,UAAU,6BAA6B;IAC3C,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;
|
|
1
|
+
{"version":3,"file":"GeolocationPolyfill.js","sourceRoot":"","sources":["../src/GeolocationPoly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,CAAC;QAC7C,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,uBAAuB,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC,CAAC;QAC9F,OAAO,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,KAAK,CAAC,CAAC,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AAED,gDAAgD;AAChD,SAAS,aAAa,CACpB,OAAmC,EACnC,KAA+B,EAC/B,OAA2B;IAE3B,MAAM,OAAO,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAE7D,YAAY,CAAC,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,GAAQ,EAAE,EAAE;QACvE,kBAAkB,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,6CAA6C;AAC7C,SAAS,UAAU,CAAC,OAAe;IACjC,kBAAkB,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import { Platform } from 'expo-modules-core';\n\nimport ExpoLocation from './ExpoLocation';\nimport { LocationObject, LocationAccuracy, LocationOptions } from './Location.types';\nimport { LocationSubscriber } from './LocationSubscribers';\n\ntype GeolocationSuccessCallback = (data: LocationObject) => void;\ntype GeolocationErrorCallback = (error: any) => void;\n\ntype GeolocationOptions = {\n enableHighAccuracy?: boolean;\n};\n\ndeclare const global: any;\n\n// @needsAudit\n/**\n * Polyfills `navigator.geolocation` for interop with the core React Native and Web API approach to geolocation.\n */\nexport function installWebGeolocationPolyfill(): void {\n if (Platform.OS !== 'web') {\n // Make sure `window.navigator` is defined in the global scope.\n if (!('window' in global)) {\n global.window = global;\n }\n if (!('navigator' in global.window)) {\n global.window.navigator = {};\n }\n\n // @ts-ignore\n window.navigator.geolocation = {\n getCurrentPosition,\n watchPosition,\n clearWatch,\n };\n }\n}\n\nfunction convertGeolocationOptions(options: GeolocationOptions): LocationOptions {\n return {\n accuracy: options.enableHighAccuracy ? LocationAccuracy.High : LocationAccuracy.Balanced,\n };\n}\n\nfunction getCurrentPosition(\n success: GeolocationSuccessCallback,\n error: GeolocationErrorCallback = () => {},\n options: GeolocationOptions = {}\n): void {\n _getCurrentPositionAsyncWrapper(success, error, options);\n}\n\n// This function exists to let us continue to return undefined from getCurrentPosition, while still\n// using async/await for the internal implementation of it\nasync function _getCurrentPositionAsyncWrapper(\n success: GeolocationSuccessCallback,\n error: GeolocationErrorCallback,\n options: GeolocationOptions\n): Promise<any> {\n try {\n await ExpoLocation.requestPermissionsAsync();\n const result = await ExpoLocation.getCurrentPositionAsync(convertGeolocationOptions(options));\n success(result);\n } catch (e) {\n error(e);\n }\n}\n\n// Polyfill: navigator.geolocation.watchPosition\nfunction watchPosition(\n success: GeolocationSuccessCallback,\n error: GeolocationErrorCallback,\n options: GeolocationOptions\n) {\n const watchId = LocationSubscriber.registerCallback(success);\n\n ExpoLocation.watchPositionImplAsync(watchId, options).catch((err: any) => {\n LocationSubscriber.unregisterCallback(watchId);\n error({ watchId, message: err.message, code: err.code });\n });\n\n return watchId;\n}\n\n// Polyfill: navigator.geolocation.clearWatch\nfunction clearWatch(watchId: number) {\n LocationSubscriber.unregisterCallback(watchId);\n}\n"]}
|
package/build/Location.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Location.js","sourceRoot":"","sources":["../src/Location.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAsB,oBAAoB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEvF,OAAO,YAAY,MAAM,gBAAgB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CAAC,SAAS,YAAY,CAC1E,CAAC;SACH;QACD,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE;YACrC,MAAM,IAAI,SAAS,CAAC,0CAA0C,MAAM,CAAC,MAAM,YAAY,CAAC,CAAC;SAC1F;KACF;AACH,CAAC;AAED,cAAc;AACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,QAAgB,EAChB,UAA4B,EAAE;IAE9B,SAAS,CAAC,QAAQ,CAAC,CAAC;IACpB,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC1B,MAAM,YAAY,CAAC,oBAAoB,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AACjE,CAAC;AAED,cAAc;AACd;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,QAAgB;IACxD,SAAS,CAAC,QAAQ,CAAC,CAAC;IACpB,MAAM,YAAY,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AACnD,CAAC;AAED,cAAc;AACd;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,QAAgB;IAC9D,SAAS,CAAC,QAAQ,CAAC,CAAC;IACpB,OAAO,YAAY,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import { isRunningInExpoGo } from 'expo';\nimport { PermissionResponse, createPermissionHook, Platform } from 'expo-modules-core';\n\nimport ExpoLocation from './ExpoLocation';\nimport {\n LocationErrorCallback,\n LocationAccuracy,\n LocationCallback,\n LocationGeocodedAddress,\n LocationGeocodedLocation,\n LocationHeadingCallback,\n LocationHeadingObject,\n LocationLastKnownOptions,\n LocationObject,\n LocationOptions,\n LocationPermissionResponse,\n LocationProviderStatus,\n LocationRegion,\n LocationSubscription,\n LocationTaskOptions,\n} from './Location.types';\nimport {\n LocationSubscriber,\n HeadingSubscriber,\n LocationErrorSubscriber,\n} from './LocationSubscribers';\n\n// Flag for warning about background services not being available in Expo Go\nlet warnAboutExpoGoDisplayed = false;\n\n// @needsAudit\n/**\n * Check status of location providers.\n * @return A promise which fulfills with an object of type [`LocationProviderStatus`](#locationproviderstatus).\n */\nexport async function getProviderStatusAsync(): Promise<LocationProviderStatus> {\n return ExpoLocation.getProviderStatusAsync();\n}\n\n// @needsAudit\n/**\n * Asks the user to turn on high accuracy location mode which enables network provider that uses\n * Google Play services to improve location accuracy and location-based services.\n * @return A promise resolving as soon as the user accepts the dialog. Rejects if denied.\n *\n * @platform android\n */\nexport async function enableNetworkProviderAsync(): Promise<void> {\n // If network provider is disabled (user's location mode is set to \"Device only\"),\n // Android's location provider may not give you any results. Use this method in order to ask the user\n // to change the location mode to \"High accuracy\" which uses Google Play services and enables network provider.\n // `getCurrentPositionAsync` and `watchPositionAsync` are doing it automatically anyway.\n\n if (Platform.OS === 'android') {\n return ExpoLocation.enableNetworkProviderAsync();\n }\n}\n\n// @needsAudit\n/**\n * Requests for one-time delivery of the user's current location.\n * Depending on given `accuracy` option it may take some time to resolve,\n * especially when you're inside a building.\n * > __Note:__ Calling it causes the location manager to obtain a location fix which may take several\n * > seconds. Consider using [`getLastKnownPositionAsync`](#locationgetlastknownpositionasyncoptions)\n * > if you expect to get a quick response and high accuracy is not required.\n * @param options\n * @return A promise which fulfills with an object of type [`LocationObject`](#locationobject).\n */\nexport async function getCurrentPositionAsync(\n options: LocationOptions = {}\n): Promise<LocationObject> {\n return ExpoLocation.getCurrentPositionAsync(options);\n}\n\n// @needsAudit\n/**\n * Gets the last known position of the device or `null` if it's not available or doesn't match given\n * requirements such as maximum age or required accuracy.\n * It's considered to be faster than `getCurrentPositionAsync` as it doesn't request for the current\n * location, but keep in mind the returned location may not be up-to-date.\n * @param options\n * @return A promise which fulfills with an object of type [`LocationObject`](#locationobject) or\n * `null` if it's not available or doesn't match given requirements such as maximum age or required\n * accuracy.\n */\nexport async function getLastKnownPositionAsync(\n options: LocationLastKnownOptions = {}\n): Promise<LocationObject | null> {\n return ExpoLocation.getLastKnownPositionAsync(options);\n}\n\n// @needsAudit\n/**\n * Subscribe to location updates from the device. Please note that updates will only occur while the\n * application is in the foreground. To get location updates while in background you'll need to use\n * [`startLocationUpdatesAsync`](#locationstartlocationupdatesasynctaskname-options).\n * @param options\n * @param callback This function is called on each location update. It receives an object of type\n * [`LocationObject`](#locationobject) as the first argument.\n * @param errorHandler This function is called when an error occurs. It receives a string with the\n * error message as the first argument.\n * @return A promise which fulfills with a [`LocationSubscription`](#locationsubscription) object.\n */\nexport async function watchPositionAsync(\n options: LocationOptions,\n callback: LocationCallback,\n errorHandler?: LocationErrorCallback\n): Promise<LocationSubscription> {\n const watchId = LocationSubscriber.registerCallback(callback);\n errorHandler && LocationErrorSubscriber.registerCallbackForId(watchId, errorHandler);\n\n await ExpoLocation.watchPositionImplAsync(watchId, options);\n\n return {\n remove() {\n LocationSubscriber.unregisterCallback(watchId);\n errorHandler && LocationErrorSubscriber.unregisterCallback(watchId);\n },\n };\n}\n\n// @needsAudit\n/**\n * Gets the current heading information from the device. To simplify, it calls `watchHeadingAsync`\n * and waits for a couple of updates, and then returns the one that is accurate enough.\n * @return A promise which fulfills with an object of type [`LocationHeadingObject`](#locationheadingobject).\n */\nexport async function getHeadingAsync(): Promise<LocationHeadingObject> {\n return new Promise(async (resolve, reject) => {\n let tries = 0;\n let subscriber: LocationSubscription | undefined = undefined;\n\n try {\n subscriber = await watchHeadingAsync(\n (heading) => {\n if (heading.accuracy > 1 || tries > 5) {\n subscriber?.remove();\n resolve(heading);\n } else {\n tries += 1;\n }\n },\n (reason) => {\n subscriber?.remove();\n reject(reason);\n }\n );\n } catch (e) {\n reject(e);\n }\n });\n}\n\n// @needsAudit\n/**\n * Subscribe to compass updates from the device.\n *\n * @param callback This function is called on each compass update. It receives an object of type\n * [LocationHeadingObject](#locationheadingobject) as the first argument.\n * @param errorHandler This function is called when an error occurs. It receives a string with the\n * error message as the first argument.\n * @return A promise which fulfills with a [`LocationSubscription`](#locationsubscription) object.\n *\n * @platform android\n * @platform ios\n */\nexport async function watchHeadingAsync(\n callback: LocationHeadingCallback,\n errorHandler?: LocationErrorCallback\n): Promise<LocationSubscription> {\n const watchId = HeadingSubscriber.registerCallback(callback);\n errorHandler && LocationErrorSubscriber.registerCallbackForId(watchId, errorHandler);\n\n await ExpoLocation.watchDeviceHeading(watchId);\n\n return {\n remove() {\n HeadingSubscriber.unregisterCallback(watchId);\n errorHandler && LocationErrorSubscriber.unregisterCallback(watchId);\n },\n };\n}\n\n// @needsAudit\n/**\n * Geocode an address string to latitude-longitude location.\n *\n * On Android, you must request location permissions with [`requestForegroundPermissionsAsync`](#locationrequestforegroundpermissionsasync)\n * before geocoding can be used.\n *\n * > **Note**: Geocoding is resource consuming and has to be used reasonably. Creating too many\n * > requests at a time can result in an error, so they have to be managed properly.\n * > It's also discouraged to use geocoding while the app is in the background and its results won't\n * > be shown to the user immediately.\n *\n * @param address A string representing address, eg. `\"Baker Street London\"`.\n * @return A promise which fulfills with an array (in most cases its size is 1) of [`LocationGeocodedLocation`](#locationgeocodedlocation)\n * objects.\n *\n * @platform android\n * @platform ios\n */\nexport async function geocodeAsync(address: string): Promise<LocationGeocodedLocation[]> {\n if (typeof address !== 'string') {\n throw new TypeError(`Address to geocode must be a string. Got ${address} instead.`);\n }\n\n if (Platform.OS === 'web') {\n if (__DEV__) {\n console.warn(\n 'The Geocoding API has been removed in SDK 49, use Place Autocomplete service instead' +\n '(https://developers.google.com/maps/documentation/places/web-service/autocomplete)'\n );\n }\n return [];\n }\n\n return await ExpoLocation.geocodeAsync(address);\n}\n\n// @needsAudit\n/**\n * Reverse geocode a location to postal address.\n *\n * On Android, you must request location permissions with [`requestForegroundPermissionsAsync`](#locationrequestforegroundpermissionsasync)\n * before geocoding can be used.\n *\n * > **Note**: Geocoding is resource consuming and has to be used reasonably. Creating too many\n * > requests at a time can result in an error, so they have to be managed properly.\n * > It's also discouraged to use geocoding while the app is in the background and its results won't\n * > be shown to the user immediately.\n *\n * @param location An object representing a location.\n * @return A promise which fulfills with an array (in most cases its size is 1) of [`LocationGeocodedAddress`](#locationgeocodedaddress) objects.\n *\n * @platform android\n * @platform ios\n */\nexport async function reverseGeocodeAsync(\n location: Pick<LocationGeocodedLocation, 'latitude' | 'longitude'>\n): Promise<LocationGeocodedAddress[]> {\n if (typeof location.latitude !== 'number' || typeof location.longitude !== 'number') {\n throw new TypeError(\n 'Location to reverse-geocode must be an object with number properties `latitude` and `longitude`.'\n );\n }\n\n if (Platform.OS === 'web') {\n if (__DEV__) {\n console.warn(\n 'The Geocoding API has been removed in SDK 49, use Place Autocomplete service instead' +\n '(https://developers.google.com/maps/documentation/places/web-service/autocomplete)'\n );\n }\n return [];\n }\n\n return await ExpoLocation.reverseGeocodeAsync(location);\n}\n\n// @needsAudit\n/**\n * Checks user's permissions for accessing location while the app is in the foreground.\n * @return A promise that fulfills with an object of type [`LocationPermissionResponse`](#locationpermissionresponse).\n */\nexport async function getForegroundPermissionsAsync(): Promise<LocationPermissionResponse> {\n return await ExpoLocation.getForegroundPermissionsAsync();\n}\n\n// @needsAudit\n/**\n * Asks the user to grant permissions for location while the app is in the foreground.\n * @return A promise that fulfills with an object of type [`LocationPermissionResponse`](#locationpermissionresponse).\n */\nexport async function requestForegroundPermissionsAsync(): Promise<LocationPermissionResponse> {\n return await ExpoLocation.requestForegroundPermissionsAsync();\n}\n\n// @needsAudit\n/**\n * Check or request permissions for the foreground location.\n * This uses both `requestForegroundPermissionsAsync` and `getForegroundPermissionsAsync` to interact with the permissions.\n *\n * @example\n * ```ts\n * const [status, requestPermission] = Location.useForegroundPermissions();\n * ```\n */\nexport const useForegroundPermissions = createPermissionHook({\n getMethod: getForegroundPermissionsAsync,\n requestMethod: requestForegroundPermissionsAsync,\n});\n\n// @needsAudit\n/**\n * Checks user's permissions for accessing location while the app is in the background.\n * @return A promise that fulfills with an object of type [`PermissionResponse`](#permissionresponse).\n */\nexport async function getBackgroundPermissionsAsync(): Promise<PermissionResponse> {\n return await ExpoLocation.getBackgroundPermissionsAsync();\n}\n\n// @needsAudit\n/**\n * Asks the user to grant permissions for location while the app is in the background.\n * On __Android 11 or higher__: this method will open the system settings page - before that happens\n * you should explain to the user why your application needs background location permission.\n * For example, you can use `Modal` component from `react-native` to do that.\n * > __Note__: Foreground permissions should be granted before asking for the background permissions\n * (your app can't obtain background permission without foreground permission).\n * @return A promise that fulfills with an object of type [`PermissionResponse`](#permissionresponse).\n */\nexport async function requestBackgroundPermissionsAsync(): Promise<PermissionResponse> {\n return await ExpoLocation.requestBackgroundPermissionsAsync();\n}\n\n// @needsAudit\n/**\n * Check or request permissions for the background location.\n * This uses both `requestBackgroundPermissionsAsync` and `getBackgroundPermissionsAsync` to\n * interact with the permissions.\n *\n * @example\n * ```ts\n * const [status, requestPermission] = Location.useBackgroundPermissions();\n * ```\n */\nexport const useBackgroundPermissions = createPermissionHook({\n getMethod: getBackgroundPermissionsAsync,\n requestMethod: requestBackgroundPermissionsAsync,\n});\n\n// --- Location service\n\n// @needsAudit\n/**\n * Checks whether location services are enabled by the user.\n * @return A promise which fulfills to `true` if location services are enabled on the device,\n * or `false` if not.\n */\nexport async function hasServicesEnabledAsync(): Promise<boolean> {\n return await ExpoLocation.hasServicesEnabledAsync();\n}\n\n// --- Background location updates\n\nfunction _validate(taskName: string) {\n if (!taskName || typeof taskName !== 'string') {\n throw new Error(`\\`taskName\\` must be a non-empty string. Got ${taskName} instead.`);\n }\n if (isRunningInExpoGo()) {\n if (!warnAboutExpoGoDisplayed) {\n const message =\n 'Background location is limited in Expo Go:\\n' +\n 'On Android, it is not available at all.\\n' +\n 'On iOS, it works when running in the Simulator.\\n' +\n 'Please use a development build to avoid limitations. Learn more: https://expo.fyi/dev-client.';\n console.warn(message);\n warnAboutExpoGoDisplayed = true;\n }\n }\n}\n\n// @docsMissing\nexport async function isBackgroundLocationAvailableAsync(): Promise<boolean> {\n const providerStatus = await getProviderStatusAsync();\n return providerStatus.backgroundModeEnabled;\n}\n\n// @needsAudit\n/**\n * Registers for receiving location updates that can also come when the app is in the background.\n *\n * # Task parameters\n *\n * Background location task will be receiving following data:\n * - `locations` - An array of the new locations.\n *\n * @example\n * ```ts\n * import * as TaskManager from 'expo-task-manager';\n *\n * TaskManager.defineTask(YOUR_TASK_NAME, ({ data: { locations }, error }) => {\n * if (error) {\n * // check `error.message` for more details.\n * return;\n * }\n * console.log('Received new locations', locations);\n * });\n * ```\n *\n * @param taskName Name of the task receiving location updates.\n * @param options An object of options passed to the location manager.\n *\n * @return A promise resolving once the task with location updates is registered.\n */\nexport async function startLocationUpdatesAsync(\n taskName: string,\n options: LocationTaskOptions = { accuracy: LocationAccuracy.Balanced }\n): Promise<void> {\n _validate(taskName);\n await ExpoLocation.startLocationUpdatesAsync(taskName, options);\n}\n\n// @needsAudit\n/**\n * Stops location updates for specified task.\n * @param taskName Name of the background location task to stop.\n * @return A promise resolving as soon as the task is unregistered.\n */\nexport async function stopLocationUpdatesAsync(taskName: string): Promise<void> {\n _validate(taskName);\n await ExpoLocation.stopLocationUpdatesAsync(taskName);\n}\n\n// @needsAudit\n/**\n * @param taskName Name of the location task to check.\n * @return A promise which fulfills with boolean value indicating whether the location task is\n * started or not.\n */\nexport async function hasStartedLocationUpdatesAsync(taskName: string): Promise<boolean> {\n _validate(taskName);\n return ExpoLocation.hasStartedLocationUpdatesAsync(taskName);\n}\n\n// --- Geofencing\n\nfunction _validateRegions(regions: LocationRegion[]) {\n if (!regions || regions.length === 0) {\n throw new Error(\n 'Regions array cannot be empty. Use `stopGeofencingAsync` if you want to stop geofencing all regions'\n );\n }\n for (const region of regions) {\n if (typeof region.latitude !== 'number') {\n throw new TypeError(`Region's latitude must be a number. Got '${region.latitude}' instead.`);\n }\n if (typeof region.longitude !== 'number') {\n throw new TypeError(\n `Region's longitude must be a number. Got '${region.longitude}' instead.`\n );\n }\n if (typeof region.radius !== 'number') {\n throw new TypeError(`Region's radius must be a number. Got '${region.radius}' instead.`);\n }\n }\n}\n\n// @needsAudit\n/**\n * Starts geofencing for given regions. When the new event comes, the task with specified name will\n * be called with the region that the device enter to or exit from.\n * If you want to add or remove regions from already running geofencing task, you can just call\n * `startGeofencingAsync` again with the new array of regions.\n *\n * # Task parameters\n *\n * Geofencing task will be receiving following data:\n * - `eventType` - Indicates the reason for calling the task, which can be triggered by entering or exiting the region.\n * See [`GeofencingEventType`](#geofencingeventtype).\n * - `region` - Object containing details about updated region. See [`LocationRegion`](#locationregion) for more details.\n *\n * @param taskName Name of the task that will be called when the device enters or exits from specified regions.\n * @param regions Array of region objects to be geofenced.\n *\n * @return A promise resolving as soon as the task is registered.\n *\n * @example\n * ```ts\n * import { GeofencingEventType } from 'expo-location';\n * import * as TaskManager from 'expo-task-manager';\n *\n * TaskManager.defineTask(YOUR_TASK_NAME, ({ data: { eventType, region }, error }) => {\n * if (error) {\n * // check `error.message` for more details.\n * return;\n * }\n * if (eventType === GeofencingEventType.Enter) {\n * console.log(\"You've entered region:\", region);\n * } else if (eventType === GeofencingEventType.Exit) {\n * console.log(\"You've left region:\", region);\n * }\n * });\n * ```\n */\nexport async function startGeofencingAsync(\n taskName: string,\n regions: LocationRegion[] = []\n): Promise<void> {\n _validate(taskName);\n _validateRegions(regions);\n await ExpoLocation.startGeofencingAsync(taskName, { regions });\n}\n\n// @needsAudit\n/**\n * Stops geofencing for specified task. It unregisters the background task so the app will not be\n * receiving any updates, especially in the background.\n * @param taskName Name of the task to unregister.\n * @return A promise resolving as soon as the task is unregistered.\n */\nexport async function stopGeofencingAsync(taskName: string): Promise<void> {\n _validate(taskName);\n await ExpoLocation.stopGeofencingAsync(taskName);\n}\n\n// @needsAudit\n/**\n * @param taskName Name of the geofencing task to check.\n * @return A promise which fulfills with boolean value indicating whether the geofencing task is\n * started or not.\n */\nexport async function hasStartedGeofencingAsync(taskName: string): Promise<boolean> {\n _validate(taskName);\n return ExpoLocation.hasStartedGeofencingAsync(taskName);\n}\n"]}
|
|
1
|
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,CAAC,CAAC;IACpB,OAAO,YAAY,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import { isRunningInExpoGo } from 'expo';\nimport { PermissionResponse, createPermissionHook, Platform } from 'expo-modules-core';\n\nimport ExpoLocation from './ExpoLocation';\nimport {\n LocationErrorCallback,\n LocationAccuracy,\n LocationCallback,\n LocationGeocodedAddress,\n LocationGeocodedLocation,\n LocationHeadingCallback,\n LocationHeadingObject,\n LocationLastKnownOptions,\n LocationObject,\n LocationOptions,\n LocationPermissionResponse,\n LocationProviderStatus,\n LocationRegion,\n LocationSubscription,\n LocationTaskOptions,\n} from './Location.types';\nimport {\n LocationSubscriber,\n HeadingSubscriber,\n LocationErrorSubscriber,\n} from './LocationSubscribers';\n\n// Flag for warning about background services not being available in Expo Go\nlet warnAboutExpoGoDisplayed = false;\n\n// @needsAudit\n/**\n * Check status of location providers.\n * @return A promise which fulfills with an object of type [`LocationProviderStatus`](#locationproviderstatus).\n */\nexport async function getProviderStatusAsync(): Promise<LocationProviderStatus> {\n return ExpoLocation.getProviderStatusAsync();\n}\n\n// @needsAudit\n/**\n * Asks the user to turn on high accuracy location mode which enables network provider that uses\n * Google Play services to improve location accuracy and location-based services.\n * @return A promise resolving as soon as the user accepts the dialog. Rejects if denied.\n *\n * @platform android\n */\nexport async function enableNetworkProviderAsync(): Promise<void> {\n // If network provider is disabled (user's location mode is set to \"Device only\"),\n // Android's location provider may not give you any results. Use this method in order to ask the user\n // to change the location mode to \"High accuracy\" which uses Google Play services and enables network provider.\n // `getCurrentPositionAsync` and `watchPositionAsync` are doing it automatically anyway.\n\n if (Platform.OS === 'android') {\n return ExpoLocation.enableNetworkProviderAsync();\n }\n}\n\n// @needsAudit\n/**\n * Requests for one-time delivery of the user's current location.\n * Depending on given `accuracy` option it may take some time to resolve,\n * especially when you're inside a building.\n * > __Note:__ Calling it causes the location manager to obtain a location fix which may take several\n * > seconds. Consider using [`getLastKnownPositionAsync`](#locationgetlastknownpositionasyncoptions)\n * > if you expect to get a quick response and high accuracy is not required.\n * @param options\n * @return A promise which fulfills with an object of type [`LocationObject`](#locationobject).\n */\nexport async function getCurrentPositionAsync(\n options: LocationOptions = {}\n): Promise<LocationObject> {\n return ExpoLocation.getCurrentPositionAsync(options);\n}\n\n// @needsAudit\n/**\n * Gets the last known position of the device or `null` if it's not available or doesn't match given\n * requirements such as maximum age or required accuracy.\n * It's considered to be faster than `getCurrentPositionAsync` as it doesn't request for the current\n * location, but keep in mind the returned location may not be up-to-date.\n * @param options\n * @return A promise which fulfills with an object of type [`LocationObject`](#locationobject) or\n * `null` if it's not available or doesn't match given requirements such as maximum age or required\n * accuracy.\n */\nexport async function getLastKnownPositionAsync(\n options: LocationLastKnownOptions = {}\n): Promise<LocationObject | null> {\n return ExpoLocation.getLastKnownPositionAsync(options);\n}\n\n// @needsAudit\n/**\n * Subscribe to location updates from the device. Please note that updates will only occur while the\n * application is in the foreground. To get location updates while in background you'll need to use\n * [`startLocationUpdatesAsync`](#locationstartlocationupdatesasynctaskname-options).\n * @param options\n * @param callback This function is called on each location update. It receives an object of type\n * [`LocationObject`](#locationobject) as the first argument.\n * @param errorHandler This function is called when an error occurs. It receives a string with the\n * error message as the first argument.\n * @return A promise which fulfills with a [`LocationSubscription`](#locationsubscription) object.\n */\nexport async function watchPositionAsync(\n options: LocationOptions,\n callback: LocationCallback,\n errorHandler?: LocationErrorCallback\n): Promise<LocationSubscription> {\n const watchId = LocationSubscriber.registerCallback(callback);\n errorHandler && LocationErrorSubscriber.registerCallbackForId(watchId, errorHandler);\n\n await ExpoLocation.watchPositionImplAsync(watchId, options);\n\n return {\n remove() {\n LocationSubscriber.unregisterCallback(watchId);\n errorHandler && LocationErrorSubscriber.unregisterCallback(watchId);\n },\n };\n}\n\n// @needsAudit\n/**\n * Gets the current heading information from the device. To simplify, it calls `watchHeadingAsync`\n * and waits for a couple of updates, and then returns the one that is accurate enough.\n * @return A promise which fulfills with an object of type [`LocationHeadingObject`](#locationheadingobject).\n */\nexport async function getHeadingAsync(): Promise<LocationHeadingObject> {\n return new Promise(async (resolve, reject) => {\n let tries = 0;\n let subscriber: LocationSubscription | undefined = undefined;\n\n try {\n subscriber = await watchHeadingAsync(\n (heading) => {\n if (heading.accuracy > 1 || tries > 5) {\n subscriber?.remove();\n resolve(heading);\n } else {\n tries += 1;\n }\n },\n (reason) => {\n subscriber?.remove();\n reject(reason);\n }\n );\n } catch (e) {\n reject(e);\n }\n });\n}\n\n// @needsAudit\n/**\n * Subscribe to compass updates from the device.\n *\n * @param callback This function is called on each compass update. It receives an object of type\n * [LocationHeadingObject](#locationheadingobject) as the first argument.\n * @param errorHandler This function is called when an error occurs. It receives a string with the\n * error message as the first argument.\n * @return A promise which fulfills with a [`LocationSubscription`](#locationsubscription) object.\n *\n * @platform android\n * @platform ios\n */\nexport async function watchHeadingAsync(\n callback: LocationHeadingCallback,\n errorHandler?: LocationErrorCallback\n): Promise<LocationSubscription> {\n const watchId = HeadingSubscriber.registerCallback(callback);\n errorHandler && LocationErrorSubscriber.registerCallbackForId(watchId, errorHandler);\n\n await ExpoLocation.watchDeviceHeading(watchId);\n\n return {\n remove() {\n HeadingSubscriber.unregisterCallback(watchId);\n errorHandler && LocationErrorSubscriber.unregisterCallback(watchId);\n },\n };\n}\n\n// @needsAudit\n/**\n * Geocode an address string to latitude-longitude location.\n *\n * On Android, you must request location permissions with [`requestForegroundPermissionsAsync`](#locationrequestforegroundpermissionsasync)\n * before geocoding can be used.\n *\n * > **Note**: Geocoding is resource consuming and has to be used reasonably. Creating too many\n * > requests at a time can result in an error, so they have to be managed properly.\n * > It's also discouraged to use geocoding while the app is in the background and its results won't\n * > be shown to the user immediately.\n *\n * @param address A string representing address, eg. `\"Baker Street London\"`.\n * @return A promise which fulfills with an array (in most cases its size is 1) of [`LocationGeocodedLocation`](#locationgeocodedlocation)\n * objects.\n *\n * @platform android\n * @platform ios\n */\nexport async function geocodeAsync(address: string): Promise<LocationGeocodedLocation[]> {\n if (typeof address !== 'string') {\n throw new TypeError(`Address to geocode must be a string. Got ${address} instead.`);\n }\n\n if (Platform.OS === 'web') {\n if (__DEV__) {\n console.warn(\n 'The Geocoding API has been removed in SDK 49, use Place Autocomplete service instead' +\n '(https://developers.google.com/maps/documentation/places/web-service/autocomplete)'\n );\n }\n return [];\n }\n\n return await ExpoLocation.geocodeAsync(address);\n}\n\n// @needsAudit\n/**\n * Reverse geocode a location to postal address.\n *\n * On Android, you must request location permissions with [`requestForegroundPermissionsAsync`](#locationrequestforegroundpermissionsasync)\n * before geocoding can be used.\n *\n * > **Note**: Geocoding is resource consuming and has to be used reasonably. Creating too many\n * > requests at a time can result in an error, so they have to be managed properly.\n * > It's also discouraged to use geocoding while the app is in the background and its results won't\n * > be shown to the user immediately.\n *\n * @param location An object representing a location.\n * @return A promise which fulfills with an array (in most cases its size is 1) of [`LocationGeocodedAddress`](#locationgeocodedaddress) objects.\n *\n * @platform android\n * @platform ios\n */\nexport async function reverseGeocodeAsync(\n location: Pick<LocationGeocodedLocation, 'latitude' | 'longitude'>\n): Promise<LocationGeocodedAddress[]> {\n if (typeof location.latitude !== 'number' || typeof location.longitude !== 'number') {\n throw new TypeError(\n 'Location to reverse-geocode must be an object with number properties `latitude` and `longitude`.'\n );\n }\n\n if (Platform.OS === 'web') {\n if (__DEV__) {\n console.warn(\n 'The Geocoding API has been removed in SDK 49, use Place Autocomplete service instead' +\n '(https://developers.google.com/maps/documentation/places/web-service/autocomplete)'\n );\n }\n return [];\n }\n\n return await ExpoLocation.reverseGeocodeAsync(location);\n}\n\n// @needsAudit\n/**\n * Checks user's permissions for accessing location while the app is in the foreground.\n * @return A promise that fulfills with an object of type [`LocationPermissionResponse`](#locationpermissionresponse).\n */\nexport async function getForegroundPermissionsAsync(): Promise<LocationPermissionResponse> {\n return await ExpoLocation.getForegroundPermissionsAsync();\n}\n\n// @needsAudit\n/**\n * Asks the user to grant permissions for location while the app is in the foreground.\n * @return A promise that fulfills with an object of type [`LocationPermissionResponse`](#locationpermissionresponse).\n */\nexport async function requestForegroundPermissionsAsync(): Promise<LocationPermissionResponse> {\n return await ExpoLocation.requestForegroundPermissionsAsync();\n}\n\n// @needsAudit\n/**\n * Check or request permissions for the foreground location.\n * This uses both `requestForegroundPermissionsAsync` and `getForegroundPermissionsAsync` to interact with the permissions.\n *\n * @example\n * ```ts\n * const [status, requestPermission] = Location.useForegroundPermissions();\n * ```\n */\nexport const useForegroundPermissions = createPermissionHook({\n getMethod: getForegroundPermissionsAsync,\n requestMethod: requestForegroundPermissionsAsync,\n});\n\n// @needsAudit\n/**\n * Checks user's permissions for accessing location while the app is in the background.\n * @return A promise that fulfills with an object of type [`PermissionResponse`](#permissionresponse).\n */\nexport async function getBackgroundPermissionsAsync(): Promise<PermissionResponse> {\n return await ExpoLocation.getBackgroundPermissionsAsync();\n}\n\n// @needsAudit\n/**\n * Asks the user to grant permissions for location while the app is in the background.\n * On __Android 11 or higher__: this method will open the system settings page - before that happens\n * you should explain to the user why your application needs background location permission.\n * For example, you can use `Modal` component from `react-native` to do that.\n * > __Note__: Foreground permissions should be granted before asking for the background permissions\n * (your app can't obtain background permission without foreground permission).\n * @return A promise that fulfills with an object of type [`PermissionResponse`](#permissionresponse).\n */\nexport async function requestBackgroundPermissionsAsync(): Promise<PermissionResponse> {\n return await ExpoLocation.requestBackgroundPermissionsAsync();\n}\n\n// @needsAudit\n/**\n * Check or request permissions for the background location.\n * This uses both `requestBackgroundPermissionsAsync` and `getBackgroundPermissionsAsync` to\n * interact with the permissions.\n *\n * @example\n * ```ts\n * const [status, requestPermission] = Location.useBackgroundPermissions();\n * ```\n */\nexport const useBackgroundPermissions = createPermissionHook({\n getMethod: getBackgroundPermissionsAsync,\n requestMethod: requestBackgroundPermissionsAsync,\n});\n\n// --- Location service\n\n// @needsAudit\n/**\n * Checks whether location services are enabled by the user.\n * @return A promise which fulfills to `true` if location services are enabled on the device,\n * or `false` if not.\n */\nexport async function hasServicesEnabledAsync(): Promise<boolean> {\n return await ExpoLocation.hasServicesEnabledAsync();\n}\n\n// --- Background location updates\n\nfunction _validate(taskName: string) {\n if (!taskName || typeof taskName !== 'string') {\n throw new Error(`\\`taskName\\` must be a non-empty string. Got ${taskName} instead.`);\n }\n if (isRunningInExpoGo()) {\n if (!warnAboutExpoGoDisplayed) {\n const message =\n 'Background location is limited in Expo Go:\\n' +\n 'On Android, it is not available at all.\\n' +\n 'On iOS, it works when running in the Simulator.\\n' +\n 'Please use a development build to avoid limitations. Learn more: https://expo.fyi/dev-client.';\n console.warn(message);\n warnAboutExpoGoDisplayed = true;\n }\n }\n}\n\n// @docsMissing\nexport async function isBackgroundLocationAvailableAsync(): Promise<boolean> {\n const providerStatus = await getProviderStatusAsync();\n return providerStatus.backgroundModeEnabled;\n}\n\n// @needsAudit\n/**\n * Registers for receiving location updates that can also come when the app is in the background.\n *\n * # Task parameters\n *\n * Background location task will be receiving following data:\n * - `locations` - An array of the new locations.\n *\n * @example\n * ```ts\n * import * as TaskManager from 'expo-task-manager';\n *\n * TaskManager.defineTask(YOUR_TASK_NAME, ({ data: { locations }, error }) => {\n * if (error) {\n * // check `error.message` for more details.\n * return;\n * }\n * console.log('Received new locations', locations);\n * });\n * ```\n *\n * @param taskName Name of the task receiving location updates.\n * @param options An object of options passed to the location manager.\n *\n * @return A promise resolving once the task with location updates is registered.\n */\nexport async function startLocationUpdatesAsync(\n taskName: string,\n options: LocationTaskOptions = { accuracy: LocationAccuracy.Balanced }\n): Promise<void> {\n _validate(taskName);\n await ExpoLocation.startLocationUpdatesAsync(taskName, options);\n}\n\n// @needsAudit\n/**\n * Stops location updates for specified task.\n * @param taskName Name of the background location task to stop.\n * @return A promise resolving as soon as the task is unregistered.\n */\nexport async function stopLocationUpdatesAsync(taskName: string): Promise<void> {\n _validate(taskName);\n await ExpoLocation.stopLocationUpdatesAsync(taskName);\n}\n\n// @needsAudit\n/**\n * @param taskName Name of the location task to check.\n * @return A promise which fulfills with boolean value indicating whether the location task is\n * started or not.\n */\nexport async function hasStartedLocationUpdatesAsync(taskName: string): Promise<boolean> {\n _validate(taskName);\n return ExpoLocation.hasStartedLocationUpdatesAsync(taskName);\n}\n\n// --- Geofencing\n\nfunction _validateRegions(regions: LocationRegion[]) {\n if (!regions || regions.length === 0) {\n throw new Error(\n 'Regions array cannot be empty. Use `stopGeofencingAsync` if you want to stop geofencing all regions'\n );\n }\n for (const region of regions) {\n if (typeof region.latitude !== 'number') {\n throw new TypeError(`Region's latitude must be a number. Got '${region.latitude}' instead.`);\n }\n if (typeof region.longitude !== 'number') {\n throw new TypeError(\n `Region's longitude must be a number. Got '${region.longitude}' instead.`\n );\n }\n if (typeof region.radius !== 'number') {\n throw new TypeError(`Region's radius must be a number. Got '${region.radius}' instead.`);\n }\n }\n}\n\n// @needsAudit\n/**\n * Starts geofencing for given regions. When the new event comes, the task with specified name will\n * be called with the region that the device enter to or exit from.\n * If you want to add or remove regions from already running geofencing task, you can just call\n * `startGeofencingAsync` again with the new array of regions.\n *\n * # Task parameters\n *\n * Geofencing task will be receiving following data:\n * - `eventType` - Indicates the reason for calling the task, which can be triggered by entering or exiting the region.\n * See [`GeofencingEventType`](#geofencingeventtype).\n * - `region` - Object containing details about updated region. See [`LocationRegion`](#locationregion) for more details.\n *\n * @param taskName Name of the task that will be called when the device enters or exits from specified regions.\n * @param regions Array of region objects to be geofenced.\n *\n * @return A promise resolving as soon as the task is registered.\n *\n * @example\n * ```ts\n * import { GeofencingEventType } from 'expo-location';\n * import * as TaskManager from 'expo-task-manager';\n *\n * TaskManager.defineTask(YOUR_TASK_NAME, ({ data: { eventType, region }, error }) => {\n * if (error) {\n * // check `error.message` for more details.\n * return;\n * }\n * if (eventType === GeofencingEventType.Enter) {\n * console.log(\"You've entered region:\", region);\n * } else if (eventType === GeofencingEventType.Exit) {\n * console.log(\"You've left region:\", region);\n * }\n * });\n * ```\n */\nexport async function startGeofencingAsync(\n taskName: string,\n regions: LocationRegion[] = []\n): Promise<void> {\n _validate(taskName);\n _validateRegions(regions);\n await ExpoLocation.startGeofencingAsync(taskName, { regions });\n}\n\n// @needsAudit\n/**\n * Stops geofencing for specified task. It unregisters the background task so the app will not be\n * receiving any updates, especially in the background.\n * @param taskName Name of the task to unregister.\n * @return A promise resolving as soon as the task is unregistered.\n */\nexport async function stopGeofencingAsync(taskName: string): Promise<void> {\n _validate(taskName);\n await ExpoLocation.stopGeofencingAsync(taskName);\n}\n\n// @needsAudit\n/**\n * @param taskName Name of the geofencing task to check.\n * @return A promise which fulfills with boolean value indicating whether the geofencing task is\n * started or not.\n */\nexport async function hasStartedGeofencingAsync(taskName: string): Promise<boolean> {\n _validate(taskName);\n return ExpoLocation.hasStartedGeofencingAsync(taskName);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocationSubscribers.js","sourceRoot":"","sources":["../src/LocationSubscribers.ts"],"names":[],"mappings":"AAEA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAO9D,IAAI,WAAW,GAAG,CAAC,CAAC;AAEpB,MAAM,UAAU;IAGN,SAAS,CAAS;IAClB,cAAc,CAAS;IACvB,SAAS,GAAmC,EAAE,CAAC;IAC/C,iBAAiB,GAA6B,IAAI,CAAC;IAE3D,YAAY,SAAiB,EAAE,cAAsB;QACnD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED,2BAA2B;QACzB,IAAI,IAAI,CAAC,iBAAiB,EAAE;
|
|
1
|
+
{"version":3,"file":"LocationSubscribers.js","sourceRoot":"","sources":["../src/LocationSubscribers.ts"],"names":[],"mappings":"AAEA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAO9D,IAAI,WAAW,GAAG,CAAC,CAAC;AAEpB,MAAM,UAAU;IAGN,SAAS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AAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACvE,oBAAoB,CAAC,kBAAkB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAChE,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAChC,CAAC;IACH,CAAC;IAED,OAAO,CAAC,KAAkB;QACxB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAEzC,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;QACvC,CAAC;aAAM,CAAC;YACN,YAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,UAAU,CAC9C,sBAAsB,EACtB,UAAU,CACX,CAAC;AACF,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,UAAU,CAC7C,qBAAqB,EACrB,SAAS,CACV,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,UAAU,CACnD,oBAAoB,EACpB,QAAQ,CACT,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { type EventSubscription } from 'expo-modules-core';\n\nimport ExpoLocation from './ExpoLocation';\nimport { LocationCallback, LocationErrorCallback, LocationHeadingCallback } from './Location.types';\nimport { LocationEventEmitter } from './LocationEventEmitter';\n\ntype EventObject = {\n watchId: number;\n [key: string]: any;\n};\n\nlet nextWatchId = 0;\n\nclass Subscriber<\n CallbackType extends LocationCallback | LocationHeadingCallback | LocationErrorCallback,\n> {\n private eventName: string;\n private eventDataField: string;\n private callbacks: { [id: string]: CallbackType } = {};\n private eventSubscription: EventSubscription | null = null;\n\n constructor(eventName: string, eventDataField: string) {\n this.eventName = eventName;\n this.eventDataField = eventDataField;\n }\n\n maybeInitializeSubscription() {\n if (this.eventSubscription) {\n return;\n }\n this.eventSubscription = LocationEventEmitter.addListener(\n this.eventName,\n (event: EventObject) => this.trigger(event)\n );\n }\n\n /**\n * Registers given callback under new id which is then returned.\n */\n registerCallback(callback: CallbackType): number {\n this.maybeInitializeSubscription();\n const id = ++nextWatchId;\n this.callbacks[id] = callback;\n return id;\n }\n\n /**\n * Registers given callback under and existing id. This can be used to\n * create a subscriber for the error event on the same id as the location\n * event is subscribed to.\n */\n registerCallbackForId(watchId: number, callback: CallbackType): number {\n this.maybeInitializeSubscription();\n const id = watchId;\n this.callbacks[id] = callback;\n return id;\n }\n\n /**\n * Unregisters a callback with given id and revokes the subscription if possible.\n */\n unregisterCallback(id: number): void {\n // Do nothing if we have already unregistered the callback.\n if (!this.callbacks[id]) {\n return;\n }\n\n delete this.callbacks[id];\n ExpoLocation.removeWatchAsync(id);\n\n if (Object.keys(this.callbacks).length === 0 && this.eventSubscription) {\n LocationEventEmitter.removeSubscription(this.eventSubscription);\n this.eventSubscription = null;\n }\n }\n\n trigger(event: EventObject): void {\n const watchId = event.watchId;\n const callback = this.callbacks[watchId];\n\n if (callback) {\n callback(event[this.eventDataField]);\n } else {\n ExpoLocation.removeWatchAsync(watchId);\n }\n }\n}\n\nexport const LocationSubscriber = new Subscriber<LocationCallback>(\n 'Expo.locationChanged',\n 'location'\n);\nexport const HeadingSubscriber = new Subscriber<LocationHeadingCallback>(\n 'Expo.headingChanged',\n 'heading'\n);\n\nexport const LocationErrorSubscriber = new Subscriber<LocationErrorCallback>(\n 'Expo.locationError',\n 'reason'\n);\n\n/**\n * @private Necessary for some unit tests.\n */\nexport function _getCurrentWatchId(): number {\n return nextWatchId;\n}\n"]}
|
package/expo-module.config.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"component": {
|
|
4
4
|
"group": "host.exp.exponent",
|
|
5
5
|
"module": "expo.modules.location",
|
|
6
|
-
"version": "18.1.
|
|
6
|
+
"version": "18.1.2",
|
|
7
7
|
"attributes": {
|
|
8
8
|
"org.gradle.status": "release"
|
|
9
9
|
}
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
],
|
|
34
34
|
"files": [
|
|
35
35
|
{
|
|
36
|
-
"name": "expo.modules.location-18.1.
|
|
37
|
-
"url": "expo.modules.location-18.1.
|
|
36
|
+
"name": "expo.modules.location-18.1.2.aar",
|
|
37
|
+
"url": "expo.modules.location-18.1.2.aar",
|
|
38
38
|
"size": 184741,
|
|
39
39
|
"sha512": "9d46ba015b36cdb45893d41d39621afaae41598e4823ff3586f60417717930e93d3becddbbd502504546551cdb9a8424a1c595e63a7dc19479b79679de39c2b2",
|
|
40
40
|
"sha256": "1aea5a6b3fd289628062582aad3e511c3dded4b9e1698be4dabea6f8f8dee952",
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
],
|
|
77
77
|
"files": [
|
|
78
78
|
{
|
|
79
|
-
"name": "expo.modules.location-18.1.
|
|
80
|
-
"url": "expo.modules.location-18.1.
|
|
79
|
+
"name": "expo.modules.location-18.1.2.aar",
|
|
80
|
+
"url": "expo.modules.location-18.1.2.aar",
|
|
81
81
|
"size": 184741,
|
|
82
82
|
"sha512": "9d46ba015b36cdb45893d41d39621afaae41598e4823ff3586f60417717930e93d3becddbbd502504546551cdb9a8424a1c595e63a7dc19479b79679de39c2b2",
|
|
83
83
|
"sha256": "1aea5a6b3fd289628062582aad3e511c3dded4b9e1698be4dabea6f8f8dee952",
|
|
@@ -96,8 +96,8 @@
|
|
|
96
96
|
},
|
|
97
97
|
"files": [
|
|
98
98
|
{
|
|
99
|
-
"name": "expo.modules.location-18.1.
|
|
100
|
-
"url": "expo.modules.location-18.1.
|
|
99
|
+
"name": "expo.modules.location-18.1.2-sources.jar",
|
|
100
|
+
"url": "expo.modules.location-18.1.2-sources.jar",
|
|
101
101
|
"size": 22886,
|
|
102
102
|
"sha512": "68920c75933565fda76d75b67d44945458385ade303118b7942cf8e07ad741a25dafc44fa2a5046aaa04f6be46a13ef14d80ac131aedd115061b5ac7c863dc94",
|
|
103
103
|
"sha256": "d30c5c5e8e013d7356095a0ba9b19939ede75235295cac9193aa27a7601f2d8a",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
912312055de86ab734c40015ade505e4
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
c8a8473a9f7720e563dd8ed5c33e5db2cf274bc9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
67d6b6856b4b79654a49432a2182319804f1a5088c6f2c871a009a4276e4fbeb
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
14a0fbac615d008b89b8745fc04013e10eddf2fac52363c0a892e801fc90005077d61e6a044d0fd38d9b0b4f5be7a50e9cf2a1855de5968ba36c06935079d921
|
|
@@ -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>18.1.
|
|
12
|
+
<version>18.1.2</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
|
+
cedc5e2ab4ff2586edfba93fb98be365
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
78d9660f7057af07395eccc3bd83b3cfaf2c5ca0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
61fef3aaf0ad66370c02f268e6ca8881e01a26f7e45523c5a4cf5faab8bff30e
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
744be940404551ec030fde25f35bb1f76e4912cf3e17ab67a8306b68458934d9296924113bacad98e063ac748d6bf1aa73eab04870968804e8c9edb81eb558fc
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
<groupId>host.exp.exponent</groupId>
|
|
4
4
|
<artifactId>expo.modules.location</artifactId>
|
|
5
5
|
<versioning>
|
|
6
|
-
<latest>18.1.
|
|
7
|
-
<release>18.1.
|
|
6
|
+
<latest>18.1.2</latest>
|
|
7
|
+
<release>18.1.2</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>18.1.
|
|
9
|
+
<version>18.1.2</version>
|
|
10
10
|
</versions>
|
|
11
|
-
<lastUpdated>
|
|
11
|
+
<lastUpdated>20250414184121</lastUpdated>
|
|
12
12
|
</versioning>
|
|
13
13
|
</metadata>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
8ad442c0110bd2d22ea8e85e521f611a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
f5c24c72cb3ed9c0586a7569b26e2085c88c49a9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
d12b3cf85255241bd8fff1866165b02a198f4769a34972639a0e1c151d1fec19
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
9528b5ef26199f066d1a538dee3a8d9b87b8a7052814f6a8082faa6659f952383ff2a58456d8838142078377f98fc524901d8eb411dab464e47b75b31cd2a31c
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-location",
|
|
3
|
-
"version": "18.1.
|
|
3
|
+
"version": "18.1.2",
|
|
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
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -39,9 +39,10 @@
|
|
|
39
39
|
"preset": "expo-module-scripts"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"expo-module-scripts": "4.1.
|
|
42
|
+
"expo-module-scripts": "^4.1.2"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"expo": "
|
|
46
|
-
}
|
|
45
|
+
"expo": "*"
|
|
46
|
+
},
|
|
47
|
+
"gitHead": "335e9312f5caf634097354a230f0d4bbbfb9b0ba"
|
|
47
48
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ConfigPlugin } from 'expo/config-plugins';
|
|
2
2
|
declare const _default: ConfigPlugin<void | {
|
|
3
|
-
locationAlwaysAndWhenInUsePermission?: string | false
|
|
4
|
-
locationAlwaysPermission?: string | false
|
|
5
|
-
locationWhenInUsePermission?: string | false
|
|
6
|
-
isIosBackgroundLocationEnabled?: boolean
|
|
7
|
-
isAndroidBackgroundLocationEnabled?: boolean
|
|
8
|
-
isAndroidForegroundServiceEnabled?: boolean
|
|
3
|
+
locationAlwaysAndWhenInUsePermission?: string | false;
|
|
4
|
+
locationAlwaysPermission?: string | false;
|
|
5
|
+
locationWhenInUsePermission?: string | false;
|
|
6
|
+
isIosBackgroundLocationEnabled?: boolean;
|
|
7
|
+
isAndroidBackgroundLocationEnabled?: boolean;
|
|
8
|
+
isAndroidForegroundServiceEnabled?: boolean;
|
|
9
9
|
}>;
|
|
10
10
|
export default _default;
|
package/src/ExpoLocation.web.ts
CHANGED
|
@@ -139,7 +139,7 @@ export default {
|
|
|
139
139
|
},
|
|
140
140
|
async getCurrentPositionAsync(options: LocationOptions): Promise<LocationObject> {
|
|
141
141
|
return new Promise<LocationObject>((resolve, reject) => {
|
|
142
|
-
const resolver = (position) => {
|
|
142
|
+
const resolver: PositionCallback = (position) => {
|
|
143
143
|
lastKnownPosition = geolocationPositionToJSON(position);
|
|
144
144
|
resolve(lastKnownPosition);
|
|
145
145
|
};
|
|
@@ -150,10 +150,10 @@ export default {
|
|
|
150
150
|
});
|
|
151
151
|
});
|
|
152
152
|
},
|
|
153
|
-
async removeWatchAsync(watchId): Promise<void> {
|
|
153
|
+
async removeWatchAsync(watchId: number): Promise<void> {
|
|
154
154
|
navigator.geolocation.clearWatch(watchId);
|
|
155
155
|
},
|
|
156
|
-
async watchDeviceHeading(
|
|
156
|
+
async watchDeviceHeading(_headingId: number): Promise<void> {
|
|
157
157
|
console.warn('Location.watchDeviceHeading: is not supported on web');
|
|
158
158
|
},
|
|
159
159
|
async hasServicesEnabledAsync(): Promise<boolean> {
|
|
@@ -165,10 +165,9 @@ export default {
|
|
|
165
165
|
async reverseGeocodeAsync(): Promise<any[]> {
|
|
166
166
|
throw new GeocoderError();
|
|
167
167
|
},
|
|
168
|
-
async watchPositionImplAsync(watchId:
|
|
169
|
-
return new Promise
|
|
170
|
-
|
|
171
|
-
watchId = global.navigator.geolocation.watchPosition(
|
|
168
|
+
async watchPositionImplAsync(watchId: number, options: PositionOptions): Promise<number> {
|
|
169
|
+
return new Promise((resolve) => {
|
|
170
|
+
watchId = navigator.geolocation.watchPosition(
|
|
172
171
|
(position) => {
|
|
173
172
|
lastKnownPosition = geolocationPositionToJSON(position);
|
|
174
173
|
LocationEventEmitter.emit('Expo.locationChanged', {
|
|
@@ -74,7 +74,7 @@ function watchPosition(
|
|
|
74
74
|
) {
|
|
75
75
|
const watchId = LocationSubscriber.registerCallback(success);
|
|
76
76
|
|
|
77
|
-
ExpoLocation.watchPositionImplAsync(watchId, options).catch((err) => {
|
|
77
|
+
ExpoLocation.watchPositionImplAsync(watchId, options).catch((err: any) => {
|
|
78
78
|
LocationSubscriber.unregisterCallback(watchId);
|
|
79
79
|
error({ watchId, message: err.message, code: err.code });
|
|
80
80
|
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2fd9e06b9cb6132ccab67e51178ba29e
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
e00b239db32df2b49645e66e5ea2ceaf94566676
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3bf8082902685eb27da84a7725bde2ea78b3576d085d9a113a6fb9ea7764d9cf
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1d7f18fc0cae52ac043a09e4876ceca2d1e8ebec32f3980b382f817ed864f4c77fdc7bd72c2ce2bc164d453cb0606390e340ea7803c93b33475e2595d17087ba
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
74be4abaeab6dfdd4289434ed49b7113
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
ed2eeb7a65fd702f9ee7bfc08bcb6434e2ae379e
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
5494f1f41254c78e79acc9df06cf91370c037cb06b4999e1ba40dc6ecc49c36e
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
7aa1e0775b09c2ee6c368c069212118b3a8f879fdabcd6bc25d0e59d3012b07531666299bb3d3c6ee446a6c86270350a2852a2c7857fc955bcc6125269321be5
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|