@umituz/react-native-location 1.0.0 → 1.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/README.md CHANGED
File without changes
package/package.json CHANGED
@@ -1,16 +1,14 @@
1
1
  {
2
2
  "name": "@umituz/react-native-location",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Device location services for React Native with GPS, permissions, caching, and reverse geocoding",
5
- "main": "./lib/index.js",
6
- "types": "./lib/index.d.ts",
5
+ "main": "./src/index.ts",
6
+ "types": "./src/index.ts",
7
7
  "scripts": {
8
- "build": "tsc",
9
8
  "typecheck": "tsc --noEmit",
10
9
  "lint": "tsc --noEmit",
11
10
  "clean": "rm -rf lib",
12
11
  "prebuild": "npm run clean",
13
- "prepublishOnly": "npm run build",
14
12
  "version:patch": "npm version patch -m 'chore: release v%s'",
15
13
  "version:minor": "npm version minor -m 'chore: release v%s'",
16
14
  "version:major": "npm version major -m 'chore: release v%s'"
@@ -48,10 +46,8 @@
48
46
  "access": "public"
49
47
  },
50
48
  "files": [
51
- "lib",
52
49
  "src",
53
50
  "README.md",
54
51
  "LICENSE"
55
52
  ]
56
53
  }
57
-
File without changes
package/src/index.ts CHANGED
File without changes
File without changes
File without changes
package/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Ümit UZ
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
22
-
@@ -1,144 +0,0 @@
1
- /**
2
- * Location Domain Entities
3
- *
4
- * Core location types and interfaces for device location services
5
- * and geolocation features
6
- *
7
- * Features:
8
- * - Current location retrieval with GPS
9
- * - Location permission management
10
- * - Location caching (15-minute cache)
11
- * - Reverse geocoding (address lookup)
12
- * - Fallback strategies (High → Balanced → Cached)
13
- * - Platform-aware (iOS/Android only, no web)
14
- *
15
- * Dependencies:
16
- * - expo-location (GPS and permissions)
17
- * - AsyncStorage (location cache)
18
- */
19
- /**
20
- * Location data with coordinates and optional address
21
- */
22
- export interface LocationData {
23
- /** Latitude coordinate */
24
- latitude: number;
25
- /** Longitude coordinate */
26
- longitude: number;
27
- /** Human-readable address (reverse geocoded) */
28
- address?: string;
29
- /** Timestamp when location was captured (milliseconds since epoch) */
30
- timestamp: number;
31
- /** GPS accuracy in meters (lower is better) */
32
- accuracy?: number;
33
- /** Whether this location is from cache (not fresh GPS) */
34
- isCached?: boolean;
35
- }
36
- /**
37
- * Location permission status
38
- */
39
- export type LocationPermissionStatus = 'granted' | 'denied' | 'unknown';
40
- /**
41
- * Location accuracy levels for GPS
42
- */
43
- export declare enum LocationAccuracy {
44
- /** Lowest accuracy, fastest response, battery-friendly */
45
- Lowest = 1,
46
- /** Low accuracy */
47
- Low = 2,
48
- /** Balanced accuracy (recommended for most use cases) */
49
- Balanced = 3,
50
- /** High accuracy (GPS-based) */
51
- High = 4,
52
- /** Highest accuracy (most battery-intensive) */
53
- Highest = 5,
54
- /** Best for navigation (continuous high accuracy) */
55
- BestForNavigation = 6
56
- }
57
- /**
58
- * Location cache configuration
59
- */
60
- export interface LocationCacheConfig {
61
- /** Cache duration in milliseconds (default: 15 minutes) */
62
- duration: number;
63
- /** Storage key for cached location */
64
- storageKey: string;
65
- }
66
- /**
67
- * Location retrieval configuration
68
- */
69
- export interface LocationRetrievalConfig {
70
- /** Timeout for high accuracy request (milliseconds) */
71
- highAccuracyTimeout: number;
72
- /** Timeout for balanced accuracy request (milliseconds) */
73
- balancedAccuracyTimeout: number;
74
- /** Whether to enable reverse geocoding (address lookup) */
75
- enableGeocoding: boolean;
76
- }
77
- /**
78
- * Cached location storage format
79
- */
80
- export interface CachedLocation {
81
- /** Location data */
82
- data: LocationData;
83
- /** Timestamp when location was cached (milliseconds since epoch) */
84
- cachedAt: number;
85
- }
86
- /**
87
- * Location Service Interface
88
- * Defines all location-related operations
89
- */
90
- export interface ILocationService {
91
- /**
92
- * Request location permissions from user
93
- * @returns Promise resolving to true if granted, false otherwise
94
- */
95
- requestPermissions(): Promise<boolean>;
96
- /**
97
- * Check if location permissions are granted
98
- * @returns Promise resolving to true if granted, false otherwise
99
- */
100
- hasPermissions(): Promise<boolean>;
101
- /**
102
- * Get current permission status without requesting
103
- * @returns Current permission status ('granted' | 'denied' | 'unknown')
104
- */
105
- getPermissionStatus(): LocationPermissionStatus;
106
- /**
107
- * Get current device location with fallback strategies
108
- * Priority: High accuracy → Balanced accuracy → Cached location → null
109
- * @returns Promise resolving to LocationData or null if unavailable
110
- */
111
- getCurrentLocation(): Promise<LocationData | null>;
112
- /**
113
- * Get cached location if available and not expired
114
- * @returns Cached location or null
115
- */
116
- getCachedLocation(): LocationData | null;
117
- /**
118
- * Format location for display (address or coordinates)
119
- * @param location - LocationData to format
120
- * @returns Formatted string (address or "lat, lng")
121
- */
122
- formatLocation(location: LocationData): string;
123
- /**
124
- * Check if location services are available on this platform
125
- * @returns True if available (iOS/Android), false otherwise (web)
126
- */
127
- isLocationAvailable(): boolean;
128
- }
129
- /**
130
- * Location service constants
131
- */
132
- export declare const LOCATION_CONSTANTS: {
133
- /** Cache duration: 15 minutes */
134
- readonly CACHE_DURATION: number;
135
- /** High accuracy timeout: 15 seconds */
136
- readonly HIGH_ACCURACY_TIMEOUT: 15000;
137
- /** Balanced accuracy timeout: 8 seconds */
138
- readonly BALANCED_ACCURACY_TIMEOUT: 8000;
139
- /** AsyncStorage key for cached location */
140
- readonly CACHE_KEY: "@location_cache";
141
- /** Coordinate decimal precision for display */
142
- readonly COORDINATE_PRECISION: 4;
143
- };
144
- //# sourceMappingURL=Location.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Location.d.ts","sourceRoot":"","sources":["../../../src/domain/entities/Location.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,CAAC;IAEjB,2BAA2B;IAC3B,SAAS,EAAE,MAAM,CAAC;IAElB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,sEAAsE;IACtE,SAAS,EAAE,MAAM,CAAC;IAElB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExE;;GAEG;AACH,oBAAY,gBAAgB;IAC1B,0DAA0D;IAC1D,MAAM,IAAI;IAEV,mBAAmB;IACnB,GAAG,IAAI;IAEP,yDAAyD;IACzD,QAAQ,IAAI;IAEZ,gCAAgC;IAChC,IAAI,IAAI;IAER,gDAAgD;IAChD,OAAO,IAAI;IAEX,qDAAqD;IACrD,iBAAiB,IAAI;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;IAEjB,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,uDAAuD;IACvD,mBAAmB,EAAE,MAAM,CAAC;IAE5B,2DAA2D;IAC3D,uBAAuB,EAAE,MAAM,CAAC;IAEhC,2DAA2D;IAC3D,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,oBAAoB;IACpB,IAAI,EAAE,YAAY,CAAC;IAEnB,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAEvC;;;OAGG;IACH,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnC;;;OAGG;IACH,mBAAmB,IAAI,wBAAwB,CAAC;IAEhD;;;;OAIG;IACH,kBAAkB,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAEnD;;;OAGG;IACH,iBAAiB,IAAI,YAAY,GAAG,IAAI,CAAC;IAEzC;;;;OAIG;IACH,cAAc,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAAC;IAE/C;;;OAGG;IACH,mBAAmB,IAAI,OAAO,CAAC;CAChC;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB;IAC7B,iCAAiC;;IAGjC,wCAAwC;;IAGxC,2CAA2C;;IAG3C,2CAA2C;;IAG3C,+CAA+C;;CAEvC,CAAC"}
@@ -1,52 +0,0 @@
1
- /**
2
- * Location Domain Entities
3
- *
4
- * Core location types and interfaces for device location services
5
- * and geolocation features
6
- *
7
- * Features:
8
- * - Current location retrieval with GPS
9
- * - Location permission management
10
- * - Location caching (15-minute cache)
11
- * - Reverse geocoding (address lookup)
12
- * - Fallback strategies (High → Balanced → Cached)
13
- * - Platform-aware (iOS/Android only, no web)
14
- *
15
- * Dependencies:
16
- * - expo-location (GPS and permissions)
17
- * - AsyncStorage (location cache)
18
- */
19
- /**
20
- * Location accuracy levels for GPS
21
- */
22
- export var LocationAccuracy;
23
- (function (LocationAccuracy) {
24
- /** Lowest accuracy, fastest response, battery-friendly */
25
- LocationAccuracy[LocationAccuracy["Lowest"] = 1] = "Lowest";
26
- /** Low accuracy */
27
- LocationAccuracy[LocationAccuracy["Low"] = 2] = "Low";
28
- /** Balanced accuracy (recommended for most use cases) */
29
- LocationAccuracy[LocationAccuracy["Balanced"] = 3] = "Balanced";
30
- /** High accuracy (GPS-based) */
31
- LocationAccuracy[LocationAccuracy["High"] = 4] = "High";
32
- /** Highest accuracy (most battery-intensive) */
33
- LocationAccuracy[LocationAccuracy["Highest"] = 5] = "Highest";
34
- /** Best for navigation (continuous high accuracy) */
35
- LocationAccuracy[LocationAccuracy["BestForNavigation"] = 6] = "BestForNavigation";
36
- })(LocationAccuracy || (LocationAccuracy = {}));
37
- /**
38
- * Location service constants
39
- */
40
- export const LOCATION_CONSTANTS = {
41
- /** Cache duration: 15 minutes */
42
- CACHE_DURATION: 15 * 60 * 1000,
43
- /** High accuracy timeout: 15 seconds */
44
- HIGH_ACCURACY_TIMEOUT: 15000,
45
- /** Balanced accuracy timeout: 8 seconds */
46
- BALANCED_ACCURACY_TIMEOUT: 8000,
47
- /** AsyncStorage key for cached location */
48
- CACHE_KEY: '@location_cache',
49
- /** Coordinate decimal precision for display */
50
- COORDINATE_PRECISION: 4,
51
- };
52
- //# sourceMappingURL=Location.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Location.js","sourceRoot":"","sources":["../../../src/domain/entities/Location.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA8BH;;GAEG;AACH,MAAM,CAAN,IAAY,gBAkBX;AAlBD,WAAY,gBAAgB;IAC1B,0DAA0D;IAC1D,2DAAU,CAAA;IAEV,mBAAmB;IACnB,qDAAO,CAAA;IAEP,yDAAyD;IACzD,+DAAY,CAAA;IAEZ,gCAAgC;IAChC,uDAAQ,CAAA;IAER,gDAAgD;IAChD,6DAAW,CAAA;IAEX,qDAAqD;IACrD,iFAAqB,CAAA;AACvB,CAAC,EAlBW,gBAAgB,KAAhB,gBAAgB,QAkB3B;AAwFD;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,iCAAiC;IACjC,cAAc,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IAE9B,wCAAwC;IACxC,qBAAqB,EAAE,KAAK;IAE5B,2CAA2C;IAC3C,yBAAyB,EAAE,IAAI;IAE/B,2CAA2C;IAC3C,SAAS,EAAE,iBAAiB;IAE5B,+CAA+C;IAC/C,oBAAoB,EAAE,CAAC;CACf,CAAC"}
package/lib/index.d.ts DELETED
@@ -1,95 +0,0 @@
1
- /**
2
- * Location Domain - Barrel Export
3
- *
4
- * Global infrastructure domain for device location services and geolocation
5
- *
6
- * Features:
7
- * - Current location retrieval with GPS
8
- * - Location permission management (iOS/Android)
9
- * - 15-minute location caching for performance
10
- * - Reverse geocoding (coordinates → address)
11
- * - Multi-tier accuracy fallback (High → Balanced → Cached)
12
- * - Platform-aware (iOS/Android only, no web support)
13
- * - Silent failures (no console logging)
14
- *
15
- * Dependencies:
16
- * - expo-location (GPS and permissions API)
17
- * - AsyncStorage (cache persistence)
18
- *
19
- * USAGE:
20
- * ```typescript
21
- * // Recommended: Use hook in components
22
- * import { useLocation } from '@umituz/react-native-location';
23
- *
24
- * const MyComponent = () => {
25
- * const {
26
- * location,
27
- * loading,
28
- * hasPermission,
29
- * requestPermission,
30
- * getCurrentLocation,
31
- * formatLocation,
32
- * } = useLocation();
33
- *
34
- * useEffect(() => {
35
- * // Auto-fetch on mount
36
- * getCurrentLocation();
37
- * }, []);
38
- *
39
- * if (loading) return <LoadingIndicator />;
40
- *
41
- * return (
42
- * <View>
43
- * {location && (
44
- * <>
45
- * <Text>Location: {formatLocation(location)}</Text>
46
- * <Text>Lat: {location.latitude}</Text>
47
- * <Text>Lng: {location.longitude}</Text>
48
- * {location.accuracy && (
49
- * <Text>Accuracy: {location.accuracy.toFixed(0)}m</Text>
50
- * )}
51
- * </>
52
- * )}
53
- * <AtomicButton onPress={getCurrentLocation}>
54
- * Refresh Location
55
- * </AtomicButton>
56
- * </View>
57
- * );
58
- * };
59
- *
60
- * // Alternative: Use service directly (for non-component code)
61
- * import { locationService } from '@umituz/react-native-location';
62
- *
63
- * const location = await locationService.getCurrentLocation();
64
- * if (location) {
65
- * console.log(locationService.formatLocation(location));
66
- * }
67
- * ```
68
- *
69
- * PLATFORM SUPPORT:
70
- * - ✅ iOS: Full support (GPS, permissions, geocoding)
71
- * - ✅ Android: Full support (GPS, permissions, geocoding)
72
- * - ❌ Web: Not supported (returns null)
73
- *
74
- * PERMISSION FLOW:
75
- * 1. Check: hasPermissions() → true/false
76
- * 2. Request: requestPermissions() → true/false
77
- * 3. Retrieve: getCurrentLocation() → LocationData | null
78
- *
79
- * FALLBACK STRATEGY:
80
- * 1. High accuracy GPS (15s timeout)
81
- * 2. Balanced accuracy GPS (8s timeout)
82
- * 3. Cached location (15min cache)
83
- * 4. null (no location available)
84
- *
85
- * CACHING:
86
- * - Duration: 15 minutes
87
- * - Storage: AsyncStorage (@location_cache)
88
- * - Auto-refresh: On getCurrentLocation() if expired
89
- */
90
- export type { LocationData, LocationPermissionStatus, CachedLocation, LocationCacheConfig, LocationRetrievalConfig, ILocationService, } from './domain/entities/Location';
91
- export { LocationAccuracy, LOCATION_CONSTANTS } from './domain/entities/Location';
92
- export { locationService } from './infrastructure/services/LocationService';
93
- export { useLocation } from './presentation/hooks/useLocation';
94
- export type { UseLocationReturn } from './presentation/hooks/useLocation';
95
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;AAGH,YAAY,EACV,YAAY,EACZ,wBAAwB,EACxB,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGlF,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAG5E,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,YAAY,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC"}
package/lib/index.js DELETED
@@ -1,95 +0,0 @@
1
- /**
2
- * Location Domain - Barrel Export
3
- *
4
- * Global infrastructure domain for device location services and geolocation
5
- *
6
- * Features:
7
- * - Current location retrieval with GPS
8
- * - Location permission management (iOS/Android)
9
- * - 15-minute location caching for performance
10
- * - Reverse geocoding (coordinates → address)
11
- * - Multi-tier accuracy fallback (High → Balanced → Cached)
12
- * - Platform-aware (iOS/Android only, no web support)
13
- * - Silent failures (no console logging)
14
- *
15
- * Dependencies:
16
- * - expo-location (GPS and permissions API)
17
- * - AsyncStorage (cache persistence)
18
- *
19
- * USAGE:
20
- * ```typescript
21
- * // Recommended: Use hook in components
22
- * import { useLocation } from '@umituz/react-native-location';
23
- *
24
- * const MyComponent = () => {
25
- * const {
26
- * location,
27
- * loading,
28
- * hasPermission,
29
- * requestPermission,
30
- * getCurrentLocation,
31
- * formatLocation,
32
- * } = useLocation();
33
- *
34
- * useEffect(() => {
35
- * // Auto-fetch on mount
36
- * getCurrentLocation();
37
- * }, []);
38
- *
39
- * if (loading) return <LoadingIndicator />;
40
- *
41
- * return (
42
- * <View>
43
- * {location && (
44
- * <>
45
- * <Text>Location: {formatLocation(location)}</Text>
46
- * <Text>Lat: {location.latitude}</Text>
47
- * <Text>Lng: {location.longitude}</Text>
48
- * {location.accuracy && (
49
- * <Text>Accuracy: {location.accuracy.toFixed(0)}m</Text>
50
- * )}
51
- * </>
52
- * )}
53
- * <AtomicButton onPress={getCurrentLocation}>
54
- * Refresh Location
55
- * </AtomicButton>
56
- * </View>
57
- * );
58
- * };
59
- *
60
- * // Alternative: Use service directly (for non-component code)
61
- * import { locationService } from '@umituz/react-native-location';
62
- *
63
- * const location = await locationService.getCurrentLocation();
64
- * if (location) {
65
- * console.log(locationService.formatLocation(location));
66
- * }
67
- * ```
68
- *
69
- * PLATFORM SUPPORT:
70
- * - ✅ iOS: Full support (GPS, permissions, geocoding)
71
- * - ✅ Android: Full support (GPS, permissions, geocoding)
72
- * - ❌ Web: Not supported (returns null)
73
- *
74
- * PERMISSION FLOW:
75
- * 1. Check: hasPermissions() → true/false
76
- * 2. Request: requestPermissions() → true/false
77
- * 3. Retrieve: getCurrentLocation() → LocationData | null
78
- *
79
- * FALLBACK STRATEGY:
80
- * 1. High accuracy GPS (15s timeout)
81
- * 2. Balanced accuracy GPS (8s timeout)
82
- * 3. Cached location (15min cache)
83
- * 4. null (no location available)
84
- *
85
- * CACHING:
86
- * - Duration: 15 minutes
87
- * - Storage: AsyncStorage (@location_cache)
88
- * - Auto-refresh: On getCurrentLocation() if expired
89
- */
90
- export { LocationAccuracy, LOCATION_CONSTANTS } from './domain/entities/Location';
91
- // Infrastructure Services
92
- export { locationService } from './infrastructure/services/LocationService';
93
- // Presentation Hooks
94
- export { useLocation } from './presentation/hooks/useLocation';
95
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;AAWH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAElF,0BAA0B;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAE5E,qBAAqB;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC"}
@@ -1,93 +0,0 @@
1
- /**
2
- * Location Service Implementation
3
- *
4
- * Handles device location retrieval, permissions, caching, and reverse geocoding
5
- * with intelligent fallback strategies
6
- *
7
- * Features:
8
- * - Multi-tier accuracy fallback (High → Balanced → Cached)
9
- * - 15-minute location caching for performance
10
- * - Reverse geocoding with coordinate fallback
11
- * - Platform detection (iOS/Android only, no web)
12
- * - Silent failures (no console logging)
13
- * - AsyncStorage persistence
14
- *
15
- * Dependencies:
16
- * - expo-location (GPS and permissions API)
17
- * - AsyncStorage (cache persistence)
18
- *
19
- * USAGE:
20
- * ```typescript
21
- * import { locationService } from '@umituz/react-native-location';
22
- *
23
- * // Check permission
24
- * const hasPermission = await locationService.hasPermissions();
25
- *
26
- * // Request permission if needed
27
- * if (!hasPermission) {
28
- * const granted = await locationService.requestPermissions();
29
- * }
30
- *
31
- * // Get current location
32
- * const location = await locationService.getCurrentLocation();
33
- * if (location) {
34
- * console.log(location.latitude, location.longitude);
35
- * console.log(locationService.formatLocation(location));
36
- * }
37
- * ```
38
- */
39
- import type { LocationData, LocationPermissionStatus, ILocationService } from '../../domain/entities/Location';
40
- declare class LocationService implements ILocationService {
41
- private cachedLocation;
42
- private cachedAt;
43
- private permissionStatus;
44
- constructor();
45
- /**
46
- * Check if location services are available on this platform
47
- */
48
- isLocationAvailable(): boolean;
49
- /**
50
- * Load cached location from AsyncStorage
51
- */
52
- private loadCachedLocation;
53
- /**
54
- * Save location to cache (AsyncStorage + memory)
55
- */
56
- private saveCachedLocation;
57
- /**
58
- * Get cached location if available and not expired
59
- */
60
- getCachedLocation(): LocationData | null;
61
- /**
62
- * Request location permissions from user
63
- */
64
- requestPermissions(): Promise<boolean>;
65
- /**
66
- * Check if location permissions are granted
67
- */
68
- hasPermissions(): Promise<boolean>;
69
- /**
70
- * Get permission status without requesting
71
- */
72
- getPermissionStatus(): LocationPermissionStatus;
73
- /**
74
- * Get current location with fallback strategies
75
- * Priority: High accuracy → Balanced accuracy → Cached location → null
76
- */
77
- getCurrentLocation(): Promise<LocationData | null>;
78
- /**
79
- * Get location with specific accuracy and timeout
80
- */
81
- private getLocationWithAccuracy;
82
- /**
83
- * Format location for display (address or coordinates)
84
- */
85
- formatLocation(location: LocationData): string;
86
- }
87
- /**
88
- * Singleton instance
89
- * Use this for all location operations
90
- */
91
- export declare const locationService: LocationService;
92
- export {};
93
- //# sourceMappingURL=LocationService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LocationService.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/services/LocationService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAMH,OAAO,KAAK,EACV,YAAY,EACZ,wBAAwB,EAExB,gBAAgB,EACjB,MAAM,gCAAgC,CAAC;AAGxC,cAAM,eAAgB,YAAW,gBAAgB;IAC/C,OAAO,CAAC,cAAc,CAA6B;IACnD,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,gBAAgB,CAAuC;;IAM/D;;OAEG;IACH,mBAAmB,IAAI,OAAO;IAQ9B;;OAEG;YACW,kBAAkB;IAkBhC;;OAEG;YACW,kBAAkB;IAiBhC;;OAEG;IACH,iBAAiB,IAAI,YAAY,GAAG,IAAI;IAWxC;;OAEG;IACG,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IAgB5C;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAoBxC;;OAEG;IACH,mBAAmB,IAAI,wBAAwB;IAI/C;;;OAGG;IACG,kBAAkB,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IA6CxD;;OAEG;YACW,uBAAuB;IAqDrC;;OAEG;IACH,cAAc,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM;CAQ/C;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,iBAAwB,CAAC"}
@@ -1,250 +0,0 @@
1
- /**
2
- * Location Service Implementation
3
- *
4
- * Handles device location retrieval, permissions, caching, and reverse geocoding
5
- * with intelligent fallback strategies
6
- *
7
- * Features:
8
- * - Multi-tier accuracy fallback (High → Balanced → Cached)
9
- * - 15-minute location caching for performance
10
- * - Reverse geocoding with coordinate fallback
11
- * - Platform detection (iOS/Android only, no web)
12
- * - Silent failures (no console logging)
13
- * - AsyncStorage persistence
14
- *
15
- * Dependencies:
16
- * - expo-location (GPS and permissions API)
17
- * - AsyncStorage (cache persistence)
18
- *
19
- * USAGE:
20
- * ```typescript
21
- * import { locationService } from '@umituz/react-native-location';
22
- *
23
- * // Check permission
24
- * const hasPermission = await locationService.hasPermissions();
25
- *
26
- * // Request permission if needed
27
- * if (!hasPermission) {
28
- * const granted = await locationService.requestPermissions();
29
- * }
30
- *
31
- * // Get current location
32
- * const location = await locationService.getCurrentLocation();
33
- * if (location) {
34
- * console.log(location.latitude, location.longitude);
35
- * console.log(locationService.formatLocation(location));
36
- * }
37
- * ```
38
- */
39
- import { Platform } from 'react-native';
40
- import * as Location from 'expo-location';
41
- import AsyncStorage from '@react-native-async-storage/async-storage';
42
- import { LOCATION_CONSTANTS } from '../../domain/entities/Location';
43
- class LocationService {
44
- constructor() {
45
- this.cachedLocation = null;
46
- this.cachedAt = 0;
47
- this.permissionStatus = 'unknown';
48
- this.loadCachedLocation();
49
- }
50
- /**
51
- * Check if location services are available on this platform
52
- */
53
- isLocationAvailable() {
54
- // Location services not available on web
55
- if (Platform.OS === 'web') {
56
- return false;
57
- }
58
- return true;
59
- }
60
- /**
61
- * Load cached location from AsyncStorage
62
- */
63
- async loadCachedLocation() {
64
- try {
65
- const cached = await AsyncStorage.getItem(LOCATION_CONSTANTS.CACHE_KEY);
66
- if (cached) {
67
- const parsed = JSON.parse(cached);
68
- if (Date.now() - parsed.cachedAt < LOCATION_CONSTANTS.CACHE_DURATION) {
69
- this.cachedLocation = parsed.data;
70
- this.cachedAt = parsed.cachedAt;
71
- }
72
- else {
73
- // Expired cache, remove it
74
- await AsyncStorage.removeItem(LOCATION_CONSTANTS.CACHE_KEY);
75
- }
76
- }
77
- }
78
- catch (error) {
79
- // Silent failure on cache load
80
- }
81
- }
82
- /**
83
- * Save location to cache (AsyncStorage + memory)
84
- */
85
- async saveCachedLocation(location) {
86
- try {
87
- const cached = {
88
- data: location,
89
- cachedAt: Date.now(),
90
- };
91
- this.cachedLocation = location;
92
- this.cachedAt = cached.cachedAt;
93
- await AsyncStorage.setItem(LOCATION_CONSTANTS.CACHE_KEY, JSON.stringify(cached));
94
- }
95
- catch (error) {
96
- // Silent failure on cache save
97
- }
98
- }
99
- /**
100
- * Get cached location if available and not expired
101
- */
102
- getCachedLocation() {
103
- if (!this.cachedLocation) {
104
- return null;
105
- }
106
- const age = Date.now() - this.cachedAt;
107
- if (age < LOCATION_CONSTANTS.CACHE_DURATION) {
108
- return { ...this.cachedLocation, isCached: true };
109
- }
110
- return null;
111
- }
112
- /**
113
- * Request location permissions from user
114
- */
115
- async requestPermissions() {
116
- if (!this.isLocationAvailable()) {
117
- this.permissionStatus = 'denied';
118
- return false;
119
- }
120
- try {
121
- const { status } = await Location.requestForegroundPermissionsAsync();
122
- this.permissionStatus = status === 'granted' ? 'granted' : 'denied';
123
- return status === 'granted';
124
- }
125
- catch (error) {
126
- this.permissionStatus = 'denied';
127
- return false;
128
- }
129
- }
130
- /**
131
- * Check if location permissions are granted
132
- */
133
- async hasPermissions() {
134
- if (!this.isLocationAvailable()) {
135
- return false;
136
- }
137
- // Use cached permission status if available
138
- if (this.permissionStatus !== 'unknown') {
139
- return this.permissionStatus === 'granted';
140
- }
141
- try {
142
- const { status } = await Location.getForegroundPermissionsAsync();
143
- this.permissionStatus = status === 'granted' ? 'granted' : 'denied';
144
- return status === 'granted';
145
- }
146
- catch (error) {
147
- this.permissionStatus = 'denied';
148
- return false;
149
- }
150
- }
151
- /**
152
- * Get permission status without requesting
153
- */
154
- getPermissionStatus() {
155
- return this.permissionStatus;
156
- }
157
- /**
158
- * Get current location with fallback strategies
159
- * Priority: High accuracy → Balanced accuracy → Cached location → null
160
- */
161
- async getCurrentLocation() {
162
- if (!this.isLocationAvailable()) {
163
- return null;
164
- }
165
- try {
166
- const hasPermission = await this.hasPermissions();
167
- if (!hasPermission) {
168
- const granted = await this.requestPermissions();
169
- if (!granted) {
170
- // Return cached location if available
171
- return this.getCachedLocation();
172
- }
173
- }
174
- // Try high accuracy first
175
- let locationData = await this.getLocationWithAccuracy(Location.Accuracy.High, LOCATION_CONSTANTS.HIGH_ACCURACY_TIMEOUT);
176
- // Fallback to balanced accuracy if high accuracy fails
177
- if (!locationData) {
178
- locationData = await this.getLocationWithAccuracy(Location.Accuracy.Balanced, LOCATION_CONSTANTS.BALANCED_ACCURACY_TIMEOUT);
179
- }
180
- // Fallback to cached location
181
- if (!locationData) {
182
- return this.getCachedLocation();
183
- }
184
- // Cache the new location
185
- await this.saveCachedLocation(locationData);
186
- return locationData;
187
- }
188
- catch (error) {
189
- // Return cached location as last resort
190
- return this.getCachedLocation();
191
- }
192
- }
193
- /**
194
- * Get location with specific accuracy and timeout
195
- */
196
- async getLocationWithAccuracy(accuracy, timeout) {
197
- try {
198
- const location = (await Promise.race([
199
- Location.getCurrentPositionAsync({ accuracy }),
200
- new Promise((_, reject) => setTimeout(() => reject(new Error('Timeout')), timeout)),
201
- ]));
202
- if (!location) {
203
- return null;
204
- }
205
- const locationData = {
206
- latitude: location.coords.latitude,
207
- longitude: location.coords.longitude,
208
- timestamp: Date.now(),
209
- accuracy: location.coords.accuracy ?? undefined,
210
- isCached: false,
211
- };
212
- // Try to get address (reverse geocoding)
213
- try {
214
- const addresses = await Location.reverseGeocodeAsync({
215
- latitude: location.coords.latitude,
216
- longitude: location.coords.longitude,
217
- });
218
- if (addresses && addresses.length > 0) {
219
- const address = addresses[0];
220
- const addressParts = [address.street, address.city, address.region].filter(Boolean);
221
- locationData.address =
222
- addressParts.join(', ') || 'Unknown location';
223
- }
224
- }
225
- catch (error) {
226
- // Fallback to coordinates if geocoding fails
227
- locationData.address = `${location.coords.latitude.toFixed(LOCATION_CONSTANTS.COORDINATE_PRECISION)}, ${location.coords.longitude.toFixed(LOCATION_CONSTANTS.COORDINATE_PRECISION)}`;
228
- }
229
- return locationData;
230
- }
231
- catch (error) {
232
- return null;
233
- }
234
- }
235
- /**
236
- * Format location for display (address or coordinates)
237
- */
238
- formatLocation(location) {
239
- if (location.address) {
240
- return location.address;
241
- }
242
- return `${location.latitude.toFixed(LOCATION_CONSTANTS.COORDINATE_PRECISION)}, ${location.longitude.toFixed(LOCATION_CONSTANTS.COORDINATE_PRECISION)}`;
243
- }
244
- }
245
- /**
246
- * Singleton instance
247
- * Use this for all location operations
248
- */
249
- export const locationService = new LocationService();
250
- //# sourceMappingURL=LocationService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LocationService.js","sourceRoot":"","sources":["../../../src/infrastructure/services/LocationService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,YAAY,MAAM,2CAA2C,CAAC;AAQrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,MAAM,eAAe;IAKnB;QAJQ,mBAAc,GAAwB,IAAI,CAAC;QAC3C,aAAQ,GAAW,CAAC,CAAC;QACrB,qBAAgB,GAA6B,SAAS,CAAC;QAG7D,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,mBAAmB;QACjB,yCAAyC;QACzC,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;YAC1B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,kBAAkB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MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CACxE,OAAO,CACR,CAAC;oBAEF,YAAY,CAAC,OAAO;wBAClB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,kBAAkB,CAAC;gBAClD,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,6CAA6C;gBAC7C,YAAY,CAAC,OAAO,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CACxD,kBAAkB,CAAC,oBAAoB,CACxC,KAAK,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,EAAE,CAAC;YACrF,CAAC;YAED,OAAO,YAAY,CAAC;QACtB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,QAAsB;QACnC,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;YACrB,OAAO,QAAQ,CAAC,OAAO,CAAC;QAC1B,CAAC;QACD,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,CACjC,kBAAkB,CAAC,oBAAoB,CACxC,KAAK,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,EAAE,CAAC;IAC9E,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC"}
@@ -1,95 +0,0 @@
1
- /**
2
- * useLocation Hook
3
- *
4
- * React hook for device location services
5
- * Wraps locationService with React-friendly state management
6
- *
7
- * Features:
8
- * - Get current location with loading state
9
- * - Permission management
10
- * - Cached location access
11
- * - Error handling
12
- * - Format locations for display
13
- *
14
- * USAGE:
15
- * ```typescript
16
- * import { useLocation } from '@umituz/react-native-location';
17
- *
18
- * const MyComponent = () => {
19
- * const {
20
- * location,
21
- * loading,
22
- * error,
23
- * hasPermission,
24
- * requestPermission,
25
- * getCurrentLocation,
26
- * getCached,
27
- * formatLocation,
28
- * } = useLocation();
29
- *
30
- * useEffect(() => {
31
- * // Auto-fetch location on mount
32
- * getCurrentLocation();
33
- * }, []);
34
- *
35
- * if (loading) return <LoadingIndicator />;
36
- * if (error) return <ErrorMessage message={error} />;
37
- *
38
- * return (
39
- * <View>
40
- * {location && (
41
- * <Text>Location: {formatLocation(location)}</Text>
42
- * )}
43
- * <AtomicButton onPress={getCurrentLocation}>
44
- * Refresh Location
45
- * </AtomicButton>
46
- * </View>
47
- * );
48
- * };
49
- * ```
50
- */
51
- import type { LocationData, LocationPermissionStatus } from '../../domain/entities/Location';
52
- export interface UseLocationReturn {
53
- /** Current location data (null if not retrieved) */
54
- location: LocationData | null;
55
- /** Loading state during location retrieval */
56
- loading: boolean;
57
- /** Error message if location retrieval failed */
58
- error: string | null;
59
- /** Current permission status */
60
- permissionStatus: LocationPermissionStatus;
61
- /** Whether location permissions are granted */
62
- hasPermission: boolean;
63
- /** Whether location services are available on this platform */
64
- isAvailable: boolean;
65
- /**
66
- * Request location permissions from user
67
- * @returns Promise resolving to true if granted
68
- */
69
- requestPermission: () => Promise<boolean>;
70
- /**
71
- * Get current location with fallback strategies
72
- * Updates location state and handles errors
73
- */
74
- getCurrentLocation: () => Promise<void>;
75
- /**
76
- * Get cached location if available
77
- * @returns Cached location or null
78
- */
79
- getCached: () => LocationData | null;
80
- /**
81
- * Format location for display
82
- * @param loc - LocationData to format
83
- * @returns Formatted string (address or coordinates)
84
- */
85
- formatLocation: (loc: LocationData) => string;
86
- /**
87
- * Clear current location state
88
- */
89
- clearLocation: () => void;
90
- }
91
- /**
92
- * Hook for device location services
93
- */
94
- export declare const useLocation: () => UseLocationReturn;
95
- //# sourceMappingURL=useLocation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLocation.d.ts","sourceRoot":"","sources":["../../../src/presentation/hooks/useLocation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAIH,OAAO,KAAK,EACV,YAAY,EACZ,wBAAwB,EACzB,MAAM,gCAAgC,CAAC;AAExC,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC;IAE9B,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IAEjB,iDAAiD;IACjD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAErB,gCAAgC;IAChC,gBAAgB,EAAE,wBAAwB,CAAC;IAE3C,+CAA+C;IAC/C,aAAa,EAAE,OAAO,CAAC;IAEvB,+DAA+D;IAC/D,WAAW,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,iBAAiB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAE1C;;;OAGG;IACH,kBAAkB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAExC;;;OAGG;IACH,SAAS,EAAE,MAAM,YAAY,GAAG,IAAI,CAAC;IAErC;;;;OAIG;IACH,cAAc,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAC;IAE9C;;OAEG;IACH,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,QAAO,iBAiH9B,CAAC"}
@@ -1,156 +0,0 @@
1
- /**
2
- * useLocation Hook
3
- *
4
- * React hook for device location services
5
- * Wraps locationService with React-friendly state management
6
- *
7
- * Features:
8
- * - Get current location with loading state
9
- * - Permission management
10
- * - Cached location access
11
- * - Error handling
12
- * - Format locations for display
13
- *
14
- * USAGE:
15
- * ```typescript
16
- * import { useLocation } from '@umituz/react-native-location';
17
- *
18
- * const MyComponent = () => {
19
- * const {
20
- * location,
21
- * loading,
22
- * error,
23
- * hasPermission,
24
- * requestPermission,
25
- * getCurrentLocation,
26
- * getCached,
27
- * formatLocation,
28
- * } = useLocation();
29
- *
30
- * useEffect(() => {
31
- * // Auto-fetch location on mount
32
- * getCurrentLocation();
33
- * }, []);
34
- *
35
- * if (loading) return <LoadingIndicator />;
36
- * if (error) return <ErrorMessage message={error} />;
37
- *
38
- * return (
39
- * <View>
40
- * {location && (
41
- * <Text>Location: {formatLocation(location)}</Text>
42
- * )}
43
- * <AtomicButton onPress={getCurrentLocation}>
44
- * Refresh Location
45
- * </AtomicButton>
46
- * </View>
47
- * );
48
- * };
49
- * ```
50
- */
51
- import { useState, useCallback, useEffect } from 'react';
52
- import { locationService } from '../../infrastructure/services/LocationService';
53
- /**
54
- * Hook for device location services
55
- */
56
- export const useLocation = () => {
57
- const [location, setLocation] = useState(null);
58
- const [loading, setLoading] = useState(false);
59
- const [error, setError] = useState(null);
60
- const [permissionStatus, setPermissionStatus] = useState('unknown');
61
- // Check if location services are available
62
- const isAvailable = locationService.isLocationAvailable();
63
- // Check initial permission status
64
- useEffect(() => {
65
- const checkPermission = async () => {
66
- const hasPermission = await locationService.hasPermissions();
67
- setPermissionStatus(hasPermission ? 'granted' : locationService.getPermissionStatus());
68
- };
69
- if (isAvailable) {
70
- checkPermission();
71
- }
72
- }, [isAvailable]);
73
- /**
74
- * Request location permissions
75
- */
76
- const requestPermission = useCallback(async () => {
77
- if (!isAvailable) {
78
- setError('Location services not available on this platform');
79
- setPermissionStatus('denied');
80
- return false;
81
- }
82
- try {
83
- const granted = await locationService.requestPermissions();
84
- setPermissionStatus(granted ? 'granted' : 'denied');
85
- if (!granted) {
86
- setError('Location permission denied');
87
- }
88
- return granted;
89
- }
90
- catch (err) {
91
- setError('Failed to request location permission');
92
- setPermissionStatus('denied');
93
- return false;
94
- }
95
- }, [isAvailable]);
96
- /**
97
- * Get current location with fallback strategies
98
- */
99
- const getCurrentLocation = useCallback(async () => {
100
- if (!isAvailable) {
101
- setError('Location services not available on this platform');
102
- return;
103
- }
104
- setLoading(true);
105
- setError(null);
106
- try {
107
- const currentLocation = await locationService.getCurrentLocation();
108
- if (currentLocation) {
109
- setLocation(currentLocation);
110
- setError(null);
111
- }
112
- else {
113
- setError('Unable to retrieve location');
114
- }
115
- }
116
- catch (err) {
117
- setError('Failed to get location');
118
- }
119
- finally {
120
- setLoading(false);
121
- }
122
- }, [isAvailable]);
123
- /**
124
- * Get cached location
125
- */
126
- const getCached = useCallback(() => {
127
- return locationService.getCachedLocation();
128
- }, []);
129
- /**
130
- * Format location for display
131
- */
132
- const formatLocation = useCallback((loc) => {
133
- return locationService.formatLocation(loc);
134
- }, []);
135
- /**
136
- * Clear location state
137
- */
138
- const clearLocation = useCallback(() => {
139
- setLocation(null);
140
- setError(null);
141
- }, []);
142
- return {
143
- location,
144
- loading,
145
- error,
146
- permissionStatus,
147
- hasPermission: permissionStatus === 'granted',
148
- isAvailable,
149
- requestPermission,
150
- getCurrentLocation,
151
- getCached,
152
- formatLocation,
153
- clearLocation,
154
- };
155
- };
156
- //# sourceMappingURL=useLocation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLocation.js","sourceRoot":"","sources":["../../../src/presentation/hooks/useLocation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC;AAwDhF;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,GAAsB,EAAE;IACjD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAsB,IAAI,CAAC,CAAC;IACpE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IACvD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IACxD,MAAM,CA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