@elizaos/capacitor-location 1.0.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/ElizaosCapacitorLocation.podspec +17 -0
- package/android/build.gradle +45 -0
- package/android/src/main/AndroidManifest.xml +5 -0
- package/android/src/main/java/ai/eliza/plugins/location/LocationPlugin.kt +346 -0
- package/dist/esm/definitions.d.ts +133 -0
- package/dist/esm/definitions.d.ts.map +1 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +20 -0
- package/dist/esm/web.d.ts.map +1 -0
- package/dist/esm/web.js +133 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +148 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +151 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/LocationPlugin/LocationPlugin.swift +391 -0
- package/package.json +83 -0
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { WebPlugin } from "@capacitor/core";
|
|
2
|
+
/**
|
|
3
|
+
* Web implementation of the Location Plugin
|
|
4
|
+
*
|
|
5
|
+
* Uses the browser Geolocation API.
|
|
6
|
+
*/
|
|
7
|
+
export class LocationWeb extends WebPlugin {
|
|
8
|
+
watches = new Map();
|
|
9
|
+
async getCurrentPosition(options) {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
const geoOptions = {
|
|
12
|
+
enableHighAccuracy: options?.accuracy === "best" || options?.accuracy === "high",
|
|
13
|
+
maximumAge: options?.maxAge ?? 0,
|
|
14
|
+
timeout: options?.timeout ?? 10000,
|
|
15
|
+
};
|
|
16
|
+
navigator.geolocation.getCurrentPosition((position) => {
|
|
17
|
+
resolve({
|
|
18
|
+
coords: {
|
|
19
|
+
latitude: position.coords.latitude,
|
|
20
|
+
longitude: position.coords.longitude,
|
|
21
|
+
altitude: position.coords.altitude ?? undefined,
|
|
22
|
+
accuracy: position.coords.accuracy,
|
|
23
|
+
altitudeAccuracy: position.coords.altitudeAccuracy ?? undefined,
|
|
24
|
+
speed: position.coords.speed ?? undefined,
|
|
25
|
+
heading: position.coords.heading ?? undefined,
|
|
26
|
+
timestamp: position.timestamp,
|
|
27
|
+
},
|
|
28
|
+
cached: false,
|
|
29
|
+
});
|
|
30
|
+
}, (error) => {
|
|
31
|
+
let code;
|
|
32
|
+
switch (error.code) {
|
|
33
|
+
case error.PERMISSION_DENIED:
|
|
34
|
+
code = "PERMISSION_DENIED";
|
|
35
|
+
break;
|
|
36
|
+
case error.POSITION_UNAVAILABLE:
|
|
37
|
+
code = "POSITION_UNAVAILABLE";
|
|
38
|
+
break;
|
|
39
|
+
case error.TIMEOUT:
|
|
40
|
+
code = "TIMEOUT";
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
code = "UNKNOWN";
|
|
44
|
+
}
|
|
45
|
+
reject({ code, message: error.message });
|
|
46
|
+
}, geoOptions);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async watchPosition(options) {
|
|
50
|
+
const watchId = `watch-${Date.now()}-${Math.random().toString(36).substring(7)}`;
|
|
51
|
+
const geoOptions = {
|
|
52
|
+
enableHighAccuracy: options?.accuracy === "best" || options?.accuracy === "high",
|
|
53
|
+
maximumAge: options?.maxAge ?? 0,
|
|
54
|
+
timeout: options?.timeout ?? 10000,
|
|
55
|
+
};
|
|
56
|
+
const nativeWatchId = navigator.geolocation.watchPosition((position) => {
|
|
57
|
+
this.notifyListeners("locationChange", {
|
|
58
|
+
coords: {
|
|
59
|
+
latitude: position.coords.latitude,
|
|
60
|
+
longitude: position.coords.longitude,
|
|
61
|
+
altitude: position.coords.altitude ?? undefined,
|
|
62
|
+
accuracy: position.coords.accuracy,
|
|
63
|
+
altitudeAccuracy: position.coords.altitudeAccuracy ?? undefined,
|
|
64
|
+
speed: position.coords.speed ?? undefined,
|
|
65
|
+
heading: position.coords.heading ?? undefined,
|
|
66
|
+
timestamp: position.timestamp,
|
|
67
|
+
},
|
|
68
|
+
cached: false,
|
|
69
|
+
});
|
|
70
|
+
}, (error) => {
|
|
71
|
+
let code;
|
|
72
|
+
switch (error.code) {
|
|
73
|
+
case error.PERMISSION_DENIED:
|
|
74
|
+
code = "PERMISSION_DENIED";
|
|
75
|
+
break;
|
|
76
|
+
case error.POSITION_UNAVAILABLE:
|
|
77
|
+
code = "POSITION_UNAVAILABLE";
|
|
78
|
+
break;
|
|
79
|
+
case error.TIMEOUT:
|
|
80
|
+
code = "TIMEOUT";
|
|
81
|
+
break;
|
|
82
|
+
default:
|
|
83
|
+
code = "UNKNOWN";
|
|
84
|
+
}
|
|
85
|
+
this.notifyListeners("error", { code, message: error.message });
|
|
86
|
+
}, geoOptions);
|
|
87
|
+
this.watches.set(watchId, nativeWatchId);
|
|
88
|
+
return { watchId };
|
|
89
|
+
}
|
|
90
|
+
async clearWatch(options) {
|
|
91
|
+
const nativeWatchId = this.watches.get(options.watchId);
|
|
92
|
+
if (nativeWatchId !== undefined) {
|
|
93
|
+
navigator.geolocation.clearWatch(nativeWatchId);
|
|
94
|
+
this.watches.delete(options.watchId);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async checkPermissions() {
|
|
98
|
+
if ("permissions" in navigator) {
|
|
99
|
+
try {
|
|
100
|
+
const result = await navigator.permissions.query({
|
|
101
|
+
name: "geolocation",
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
location: result.state === "granted"
|
|
105
|
+
? "granted"
|
|
106
|
+
: result.state === "denied"
|
|
107
|
+
? "denied"
|
|
108
|
+
: "prompt",
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return { location: "prompt" };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return { location: "prompt" };
|
|
116
|
+
}
|
|
117
|
+
async requestPermissions() {
|
|
118
|
+
// On web, permissions are requested implicitly when calling getCurrentPosition
|
|
119
|
+
// Try to get current position to trigger permission request
|
|
120
|
+
try {
|
|
121
|
+
await this.getCurrentPosition({ timeout: 5000 });
|
|
122
|
+
return { location: "granted" };
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
const e = error;
|
|
126
|
+
if (e.code === "PERMISSION_DENIED") {
|
|
127
|
+
return { location: "denied" };
|
|
128
|
+
}
|
|
129
|
+
return { location: "prompt" };
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAS5C;;;;GAIG;AACH,MAAM,OAAO,WAAY,SAAQ,SAAS;IAChC,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE5C,KAAK,CAAC,kBAAkB,CAAC,OAAyB;QAChD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,UAAU,GAAoB;gBAClC,kBAAkB,EAChB,OAAO,EAAE,QAAQ,KAAK,MAAM,IAAI,OAAO,EAAE,QAAQ,KAAK,MAAM;gBAC9D,UAAU,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;gBAChC,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,KAAK;aACnC,CAAC;YAEF,SAAS,CAAC,WAAW,CAAC,kBAAkB,CACtC,CAAC,QAAQ,EAAE,EAAE;gBACX,OAAO,CAAC;oBACN,MAAM,EAAE;wBACN,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ;wBAClC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS;wBACpC,QAAQ,EAAE,QAA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YACjD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;QACjC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,GAAG,KAAyB,CAAC;YACpC,IAAI,CAAC,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;gBACnC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;YAChC,CAAC;YACD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;QAChC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@capacitor/core');
|
|
4
|
+
|
|
5
|
+
const loadWeb = () => Promise.resolve().then(function () { return web; }).then((m) => new m.LocationWeb());
|
|
6
|
+
const Location = core.registerPlugin("ElizaLocation", {
|
|
7
|
+
web: loadWeb,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Web implementation of the Location Plugin
|
|
12
|
+
*
|
|
13
|
+
* Uses the browser Geolocation API.
|
|
14
|
+
*/
|
|
15
|
+
class LocationWeb extends core.WebPlugin {
|
|
16
|
+
watches = new Map();
|
|
17
|
+
async getCurrentPosition(options) {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
const geoOptions = {
|
|
20
|
+
enableHighAccuracy: options?.accuracy === "best" || options?.accuracy === "high",
|
|
21
|
+
maximumAge: options?.maxAge ?? 0,
|
|
22
|
+
timeout: options?.timeout ?? 10000,
|
|
23
|
+
};
|
|
24
|
+
navigator.geolocation.getCurrentPosition((position) => {
|
|
25
|
+
resolve({
|
|
26
|
+
coords: {
|
|
27
|
+
latitude: position.coords.latitude,
|
|
28
|
+
longitude: position.coords.longitude,
|
|
29
|
+
altitude: position.coords.altitude ?? undefined,
|
|
30
|
+
accuracy: position.coords.accuracy,
|
|
31
|
+
altitudeAccuracy: position.coords.altitudeAccuracy ?? undefined,
|
|
32
|
+
speed: position.coords.speed ?? undefined,
|
|
33
|
+
heading: position.coords.heading ?? undefined,
|
|
34
|
+
timestamp: position.timestamp,
|
|
35
|
+
},
|
|
36
|
+
cached: false,
|
|
37
|
+
});
|
|
38
|
+
}, (error) => {
|
|
39
|
+
let code;
|
|
40
|
+
switch (error.code) {
|
|
41
|
+
case error.PERMISSION_DENIED:
|
|
42
|
+
code = "PERMISSION_DENIED";
|
|
43
|
+
break;
|
|
44
|
+
case error.POSITION_UNAVAILABLE:
|
|
45
|
+
code = "POSITION_UNAVAILABLE";
|
|
46
|
+
break;
|
|
47
|
+
case error.TIMEOUT:
|
|
48
|
+
code = "TIMEOUT";
|
|
49
|
+
break;
|
|
50
|
+
default:
|
|
51
|
+
code = "UNKNOWN";
|
|
52
|
+
}
|
|
53
|
+
reject({ code, message: error.message });
|
|
54
|
+
}, geoOptions);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async watchPosition(options) {
|
|
58
|
+
const watchId = `watch-${Date.now()}-${Math.random().toString(36).substring(7)}`;
|
|
59
|
+
const geoOptions = {
|
|
60
|
+
enableHighAccuracy: options?.accuracy === "best" || options?.accuracy === "high",
|
|
61
|
+
maximumAge: options?.maxAge ?? 0,
|
|
62
|
+
timeout: options?.timeout ?? 10000,
|
|
63
|
+
};
|
|
64
|
+
const nativeWatchId = navigator.geolocation.watchPosition((position) => {
|
|
65
|
+
this.notifyListeners("locationChange", {
|
|
66
|
+
coords: {
|
|
67
|
+
latitude: position.coords.latitude,
|
|
68
|
+
longitude: position.coords.longitude,
|
|
69
|
+
altitude: position.coords.altitude ?? undefined,
|
|
70
|
+
accuracy: position.coords.accuracy,
|
|
71
|
+
altitudeAccuracy: position.coords.altitudeAccuracy ?? undefined,
|
|
72
|
+
speed: position.coords.speed ?? undefined,
|
|
73
|
+
heading: position.coords.heading ?? undefined,
|
|
74
|
+
timestamp: position.timestamp,
|
|
75
|
+
},
|
|
76
|
+
cached: false,
|
|
77
|
+
});
|
|
78
|
+
}, (error) => {
|
|
79
|
+
let code;
|
|
80
|
+
switch (error.code) {
|
|
81
|
+
case error.PERMISSION_DENIED:
|
|
82
|
+
code = "PERMISSION_DENIED";
|
|
83
|
+
break;
|
|
84
|
+
case error.POSITION_UNAVAILABLE:
|
|
85
|
+
code = "POSITION_UNAVAILABLE";
|
|
86
|
+
break;
|
|
87
|
+
case error.TIMEOUT:
|
|
88
|
+
code = "TIMEOUT";
|
|
89
|
+
break;
|
|
90
|
+
default:
|
|
91
|
+
code = "UNKNOWN";
|
|
92
|
+
}
|
|
93
|
+
this.notifyListeners("error", { code, message: error.message });
|
|
94
|
+
}, geoOptions);
|
|
95
|
+
this.watches.set(watchId, nativeWatchId);
|
|
96
|
+
return { watchId };
|
|
97
|
+
}
|
|
98
|
+
async clearWatch(options) {
|
|
99
|
+
const nativeWatchId = this.watches.get(options.watchId);
|
|
100
|
+
if (nativeWatchId !== undefined) {
|
|
101
|
+
navigator.geolocation.clearWatch(nativeWatchId);
|
|
102
|
+
this.watches.delete(options.watchId);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async checkPermissions() {
|
|
106
|
+
if ("permissions" in navigator) {
|
|
107
|
+
try {
|
|
108
|
+
const result = await navigator.permissions.query({
|
|
109
|
+
name: "geolocation",
|
|
110
|
+
});
|
|
111
|
+
return {
|
|
112
|
+
location: result.state === "granted"
|
|
113
|
+
? "granted"
|
|
114
|
+
: result.state === "denied"
|
|
115
|
+
? "denied"
|
|
116
|
+
: "prompt",
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
return { location: "prompt" };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return { location: "prompt" };
|
|
124
|
+
}
|
|
125
|
+
async requestPermissions() {
|
|
126
|
+
// On web, permissions are requested implicitly when calling getCurrentPosition
|
|
127
|
+
// Try to get current position to trigger permission request
|
|
128
|
+
try {
|
|
129
|
+
await this.getCurrentPosition({ timeout: 5000 });
|
|
130
|
+
return { location: "granted" };
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
const e = error;
|
|
134
|
+
if (e.code === "PERMISSION_DENIED") {
|
|
135
|
+
return { location: "denied" };
|
|
136
|
+
}
|
|
137
|
+
return { location: "prompt" };
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
143
|
+
__proto__: null,
|
|
144
|
+
LocationWeb: LocationWeb
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
exports.Location = Location;
|
|
148
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nexport * from \"./definitions\";\nconst loadWeb = () => import(\"./web\").then((m) => new m.LocationWeb());\nexport const Location = registerPlugin(\"ElizaLocation\", {\n web: loadWeb,\n});\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\n/**\n * Web implementation of the Location Plugin\n *\n * Uses the browser Geolocation API.\n */\nexport class LocationWeb extends WebPlugin {\n watches = new Map();\n async getCurrentPosition(options) {\n return new Promise((resolve, reject) => {\n const geoOptions = {\n enableHighAccuracy: options?.accuracy === \"best\" || options?.accuracy === \"high\",\n maximumAge: options?.maxAge ?? 0,\n timeout: options?.timeout ?? 10000,\n };\n navigator.geolocation.getCurrentPosition((position) => {\n resolve({\n coords: {\n latitude: position.coords.latitude,\n longitude: position.coords.longitude,\n altitude: position.coords.altitude ?? undefined,\n accuracy: position.coords.accuracy,\n altitudeAccuracy: position.coords.altitudeAccuracy ?? undefined,\n speed: position.coords.speed ?? undefined,\n heading: position.coords.heading ?? undefined,\n timestamp: position.timestamp,\n },\n cached: false,\n });\n }, (error) => {\n let code;\n switch (error.code) {\n case error.PERMISSION_DENIED:\n code = \"PERMISSION_DENIED\";\n break;\n case error.POSITION_UNAVAILABLE:\n code = \"POSITION_UNAVAILABLE\";\n break;\n case error.TIMEOUT:\n code = \"TIMEOUT\";\n break;\n default:\n code = \"UNKNOWN\";\n }\n reject({ code, message: error.message });\n }, geoOptions);\n });\n }\n async watchPosition(options) {\n const watchId = `watch-${Date.now()}-${Math.random().toString(36).substring(7)}`;\n const geoOptions = {\n enableHighAccuracy: options?.accuracy === \"best\" || options?.accuracy === \"high\",\n maximumAge: options?.maxAge ?? 0,\n timeout: options?.timeout ?? 10000,\n };\n const nativeWatchId = navigator.geolocation.watchPosition((position) => {\n this.notifyListeners(\"locationChange\", {\n coords: {\n latitude: position.coords.latitude,\n longitude: position.coords.longitude,\n altitude: position.coords.altitude ?? undefined,\n accuracy: position.coords.accuracy,\n altitudeAccuracy: position.coords.altitudeAccuracy ?? undefined,\n speed: position.coords.speed ?? undefined,\n heading: position.coords.heading ?? undefined,\n timestamp: position.timestamp,\n },\n cached: false,\n });\n }, (error) => {\n let code;\n switch (error.code) {\n case error.PERMISSION_DENIED:\n code = \"PERMISSION_DENIED\";\n break;\n case error.POSITION_UNAVAILABLE:\n code = \"POSITION_UNAVAILABLE\";\n break;\n case error.TIMEOUT:\n code = \"TIMEOUT\";\n break;\n default:\n code = \"UNKNOWN\";\n }\n this.notifyListeners(\"error\", { code, message: error.message });\n }, geoOptions);\n this.watches.set(watchId, nativeWatchId);\n return { watchId };\n }\n async clearWatch(options) {\n const nativeWatchId = this.watches.get(options.watchId);\n if (nativeWatchId !== undefined) {\n navigator.geolocation.clearWatch(nativeWatchId);\n this.watches.delete(options.watchId);\n }\n }\n async checkPermissions() {\n if (\"permissions\" in navigator) {\n try {\n const result = await navigator.permissions.query({\n name: \"geolocation\",\n });\n return {\n location: result.state === \"granted\"\n ? \"granted\"\n : result.state === \"denied\"\n ? \"denied\"\n : \"prompt\",\n };\n }\n catch {\n return { location: \"prompt\" };\n }\n }\n return { location: \"prompt\" };\n }\n async requestPermissions() {\n // On web, permissions are requested implicitly when calling getCurrentPosition\n // Try to get current position to trigger permission request\n try {\n await this.getCurrentPosition({ timeout: 5000 });\n return { location: \"granted\" };\n }\n catch (error) {\n const e = error;\n if (e.code === \"PERMISSION_DENIED\") {\n return { location: \"denied\" };\n }\n return { location: \"prompt\" };\n }\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AAEA,MAAM,OAAO,GAAG,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;AAC1D,MAAC,QAAQ,GAAGA,mBAAc,CAAC,eAAe,EAAE;AACxD,IAAI,GAAG,EAAE,OAAO;AAChB,CAAC;;ACJD;AACA;AACA;AACA;AACA;AACO,MAAM,WAAW,SAASC,cAAS,CAAC;AAC3C,IAAI,OAAO,GAAG,IAAI,GAAG,EAAE;AACvB,IAAI,MAAM,kBAAkB,CAAC,OAAO,EAAE;AACtC,QAAQ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAChD,YAAY,MAAM,UAAU,GAAG;AAC/B,gBAAgB,kBAAkB,EAAE,OAAO,EAAE,QAAQ,KAAK,MAAM,IAAI,OAAO,EAAE,QAAQ,KAAK,MAAM;AAChG,gBAAgB,UAAU,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAChD,gBAAgB,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,KAAK;AAClD,aAAa;AACb,YAAY,SAAS,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,QAAQ,KAAK;AACnE,gBAAgB,OAAO,CAAC;AACxB,oBAAoB,MAAM,EAAE;AAC5B,wBAAwB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ;AAC1D,wBAAwB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS;AAC5D,wBAAwB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ,IAAI,SAAS;AACvE,wBAAwB,QA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AAE;AAC7C,YAAY;AACZ,QAAQ;AACR,QAAQ,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE;AACrC,IAAI;AACJ,IAAI,MAAM,kBAAkB,GAAG;AAC/B;AACA;AACA,QAAQ,IAAI;AACZ,YAAY,MAAM,IAAI,CAAC,kBAAkB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC5D,YAAY,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE;AAC1C,QAAQ;AACR,QAAQ,OAAO,KAAK,EAAE;AACtB,YAAY,MAAM,CAAC,GAAG,KAAK;AAC3B,YAAY,IAAI,CAAC,CAAC,IAAI,KAAK,mBAAmB,EAAE;AAChD,gBAAgB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE;AAC7C,YAAY;AACZ,YAAY,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE;AACzC,QAAQ;AACR,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
var capacitorLocation = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const loadWeb = () => Promise.resolve().then(function () { return web; }).then((m) => new m.LocationWeb());
|
|
5
|
+
const Location = core.registerPlugin("ElizaLocation", {
|
|
6
|
+
web: loadWeb,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Web implementation of the Location Plugin
|
|
11
|
+
*
|
|
12
|
+
* Uses the browser Geolocation API.
|
|
13
|
+
*/
|
|
14
|
+
class LocationWeb extends core.WebPlugin {
|
|
15
|
+
watches = new Map();
|
|
16
|
+
async getCurrentPosition(options) {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
const geoOptions = {
|
|
19
|
+
enableHighAccuracy: options?.accuracy === "best" || options?.accuracy === "high",
|
|
20
|
+
maximumAge: options?.maxAge ?? 0,
|
|
21
|
+
timeout: options?.timeout ?? 10000,
|
|
22
|
+
};
|
|
23
|
+
navigator.geolocation.getCurrentPosition((position) => {
|
|
24
|
+
resolve({
|
|
25
|
+
coords: {
|
|
26
|
+
latitude: position.coords.latitude,
|
|
27
|
+
longitude: position.coords.longitude,
|
|
28
|
+
altitude: position.coords.altitude ?? undefined,
|
|
29
|
+
accuracy: position.coords.accuracy,
|
|
30
|
+
altitudeAccuracy: position.coords.altitudeAccuracy ?? undefined,
|
|
31
|
+
speed: position.coords.speed ?? undefined,
|
|
32
|
+
heading: position.coords.heading ?? undefined,
|
|
33
|
+
timestamp: position.timestamp,
|
|
34
|
+
},
|
|
35
|
+
cached: false,
|
|
36
|
+
});
|
|
37
|
+
}, (error) => {
|
|
38
|
+
let code;
|
|
39
|
+
switch (error.code) {
|
|
40
|
+
case error.PERMISSION_DENIED:
|
|
41
|
+
code = "PERMISSION_DENIED";
|
|
42
|
+
break;
|
|
43
|
+
case error.POSITION_UNAVAILABLE:
|
|
44
|
+
code = "POSITION_UNAVAILABLE";
|
|
45
|
+
break;
|
|
46
|
+
case error.TIMEOUT:
|
|
47
|
+
code = "TIMEOUT";
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
code = "UNKNOWN";
|
|
51
|
+
}
|
|
52
|
+
reject({ code, message: error.message });
|
|
53
|
+
}, geoOptions);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async watchPosition(options) {
|
|
57
|
+
const watchId = `watch-${Date.now()}-${Math.random().toString(36).substring(7)}`;
|
|
58
|
+
const geoOptions = {
|
|
59
|
+
enableHighAccuracy: options?.accuracy === "best" || options?.accuracy === "high",
|
|
60
|
+
maximumAge: options?.maxAge ?? 0,
|
|
61
|
+
timeout: options?.timeout ?? 10000,
|
|
62
|
+
};
|
|
63
|
+
const nativeWatchId = navigator.geolocation.watchPosition((position) => {
|
|
64
|
+
this.notifyListeners("locationChange", {
|
|
65
|
+
coords: {
|
|
66
|
+
latitude: position.coords.latitude,
|
|
67
|
+
longitude: position.coords.longitude,
|
|
68
|
+
altitude: position.coords.altitude ?? undefined,
|
|
69
|
+
accuracy: position.coords.accuracy,
|
|
70
|
+
altitudeAccuracy: position.coords.altitudeAccuracy ?? undefined,
|
|
71
|
+
speed: position.coords.speed ?? undefined,
|
|
72
|
+
heading: position.coords.heading ?? undefined,
|
|
73
|
+
timestamp: position.timestamp,
|
|
74
|
+
},
|
|
75
|
+
cached: false,
|
|
76
|
+
});
|
|
77
|
+
}, (error) => {
|
|
78
|
+
let code;
|
|
79
|
+
switch (error.code) {
|
|
80
|
+
case error.PERMISSION_DENIED:
|
|
81
|
+
code = "PERMISSION_DENIED";
|
|
82
|
+
break;
|
|
83
|
+
case error.POSITION_UNAVAILABLE:
|
|
84
|
+
code = "POSITION_UNAVAILABLE";
|
|
85
|
+
break;
|
|
86
|
+
case error.TIMEOUT:
|
|
87
|
+
code = "TIMEOUT";
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
code = "UNKNOWN";
|
|
91
|
+
}
|
|
92
|
+
this.notifyListeners("error", { code, message: error.message });
|
|
93
|
+
}, geoOptions);
|
|
94
|
+
this.watches.set(watchId, nativeWatchId);
|
|
95
|
+
return { watchId };
|
|
96
|
+
}
|
|
97
|
+
async clearWatch(options) {
|
|
98
|
+
const nativeWatchId = this.watches.get(options.watchId);
|
|
99
|
+
if (nativeWatchId !== undefined) {
|
|
100
|
+
navigator.geolocation.clearWatch(nativeWatchId);
|
|
101
|
+
this.watches.delete(options.watchId);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async checkPermissions() {
|
|
105
|
+
if ("permissions" in navigator) {
|
|
106
|
+
try {
|
|
107
|
+
const result = await navigator.permissions.query({
|
|
108
|
+
name: "geolocation",
|
|
109
|
+
});
|
|
110
|
+
return {
|
|
111
|
+
location: result.state === "granted"
|
|
112
|
+
? "granted"
|
|
113
|
+
: result.state === "denied"
|
|
114
|
+
? "denied"
|
|
115
|
+
: "prompt",
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return { location: "prompt" };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return { location: "prompt" };
|
|
123
|
+
}
|
|
124
|
+
async requestPermissions() {
|
|
125
|
+
// On web, permissions are requested implicitly when calling getCurrentPosition
|
|
126
|
+
// Try to get current position to trigger permission request
|
|
127
|
+
try {
|
|
128
|
+
await this.getCurrentPosition({ timeout: 5000 });
|
|
129
|
+
return { location: "granted" };
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
const e = error;
|
|
133
|
+
if (e.code === "PERMISSION_DENIED") {
|
|
134
|
+
return { location: "denied" };
|
|
135
|
+
}
|
|
136
|
+
return { location: "prompt" };
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
142
|
+
__proto__: null,
|
|
143
|
+
LocationWeb: LocationWeb
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
exports.Location = Location;
|
|
147
|
+
|
|
148
|
+
return exports;
|
|
149
|
+
|
|
150
|
+
})({}, capacitorExports);
|
|
151
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nexport * from \"./definitions\";\nconst loadWeb = () => import(\"./web\").then((m) => new m.LocationWeb());\nexport const Location = registerPlugin(\"ElizaLocation\", {\n web: loadWeb,\n});\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\n/**\n * Web implementation of the Location Plugin\n *\n * Uses the browser Geolocation API.\n */\nexport class LocationWeb extends WebPlugin {\n watches = new Map();\n async getCurrentPosition(options) {\n return new Promise((resolve, reject) => {\n const geoOptions = {\n enableHighAccuracy: options?.accuracy === \"best\" || options?.accuracy === \"high\",\n maximumAge: options?.maxAge ?? 0,\n timeout: options?.timeout ?? 10000,\n };\n navigator.geolocation.getCurrentPosition((position) => {\n resolve({\n coords: {\n latitude: position.coords.latitude,\n longitude: position.coords.longitude,\n altitude: position.coords.altitude ?? undefined,\n accuracy: position.coords.accuracy,\n altitudeAccuracy: position.coords.altitudeAccuracy ?? undefined,\n speed: position.coords.speed ?? undefined,\n heading: position.coords.heading ?? undefined,\n timestamp: position.timestamp,\n },\n cached: false,\n });\n }, (error) => {\n let code;\n switch (error.code) {\n case error.PERMISSION_DENIED:\n code = \"PERMISSION_DENIED\";\n break;\n case error.POSITION_UNAVAILABLE:\n code = \"POSITION_UNAVAILABLE\";\n break;\n case error.TIMEOUT:\n code = \"TIMEOUT\";\n break;\n default:\n code = \"UNKNOWN\";\n }\n reject({ code, message: error.message });\n }, geoOptions);\n });\n }\n async watchPosition(options) {\n const watchId = `watch-${Date.now()}-${Math.random().toString(36).substring(7)}`;\n const geoOptions = {\n enableHighAccuracy: options?.accuracy === \"best\" || options?.accuracy === \"high\",\n maximumAge: options?.maxAge ?? 0,\n timeout: options?.timeout ?? 10000,\n };\n const nativeWatchId = navigator.geolocation.watchPosition((position) => {\n this.notifyListeners(\"locationChange\", {\n coords: {\n latitude: position.coords.latitude,\n longitude: position.coords.longitude,\n altitude: position.coords.altitude ?? undefined,\n accuracy: position.coords.accuracy,\n altitudeAccuracy: position.coords.altitudeAccuracy ?? undefined,\n speed: position.coords.speed ?? undefined,\n heading: position.coords.heading ?? undefined,\n timestamp: position.timestamp,\n },\n cached: false,\n });\n }, (error) => {\n let code;\n switch (error.code) {\n case error.PERMISSION_DENIED:\n code = \"PERMISSION_DENIED\";\n break;\n case error.POSITION_UNAVAILABLE:\n code = \"POSITION_UNAVAILABLE\";\n break;\n case error.TIMEOUT:\n code = \"TIMEOUT\";\n break;\n default:\n code = \"UNKNOWN\";\n }\n this.notifyListeners(\"error\", { code, message: error.message });\n }, geoOptions);\n this.watches.set(watchId, nativeWatchId);\n return { watchId };\n }\n async clearWatch(options) {\n const nativeWatchId = this.watches.get(options.watchId);\n if (nativeWatchId !== undefined) {\n navigator.geolocation.clearWatch(nativeWatchId);\n this.watches.delete(options.watchId);\n }\n }\n async checkPermissions() {\n if (\"permissions\" in navigator) {\n try {\n const result = await navigator.permissions.query({\n name: \"geolocation\",\n });\n return {\n location: result.state === \"granted\"\n ? \"granted\"\n : result.state === \"denied\"\n ? \"denied\"\n : \"prompt\",\n };\n }\n catch {\n return { location: \"prompt\" };\n }\n }\n return { location: \"prompt\" };\n }\n async requestPermissions() {\n // On web, permissions are requested implicitly when calling getCurrentPosition\n // Try to get current position to trigger permission request\n try {\n await this.getCurrentPosition({ timeout: 5000 });\n return { location: \"granted\" };\n }\n catch (error) {\n const e = error;\n if (e.code === \"PERMISSION_DENIED\") {\n return { location: \"denied\" };\n }\n return { location: \"prompt\" };\n }\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAEA,MAAM,OAAO,GAAG,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;AAC1D,UAAC,QAAQ,GAAGA,mBAAc,CAAC,eAAe,EAAE;IACxD,IAAI,GAAG,EAAE,OAAO;IAChB,CAAC;;ICJD;IACA;IACA;IACA;IACA;IACO,MAAM,WAAW,SAASC,cAAS,CAAC;IAC3C,IAAI,OAAO,GAAG,IAAI,GAAG,EAAE;IACvB,IAAI,MAAM,kBAAkB,CAAC,OAAO,EAAE;IACtC,QAAQ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;IAChD,YAAY,MAAM,UAAU,GAAG;IAC/B,gBAAgB,kBAAkB,EAAE,OAAO,EAAE,QAAQ,KAAK,MAAM,IAAI,OAAO,EAAE,QAAQ,KAAK,MAAM;IAChG,gBAAgB,UAAU,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;IAChD,gBAAgB,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,KAAK;IAClD,aAAa;IAC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