@angelrove/forecast-utils 1.1.14 → 1.1.17

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
@@ -1,15 +1,11 @@
1
1
  # @forecast-utils
2
2
 
3
- Several utility libraries for my "tierracolora.com" project:
4
- - Forecast API (OpenWeather)
5
- - Astronomy utilities
6
- - Geolocation
7
- - Another utilities.
3
+ Several utility libraries for my "tierracolora.com" project.
8
4
 
9
- Includes directory *images/ws* with weather images (symbols)
5
+ Includes directory `images/ws` with weather images (symbols)
10
6
 
11
7
  I use private libraries for the following:
12
- - Astronomy calculations: suncalc3
8
+ - Astronomy calculations: `suncalc3`
13
9
 
14
10
  # Documentation
15
11
  ## Modules
@@ -31,7 +27,8 @@ Con excepción de 'getSolarTime()': recibe la hora local correspondiente
31
27
  <dt><a href="#module_Geolocation">Geolocation</a></dt>
32
28
  <dd></dd>
33
29
  <dt><a href="#module_OpenMeteo">OpenMeteo</a></dt>
34
- <dd></dd>
30
+ <dd><p>Use the OpenWeather forecast API</p>
31
+ </dd>
35
32
  <dt><a href="#module_Utils">Utils</a></dt>
36
33
  <dd></dd>
37
34
  <dt><a href="#module_Utils/TimeDateStr">Utils/TimeDateStr</a></dt>
@@ -312,8 +309,9 @@ Con excepción de 'getSolarTime()': recibe la hora local correspondiente a la lo
312
309
  ## Geolocation
313
310
 
314
311
  * [Geolocation](#module_Geolocation)
315
- * [.exports.getGeolocation()](#module_Geolocation.exports.getGeolocation) ⇒ <code>Promise.&lt;{latitude: number, longitude: number, formatted\_address: string}&gt;</code>
312
+ * [.exports.getGeolocation()](#module_Geolocation.exports.getGeolocation) ⇒ <code>Promise.&lt;ResolvedLocation&gt;</code>
316
313
  * [.exports.timeFromLocation(apiKey, lat, lng)](#module_Geolocation.exports.timeFromLocation) ⇒ <code>Promise.&lt;(any\|LocalTimeData)&gt;</code>
314
+ * [.ResolvedLocation](#module_Geolocation.ResolvedLocation) : <code>Object</code>
317
315
  * [.LocalTimeData](#module_Geolocation.LocalTimeData) : <code>Object</code>
318
316
 
319
317
 
@@ -321,11 +319,11 @@ Con excepción de 'getSolarTime()': recibe la hora local correspondiente a la lo
321
319
 
322
320
  <a name="module_Geolocation.exports.getGeolocation"></a>
323
321
 
324
- ### Geolocation.exports.getGeolocation() ⇒ <code>Promise.&lt;{latitude: number, longitude: number, formatted\_address: string}&gt;</code>
322
+ ### Geolocation.exports.getGeolocation() ⇒ <code>Promise.&lt;ResolvedLocation&gt;</code>
325
323
  Get the current geolocation of the device and reverse geocode it to get the address.
326
324
 
327
325
  **Kind**: static method of [<code>Geolocation</code>](#module_Geolocation)
328
- **Returns**: <code>Promise.&lt;{latitude: number, longitude: number, formatted\_address: string}&gt;</code> - Promise
326
+ **Returns**: <code>Promise.&lt;ResolvedLocation&gt;</code> - Promise
329
327
  **Throws**:
330
328
 
331
329
  - <code>Error</code> If geolocation is not supported or permission is denied.
@@ -352,6 +350,25 @@ Get local time from a given location (lat, lng) using 'GoogleMaps TimeZone' API.
352
350
  | lng | <code>number</code> | |
353
351
 
354
352
 
353
+ * * *
354
+
355
+ <a name="module_Geolocation.ResolvedLocation"></a>
356
+
357
+ ### Geolocation.ResolvedLocation : <code>Object</code>
358
+ **Kind**: static typedef of [<code>Geolocation</code>](#module_Geolocation)
359
+ **Properties**
360
+
361
+ | Name | Type | Description |
362
+ | --- | --- | --- |
363
+ | latitude | <code>number</code> | |
364
+ | longitude | <code>number</code> | // Address |
365
+ | sublocality | <code>string</code> | |
366
+ | locality | <code>string</code> | |
367
+ | country | <code>string</code> | |
368
+ | country_short | <code>string</code> | |
369
+ | formatted_address | <code>string</code> | |
370
+
371
+
355
372
  * * *
356
373
 
357
374
  <a name="module_Geolocation.LocalTimeData"></a>
@@ -376,6 +393,8 @@ Get local time from a given location (lat, lng) using 'GoogleMaps TimeZone' API.
376
393
  <a name="module_OpenMeteo"></a>
377
394
 
378
395
  ## OpenMeteo
396
+ Use the OpenWeather forecast API
397
+
379
398
 
380
399
  * [OpenMeteo](#module_OpenMeteo)
381
400
  * [.exports.useForecastCurrent(lat, lon, refreshIntervalMin)](#module_OpenMeteo.exports.useForecastCurrent) ⇒ <code>ForecastData</code>
@@ -1,12 +1,32 @@
1
+ /**
2
+ * @memberof module:Geolocation
3
+ * @typedef {Object} ResolvedLocation
4
+ * @property {number} latitude
5
+ * @property {number} longitude
6
+ * // Address
7
+ * @property {string} sublocality
8
+ * @property {string} locality
9
+ * @property {string} country
10
+ * @property {string} country_short
11
+ * @property {string} formatted_address
12
+ */
1
13
  /**
2
14
  * Get the current geolocation of the device and reverse geocode it to get the address.
3
15
  *
4
- * @returns {Promise<{latitude: number, longitude: number, formatted_address: string}>} Promise
5
- * @throws {Error} If geolocation is not supported or permission is denied.
6
16
  * @memberof module:Geolocation
17
+ * @returns {Promise<ResolvedLocation>} Promise
18
+ * @throws {Error} If geolocation is not supported or permission is denied.
7
19
  */
8
- export function getGeolocation(): Promise<{
20
+ export function getGeolocation(): Promise<ResolvedLocation>;
21
+ export type ResolvedLocation = {
9
22
  latitude: number;
23
+ /**
24
+ * // Address
25
+ */
10
26
  longitude: number;
27
+ sublocality: string;
28
+ locality: string;
29
+ country: string;
30
+ country_short: string;
11
31
  formatted_address: string;
12
- }>;
32
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Jose Angel Romero Vegas",
3
3
  "name": "@angelrove/forecast-utils",
4
- "version": "1.1.14",
4
+ "version": "1.1.17",
5
5
  "description": "Utilities for obtaining weather and astronomy forecast data.",
6
6
  "license": "MIT",
7
7
  "publishConfig": {
@@ -38,11 +38,11 @@
38
38
  "@capacitor/geolocation": "^7.1.2"
39
39
  },
40
40
  "devDependencies": {
41
- "@biomejs/biome": "1.9.4",
42
- "@types/react": "^19.1.5",
43
- "@types/react-dom": "^19.1.5",
44
- "jsdoc-to-markdown": "^9.1.1",
45
- "typescript": "^5.8.3"
41
+ "@biomejs/biome": "2.2.4",
42
+ "@types/react": "^19.1.12",
43
+ "@types/react-dom": "^19.1.9",
44
+ "jsdoc-to-markdown": "^9.1.2",
45
+ "typescript": "^5.9.2"
46
46
  },
47
47
  "dependencies": {}
48
48
  }
@@ -1,4 +1,5 @@
1
1
  /**
2
+ * Use the OpenWeather forecast API
2
3
  * @module OpenMeteo
3
4
  *
4
5
  */
@@ -1,15 +1,28 @@
1
1
  import geolocationCapacitor from "./lib/geolocation.js";
2
2
  import reverseGeocoding from "./lib/reversegeocoding.js";
3
3
 
4
+ /**
5
+ * @memberof module:Geolocation
6
+ * @typedef {Object} ResolvedLocation
7
+ * @property {number} latitude
8
+ * @property {number} longitude
9
+ * // Address
10
+ * @property {string} sublocality
11
+ * @property {string} locality
12
+ * @property {string} country
13
+ * @property {string} country_short
14
+ * @property {string} formatted_address
15
+ */
16
+
4
17
  /**
5
18
  * Get the current geolocation of the device and reverse geocode it to get the address.
6
19
  *
7
- * @returns {Promise<{latitude: number, longitude: number, formatted_address: string}>} Promise
8
- * @throws {Error} If geolocation is not supported or permission is denied.
9
20
  * @memberof module:Geolocation
21
+ * @returns {Promise<ResolvedLocation>} Promise
22
+ * @throws {Error} If geolocation is not supported or permission is denied.
10
23
  */
11
24
  export async function getGeolocation() {
12
- let location = null;
25
+ let location;
13
26
  let address = null;
14
27
 
15
28
  // Location ---
@@ -33,6 +46,10 @@ export async function getGeolocation() {
33
46
  const message = error instanceof Error ? error.message : error;
34
47
  console.log("reverseGeocoding - error: ", message);
35
48
  address = {
49
+ sublocality: "",
50
+ locality: "",
51
+ country: "",
52
+ country_short: "",
36
53
  formatted_address:
37
54
  "[" + location.latitude + ", " + location.longitude + "]",
38
55
  };
@@ -40,8 +57,13 @@ export async function getGeolocation() {
40
57
 
41
58
  // Return data ---
42
59
  return {
43
- ...location,
44
- ...address,
60
+ latitude: location.latitude,
61
+ longitude: location.longitude,
62
+ sublocality: address.sublocality,
63
+ locality: address.locality,
64
+ country: address.country,
65
+ country_short: address.country_short,
66
+ formatted_address: address.formatted_address,
45
67
  };
46
68
  }
47
69
  //--------------------------------------------