@angelrove/forecast-utils 1.1.8 → 1.1.10
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 +92 -16
- package/dist/types/OpenMeteo/current/useForecastCurrent.d.ts +2 -7
- package/dist/types/OpenMeteo/daily/useForecastDaily.d.ts +2 -6
- package/dist/types/OpenMeteo/hourly/useForecastHourly.d.ts +3 -7
- package/dist/types/OpenMeteo/types.d.ts +18 -0
- package/dist/types/OpenMeteo/weatherSymbol/weatherSymbol.d.ts +1 -0
- package/dist/types/astronomy/moon/MoonCalc.d.ts +26 -16
- package/dist/types/astronomy/sun/SunCalc.d.ts +11 -8
- package/dist/types/geolocation/getGeolocation.d.ts +1 -1
- package/dist/types/geolocation/timeFromLocation.d.ts +44 -3
- package/dist/types/utils/degreesToCompass.d.ts +1 -1
- package/dist/types/utils/timehelpers.d.ts +1 -1
- package/dist/types/utils/warning.d.ts +2 -0
- package/dist/types/utils/wind/windArrowTx.d.ts +2 -4
- package/package.json +1 -1
- package/src/OpenMeteo/current/useForecastCurrent.js +2 -5
- package/src/OpenMeteo/daily/useForecastDaily.js +3 -5
- package/src/OpenMeteo/hourly/useForecastHourly.js +4 -6
- package/src/OpenMeteo/types.js +8 -0
- package/src/OpenMeteo/weatherSymbol/weatherSymbol.js +1 -4
- package/src/astronomy/moon/MoonCalc.js +37 -14
- package/src/astronomy/sun/SunCalc.js +9 -6
- package/src/geolocation/getGeolocation.js +1 -1
- package/src/geolocation/timeFromLocation.js +15 -3
- package/src/utils/degreesToCompass.js +1 -1
- package/src/utils/timehelpers.js +1 -1
- package/src/utils/warning.js +2 -0
- package/src/utils/wind/windArrowTx.js +2 -4
- package/src/utils/wind/windLevel.js +0 -4
- package/src/astronomy/types.js +0 -20
package/README.md
CHANGED
|
@@ -39,10 +39,11 @@ Importante!:
|
|
|
39
39
|
* [Astronomy/MoonCalc](#module_Astronomy/MoonCalc)
|
|
40
40
|
* [.phasesES](#module_Astronomy/MoonCalc.phasesES) : <code>Object.<string, string></code>
|
|
41
41
|
* [.data(latitude, longitude, [date], [language])](#module_Astronomy/MoonCalc.data) ⇒ <code>MoonData</code>
|
|
42
|
-
* [.dataExt(latitude, longitude, [date], [language])](#module_Astronomy/MoonCalc.dataExt) ⇒ <code>
|
|
42
|
+
* [.dataExt(latitude, longitude, [date], [language])](#module_Astronomy/MoonCalc.dataExt) ⇒ <code>MoonDataExt</code>
|
|
43
43
|
* [.emoji(latitude, longitude, [date])](#module_Astronomy/MoonCalc.emoji) ⇒ <code>string</code>
|
|
44
44
|
* [.times(latitude, longitude, timezoneId, date)](#module_Astronomy/MoonCalc.times) ⇒ <code>Object</code>
|
|
45
45
|
* [.getUpOrDown(altitude, highest)](#module_Astronomy/MoonCalc.getUpOrDown) ⇒ <code>string</code>
|
|
46
|
+
* [.MoonDataExt](#module_Astronomy/MoonCalc.MoonDataExt) : <code>Object</code>
|
|
46
47
|
* [.MoonData](#module_Astronomy/MoonCalc.MoonData) : <code>Object</code>
|
|
47
48
|
|
|
48
49
|
|
|
@@ -62,6 +63,7 @@ Mapa de fases lunares.
|
|
|
62
63
|
|
|
63
64
|
### Astronomy/MoonCalc.data(latitude, longitude, [date], [language]) ⇒ <code>MoonData</code>
|
|
64
65
|
**Kind**: static method of [<code>Astronomy/MoonCalc</code>](#module_Astronomy/MoonCalc)
|
|
66
|
+
**Returns**: <code>MoonData</code> - Moon info object
|
|
65
67
|
|
|
66
68
|
| Param | Type | Default |
|
|
67
69
|
| --- | --- | --- |
|
|
@@ -75,11 +77,12 @@ Mapa de fases lunares.
|
|
|
75
77
|
|
|
76
78
|
<a name="module_Astronomy/MoonCalc.dataExt"></a>
|
|
77
79
|
|
|
78
|
-
### Astronomy/MoonCalc.dataExt(latitude, longitude, [date], [language]) ⇒ <code>
|
|
80
|
+
### Astronomy/MoonCalc.dataExt(latitude, longitude, [date], [language]) ⇒ <code>MoonDataExt</code>
|
|
79
81
|
Información de la luna para una fecha y hora dadas.
|
|
80
82
|
La fecha y hora se devolverán en la zona horaria local.
|
|
81
83
|
|
|
82
84
|
**Kind**: static method of [<code>Astronomy/MoonCalc</code>](#module_Astronomy/MoonCalc)
|
|
85
|
+
**Returns**: <code>MoonDataExt</code> - Full information
|
|
83
86
|
|
|
84
87
|
| Param | Type | Default |
|
|
85
88
|
| --- | --- | --- |
|
|
@@ -95,7 +98,7 @@ La fecha y hora se devolverán en la zona horaria local.
|
|
|
95
98
|
|
|
96
99
|
### Astronomy/MoonCalc.emoji(latitude, longitude, [date]) ⇒ <code>string</code>
|
|
97
100
|
**Kind**: static method of [<code>Astronomy/MoonCalc</code>](#module_Astronomy/MoonCalc)
|
|
98
|
-
**Returns**: <code>string</code> -
|
|
101
|
+
**Returns**: <code>string</code> - Emoji of the moon phase
|
|
99
102
|
|
|
100
103
|
| Param | Type | Default |
|
|
101
104
|
| --- | --- | --- |
|
|
@@ -110,6 +113,7 @@ La fecha y hora se devolverán en la zona horaria local.
|
|
|
110
113
|
|
|
111
114
|
### Astronomy/MoonCalc.times(latitude, longitude, timezoneId, date) ⇒ <code>Object</code>
|
|
112
115
|
**Kind**: static method of [<code>Astronomy/MoonCalc</code>](#module_Astronomy/MoonCalc)
|
|
116
|
+
**Returns**: <code>Object</code> - Moon times
|
|
113
117
|
|
|
114
118
|
| Param | Type |
|
|
115
119
|
| --- | --- |
|
|
@@ -133,6 +137,28 @@ La fecha y hora se devolverán en la zona horaria local.
|
|
|
133
137
|
| highest | <code>Date</code> |
|
|
134
138
|
|
|
135
139
|
|
|
140
|
+
* * *
|
|
141
|
+
|
|
142
|
+
<a name="module_Astronomy/MoonCalc.MoonDataExt"></a>
|
|
143
|
+
|
|
144
|
+
### Astronomy/MoonCalc.MoonDataExt : <code>Object</code>
|
|
145
|
+
**Kind**: static typedef of [<code>Astronomy/MoonCalc</code>](#module_Astronomy/MoonCalc)
|
|
146
|
+
**Properties**
|
|
147
|
+
|
|
148
|
+
| Name | Type |
|
|
149
|
+
| --- | --- |
|
|
150
|
+
| date | <code>string</code> |
|
|
151
|
+
| time | <code>string</code> |
|
|
152
|
+
| illumination | <code>string</code> |
|
|
153
|
+
| phase | <code>string</code> |
|
|
154
|
+
| phaseId | <code>string</code> |
|
|
155
|
+
| emoji | <code>string</code> |
|
|
156
|
+
| parallacticAngle | <code>number</code> |
|
|
157
|
+
| angle | <code>number</code> |
|
|
158
|
+
| position | <code>AstroPosition</code> |
|
|
159
|
+
| next | <code>Object</code> |
|
|
160
|
+
|
|
161
|
+
|
|
136
162
|
* * *
|
|
137
163
|
|
|
138
164
|
<a name="module_Astronomy/MoonCalc.MoonData"></a>
|
|
@@ -178,6 +204,7 @@ Con excepción de 'getSolarTime()': recibe la hora local correspondiente a la lo
|
|
|
178
204
|
|
|
179
205
|
### Astronomy/SunCalc.all(date, latitude, longitude, timezoneId) ⇒ <code>Object</code>
|
|
180
206
|
**Kind**: static method of [<code>Astronomy/SunCalc</code>](#module_Astronomy/SunCalc)
|
|
207
|
+
**Returns**: <code>Object</code> - { sunTimes: Object, sunPosition: Object, sunPhase: string }
|
|
181
208
|
|
|
182
209
|
| Param | Type |
|
|
183
210
|
| --- | --- |
|
|
@@ -193,6 +220,7 @@ Con excepción de 'getSolarTime()': recibe la hora local correspondiente a la lo
|
|
|
193
220
|
|
|
194
221
|
### Astronomy/SunCalc.times(date, latitude, longitude, timezoneId) ⇒ <code>Object</code>
|
|
195
222
|
**Kind**: static method of [<code>Astronomy/SunCalc</code>](#module_Astronomy/SunCalc)
|
|
223
|
+
**Returns**: <code>Object</code> - { date: Date, sunrise: string, sunset: string, noon: string, dawn: string, dusk: string }
|
|
196
224
|
|
|
197
225
|
| Param | Type |
|
|
198
226
|
| --- | --- |
|
|
@@ -208,7 +236,7 @@ Con excepción de 'getSolarTime()': recibe la hora local correspondiente a la lo
|
|
|
208
236
|
|
|
209
237
|
### Astronomy/SunCalc.getSolarTime(date, lng, offsetSign, offset) ⇒ <code>string</code>
|
|
210
238
|
**Kind**: static method of [<code>Astronomy/SunCalc</code>](#module_Astronomy/SunCalc)
|
|
211
|
-
**Returns**: <code>string</code> -
|
|
239
|
+
**Returns**: <code>string</code> - Local time in "HH:mm" format
|
|
212
240
|
|
|
213
241
|
| Param | Type | Description |
|
|
214
242
|
| --- | --- | --- |
|
|
@@ -224,6 +252,7 @@ Con excepción de 'getSolarTime()': recibe la hora local correspondiente a la lo
|
|
|
224
252
|
|
|
225
253
|
### Astronomy/SunCalc.position(latitude, longitude) ⇒ <code>Object</code>
|
|
226
254
|
**Kind**: static method of [<code>Astronomy/SunCalc</code>](#module_Astronomy/SunCalc)
|
|
255
|
+
**Returns**: <code>Object</code> - {date: string, azimuth: number, direction: string, direction_full: string, altitude: number, zenith: number, declination: number}
|
|
227
256
|
|
|
228
257
|
| Param | Type |
|
|
229
258
|
| --- | --- |
|
|
@@ -237,7 +266,7 @@ Con excepción de 'getSolarTime()': recibe la hora local correspondiente a la lo
|
|
|
237
266
|
|
|
238
267
|
### Astronomy/SunCalc.getIsNight(lat, lon, timezoneId, date, dateStr) ⇒ <code>boolean</code>
|
|
239
268
|
**Kind**: static method of [<code>Astronomy/SunCalc</code>](#module_Astronomy/SunCalc)
|
|
240
|
-
**Returns**: <code>boolean</code> -
|
|
269
|
+
**Returns**: <code>boolean</code> - true if it's night, false otherwise
|
|
241
270
|
|
|
242
271
|
| Param | Type |
|
|
243
272
|
| --- | --- |
|
|
@@ -254,7 +283,7 @@ Con excepción de 'getSolarTime()': recibe la hora local correspondiente a la lo
|
|
|
254
283
|
|
|
255
284
|
### Astronomy/SunCalc.getPhase(altitude, noon) ⇒ <code>string</code>
|
|
256
285
|
**Kind**: static method of [<code>Astronomy/SunCalc</code>](#module_Astronomy/SunCalc)
|
|
257
|
-
**Returns**: <code>string</code> -
|
|
286
|
+
**Returns**: <code>string</code> - The phase of the sun based on its altitude
|
|
258
287
|
|
|
259
288
|
| Param | Type |
|
|
260
289
|
| --- | --- |
|
|
@@ -271,6 +300,7 @@ Con excepción de 'getSolarTime()': recibe la hora local correspondiente a la lo
|
|
|
271
300
|
* [Geolocation](#module_Geolocation)
|
|
272
301
|
* [.exports.getGeolocation()](#module_Geolocation.exports.getGeolocation) ⇒ <code>Promise.<{latitude: number, longitude: number, formatted\_address: string}></code>
|
|
273
302
|
* [.exports.timeFromLocation(apiKey, lat, lng)](#module_Geolocation.exports.timeFromLocation) ⇒ <code>Promise.<(any\|LocalTimeData)></code>
|
|
303
|
+
* [.LocalTimeData](#module_Geolocation.LocalTimeData) : <code>Object</code>
|
|
274
304
|
|
|
275
305
|
|
|
276
306
|
* * *
|
|
@@ -281,6 +311,7 @@ Con excepción de 'getSolarTime()': recibe la hora local correspondiente a la lo
|
|
|
281
311
|
Get the current geolocation of the device and reverse geocode it to get the address.
|
|
282
312
|
|
|
283
313
|
**Kind**: static method of [<code>Geolocation</code>](#module_Geolocation)
|
|
314
|
+
**Returns**: <code>Promise.<{latitude: number, longitude: number, formatted\_address: string}></code> - Promise
|
|
284
315
|
**Throws**:
|
|
285
316
|
|
|
286
317
|
- <code>Error</code> If geolocation is not supported or permission is denied.
|
|
@@ -294,10 +325,10 @@ Get the current geolocation of the device and reverse geocode it to get the addr
|
|
|
294
325
|
Get local time from a given location (lat, lng) using 'GoogleMaps TimeZone' API.
|
|
295
326
|
|
|
296
327
|
**Kind**: static method of [<code>Geolocation</code>](#module_Geolocation)
|
|
297
|
-
**Returns**: <code>Promise.<(any\|LocalTimeData)></code> -
|
|
328
|
+
**Returns**: <code>Promise.<(any\|LocalTimeData)></code> - An object containing the local time and timezone information:
|
|
298
329
|
**Throws**:
|
|
299
330
|
|
|
300
|
-
- <code>Error</code>
|
|
331
|
+
- <code>Error</code> If the API request fails or returns an error status.
|
|
301
332
|
|
|
302
333
|
|
|
303
334
|
| Param | Type | Description |
|
|
@@ -307,6 +338,25 @@ Get local time from a given location (lat, lng) using 'GoogleMaps TimeZone' API.
|
|
|
307
338
|
| lng | <code>number</code> | |
|
|
308
339
|
|
|
309
340
|
|
|
341
|
+
* * *
|
|
342
|
+
|
|
343
|
+
<a name="module_Geolocation.LocalTimeData"></a>
|
|
344
|
+
|
|
345
|
+
### Geolocation.LocalTimeData : <code>Object</code>
|
|
346
|
+
**Kind**: static typedef of [<code>Geolocation</code>](#module_Geolocation)
|
|
347
|
+
**Properties**
|
|
348
|
+
|
|
349
|
+
| Name | Type | Description |
|
|
350
|
+
| --- | --- | --- |
|
|
351
|
+
| time | <code>Date</code> | The local time. |
|
|
352
|
+
| timeStr | <code>string</code> | The formatted local time string. |
|
|
353
|
+
| timezone | <code>string</code> | The timezone name. |
|
|
354
|
+
| timezoneId | <code>string</code> | The timezone ID. |
|
|
355
|
+
| offset | <code>number</code> | The UTC offset in hours. |
|
|
356
|
+
| offsetSign | <code>string</code> | The sign of the offset ('+' or '-'). |
|
|
357
|
+
| dstOffset | <code>number</code> | The DST offset in hours. |
|
|
358
|
+
|
|
359
|
+
|
|
310
360
|
* * *
|
|
311
361
|
|
|
312
362
|
<a name="module_OpenMeteo"></a>
|
|
@@ -314,20 +364,22 @@ Get local time from a given location (lat, lng) using 'GoogleMaps TimeZone' API.
|
|
|
314
364
|
## OpenMeteo
|
|
315
365
|
|
|
316
366
|
* [OpenMeteo](#module_OpenMeteo)
|
|
317
|
-
* [.exports.useForecastCurrent(lat, lon, refreshIntervalMin)](#module_OpenMeteo.exports.useForecastCurrent) ⇒ <code>
|
|
318
|
-
* [.exports.useForecastDaily(lat, lon, refreshIntervalMin)](#module_OpenMeteo.exports.useForecastDaily) ⇒ <code>
|
|
319
|
-
* [.exports.useForecastHourly(location, dayNum)](#module_OpenMeteo.exports.useForecastHourly) ⇒ <code>
|
|
367
|
+
* [.exports.useForecastCurrent(lat, lon, refreshIntervalMin)](#module_OpenMeteo.exports.useForecastCurrent) ⇒ <code>ForecastData</code>
|
|
368
|
+
* [.exports.useForecastDaily(lat, lon, refreshIntervalMin)](#module_OpenMeteo.exports.useForecastDaily) ⇒ <code>ForecastData</code>
|
|
369
|
+
* [.exports.useForecastHourly(location, dayNum)](#module_OpenMeteo.exports.useForecastHourly) ⇒ <code>ForecastData</code>
|
|
320
370
|
* [.exports.weatherSymbol(code, [precipitation], night, dark)](#module_OpenMeteo.exports.weatherSymbol) ⇒ <code>Object</code>
|
|
371
|
+
* [.ForecastData](#module_OpenMeteo.ForecastData) : <code>Object</code>
|
|
321
372
|
|
|
322
373
|
|
|
323
374
|
* * *
|
|
324
375
|
|
|
325
376
|
<a name="module_OpenMeteo.exports.useForecastCurrent"></a>
|
|
326
377
|
|
|
327
|
-
### OpenMeteo.exports.useForecastCurrent(lat, lon, refreshIntervalMin) ⇒ <code>
|
|
378
|
+
### OpenMeteo.exports.useForecastCurrent(lat, lon, refreshIntervalMin) ⇒ <code>ForecastData</code>
|
|
328
379
|
Custom hook to fetch current weather data from OpenMeteo API.
|
|
329
380
|
|
|
330
381
|
**Kind**: static method of [<code>OpenMeteo</code>](#module_OpenMeteo)
|
|
382
|
+
**Returns**: <code>ForecastData</code> - -
|
|
331
383
|
|
|
332
384
|
| Param | Type |
|
|
333
385
|
| --- | --- |
|
|
@@ -340,11 +392,12 @@ Custom hook to fetch current weather data from OpenMeteo API.
|
|
|
340
392
|
|
|
341
393
|
<a name="module_OpenMeteo.exports.useForecastDaily"></a>
|
|
342
394
|
|
|
343
|
-
### OpenMeteo.exports.useForecastDaily(lat, lon, refreshIntervalMin) ⇒ <code>
|
|
395
|
+
### OpenMeteo.exports.useForecastDaily(lat, lon, refreshIntervalMin) ⇒ <code>ForecastData</code>
|
|
344
396
|
Custom hook to fetch daily forecast (10 days) data from OpenMeteo API.
|
|
345
397
|
https://api.open-meteo.com/v1/forecast?timezone=auto&latitude=36.6644363&longitude=-4.5108962&forecast_days=10&daily=weathercode
|
|
346
398
|
|
|
347
399
|
**Kind**: static method of [<code>OpenMeteo</code>](#module_OpenMeteo)
|
|
400
|
+
**Returns**: <code>ForecastData</code> - -
|
|
348
401
|
|
|
349
402
|
| Param | Type |
|
|
350
403
|
| --- | --- |
|
|
@@ -357,10 +410,11 @@ https://api.open-meteo.com/v1/forecast?timezone=auto&latitude=36.6644363&longitu
|
|
|
357
410
|
|
|
358
411
|
<a name="module_OpenMeteo.exports.useForecastHourly"></a>
|
|
359
412
|
|
|
360
|
-
### OpenMeteo.exports.useForecastHourly(location, dayNum) ⇒ <code>
|
|
413
|
+
### OpenMeteo.exports.useForecastHourly(location, dayNum) ⇒ <code>ForecastData</code>
|
|
361
414
|
Custom hook to fetch hourly forecast data for a given location and number of days from OpenMeteo API.
|
|
362
415
|
|
|
363
416
|
**Kind**: static method of [<code>OpenMeteo</code>](#module_OpenMeteo)
|
|
417
|
+
**Returns**: <code>ForecastData</code> - -
|
|
364
418
|
|
|
365
419
|
| Param | Type | Description |
|
|
366
420
|
| --- | --- | --- |
|
|
@@ -376,6 +430,7 @@ Custom hook to fetch hourly forecast data for a given location and number of day
|
|
|
376
430
|
Get weather symbol and description based on the weather code.
|
|
377
431
|
|
|
378
432
|
**Kind**: static method of [<code>OpenMeteo</code>](#module_OpenMeteo)
|
|
433
|
+
**Returns**: <code>Object</code> - { icon: string, description: string }
|
|
379
434
|
|
|
380
435
|
| Param | Type |
|
|
381
436
|
| --- | --- |
|
|
@@ -385,6 +440,22 @@ Get weather symbol and description based on the weather code.
|
|
|
385
440
|
| dark | <code>boolean</code> |
|
|
386
441
|
|
|
387
442
|
|
|
443
|
+
* * *
|
|
444
|
+
|
|
445
|
+
<a name="module_OpenMeteo.ForecastData"></a>
|
|
446
|
+
|
|
447
|
+
### OpenMeteo.ForecastData : <code>Object</code>
|
|
448
|
+
**Kind**: static typedef of [<code>OpenMeteo</code>](#module_OpenMeteo)
|
|
449
|
+
**Properties**
|
|
450
|
+
|
|
451
|
+
| Name | Type | Description |
|
|
452
|
+
| --- | --- | --- |
|
|
453
|
+
| data | <code>any</code> | Forecast data |
|
|
454
|
+
| isLoading | <code>boolean</code> | Loading state |
|
|
455
|
+
| isError | <code>any</code> | Error state |
|
|
456
|
+
| apiUrl | <code>string</code> | API URL |
|
|
457
|
+
|
|
458
|
+
|
|
388
459
|
* * *
|
|
389
460
|
|
|
390
461
|
<a name="module_Utils"></a>
|
|
@@ -400,7 +471,7 @@ Get weather symbol and description based on the weather code.
|
|
|
400
471
|
* [.exports.getWarningByDays(precipitationSumToday, precipitationSumTomorrow, showersSumToday, showersSumTomorrow)](#module_Utils.exports.getWarningByDays) ⇒ <code>Object</code> \| <code>null</code>
|
|
401
472
|
* [.exports.getWarning(precipitation, showers)](#module_Utils.exports.getWarning) ⇒ <code>Object</code> \| <code>null</code>
|
|
402
473
|
* [.exports.WindArrow(props)](#module_Utils.exports.WindArrow)
|
|
403
|
-
* [.exports.windArrowTx(deg)](#module_Utils.exports.windArrowTx)
|
|
474
|
+
* [.exports.windArrowTx(deg)](#module_Utils.exports.windArrowTx) ⇒ <code>string</code>
|
|
404
475
|
* [.exports.getWindLevel(speed)](#module_Utils.exports.getWindLevel) ⇒ <code>WindLevel</code> \| <code>null</code>
|
|
405
476
|
* [.Compass](#module_Utils.Compass) : <code>Object</code>
|
|
406
477
|
* [.AlertLevel](#module_Utils.AlertLevel) : <code>Object</code>
|
|
@@ -465,6 +536,7 @@ Ordered list of wind levels.
|
|
|
465
536
|
Convert degrees to compass designation
|
|
466
537
|
|
|
467
538
|
**Kind**: static method of [<code>Utils</code>](#module_Utils)
|
|
539
|
+
**Returns**: <code>Object</code> - {short: string, full: string}
|
|
468
540
|
|
|
469
541
|
| Param | Type | Description |
|
|
470
542
|
| --- | --- | --- |
|
|
@@ -480,6 +552,7 @@ Convert degrees to compass designation
|
|
|
480
552
|
Get warning by today and tomorrow
|
|
481
553
|
|
|
482
554
|
**Kind**: static method of [<code>Utils</code>](#module_Utils)
|
|
555
|
+
**Returns**: <code>Object</code> \| <code>null</code> - {{ levelNum: number, level: string, message: string, day: number } | null}
|
|
483
556
|
|
|
484
557
|
| Param | Type |
|
|
485
558
|
| --- | --- |
|
|
@@ -497,6 +570,7 @@ Get warning by today and tomorrow
|
|
|
497
570
|
Get warning by precipitation and showers
|
|
498
571
|
|
|
499
572
|
**Kind**: static method of [<code>Utils</code>](#module_Utils)
|
|
573
|
+
**Returns**: <code>Object</code> \| <code>null</code> - {{ levelNum: number, level: string, message: string } | null}
|
|
500
574
|
|
|
501
575
|
| Param | Type |
|
|
502
576
|
| --- | --- |
|
|
@@ -527,10 +601,11 @@ SVG arrow indicating wind direction.
|
|
|
527
601
|
|
|
528
602
|
<a name="module_Utils.exports.windArrowTx"></a>
|
|
529
603
|
|
|
530
|
-
### Utils.exports.windArrowTx(deg)
|
|
604
|
+
### Utils.exports.windArrowTx(deg) ⇒ <code>string</code>
|
|
531
605
|
Convert wind direction in degrees to an arrow representation.
|
|
532
606
|
|
|
533
607
|
**Kind**: static method of [<code>Utils</code>](#module_Utils)
|
|
608
|
+
**Returns**: <code>string</code> - Arrow representation of the wind direction.
|
|
534
609
|
|
|
535
610
|
| Param | Type | Description |
|
|
536
611
|
| --- | --- | --- |
|
|
@@ -653,6 +728,7 @@ Returns a time as a formated string.
|
|
|
653
728
|
Returns a now time as a formated string.
|
|
654
729
|
|
|
655
730
|
**Kind**: static method of [<code>Utils/TimeDateStr</code>](#module_Utils/TimeDateStr)
|
|
731
|
+
**Returns**: <code>String</code> - now time as a formated string
|
|
656
732
|
|
|
657
733
|
| Param | Type | Default |
|
|
658
734
|
| --- | --- | --- |
|
|
@@ -4,12 +4,7 @@
|
|
|
4
4
|
* @param {number} lat
|
|
5
5
|
* @param {number} lon
|
|
6
6
|
* @param {number} refreshIntervalMin
|
|
7
|
-
* @returns {
|
|
7
|
+
* @returns {ForecastData} -
|
|
8
8
|
* @memberof module:OpenMeteo
|
|
9
9
|
*/
|
|
10
|
-
export function useForecastCurrent(lat: number, lon: number, refreshIntervalMin?: number):
|
|
11
|
-
data: any;
|
|
12
|
-
apiUrl: string;
|
|
13
|
-
isLoading: boolean;
|
|
14
|
-
isError: any;
|
|
15
|
-
};
|
|
10
|
+
export function useForecastCurrent(lat: number, lon: number, refreshIntervalMin?: number): ForecastData;
|
|
@@ -5,11 +5,7 @@
|
|
|
5
5
|
* @param {number} lat
|
|
6
6
|
* @param {number} lon
|
|
7
7
|
* @param {number} refreshIntervalMin
|
|
8
|
-
* @returns {
|
|
8
|
+
* @returns {ForecastData} -
|
|
9
9
|
* @memberof module:OpenMeteo
|
|
10
10
|
*/
|
|
11
|
-
export function useForecastDaily(lat: number, lon: number, refreshIntervalMin?: number):
|
|
12
|
-
data: any;
|
|
13
|
-
isLoading: boolean;
|
|
14
|
-
isError: any;
|
|
15
|
-
};
|
|
11
|
+
export function useForecastDaily(lat: number, lon: number, refreshIntervalMin?: number): ForecastData;
|
|
@@ -2,15 +2,11 @@
|
|
|
2
2
|
* Custom hook to fetch hourly forecast data for a given location and number of days from OpenMeteo API.
|
|
3
3
|
*
|
|
4
4
|
* @param {{ latitude: number, longitude: number }} location
|
|
5
|
-
* @param {number} dayNum
|
|
6
|
-
* @returns {
|
|
5
|
+
* @param {number} dayNum Number of days from today: -1 = 24 hours, 0 = today, 1 = tomorrow, ...
|
|
6
|
+
* @returns {ForecastData} -
|
|
7
7
|
* @memberof module:OpenMeteo
|
|
8
8
|
*/
|
|
9
9
|
export function useForecastHourly(location: {
|
|
10
10
|
latitude: number;
|
|
11
11
|
longitude: number;
|
|
12
|
-
}, dayNum: number):
|
|
13
|
-
data: any;
|
|
14
|
-
isLoading: boolean;
|
|
15
|
-
isError: any;
|
|
16
|
-
};
|
|
12
|
+
}, dayNum: number): ForecastData;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @param {boolean} night
|
|
7
7
|
* @param {boolean} dark
|
|
8
8
|
* @returns {{ icon: string, description: string }}
|
|
9
|
+
* { icon: string, description: string }
|
|
9
10
|
* @memberof module:OpenMeteo
|
|
10
11
|
*/
|
|
11
12
|
export function weatherSymbol(code: any, precipitation?: number, night?: boolean, dark?: boolean): {
|
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
export default MoonCalc;
|
|
2
|
+
export type AstroPosition = {
|
|
3
|
+
altitude: number;
|
|
4
|
+
azimuth: number;
|
|
5
|
+
direction: string;
|
|
6
|
+
/**
|
|
7
|
+
* ``
|
|
8
|
+
*/
|
|
9
|
+
direction_full: string;
|
|
10
|
+
};
|
|
11
|
+
export type MoonDataExt = {
|
|
12
|
+
date: string;
|
|
13
|
+
time: string;
|
|
14
|
+
illumination: string;
|
|
15
|
+
phase: string;
|
|
16
|
+
phaseId: string;
|
|
17
|
+
emoji: string;
|
|
18
|
+
parallacticAngle: number;
|
|
19
|
+
angle: number;
|
|
20
|
+
position: AstroPosition;
|
|
21
|
+
next: Object;
|
|
22
|
+
};
|
|
2
23
|
export type MoonData = {
|
|
3
24
|
position: AstroPosition;
|
|
4
25
|
next: {
|
|
@@ -18,7 +39,7 @@ declare namespace MoonCalc {
|
|
|
18
39
|
* @param {number} longitude
|
|
19
40
|
* @param {Date} [date=new Date()]
|
|
20
41
|
* @param {string} [language=es-ES]
|
|
21
|
-
* @returns {MoonData}
|
|
42
|
+
* @returns {MoonData} Moon info object
|
|
22
43
|
* @memberof module:Astronomy/MoonCalc
|
|
23
44
|
*/
|
|
24
45
|
declare function data(latitude: number, longitude: number, date?: Date, language?: string): MoonData;
|
|
@@ -30,27 +51,16 @@ declare function data(latitude: number, longitude: number, date?: Date, language
|
|
|
30
51
|
* @param {number} longitude
|
|
31
52
|
* @param {Date} [date=new Date()]
|
|
32
53
|
* @param {string} [language=es-ES]
|
|
33
|
-
* @returns {
|
|
54
|
+
* @returns {MoonDataExt} Full information
|
|
34
55
|
* @memberof module:Astronomy/MoonCalc
|
|
35
56
|
*/
|
|
36
|
-
declare function dataExt(latitude: number, longitude: number, date?: Date, language?: string):
|
|
37
|
-
date: string;
|
|
38
|
-
time: string;
|
|
39
|
-
illumination: string;
|
|
40
|
-
phase: string;
|
|
41
|
-
phaseId: string;
|
|
42
|
-
emoji: string;
|
|
43
|
-
parallacticAngle: number;
|
|
44
|
-
angle: number;
|
|
45
|
-
position: AstroPosition;
|
|
46
|
-
next: object;
|
|
47
|
-
};
|
|
57
|
+
declare function dataExt(latitude: number, longitude: number, date?: Date, language?: string): MoonDataExt;
|
|
48
58
|
/**
|
|
49
59
|
* @param {number} latitude
|
|
50
60
|
* @param {number} longitude
|
|
51
61
|
* @param {string} timezoneId
|
|
52
62
|
* @param {Date} date
|
|
53
|
-
* @returns {{rise: string, set: string, highest: string}}
|
|
63
|
+
* @returns {{rise: string, set: string, highest: string}} Moon times
|
|
54
64
|
* @memberof module:Astronomy/MoonCalc
|
|
55
65
|
*/
|
|
56
66
|
declare function times(latitude: number, longitude: number, timezoneId: string, date?: Date): {
|
|
@@ -62,7 +72,7 @@ declare function times(latitude: number, longitude: number, timezoneId: string,
|
|
|
62
72
|
* @param {number} latitude
|
|
63
73
|
* @param {number} longitude
|
|
64
74
|
* @param {Date} [date=new Date()]
|
|
65
|
-
* @returns {string}
|
|
75
|
+
* @returns {string} Emoji of the moon phase
|
|
66
76
|
* @memberof module:Astronomy/MoonCalc
|
|
67
77
|
*/
|
|
68
78
|
declare function emoji(latitude: number, longitude: number, date?: Date): string;
|
|
@@ -12,12 +12,13 @@ declare namespace SunCalc {
|
|
|
12
12
|
* @param {number} latitude
|
|
13
13
|
* @param {number} longitude
|
|
14
14
|
* @param {string} timezoneId
|
|
15
|
-
* @returns {{ sunTimes:
|
|
15
|
+
* @returns {{ sunTimes: Object, sunPosition: Object, sunPhase: string }}
|
|
16
|
+
* { sunTimes: Object, sunPosition: Object, sunPhase: string }
|
|
16
17
|
* @memberof module:Astronomy/SunCalc
|
|
17
18
|
*/
|
|
18
19
|
declare function all(date: Date, latitude: number, longitude: number, timezoneId: string): {
|
|
19
|
-
sunTimes:
|
|
20
|
-
sunPosition:
|
|
20
|
+
sunTimes: Object;
|
|
21
|
+
sunPosition: Object;
|
|
21
22
|
sunPhase: string;
|
|
22
23
|
};
|
|
23
24
|
/**
|
|
@@ -26,6 +27,7 @@ declare function all(date: Date, latitude: number, longitude: number, timezoneId
|
|
|
26
27
|
* @param {number} longitude
|
|
27
28
|
* @param {string} timezoneId
|
|
28
29
|
* @returns {{ date: Date, sunrise: string, sunset: string, noon: string, dawn: string, dusk: string }}
|
|
30
|
+
* { date: Date, sunrise: string, sunset: string, noon: string, dawn: string, dusk: string }
|
|
29
31
|
* @memberof module:Astronomy/SunCalc
|
|
30
32
|
*/
|
|
31
33
|
declare function times(date: Date, latitude: number, longitude: number, timezoneId: string): {
|
|
@@ -39,9 +41,9 @@ declare function times(date: Date, latitude: number, longitude: number, timezone
|
|
|
39
41
|
/**
|
|
40
42
|
* @param {Date} date
|
|
41
43
|
* @param {number} lng
|
|
42
|
-
* @param {string} offsetSign
|
|
43
|
-
* @param {number} offset
|
|
44
|
-
* @returns {string}
|
|
44
|
+
* @param {string} offsetSign "+" or "-"
|
|
45
|
+
* @param {number} offset UTC offset in hours
|
|
46
|
+
* @returns {string} Local time in "HH:mm" format
|
|
45
47
|
* @memberof module:Astronomy/SunCalc
|
|
46
48
|
*/
|
|
47
49
|
declare function getSolarTime(date: Date, lng: number, offsetSign: string, offset: number): string;
|
|
@@ -49,6 +51,7 @@ declare function getSolarTime(date: Date, lng: number, offsetSign: string, offse
|
|
|
49
51
|
* @param {number} latitude
|
|
50
52
|
* @param {number} longitude
|
|
51
53
|
* @returns {{date: string, azimuth: number, direction: string, direction_full: string, altitude: number, zenith: number, declination: number}}
|
|
54
|
+
* {date: string, azimuth: number, direction: string, direction_full: string, altitude: number, zenith: number, declination: number}
|
|
52
55
|
* @memberof module:Astronomy/SunCalc
|
|
53
56
|
*/
|
|
54
57
|
declare function position(latitude: number, longitude: number, date?: Date, language?: string): {
|
|
@@ -66,14 +69,14 @@ declare function position(latitude: number, longitude: number, date?: Date, lang
|
|
|
66
69
|
* @param {string} timezoneId
|
|
67
70
|
* @param {number | Date} date
|
|
68
71
|
* @param {string} dateStr
|
|
69
|
-
* @returns {boolean}
|
|
72
|
+
* @returns {boolean} true if it's night, false otherwise
|
|
70
73
|
* @memberof module:Astronomy/SunCalc
|
|
71
74
|
*/
|
|
72
75
|
declare function getIsNight(lat: number, lon: number, timezoneId: string, date: number | Date, dateStr: string): boolean;
|
|
73
76
|
/**
|
|
74
77
|
* @param {number} altitude
|
|
75
78
|
* @param {string} noon
|
|
76
|
-
* @returns {string}
|
|
79
|
+
* @returns {string} The phase of the sun based on its altitude
|
|
77
80
|
* @memberof module:Astronomy/SunCalc
|
|
78
81
|
*/
|
|
79
82
|
declare function getPhase(altitude: number, noon: string): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Get the current geolocation of the device and reverse geocode it to get the address.
|
|
3
3
|
*
|
|
4
|
-
* @returns {Promise<{latitude: number, longitude: number, formatted_address: string}>}
|
|
4
|
+
* @returns {Promise<{latitude: number, longitude: number, formatted_address: string}>} Promise
|
|
5
5
|
* @throws {Error} If geolocation is not supported or permission is denied.
|
|
6
6
|
* @memberof module:Geolocation
|
|
7
7
|
*/
|
|
@@ -1,11 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @memberof module:Geolocation
|
|
3
|
+
* @typedef {Object} LocalTimeData
|
|
4
|
+
* @property {Date} time - The local time.
|
|
5
|
+
* @property {string} timeStr - The formatted local time string.
|
|
6
|
+
* @property {string} timezone - The timezone name.
|
|
7
|
+
* @property {string} timezoneId - The timezone ID.
|
|
8
|
+
* @property {number} offset - The UTC offset in hours.
|
|
9
|
+
* @property {string} offsetSign - The sign of the offset ('+' or '-').
|
|
10
|
+
* @property {number} dstOffset - The DST offset in hours.
|
|
11
|
+
*/
|
|
1
12
|
/**
|
|
2
13
|
* Get local time from a given location (lat, lng) using 'GoogleMaps TimeZone' API.
|
|
3
14
|
*
|
|
4
|
-
* @param {string} apiKey
|
|
15
|
+
* @param {string} apiKey GoogleMaps API key.
|
|
5
16
|
* @param {number} lat
|
|
6
17
|
* @param {number} lng
|
|
7
|
-
* @returns {Promise<any | LocalTimeData>}
|
|
8
|
-
* @throws {Error}
|
|
18
|
+
* @returns {Promise<any | LocalTimeData>} An object containing the local time and timezone information:
|
|
19
|
+
* @throws {Error} If the API request fails or returns an error status.
|
|
9
20
|
* @memberof module:Geolocation
|
|
10
21
|
*/
|
|
11
22
|
export function timeFromLocation(apiKey: string, lat: number, lng: number): Promise<any | LocalTimeData>;
|
|
23
|
+
export type LocalTimeData = {
|
|
24
|
+
/**
|
|
25
|
+
* - The local time.
|
|
26
|
+
*/
|
|
27
|
+
time: Date;
|
|
28
|
+
/**
|
|
29
|
+
* - The formatted local time string.
|
|
30
|
+
*/
|
|
31
|
+
timeStr: string;
|
|
32
|
+
/**
|
|
33
|
+
* - The timezone name.
|
|
34
|
+
*/
|
|
35
|
+
timezone: string;
|
|
36
|
+
/**
|
|
37
|
+
* - The timezone ID.
|
|
38
|
+
*/
|
|
39
|
+
timezoneId: string;
|
|
40
|
+
/**
|
|
41
|
+
* - The UTC offset in hours.
|
|
42
|
+
*/
|
|
43
|
+
offset: number;
|
|
44
|
+
/**
|
|
45
|
+
* - The sign of the offset ('+' or '-').
|
|
46
|
+
*/
|
|
47
|
+
offsetSign: string;
|
|
48
|
+
/**
|
|
49
|
+
* - The DST offset in hours.
|
|
50
|
+
*/
|
|
51
|
+
dstOffset: number;
|
|
52
|
+
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {number} degrees
|
|
5
5
|
* @param {string} language - Language code ("en-US", "es-ES", "auto")
|
|
6
|
-
* @returns {{short: string, full: string}}
|
|
6
|
+
* @returns {{short: string, full: string}} {short: string, full: string}
|
|
7
7
|
* @memberof module:Utils
|
|
8
8
|
*/
|
|
9
9
|
export function degreesToCompass(degrees: number, language?: string): {
|
|
@@ -17,7 +17,7 @@ declare function dateFormat(date?: Date): string;
|
|
|
17
17
|
* Returns a now time as a formated string.
|
|
18
18
|
*
|
|
19
19
|
* @param {boolean} sec
|
|
20
|
-
* @returns {String}
|
|
20
|
+
* @returns {String} now time as a formated string
|
|
21
21
|
* @memberof module:Utils/TimeDateStr
|
|
22
22
|
*/
|
|
23
23
|
declare function nowString(sec?: boolean): string;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @param {number} showersSumToday
|
|
7
7
|
* @param {number} showersSumTomorrow
|
|
8
8
|
* @returns {{ levelNum: number, level: string, message: string, day: number } | null}
|
|
9
|
+
* {{ levelNum: number, level: string, message: string, day: number } | null}
|
|
9
10
|
* @memberof module:Utils
|
|
10
11
|
*/
|
|
11
12
|
export function getWarningByDays(precipitationSumToday: number, precipitationSumTomorrow: number, showersSumToday: number, showersSumTomorrow: number): {
|
|
@@ -21,6 +22,7 @@ export function getWarningByDays(precipitationSumToday: number, precipitationSum
|
|
|
21
22
|
* @param {number} precipitation
|
|
22
23
|
* @param {number} showers
|
|
23
24
|
* @returns {{ levelNum: number, level: string, message: string } | null}
|
|
25
|
+
* {{ levelNum: number, level: string, message: string } | null}
|
|
24
26
|
* @memberof module:Utils
|
|
25
27
|
*/
|
|
26
28
|
export function getWarning(precipitation: number, showers: number): {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert wind direction in degrees to an arrow representation.
|
|
3
|
-
*/
|
|
4
1
|
/**
|
|
5
2
|
* Convert wind direction in degrees to an arrow representation.
|
|
6
3
|
*
|
|
7
4
|
* @param {number} deg - Wind direction in degrees.
|
|
5
|
+
* @returns {string} Arrow representation of the wind direction.
|
|
8
6
|
* @memberof module:Utils
|
|
9
7
|
*/
|
|
10
|
-
export function windArrowTx(deg: number):
|
|
8
|
+
export function windArrowTx(deg: number): string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Custom hook to fetch current weather data from OpenMeteo API.
|
|
3
|
-
*/
|
|
4
|
-
|
|
1
|
+
// @ts-nocheck
|
|
5
2
|
import useSWR from "swr";
|
|
6
3
|
import { fetcher, getPath } from "../conf.js";
|
|
7
4
|
import { fetchParams } from "./fetchParams.js";
|
|
@@ -13,7 +10,7 @@ import transformer from "./transformer.js";
|
|
|
13
10
|
* @param {number} lat
|
|
14
11
|
* @param {number} lon
|
|
15
12
|
* @param {number} refreshIntervalMin
|
|
16
|
-
* @returns {
|
|
13
|
+
* @returns {ForecastData} -
|
|
17
14
|
* @memberof module:OpenMeteo
|
|
18
15
|
*/
|
|
19
16
|
export function useForecastCurrent(lat, lon, refreshIntervalMin = 0) {
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Custom hook to fetch daily forecast (10 days) data from OpenMeteo API.
|
|
3
|
-
*/
|
|
4
|
-
|
|
1
|
+
// @ts-nocheck
|
|
5
2
|
import useSWR from "swr";
|
|
6
3
|
import { fetcher, getPath } from "../conf.js";
|
|
7
4
|
import { fetchParams } from "./fetchParams.js";
|
|
@@ -14,7 +11,7 @@ import transformer from "./transformer.js";
|
|
|
14
11
|
* @param {number} lat
|
|
15
12
|
* @param {number} lon
|
|
16
13
|
* @param {number} refreshIntervalMin
|
|
17
|
-
* @returns {
|
|
14
|
+
* @returns {ForecastData} -
|
|
18
15
|
* @memberof module:OpenMeteo
|
|
19
16
|
*/
|
|
20
17
|
export function useForecastDaily(lat, lon, refreshIntervalMin = 0) {
|
|
@@ -33,6 +30,7 @@ export function useForecastDaily(lat, lon, refreshIntervalMin = 0) {
|
|
|
33
30
|
// Return --
|
|
34
31
|
return {
|
|
35
32
|
data: data ? transformer(data) : null,
|
|
33
|
+
apiUrl: apiUrl,
|
|
36
34
|
isLoading,
|
|
37
35
|
isError: error,
|
|
38
36
|
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Custom hook to fetch hourly forecast data for a given location and number of days from OpenMeteo API.
|
|
3
|
-
*/
|
|
4
|
-
|
|
1
|
+
// @ts-nocheck
|
|
5
2
|
import useSWR from "swr";
|
|
6
3
|
import { fetcher, getPath } from "../conf.js";
|
|
7
4
|
import { getDatesFromNumDays } from "../helpers.js";
|
|
@@ -11,8 +8,8 @@ import { fetchParams } from "./fetchParams.js";
|
|
|
11
8
|
* Custom hook to fetch hourly forecast data for a given location and number of days from OpenMeteo API.
|
|
12
9
|
*
|
|
13
10
|
* @param {{ latitude: number, longitude: number }} location
|
|
14
|
-
* @param {number} dayNum
|
|
15
|
-
* @returns {
|
|
11
|
+
* @param {number} dayNum Number of days from today: -1 = 24 hours, 0 = today, 1 = tomorrow, ...
|
|
12
|
+
* @returns {ForecastData} -
|
|
16
13
|
* @memberof module:OpenMeteo
|
|
17
14
|
*/
|
|
18
15
|
export function useForecastHourly(location, dayNum) {
|
|
@@ -37,6 +34,7 @@ export function useForecastHourly(location, dayNum) {
|
|
|
37
34
|
|
|
38
35
|
return {
|
|
39
36
|
data: data,
|
|
37
|
+
apiUrl: apiUrl,
|
|
40
38
|
isLoading,
|
|
41
39
|
isError: error,
|
|
42
40
|
};
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get weather symbol and description based on the weather code.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
1
|
import { getWeatherCodeEntry } from "./lib/getWeatherCodeEntry.js";
|
|
6
2
|
|
|
7
3
|
/**
|
|
@@ -12,6 +8,7 @@ import { getWeatherCodeEntry } from "./lib/getWeatherCodeEntry.js";
|
|
|
12
8
|
* @param {boolean} night
|
|
13
9
|
* @param {boolean} dark
|
|
14
10
|
* @returns {{ icon: string, description: string }}
|
|
11
|
+
* { icon: string, description: string }
|
|
15
12
|
* @memberof module:OpenMeteo
|
|
16
13
|
*/
|
|
17
14
|
export function weatherSymbol(
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* MoonCalc for calculating moon times, positions, and phases.
|
|
4
3
|
*
|
|
@@ -15,15 +14,6 @@ import SunCalc from "suncalc3";
|
|
|
15
14
|
import TimeDateStr from "../../utils/timehelpers.js";
|
|
16
15
|
import { parseBasicData } from "./parseBasicData.js";
|
|
17
16
|
|
|
18
|
-
/**
|
|
19
|
-
* @memberof module:Astronomy/MoonCalc
|
|
20
|
-
* @typedef {Object} MoonData
|
|
21
|
-
* @property {AstroPosition} position
|
|
22
|
-
* @property {Object} next
|
|
23
|
-
* @property {string} next.newMoon - Date of the next new moon.
|
|
24
|
-
* @property {string} next.fullMoon - Date of the next full moon.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
17
|
/**
|
|
28
18
|
* MoonCalc.
|
|
29
19
|
* @ignore
|
|
@@ -37,6 +27,39 @@ const MoonCalc = {
|
|
|
37
27
|
};
|
|
38
28
|
export default MoonCalc;
|
|
39
29
|
|
|
30
|
+
/**
|
|
31
|
+
* @memberof module:Astronomy
|
|
32
|
+
* @typedef {Object} AstroPosition
|
|
33
|
+
* @property {number} altitude
|
|
34
|
+
* @property {number} azimuth
|
|
35
|
+
* @property {string} direction
|
|
36
|
+
* @property {string} direction_full``
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @memberof module:Astronomy/MoonCalc
|
|
41
|
+
* @typedef {Object} MoonDataExt
|
|
42
|
+
* @property {string} date
|
|
43
|
+
* @property {string} time
|
|
44
|
+
* @property {string} illumination
|
|
45
|
+
* @property {string} phase
|
|
46
|
+
* @property {string} phaseId
|
|
47
|
+
* @property {string} emoji
|
|
48
|
+
* @property {number} parallacticAngle
|
|
49
|
+
* @property {number} angle
|
|
50
|
+
* @property {AstroPosition} position
|
|
51
|
+
* @property {Object} next
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @memberof module:Astronomy/MoonCalc
|
|
56
|
+
* @typedef {Object} MoonData
|
|
57
|
+
* @property {AstroPosition} position
|
|
58
|
+
* @property {Object} next
|
|
59
|
+
* @property {string} next.newMoon - Date of the next new moon.
|
|
60
|
+
* @property {string} next.fullMoon - Date of the next full moon.
|
|
61
|
+
*/
|
|
62
|
+
|
|
40
63
|
/**
|
|
41
64
|
* Mapa de fases lunares.
|
|
42
65
|
* { phaseId, phaseName }
|
|
@@ -61,7 +84,7 @@ const phasesES = {
|
|
|
61
84
|
* @param {number} longitude
|
|
62
85
|
* @param {Date} [date=new Date()]
|
|
63
86
|
* @param {string} [language=es-ES]
|
|
64
|
-
* @returns {MoonData}
|
|
87
|
+
* @returns {MoonData} Moon info object
|
|
65
88
|
* @memberof module:Astronomy/MoonCalc
|
|
66
89
|
*/
|
|
67
90
|
function data(latitude, longitude, date = new Date(), language = "es-ES") {
|
|
@@ -80,7 +103,7 @@ function data(latitude, longitude, date = new Date(), language = "es-ES") {
|
|
|
80
103
|
* @param {number} longitude
|
|
81
104
|
* @param {Date} [date=new Date()]
|
|
82
105
|
* @param {string} [language=es-ES]
|
|
83
|
-
* @returns {
|
|
106
|
+
* @returns {MoonDataExt} Full information
|
|
84
107
|
* @memberof module:Astronomy/MoonCalc
|
|
85
108
|
*/
|
|
86
109
|
function dataExt(latitude, longitude, date = new Date(), language = "es-ES") {
|
|
@@ -122,7 +145,7 @@ function dataExt(latitude, longitude, date = new Date(), language = "es-ES") {
|
|
|
122
145
|
* @param {number} latitude
|
|
123
146
|
* @param {number} longitude
|
|
124
147
|
* @param {Date} [date=new Date()]
|
|
125
|
-
* @returns {string}
|
|
148
|
+
* @returns {string} Emoji of the moon phase
|
|
126
149
|
* @memberof module:Astronomy/MoonCalc
|
|
127
150
|
*/
|
|
128
151
|
function emoji(latitude, longitude, date = new Date()) {
|
|
@@ -135,7 +158,7 @@ function emoji(latitude, longitude, date = new Date()) {
|
|
|
135
158
|
* @param {number} longitude
|
|
136
159
|
* @param {string} timezoneId
|
|
137
160
|
* @param {Date} date
|
|
138
|
-
* @returns {{rise: string, set: string, highest: string}}
|
|
161
|
+
* @returns {{rise: string, set: string, highest: string}} Moon times
|
|
139
162
|
* @memberof module:Astronomy/MoonCalc
|
|
140
163
|
*/
|
|
141
164
|
function times(latitude, longitude, timezoneId, date = new Date()) {
|
|
@@ -35,7 +35,8 @@ export default SunCalc;
|
|
|
35
35
|
* @param {number} latitude
|
|
36
36
|
* @param {number} longitude
|
|
37
37
|
* @param {string} timezoneId
|
|
38
|
-
* @returns {{ sunTimes:
|
|
38
|
+
* @returns {{ sunTimes: Object, sunPosition: Object, sunPhase: string }}
|
|
39
|
+
* { sunTimes: Object, sunPosition: Object, sunPhase: string }
|
|
39
40
|
* @memberof module:Astronomy/SunCalc
|
|
40
41
|
*/
|
|
41
42
|
function all(date, latitude, longitude, timezoneId) {
|
|
@@ -57,6 +58,7 @@ function all(date, latitude, longitude, timezoneId) {
|
|
|
57
58
|
* @param {number} longitude
|
|
58
59
|
* @param {string} timezoneId
|
|
59
60
|
* @returns {{ date: Date, sunrise: string, sunset: string, noon: string, dawn: string, dusk: string }}
|
|
61
|
+
* { date: Date, sunrise: string, sunset: string, noon: string, dawn: string, dusk: string }
|
|
60
62
|
* @memberof module:Astronomy/SunCalc
|
|
61
63
|
*/
|
|
62
64
|
function times(date, latitude, longitude, timezoneId) {
|
|
@@ -81,9 +83,9 @@ function times(date, latitude, longitude, timezoneId) {
|
|
|
81
83
|
/**
|
|
82
84
|
* @param {Date} date
|
|
83
85
|
* @param {number} lng
|
|
84
|
-
* @param {string} offsetSign
|
|
85
|
-
* @param {number} offset
|
|
86
|
-
* @returns {string}
|
|
86
|
+
* @param {string} offsetSign "+" or "-"
|
|
87
|
+
* @param {number} offset UTC offset in hours
|
|
88
|
+
* @returns {string} Local time in "HH:mm" format
|
|
87
89
|
* @memberof module:Astronomy/SunCalc
|
|
88
90
|
*/
|
|
89
91
|
function getSolarTime(date, lng, offsetSign, offset) {
|
|
@@ -97,6 +99,7 @@ function getSolarTime(date, lng, offsetSign, offset) {
|
|
|
97
99
|
* @param {number} latitude
|
|
98
100
|
* @param {number} longitude
|
|
99
101
|
* @returns {{date: string, azimuth: number, direction: string, direction_full: string, altitude: number, zenith: number, declination: number}}
|
|
102
|
+
* {date: string, azimuth: number, direction: string, direction_full: string, altitude: number, zenith: number, declination: number}
|
|
100
103
|
* @memberof module:Astronomy/SunCalc
|
|
101
104
|
*/
|
|
102
105
|
function position(latitude, longitude, date = new Date(), language = "es-ES") {
|
|
@@ -124,7 +127,7 @@ function position(latitude, longitude, date = new Date(), language = "es-ES") {
|
|
|
124
127
|
* @param {string} timezoneId
|
|
125
128
|
* @param {number | Date} date
|
|
126
129
|
* @param {string} dateStr
|
|
127
|
-
* @returns {boolean}
|
|
130
|
+
* @returns {boolean} true if it's night, false otherwise
|
|
128
131
|
* @memberof module:Astronomy/SunCalc
|
|
129
132
|
*/
|
|
130
133
|
function getIsNight(lat, lon, timezoneId, date, dateStr) {
|
|
@@ -147,7 +150,7 @@ function getIsNight(lat, lon, timezoneId, date, dateStr) {
|
|
|
147
150
|
/**
|
|
148
151
|
* @param {number} altitude
|
|
149
152
|
* @param {string} noon
|
|
150
|
-
* @returns {string}
|
|
153
|
+
* @returns {string} The phase of the sun based on its altitude
|
|
151
154
|
* @memberof module:Astronomy/SunCalc
|
|
152
155
|
*/
|
|
153
156
|
function getPhase(altitude, noon) {
|
|
@@ -4,7 +4,7 @@ import reverseGeocoding from "./lib/reversegeocoding.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* Get the current geolocation of the device and reverse geocode it to get the address.
|
|
6
6
|
*
|
|
7
|
-
* @returns {Promise<{latitude: number, longitude: number, formatted_address: string}>}
|
|
7
|
+
* @returns {Promise<{latitude: number, longitude: number, formatted_address: string}>} Promise
|
|
8
8
|
* @throws {Error} If geolocation is not supported or permission is denied.
|
|
9
9
|
* @memberof module:Geolocation
|
|
10
10
|
*/
|
|
@@ -1,15 +1,27 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import TimeDateStr from "../utils/timehelpers.js";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @memberof module:Geolocation
|
|
6
|
+
* @typedef {Object} LocalTimeData
|
|
7
|
+
* @property {Date} time - The local time.
|
|
8
|
+
* @property {string} timeStr - The formatted local time string.
|
|
9
|
+
* @property {string} timezone - The timezone name.
|
|
10
|
+
* @property {string} timezoneId - The timezone ID.
|
|
11
|
+
* @property {number} offset - The UTC offset in hours.
|
|
12
|
+
* @property {string} offsetSign - The sign of the offset ('+' or '-').
|
|
13
|
+
* @property {number} dstOffset - The DST offset in hours.
|
|
14
|
+
*/
|
|
15
|
+
|
|
4
16
|
//------------------------------------------------------
|
|
5
17
|
/**
|
|
6
18
|
* Get local time from a given location (lat, lng) using 'GoogleMaps TimeZone' API.
|
|
7
19
|
*
|
|
8
|
-
* @param {string} apiKey
|
|
20
|
+
* @param {string} apiKey GoogleMaps API key.
|
|
9
21
|
* @param {number} lat
|
|
10
22
|
* @param {number} lng
|
|
11
|
-
* @returns {Promise<any | LocalTimeData>}
|
|
12
|
-
* @throws {Error}
|
|
23
|
+
* @returns {Promise<any | LocalTimeData>} An object containing the local time and timezone information:
|
|
24
|
+
* @throws {Error} If the API request fails or returns an error status.
|
|
13
25
|
* @memberof module:Geolocation
|
|
14
26
|
*/
|
|
15
27
|
export async function timeFromLocation(apiKey, lat, lng) {
|
|
@@ -52,7 +52,7 @@ const directionsEs = [
|
|
|
52
52
|
*
|
|
53
53
|
* @param {number} degrees
|
|
54
54
|
* @param {string} language - Language code ("en-US", "es-ES", "auto")
|
|
55
|
-
* @returns {{short: string, full: string}}
|
|
55
|
+
* @returns {{short: string, full: string}} {short: string, full: string}
|
|
56
56
|
* @memberof module:Utils
|
|
57
57
|
*/
|
|
58
58
|
export function degreesToCompass(degrees, language = "auto") {
|
package/src/utils/timehelpers.js
CHANGED
|
@@ -63,7 +63,7 @@ function timeString(date = new Date(), sec = false) {
|
|
|
63
63
|
* Returns a now time as a formated string.
|
|
64
64
|
*
|
|
65
65
|
* @param {boolean} sec
|
|
66
|
-
* @returns {String}
|
|
66
|
+
* @returns {String} now time as a formated string
|
|
67
67
|
* @memberof module:Utils/TimeDateStr
|
|
68
68
|
*/
|
|
69
69
|
function nowString(sec = false) {
|
package/src/utils/warning.js
CHANGED
|
@@ -27,6 +27,7 @@ const ALERT_LEVEL = [
|
|
|
27
27
|
* @param {number} showersSumToday
|
|
28
28
|
* @param {number} showersSumTomorrow
|
|
29
29
|
* @returns {{ levelNum: number, level: string, message: string, day: number } | null}
|
|
30
|
+
* {{ levelNum: number, level: string, message: string, day: number } | null}
|
|
30
31
|
* @memberof module:Utils
|
|
31
32
|
*/
|
|
32
33
|
export function getWarningByDays(
|
|
@@ -63,6 +64,7 @@ export function getWarningByDays(
|
|
|
63
64
|
* @param {number} precipitation
|
|
64
65
|
* @param {number} showers
|
|
65
66
|
* @returns {{ levelNum: number, level: string, message: string } | null}
|
|
67
|
+
* {{ levelNum: number, level: string, message: string } | null}
|
|
66
68
|
* @memberof module:Utils
|
|
67
69
|
*/
|
|
68
70
|
export function getWarning(precipitation, showers) {
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert wind direction in degrees to an arrow representation.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
1
|
/**
|
|
6
2
|
* Convert wind direction in degrees to an arrow representation.
|
|
7
3
|
*
|
|
8
4
|
* @param {number} deg - Wind direction in degrees.
|
|
5
|
+
* @returns {string} Arrow representation of the wind direction.
|
|
9
6
|
* @memberof module:Utils
|
|
10
7
|
*/
|
|
11
8
|
export function windArrowTx(deg) {
|
|
@@ -22,4 +19,5 @@ export function windArrowTx(deg) {
|
|
|
22
19
|
if (deg < 247.5) return "↗";
|
|
23
20
|
if (deg < 292.5) return "→";
|
|
24
21
|
if (deg < 337.5) return "↘";
|
|
22
|
+
return "↓"; // Default arrow for degrees >= 337.5
|
|
25
23
|
}
|
package/src/astronomy/types.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @memberof module:Astronomy
|
|
3
|
-
* @typedef {Object} AstroPosition
|
|
4
|
-
* @property {number} altitude
|
|
5
|
-
* @property {number} azimuth
|
|
6
|
-
* @property {string} direction
|
|
7
|
-
* @property {string} direction_full
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @memberof module:Astronomy
|
|
12
|
-
* @typedef {Object} LocalTimeData
|
|
13
|
-
* @property {Date} time - The local time.
|
|
14
|
-
* @property {string} timeStr - The formatted local time string.
|
|
15
|
-
* @property {string} timezone - The timezone name.
|
|
16
|
-
* @property {string} timezoneId - The timezone ID.
|
|
17
|
-
* @property {number} offset - The UTC offset in hours.
|
|
18
|
-
* @property {string} offsetSign - The sign of the offset ('+' or '-').
|
|
19
|
-
* @property {number} dstOffset - The DST offset in hours.
|
|
20
|
-
*/
|