@capgo/background-geolocation 8.0.32 → 8.0.34
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 +298 -14
- package/android/build.gradle +2 -0
- package/android/src/main/AndroidManifest.xml +17 -0
- package/android/src/main/java/com/capgo/capacitor_background_geolocation/BackgroundGeolocation.java +281 -2
- package/android/src/main/java/com/capgo/capacitor_background_geolocation/GeofenceBootReceiver.java +58 -0
- package/android/src/main/java/com/capgo/capacitor_background_geolocation/GeofenceBroadcastReceiver.java +83 -0
- package/android/src/main/java/com/capgo/capacitor_background_geolocation/GeofenceStore.java +255 -0
- package/android/src/main/java/com/capgo/capacitor_background_geolocation/GeofenceTransitionWorker.java +35 -0
- package/dist/docs.json +740 -4
- package/dist/esm/definitions.d.ts +317 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +17 -1
- package/dist/esm/web.js +108 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +108 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +108 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapgoBackgroundGeolocationPlugin/CapgoCapacitorBackgroundGeolocationPlugin.swift +425 -4
- package/ios/Tests/CapgoBackgroundGeolocationPluginTests/CapgoBackgroundGeolocationPluginTests.swift +5 -0
- package/package.json +17 -10
package/dist/plugin.cjs.js
CHANGED
|
@@ -12,6 +12,10 @@ class BackgroundGeolocationWeb extends core.WebPlugin {
|
|
|
12
12
|
this.plannedRoute = [];
|
|
13
13
|
this.isOffRoute = true;
|
|
14
14
|
this.distanceThreshold = 50;
|
|
15
|
+
this.geofences = new Map();
|
|
16
|
+
this.geofencePayload = {};
|
|
17
|
+
this.notifyOnEntry = true;
|
|
18
|
+
this.notifyOnExit = true;
|
|
15
19
|
}
|
|
16
20
|
async start(options, callback) {
|
|
17
21
|
if (!navigator.geolocation) {
|
|
@@ -50,6 +54,7 @@ class BackgroundGeolocationWeb extends core.WebPlugin {
|
|
|
50
54
|
}
|
|
51
55
|
this.isOffRoute = offRoute;
|
|
52
56
|
}
|
|
57
|
+
this.checkGeofences(position.coords.latitude, position.coords.longitude);
|
|
53
58
|
callback(location);
|
|
54
59
|
}, (error) => {
|
|
55
60
|
const callbackError = {
|
|
@@ -87,6 +92,109 @@ class BackgroundGeolocationWeb extends core.WebPlugin {
|
|
|
87
92
|
this.plannedRoute = options.route || [];
|
|
88
93
|
this.distanceThreshold = options.distance || 50;
|
|
89
94
|
}
|
|
95
|
+
async setupGeofencing(options) {
|
|
96
|
+
var _a, _b, _c;
|
|
97
|
+
if (options.url) {
|
|
98
|
+
new URL(options.url);
|
|
99
|
+
}
|
|
100
|
+
this.geofenceUrl = options.url;
|
|
101
|
+
this.notifyOnEntry = (_a = options.notifyOnEntry) !== null && _a !== void 0 ? _a : true;
|
|
102
|
+
this.notifyOnExit = (_b = options.notifyOnExit) !== null && _b !== void 0 ? _b : true;
|
|
103
|
+
this.geofencePayload = (_c = options.payload) !== null && _c !== void 0 ? _c : {};
|
|
104
|
+
}
|
|
105
|
+
async addGeofence(options) {
|
|
106
|
+
var _a, _b, _c, _d;
|
|
107
|
+
if (!navigator.geolocation) {
|
|
108
|
+
throw new Error('Geolocation is not supported by this browser');
|
|
109
|
+
}
|
|
110
|
+
this.validateGeofence(options.latitude, options.longitude, (_a = options.radius) !== null && _a !== void 0 ? _a : 50, options.identifier);
|
|
111
|
+
this.geofences.set(options.identifier, {
|
|
112
|
+
latitude: options.latitude,
|
|
113
|
+
longitude: options.longitude,
|
|
114
|
+
radius: (_b = options.radius) !== null && _b !== void 0 ? _b : 50,
|
|
115
|
+
identifier: options.identifier,
|
|
116
|
+
notifyOnEntry: (_c = options.notifyOnEntry) !== null && _c !== void 0 ? _c : this.notifyOnEntry,
|
|
117
|
+
notifyOnExit: (_d = options.notifyOnExit) !== null && _d !== void 0 ? _d : this.notifyOnExit,
|
|
118
|
+
payload: options.payload,
|
|
119
|
+
});
|
|
120
|
+
this.startGeofenceWatch();
|
|
121
|
+
}
|
|
122
|
+
async removeGeofence(options) {
|
|
123
|
+
if (!options.identifier) {
|
|
124
|
+
throw new Error('Identifier is required');
|
|
125
|
+
}
|
|
126
|
+
this.geofences.delete(options.identifier);
|
|
127
|
+
this.stopGeofenceWatchIfIdle();
|
|
128
|
+
}
|
|
129
|
+
async removeAllGeofences() {
|
|
130
|
+
this.geofences.clear();
|
|
131
|
+
this.stopGeofenceWatchIfIdle();
|
|
132
|
+
}
|
|
133
|
+
async getMonitoredGeofences() {
|
|
134
|
+
return { regions: Array.from(this.geofences.keys()) };
|
|
135
|
+
}
|
|
136
|
+
validateGeofence(latitude, longitude, radius, identifier) {
|
|
137
|
+
if (!identifier) {
|
|
138
|
+
throw new Error('Identifier is required');
|
|
139
|
+
}
|
|
140
|
+
if (!Number.isFinite(latitude) || latitude < -90 || latitude > 90) {
|
|
141
|
+
throw new Error('Latitude must be between -90 and 90');
|
|
142
|
+
}
|
|
143
|
+
if (!Number.isFinite(longitude) || longitude < -180 || longitude > 180) {
|
|
144
|
+
throw new Error('Longitude must be between -180 and 180');
|
|
145
|
+
}
|
|
146
|
+
if (!Number.isFinite(radius) || radius <= 0) {
|
|
147
|
+
throw new Error('Radius must be greater than 0');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
startGeofenceWatch() {
|
|
151
|
+
if (this.geofenceWatchId !== undefined || this.geofences.size === 0 || !navigator.geolocation) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this.geofenceWatchId = navigator.geolocation.watchPosition((position) => this.checkGeofences(position.coords.latitude, position.coords.longitude), () => undefined, {
|
|
155
|
+
enableHighAccuracy: false,
|
|
156
|
+
timeout: 30000,
|
|
157
|
+
maximumAge: 60000,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
stopGeofenceWatchIfIdle() {
|
|
161
|
+
if (this.geofences.size > 0 || this.geofenceWatchId === undefined) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
navigator.geolocation.clearWatch(this.geofenceWatchId);
|
|
165
|
+
this.geofenceWatchId = undefined;
|
|
166
|
+
}
|
|
167
|
+
checkGeofences(latitude, longitude) {
|
|
168
|
+
const point = [longitude, latitude];
|
|
169
|
+
this.geofences.forEach((geofence) => {
|
|
170
|
+
const distance = this.haversine(point, [geofence.longitude, geofence.latitude]);
|
|
171
|
+
const inside = distance <= geofence.radius;
|
|
172
|
+
const previousInside = geofence.inside;
|
|
173
|
+
geofence.inside = inside;
|
|
174
|
+
if (inside && previousInside !== true && geofence.notifyOnEntry) {
|
|
175
|
+
this.emitGeofenceTransition(geofence, true);
|
|
176
|
+
}
|
|
177
|
+
else if (!inside && previousInside === true && geofence.notifyOnExit) {
|
|
178
|
+
this.emitGeofenceTransition(geofence, false);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
emitGeofenceTransition(geofence, enter) {
|
|
183
|
+
var _a;
|
|
184
|
+
const payload = Object.assign(Object.assign({}, this.geofencePayload), ((_a = geofence.payload) !== null && _a !== void 0 ? _a : {}));
|
|
185
|
+
const event = Object.assign(Object.assign({}, payload), { identifier: geofence.identifier, transition: enter ? 'enter' : 'exit', enter, latitude: geofence.latitude, longitude: geofence.longitude, radius: geofence.radius, payload });
|
|
186
|
+
void this.notifyListeners('geofenceTransition', event);
|
|
187
|
+
if (this.geofenceUrl) {
|
|
188
|
+
void fetch(this.geofenceUrl, {
|
|
189
|
+
method: 'POST',
|
|
190
|
+
headers: {
|
|
191
|
+
Accept: 'application/json',
|
|
192
|
+
'Content-Type': 'application/json',
|
|
193
|
+
},
|
|
194
|
+
body: JSON.stringify(event),
|
|
195
|
+
}).catch(() => undefined);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
90
198
|
toRadians(degrees) {
|
|
91
199
|
return (degrees * Math.PI) / 180;
|
|
92
200
|
}
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst BackgroundGeolocation = registerPlugin('BackgroundGeolocation', {\n web: () => import('./web').then((m) => new m.BackgroundGeolocationWeb()),\n});\nexport * from './definitions';\nexport { BackgroundGeolocation };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class BackgroundGeolocationWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.plannedRoute = [];\n this.isOffRoute = true;\n this.distanceThreshold = 50;\n }\n async start(options, callback) {\n if (!navigator.geolocation) {\n callback(undefined, {\n name: 'GeolocationError',\n message: 'Geolocation is not supported by this browser',\n code: 'NOT_SUPPORTED',\n });\n return;\n }\n if (this.watchId) {\n callback(undefined, {\n name: 'GeolocationError',\n message: 'Geolocation already started',\n code: 'ALREADY_STARTED',\n });\n return;\n }\n this.watchId = navigator.geolocation.watchPosition((position) => {\n const location = {\n latitude: position.coords.latitude,\n longitude: position.coords.longitude,\n accuracy: position.coords.accuracy,\n altitude: position.coords.altitude,\n altitudeAccuracy: position.coords.altitudeAccuracy,\n simulated: false,\n bearing: position.coords.heading,\n speed: position.coords.speed,\n time: position.timestamp,\n };\n if (this.audio && this.plannedRoute.length > 0) {\n const currentPoint = [position.coords.longitude, position.coords.latitude];\n const offRoute = this.distancePointToRoute(currentPoint) > this.distanceThreshold;\n if (offRoute == true && this.isOffRoute === false) {\n this.audio.play();\n }\n this.isOffRoute = offRoute;\n }\n callback(location);\n }, (error) => {\n const callbackError = {\n name: 'GeolocationError',\n message: error.message,\n code: error.code.toString(),\n };\n callback(undefined, callbackError);\n }, {\n enableHighAccuracy: true,\n timeout: 10000,\n maximumAge: options.stale ? 300000 : 0,\n });\n }\n async stop() {\n if (this.watchId) {\n navigator.geolocation.clearWatch(this.watchId);\n delete this.watchId;\n }\n }\n async openSettings() {\n console.log('openSettings: Web implementation cannot open native settings');\n window.alert('Please enable location permissions in your browser settings');\n }\n async setPlannedRoute(options) {\n if (!options.soundFile) {\n throw new Error('Sound file is required');\n }\n if (this.audio) {\n this.audio.pause();\n this.audio.src = '';\n this.audio = undefined;\n }\n this.audio = new Audio(options.soundFile);\n this.plannedRoute = options.route || [];\n this.distanceThreshold = options.distance || 50;\n }\n toRadians(degrees) {\n return (degrees * Math.PI) / 180;\n }\n haversine(point1, point2) {\n const [lon1, lat1] = point1;\n const [lon2, lat2] = point2;\n const dLat = this.toRadians(lat2 - lat1);\n const dLon = this.toRadians(lon2 - lon1);\n const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +\n Math.cos(this.toRadians(lat1)) * Math.cos(this.toRadians(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2);\n const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n return BackgroundGeolocationWeb.EARTH_RADIUS_M * c;\n }\n distancePointToLineSegment(point, lineStart, lineEnd) {\n // Calculate the distances between the three points using Haversine\n const dist_A_B = this.haversine(point, lineStart);\n const dist_A_C = this.haversine(point, lineEnd);\n const dist_B_C = this.haversine(lineStart, lineEnd);\n // Handle the edge case where the line segment is a single point\n if (dist_B_C === 0) {\n return dist_A_B;\n }\n // Check if the angles at the line segment's endpoints are obtuse.\n // We use the Law of Cosines (c^2 = a^2 + b^2 - 2ab*cos(C))\n // If cos(C) < 0, the angle is obtuse.\n // Angle at B (lineStart)\n // Use a small epsilon to handle floating point inaccuracies in division by zero\n const cos_B = (dist_A_B ** 2 + dist_B_C ** 2 - dist_A_C ** 2) / (2 * dist_A_B * dist_B_C + Number.EPSILON);\n if (cos_B < 0) {\n return dist_A_B;\n }\n // Angle at C (lineEnd)\n const cos_C = (dist_A_C ** 2 + dist_B_C ** 2 - dist_A_B ** 2) / (2 * dist_A_C * dist_B_C + Number.EPSILON);\n if (cos_C < 0) {\n return dist_A_C;\n }\n // If both angles are acute, the closest point is on the line segment itself.\n // We can calculate the distance (height of the triangle) using its area.\n // 1. Calculate the semi-perimeter of the triangle ABC\n const s = (dist_A_B + dist_A_C + dist_B_C) / 2;\n // 2. Calculate the area using Heron's formula\n const area = Math.sqrt(Math.max(0, s * (s - dist_A_B) * (s - dist_A_C) * (s - dist_B_C)));\n // 3. The distance is the height of the triangle from point A to the base BC\n // Area = 0.5 * base * height => height = 2 * Area / base\n return (2 * area) / (dist_B_C + Number.EPSILON);\n }\n distancePointToRoute(point) {\n // If the route has less than 2 points, we can't form a segment.\n if (this.plannedRoute.length < 2) {\n if (this.plannedRoute.length === 1) {\n return this.haversine(point, this.plannedRoute[0]);\n }\n return Infinity; // No line segments to measure against\n }\n let minDistance = Infinity;\n for (let i = 0; i < this.plannedRoute.length - 1; i++) {\n const lineStart = this.plannedRoute[i];\n const lineEnd = this.plannedRoute[i + 1];\n const distance = this.distancePointToLineSegment(point, lineStart, lineEnd);\n if (distance < minDistance) {\n minDistance = distance;\n }\n }\n return minDistance;\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\nBackgroundGeolocationWeb.EARTH_RADIUS_M = 6371000;\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,qBAAqB,GAAGA,mBAAc,CAAC,uBAAuB,EAAE;AACtE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,wBAAwB,EAAE,CAAC;AAC5E,CAAC;;ACFM,MAAM,wBAAwB,SAASC,cAAS,CAAC;AACxD,IAAI,WAAW,GAAG;AAClB,QAAQ,KAAK,CAAC,GAAG,SAAS,CAAC;AAC3B,QAAQ,IAAI,CAAC,YAAY,GAAG,EAAE;AAC9B,QAAQ,IAAI,CAAC,UAAU,GAAG,IAAI;AAC9B,QAAQ,IAAI,CAAC,iBAAiB,GAAG,EAAE;AACnC,IAAI;AACJ,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE;AACnC,QAAQ,IAAI,CAAC,SAAS,CAAC,WAA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,CAAC;AACvF,YAAY,IAAI,QAAQ,GAAG,WAAW,EAAE;AACxC,gBAAgB,WAAW,GAAG,QAAQ;AACtC,YAAY;AACZ,QAAQ;AACR,QAAQ,OAAO,WAAW;AAC1B,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;AACA,wBAAwB,CAAC,cAAc,GAAG,OAAO;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst BackgroundGeolocation = registerPlugin('BackgroundGeolocation', {\n web: () => import('./web').then((m) => new m.BackgroundGeolocationWeb()),\n});\nexport * from './definitions';\nexport { BackgroundGeolocation };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class BackgroundGeolocationWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.plannedRoute = [];\n this.isOffRoute = true;\n this.distanceThreshold = 50;\n this.geofences = new Map();\n this.geofencePayload = {};\n this.notifyOnEntry = true;\n this.notifyOnExit = true;\n }\n async start(options, callback) {\n if (!navigator.geolocation) {\n callback(undefined, {\n name: 'GeolocationError',\n message: 'Geolocation is not supported by this browser',\n code: 'NOT_SUPPORTED',\n });\n return;\n }\n if (this.watchId) {\n callback(undefined, {\n name: 'GeolocationError',\n message: 'Geolocation already started',\n code: 'ALREADY_STARTED',\n });\n return;\n }\n this.watchId = navigator.geolocation.watchPosition((position) => {\n const location = {\n latitude: position.coords.latitude,\n longitude: position.coords.longitude,\n accuracy: position.coords.accuracy,\n altitude: position.coords.altitude,\n altitudeAccuracy: position.coords.altitudeAccuracy,\n simulated: false,\n bearing: position.coords.heading,\n speed: position.coords.speed,\n time: position.timestamp,\n };\n if (this.audio && this.plannedRoute.length > 0) {\n const currentPoint = [position.coords.longitude, position.coords.latitude];\n const offRoute = this.distancePointToRoute(currentPoint) > this.distanceThreshold;\n if (offRoute == true && this.isOffRoute === false) {\n this.audio.play();\n }\n this.isOffRoute = offRoute;\n }\n this.checkGeofences(position.coords.latitude, position.coords.longitude);\n callback(location);\n }, (error) => {\n const callbackError = {\n name: 'GeolocationError',\n message: error.message,\n code: error.code.toString(),\n };\n callback(undefined, callbackError);\n }, {\n enableHighAccuracy: true,\n timeout: 10000,\n maximumAge: options.stale ? 300000 : 0,\n });\n }\n async stop() {\n if (this.watchId) {\n navigator.geolocation.clearWatch(this.watchId);\n delete this.watchId;\n }\n }\n async openSettings() {\n console.log('openSettings: Web implementation cannot open native settings');\n window.alert('Please enable location permissions in your browser settings');\n }\n async setPlannedRoute(options) {\n if (!options.soundFile) {\n throw new Error('Sound file is required');\n }\n if (this.audio) {\n this.audio.pause();\n this.audio.src = '';\n this.audio = undefined;\n }\n this.audio = new Audio(options.soundFile);\n this.plannedRoute = options.route || [];\n this.distanceThreshold = options.distance || 50;\n }\n async setupGeofencing(options) {\n var _a, _b, _c;\n if (options.url) {\n new URL(options.url);\n }\n this.geofenceUrl = options.url;\n this.notifyOnEntry = (_a = options.notifyOnEntry) !== null && _a !== void 0 ? _a : true;\n this.notifyOnExit = (_b = options.notifyOnExit) !== null && _b !== void 0 ? _b : true;\n this.geofencePayload = (_c = options.payload) !== null && _c !== void 0 ? _c : {};\n }\n async addGeofence(options) {\n var _a, _b, _c, _d;\n if (!navigator.geolocation) {\n throw new Error('Geolocation is not supported by this browser');\n }\n this.validateGeofence(options.latitude, options.longitude, (_a = options.radius) !== null && _a !== void 0 ? _a : 50, options.identifier);\n this.geofences.set(options.identifier, {\n latitude: options.latitude,\n longitude: options.longitude,\n radius: (_b = options.radius) !== null && _b !== void 0 ? _b : 50,\n identifier: options.identifier,\n notifyOnEntry: (_c = options.notifyOnEntry) !== null && _c !== void 0 ? _c : this.notifyOnEntry,\n notifyOnExit: (_d = options.notifyOnExit) !== null && _d !== void 0 ? _d : this.notifyOnExit,\n payload: options.payload,\n });\n this.startGeofenceWatch();\n }\n async removeGeofence(options) {\n if (!options.identifier) {\n throw new Error('Identifier is required');\n }\n this.geofences.delete(options.identifier);\n this.stopGeofenceWatchIfIdle();\n }\n async removeAllGeofences() {\n this.geofences.clear();\n this.stopGeofenceWatchIfIdle();\n }\n async getMonitoredGeofences() {\n return { regions: Array.from(this.geofences.keys()) };\n }\n validateGeofence(latitude, longitude, radius, identifier) {\n if (!identifier) {\n throw new Error('Identifier is required');\n }\n if (!Number.isFinite(latitude) || latitude < -90 || latitude > 90) {\n throw new Error('Latitude must be between -90 and 90');\n }\n if (!Number.isFinite(longitude) || longitude < -180 || longitude > 180) {\n throw new Error('Longitude must be between -180 and 180');\n }\n if (!Number.isFinite(radius) || radius <= 0) {\n throw new Error('Radius must be greater than 0');\n }\n }\n startGeofenceWatch() {\n if (this.geofenceWatchId !== undefined || this.geofences.size === 0 || !navigator.geolocation) {\n return;\n }\n this.geofenceWatchId = navigator.geolocation.watchPosition((position) => this.checkGeofences(position.coords.latitude, position.coords.longitude), () => undefined, {\n enableHighAccuracy: false,\n timeout: 30000,\n maximumAge: 60000,\n });\n }\n stopGeofenceWatchIfIdle() {\n if (this.geofences.size > 0 || this.geofenceWatchId === undefined) {\n return;\n }\n navigator.geolocation.clearWatch(this.geofenceWatchId);\n this.geofenceWatchId = undefined;\n }\n checkGeofences(latitude, longitude) {\n const point = [longitude, latitude];\n this.geofences.forEach((geofence) => {\n const distance = this.haversine(point, [geofence.longitude, geofence.latitude]);\n const inside = distance <= geofence.radius;\n const previousInside = geofence.inside;\n geofence.inside = inside;\n if (inside && previousInside !== true && geofence.notifyOnEntry) {\n this.emitGeofenceTransition(geofence, true);\n }\n else if (!inside && previousInside === true && geofence.notifyOnExit) {\n this.emitGeofenceTransition(geofence, false);\n }\n });\n }\n emitGeofenceTransition(geofence, enter) {\n var _a;\n const payload = Object.assign(Object.assign({}, this.geofencePayload), ((_a = geofence.payload) !== null && _a !== void 0 ? _a : {}));\n const event = Object.assign(Object.assign({}, payload), { identifier: geofence.identifier, transition: enter ? 'enter' : 'exit', enter, latitude: geofence.latitude, longitude: geofence.longitude, radius: geofence.radius, payload });\n void this.notifyListeners('geofenceTransition', event);\n if (this.geofenceUrl) {\n void fetch(this.geofenceUrl, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(event),\n }).catch(() => undefined);\n }\n }\n toRadians(degrees) {\n return (degrees * Math.PI) / 180;\n }\n haversine(point1, point2) {\n const [lon1, lat1] = point1;\n const [lon2, lat2] = point2;\n const dLat = this.toRadians(lat2 - lat1);\n const dLon = this.toRadians(lon2 - lon1);\n const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +\n Math.cos(this.toRadians(lat1)) * Math.cos(this.toRadians(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2);\n const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n return BackgroundGeolocationWeb.EARTH_RADIUS_M * c;\n }\n distancePointToLineSegment(point, lineStart, lineEnd) {\n // Calculate the distances between the three points using Haversine\n const dist_A_B = this.haversine(point, lineStart);\n const dist_A_C = this.haversine(point, lineEnd);\n const dist_B_C = this.haversine(lineStart, lineEnd);\n // Handle the edge case where the line segment is a single point\n if (dist_B_C === 0) {\n return dist_A_B;\n }\n // Check if the angles at the line segment's endpoints are obtuse.\n // We use the Law of Cosines (c^2 = a^2 + b^2 - 2ab*cos(C))\n // If cos(C) < 0, the angle is obtuse.\n // Angle at B (lineStart)\n // Use a small epsilon to handle floating point inaccuracies in division by zero\n const cos_B = (dist_A_B ** 2 + dist_B_C ** 2 - dist_A_C ** 2) / (2 * dist_A_B * dist_B_C + Number.EPSILON);\n if (cos_B < 0) {\n return dist_A_B;\n }\n // Angle at C (lineEnd)\n const cos_C = (dist_A_C ** 2 + dist_B_C ** 2 - dist_A_B ** 2) / (2 * dist_A_C * dist_B_C + Number.EPSILON);\n if (cos_C < 0) {\n return dist_A_C;\n }\n // If both angles are acute, the closest point is on the line segment itself.\n // We can calculate the distance (height of the triangle) using its area.\n // 1. Calculate the semi-perimeter of the triangle ABC\n const s = (dist_A_B + dist_A_C + dist_B_C) / 2;\n // 2. Calculate the area using Heron's formula\n const area = Math.sqrt(Math.max(0, s * (s - dist_A_B) * (s - dist_A_C) * (s - dist_B_C)));\n // 3. The distance is the height of the triangle from point A to the base BC\n // Area = 0.5 * base * height => height = 2 * Area / base\n return (2 * area) / (dist_B_C + Number.EPSILON);\n }\n distancePointToRoute(point) {\n // If the route has less than 2 points, we can't form a segment.\n if (this.plannedRoute.length < 2) {\n if (this.plannedRoute.length === 1) {\n return this.haversine(point, this.plannedRoute[0]);\n }\n return Infinity; // No line segments to measure against\n }\n let minDistance = Infinity;\n for (let i = 0; i < this.plannedRoute.length - 1; i++) {\n const lineStart = this.plannedRoute[i];\n const lineEnd = this.plannedRoute[i + 1];\n const distance = this.distancePointToLineSegment(point, lineStart, lineEnd);\n if (distance < minDistance) {\n minDistance = distance;\n }\n }\n return minDistance;\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\nBackgroundGeolocationWeb.EARTH_RADIUS_M = 6371000;\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,qBAAqB,GAAGA,mBAAc,CAAC,uBAAuB,EAAE;AACtE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,wBAAwB,EAAE,CAAC;AAC5E,CAAC;;ACFM,MAAM,wBAAwB,SAASC,cAAS,CAAC;AACxD,IAAI,WAAW,GAAG;AAClB,QAAQ,KAAK,CAAC,GAAG,SAAS,CAAC;AAC3B,QAAQ,IAAI,CAAC,YAAY,GAAG,EAAE;AAC9B,QAAQ,IAAI,CAAC,UAAU,GAAG,IAAI;AAC9B,QAAQ,IAAI,CAAC,iBAAiB,GAAG,EAAE;AACnC,QAAQ,IAAI,CAAC,SAAS,GAAG,IAAI,GAA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A0B,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC;AACvF,YAAY,IAAI,QAAQ,GAAG,WAAW,EAAE;AACxC,gBAAgB,WAAW,GAAG,QAAQ;AACtC,YAAY;AACZ,QAAQ;AACR,QAAQ,OAAO,WAAW;AAC1B,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;AACA,wBAAwB,CAAC,cAAc,GAAG,OAAO;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -11,6 +11,10 @@ var capacitorBackgroundGeolocation = (function (exports, core) {
|
|
|
11
11
|
this.plannedRoute = [];
|
|
12
12
|
this.isOffRoute = true;
|
|
13
13
|
this.distanceThreshold = 50;
|
|
14
|
+
this.geofences = new Map();
|
|
15
|
+
this.geofencePayload = {};
|
|
16
|
+
this.notifyOnEntry = true;
|
|
17
|
+
this.notifyOnExit = true;
|
|
14
18
|
}
|
|
15
19
|
async start(options, callback) {
|
|
16
20
|
if (!navigator.geolocation) {
|
|
@@ -49,6 +53,7 @@ var capacitorBackgroundGeolocation = (function (exports, core) {
|
|
|
49
53
|
}
|
|
50
54
|
this.isOffRoute = offRoute;
|
|
51
55
|
}
|
|
56
|
+
this.checkGeofences(position.coords.latitude, position.coords.longitude);
|
|
52
57
|
callback(location);
|
|
53
58
|
}, (error) => {
|
|
54
59
|
const callbackError = {
|
|
@@ -86,6 +91,109 @@ var capacitorBackgroundGeolocation = (function (exports, core) {
|
|
|
86
91
|
this.plannedRoute = options.route || [];
|
|
87
92
|
this.distanceThreshold = options.distance || 50;
|
|
88
93
|
}
|
|
94
|
+
async setupGeofencing(options) {
|
|
95
|
+
var _a, _b, _c;
|
|
96
|
+
if (options.url) {
|
|
97
|
+
new URL(options.url);
|
|
98
|
+
}
|
|
99
|
+
this.geofenceUrl = options.url;
|
|
100
|
+
this.notifyOnEntry = (_a = options.notifyOnEntry) !== null && _a !== void 0 ? _a : true;
|
|
101
|
+
this.notifyOnExit = (_b = options.notifyOnExit) !== null && _b !== void 0 ? _b : true;
|
|
102
|
+
this.geofencePayload = (_c = options.payload) !== null && _c !== void 0 ? _c : {};
|
|
103
|
+
}
|
|
104
|
+
async addGeofence(options) {
|
|
105
|
+
var _a, _b, _c, _d;
|
|
106
|
+
if (!navigator.geolocation) {
|
|
107
|
+
throw new Error('Geolocation is not supported by this browser');
|
|
108
|
+
}
|
|
109
|
+
this.validateGeofence(options.latitude, options.longitude, (_a = options.radius) !== null && _a !== void 0 ? _a : 50, options.identifier);
|
|
110
|
+
this.geofences.set(options.identifier, {
|
|
111
|
+
latitude: options.latitude,
|
|
112
|
+
longitude: options.longitude,
|
|
113
|
+
radius: (_b = options.radius) !== null && _b !== void 0 ? _b : 50,
|
|
114
|
+
identifier: options.identifier,
|
|
115
|
+
notifyOnEntry: (_c = options.notifyOnEntry) !== null && _c !== void 0 ? _c : this.notifyOnEntry,
|
|
116
|
+
notifyOnExit: (_d = options.notifyOnExit) !== null && _d !== void 0 ? _d : this.notifyOnExit,
|
|
117
|
+
payload: options.payload,
|
|
118
|
+
});
|
|
119
|
+
this.startGeofenceWatch();
|
|
120
|
+
}
|
|
121
|
+
async removeGeofence(options) {
|
|
122
|
+
if (!options.identifier) {
|
|
123
|
+
throw new Error('Identifier is required');
|
|
124
|
+
}
|
|
125
|
+
this.geofences.delete(options.identifier);
|
|
126
|
+
this.stopGeofenceWatchIfIdle();
|
|
127
|
+
}
|
|
128
|
+
async removeAllGeofences() {
|
|
129
|
+
this.geofences.clear();
|
|
130
|
+
this.stopGeofenceWatchIfIdle();
|
|
131
|
+
}
|
|
132
|
+
async getMonitoredGeofences() {
|
|
133
|
+
return { regions: Array.from(this.geofences.keys()) };
|
|
134
|
+
}
|
|
135
|
+
validateGeofence(latitude, longitude, radius, identifier) {
|
|
136
|
+
if (!identifier) {
|
|
137
|
+
throw new Error('Identifier is required');
|
|
138
|
+
}
|
|
139
|
+
if (!Number.isFinite(latitude) || latitude < -90 || latitude > 90) {
|
|
140
|
+
throw new Error('Latitude must be between -90 and 90');
|
|
141
|
+
}
|
|
142
|
+
if (!Number.isFinite(longitude) || longitude < -180 || longitude > 180) {
|
|
143
|
+
throw new Error('Longitude must be between -180 and 180');
|
|
144
|
+
}
|
|
145
|
+
if (!Number.isFinite(radius) || radius <= 0) {
|
|
146
|
+
throw new Error('Radius must be greater than 0');
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
startGeofenceWatch() {
|
|
150
|
+
if (this.geofenceWatchId !== undefined || this.geofences.size === 0 || !navigator.geolocation) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
this.geofenceWatchId = navigator.geolocation.watchPosition((position) => this.checkGeofences(position.coords.latitude, position.coords.longitude), () => undefined, {
|
|
154
|
+
enableHighAccuracy: false,
|
|
155
|
+
timeout: 30000,
|
|
156
|
+
maximumAge: 60000,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
stopGeofenceWatchIfIdle() {
|
|
160
|
+
if (this.geofences.size > 0 || this.geofenceWatchId === undefined) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
navigator.geolocation.clearWatch(this.geofenceWatchId);
|
|
164
|
+
this.geofenceWatchId = undefined;
|
|
165
|
+
}
|
|
166
|
+
checkGeofences(latitude, longitude) {
|
|
167
|
+
const point = [longitude, latitude];
|
|
168
|
+
this.geofences.forEach((geofence) => {
|
|
169
|
+
const distance = this.haversine(point, [geofence.longitude, geofence.latitude]);
|
|
170
|
+
const inside = distance <= geofence.radius;
|
|
171
|
+
const previousInside = geofence.inside;
|
|
172
|
+
geofence.inside = inside;
|
|
173
|
+
if (inside && previousInside !== true && geofence.notifyOnEntry) {
|
|
174
|
+
this.emitGeofenceTransition(geofence, true);
|
|
175
|
+
}
|
|
176
|
+
else if (!inside && previousInside === true && geofence.notifyOnExit) {
|
|
177
|
+
this.emitGeofenceTransition(geofence, false);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
emitGeofenceTransition(geofence, enter) {
|
|
182
|
+
var _a;
|
|
183
|
+
const payload = Object.assign(Object.assign({}, this.geofencePayload), ((_a = geofence.payload) !== null && _a !== void 0 ? _a : {}));
|
|
184
|
+
const event = Object.assign(Object.assign({}, payload), { identifier: geofence.identifier, transition: enter ? 'enter' : 'exit', enter, latitude: geofence.latitude, longitude: geofence.longitude, radius: geofence.radius, payload });
|
|
185
|
+
void this.notifyListeners('geofenceTransition', event);
|
|
186
|
+
if (this.geofenceUrl) {
|
|
187
|
+
void fetch(this.geofenceUrl, {
|
|
188
|
+
method: 'POST',
|
|
189
|
+
headers: {
|
|
190
|
+
Accept: 'application/json',
|
|
191
|
+
'Content-Type': 'application/json',
|
|
192
|
+
},
|
|
193
|
+
body: JSON.stringify(event),
|
|
194
|
+
}).catch(() => undefined);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
89
197
|
toRadians(degrees) {
|
|
90
198
|
return (degrees * Math.PI) / 180;
|
|
91
199
|
}
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst BackgroundGeolocation = registerPlugin('BackgroundGeolocation', {\n web: () => import('./web').then((m) => new m.BackgroundGeolocationWeb()),\n});\nexport * from './definitions';\nexport { BackgroundGeolocation };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class BackgroundGeolocationWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.plannedRoute = [];\n this.isOffRoute = true;\n this.distanceThreshold = 50;\n }\n async start(options, callback) {\n if (!navigator.geolocation) {\n callback(undefined, {\n name: 'GeolocationError',\n message: 'Geolocation is not supported by this browser',\n code: 'NOT_SUPPORTED',\n });\n return;\n }\n if (this.watchId) {\n callback(undefined, {\n name: 'GeolocationError',\n message: 'Geolocation already started',\n code: 'ALREADY_STARTED',\n });\n return;\n }\n this.watchId = navigator.geolocation.watchPosition((position) => {\n const location = {\n latitude: position.coords.latitude,\n longitude: position.coords.longitude,\n accuracy: position.coords.accuracy,\n altitude: position.coords.altitude,\n altitudeAccuracy: position.coords.altitudeAccuracy,\n simulated: false,\n bearing: position.coords.heading,\n speed: position.coords.speed,\n time: position.timestamp,\n };\n if (this.audio && this.plannedRoute.length > 0) {\n const currentPoint = [position.coords.longitude, position.coords.latitude];\n const offRoute = this.distancePointToRoute(currentPoint) > this.distanceThreshold;\n if (offRoute == true && this.isOffRoute === false) {\n this.audio.play();\n }\n this.isOffRoute = offRoute;\n }\n callback(location);\n }, (error) => {\n const callbackError = {\n name: 'GeolocationError',\n message: error.message,\n code: error.code.toString(),\n };\n callback(undefined, callbackError);\n }, {\n enableHighAccuracy: true,\n timeout: 10000,\n maximumAge: options.stale ? 300000 : 0,\n });\n }\n async stop() {\n if (this.watchId) {\n navigator.geolocation.clearWatch(this.watchId);\n delete this.watchId;\n }\n }\n async openSettings() {\n console.log('openSettings: Web implementation cannot open native settings');\n window.alert('Please enable location permissions in your browser settings');\n }\n async setPlannedRoute(options) {\n if (!options.soundFile) {\n throw new Error('Sound file is required');\n }\n if (this.audio) {\n this.audio.pause();\n this.audio.src = '';\n this.audio = undefined;\n }\n this.audio = new Audio(options.soundFile);\n this.plannedRoute = options.route || [];\n this.distanceThreshold = options.distance || 50;\n }\n toRadians(degrees) {\n return (degrees * Math.PI) / 180;\n }\n haversine(point1, point2) {\n const [lon1, lat1] = point1;\n const [lon2, lat2] = point2;\n const dLat = this.toRadians(lat2 - lat1);\n const dLon = this.toRadians(lon2 - lon1);\n const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +\n Math.cos(this.toRadians(lat1)) * Math.cos(this.toRadians(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2);\n const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n return BackgroundGeolocationWeb.EARTH_RADIUS_M * c;\n }\n distancePointToLineSegment(point, lineStart, lineEnd) {\n // Calculate the distances between the three points using Haversine\n const dist_A_B = this.haversine(point, lineStart);\n const dist_A_C = this.haversine(point, lineEnd);\n const dist_B_C = this.haversine(lineStart, lineEnd);\n // Handle the edge case where the line segment is a single point\n if (dist_B_C === 0) {\n return dist_A_B;\n }\n // Check if the angles at the line segment's endpoints are obtuse.\n // We use the Law of Cosines (c^2 = a^2 + b^2 - 2ab*cos(C))\n // If cos(C) < 0, the angle is obtuse.\n // Angle at B (lineStart)\n // Use a small epsilon to handle floating point inaccuracies in division by zero\n const cos_B = (dist_A_B ** 2 + dist_B_C ** 2 - dist_A_C ** 2) / (2 * dist_A_B * dist_B_C + Number.EPSILON);\n if (cos_B < 0) {\n return dist_A_B;\n }\n // Angle at C (lineEnd)\n const cos_C = (dist_A_C ** 2 + dist_B_C ** 2 - dist_A_B ** 2) / (2 * dist_A_C * dist_B_C + Number.EPSILON);\n if (cos_C < 0) {\n return dist_A_C;\n }\n // If both angles are acute, the closest point is on the line segment itself.\n // We can calculate the distance (height of the triangle) using its area.\n // 1. Calculate the semi-perimeter of the triangle ABC\n const s = (dist_A_B + dist_A_C + dist_B_C) / 2;\n // 2. Calculate the area using Heron's formula\n const area = Math.sqrt(Math.max(0, s * (s - dist_A_B) * (s - dist_A_C) * (s - dist_B_C)));\n // 3. The distance is the height of the triangle from point A to the base BC\n // Area = 0.5 * base * height => height = 2 * Area / base\n return (2 * area) / (dist_B_C + Number.EPSILON);\n }\n distancePointToRoute(point) {\n // If the route has less than 2 points, we can't form a segment.\n if (this.plannedRoute.length < 2) {\n if (this.plannedRoute.length === 1) {\n return this.haversine(point, this.plannedRoute[0]);\n }\n return Infinity; // No line segments to measure against\n }\n let minDistance = Infinity;\n for (let i = 0; i < this.plannedRoute.length - 1; i++) {\n const lineStart = this.plannedRoute[i];\n const lineEnd = this.plannedRoute[i + 1];\n const distance = this.distancePointToLineSegment(point, lineStart, lineEnd);\n if (distance < minDistance) {\n minDistance = distance;\n }\n }\n return minDistance;\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\nBackgroundGeolocationWeb.EARTH_RADIUS_M = 6371000;\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,qBAAqB,GAAGA,mBAAc,CAAC,uBAAuB,EAAE;IACtE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,wBAAwB,EAAE,CAAC;IAC5E,CAAC;;ICFM,MAAM,wBAAwB,SAASC,cAAS,CAAC;IACxD,IAAI,WAAW,GAAG;IAClB,QAAQ,KAAK,CAAC,GAAG,SAAS,CAAC;IAC3B,QAAQ,IAAI,CAAC,YAAY,GAAG,EAAE;IAC9B,QAAQ,IAAI,CAAC,UAAU,GAAG,IAAI;IAC9B,QAAQ,IAAI,CAAC,iBAAiB,GAAG,EAAE;IACnC,IAAI;IACJ,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE;IACnC,QAAQ,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;IACpC,YAAY,QAAQ,CAAC,SAAS,EAAE;IAChC,gBAAgB,IAAI,EAAE,kBAAkB;IACxC,gBAAgB,OAAO,EAAE,8CAA8C;IACvE,gBAAgB,IAAI,EAAE,eAAe;IACrC,aAAa,CAAC;IACd,YAAY;IACZ,QAAQ;IACR,QAAQ,IAAI,IAAI,CAAC,OAAO,EAAE;IAC1B,YAAY,QAAQ,CAAC,SAAS,EAAE;IAChC,gBAAgB,IAAI,EAAE,kBAAkB;IACxC,gBAAgB,OAAO,EAAE,6BAA6B;IACtD,gBAAgB,IAAI,EAAE,iBAAiB;IACvC,aAAa,CAAC;IACd,YAAY;IACZ,QAAQ;IACR,QAAQ,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,QAAQ,KAAK;IACzE,YAAY,MAAM,QAAQ,GAAG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IAChC;IACA,QAAQ,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;IAC1C,YAAY,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;IAChD,gBAAgB,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAClE,YAAY;IACZ,YAAY,OAAO,QAAQ,CAAC;IAC5B,QAAQ;IACR,QAAQ,IAAI,WAAW,GAAG,QAAQ;IAClC,QAAQ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;IAC/D,YAAY,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAClD,YAAY,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC;IACpD,YAAY,MAAM,QAAQ,GAAG,IAAI,CAAC,0BAA0B,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC;IACvF,YAAY,IAAI,QAAQ,GAAG,WAAW,EAAE;IACxC,gBAAgB,WAAW,GAAG,QAAQ;IACtC,YAAY;IACZ,QAAQ;IACR,QAAQ,OAAO,WAAW;IAC1B,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;IACA,wBAAwB,CAAC,cAAc,GAAG,OAAO;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst BackgroundGeolocation = registerPlugin('BackgroundGeolocation', {\n web: () => import('./web').then((m) => new m.BackgroundGeolocationWeb()),\n});\nexport * from './definitions';\nexport { BackgroundGeolocation };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class BackgroundGeolocationWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.plannedRoute = [];\n this.isOffRoute = true;\n this.distanceThreshold = 50;\n this.geofences = new Map();\n this.geofencePayload = {};\n this.notifyOnEntry = true;\n this.notifyOnExit = true;\n }\n async start(options, callback) {\n if (!navigator.geolocation) {\n callback(undefined, {\n name: 'GeolocationError',\n message: 'Geolocation is not supported by this browser',\n code: 'NOT_SUPPORTED',\n });\n return;\n }\n if (this.watchId) {\n callback(undefined, {\n name: 'GeolocationError',\n message: 'Geolocation already started',\n code: 'ALREADY_STARTED',\n });\n return;\n }\n this.watchId = navigator.geolocation.watchPosition((position) => {\n const location = {\n latitude: position.coords.latitude,\n longitude: position.coords.longitude,\n accuracy: position.coords.accuracy,\n altitude: position.coords.altitude,\n altitudeAccuracy: position.coords.altitudeAccuracy,\n simulated: false,\n bearing: position.coords.heading,\n speed: position.coords.speed,\n time: position.timestamp,\n };\n if (this.audio && this.plannedRoute.length > 0) {\n const currentPoint = [position.coords.longitude, position.coords.latitude];\n const offRoute = this.distancePointToRoute(currentPoint) > this.distanceThreshold;\n if (offRoute == true && this.isOffRoute === false) {\n this.audio.play();\n }\n this.isOffRoute = offRoute;\n }\n this.checkGeofences(position.coords.latitude, position.coords.longitude);\n callback(location);\n }, (error) => {\n const callbackError = {\n name: 'GeolocationError',\n message: error.message,\n code: error.code.toString(),\n };\n callback(undefined, callbackError);\n }, {\n enableHighAccuracy: true,\n timeout: 10000,\n maximumAge: options.stale ? 300000 : 0,\n });\n }\n async stop() {\n if (this.watchId) {\n navigator.geolocation.clearWatch(this.watchId);\n delete this.watchId;\n }\n }\n async openSettings() {\n console.log('openSettings: Web implementation cannot open native settings');\n window.alert('Please enable location permissions in your browser settings');\n }\n async setPlannedRoute(options) {\n if (!options.soundFile) {\n throw new Error('Sound file is required');\n }\n if (this.audio) {\n this.audio.pause();\n this.audio.src = '';\n this.audio = undefined;\n }\n this.audio = new Audio(options.soundFile);\n this.plannedRoute = options.route || [];\n this.distanceThreshold = options.distance || 50;\n }\n async setupGeofencing(options) {\n var _a, _b, _c;\n if (options.url) {\n new URL(options.url);\n }\n this.geofenceUrl = options.url;\n this.notifyOnEntry = (_a = options.notifyOnEntry) !== null && _a !== void 0 ? _a : true;\n this.notifyOnExit = (_b = options.notifyOnExit) !== null && _b !== void 0 ? _b : true;\n this.geofencePayload = (_c = options.payload) !== null && _c !== void 0 ? _c : {};\n }\n async addGeofence(options) {\n var _a, _b, _c, _d;\n if (!navigator.geolocation) {\n throw new Error('Geolocation is not supported by this browser');\n }\n this.validateGeofence(options.latitude, options.longitude, (_a = options.radius) !== null && _a !== void 0 ? _a : 50, options.identifier);\n this.geofences.set(options.identifier, {\n latitude: options.latitude,\n longitude: options.longitude,\n radius: (_b = options.radius) !== null && _b !== void 0 ? _b : 50,\n identifier: options.identifier,\n notifyOnEntry: (_c = options.notifyOnEntry) !== null && _c !== void 0 ? _c : this.notifyOnEntry,\n notifyOnExit: (_d = options.notifyOnExit) !== null && _d !== void 0 ? _d : this.notifyOnExit,\n payload: options.payload,\n });\n this.startGeofenceWatch();\n }\n async removeGeofence(options) {\n if (!options.identifier) {\n throw new Error('Identifier is required');\n }\n this.geofences.delete(options.identifier);\n this.stopGeofenceWatchIfIdle();\n }\n async removeAllGeofences() {\n this.geofences.clear();\n this.stopGeofenceWatchIfIdle();\n }\n async getMonitoredGeofences() {\n return { regions: Array.from(this.geofences.keys()) };\n }\n validateGeofence(latitude, longitude, radius, identifier) {\n if (!identifier) {\n throw new Error('Identifier is required');\n }\n if (!Number.isFinite(latitude) || latitude < -90 || latitude > 90) {\n throw new Error('Latitude must be between -90 and 90');\n }\n if (!Number.isFinite(longitude) || longitude < -180 || longitude > 180) {\n throw new Error('Longitude must be between -180 and 180');\n }\n if (!Number.isFinite(radius) || radius <= 0) {\n throw new Error('Radius must be greater than 0');\n }\n }\n startGeofenceWatch() {\n if (this.geofenceWatchId !== undefined || this.geofences.size === 0 || !navigator.geolocation) {\n return;\n }\n this.geofenceWatchId = navigator.geolocation.watchPosition((position) => this.checkGeofences(position.coords.latitude, position.coords.longitude), () => undefined, {\n enableHighAccuracy: false,\n timeout: 30000,\n maximumAge: 60000,\n });\n }\n stopGeofenceWatchIfIdle() {\n if (this.geofences.size > 0 || this.geofenceWatchId === undefined) {\n return;\n }\n navigator.geolocation.clearWatch(this.geofenceWatchId);\n this.geofenceWatchId = undefined;\n }\n checkGeofences(latitude, longitude) {\n const point = [longitude, latitude];\n this.geofences.forEach((geofence) => {\n const distance = this.haversine(point, [geofence.longitude, geofence.latitude]);\n const inside = distance <= geofence.radius;\n const previousInside = geofence.inside;\n geofence.inside = inside;\n if (inside && previousInside !== true && geofence.notifyOnEntry) {\n this.emitGeofenceTransition(geofence, true);\n }\n else if (!inside && previousInside === true && geofence.notifyOnExit) {\n this.emitGeofenceTransition(geofence, false);\n }\n });\n }\n emitGeofenceTransition(geofence, enter) {\n var _a;\n const payload = Object.assign(Object.assign({}, this.geofencePayload), ((_a = geofence.payload) !== null && _a !== void 0 ? _a : {}));\n const event = Object.assign(Object.assign({}, payload), { identifier: geofence.identifier, transition: enter ? 'enter' : 'exit', enter, latitude: geofence.latitude, longitude: geofence.longitude, radius: geofence.radius, payload });\n void this.notifyListeners('geofenceTransition', event);\n if (this.geofenceUrl) {\n void fetch(this.geofenceUrl, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(event),\n }).catch(() => undefined);\n }\n }\n toRadians(degrees) {\n return (degrees * Math.PI) / 180;\n }\n haversine(point1, point2) {\n const [lon1, lat1] = point1;\n const [lon2, lat2] = point2;\n const dLat = this.toRadians(lat2 - lat1);\n const dLon = this.toRadians(lon2 - lon1);\n const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +\n Math.cos(this.toRadians(lat1)) * Math.cos(this.toRadians(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2);\n const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n return BackgroundGeolocationWeb.EARTH_RADIUS_M * c;\n }\n distancePointToLineSegment(point, lineStart, lineEnd) {\n // Calculate the distances between the three points using Haversine\n const dist_A_B = this.haversine(point, lineStart);\n const dist_A_C = this.haversine(point, lineEnd);\n const dist_B_C = this.haversine(lineStart, lineEnd);\n // Handle the edge case where the line segment is a single point\n if (dist_B_C === 0) {\n return dist_A_B;\n }\n // Check if the angles at the line segment's endpoints are obtuse.\n // We use the Law of Cosines (c^2 = a^2 + b^2 - 2ab*cos(C))\n // If cos(C) < 0, the angle is obtuse.\n // Angle at B (lineStart)\n // Use a small epsilon to handle floating point inaccuracies in division by zero\n const cos_B = (dist_A_B ** 2 + dist_B_C ** 2 - dist_A_C ** 2) / (2 * dist_A_B * dist_B_C + Number.EPSILON);\n if (cos_B < 0) {\n return dist_A_B;\n }\n // Angle at C (lineEnd)\n const cos_C = (dist_A_C ** 2 + dist_B_C ** 2 - dist_A_B ** 2) / (2 * dist_A_C * dist_B_C + Number.EPSILON);\n if (cos_C < 0) {\n return dist_A_C;\n }\n // If both angles are acute, the closest point is on the line segment itself.\n // We can calculate the distance (height of the triangle) using its area.\n // 1. Calculate the semi-perimeter of the triangle ABC\n const s = (dist_A_B + dist_A_C + dist_B_C) / 2;\n // 2. Calculate the area using Heron's formula\n const area = Math.sqrt(Math.max(0, s * (s - dist_A_B) * (s - dist_A_C) * (s - dist_B_C)));\n // 3. The distance is the height of the triangle from point A to the base BC\n // Area = 0.5 * base * height => height = 2 * Area / base\n return (2 * area) / (dist_B_C + Number.EPSILON);\n }\n distancePointToRoute(point) {\n // If the route has less than 2 points, we can't form a segment.\n if (this.plannedRoute.length < 2) {\n if (this.plannedRoute.length === 1) {\n return this.haversine(point, this.plannedRoute[0]);\n }\n return Infinity; // No line segments to measure against\n }\n let minDistance = Infinity;\n for (let i = 0; i < this.plannedRoute.length - 1; i++) {\n const lineStart = this.plannedRoute[i];\n const lineEnd = this.plannedRoute[i + 1];\n const distance = this.distancePointToLineSegment(point, lineStart, lineEnd);\n if (distance < minDistance) {\n minDistance = distance;\n }\n }\n return minDistance;\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\nBackgroundGeolocationWeb.EARTH_RADIUS_M = 6371000;\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,qBAAqB,GAAGA,mBAAc,CAAC,uBAAuB,EAAE;IACtE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,wBAAwB,EAAE,CAAC;IAC5E,CAAC;;ICFM,MAAM,wBAAwB,SAASC,cAAS,CAAC;IACxD,IAAI,WAAW,GAAG;IAClB,QAAQ,KAAK,CAAC,GAAG,SAAS,CAAC;IAC3B,QAAQ,IAAI,CAAC,YAAY,GAAG,EAAE;IAC9B,QAAQ,IAAI,CAAC,UAAU,GAAG,IAAI;IAC9B,QAAQ,IAAI,CAAC,iBAAiB,GAAG,EAAE;IACnC,QAAQ,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAE;IAClC,QAAQ,IAAI,CAAC,eAAe,GAAG,EAAE;IACjC,QAAQ,IAAI,CAAC,aAAa,GAAG,IAAI;IACjC,QAAQ,IAAI,CAAC,YAAY,GAAG,IAAI;IAChC,IAAI;IACJ,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE;IACnC,QAAQ,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;IACpC,YAAY,QAAQ,CAAC,SAAS,EAAE;IAChC,gBAAgB,IAAI,EAAE,kBAAkB;IACxC,gBAAgB,OAAO,EAAE,8CAA8C;IACvE,gBAAgB,IAAI,EAAE,eAAe;IACrC,aAAa,CAAC;IACd,YAAY;IACZ,QAAQ;IACR,QAAQ,IAAI,IAAI,CAAC,OAAO,EAAE;IAC1B,YAAY,QAAQ,CAAC,SAAS,EAAE;IAChC,gBAAgB,IAAI,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