@bricks-soft/capacitor-location-tracking 8.0.0 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +375 -124
- package/android/build.gradle +2 -1
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/brickssoft/locationtracking/bridge/OptionParsers.kt +4 -1
- package/android/src/main/java/com/brickssoft/locationtracking/bridge/PluginHandlers.kt +14 -5
- package/android/src/main/java/com/brickssoft/locationtracking/config/Config.kt +10 -0
- package/android/src/main/java/com/brickssoft/locationtracking/config/ConfigJson.kt +70 -15
- package/android/src/main/java/com/brickssoft/locationtracking/config/ConfigStore.kt +6 -0
- package/android/src/main/java/com/brickssoft/locationtracking/config/ConfigValidator.kt +8 -3
- package/android/src/main/java/com/brickssoft/locationtracking/config/RuntimeStateJson.kt +10 -0
- package/android/src/main/java/com/brickssoft/locationtracking/config/SecretStore.kt +188 -0
- package/android/src/main/java/com/brickssoft/locationtracking/config/SharedPrefsConfigStore.kt +188 -17
- package/android/src/main/java/com/brickssoft/locationtracking/config/State.kt +11 -0
- package/android/src/main/java/com/brickssoft/locationtracking/core/Components.kt +21 -5
- package/android/src/main/java/com/brickssoft/locationtracking/core/ForceStopProbe.kt +20 -9
- package/android/src/main/java/com/brickssoft/locationtracking/core/TrackingEvent.kt +24 -2
- package/android/src/main/java/com/brickssoft/locationtracking/data/TrackingDatabase.kt +43 -1
- package/android/src/main/java/com/brickssoft/locationtracking/device/DefaultDeviceInfoProvider.kt +17 -0
- package/android/src/main/java/com/brickssoft/locationtracking/device/DeviceDetails.kt +167 -0
- package/android/src/main/java/com/brickssoft/locationtracking/engine/DefaultTrackingEngine.kt +191 -34
- package/android/src/main/java/com/brickssoft/locationtracking/engine/TrackingEngine.kt +6 -0
- package/android/src/main/java/com/brickssoft/locationtracking/engine/TrackingTimers.kt +3 -0
- package/android/src/main/java/com/brickssoft/locationtracking/heartbeat/DefaultHeartbeatScheduler.kt +52 -8
- package/android/src/main/java/com/brickssoft/locationtracking/heartbeat/HeartbeatAlarmReceiver.kt +22 -0
- package/android/src/main/java/com/brickssoft/locationtracking/http/AuthorizationManager.kt +78 -27
- package/android/src/main/java/com/brickssoft/locationtracking/http/ConfigChecks.kt +140 -0
- package/android/src/main/java/com/brickssoft/locationtracking/http/HttpSupport.kt +50 -12
- package/android/src/main/java/com/brickssoft/locationtracking/http/HttpSyncer.kt +17 -0
- package/android/src/main/java/com/brickssoft/locationtracking/http/OkHttpSyncer.kt +507 -92
- package/android/src/main/java/com/brickssoft/locationtracking/http/SyncPolicy.kt +6 -6
- package/android/src/main/java/com/brickssoft/locationtracking/http/TemplateRenderer.kt +23 -1
- package/android/src/main/java/com/brickssoft/locationtracking/http/UploadJobs.kt +217 -0
- package/android/src/main/java/com/brickssoft/locationtracking/http/UploadWait.kt +184 -0
- package/android/src/main/java/com/brickssoft/locationtracking/logging/FileLogger.kt +66 -7
- package/android/src/main/java/com/brickssoft/locationtracking/logging/LogRedaction.kt +31 -0
- package/android/src/main/java/com/brickssoft/locationtracking/model/DeviceModels.kt +44 -1
- package/android/src/main/java/com/brickssoft/locationtracking/model/ModelJson.kt +79 -8
- package/android/src/main/java/com/brickssoft/locationtracking/model/Record.kt +9 -0
- package/android/src/main/java/com/brickssoft/locationtracking/model/TrackedLocation.kt +12 -2
- package/android/src/main/java/com/brickssoft/locationtracking/position/DefaultPositionService.kt +10 -2
- package/android/src/main/java/com/brickssoft/locationtracking/position/PositionWatch.kt +24 -1
- package/android/src/main/java/com/brickssoft/locationtracking/processing/DefaultRecordFactory.kt +31 -10
- package/android/src/main/java/com/brickssoft/locationtracking/provider/Backends.kt +48 -3
- package/android/src/main/java/com/brickssoft/locationtracking/provider/DefaultProviderFactory.kt +60 -0
- package/android/src/main/java/com/brickssoft/locationtracking/provider/LocationSubscriptions.kt +180 -0
- package/android/src/main/java/com/brickssoft/locationtracking/provider/android/AndroidLocationBackend.kt +200 -126
- package/android/src/main/java/com/brickssoft/locationtracking/provider/android/LocationProviders.kt +20 -0
- package/android/src/main/java/com/brickssoft/locationtracking/provider/gms/GmsLocationBackend.kt +39 -51
- package/android/src/main/java/com/brickssoft/locationtracking/provider/gms/GmsProviderBundle.kt +8 -0
- package/android/src/main/java/com/brickssoft/locationtracking/provider/hms/HmsLocationBackend.kt +47 -53
- package/android/src/main/java/com/brickssoft/locationtracking/provider/hms/HmsProviderBundle.kt +34 -2
- package/android/src/main/java/com/brickssoft/locationtracking/record/RecordSink.kt +19 -1
- package/android/src/main/java/com/brickssoft/locationtracking/service/BootCountStore.kt +7 -0
- package/android/src/main/res/xml/lt_file_paths.xml +1 -1
- package/dist/esm/definitions.d.ts +107 -4
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/events.d.ts +8 -2
- package/dist/esm/events.js +7 -1
- package/dist/esm/events.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web/config.js +10 -0
- package/dist/esm/web/config.js.map +1 -1
- package/dist/esm/web/device.d.ts +2 -2
- package/dist/esm/web/device.js +9 -2
- package/dist/esm/web/device.js.map +1 -1
- package/dist/esm/web.d.ts +0 -8
- package/dist/esm/web.js +12 -3
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +40 -6
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +40 -6
- package/dist/plugin.js.map +1 -1
- package/package.json +4 -3
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AA2B5C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC9F,OAAO,EAAE,aAAa,EAAE,MAA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config,\n CurrentPositionOptions,\n DesiredAccuracy,\n DeviceInfo,\n Geofence,\n HeartbeatStatus,\n InsertLocationInput,\n Location,\n LocationTrackingEventMap,\n LocationTrackingPlugin,\n LogLevel,\n LogQuery,\n PermissionStatus,\n PermissionType,\n PowerManagerInfo,\n ProviderState,\n ReadyOptions,\n Sensors,\n State,\n WatchPositionCallback,\n WatchPositionOptions,\n} from './definitions';\nimport { cloneJson, defaultConfig, isPlainObject, mergeConfig, webState } from './web/config';\nimport { webDeviceInfo } from './web/device';\nimport { positionErrorInfo, webError } from './web/errors';\nimport {\n browserGeolocation,\n probeLocationPermission,\n queryLocationPermission,\n sampleBestPosition,\n} from './web/geolocation';\nimport { toLocation } from './web/location';\n\nconst ALL_PERMISSIONS: PermissionType[] = ['location', 'notifications', 'activityRecognition', 'backgroundLocation'];\n\ninterface WatchEntry {\n active: boolean;\n geolocation: Geolocation;\n browserId: number;\n}\n\nfunction highAccuracy(accuracy: DesiredAccuracy | undefined): boolean {\n return accuracy === undefined || accuracy === 'high';\n}\n\nfunction nonNegative(value: unknown, fallback: number): number {\n return typeof value === 'number' && value >= 0 ? value : fallback;\n}\n\n/** The defaults plus `options.config` (optional; must be an object when given). */\nfunction configFromDefaults(options: { config?: Config } | undefined): Config {\n const given = options ? options.config : undefined;\n if (given !== undefined && given !== null && !isPlainObject(given)) {\n throw webError('INVALID_ARGUMENT', 'config must be an object.');\n }\n return mergeConfig(defaultConfig(), given || undefined);\n}\n\n/**\n * Web implementation. It covers `getCurrentPosition`, `watchPosition` and `clearWatch` (via `navigator.geolocation`),\n * an in-memory config and state, permissions and device info. Nothing is persisted or uploaded, and tracking cannot\n * be started. Every other method rejects with `UNIMPLEMENTED`.\n *\n * Like the Android bridge, methods other than `ready`, `getState`, `checkPermissions`, `requestPermissions` and\n * `getDeviceInfo` reject with `NOT_READY` until `ready()` has resolved.\n */\nexport class LocationTrackingWeb extends WebPlugin implements LocationTrackingPlugin {\n private config: Config = defaultConfig();\n private isReady = false;\n private lastPosition: GeolocationPosition | null = null;\n private watchSeq = 0;\n private readonly watches = new Map<string, WatchEntry>();\n\n async ready(options?: ReadyOptions): Promise<State> {\n const config = configFromDefaults(options);\n // reset:false applies the given config only on the first ready(); afterwards the current config wins.\n if (!options || options.reset !== false || !this.isReady) {\n this.config = config;\n }\n this.isReady = true;\n return webState(this.config);\n }\n\n async setConfig(options: { config: Config }): Promise<State> {\n this.requireReady();\n if (!options || !isPlainObject(options.config)) {\n throw webError('INVALID_ARGUMENT', 'config must be an object.');\n }\n this.config = mergeConfig(this.config, options.config);\n return webState(this.config);\n }\n\n async reset(options?: { config?: Config }): Promise<State> {\n this.requireReady();\n this.config = configFromDefaults(options);\n return webState(this.config);\n }\n\n async getState(): Promise<State> {\n return webState(this.config);\n }\n\n async start(): Promise<State> {\n throw this.unimplemented('Not implemented on web.');\n }\n async startGeofences(): Promise<State> {\n throw this.unimplemented('Not implemented on web.');\n }\n async stop(): Promise<State> {\n throw this.unimplemented('Not implemented on web.');\n }\n async changePace(_options: { isMoving: boolean }): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n /**\n * Takes `samples` fixes within `timeout` and resolves the most accurate one. With `maximumAge > 0`, a fix this\n * plugin received at most that long ago is returned right away. Like a persisted record on Android, the result is\n * also emitted as a `location` event unless `persist` is false.\n */\n async getCurrentPosition(options?: CurrentPositionOptions): Promise<Location> {\n this.requireReady();\n const geolocation = this.requireGeolocation();\n const o = options || {};\n const maximumAge = nonNegative(o.maximumAge, 0);\n const cached = this.lastPosition;\n let position: GeolocationPosition;\n if (maximumAge > 0 && cached && Date.now() - cached.timestamp <= maximumAge) {\n position = cached;\n } else {\n const samples = typeof o.samples === 'number' && o.samples >= 1 ? Math.floor(o.samples) : 3;\n position = await sampleBestPosition(geolocation, {\n samples,\n timeout: nonNegative(o.timeout, nonNegative(this.config.geolocation?.locationTimeout, 30000)),\n maximumAge,\n enableHighAccuracy: highAccuracy(o.desiredAccuracy),\n });\n }\n this.lastPosition = position;\n const location = toLocation(position, 'current_position', this.recordExtras(o.extras));\n if (o.persist !== false) {\n this.emit('location', location);\n }\n return location;\n }\n\n /**\n * Starts `navigator.geolocation.watchPosition` and resolves its id. The callback gets each fix as a\n * `watch_position` Location, or `(null, { code, message })` on error. `interval` is ignored: the browser decides\n * how often fixes arrive. With `persist: true` each fix is also emitted as a `location` event.\n */\n async watchPosition(options: WatchPositionOptions, callback: WatchPositionCallback): Promise<CallbackID> {\n this.requireReady();\n if (typeof callback !== 'function') {\n throw webError('INVALID_ARGUMENT', 'watchPosition requires a callback.');\n }\n const geolocation = this.requireGeolocation();\n const o = options || {};\n const callExtras = cloneJson(o.extras);\n const persist = o.persist === true;\n const entry: WatchEntry = { active: true, geolocation, browserId: 0 };\n try {\n entry.browserId = geolocation.watchPosition(\n (position) => {\n // Browsers may still deliver a queued fix after clearWatch.\n if (!entry.active) {\n return;\n }\n this.lastPosition = position;\n const location = toLocation(position, 'watch_position', this.recordExtras(callExtras));\n if (persist) {\n this.emit('location', location);\n }\n callback(location);\n },\n (error) => {\n if (entry.active) {\n callback(null, positionErrorInfo(error));\n }\n },\n { enableHighAccuracy: highAccuracy(o.desiredAccuracy), maximumAge: 0 },\n );\n } catch (e) {\n throw webError('UNAVAILABLE', e instanceof Error ? e.message : String(e));\n }\n const id = `web-watch-${++this.watchSeq}`;\n this.watches.set(id, entry);\n return id;\n }\n\n /** Stops a watch. Unknown ids are ignored. */\n async clearWatch(options: { id: CallbackID }): Promise<void> {\n this.requireReady();\n if (!options || typeof options.id !== 'string') {\n throw webError('INVALID_ARGUMENT', 'id must be a string.');\n }\n const entry = this.watches.get(options.id);\n if (!entry) {\n return;\n }\n this.watches.delete(options.id);\n entry.active = false;\n entry.geolocation.clearWatch(entry.browserId);\n }\n\n async getOdometer(): Promise<{ odometer: number }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async setOdometer(_options: { odometer: number }): Promise<{ odometer: number }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async resetOdometer(): Promise<{ odometer: number }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async getLocations(_options?: { limit?: number }): Promise<{ locations: Location[] }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async getCount(): Promise<{ count: number }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async insertLocation(_options: { location: InsertLocationInput }): Promise<{ uuid: string }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async destroyLocations(): Promise<{ count: number }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async destroyLocation(_options: { uuid: string }): Promise<{ deleted: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async sync(): Promise<{ locations: Location[] }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async addGeofence(_options: { geofence: Geofence }): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n async addGeofences(_options: { geofences: Geofence[] }): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n async removeGeofence(_options: { identifier: string }): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n async removeGeofences(_options?: { identifiers?: string[] }): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n async getGeofences(): Promise<{ geofences: Geofence[] }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async getGeofence(_options: { identifier: string }): Promise<{ geofence: Geofence | null }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async geofenceExists(_options: { identifier: string }): Promise<{ exists: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async getHeartbeatStatus(): Promise<HeartbeatStatus> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async getProviderState(): Promise<ProviderState> {\n throw this.unimplemented('Not implemented on web.');\n }\n async isPowerSaveMode(): Promise<{ isPowerSaveMode: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async getBatteryOptimizationStatus(): Promise<BatteryOptimizationStatus> {\n throw this.unimplemented('Not implemented on web.');\n }\n async openBatteryOptimizationSettings(): Promise<{ opened: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async getPowerManagerInfo(): Promise<PowerManagerInfo> {\n throw this.unimplemented('Not implemented on web.');\n }\n async openPowerManagerSettings(): Promise<{ opened: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async openLocationSettings(): Promise<{ opened: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async openAppSettings(): Promise<{ opened: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n /** Best-effort values parsed from `navigator.userAgent`; `platform` is `'web'`. */\n async getDeviceInfo(): Promise<DeviceInfo> {\n const nav = typeof navigator !== 'undefined' && navigator ? navigator : undefined;\n return webDeviceInfo(nav && typeof nav.userAgent === 'string' ? nav.userAgent : '', nav ? nav.platform : undefined);\n }\n async getSensors(): Promise<Sensors> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n /** `location` comes from the Permissions API (`'prompt'` when it cannot tell); the other three are `'granted'`. */\n async checkPermissions(): Promise<PermissionStatus> {\n const location = await queryLocationPermission();\n return {\n location: location || 'prompt',\n backgroundLocation: 'granted',\n activityRecognition: 'granted',\n notifications: 'granted',\n };\n }\n\n /** When `location` is requested and still undecided, asks for a fix so the browser prompts, then reports. */\n async requestPermissions(options?: { permissions?: PermissionType[] }): Promise<PermissionStatus> {\n const requested = options && Array.isArray(options.permissions) ? options.permissions : ALL_PERMISSIONS;\n const status = await this.checkPermissions();\n const geolocation = browserGeolocation();\n if (requested.indexOf('location') < 0 || status.location !== 'prompt' || !geolocation) {\n return status;\n }\n const answer = await probeLocationPermission(geolocation);\n // A granted probe is proof, even for a one-time grant the Permissions API still reports as 'prompt'. Otherwise\n // prefer the Permissions API: a dismissed prompt fails the probe as denied but leaves the permission at 'prompt'.\n status.location = answer === 'granted' ? answer : (await queryLocationPermission()) || answer;\n return status;\n }\n\n async log(_options: { level: Exclude<LogLevel, 'off'>; message: string }): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n async getLog(_options?: LogQuery): Promise<{ log: string }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async destroyLog(): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n async uploadLog(_options: {\n url: string;\n headers?: Record<string, string>;\n params?: Record<string, unknown>;\n }): Promise<{ success: boolean; status: number }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async emailLog(_options: { email: string; subject?: string }): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n private requireReady(): void {\n if (!this.isReady) {\n throw webError('NOT_READY', 'Call ready() before using this method.');\n }\n }\n\n private requireGeolocation(): Geolocation {\n const geolocation = browserGeolocation();\n if (!geolocation) {\n throw webError('UNAVAILABLE', 'navigator.geolocation is not available.');\n }\n return geolocation;\n }\n\n /** `persistence.extras` merged with the call's extras (the call wins), like records created on Android. */\n private recordExtras(extras: Record<string, unknown> | undefined): Record<string, unknown> | undefined {\n const persisted = this.config.persistence ? this.config.persistence.extras : undefined;\n const merged: Record<string, unknown> = {};\n if (isPlainObject(persisted)) {\n Object.assign(merged, cloneJson(persisted));\n }\n if (isPlainObject(extras)) {\n Object.assign(merged, cloneJson(extras));\n }\n return Object.keys(merged).length > 0 ? merged : undefined;\n }\n\n /**\n * Like `notifyListeners`, but each listener gets its own copy of the payload (as on native, where every listener\n * receives deserialized data), and a throwing listener neither skips the others nor fails the calling method.\n */\n private emit<K extends keyof LocationTrackingEventMap>(eventName: K, data: LocationTrackingEventMap[K]): void {\n const listeners = this.listeners[eventName];\n if (!listeners) {\n return;\n }\n for (const listener of listeners.slice()) {\n try {\n listener(cloneJson(data));\n } catch (e) {\n console.error(`LocationTracking: \"${eventName}\" listener threw`, e);\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AA2B5C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EA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AAC;QAC5C,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO;QACT,CAAC;QACD,KAAK,MAAM,QAAQ,IAAI,SAAS,CAAC,KAAK,EAAE,EAAE,CAAC;YACzC,IAAI,CAAC;gBACH,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YAC5B,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,KAAK,CAAC,sBAAsB,SAAS,kBAAkB,EAAE,CAAC,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["// Owned by Unit 1 (TS wrapper + web).\nimport { WebPlugin } from '@capacitor/core';\n\nimport type {\n BatteryOptimizationStatus,\n CallbackID,\n Config,\n CurrentPositionOptions,\n DesiredAccuracy,\n DeviceInfo,\n Geofence,\n HeartbeatStatus,\n InsertLocationInput,\n Location,\n LocationTrackingEventMap,\n LocationTrackingPlugin,\n LogLevel,\n LogQuery,\n PermissionStatus,\n PermissionType,\n PowerManagerInfo,\n ProviderState,\n ReadyOptions,\n Sensors,\n State,\n WatchPositionCallback,\n WatchPositionOptions,\n} from './definitions';\nimport { cloneJson, defaultConfig, isPlainObject, mergeConfig, webState } from './web/config';\nimport { webDeviceInfo } from './web/device';\nimport { positionErrorInfo, webError } from './web/errors';\nimport {\n browserGeolocation,\n probeLocationPermission,\n queryLocationPermission,\n sampleBestPosition,\n} from './web/geolocation';\nimport { toLocation } from './web/location';\n\nconst ALL_PERMISSIONS: PermissionType[] = ['location', 'notifications', 'activityRecognition', 'backgroundLocation'];\n\ninterface WatchEntry {\n active: boolean;\n geolocation: Geolocation;\n browserId: number;\n}\n\nfunction highAccuracy(accuracy: DesiredAccuracy | undefined): boolean {\n return accuracy === undefined || accuracy === 'high';\n}\n\nfunction nonNegative(value: unknown, fallback: number): number {\n return typeof value === 'number' && value >= 0 ? value : fallback;\n}\n\n/** The defaults plus `options.config` (optional; must be an object when given). */\nfunction configFromDefaults(options: { config?: Config } | undefined): Config {\n const given = options ? options.config : undefined;\n if (given !== undefined && given !== null && !isPlainObject(given)) {\n throw webError('INVALID_ARGUMENT', 'config must be an object.');\n }\n return mergeConfig(defaultConfig(), given || undefined);\n}\n\n/**\n * Web implementation. It covers `getCurrentPosition`, `watchPosition` and `clearWatch` (via `navigator.geolocation`),\n * an in-memory config and state, permissions and device info. Nothing is persisted or uploaded, and tracking cannot\n * be started. Every other method rejects with `UNIMPLEMENTED`.\n *\n * Like the Android bridge, methods other than `ready`, `getState`, `checkPermissions`, `requestPermissions` and\n * `getDeviceInfo` reject with `NOT_READY` until `ready()` has resolved.\n */\n/** The State of `ready`, `setConfig` and `reset`, with the `warnings` the Android plugin also returns. */\nfunction withWarnings(state: State): State {\n const url = state.config.http?.url;\n const warnings =\n typeof url === 'string' && /^http:\\/\\//i.test(url.trim())\n ? [\"http.url uses http://: Android 9+ blocks cleartext traffic unless the app's network security config allows it\"]\n : [];\n return { ...state, warnings };\n}\n\nexport class LocationTrackingWeb extends WebPlugin implements LocationTrackingPlugin {\n private config: Config = defaultConfig();\n private isReady = false;\n private lastPosition: GeolocationPosition | null = null;\n private watchSeq = 0;\n private readonly watches = new Map<string, WatchEntry>();\n\n async ready(options?: ReadyOptions): Promise<State> {\n const config = configFromDefaults(options);\n // reset:false applies the given config only on the first ready(); afterwards the current config wins.\n if (!options || options.reset !== false || !this.isReady) {\n this.config = config;\n }\n this.isReady = true;\n return withWarnings(webState(this.config));\n }\n\n async setConfig(options: { config: Config }): Promise<State> {\n this.requireReady();\n if (!options || !isPlainObject(options.config)) {\n throw webError('INVALID_ARGUMENT', 'config must be an object.');\n }\n this.config = mergeConfig(this.config, options.config);\n return withWarnings(webState(this.config));\n }\n\n async reset(options?: { config?: Config }): Promise<State> {\n this.requireReady();\n this.config = configFromDefaults(options);\n return withWarnings(webState(this.config));\n }\n\n async getState(): Promise<State> {\n return webState(this.config);\n }\n\n async start(): Promise<State> {\n throw this.unimplemented('Not implemented on web.');\n }\n async startGeofences(): Promise<State> {\n throw this.unimplemented('Not implemented on web.');\n }\n async stop(): Promise<State> {\n throw this.unimplemented('Not implemented on web.');\n }\n async changePace(_options: { isMoving: boolean }): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n /**\n * Takes `samples` fixes within `timeout` and resolves the most accurate one. With `maximumAge > 0`, a fix this\n * plugin received at most that long ago is returned right away. Like a persisted record on Android, the result is\n * also emitted as a `location` event unless `persist` is false.\n */\n async getCurrentPosition(options?: CurrentPositionOptions): Promise<Location> {\n this.requireReady();\n const geolocation = this.requireGeolocation();\n const o = options || {};\n const maximumAge = nonNegative(o.maximumAge, 0);\n const cached = this.lastPosition;\n let position: GeolocationPosition;\n if (maximumAge > 0 && cached && Date.now() - cached.timestamp <= maximumAge) {\n position = cached;\n } else {\n const samples = typeof o.samples === 'number' && o.samples >= 1 ? Math.floor(o.samples) : 3;\n position = await sampleBestPosition(geolocation, {\n samples,\n timeout: nonNegative(o.timeout, nonNegative(this.config.geolocation?.locationTimeout, 30000)),\n maximumAge,\n enableHighAccuracy: highAccuracy(o.desiredAccuracy),\n });\n }\n this.lastPosition = position;\n const location = toLocation(position, 'current_position', this.recordExtras(o.extras));\n if (o.persist !== false) {\n this.emit('location', location);\n }\n return location;\n }\n\n /**\n * Starts `navigator.geolocation.watchPosition` and resolves its id. The callback gets each fix as a\n * `watch_position` Location, or `(null, { code, message })` on error. `interval` is ignored: the browser decides\n * how often fixes arrive. With `persist: true` each fix is also emitted as a `location` event.\n */\n async watchPosition(options: WatchPositionOptions, callback: WatchPositionCallback): Promise<CallbackID> {\n this.requireReady();\n if (typeof callback !== 'function') {\n throw webError('INVALID_ARGUMENT', 'watchPosition requires a callback.');\n }\n const geolocation = this.requireGeolocation();\n const o = options || {};\n const callExtras = cloneJson(o.extras);\n const persist = o.persist === true;\n const entry: WatchEntry = { active: true, geolocation, browserId: 0 };\n try {\n entry.browserId = geolocation.watchPosition(\n (position) => {\n // Browsers may still deliver a queued fix after clearWatch.\n if (!entry.active) {\n return;\n }\n this.lastPosition = position;\n const location = toLocation(position, 'watch_position', this.recordExtras(callExtras));\n if (persist) {\n this.emit('location', location);\n }\n callback(location);\n },\n (error) => {\n if (entry.active) {\n callback(null, positionErrorInfo(error));\n }\n },\n { enableHighAccuracy: highAccuracy(o.desiredAccuracy), maximumAge: 0 },\n );\n } catch (e) {\n throw webError('UNAVAILABLE', e instanceof Error ? e.message : String(e));\n }\n const id = `web-watch-${++this.watchSeq}`;\n this.watches.set(id, entry);\n return id;\n }\n\n /** Stops a watch. Unknown ids are ignored. */\n async clearWatch(options: { id: CallbackID }): Promise<void> {\n this.requireReady();\n if (!options || typeof options.id !== 'string') {\n throw webError('INVALID_ARGUMENT', 'id must be a string.');\n }\n const entry = this.watches.get(options.id);\n if (!entry) {\n return;\n }\n this.watches.delete(options.id);\n entry.active = false;\n entry.geolocation.clearWatch(entry.browserId);\n }\n\n async getOdometer(): Promise<{ odometer: number }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async setOdometer(_options: { odometer: number }): Promise<{ odometer: number }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async resetOdometer(): Promise<{ odometer: number }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async getLocations(_options?: { limit?: number }): Promise<{ locations: Location[] }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async getCount(): Promise<{ count: number }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async insertLocation(_options: { location: InsertLocationInput }): Promise<{ uuid: string }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async destroyLocations(): Promise<{ count: number }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async destroyLocation(_options: { uuid: string }): Promise<{ deleted: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async sync(): Promise<{ locations: Location[] }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async addGeofence(_options: { geofence: Geofence }): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n async addGeofences(_options: { geofences: Geofence[] }): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n async removeGeofence(_options: { identifier: string }): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n async removeGeofences(_options?: { identifiers?: string[] }): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n async getGeofences(): Promise<{ geofences: Geofence[] }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async getGeofence(_options: { identifier: string }): Promise<{ geofence: Geofence | null }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async geofenceExists(_options: { identifier: string }): Promise<{ exists: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async getHeartbeatStatus(): Promise<HeartbeatStatus> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async getProviderState(): Promise<ProviderState> {\n throw this.unimplemented('Not implemented on web.');\n }\n async isPowerSaveMode(): Promise<{ isPowerSaveMode: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async getBatteryOptimizationStatus(): Promise<BatteryOptimizationStatus> {\n throw this.unimplemented('Not implemented on web.');\n }\n async openBatteryOptimizationSettings(): Promise<{ opened: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async getPowerManagerInfo(): Promise<PowerManagerInfo> {\n throw this.unimplemented('Not implemented on web.');\n }\n async openPowerManagerSettings(): Promise<{ opened: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async openLocationSettings(): Promise<{ opened: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async openAppSettings(): Promise<{ opened: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n /** Best-effort values parsed from `navigator.userAgent`; `platform` is `'web'`. */\n async getDeviceInfo(): Promise<DeviceInfo> {\n const nav = typeof navigator !== 'undefined' && navigator ? navigator : undefined;\n return webDeviceInfo(nav && typeof nav.userAgent === 'string' ? nav.userAgent : '', nav ? nav.platform : undefined);\n }\n async getSensors(): Promise<Sensors> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n /** `location` comes from the Permissions API (`'prompt'` when it cannot tell); the other three are `'granted'`. */\n async checkPermissions(): Promise<PermissionStatus> {\n const location = await queryLocationPermission();\n return {\n location: location || 'prompt',\n backgroundLocation: 'granted',\n activityRecognition: 'granted',\n notifications: 'granted',\n };\n }\n\n /** When `location` is requested and still undecided, asks for a fix so the browser prompts, then reports. */\n async requestPermissions(options?: { permissions?: PermissionType[] }): Promise<PermissionStatus> {\n const requested = options && Array.isArray(options.permissions) ? options.permissions : ALL_PERMISSIONS;\n const status = await this.checkPermissions();\n const geolocation = browserGeolocation();\n if (requested.indexOf('location') < 0 || status.location !== 'prompt' || !geolocation) {\n return status;\n }\n const answer = await probeLocationPermission(geolocation);\n // A granted probe is proof, even for a one-time grant the Permissions API still reports as 'prompt'. Otherwise\n // prefer the Permissions API: a dismissed prompt fails the probe as denied but leaves the permission at 'prompt'.\n status.location = answer === 'granted' ? answer : (await queryLocationPermission()) || answer;\n return status;\n }\n\n async log(_options: { level: Exclude<LogLevel, 'off'>; message: string }): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n async getLog(_options?: LogQuery): Promise<{ log: string }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async destroyLog(): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n async uploadLog(_options: {\n url: string;\n headers?: Record<string, string>;\n params?: Record<string, unknown>;\n }): Promise<{ success: boolean; status: number }> {\n throw this.unimplemented('Not implemented on web.');\n }\n async emailLog(_options: { email: string; subject?: string }): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n private requireReady(): void {\n if (!this.isReady) {\n throw webError('NOT_READY', 'Call ready() before using this method.');\n }\n }\n\n private requireGeolocation(): Geolocation {\n const geolocation = browserGeolocation();\n if (!geolocation) {\n throw webError('UNAVAILABLE', 'navigator.geolocation is not available.');\n }\n return geolocation;\n }\n\n /** `persistence.extras` merged with the call's extras (the call wins), like records created on Android. */\n private recordExtras(extras: Record<string, unknown> | undefined): Record<string, unknown> | undefined {\n const persisted = this.config.persistence ? this.config.persistence.extras : undefined;\n const merged: Record<string, unknown> = {};\n if (isPlainObject(persisted)) {\n Object.assign(merged, cloneJson(persisted));\n }\n if (isPlainObject(extras)) {\n Object.assign(merged, cloneJson(extras));\n }\n return Object.keys(merged).length > 0 ? merged : undefined;\n }\n\n /**\n * Like `notifyListeners`, but each listener gets its own copy of the payload (as on native, where every listener\n * receives deserialized data), and a throwing listener neither skips the others nor fails the calling method.\n */\n private emit<K extends keyof LocationTrackingEventMap>(eventName: K, data: LocationTrackingEventMap[K]): void {\n const listeners = this.listeners[eventName];\n if (!listeners) {\n return;\n }\n for (const listener of listeners.slice()) {\n try {\n listener(cloneJson(data));\n } catch (e) {\n console.error(`LocationTracking: \"${eventName}\" listener threw`, e);\n }\n }\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -26,6 +26,8 @@ const Events = {
|
|
|
26
26
|
ENABLEDCHANGE: 'enabledchange',
|
|
27
27
|
NOTIFICATIONACTION: 'notificationaction',
|
|
28
28
|
AUTHORIZATION: 'authorization',
|
|
29
|
+
LOCATIONERROR: 'locationerror',
|
|
30
|
+
STORAGEFULL: 'storagefull',
|
|
29
31
|
};
|
|
30
32
|
/**
|
|
31
33
|
* Subscribes to any plugin event with a typed payload. Call `remove()` on the resolved handle to unsubscribe.
|
|
@@ -55,12 +57,16 @@ const onHttp = (cb) => on('http', cb);
|
|
|
55
57
|
const onConnectivityChange = (cb) => on('connectivitychange', cb);
|
|
56
58
|
/** Battery-saver mode changes. */
|
|
57
59
|
const onPowerSaveChange = (cb) => on('powersavechange', cb);
|
|
58
|
-
/** Tracking enabled / disabled. */
|
|
60
|
+
/** Tracking enabled / disabled, with the reason (the same values as the tracking_start / tracking_stop records). */
|
|
59
61
|
const onEnabledChange = (cb) => on('enabledchange', cb);
|
|
60
62
|
/** Taps on the foreground notification's action buttons. */
|
|
61
63
|
const onNotificationAction = (cb) => on('notificationaction', cb);
|
|
62
64
|
/** JWT refresh results. */
|
|
63
65
|
const onAuthorization = (cb) => on('authorization', cb);
|
|
66
|
+
/** The location request failed; the plugin requests updates again after `retryInMs`. */
|
|
67
|
+
const onLocationError = (cb) => on('locationerror', cb);
|
|
68
|
+
/** A record could not be stored because the device storage is full. */
|
|
69
|
+
const onStorageFull = (cb) => on('storagefull', cb);
|
|
64
70
|
|
|
65
71
|
/** Never copied: assigning `__proto__` would change the target's prototype instead of adding a key. */
|
|
66
72
|
const PROTO_KEY = '__proto__';
|
|
@@ -112,6 +118,7 @@ function defaultConfig() {
|
|
|
112
118
|
enabled: true,
|
|
113
119
|
minInterval: 180,
|
|
114
120
|
maxInterval: 300,
|
|
121
|
+
uploadKeepAwake: 10,
|
|
115
122
|
},
|
|
116
123
|
http: {
|
|
117
124
|
url: null,
|
|
@@ -128,6 +135,7 @@ function defaultConfig() {
|
|
|
128
135
|
locationTemplate: null,
|
|
129
136
|
geofenceTemplate: null,
|
|
130
137
|
timeout: 60000,
|
|
138
|
+
maxRetryAfter: 3600,
|
|
131
139
|
authorization: null,
|
|
132
140
|
},
|
|
133
141
|
persistence: {
|
|
@@ -261,6 +269,9 @@ function clamp(config) {
|
|
|
261
269
|
heartbeat.maxInterval < heartbeat.minInterval) {
|
|
262
270
|
heartbeat.maxInterval = heartbeat.minInterval;
|
|
263
271
|
}
|
|
272
|
+
if (typeof heartbeat.uploadKeepAwake === 'number') {
|
|
273
|
+
heartbeat.uploadKeepAwake = Math.min(60, Math.max(0, heartbeat.uploadKeepAwake));
|
|
274
|
+
}
|
|
264
275
|
}
|
|
265
276
|
const activity = config.activity;
|
|
266
277
|
if (activity && typeof activity.minimumActivityRecognitionConfidence === 'number') {
|
|
@@ -273,6 +284,9 @@ function clamp(config) {
|
|
|
273
284
|
if (http && typeof http.syncInterval === 'number' && http.syncInterval < 0) {
|
|
274
285
|
http.syncInterval = 0;
|
|
275
286
|
}
|
|
287
|
+
if (http && typeof http.maxRetryAfter === 'number' && http.maxRetryAfter < 0) {
|
|
288
|
+
http.maxRetryAfter = 0;
|
|
289
|
+
}
|
|
276
290
|
const notification = config.notification;
|
|
277
291
|
if (notification && Array.isArray(notification.actions) && notification.actions.length > 3) {
|
|
278
292
|
notification.actions = notification.actions.slice(0, 3);
|
|
@@ -301,12 +315,14 @@ function webState(config) {
|
|
|
301
315
|
odometer: 0,
|
|
302
316
|
backend: 'web',
|
|
303
317
|
lastRecordAt: null,
|
|
318
|
+
lastStopReason: null,
|
|
319
|
+
lastStopAt: null,
|
|
304
320
|
config: cloneJson(config),
|
|
305
321
|
};
|
|
306
322
|
}
|
|
307
323
|
|
|
308
|
-
/**
|
|
309
|
-
const PLUGIN_VERSION = '8.
|
|
324
|
+
/** `npm version` copies the `package.json` version here (scripts/sync-version.mjs); a test checks it. */
|
|
325
|
+
const PLUGIN_VERSION = '8.1.0';
|
|
310
326
|
/** Tokens after `Android x` that do not name a device ('K' is Chrome's reduced user agent). */
|
|
311
327
|
const NOT_A_MODEL = ['K', 'U', 'wv', 'Mobile', 'Tablet', 'HarmonyOS'];
|
|
312
328
|
/** The device model among the `;`-separated tokens that follow `Android x` in the user agent's comment. */
|
|
@@ -392,6 +408,13 @@ function webDeviceInfo(userAgent, platform) {
|
|
|
392
408
|
hmsAvailable: false,
|
|
393
409
|
backend: 'web',
|
|
394
410
|
packagedProviders: [],
|
|
411
|
+
backendFallbackReason: null,
|
|
412
|
+
gmsStatus: null,
|
|
413
|
+
hmsStatus: null,
|
|
414
|
+
hmsCoreOutdated: null,
|
|
415
|
+
locationAvailableHint: null,
|
|
416
|
+
cpuCores: typeof navigator !== 'undefined' && navigator.hardwareConcurrency ? navigator.hardwareConcurrency : 0,
|
|
417
|
+
supportedAbis: [],
|
|
395
418
|
};
|
|
396
419
|
}
|
|
397
420
|
|
|
@@ -623,6 +646,15 @@ function configFromDefaults(options) {
|
|
|
623
646
|
* Like the Android bridge, methods other than `ready`, `getState`, `checkPermissions`, `requestPermissions` and
|
|
624
647
|
* `getDeviceInfo` reject with `NOT_READY` until `ready()` has resolved.
|
|
625
648
|
*/
|
|
649
|
+
/** The State of `ready`, `setConfig` and `reset`, with the `warnings` the Android plugin also returns. */
|
|
650
|
+
function withWarnings(state) {
|
|
651
|
+
var _a;
|
|
652
|
+
const url = (_a = state.config.http) === null || _a === void 0 ? void 0 : _a.url;
|
|
653
|
+
const warnings = typeof url === 'string' && /^http:\/\//i.test(url.trim())
|
|
654
|
+
? ["http.url uses http://: Android 9+ blocks cleartext traffic unless the app's network security config allows it"]
|
|
655
|
+
: [];
|
|
656
|
+
return Object.assign(Object.assign({}, state), { warnings });
|
|
657
|
+
}
|
|
626
658
|
class LocationTrackingWeb extends core.WebPlugin {
|
|
627
659
|
constructor() {
|
|
628
660
|
super(...arguments);
|
|
@@ -639,7 +671,7 @@ class LocationTrackingWeb extends core.WebPlugin {
|
|
|
639
671
|
this.config = config;
|
|
640
672
|
}
|
|
641
673
|
this.isReady = true;
|
|
642
|
-
return webState(this.config);
|
|
674
|
+
return withWarnings(webState(this.config));
|
|
643
675
|
}
|
|
644
676
|
async setConfig(options) {
|
|
645
677
|
this.requireReady();
|
|
@@ -647,12 +679,12 @@ class LocationTrackingWeb extends core.WebPlugin {
|
|
|
647
679
|
throw webError('INVALID_ARGUMENT', 'config must be an object.');
|
|
648
680
|
}
|
|
649
681
|
this.config = mergeConfig(this.config, options.config);
|
|
650
|
-
return webState(this.config);
|
|
682
|
+
return withWarnings(webState(this.config));
|
|
651
683
|
}
|
|
652
684
|
async reset(options) {
|
|
653
685
|
this.requireReady();
|
|
654
686
|
this.config = configFromDefaults(options);
|
|
655
|
-
return webState(this.config);
|
|
687
|
+
return withWarnings(webState(this.config));
|
|
656
688
|
}
|
|
657
689
|
async getState() {
|
|
658
690
|
return webState(this.config);
|
|
@@ -938,8 +970,10 @@ exports.onGeofencesChange = onGeofencesChange;
|
|
|
938
970
|
exports.onHeartbeat = onHeartbeat;
|
|
939
971
|
exports.onHttp = onHttp;
|
|
940
972
|
exports.onLocation = onLocation;
|
|
973
|
+
exports.onLocationError = onLocationError;
|
|
941
974
|
exports.onMotionChange = onMotionChange;
|
|
942
975
|
exports.onNotificationAction = onNotificationAction;
|
|
943
976
|
exports.onPowerSaveChange = onPowerSaveChange;
|
|
944
977
|
exports.onProviderChange = onProviderChange;
|
|
978
|
+
exports.onStorageFull = onStorageFull;
|
|
945
979
|
//# sourceMappingURL=plugin.cjs.js.map
|