This commit is contained in:
Yamozha
2021-04-02 02:24:13 +03:00
parent c23950b545
commit 7256d79e2c
31493 changed files with 3036630 additions and 0 deletions

2
node_modules/expo-location/build/ExpoLocation.d.ts generated vendored Normal file
View File

@ -0,0 +1,2 @@
declare const _default: import("@unimodules/core").ProxyNativeModule;
export default _default;

3
node_modules/expo-location/build/ExpoLocation.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
import { NativeModulesProxy } from '@unimodules/core';
export default NativeModulesProxy.ExpoLocation;
//# sourceMappingURL=ExpoLocation.js.map

1
node_modules/expo-location/build/ExpoLocation.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"ExpoLocation.js","sourceRoot":"","sources":["../src/ExpoLocation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,eAAe,kBAAkB,CAAC,YAAY,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\nexport default NativeModulesProxy.ExpoLocation;\n"]}

26
node_modules/expo-location/build/ExpoLocation.web.d.ts generated vendored Normal file
View File

@ -0,0 +1,26 @@
import { PermissionResponse } from 'unimodules-permissions-interface';
import { LocationLastKnownOptions, LocationObject, LocationOptions } from './Location.types';
/**
* Gets the permission details. The implementation is not very good as it actually requests
* for the current location, but there is no better way on web so far :(
*/
declare function getPermissionsAsync(): Promise<PermissionResponse>;
declare const _default: {
readonly name: string;
getProviderStatusAsync(): Promise<{
locationServicesEnabled: boolean;
}>;
getLastKnownPositionAsync(options?: LocationLastKnownOptions): Promise<LocationObject | null>;
getCurrentPositionAsync(options: LocationOptions): Promise<LocationObject>;
removeWatchAsync(watchId: any): Promise<void>;
watchDeviceHeading(headingId: any): Promise<void>;
hasServicesEnabledAsync(): Promise<boolean>;
geocodeAsync(): Promise<any[]>;
reverseGeocodeAsync(): Promise<any[]>;
watchPositionImplAsync(watchId: string, options: LocationOptions): Promise<string>;
getPermissionsAsync: typeof getPermissionsAsync;
requestPermissionsAsync(): Promise<PermissionResponse>;
startObserving(): void;
stopObserving(): void;
};
export default _default;

126
node_modules/expo-location/build/ExpoLocation.web.js generated vendored Normal file
View File

@ -0,0 +1,126 @@
import { PermissionStatus } from 'unimodules-permissions-interface';
import { LocationAccuracy, } from './Location.types';
import { LocationEventEmitter } from './LocationEventEmitter';
class GeocoderError extends Error {
constructor() {
super('Geocoder service is not available for this device.');
this.code = 'E_NO_GEOCODER';
}
}
/**
* Converts `GeolocationPosition` to JavaScript object.
*/
function geolocationPositionToJSON(position) {
const { coords, timestamp } = position;
return {
coords: {
latitude: coords.latitude,
longitude: coords.longitude,
altitude: coords.altitude,
accuracy: coords.accuracy,
altitudeAccuracy: coords.altitudeAccuracy,
heading: coords.heading,
speed: coords.speed,
},
timestamp,
};
}
/**
* Checks whether given location didn't exceed given `maxAge` and fits in the required accuracy.
*/
function isLocationValid(location, options) {
const maxAge = typeof options.maxAge === 'number' ? options.maxAge : Infinity;
const requiredAccuracy = typeof options.requiredAccuracy === 'number' ? options.requiredAccuracy : Infinity;
const locationAccuracy = location.coords.accuracy ?? Infinity;
return Date.now() - location.timestamp <= maxAge && locationAccuracy <= requiredAccuracy;
}
/**
* Gets the permission details. The implementation is not very good as it actually requests
* for the current location, but there is no better way on web so far :(
*/
async function getPermissionsAsync() {
return new Promise(resolve => {
const resolveWithStatus = status => resolve({
status,
granted: status === PermissionStatus.GRANTED,
canAskAgain: true,
expires: 0,
});
navigator.geolocation.getCurrentPosition(() => resolveWithStatus(PermissionStatus.GRANTED), ({ code }) => {
if (code === 1 /* PERMISSION_DENIED */) {
resolveWithStatus(PermissionStatus.DENIED);
}
else {
resolveWithStatus(PermissionStatus.UNDETERMINED);
}
}, { enableHighAccuracy: false, maximumAge: Infinity });
});
}
let lastKnownPosition = null;
export default {
get name() {
return 'ExpoLocation';
},
async getProviderStatusAsync() {
return {
locationServicesEnabled: 'geolocation' in navigator,
};
},
async getLastKnownPositionAsync(options = {}) {
if (lastKnownPosition && isLocationValid(lastKnownPosition, options)) {
return lastKnownPosition;
}
return null;
},
async getCurrentPositionAsync(options) {
return new Promise((resolve, reject) => {
const resolver = position => {
lastKnownPosition = geolocationPositionToJSON(position);
resolve(lastKnownPosition);
};
navigator.geolocation.getCurrentPosition(resolver, reject, {
maximumAge: Infinity,
enableHighAccuracy: (options.accuracy ?? 0) > LocationAccuracy.Balanced,
...options,
});
});
},
async removeWatchAsync(watchId) {
navigator.geolocation.clearWatch(watchId);
},
async watchDeviceHeading(headingId) {
console.warn('Location.watchDeviceHeading: is not supported on web');
},
async hasServicesEnabledAsync() {
return 'geolocation' in navigator;
},
async geocodeAsync() {
throw new GeocoderError();
},
async reverseGeocodeAsync() {
throw new GeocoderError();
},
async watchPositionImplAsync(watchId, options) {
return new Promise(resolve => {
// @ts-ignore: the types here need to be fixed
watchId = global.navigator.geolocation.watchPosition(position => {
lastKnownPosition = geolocationPositionToJSON(position);
LocationEventEmitter.emit('Expo.locationChanged', {
watchId,
location: lastKnownPosition,
});
}, undefined,
// @ts-ignore: the options object needs to be fixed
options);
resolve(watchId);
});
},
getPermissionsAsync,
async requestPermissionsAsync() {
return getPermissionsAsync();
},
// no-op
startObserving() { },
stopObserving() { },
};
//# sourceMappingURL=ExpoLocation.web.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
export declare function installWebGeolocationPolyfill(): void;

View File

@ -0,0 +1,53 @@
import { Platform } from '@unimodules/core';
import ExpoLocation from './ExpoLocation';
import { LocationAccuracy } from './Location.types';
import { LocationSubscriber } from './LocationSubscribers';
export function installWebGeolocationPolyfill() {
if (Platform.OS !== 'web') {
// Polyfill navigator.geolocation for interop with the core react-native and web API approach to
// geolocation
// @ts-ignore
window.navigator.geolocation = {
getCurrentPosition,
watchPosition,
clearWatch,
// We don't polyfill stopObserving, this is an internal method that probably should not even exist
// in react-native docs
stopObserving: () => { },
};
}
}
function convertGeolocationOptions(options) {
return {
accuracy: options.enableHighAccuracy ? LocationAccuracy.High : LocationAccuracy.Balanced,
};
}
function getCurrentPosition(success, error = () => { }, options = {}) {
_getCurrentPositionAsyncWrapper(success, error, options);
}
// This function exists to let us continue to return undefined from getCurrentPosition, while still
// using async/await for the internal implementation of it
async function _getCurrentPositionAsyncWrapper(success, error, options) {
try {
await ExpoLocation.requestPermissionsAsync();
const result = await ExpoLocation.getCurrentPositionAsync(convertGeolocationOptions(options));
success(result);
}
catch (e) {
error(e);
}
}
// Polyfill: navigator.geolocation.watchPosition
function watchPosition(success, error, options) {
const watchId = LocationSubscriber.registerCallback(success);
ExpoLocation.watchPositionImplAsync(watchId, options).catch(err => {
LocationSubscriber.unregisterCallback(watchId);
error({ watchId, message: err.message, code: err.code });
});
return watchId;
}
// Polyfill: navigator.geolocation.clearWatch
function clearWatch(watchId) {
LocationSubscriber.unregisterCallback(watchId);
}
//# sourceMappingURL=GeolocationPolyfill.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"GeolocationPolyfill.js","sourceRoot":"","sources":["../src/GeolocationPolyfill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAkB,gBAAgB,EAAmB,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAS3D,MAAM,UAAU,6BAA6B;IAC3C,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;QACzB,gGAAgG;QAChG,cAAc;QACd,aAAa;QACb,MAAM,CAAC,SAAS,CAAC,WAAW,GAAG;YAC7B,kBAAkB;YAClB,aAAa;YACb,UAAU;YAEV,kGAAkG;YAClG,uBAAuB;YACvB,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC;SACxB,CAAC;KACH;AACH,CAAC;AAED,SAAS,yBAAyB,CAAC,OAA2B;IAC5D,OAAO;QACL,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,QAAQ;KACzF,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CACzB,OAAmC,EACnC,QAAkC,GAAG,EAAE,GAAE,CAAC,EAC1C,UAA8B,EAAE;IAEhC,+BAA+B,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAC3D,CAAC;AAED,mGAAmG;AACnG,0DAA0D;AAC1D,KAAK,UAAU,+BAA+B,CAC5C,OAAmC,EACnC,KAA+B,EAC/B,OAA2B;IAE3B,IAAI;QACF,MAAM,YAAY,CAAC,uBAAuB,EAAE,CAAC;QAC7C,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,uBAAuB,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC,CAAC;QAC9F,OAAO,CAAC,MAAM,CAAC,CAAC;KACjB;IAAC,OAAO,CAAC,EAAE;QACV,KAAK,CAAC,CAAC,CAAC,CAAC;KACV;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,GAAG,CAAC,EAAE;QAChE,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 '@unimodules/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\nexport function installWebGeolocationPolyfill(): void {\n if (Platform.OS !== 'web') {\n // Polyfill navigator.geolocation for interop with the core react-native and web API approach to\n // geolocation\n // @ts-ignore\n window.navigator.geolocation = {\n getCurrentPosition,\n watchPosition,\n clearWatch,\n\n // We don't polyfill stopObserving, this is an internal method that probably should not even exist\n // in react-native docs\n stopObserving: () => {},\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 => {\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"]}

73
node_modules/expo-location/build/Location.d.ts generated vendored Normal file
View File

@ -0,0 +1,73 @@
import { PermissionStatus } from 'unimodules-permissions-interface';
import { LocationAccuracy, LocationCallback, LocationGeocodedAddress, LocationGeocodedLocation, LocationHeadingCallback, LocationHeadingObject, LocationLastKnownOptions, LocationObject, LocationOptions, LocationPermissionResponse, LocationProviderStatus, LocationRegion, LocationSubscription, LocationTaskOptions, LocationActivityType, LocationGeofencingEventType, LocationGeofencingRegionState, LocationGeocodingOptions } from './Location.types';
import { LocationEventEmitter } from './LocationEventEmitter';
import { setGoogleApiKey } from './LocationGoogleGeocoding';
import { _getCurrentWatchId } from './LocationSubscribers';
export declare function getProviderStatusAsync(): Promise<LocationProviderStatus>;
export declare function enableNetworkProviderAsync(): Promise<void>;
/**
* Requests for one-time delivery of the user's current location.
* Depending on given `accuracy` option it may take some time to resolve,
* especially when you're inside a building.
*/
export declare function getCurrentPositionAsync(options?: LocationOptions): Promise<LocationObject>;
/**
* Gets the last known position of the device or `null` if it's not available
* or doesn't match given requirements such as maximum age or required accuracy.
* It's considered to be faster than `getCurrentPositionAsync` as it doesn't request for the current location.
*/
export declare function getLastKnownPositionAsync(options?: LocationLastKnownOptions): Promise<LocationObject | null>;
/**
* Starts watching for location changes.
* Given callback will be called once the new location is available.
*/
export declare function watchPositionAsync(options: LocationOptions, callback: LocationCallback): Promise<{
remove(): void;
}>;
/**
* Resolves to an object with current heading details.
* To simplify, it calls `watchHeadingAsync` and waits for a couple of updates
* and returns the one that is accurate enough.
*/
export declare function getHeadingAsync(): Promise<LocationHeadingObject>;
/**
* Starts watching for heading changes.
* Given callback will be called once the new heading is available.
*/
export declare function watchHeadingAsync(callback: LocationHeadingCallback): Promise<LocationSubscription>;
/**
* Geocodes given address to an array of latitude-longitude coordinates.
*/
export declare function geocodeAsync(address: string, options?: LocationGeocodingOptions): Promise<LocationGeocodedLocation[]>;
/**
* The opposite behavior of `geocodeAsync` — translates location coordinates to an array of addresses.
*/
export declare function reverseGeocodeAsync(location: Pick<LocationGeocodedLocation, 'latitude' | 'longitude'>, options?: LocationGeocodingOptions): Promise<LocationGeocodedAddress[]>;
/**
* Gets the current state of location permissions.
*/
export declare function getPermissionsAsync(): Promise<LocationPermissionResponse>;
/**
* Requests the user to grant location permissions.
*/
export declare function requestPermissionsAsync(): Promise<LocationPermissionResponse>;
/**
* Returns `true` if the device has location services enabled or `false` otherwise.
*/
export declare function hasServicesEnabledAsync(): Promise<boolean>;
export declare function isBackgroundLocationAvailableAsync(): Promise<boolean>;
export declare function startLocationUpdatesAsync(taskName: string, options?: LocationTaskOptions): Promise<void>;
export declare function stopLocationUpdatesAsync(taskName: string): Promise<void>;
export declare function hasStartedLocationUpdatesAsync(taskName: string): Promise<boolean>;
export declare function startGeofencingAsync(taskName: string, regions?: LocationRegion[]): Promise<void>;
export declare function stopGeofencingAsync(taskName: string): Promise<void>;
export declare function hasStartedGeofencingAsync(taskName: string): Promise<boolean>;
/**
* @deprecated
* Deprecated as of SDK39 in favour of `setGoogleApiKey`.
*/
export declare function setApiKey(apiKey: string): void;
export { LocationEventEmitter as EventEmitter, _getCurrentWatchId };
export { LocationAccuracy as Accuracy, LocationActivityType as ActivityType, LocationGeofencingEventType as GeofencingEventType, LocationGeofencingRegionState as GeofencingRegionState, PermissionStatus, setGoogleApiKey, };
export { installWebGeolocationPolyfill } from './GeolocationPolyfill';
export * from './Location.types';

190
node_modules/expo-location/build/Location.js generated vendored Normal file
View File

@ -0,0 +1,190 @@
import { Platform } from '@unimodules/core';
import { PermissionStatus } from 'unimodules-permissions-interface';
import ExpoLocation from './ExpoLocation';
import { LocationAccuracy, LocationActivityType, LocationGeofencingEventType, LocationGeofencingRegionState, } from './Location.types';
import { LocationEventEmitter } from './LocationEventEmitter';
import { setGoogleApiKey, googleGeocodeAsync, googleReverseGeocodeAsync, } from './LocationGoogleGeocoding';
import { LocationSubscriber, HeadingSubscriber, _getCurrentWatchId } from './LocationSubscribers';
export async function getProviderStatusAsync() {
return ExpoLocation.getProviderStatusAsync();
}
export async function enableNetworkProviderAsync() {
// If network provider is disabled (user's location mode is set to "Device only"),
// Android's location provider may not give you any results. Use this method in order to ask the user
// to change the location mode to "High accuracy" which uses Google Play services and enables network provider.
// `getCurrentPositionAsync` and `watchPositionAsync` are doing it automatically anyway.
if (Platform.OS === 'android') {
return ExpoLocation.enableNetworkProviderAsync();
}
}
/**
* Requests for one-time delivery of the user's current location.
* Depending on given `accuracy` option it may take some time to resolve,
* especially when you're inside a building.
*/
export async function getCurrentPositionAsync(options = {}) {
return ExpoLocation.getCurrentPositionAsync(options);
}
/**
* Gets the last known position of the device or `null` if it's not available
* or doesn't match given requirements such as maximum age or required accuracy.
* It's considered to be faster than `getCurrentPositionAsync` as it doesn't request for the current location.
*/
export async function getLastKnownPositionAsync(options = {}) {
return ExpoLocation.getLastKnownPositionAsync(options);
}
/**
* Starts watching for location changes.
* Given callback will be called once the new location is available.
*/
export async function watchPositionAsync(options, callback) {
const watchId = LocationSubscriber.registerCallback(callback);
await ExpoLocation.watchPositionImplAsync(watchId, options);
return {
remove() {
LocationSubscriber.unregisterCallback(watchId);
},
};
}
/**
* Resolves to an object with current heading details.
* To simplify, it calls `watchHeadingAsync` and waits for a couple of updates
* and returns the one that is accurate enough.
*/
export async function getHeadingAsync() {
return new Promise(async (resolve) => {
let tries = 0;
const subscription = await watchHeadingAsync(heading => {
if (heading.accuracy > 1 || tries > 5) {
subscription.remove();
resolve(heading);
}
else {
tries += 1;
}
});
});
}
/**
* Starts watching for heading changes.
* Given callback will be called once the new heading is available.
*/
export async function watchHeadingAsync(callback) {
const watchId = HeadingSubscriber.registerCallback(callback);
await ExpoLocation.watchDeviceHeading(watchId);
return {
remove() {
HeadingSubscriber.unregisterCallback(watchId);
},
};
}
/**
* Geocodes given address to an array of latitude-longitude coordinates.
*/
export async function geocodeAsync(address, options) {
if (typeof address !== 'string') {
throw new TypeError(`Address to geocode must be a string. Got ${address} instead.`);
}
if (options?.useGoogleMaps || Platform.OS === 'web') {
return await googleGeocodeAsync(address);
}
return await ExpoLocation.geocodeAsync(address);
}
/**
* The opposite behavior of `geocodeAsync` — translates location coordinates to an array of addresses.
*/
export async function reverseGeocodeAsync(location, options) {
if (typeof location.latitude !== 'number' || typeof location.longitude !== 'number') {
throw new TypeError('Location to reverse-geocode must be an object with number properties `latitude` and `longitude`.');
}
if (options?.useGoogleMaps || Platform.OS === 'web') {
return await googleReverseGeocodeAsync(location);
}
return await ExpoLocation.reverseGeocodeAsync(location);
}
/**
* Gets the current state of location permissions.
*/
export async function getPermissionsAsync() {
return await ExpoLocation.getPermissionsAsync();
}
/**
* Requests the user to grant location permissions.
*/
export async function requestPermissionsAsync() {
return await ExpoLocation.requestPermissionsAsync();
}
// --- Location service
/**
* Returns `true` if the device has location services enabled or `false` otherwise.
*/
export async function hasServicesEnabledAsync() {
return await ExpoLocation.hasServicesEnabledAsync();
}
// --- Background location updates
function _validateTaskName(taskName) {
if (!taskName || typeof taskName !== 'string') {
throw new Error(`\`taskName\` must be a non-empty string. Got ${taskName} instead.`);
}
}
export async function isBackgroundLocationAvailableAsync() {
const providerStatus = await getProviderStatusAsync();
return providerStatus.backgroundModeEnabled;
}
export async function startLocationUpdatesAsync(taskName, options = { accuracy: LocationAccuracy.Balanced }) {
_validateTaskName(taskName);
await ExpoLocation.startLocationUpdatesAsync(taskName, options);
}
export async function stopLocationUpdatesAsync(taskName) {
_validateTaskName(taskName);
await ExpoLocation.stopLocationUpdatesAsync(taskName);
}
export async function hasStartedLocationUpdatesAsync(taskName) {
_validateTaskName(taskName);
return ExpoLocation.hasStartedLocationUpdatesAsync(taskName);
}
// --- Geofencing
function _validateRegions(regions) {
if (!regions || regions.length === 0) {
throw new Error('Regions array cannot be empty. Use `stopGeofencingAsync` if you want to stop geofencing all regions');
}
for (const region of regions) {
if (typeof region.latitude !== 'number') {
throw new TypeError(`Region's latitude must be a number. Got '${region.latitude}' instead.`);
}
if (typeof region.longitude !== 'number') {
throw new TypeError(`Region's longitude must be a number. Got '${region.longitude}' instead.`);
}
if (typeof region.radius !== 'number') {
throw new TypeError(`Region's radius must be a number. Got '${region.radius}' instead.`);
}
}
}
export async function startGeofencingAsync(taskName, regions = []) {
_validateTaskName(taskName);
_validateRegions(regions);
await ExpoLocation.startGeofencingAsync(taskName, { regions });
}
export async function stopGeofencingAsync(taskName) {
_validateTaskName(taskName);
await ExpoLocation.stopGeofencingAsync(taskName);
}
export async function hasStartedGeofencingAsync(taskName) {
_validateTaskName(taskName);
return ExpoLocation.hasStartedGeofencingAsync(taskName);
}
/**
* @deprecated
* Deprecated as of SDK39 in favour of `setGoogleApiKey`.
*/
export function setApiKey(apiKey) {
console.warn("Location's method `setApiKey` is deprecated in favor of `setGoogleApiKey`.");
setGoogleApiKey(apiKey);
}
// For internal purposes
export { LocationEventEmitter as EventEmitter, _getCurrentWatchId };
// Export as namespaced types.
export { LocationAccuracy as Accuracy, LocationActivityType as ActivityType, LocationGeofencingEventType as GeofencingEventType, LocationGeofencingRegionState as GeofencingRegionState, PermissionStatus, setGoogleApiKey, };
export { installWebGeolocationPolyfill } from './GeolocationPolyfill';
export * from './Location.types';
//# sourceMappingURL=Location.js.map

1
node_modules/expo-location/build/Location.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

194
node_modules/expo-location/build/Location.types.d.ts generated vendored Normal file
View File

@ -0,0 +1,194 @@
import { PermissionResponse as UMPermissionResponse } from 'unimodules-permissions-interface';
/**
* Enum with available location accuracies.
*/
export declare enum LocationAccuracy {
Lowest = 1,
Low = 2,
Balanced = 3,
High = 4,
Highest = 5,
BestForNavigation = 6
}
/**
* Enum with available activity types of background location tracking.
*/
export declare enum LocationActivityType {
Other = 1,
AutomotiveNavigation = 2,
Fitness = 3,
OtherNavigation = 4,
Airborne = 5
}
/**
* A type of the event that geofencing task can receive.
*/
export declare enum LocationGeofencingEventType {
Enter = 1,
Exit = 2
}
/**
* State of the geofencing region that you receive through the geofencing task.
*/
export declare enum LocationGeofencingRegionState {
Unknown = 0,
Inside = 1,
Outside = 2
}
/**
* Type representing options argument in `getCurrentPositionAsync`.
*/
export declare type LocationOptions = {
/**
* Location manager accuracy. Pass one of `LocationAccuracy` enum values.
* For low-accuracies the implementation can avoid geolocation providers
* that consume a significant amount of power (such as GPS).
*/
accuracy?: LocationAccuracy;
/**
* (Android only) Specifies whether to ask the user to turn on improved accuracy location mode
* which uses Wi-Fi, cell networks and GPS sensor. Defaults to `true`.
*/
mayShowUserSettingsDialog?: boolean;
/**
* (Android only) Minimum time to wait between each update in milliseconds.
* Default value may depend on `accuracy` option.
*/
timeInterval?: number;
/**
* Receive updates only when the location has changed by at least this distance in meters.
* Default value may depend on `accuracy` option.
*/
distanceInterval?: number;
};
/**
* Type representing options object that can be passed to `getLastKnownPositionAsync`.
*/
export declare type LocationLastKnownOptions = {
/**
* Maximum age of the location in miliseconds.
*/
maxAge?: number;
/**
* Maximum radius of horizontal accuracy in meters.
*/
requiredAccuracy?: number;
};
/**
* Type representing background location task options.
*/
export declare type LocationTaskOptions = LocationOptions & {
showsBackgroundLocationIndicator?: boolean;
deferredUpdatesDistance?: number;
deferredUpdatesTimeout?: number;
deferredUpdatesInterval?: number;
activityType?: LocationActivityType;
pausesUpdatesAutomatically?: boolean;
foregroundService?: {
notificationTitle: string;
notificationBody: string;
notificationColor?: string;
};
};
/**
* Type representing geofencing region object.
*/
export declare type LocationRegion = {
identifier?: string;
latitude: number;
longitude: number;
radius: number;
notifyOnEnter?: boolean;
notifyOnExit?: boolean;
};
/**
* Type representing the location object.
*/
export declare type LocationObject = {
coords: {
latitude: number;
longitude: number;
altitude: number | null;
accuracy: number | null;
altitudeAccuracy: number | null;
heading: number | null;
speed: number | null;
};
timestamp: number;
};
/**
* Represents `watchPositionAsync` callback.
*/
export declare type LocationCallback = (location: LocationObject) => any;
/**
* Represents the object containing details about location provider.
*/
export declare type LocationProviderStatus = {
locationServicesEnabled: boolean;
backgroundModeEnabled: boolean;
gpsAvailable?: boolean;
networkAvailable?: boolean;
passiveAvailable?: boolean;
};
/**
* Type of the object containing heading details and provided by `watchHeadingAsync` callback.
*/
export declare type LocationHeadingObject = {
trueHeading: number;
magHeading: number;
accuracy: number;
};
/**
* Represents `watchHeadingAsync` callback.
*/
export declare type LocationHeadingCallback = (location: LocationHeadingObject) => any;
/**
* An object of options for forward and reverse geocoding.
*/
export declare type LocationGeocodingOptions = {
/**
* Whether to force using Google Maps API instead of the native implementation.
* Used by default only on Web platform. Requires providing an API key by `setGoogleApiKey`.
*/
useGoogleMaps?: boolean;
};
/**
* Type representing a result of `geocodeAsync`.
*/
export declare type LocationGeocodedLocation = {
latitude: number;
longitude: number;
altitude?: number;
accuracy?: number;
};
/**
* Type representing a result of `reverseGeocodeAsync`.
*/
export declare type LocationGeocodedAddress = {
city: string | null;
district: string | null;
street: string | null;
region: string | null;
subregion: string | null;
country: string | null;
postalCode: string | null;
name: string | null;
isoCountryCode: string | null;
timezone: string | null;
};
/**
* Represents subscription object returned by methods watching for new locations or headings.
*/
export declare type LocationSubscription = {
remove: () => void;
};
export declare type PermissionDetailsLocationIOS = {
scope: 'whenInUse' | 'always' | 'none';
};
export declare type PermissionDetailsLocationAndroid = {
scope: 'fine' | 'coarse' | 'none';
};
export interface LocationPermissionResponse extends UMPermissionResponse {
ios?: PermissionDetailsLocationIOS;
android?: PermissionDetailsLocationAndroid;
}

41
node_modules/expo-location/build/Location.types.js generated vendored Normal file
View File

@ -0,0 +1,41 @@
/**
* Enum with available location accuracies.
*/
export var LocationAccuracy;
(function (LocationAccuracy) {
LocationAccuracy[LocationAccuracy["Lowest"] = 1] = "Lowest";
LocationAccuracy[LocationAccuracy["Low"] = 2] = "Low";
LocationAccuracy[LocationAccuracy["Balanced"] = 3] = "Balanced";
LocationAccuracy[LocationAccuracy["High"] = 4] = "High";
LocationAccuracy[LocationAccuracy["Highest"] = 5] = "Highest";
LocationAccuracy[LocationAccuracy["BestForNavigation"] = 6] = "BestForNavigation";
})(LocationAccuracy || (LocationAccuracy = {}));
/**
* Enum with available activity types of background location tracking.
*/
export var LocationActivityType;
(function (LocationActivityType) {
LocationActivityType[LocationActivityType["Other"] = 1] = "Other";
LocationActivityType[LocationActivityType["AutomotiveNavigation"] = 2] = "AutomotiveNavigation";
LocationActivityType[LocationActivityType["Fitness"] = 3] = "Fitness";
LocationActivityType[LocationActivityType["OtherNavigation"] = 4] = "OtherNavigation";
LocationActivityType[LocationActivityType["Airborne"] = 5] = "Airborne";
})(LocationActivityType || (LocationActivityType = {}));
/**
* A type of the event that geofencing task can receive.
*/
export var LocationGeofencingEventType;
(function (LocationGeofencingEventType) {
LocationGeofencingEventType[LocationGeofencingEventType["Enter"] = 1] = "Enter";
LocationGeofencingEventType[LocationGeofencingEventType["Exit"] = 2] = "Exit";
})(LocationGeofencingEventType || (LocationGeofencingEventType = {}));
/**
* State of the geofencing region that you receive through the geofencing task.
*/
export var LocationGeofencingRegionState;
(function (LocationGeofencingRegionState) {
LocationGeofencingRegionState[LocationGeofencingRegionState["Unknown"] = 0] = "Unknown";
LocationGeofencingRegionState[LocationGeofencingRegionState["Inside"] = 1] = "Inside";
LocationGeofencingRegionState[LocationGeofencingRegionState["Outside"] = 2] = "Outside";
})(LocationGeofencingRegionState || (LocationGeofencingRegionState = {}));
//# sourceMappingURL=Location.types.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
import { EventEmitter } from '@unimodules/core';
export declare const LocationEventEmitter: EventEmitter;

View File

@ -0,0 +1,4 @@
import { EventEmitter } from '@unimodules/core';
import ExpoLocation from './ExpoLocation';
export const LocationEventEmitter = new EventEmitter(ExpoLocation);
//# sourceMappingURL=LocationEventEmitter.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"LocationEventEmitter.js","sourceRoot":"","sources":["../src/LocationEventEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import { EventEmitter } from '@unimodules/core';\n\nimport ExpoLocation from './ExpoLocation';\n\nexport const LocationEventEmitter = new EventEmitter(ExpoLocation);\n"]}

View File

@ -0,0 +1,2 @@
import { EventEmitter } from '@unimodules/core';
export declare const LocationEventEmitter: EventEmitter;

View File

@ -0,0 +1,3 @@
import { EventEmitter } from '@unimodules/core';
export const LocationEventEmitter = new EventEmitter({});
//# sourceMappingURL=LocationEventEmitter.web.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"LocationEventEmitter.web.js","sourceRoot":"","sources":["../src/LocationEventEmitter.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,YAAY,CAAC,EAAS,CAAC,CAAC","sourcesContent":["import { EventEmitter } from '@unimodules/core';\n\nexport const LocationEventEmitter = new EventEmitter({} as any);\n"]}

View File

@ -0,0 +1,7 @@
import { LocationGeocodedAddress, LocationGeocodedLocation } from './Location.types';
export declare function setGoogleApiKey(apiKey: string): void;
export declare function googleGeocodeAsync(address: string): Promise<LocationGeocodedLocation[]>;
export declare function googleReverseGeocodeAsync(options: {
latitude: number;
longitude: number;
}): Promise<LocationGeocodedAddress[]>;

View File

@ -0,0 +1,113 @@
import { CodedError } from '@unimodules/core';
const GOOGLE_API_URL = 'https://maps.googleapis.com/maps/api/geocode/json';
let googleApiKey;
export function setGoogleApiKey(apiKey) {
googleApiKey = apiKey;
}
export async function googleGeocodeAsync(address) {
assertGoogleApiKey();
const result = await requestGoogleApiAsync({ address });
if (result.status === 'ZERO_RESULTS') {
return [];
}
assertGeocodeResults(result);
return result.results.map(geocodingResultToLocation);
}
export async function googleReverseGeocodeAsync(options) {
assertGoogleApiKey();
const result = await requestGoogleApiAsync({
latlng: `${options.latitude},${options.longitude}`,
});
if (result.status === 'ZERO_RESULTS') {
return [];
}
assertGeocodeResults(result);
return result.results.map(reverseGeocodingResultToAddress);
}
// https://developers.google.com/maps/documentation/geocoding/intro
function assertGeocodeResults(resultObject) {
const { status, error_message } = resultObject;
if (status !== 'ZERO_RESULTS' && status !== 'OK') {
if (error_message) {
throw new CodedError(status, error_message);
}
else if (status === 'UNKNOWN_ERROR') {
throw new CodedError(status, 'the request could not be processed due to a server error. The request may succeed if you try again.');
}
throw new CodedError(status, `An error occurred during geocoding.`);
}
}
/**
* Makes sure the Google API key is set.
*/
function assertGoogleApiKey() {
if (!googleApiKey) {
throw new Error('Google API key is required to use geocoding. Please set it using `setGoogleApiKey` method.');
}
}
/**
* Generic and handy method for sending requests to Google Maps API endpoint.
*/
async function requestGoogleApiAsync(params) {
const query = Object.entries(params)
.map(entry => `${entry[0]}=${encodeURI(entry[1])}`)
.join('&');
const result = await fetch(`${GOOGLE_API_URL}?key=${googleApiKey}&${query}`);
return await result.json();
}
/**
* Converts Google's result to the location object.
*/
function geocodingResultToLocation(result) {
const { location } = result.geometry;
return {
latitude: location.lat,
longitude: location.lng,
};
}
/**
* Converts Google's result to address object.
*/
function reverseGeocodingResultToAddress(result) {
const address = {};
for (const { long_name, short_name, types } of result.address_components) {
if (types.includes('locality')) {
address.city = long_name;
continue;
}
if (types.includes('sublocality')) {
address.district = long_name;
continue;
}
if (types.includes('street_address') || types.includes('route')) {
address.street = long_name;
continue;
}
if (types.includes('administrative_area_level_1')) {
address.region = long_name;
continue;
}
if (types.includes('administrative_area_level_2')) {
address.subregion = long_name;
continue;
}
if (types.includes('country')) {
address.country = long_name;
address.isoCountryCode = short_name;
continue;
}
if (types.includes('postal_code')) {
address.postalCode = long_name;
continue;
}
if (types.includes('point_of_interest')) {
address.name = long_name;
continue;
}
}
if (!address.name) {
address.name = result.formatted_address.replace(/,.*$/, '');
}
return address;
}
//# sourceMappingURL=LocationGoogleGeocoding.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,29 @@
import { LocationCallback, LocationHeadingCallback } from './Location.types';
declare type EventObject = {
watchId: number;
[key: string]: any;
};
declare class Subscriber<CallbackType extends LocationCallback | LocationHeadingCallback> {
private eventName;
private eventDataField;
private callbacks;
private eventSubscription;
constructor(eventName: string, eventDataField: string);
maybeInitializeSubscription(): void;
/**
* Registers given callback under new id which is then returned.
*/
registerCallback(callback: CallbackType): number;
/**
* Unregisters a callback with given id and revokes the subscription if possible.
*/
unregisterCallback(id: number): void;
trigger(event: EventObject): void;
}
export declare const LocationSubscriber: Subscriber<LocationCallback>;
export declare const HeadingSubscriber: Subscriber<LocationHeadingCallback>;
/**
* Necessary for some unit tests.
*/
export declare function _getCurrentWatchId(): number;
export {};

View File

@ -0,0 +1,60 @@
import ExpoLocation from './ExpoLocation';
import { LocationEventEmitter } from './LocationEventEmitter';
let nextWatchId = 0;
class Subscriber {
constructor(eventName, eventDataField) {
this.callbacks = {};
this.eventSubscription = null;
this.eventName = eventName;
this.eventDataField = eventDataField;
}
maybeInitializeSubscription() {
if (this.eventSubscription) {
return;
}
this.eventSubscription = LocationEventEmitter.addListener(this.eventName, (event) => this.trigger(event));
}
/**
* Registers given callback under new id which is then returned.
*/
registerCallback(callback) {
this.maybeInitializeSubscription();
const id = ++nextWatchId;
this.callbacks[id] = callback;
return id;
}
/**
* Unregisters a callback with given id and revokes the subscription if possible.
*/
unregisterCallback(id) {
// Do nothing if we have already unregistered the callback.
if (!this.callbacks[id]) {
return;
}
delete this.callbacks[id];
ExpoLocation.removeWatchAsync(id);
if (Object.keys(this.callbacks).length === 0 && this.eventSubscription) {
LocationEventEmitter.removeSubscription(this.eventSubscription);
this.eventSubscription = null;
}
}
trigger(event) {
const watchId = event.watchId;
const callback = this.callbacks[watchId];
if (callback) {
callback(event[this.eventDataField]);
}
else {
ExpoLocation.removeWatchAsync(watchId);
}
}
}
export const LocationSubscriber = new Subscriber('Expo.locationChanged', 'location');
export const HeadingSubscriber = new Subscriber('Expo.headingChanged', 'heading');
/**
* Necessary for some unit tests.
*/
export function _getCurrentWatchId() {
return nextWatchId;
}
//# sourceMappingURL=LocationSubscribers.js.map

View File

@ -0,0 +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;IAMd,YAAY,SAAiB,EAAE,cAAsB;QAH7C,cAAS,GAAmC,EAAE,CAAC;QAC/C,sBAAiB,GAAwB,IAAI,CAAC;QAGpD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED,2BAA2B;QACzB,IAAI,IAAI,CAAC,iBAAiB,EAAE;YAC1B,OAAO;SACR;QACD,IAAI,CAAC,iBAAiB,GAAG,oBAAoB,CAAC,WAAW,CACvD,IAAI,CAAC,SAAS,EACd,CAAC,KAAkB,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAC5C,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,gBAAgB,CAAC,QAAsB;QACrC,IAAI,CAAC,2BAA2B,EAAE,CAAC;QACnC,MAAM,EAAE,GAAG,EAAE,WAAW,CAAC;QACzB,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC;QAC9B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED;;OAEG;IACH,kBAAkB,CAAC,EAAU;QAC3B,2DAA2D;QAC3D,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE;YACvB,OAAO;SACR;QAED,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAC1B,YAAY,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QAElC,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,iBAAiB,EAAE;YACtE,oBAAoB,CAAC,kBAAkB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAChE,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;SAC/B;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;YACZ,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;SACtC;aAAM;YACL,YAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;SACxC;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;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { Subscription } from '@unimodules/core';\n\nimport ExpoLocation from './ExpoLocation';\nimport { LocationCallback, 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<CallbackType extends LocationCallback | LocationHeadingCallback> {\n private eventName: string;\n private eventDataField: string;\n private callbacks: { [id: string]: CallbackType } = {};\n private eventSubscription: Subscription | 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 * 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\n/**\n * Necessary for some unit tests.\n */\nexport function _getCurrentWatchId(): number {\n return nextWatchId;\n}\n"]}