foreground-location 0.0.1

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/dist/plugin.js ADDED
@@ -0,0 +1,141 @@
1
+ var capacitorForeGroundLocation = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ /**
5
+ * Plugin error codes for consistent error handling
6
+ */
7
+ const ERROR_CODES = {
8
+ /**
9
+ * Location permission denied or not granted
10
+ */
11
+ PERMISSION_DENIED: 'PERMISSION_DENIED',
12
+ /**
13
+ * Invalid notification configuration
14
+ */
15
+ INVALID_NOTIFICATION: 'INVALID_NOTIFICATION',
16
+ /**
17
+ * Invalid parameters provided
18
+ */
19
+ INVALID_PARAMETERS: 'INVALID_PARAMETERS',
20
+ /**
21
+ * Location services disabled
22
+ */
23
+ LOCATION_SERVICES_DISABLED: 'LOCATION_SERVICES_DISABLED',
24
+ /**
25
+ * Feature not supported on current platform
26
+ */
27
+ UNSUPPORTED_PLATFORM: 'UNSUPPORTED_PLATFORM'
28
+ };
29
+
30
+ const ForeGroundLocation = core.registerPlugin('ForeGroundLocation', {
31
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.ForeGroundLocationWeb()),
32
+ });
33
+
34
+ class ForeGroundLocationWeb extends core.WebPlugin {
35
+ async checkPermissions() {
36
+ if (typeof navigator === 'undefined') {
37
+ throw this.unavailable('Navigator not available');
38
+ }
39
+ if (!navigator.permissions) {
40
+ throw this.unavailable('Permissions API not available in this browser');
41
+ }
42
+ if (!navigator.geolocation) {
43
+ throw this.unavailable('Geolocation API not available in this browser');
44
+ }
45
+ try {
46
+ const permission = await navigator.permissions.query({ name: 'geolocation' });
47
+ return {
48
+ location: permission.state,
49
+ backgroundLocation: 'denied',
50
+ notifications: 'denied'
51
+ };
52
+ }
53
+ catch (error) {
54
+ // Fallback for browsers that support geolocation but not permissions query
55
+ return {
56
+ location: 'prompt',
57
+ backgroundLocation: 'denied',
58
+ notifications: 'denied'
59
+ };
60
+ }
61
+ }
62
+ async requestPermissions() {
63
+ throw this.unimplemented('Background location service not supported on web. Use getCurrentLocation() for one-time location access.');
64
+ }
65
+ async startForegroundLocationService() {
66
+ throw this.unimplemented('Foreground location service not supported on web. Use getCurrentLocation() for one-time location access.');
67
+ }
68
+ async stopForegroundLocationService() {
69
+ throw this.unimplemented('Foreground location service not supported on web.');
70
+ }
71
+ async isServiceRunning() {
72
+ return { isRunning: false };
73
+ }
74
+ async getCurrentLocation() {
75
+ if (typeof navigator === 'undefined') {
76
+ throw this.unavailable('Navigator not available');
77
+ }
78
+ if (!navigator.geolocation) {
79
+ throw this.unavailable('Geolocation API not available in this browser');
80
+ }
81
+ return new Promise((resolve, reject) => {
82
+ navigator.geolocation.getCurrentPosition((position) => {
83
+ resolve({
84
+ latitude: position.coords.latitude,
85
+ longitude: position.coords.longitude,
86
+ accuracy: position.coords.accuracy,
87
+ altitude: position.coords.altitude || undefined,
88
+ bearing: position.coords.heading || undefined,
89
+ speed: position.coords.speed || undefined,
90
+ timestamp: new Date(position.timestamp).toISOString(),
91
+ });
92
+ }, (error) => {
93
+ let errorMessage = 'Location error';
94
+ switch (error.code) {
95
+ case error.PERMISSION_DENIED:
96
+ errorMessage = 'Location permission denied';
97
+ break;
98
+ case error.POSITION_UNAVAILABLE:
99
+ errorMessage = 'Location position unavailable';
100
+ break;
101
+ case error.TIMEOUT:
102
+ errorMessage = 'Location request timed out';
103
+ break;
104
+ default:
105
+ errorMessage = `Location error: ${error.message}`;
106
+ break;
107
+ }
108
+ reject(errorMessage);
109
+ }, {
110
+ enableHighAccuracy: true,
111
+ timeout: 10000,
112
+ maximumAge: 300000,
113
+ });
114
+ });
115
+ }
116
+ async updateLocationSettings() {
117
+ throw this.unimplemented('Location service settings not supported on web.');
118
+ }
119
+ async getApiServiceStatus() {
120
+ throw this.unimplemented('API service not supported on web.');
121
+ }
122
+ async clearApiBuffers() {
123
+ throw this.unimplemented('API service not supported on web.');
124
+ }
125
+ async resetApiCircuitBreaker() {
126
+ throw this.unimplemented('API service not supported on web.');
127
+ }
128
+ }
129
+
130
+ var web = /*#__PURE__*/Object.freeze({
131
+ __proto__: null,
132
+ ForeGroundLocationWeb: ForeGroundLocationWeb
133
+ });
134
+
135
+ exports.ERROR_CODES = ERROR_CODES;
136
+ exports.ForeGroundLocation = ForeGroundLocation;
137
+
138
+ return exports;
139
+
140
+ })({}, capacitorExports);
141
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\r\n * Plugin error codes for consistent error handling\r\n */\r\nexport const ERROR_CODES = {\r\n /**\r\n * Location permission denied or not granted\r\n */\r\n PERMISSION_DENIED: 'PERMISSION_DENIED',\r\n /**\r\n * Invalid notification configuration\r\n */\r\n INVALID_NOTIFICATION: 'INVALID_NOTIFICATION',\r\n /**\r\n * Invalid parameters provided\r\n */\r\n INVALID_PARAMETERS: 'INVALID_PARAMETERS',\r\n /**\r\n * Location services disabled\r\n */\r\n LOCATION_SERVICES_DISABLED: 'LOCATION_SERVICES_DISABLED',\r\n /**\r\n * Feature not supported on current platform\r\n */\r\n UNSUPPORTED_PLATFORM: 'UNSUPPORTED_PLATFORM'\r\n};\r\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\r\nconst ForeGroundLocation = registerPlugin('ForeGroundLocation', {\r\n web: () => import('./web').then((m) => new m.ForeGroundLocationWeb()),\r\n});\r\nexport * from './definitions';\r\nexport { ForeGroundLocation };\r\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\r\nexport class ForeGroundLocationWeb extends WebPlugin {\r\n async checkPermissions() {\r\n if (typeof navigator === 'undefined') {\r\n throw this.unavailable('Navigator not available');\r\n }\r\n if (!navigator.permissions) {\r\n throw this.unavailable('Permissions API not available in this browser');\r\n }\r\n if (!navigator.geolocation) {\r\n throw this.unavailable('Geolocation API not available in this browser');\r\n }\r\n try {\r\n const permission = await navigator.permissions.query({ name: 'geolocation' });\r\n return {\r\n location: permission.state,\r\n backgroundLocation: 'denied',\r\n notifications: 'denied'\r\n };\r\n }\r\n catch (error) {\r\n // Fallback for browsers that support geolocation but not permissions query\r\n return {\r\n location: 'prompt',\r\n backgroundLocation: 'denied',\r\n notifications: 'denied'\r\n };\r\n }\r\n }\r\n async requestPermissions() {\r\n throw this.unimplemented('Background location service not supported on web. Use getCurrentLocation() for one-time location access.');\r\n }\r\n async startForegroundLocationService() {\r\n throw this.unimplemented('Foreground location service not supported on web. Use getCurrentLocation() for one-time location access.');\r\n }\r\n async stopForegroundLocationService() {\r\n throw this.unimplemented('Foreground location service not supported on web.');\r\n }\r\n async isServiceRunning() {\r\n return { isRunning: false };\r\n }\r\n async getCurrentLocation() {\r\n if (typeof navigator === 'undefined') {\r\n throw this.unavailable('Navigator not available');\r\n }\r\n if (!navigator.geolocation) {\r\n throw this.unavailable('Geolocation API not available in this browser');\r\n }\r\n return new Promise((resolve, reject) => {\r\n navigator.geolocation.getCurrentPosition((position) => {\r\n resolve({\r\n latitude: position.coords.latitude,\r\n longitude: position.coords.longitude,\r\n accuracy: position.coords.accuracy,\r\n altitude: position.coords.altitude || undefined,\r\n bearing: position.coords.heading || undefined,\r\n speed: position.coords.speed || undefined,\r\n timestamp: new Date(position.timestamp).toISOString(),\r\n });\r\n }, (error) => {\r\n let errorMessage = 'Location error';\r\n switch (error.code) {\r\n case error.PERMISSION_DENIED:\r\n errorMessage = 'Location permission denied';\r\n break;\r\n case error.POSITION_UNAVAILABLE:\r\n errorMessage = 'Location position unavailable';\r\n break;\r\n case error.TIMEOUT:\r\n errorMessage = 'Location request timed out';\r\n break;\r\n default:\r\n errorMessage = `Location error: ${error.message}`;\r\n break;\r\n }\r\n reject(errorMessage);\r\n }, {\r\n enableHighAccuracy: true,\r\n timeout: 10000,\r\n maximumAge: 300000,\r\n });\r\n });\r\n }\r\n async updateLocationSettings() {\r\n throw this.unimplemented('Location service settings not supported on web.');\r\n }\r\n async getApiServiceStatus() {\r\n throw this.unimplemented('API service not supported on web.');\r\n }\r\n async clearApiBuffers() {\r\n throw this.unimplemented('API service not supported on web.');\r\n }\r\n async resetApiCircuitBreaker() {\r\n throw this.unimplemented('API service not supported on web.');\r\n }\r\n}\r\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;AACY,UAAC,WAAW,GAAG;IAC3B;IACA;IACA;IACA,IAAI,iBAAiB,EAAE,mBAAmB;IAC1C;IACA;IACA;IACA,IAAI,oBAAoB,EAAE,sBAAsB;IAChD;IACA;IACA;IACA,IAAI,kBAAkB,EAAE,oBAAoB;IAC5C;IACA;IACA;IACA,IAAI,0BAA0B,EAAE,4BAA4B;IAC5D;IACA;IACA;IACA,IAAI,oBAAoB,EAAE,sBAAsB;IAChD;;ACvBK,UAAC,kBAAkB,GAAGA,mBAAc,CAAC,oBAAoB,EAAE;IAChE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,qBAAqB,EAAE,CAAC;IACzE,CAAC;;ICFM,MAAM,qBAAqB,SAASC,cAAS,CAAC;IACrD,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,IAAI,OAAO,SAAS,KAAK,WAAW,EAAE;IAC9C,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC;IAC9D,SAAS;IACT,QAAQ,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;IACpC,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,+CAA+C,CAAC,CAAC;IACpF,SAAS;IACT,QAAQ,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;IACpC,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,+CAA+C,CAAC,CAAC;IACpF,SAAS;IACT,QAAQ,IAAI;IACZ,YAAY,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC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,gBAAgB,OAAO,EAAE,KAAK;IAC9B,gBAAgB,UAAU,EAAE,MAAM;IAClC,aAAa,CAAC,CAAC;IACf,SAAS,CAAC,CAAC;IACX,KAAK;IACL,IAAI,MAAM,sBAAsB,GAAG;IACnC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,iDAAiD,CAAC,CAAC;IACpF,KAAK;IACL,IAAI,MAAM,mBAAmB,GAAG;IAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,mCAAmC,CAAC,CAAC;IACtE,KAAK;IACL,IAAI,MAAM,eAAe,GAAG;IAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,mCAAmC,CAAC,CAAC;IACtE,KAAK;IACL,IAAI,MAAM,sBAAsB,GAAG;IACnC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,mCAAmC,CAAC,CAAC;IACtE,KAAK;IACL;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,69 @@
1
+ # Documentation Updates Summary
2
+
3
+ ## Changes Made
4
+
5
+ ### 1. ✅ Created Documentation Folder
6
+
7
+ - **Created**: `docs/setup-and-examples.md` - Comprehensive guide consolidating all separate documentation files
8
+ - **Removed**: Individual documentation files that were scattered in the root:
9
+ - `AndroidManifest-example.xml`
10
+ - `example-usage.ts`
11
+ - `QUICK-SETUP.md`
12
+ - `ICON-USAGE-EXAMPLES.md`
13
+ - `NOTIFICATION-ICONS-GUIDE.md`
14
+ - `TYPESCRIPT-IMPORT-FIX.md`
15
+
16
+ ### 2. ✅ Updated README.md
17
+
18
+ - **Fixed**: All package name references from `foreground-location-plugin` to `foreground-location`
19
+ - **Fixed**: Removed `@xconcepts/capacitor-foreground-location` references
20
+ - **Updated**: Version number from `1.0.0` to `0.0.1` in changelog (matching package.json)
21
+ - **Added**: Reference to comprehensive documentation in docs folder
22
+ - **Verified**: All import statements now use correct package name
23
+
24
+ ### 3. ✅ Fixed Package Naming
25
+
26
+ - **Confirmed**: Package name is correctly set to `foreground-location` (not `foreground-location-plugin`)
27
+ - **Updated**: Repository URLs to remove `-plugin` suffix
28
+ - **Added**: `docs/` folder to files array in package.json for npm inclusion
29
+
30
+ ### 4. ✅ NPM Publish Configuration
31
+
32
+ - **Created**: `.npmignore` file to exclude development files from npm package
33
+ - **Hidden**: `plugin-plan-doc/` folder renamed to `.plugin-plan-doc/` (hidden folder)
34
+ - **Excluded**: Development files like `DEVELOPMENT-ITERATION.md`, `CONTRIBUTING.md`
35
+ - **Protected**: Planning documents and development artifacts from being published
36
+
37
+ ## Final Project Structure
38
+
39
+ ```
40
+ foreground-location/
41
+ ├── docs/
42
+ │ └── setup-and-examples.md # ✨ New comprehensive guide
43
+ ├── .npmignore # ✨ New npm exclusion rules
44
+ ├── .plugin-plan-doc/ # ✨ Hidden (was plugin-plan-doc/)
45
+ ├── README.md # ✅ Updated with correct package names
46
+ ├── package.json # ✅ Updated repository URLs
47
+ └── [other project files...]
48
+ ```
49
+
50
+ ## Package Name Standardization
51
+
52
+ - **NPM Package**: `foreground-location`
53
+ - **Import Statement**: `import { ForeGroundLocation } from 'foreground-location';`
54
+ - **Installation**: `npm install foreground-location`
55
+ - **Repository**: `github.com/xconcepts17/foreground-location`
56
+
57
+ ## Build Verification
58
+
59
+ ✅ Project builds successfully with `npm run build`
60
+ ✅ All TypeScript imports corrected
61
+ ✅ Documentation consolidated and updated
62
+ ✅ NPM publish configuration implemented
63
+
64
+ ## Next Steps
65
+
66
+ 1. The plugin is ready for npm publishing with `npm publish`
67
+ 2. Planning documents are hidden and excluded from npm package
68
+ 3. Users will get clean, consolidated documentation
69
+ 4. Package naming is consistent across all files