@angelrove/forecast-utils 1.1.18 → 1.1.19
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 +7 -420
- package/dist/types/OpenMeteo/current/transformer.d.ts +2 -2
- package/dist/types/OpenMeteo/current/useForecastCurrent.d.ts +2 -7
- package/dist/types/OpenMeteo/daily/transformer.d.ts +2 -2
- package/dist/types/OpenMeteo/daily/useForecastDaily.d.ts +2 -8
- package/dist/types/OpenMeteo/hourly/useForecastHourly.d.ts +2 -9
- package/dist/types/OpenMeteo/index.d.ts +9 -4
- package/dist/types/OpenMeteo/types.d.ts +10 -15
- package/dist/types/OpenMeteo/weatherSymbol/lib/WeatherCodesEn.d.ts +1 -1
- package/dist/types/OpenMeteo/weatherSymbol/lib/WeatherCodesEs.d.ts +1 -1
- package/dist/types/OpenMeteo/weatherSymbol/weatherSymbol.d.ts +2 -11
- package/dist/types/astronomy/moon/MoonCalc.d.ts +1 -1
- package/dist/types/astronomy/sun/SunCalc.d.ts +4 -4
- package/dist/types/geolocation/getGeolocation.d.ts +1 -1
- package/dist/types/geolocation/index.d.ts +3 -0
- package/dist/types/geolocation/timeFromLocation.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/index.d.ts +4 -1
- package/dist/types/utils/wind/WindArrow.d.ts +1 -1
- package/package.json +4 -5
- package/src/OpenMeteo/conf.js +1 -1
- package/src/OpenMeteo/current/transformer.js +1 -1
- package/src/OpenMeteo/current/{useForecastCurrent.js → useForecastCurrent.ts} +9 -9
- package/src/OpenMeteo/daily/transformer.js +1 -1
- package/src/OpenMeteo/daily/{useForecastDaily.js → useForecastDaily.ts} +7 -10
- package/src/OpenMeteo/hourly/{useForecastHourly.js → useForecastHourly.ts} +11 -10
- package/src/OpenMeteo/index.ts +11 -0
- package/src/OpenMeteo/types.ts +15 -0
- package/src/OpenMeteo/weatherSymbol/lib/WeatherCodesEn.js +1 -1
- package/src/OpenMeteo/weatherSymbol/lib/WeatherCodesEs.js +1 -1
- package/src/OpenMeteo/weatherSymbol/{weatherSymbol.js → weatherSymbol.ts} +7 -12
- package/src/astronomy/moon/MoonCalc.js +6 -6
- package/src/astronomy/sun/SunCalc.js +3 -3
- package/src/geolocation/getGeolocation.js +2 -2
- package/src/geolocation/lib/geolocation.js +3 -3
- package/src/geolocation/lib/reversegeocoding.js +1 -1
- package/src/geolocation/timeFromLocation.js +2 -2
- package/src/utils/degreesToCompass.js +1 -1
- package/src/utils/timehelpers.js +1 -1
- package/src/utils/warning.js +1 -1
- package/src/utils/wind/WindArrow.jsx +2 -3
- package/src/utils/wind/windLevel.js +1 -1
- package/src/OpenMeteo/index.js +0 -10
- package/src/OpenMeteo/types.js +0 -8
- /package/src/astronomy/{index.js → index.ts} +0 -0
- /package/src/geolocation/{index.js → index.ts} +0 -0
- /package/src/{index.js → index.ts} +0 -0
- /package/src/utils/{index.js → index.ts} +0 -0
package/README.md
CHANGED
|
@@ -24,13 +24,6 @@ I use private libraries for the following:
|
|
|
24
24
|
¡Solo proporcionar HORA LOCAL DEL SISTEMA!: 'new Date()'
|
|
25
25
|
Con excepción de 'getSolarTime()': recibe la hora local correspondiente a la localización dada.</p>
|
|
26
26
|
</dd>
|
|
27
|
-
<dt><a href="#module_Geolocation">Geolocation</a></dt>
|
|
28
|
-
<dd></dd>
|
|
29
|
-
<dt><a href="#module_OpenMeteo">OpenMeteo</a></dt>
|
|
30
|
-
<dd><p>Use the OpenWeather forecast API</p>
|
|
31
|
-
</dd>
|
|
32
|
-
<dt><a href="#module_Utils">Utils</a></dt>
|
|
33
|
-
<dd></dd>
|
|
34
27
|
<dt><a href="#module_Utils/TimeDateStr">Utils/TimeDateStr</a></dt>
|
|
35
28
|
<dd><p>Helpers for get date and time formeted strings</p>
|
|
36
29
|
</dd>
|
|
@@ -54,8 +47,8 @@ Importante!:
|
|
|
54
47
|
* [.emoji(latitude, longitude, [date])](#module_Astronomy/MoonCalc.emoji) ⇒ <code>string</code>
|
|
55
48
|
* [.times(latitude, longitude, timezoneId, date)](#module_Astronomy/MoonCalc.times) ⇒ <code>Object</code>
|
|
56
49
|
* [.getUpOrDown(altitude, highest)](#module_Astronomy/MoonCalc.getUpOrDown) ⇒ <code>string</code>
|
|
57
|
-
* [.MoonDataExt](#module_Astronomy/MoonCalc.MoonDataExt) : <code>
|
|
58
|
-
* [.MoonData](#module_Astronomy/MoonCalc.MoonData) : <code>
|
|
50
|
+
* [.MoonDataExt](#module_Astronomy/MoonCalc.MoonDataExt) : <code>object</code>
|
|
51
|
+
* [.MoonData](#module_Astronomy/MoonCalc.MoonData) : <code>object</code>
|
|
59
52
|
|
|
60
53
|
|
|
61
54
|
* * *
|
|
@@ -152,7 +145,7 @@ La fecha y hora se devolverán en la zona horaria local.
|
|
|
152
145
|
|
|
153
146
|
<a name="module_Astronomy/MoonCalc.MoonDataExt"></a>
|
|
154
147
|
|
|
155
|
-
### Astronomy/MoonCalc.MoonDataExt : <code>
|
|
148
|
+
### Astronomy/MoonCalc.MoonDataExt : <code>object</code>
|
|
156
149
|
**Kind**: static typedef of [<code>Astronomy/MoonCalc</code>](#module_Astronomy/MoonCalc)
|
|
157
150
|
**Properties**
|
|
158
151
|
|
|
@@ -167,21 +160,21 @@ La fecha y hora se devolverán en la zona horaria local.
|
|
|
167
160
|
| parallacticAngle | <code>number</code> |
|
|
168
161
|
| angle | <code>number</code> |
|
|
169
162
|
| position | <code>AstroPosition</code> |
|
|
170
|
-
| next | <code>
|
|
163
|
+
| next | <code>object</code> |
|
|
171
164
|
|
|
172
165
|
|
|
173
166
|
* * *
|
|
174
167
|
|
|
175
168
|
<a name="module_Astronomy/MoonCalc.MoonData"></a>
|
|
176
169
|
|
|
177
|
-
### Astronomy/MoonCalc.MoonData : <code>
|
|
170
|
+
### Astronomy/MoonCalc.MoonData : <code>object</code>
|
|
178
171
|
**Kind**: static typedef of [<code>Astronomy/MoonCalc</code>](#module_Astronomy/MoonCalc)
|
|
179
172
|
**Properties**
|
|
180
173
|
|
|
181
174
|
| Name | Type | Description |
|
|
182
175
|
| --- | --- | --- |
|
|
183
176
|
| position | <code>AstroPosition</code> | |
|
|
184
|
-
| next | <code>
|
|
177
|
+
| next | <code>object</code> | |
|
|
185
178
|
| next.newMoon | <code>string</code> | Date of the next new moon. |
|
|
186
179
|
| next.fullMoon | <code>string</code> | Date of the next full moon. |
|
|
187
180
|
|
|
@@ -215,7 +208,7 @@ Con excepción de 'getSolarTime()': recibe la hora local correspondiente a la lo
|
|
|
215
208
|
|
|
216
209
|
### Astronomy/SunCalc.all(date, latitude, longitude, timezoneId) ⇒ <code>Object</code>
|
|
217
210
|
**Kind**: static method of [<code>Astronomy/SunCalc</code>](#module_Astronomy/SunCalc)
|
|
218
|
-
**Returns**: <code>Object</code> - { sunTimes:
|
|
211
|
+
**Returns**: <code>Object</code> - { sunTimes: object, sunPosition: object, sunPhase: string }
|
|
219
212
|
|
|
220
213
|
| Param | Type |
|
|
221
214
|
| --- | --- |
|
|
@@ -302,412 +295,6 @@ Con excepción de 'getSolarTime()': recibe la hora local correspondiente a la lo
|
|
|
302
295
|
| noon | <code>string</code> |
|
|
303
296
|
|
|
304
297
|
|
|
305
|
-
* * *
|
|
306
|
-
|
|
307
|
-
<a name="module_Geolocation"></a>
|
|
308
|
-
|
|
309
|
-
## Geolocation
|
|
310
|
-
|
|
311
|
-
* [Geolocation](#module_Geolocation)
|
|
312
|
-
* [.exports.getGeolocation()](#module_Geolocation.exports.getGeolocation) ⇒ <code>Promise.<ResolvedLocation></code>
|
|
313
|
-
* [.exports.timeFromLocation(apiKey, lat, lng)](#module_Geolocation.exports.timeFromLocation) ⇒ <code>Promise.<(any\|LocalTimeData)></code>
|
|
314
|
-
* [.ResolvedLocation](#module_Geolocation.ResolvedLocation) : <code>Object</code>
|
|
315
|
-
* [.LocalTimeData](#module_Geolocation.LocalTimeData) : <code>Object</code>
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
* * *
|
|
319
|
-
|
|
320
|
-
<a name="module_Geolocation.exports.getGeolocation"></a>
|
|
321
|
-
|
|
322
|
-
### Geolocation.exports.getGeolocation() ⇒ <code>Promise.<ResolvedLocation></code>
|
|
323
|
-
Get the current geolocation of the device and reverse geocode it to get the address.
|
|
324
|
-
|
|
325
|
-
**Kind**: static method of [<code>Geolocation</code>](#module_Geolocation)
|
|
326
|
-
**Returns**: <code>Promise.<ResolvedLocation></code> - Promise
|
|
327
|
-
**Throws**:
|
|
328
|
-
|
|
329
|
-
- <code>Error</code> If geolocation is not supported or permission is denied.
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
* * *
|
|
333
|
-
|
|
334
|
-
<a name="module_Geolocation.exports.timeFromLocation"></a>
|
|
335
|
-
|
|
336
|
-
### Geolocation.exports.timeFromLocation(apiKey, lat, lng) ⇒ <code>Promise.<(any\|LocalTimeData)></code>
|
|
337
|
-
Get local time from a given location (lat, lng) using 'GoogleMaps TimeZone' API.
|
|
338
|
-
|
|
339
|
-
**Kind**: static method of [<code>Geolocation</code>](#module_Geolocation)
|
|
340
|
-
**Returns**: <code>Promise.<(any\|LocalTimeData)></code> - An object containing the local time and timezone information:
|
|
341
|
-
**Throws**:
|
|
342
|
-
|
|
343
|
-
- <code>Error</code> If the API request fails or returns an error status.
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
| Param | Type | Description |
|
|
347
|
-
| --- | --- | --- |
|
|
348
|
-
| apiKey | <code>string</code> | GoogleMaps API key. |
|
|
349
|
-
| lat | <code>number</code> | |
|
|
350
|
-
| lng | <code>number</code> | |
|
|
351
|
-
|
|
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
|
-
|
|
372
|
-
* * *
|
|
373
|
-
|
|
374
|
-
<a name="module_Geolocation.LocalTimeData"></a>
|
|
375
|
-
|
|
376
|
-
### Geolocation.LocalTimeData : <code>Object</code>
|
|
377
|
-
**Kind**: static typedef of [<code>Geolocation</code>](#module_Geolocation)
|
|
378
|
-
**Properties**
|
|
379
|
-
|
|
380
|
-
| Name | Type | Description |
|
|
381
|
-
| --- | --- | --- |
|
|
382
|
-
| time | <code>Date</code> | The local time. |
|
|
383
|
-
| timeStr | <code>string</code> | The formatted local time string. |
|
|
384
|
-
| timezone | <code>string</code> | The timezone name. |
|
|
385
|
-
| timezoneId | <code>string</code> | The timezone ID. |
|
|
386
|
-
| offset | <code>number</code> | The UTC offset in hours. |
|
|
387
|
-
| offsetSign | <code>string</code> | The sign of the offset ('+' or '-'). |
|
|
388
|
-
| dstOffset | <code>number</code> | The DST offset in hours. |
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
* * *
|
|
392
|
-
|
|
393
|
-
<a name="module_OpenMeteo"></a>
|
|
394
|
-
|
|
395
|
-
## OpenMeteo
|
|
396
|
-
Use the OpenWeather forecast API
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
* [OpenMeteo](#module_OpenMeteo)
|
|
400
|
-
* [.exports.useForecastCurrent(lat, lon, refreshIntervalMin)](#module_OpenMeteo.exports.useForecastCurrent) ⇒ <code>ForecastData</code>
|
|
401
|
-
* [.exports.useForecastDaily(lat, lon, refreshIntervalMin)](#module_OpenMeteo.exports.useForecastDaily) ⇒ <code>ForecastData</code>
|
|
402
|
-
* [.exports.useForecastHourly(location, dayNum)](#module_OpenMeteo.exports.useForecastHourly) ⇒ <code>ForecastData</code>
|
|
403
|
-
* [.exports.weatherSymbol(code, [precipitation], night, dark)](#module_OpenMeteo.exports.weatherSymbol) ⇒ <code>Object</code>
|
|
404
|
-
* [.ForecastData](#module_OpenMeteo.ForecastData) : <code>Object</code>
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
* * *
|
|
408
|
-
|
|
409
|
-
<a name="module_OpenMeteo.exports.useForecastCurrent"></a>
|
|
410
|
-
|
|
411
|
-
### OpenMeteo.exports.useForecastCurrent(lat, lon, refreshIntervalMin) ⇒ <code>ForecastData</code>
|
|
412
|
-
Custom hook to fetch current weather data from OpenMeteo API.
|
|
413
|
-
|
|
414
|
-
**Kind**: static method of [<code>OpenMeteo</code>](#module_OpenMeteo)
|
|
415
|
-
**Returns**: <code>ForecastData</code> - {data, isLoading, isError, apiUrl}
|
|
416
|
-
|
|
417
|
-
| Param | Type |
|
|
418
|
-
| --- | --- |
|
|
419
|
-
| lat | <code>number</code> |
|
|
420
|
-
| lon | <code>number</code> |
|
|
421
|
-
| refreshIntervalMin | <code>number</code> |
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
* * *
|
|
425
|
-
|
|
426
|
-
<a name="module_OpenMeteo.exports.useForecastDaily"></a>
|
|
427
|
-
|
|
428
|
-
### OpenMeteo.exports.useForecastDaily(lat, lon, refreshIntervalMin) ⇒ <code>ForecastData</code>
|
|
429
|
-
Custom hook to fetch daily forecast (10 days) data from OpenMeteo API.
|
|
430
|
-
|
|
431
|
-
https://api.open-meteo.com/v1/forecast?timezone=auto&latitude=36.6644363&longitude=-4.5108962&forecast_days=10&daily=weathercode
|
|
432
|
-
|
|
433
|
-
**Kind**: static method of [<code>OpenMeteo</code>](#module_OpenMeteo)
|
|
434
|
-
**Returns**: <code>ForecastData</code> - {data, isLoading, isError, apiUrl}
|
|
435
|
-
|
|
436
|
-
| Param | Type |
|
|
437
|
-
| --- | --- |
|
|
438
|
-
| lat | <code>number</code> |
|
|
439
|
-
| lon | <code>number</code> |
|
|
440
|
-
| refreshIntervalMin | <code>number</code> |
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
* * *
|
|
444
|
-
|
|
445
|
-
<a name="module_OpenMeteo.exports.useForecastHourly"></a>
|
|
446
|
-
|
|
447
|
-
### OpenMeteo.exports.useForecastHourly(location, dayNum) ⇒ <code>ForecastData</code>
|
|
448
|
-
Custom hook to fetch hourly forecast data for a given location and number of days from OpenMeteo API.
|
|
449
|
-
|
|
450
|
-
**Kind**: static method of [<code>OpenMeteo</code>](#module_OpenMeteo)
|
|
451
|
-
**Returns**: <code>ForecastData</code> - {data, isLoading, isError, apiUrl}
|
|
452
|
-
|
|
453
|
-
| Param | Type | Description |
|
|
454
|
-
| --- | --- | --- |
|
|
455
|
-
| location | <code>Object</code> | |
|
|
456
|
-
| dayNum | <code>number</code> | Number of days from today: -1 = 24 hours, 0 = today, 1 = tomorrow, ... |
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
* * *
|
|
460
|
-
|
|
461
|
-
<a name="module_OpenMeteo.exports.weatherSymbol"></a>
|
|
462
|
-
|
|
463
|
-
### OpenMeteo.exports.weatherSymbol(code, [precipitation], night, dark) ⇒ <code>Object</code>
|
|
464
|
-
Get weather symbol and description based on the weather code.
|
|
465
|
-
|
|
466
|
-
**Kind**: static method of [<code>OpenMeteo</code>](#module_OpenMeteo)
|
|
467
|
-
**Returns**: <code>Object</code> - { icon: string, description: string }
|
|
468
|
-
|
|
469
|
-
| Param | Type |
|
|
470
|
-
| --- | --- |
|
|
471
|
-
| code | <code>any</code> |
|
|
472
|
-
| [precipitation] | <code>number</code> |
|
|
473
|
-
| night | <code>boolean</code> |
|
|
474
|
-
| dark | <code>boolean</code> |
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
* * *
|
|
478
|
-
|
|
479
|
-
<a name="module_OpenMeteo.ForecastData"></a>
|
|
480
|
-
|
|
481
|
-
### OpenMeteo.ForecastData : <code>Object</code>
|
|
482
|
-
**Kind**: static typedef of [<code>OpenMeteo</code>](#module_OpenMeteo)
|
|
483
|
-
**Properties**
|
|
484
|
-
|
|
485
|
-
| Name | Type | Description |
|
|
486
|
-
| --- | --- | --- |
|
|
487
|
-
| data | <code>any</code> | Forecast data |
|
|
488
|
-
| isLoading | <code>boolean</code> | Loading state |
|
|
489
|
-
| isError | <code>any</code> | Error state |
|
|
490
|
-
| apiUrl | <code>string</code> | API URL |
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
* * *
|
|
494
|
-
|
|
495
|
-
<a name="module_Utils"></a>
|
|
496
|
-
|
|
497
|
-
## Utils
|
|
498
|
-
|
|
499
|
-
* [Utils](#module_Utils)
|
|
500
|
-
* [.directions](#module_Utils.directions) : <code>Array.<Compass></code>
|
|
501
|
-
* [.directionsEs](#module_Utils.directionsEs) : <code>Array.<Compass></code>
|
|
502
|
-
* [.ALERT_LEVEL](#module_Utils.ALERT_LEVEL) : <code>Array.<AlertLevel></code>
|
|
503
|
-
* [.WIND_LEVELS](#module_Utils.WIND_LEVELS) : <code>Array.<WindLevel></code>
|
|
504
|
-
* [.exports.degreesToCompass(degrees, language)](#module_Utils.exports.degreesToCompass) ⇒ <code>Object</code>
|
|
505
|
-
* [.exports.getWarningByDays(precipitationSumToday, precipitationSumTomorrow, showersSumToday, showersSumTomorrow)](#module_Utils.exports.getWarningByDays) ⇒ <code>Object</code> \| <code>null</code>
|
|
506
|
-
* [.exports.getWarning(precipitation, showers)](#module_Utils.exports.getWarning) ⇒ <code>Object</code> \| <code>null</code>
|
|
507
|
-
* [.exports.WindArrow(props)](#module_Utils.exports.WindArrow)
|
|
508
|
-
* [.exports.windArrowTx(deg)](#module_Utils.exports.windArrowTx) ⇒ <code>string</code>
|
|
509
|
-
* [.exports.getWindLevel(speed)](#module_Utils.exports.getWindLevel) ⇒ <code>WindLevel</code> \| <code>null</code>
|
|
510
|
-
* [.Compass](#module_Utils.Compass) : <code>Object</code>
|
|
511
|
-
* [.AlertLevel](#module_Utils.AlertLevel) : <code>Object</code>
|
|
512
|
-
* [.WindLevel](#module_Utils.WindLevel) : <code>Object</code>
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
* * *
|
|
516
|
-
|
|
517
|
-
<a name="module_Utils.directions"></a>
|
|
518
|
-
|
|
519
|
-
### Utils.directions : <code>Array.<Compass></code>
|
|
520
|
-
English compass designations
|
|
521
|
-
|
|
522
|
-
**Kind**: static constant of [<code>Utils</code>](#module_Utils)
|
|
523
|
-
**Properties**
|
|
524
|
-
|
|
525
|
-
| Name | Type | Description |
|
|
526
|
-
| --- | --- | --- |
|
|
527
|
-
| short | <code>string</code> | Short compass designation |
|
|
528
|
-
| full | <code>string</code> | Full compass designation |
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
* * *
|
|
532
|
-
|
|
533
|
-
<a name="module_Utils.directionsEs"></a>
|
|
534
|
-
|
|
535
|
-
### Utils.directionsEs : <code>Array.<Compass></code>
|
|
536
|
-
Spanish compass designations
|
|
537
|
-
|
|
538
|
-
**Kind**: static constant of [<code>Utils</code>](#module_Utils)
|
|
539
|
-
**Properties**
|
|
540
|
-
|
|
541
|
-
| Name | Type | Description |
|
|
542
|
-
| --- | --- | --- |
|
|
543
|
-
| short | <code>string</code> | Short compass designation |
|
|
544
|
-
| full | <code>string</code> | Full compass designation |
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
* * *
|
|
548
|
-
|
|
549
|
-
<a name="module_Utils.ALERT_LEVEL"></a>
|
|
550
|
-
|
|
551
|
-
### Utils.ALERT\_LEVEL : <code>Array.<AlertLevel></code>
|
|
552
|
-
Alert levels for rain and showers
|
|
553
|
-
|
|
554
|
-
**Kind**: static constant of [<code>Utils</code>](#module_Utils)
|
|
555
|
-
|
|
556
|
-
* * *
|
|
557
|
-
|
|
558
|
-
<a name="module_Utils.WIND_LEVELS"></a>
|
|
559
|
-
|
|
560
|
-
### Utils.WIND\_LEVELS : <code>Array.<WindLevel></code>
|
|
561
|
-
Ordered list of wind levels.
|
|
562
|
-
|
|
563
|
-
**Kind**: static constant of [<code>Utils</code>](#module_Utils)
|
|
564
|
-
|
|
565
|
-
* * *
|
|
566
|
-
|
|
567
|
-
<a name="module_Utils.exports.degreesToCompass"></a>
|
|
568
|
-
|
|
569
|
-
### Utils.exports.degreesToCompass(degrees, language) ⇒ <code>Object</code>
|
|
570
|
-
Convert degrees to compass designation
|
|
571
|
-
|
|
572
|
-
**Kind**: static method of [<code>Utils</code>](#module_Utils)
|
|
573
|
-
**Returns**: <code>Object</code> - {short: string, full: string}
|
|
574
|
-
|
|
575
|
-
| Param | Type | Description |
|
|
576
|
-
| --- | --- | --- |
|
|
577
|
-
| degrees | <code>number</code> | |
|
|
578
|
-
| language | <code>string</code> | Language code ("en-US", "es-ES", "auto") |
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
* * *
|
|
582
|
-
|
|
583
|
-
<a name="module_Utils.exports.getWarningByDays"></a>
|
|
584
|
-
|
|
585
|
-
### Utils.exports.getWarningByDays(precipitationSumToday, precipitationSumTomorrow, showersSumToday, showersSumTomorrow) ⇒ <code>Object</code> \| <code>null</code>
|
|
586
|
-
Get warning by today and tomorrow
|
|
587
|
-
|
|
588
|
-
**Kind**: static method of [<code>Utils</code>](#module_Utils)
|
|
589
|
-
**Returns**: <code>Object</code> \| <code>null</code> - {{ levelNum: number, level: string, message: string, day: number } | null}
|
|
590
|
-
|
|
591
|
-
| Param | Type |
|
|
592
|
-
| --- | --- |
|
|
593
|
-
| precipitationSumToday | <code>number</code> |
|
|
594
|
-
| precipitationSumTomorrow | <code>number</code> |
|
|
595
|
-
| showersSumToday | <code>number</code> |
|
|
596
|
-
| showersSumTomorrow | <code>number</code> |
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
* * *
|
|
600
|
-
|
|
601
|
-
<a name="module_Utils.exports.getWarning"></a>
|
|
602
|
-
|
|
603
|
-
### Utils.exports.getWarning(precipitation, showers) ⇒ <code>Object</code> \| <code>null</code>
|
|
604
|
-
Get warning by precipitation and showers
|
|
605
|
-
|
|
606
|
-
**Kind**: static method of [<code>Utils</code>](#module_Utils)
|
|
607
|
-
**Returns**: <code>Object</code> \| <code>null</code> - {{ levelNum: number, level: string, message: string } | null}
|
|
608
|
-
|
|
609
|
-
| Param | Type |
|
|
610
|
-
| --- | --- |
|
|
611
|
-
| precipitation | <code>number</code> |
|
|
612
|
-
| showers | <code>number</code> |
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
* * *
|
|
616
|
-
|
|
617
|
-
<a name="module_Utils.exports.WindArrow"></a>
|
|
618
|
-
|
|
619
|
-
### Utils.exports.WindArrow(props)
|
|
620
|
-
SVG arrow indicating wind direction.
|
|
621
|
-
|
|
622
|
-
**Kind**: static method of [<code>Utils</code>](#module_Utils)
|
|
623
|
-
**Component**: JSX
|
|
624
|
-
|
|
625
|
-
| Param | Type | Description |
|
|
626
|
-
| --- | --- | --- |
|
|
627
|
-
| props | <code>Object</code> | Component props. |
|
|
628
|
-
| props.deg | <code>number</code> | Wind direction in degrees (0 = North, 90 = East, etc.). |
|
|
629
|
-
| [props.size] | <code>string</code> | Tailwind CSS size class (e.g., 'size-10') |
|
|
630
|
-
| [props.strokeWidth] | <code>number</code> | Stroke width of the arrow (range: 1–6). |
|
|
631
|
-
| [props.className] | <code>string</code> | Additional CSS classes. |
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
* * *
|
|
635
|
-
|
|
636
|
-
<a name="module_Utils.exports.windArrowTx"></a>
|
|
637
|
-
|
|
638
|
-
### Utils.exports.windArrowTx(deg) ⇒ <code>string</code>
|
|
639
|
-
Convert wind direction in degrees to an arrow representation.
|
|
640
|
-
|
|
641
|
-
**Kind**: static method of [<code>Utils</code>](#module_Utils)
|
|
642
|
-
**Returns**: <code>string</code> - Arrow representation of the wind direction.
|
|
643
|
-
|
|
644
|
-
| Param | Type | Description |
|
|
645
|
-
| --- | --- | --- |
|
|
646
|
-
| deg | <code>number</code> | Wind direction in degrees. |
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
* * *
|
|
650
|
-
|
|
651
|
-
<a name="module_Utils.exports.getWindLevel"></a>
|
|
652
|
-
|
|
653
|
-
### Utils.exports.getWindLevel(speed) ⇒ <code>WindLevel</code> \| <code>null</code>
|
|
654
|
-
Return the wind level based on the speed.
|
|
655
|
-
|
|
656
|
-
**Kind**: static method of [<code>Utils</code>](#module_Utils)
|
|
657
|
-
**Returns**: <code>WindLevel</code> \| <code>null</code> - Wind level object or null if speed is null
|
|
658
|
-
|
|
659
|
-
| Param | Type | Description |
|
|
660
|
-
| --- | --- | --- |
|
|
661
|
-
| speed | <code>number</code> | Wind speed in km/h |
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
* * *
|
|
665
|
-
|
|
666
|
-
<a name="module_Utils.Compass"></a>
|
|
667
|
-
|
|
668
|
-
### Utils.Compass : <code>Object</code>
|
|
669
|
-
**Kind**: static typedef of [<code>Utils</code>](#module_Utils)
|
|
670
|
-
**Properties**
|
|
671
|
-
|
|
672
|
-
| Name | Type | Description |
|
|
673
|
-
| --- | --- | --- |
|
|
674
|
-
| short | <code>string</code> | Short compass designation |
|
|
675
|
-
| full | <code>string</code> | Full compass designation |
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
* * *
|
|
679
|
-
|
|
680
|
-
<a name="module_Utils.AlertLevel"></a>
|
|
681
|
-
|
|
682
|
-
### Utils.AlertLevel : <code>Object</code>
|
|
683
|
-
**Kind**: static typedef of [<code>Utils</code>](#module_Utils)
|
|
684
|
-
**Properties**
|
|
685
|
-
|
|
686
|
-
| Name | Type | Description |
|
|
687
|
-
| --- | --- | --- |
|
|
688
|
-
| levelNum | <code>number</code> | The alert level number. |
|
|
689
|
-
| level | <code>string</code> | The alert level string (e.g., "red", "orange", "yellow"). |
|
|
690
|
-
| precipitation | <code>number</code> | The precipitation threshold for the alert level. |
|
|
691
|
-
| showers | <code>number</code> | The showers threshold for the alert level. |
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
* * *
|
|
695
|
-
|
|
696
|
-
<a name="module_Utils.WindLevel"></a>
|
|
697
|
-
|
|
698
|
-
### Utils.WindLevel : <code>Object</code>
|
|
699
|
-
**Kind**: static typedef of [<code>Utils</code>](#module_Utils)
|
|
700
|
-
**Properties**
|
|
701
|
-
|
|
702
|
-
| Name | Type | Description |
|
|
703
|
-
| --- | --- | --- |
|
|
704
|
-
| id | <code>number</code> | Level ID |
|
|
705
|
-
| speed | <code>number</code> | Minimum wind speed for this level |
|
|
706
|
-
| color | <code>string</code> | Color representing this level |
|
|
707
|
-
| tx | <code>string</code> | Text representing this level |
|
|
708
|
-
| txEn | <code>string</code> | Text representing this level |
|
|
709
|
-
|
|
710
|
-
|
|
711
298
|
* * *
|
|
712
299
|
|
|
713
300
|
<a name="module_Utils/TimeDateStr"></a>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Transforms the OpenMeteo API data into a more usable format.
|
|
3
3
|
*
|
|
4
4
|
* @param {{current: any, daily: any, hourly: any, latitude: number, longitude: number}} data - The data object to transform.
|
|
5
|
-
* @returns {
|
|
5
|
+
* @returns {object|null} - The transformed data object or null if the input is invalid.
|
|
6
6
|
*/
|
|
7
7
|
export default function transformer(data: {
|
|
8
8
|
current: any;
|
|
@@ -10,4 +10,4 @@ export default function transformer(data: {
|
|
|
10
10
|
hourly: any;
|
|
11
11
|
latitude: number;
|
|
12
12
|
longitude: number;
|
|
13
|
-
}):
|
|
13
|
+
}): object | null;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
+
import type { ForecastData } from "../types";
|
|
1
2
|
/**
|
|
2
3
|
* Custom hook to fetch current weather data from OpenMeteo API.
|
|
3
|
-
*
|
|
4
|
-
* @param {number} lat
|
|
5
|
-
* @param {number} lon
|
|
6
|
-
* @param {number} refreshIntervalMin
|
|
7
|
-
* @returns {ForecastData} {data, isLoading, isError, apiUrl}
|
|
8
|
-
* @memberof module:OpenMeteo
|
|
9
4
|
*/
|
|
10
|
-
export function useForecastCurrent(lat: number, lon: number, refreshIntervalMin?: number): ForecastData;
|
|
5
|
+
export declare function useForecastCurrent(lat: number | undefined, lon: number | undefined, refreshIntervalMin?: number): ForecastData;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Transforms the OpenMeteo API data into a more usable format.
|
|
3
3
|
*
|
|
4
4
|
* @param {{daily: any}} data - The data object to transform.
|
|
5
|
-
* @returns {
|
|
5
|
+
* @returns {object|null} - The transformed data object or null if the input is invalid.
|
|
6
6
|
*/
|
|
7
7
|
export default function transformer(data: {
|
|
8
8
|
daily: any;
|
|
9
|
-
}):
|
|
9
|
+
}): object | null;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
+
import type { ForecastData } from "../types";
|
|
1
2
|
/**
|
|
2
3
|
* Custom hook to fetch daily forecast (10 days) data from OpenMeteo API.
|
|
3
|
-
*
|
|
4
4
|
* https://api.open-meteo.com/v1/forecast?timezone=auto&latitude=36.6644363&longitude=-4.5108962&forecast_days=10&daily=weathercode
|
|
5
|
-
*
|
|
6
|
-
* @param {number} lat
|
|
7
|
-
* @param {number} lon
|
|
8
|
-
* @param {number} refreshIntervalMin
|
|
9
|
-
* @returns {ForecastData} {data, isLoading, isError, apiUrl}
|
|
10
|
-
* @memberof module:OpenMeteo
|
|
11
5
|
*/
|
|
12
|
-
export function useForecastDaily(lat: number, lon: number, refreshIntervalMin?: number): ForecastData;
|
|
6
|
+
export declare function useForecastDaily(lat: number | undefined, lon: number | undefined, refreshIntervalMin?: number): ForecastData;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
+
import type { ForecastData } from "../types";
|
|
1
2
|
/**
|
|
2
3
|
* Custom hook to fetch hourly forecast data for a given location and number of days from OpenMeteo API.
|
|
3
|
-
*
|
|
4
|
-
* @param {{ latitude: number, longitude: number }} location
|
|
5
|
-
* @param {number} dayNum Number of days from today: -1 = 24 hours, 0 = today, 1 = tomorrow, ...
|
|
6
|
-
* @returns {ForecastData} {data, isLoading, isError, apiUrl}
|
|
7
|
-
* @memberof module:OpenMeteo
|
|
8
4
|
*/
|
|
9
|
-
export function useForecastHourly(
|
|
10
|
-
latitude: number;
|
|
11
|
-
longitude: number;
|
|
12
|
-
}, dayNum: number): ForecastData;
|
|
5
|
+
export declare function useForecastHourly(lat: number, lon: number, dayNum: number): ForecastData;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Use the OpenWeather forecast API
|
|
3
|
+
* @package OpenMeteo
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export { useForecastCurrent } from "./current/useForecastCurrent";
|
|
7
|
+
export { useForecastDaily } from "./daily/useForecastDaily";
|
|
8
|
+
export { useForecastHourly } from "./hourly/useForecastHourly";
|
|
9
|
+
export { weatherSymbol } from "./weatherSymbol/weatherSymbol";
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @memberof module:OpenMeteo
|
|
3
|
+
*/
|
|
4
|
+
export type ForecastData = {
|
|
5
5
|
data: any;
|
|
6
|
-
/**
|
|
7
|
-
* - Loading state
|
|
8
|
-
*/
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* - Error state
|
|
12
|
-
*/
|
|
13
|
-
isError: any;
|
|
14
|
-
/**
|
|
15
|
-
* - API URL
|
|
16
|
-
*/
|
|
17
6
|
apiUrl: string;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
isError: unknown;
|
|
9
|
+
};
|
|
10
|
+
export type WeatherSymbol = {
|
|
11
|
+
icon: string;
|
|
12
|
+
description: string;
|
|
18
13
|
};
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* 96, 99 * Thunderstorm with slight and heavy hail
|
|
21
21
|
*/
|
|
22
22
|
/**
|
|
23
|
-
* @typedef {
|
|
23
|
+
* @typedef {object} WeatherCodeEntry
|
|
24
24
|
* @property {number} code - WMO Weather interpretation codes (WW).
|
|
25
25
|
* @property {string} icon - Icon name.
|
|
26
26
|
* @property {string} description - Description.
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* 96, 99 * Thunderstorm with slight and heavy hail
|
|
21
21
|
*/
|
|
22
22
|
/**
|
|
23
|
-
* @typedef {
|
|
23
|
+
* @typedef {object} WeatherCodeEntry
|
|
24
24
|
* @property {number} code - WMO Weather interpretation codes (WW).
|
|
25
25
|
* @property {string} icon - Icon name.
|
|
26
26
|
* @property {string} description - Description.
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
+
import type { WeatherSymbol } from "../types";
|
|
1
2
|
/**
|
|
2
3
|
* Get weather symbol and description based on the weather code.
|
|
3
|
-
*
|
|
4
|
-
* @param {any} code
|
|
5
|
-
* @param {number} [precipitation]
|
|
6
|
-
* @param {boolean} night
|
|
7
|
-
* @param {boolean} dark
|
|
8
|
-
* @returns {{ icon: string, description: string }}
|
|
9
|
-
* { icon: string, description: string }
|
|
10
4
|
* @memberof module:OpenMeteo
|
|
11
5
|
*/
|
|
12
|
-
export function weatherSymbol(code: any, precipitation?: number, night?: boolean, dark?: boolean):
|
|
13
|
-
icon: string;
|
|
14
|
-
description: string;
|
|
15
|
-
};
|
|
6
|
+
export declare function weatherSymbol(code: any, precipitation?: number | undefined, night?: boolean, dark?: boolean): WeatherSymbol;
|
|
@@ -12,13 +12,13 @@ declare namespace SunCalc {
|
|
|
12
12
|
* @param {number} latitude
|
|
13
13
|
* @param {number} longitude
|
|
14
14
|
* @param {string} timezoneId
|
|
15
|
-
* @returns {{ sunTimes:
|
|
16
|
-
* { sunTimes:
|
|
15
|
+
* @returns {{ sunTimes: object, sunPosition: object, sunPhase: string }}
|
|
16
|
+
* { sunTimes: object, sunPosition: object, sunPhase: string }
|
|
17
17
|
* @memberof module:Astronomy/SunCalc
|
|
18
18
|
*/
|
|
19
19
|
declare function all(date: Date, latitude: number, longitude: number, timezoneId: string): {
|
|
20
|
-
sunTimes:
|
|
21
|
-
sunPosition:
|
|
20
|
+
sunTimes: object;
|
|
21
|
+
sunPosition: object;
|
|
22
22
|
sunPhase: string;
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @memberof module:Geolocation
|
|
3
|
-
* @typedef {
|
|
3
|
+
* @typedef {object} LocalTimeData
|
|
4
4
|
* @property {Date} time - The local time.
|
|
5
5
|
* @property {string} timeStr - The formatted local time string.
|
|
6
6
|
* @property {string} timezone - The timezone name.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { useForecastDaily } from "./OpenMeteo/daily/useForecastDaily";
|
|
|
8
8
|
export { useForecastHourly } from "./OpenMeteo/hourly/useForecastHourly";
|
|
9
9
|
export { weatherSymbol } from "./OpenMeteo/weatherSymbol/weatherSymbol";
|
|
10
10
|
export { degreesToCompass } from "./utils/degreesToCompass";
|
|
11
|
+
export { getWarning, getWarningByDays } from "./utils/warning";
|
|
11
12
|
export { WindArrow } from "./utils/wind/WindArrow";
|
|
12
13
|
export { windArrowTx } from "./utils/wind/windArrowTx";
|
|
13
14
|
export { getWindLevel } from "./utils/wind/windLevel";
|
|
14
|
-
export { getWarning, getWarningByDays } from "./utils/warning";
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Utils
|
|
3
|
+
*/
|
|
1
4
|
export { degreesToCompass } from "./degreesToCompass.js";
|
|
2
5
|
export { default as TimeDateStr } from "./timehelpers.js";
|
|
6
|
+
export { getWarning, getWarningByDays } from "./warning.js";
|
|
3
7
|
export { WindArrow } from "./wind/WindArrow.jsx";
|
|
4
8
|
export { windArrowTx } from "./wind/windArrowTx.js";
|
|
5
9
|
export { getWindLevel } from "./wind/windLevel.js";
|
|
6
|
-
export { getWarning, getWarningByDays } from "./warning.js";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* SVG arrow indicating wind direction.
|
|
3
3
|
*
|
|
4
4
|
* @component JSX
|
|
5
|
-
* @param {
|
|
5
|
+
* @param {object} props - Component props.
|
|
6
6
|
* @param {number} props.deg - Wind direction in degrees (0 = North, 90 = East, etc.).
|
|
7
7
|
* @param {string} [props.size] - Tailwind CSS size class (e.g., 'size-10')
|
|
8
8
|
* @param {number} [props.strokeWidth] - Stroke width of the arrow (range: 1–6).
|
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.
|
|
4
|
+
"version": "1.1.19",
|
|
5
5
|
"description": "Utilities for obtaining weather and astronomy forecast data.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"publishConfig": {
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"JavaScript"
|
|
33
33
|
],
|
|
34
34
|
"peerDependencies": {
|
|
35
|
+
"@capacitor/geolocation": "^7.1.2",
|
|
35
36
|
"react": "^19.1.0",
|
|
36
37
|
"suncalc3": "^2.0.5",
|
|
37
|
-
"swr": "^2.3.3"
|
|
38
|
-
"@capacitor/geolocation": "^7.1.2"
|
|
38
|
+
"swr": "^2.3.3"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@biomejs/biome": "2.2.4",
|
|
@@ -43,6 +43,5 @@
|
|
|
43
43
|
"@types/react-dom": "^19.1.9",
|
|
44
44
|
"jsdoc-to-markdown": "^9.1.2",
|
|
45
45
|
"typescript": "^5.9.2"
|
|
46
|
-
}
|
|
47
|
-
"dependencies": {}
|
|
46
|
+
}
|
|
48
47
|
}
|
package/src/OpenMeteo/conf.js
CHANGED
|
@@ -39,7 +39,7 @@ export function getPath(lat, lon, path) {
|
|
|
39
39
|
* @param {string} url
|
|
40
40
|
*/
|
|
41
41
|
function devLog(title, url) {
|
|
42
|
-
|
|
42
|
+
/* @ts-expect-error */
|
|
43
43
|
if (import.meta.env.MODE === "development") {
|
|
44
44
|
// console.log('%c> fetch [' + title + ']:', 'color:#9e9', url);
|
|
45
45
|
console.log("> fetch [" + title + "]:", url);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Transforms the OpenMeteo API data into a more usable format.
|
|
3
3
|
*
|
|
4
4
|
* @param {{current: any, daily: any, hourly: any, latitude: number, longitude: number}} data - The data object to transform.
|
|
5
|
-
* @returns {
|
|
5
|
+
* @returns {object|null} - The transformed data object or null if the input is invalid.
|
|
6
6
|
*/
|
|
7
7
|
export default function transformer(data) {
|
|
8
8
|
if (!data) return null;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import useSWR from "swr";
|
|
3
2
|
import { fetcher, getPath } from "../conf.js";
|
|
3
|
+
import type { ForecastData } from "../types";
|
|
4
4
|
import { fetchParams } from "./fetchParams.js";
|
|
5
5
|
import transformer from "./transformer.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Custom hook to fetch current weather data from OpenMeteo API.
|
|
9
|
-
*
|
|
10
|
-
* @param {number} lat
|
|
11
|
-
* @param {number} lon
|
|
12
|
-
* @param {number} refreshIntervalMin
|
|
13
|
-
* @returns {ForecastData} {data, isLoading, isError, apiUrl}
|
|
14
|
-
* @memberof module:OpenMeteo
|
|
15
9
|
*/
|
|
16
|
-
export function useForecastCurrent(
|
|
17
|
-
|
|
10
|
+
export function useForecastCurrent(
|
|
11
|
+
lat: number | undefined,
|
|
12
|
+
lon: number | undefined,
|
|
13
|
+
refreshIntervalMin: number = 0): ForecastData
|
|
14
|
+
{
|
|
15
|
+
// Validate --
|
|
16
|
+
if (lat == null || lon == null) {
|
|
18
17
|
throw new Error("useForecastCurrent: invalid coordinates");
|
|
19
18
|
}
|
|
20
19
|
|
|
20
|
+
// Fetch ---
|
|
21
21
|
const apiUrl = getPath(lat, lon, fetchParams);
|
|
22
22
|
const { data, error, isLoading } = useSWR(apiUrl, fetcher, {
|
|
23
23
|
refreshInterval: refreshIntervalMin * 60 * 1000,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Transforms the OpenMeteo API data into a more usable format.
|
|
3
3
|
*
|
|
4
4
|
* @param {{daily: any}} data - The data object to transform.
|
|
5
|
-
* @returns {
|
|
5
|
+
* @returns {object|null} - The transformed data object or null if the input is invalid.
|
|
6
6
|
*/
|
|
7
7
|
export default function transformer(data) {
|
|
8
8
|
if (!data) return null;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import useSWR from "swr";
|
|
3
2
|
import { fetcher, getPath } from "../conf.js";
|
|
3
|
+
import type { ForecastData } from "../types";
|
|
4
4
|
import { fetchParams } from "./fetchParams.js";
|
|
5
5
|
import transformer from "./transformer.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Custom hook to fetch daily forecast (10 days) data from OpenMeteo API.
|
|
9
|
-
*
|
|
10
9
|
* https://api.open-meteo.com/v1/forecast?timezone=auto&latitude=36.6644363&longitude=-4.5108962&forecast_days=10&daily=weathercode
|
|
11
|
-
*
|
|
12
|
-
* @param {number} lat
|
|
13
|
-
* @param {number} lon
|
|
14
|
-
* @param {number} refreshIntervalMin
|
|
15
|
-
* @returns {ForecastData} {data, isLoading, isError, apiUrl}
|
|
16
|
-
* @memberof module:OpenMeteo
|
|
17
10
|
*/
|
|
18
|
-
export function useForecastDaily(
|
|
11
|
+
export function useForecastDaily(
|
|
12
|
+
lat: number | undefined,
|
|
13
|
+
lon: number | undefined,
|
|
14
|
+
refreshIntervalMin: number = 0): ForecastData
|
|
15
|
+
{
|
|
19
16
|
// Validate --
|
|
20
|
-
if (
|
|
17
|
+
if (lat == null || lon == null) {
|
|
21
18
|
throw new Error("useForecastDaily: invalid coordinates");
|
|
22
19
|
}
|
|
23
20
|
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import useSWR from "swr";
|
|
3
2
|
import { fetcher, getPath } from "../conf.js";
|
|
4
3
|
import { getDatesFromNumDays } from "../helpers.js";
|
|
4
|
+
import type { ForecastData } from "../types";
|
|
5
5
|
import { fetchParams } from "./fetchParams.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Custom hook to fetch hourly forecast data for a given location and number of days from OpenMeteo API.
|
|
9
|
-
*
|
|
10
|
-
* @param {{ latitude: number, longitude: number }} location
|
|
11
|
-
* @param {number} dayNum Number of days from today: -1 = 24 hours, 0 = today, 1 = tomorrow, ...
|
|
12
|
-
* @returns {ForecastData} {data, isLoading, isError, apiUrl}
|
|
13
|
-
* @memberof module:OpenMeteo
|
|
14
9
|
*/
|
|
15
|
-
export function useForecastHourly(
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
export function useForecastHourly(
|
|
11
|
+
lat: number,
|
|
12
|
+
lon: number,
|
|
13
|
+
dayNum: number): ForecastData
|
|
14
|
+
{
|
|
15
|
+
|
|
16
|
+
// Validate --
|
|
17
|
+
if (lat == null || lon == null) {
|
|
18
|
+
throw new Error("useForecastHourly: invalid coordinates: ["+lon+"]["+lat+"]");
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
// Fetch ---
|
|
@@ -28,7 +29,7 @@ export function useForecastHourly(location, dayNum) {
|
|
|
28
29
|
dates.endDate +
|
|
29
30
|
"&" +
|
|
30
31
|
fetchParams;
|
|
31
|
-
apiUrl = getPath(
|
|
32
|
+
apiUrl = getPath(lat, lon, apiUrl);
|
|
32
33
|
|
|
33
34
|
const { data, error, isLoading } = useSWR(apiUrl, fetcher);
|
|
34
35
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use the OpenWeather forecast API
|
|
3
|
+
* @package OpenMeteo
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export { useForecastCurrent } from "./current/useForecastCurrent";
|
|
8
|
+
export { useForecastDaily } from "./daily/useForecastDaily";
|
|
9
|
+
export { useForecastHourly } from "./hourly/useForecastHourly";
|
|
10
|
+
export { weatherSymbol } from "./weatherSymbol/weatherSymbol";
|
|
11
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @memberof module:OpenMeteo
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export type ForecastData = {
|
|
6
|
+
data: any; // 👈 Cambiar al tipo real que devuelve `transformer`
|
|
7
|
+
apiUrl: string;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
isError: unknown;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type WeatherSymbol = {
|
|
13
|
+
icon: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
+
import type { WeatherSymbol } from "../types";
|
|
1
2
|
import { getWeatherCodeEntry } from "./lib/getWeatherCodeEntry.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Get weather symbol and description based on the weather code.
|
|
5
|
-
*
|
|
6
|
-
* @param {any} code
|
|
7
|
-
* @param {number} [precipitation]
|
|
8
|
-
* @param {boolean} night
|
|
9
|
-
* @param {boolean} dark
|
|
10
|
-
* @returns {{ icon: string, description: string }}
|
|
11
|
-
* { icon: string, description: string }
|
|
12
6
|
* @memberof module:OpenMeteo
|
|
13
7
|
*/
|
|
14
8
|
export function weatherSymbol(
|
|
15
|
-
code,
|
|
16
|
-
precipitation = undefined,
|
|
17
|
-
night = false,
|
|
18
|
-
dark = false,
|
|
19
|
-
)
|
|
9
|
+
code: any,
|
|
10
|
+
precipitation: number | undefined = undefined,
|
|
11
|
+
night: boolean = false,
|
|
12
|
+
dark: boolean = false,
|
|
13
|
+
): WeatherSymbol
|
|
14
|
+
{
|
|
20
15
|
// Parse code ---
|
|
21
16
|
let msgPlus = "";
|
|
22
17
|
let theCode = code;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @module Astronomy/MoonCalc
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
/* @ts-expect-error */
|
|
13
13
|
import SunCalc from "suncalc3";
|
|
14
14
|
import TimeDateStr from "../../utils/timehelpers.js";
|
|
15
15
|
import { parseBasicData } from "./parseBasicData.js";
|
|
@@ -29,7 +29,7 @@ export default MoonCalc;
|
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* @memberof module:Astronomy
|
|
32
|
-
* @typedef {
|
|
32
|
+
* @typedef {object} AstroPosition
|
|
33
33
|
* @property {number} altitude
|
|
34
34
|
* @property {number} azimuth
|
|
35
35
|
* @property {string} direction
|
|
@@ -38,7 +38,7 @@ export default MoonCalc;
|
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* @memberof module:Astronomy/MoonCalc
|
|
41
|
-
* @typedef {
|
|
41
|
+
* @typedef {object} MoonDataExt
|
|
42
42
|
* @property {string} date
|
|
43
43
|
* @property {string} time
|
|
44
44
|
* @property {string} illumination
|
|
@@ -48,14 +48,14 @@ export default MoonCalc;
|
|
|
48
48
|
* @property {number} parallacticAngle
|
|
49
49
|
* @property {number} angle
|
|
50
50
|
* @property {AstroPosition} position
|
|
51
|
-
* @property {
|
|
51
|
+
* @property {object} next
|
|
52
52
|
*/
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* @memberof module:Astronomy/MoonCalc
|
|
56
|
-
* @typedef {
|
|
56
|
+
* @typedef {object} MoonData
|
|
57
57
|
* @property {AstroPosition} position
|
|
58
|
-
* @property {
|
|
58
|
+
* @property {object} next
|
|
59
59
|
* @property {string} next.newMoon - Date of the next new moon.
|
|
60
60
|
* @property {string} next.fullMoon - Date of the next full moon.
|
|
61
61
|
*/
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @module Astronomy/SunCalc
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
/* @ts-expect-error */
|
|
14
14
|
import { default as SunCalc3 } from "suncalc3";
|
|
15
15
|
import { degreesToCompass } from "../../utils/degreesToCompass.js";
|
|
16
16
|
import TimeDateStr from "../../utils/timehelpers.js";
|
|
@@ -35,8 +35,8 @@ export default SunCalc;
|
|
|
35
35
|
* @param {number} latitude
|
|
36
36
|
* @param {number} longitude
|
|
37
37
|
* @param {string} timezoneId
|
|
38
|
-
* @returns {{ sunTimes:
|
|
39
|
-
* { sunTimes:
|
|
38
|
+
* @returns {{ sunTimes: object, sunPosition: object, sunPhase: string }}
|
|
39
|
+
* { sunTimes: object, sunPosition: object, sunPhase: string }
|
|
40
40
|
* @memberof module:Astronomy/SunCalc
|
|
41
41
|
*/
|
|
42
42
|
function all(date, latitude, longitude, timezoneId) {
|
|
@@ -3,7 +3,7 @@ import reverseGeocoding from "./lib/reversegeocoding.js";
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @memberof module:Geolocation
|
|
6
|
-
* @typedef {
|
|
6
|
+
* @typedef {object} ResolvedLocation
|
|
7
7
|
* @property {number} latitude
|
|
8
8
|
* @property {number} longitude
|
|
9
9
|
* // Address
|
|
@@ -39,7 +39,7 @@ export async function getGeolocation() {
|
|
|
39
39
|
address = await reverseGeocoding(
|
|
40
40
|
location.latitude,
|
|
41
41
|
location.longitude,
|
|
42
|
-
|
|
42
|
+
/* @ts-expect-error */
|
|
43
43
|
import.meta.env.VITE_googlemaps_api_key,
|
|
44
44
|
);
|
|
45
45
|
} catch (error) {
|
|
@@ -31,15 +31,15 @@ export default async function geolocation() {
|
|
|
31
31
|
} catch (error) {
|
|
32
32
|
console.error(error);
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
/* @ts-expect-error */
|
|
35
35
|
if (error.code === error.PERMISSION_DENIED) {
|
|
36
36
|
throw new Error("Geolocation: permission denied");
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
/* @ts-expect-error */
|
|
39
39
|
if (error.code === error.POSITION_UNAVAILABLE) {
|
|
40
40
|
throw new Error("Geolocation: position unavailable");
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
/* @ts-expect-error */
|
|
43
43
|
if (error.code === error.TIMEOUT) {
|
|
44
44
|
throw new Error("Geolocation: timeout");
|
|
45
45
|
}
|
|
@@ -102,7 +102,7 @@ export default async function reverseGeocoding(latitude, longitude, api_key) {
|
|
|
102
102
|
* @param {any} url
|
|
103
103
|
*/
|
|
104
104
|
function devLog(title, url) {
|
|
105
|
-
|
|
105
|
+
/* @ts-expect-error */
|
|
106
106
|
if (import.meta.env.MODE === "development") {
|
|
107
107
|
console.log(`> fetch [${title}]:`, url);
|
|
108
108
|
}
|
|
@@ -3,7 +3,7 @@ import TimeDateStr from "../utils/timehelpers.js";
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @memberof module:Geolocation
|
|
6
|
-
* @typedef {
|
|
6
|
+
* @typedef {object} LocalTimeData
|
|
7
7
|
* @property {Date} time - The local time.
|
|
8
8
|
* @property {string} timeStr - The formatted local time string.
|
|
9
9
|
* @property {string} timezone - The timezone name.
|
|
@@ -55,7 +55,7 @@ export async function timeFromLocation(apiKey, lat, lng) {
|
|
|
55
55
|
//------------------------------------------------------
|
|
56
56
|
/**
|
|
57
57
|
* @private
|
|
58
|
-
* @param {
|
|
58
|
+
* @param {object} timezoneInfo - The timezone Google API information.
|
|
59
59
|
* @param {number} timezoneInfo.rawOffset - The raw offset in seconds.
|
|
60
60
|
* @param {number} timezoneInfo.dstOffset - The DST offset in seconds.
|
|
61
61
|
* @param {string} timezoneInfo.timeZoneName - The name of the timezone.
|
package/src/utils/timehelpers.js
CHANGED
package/src/utils/warning.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {
|
|
2
|
+
* @typedef {object} AlertLevel
|
|
3
3
|
* @property {number} levelNum - The alert level number.
|
|
4
4
|
* @property {string} level - The alert level string (e.g., "red", "orange", "yellow").
|
|
5
5
|
* @property {number} precipitation - The precipitation threshold for the alert level.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* SVG arrow indicating wind direction.
|
|
3
3
|
*
|
|
4
4
|
* @component JSX
|
|
5
|
-
* @param {
|
|
5
|
+
* @param {object} props - Component props.
|
|
6
6
|
* @param {number} props.deg - Wind direction in degrees (0 = North, 90 = East, etc.).
|
|
7
7
|
* @param {string} [props.size] - Tailwind CSS size class (e.g., 'size-10')
|
|
8
8
|
* @param {number} [props.strokeWidth] - Stroke width of the arrow (range: 1–6).
|
|
@@ -17,13 +17,12 @@ export function WindArrow({
|
|
|
17
17
|
}) {
|
|
18
18
|
if (deg == null) {
|
|
19
19
|
// console.warn("WindArrow: deg is undefined");
|
|
20
|
-
/* @ts-ignore */
|
|
21
20
|
return <div>deg?</div>;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
// Render arrow ---
|
|
25
24
|
return (
|
|
26
|
-
|
|
25
|
+
/*·@ts-expect-error·*/
|
|
27
26
|
<svg
|
|
28
27
|
className={`${size} ${className}`}
|
|
29
28
|
style={{ transform: `rotate(${deg}deg)` }}
|
package/src/OpenMeteo/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Use the OpenWeather forecast API
|
|
3
|
-
* @module OpenMeteo
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export { useForecastCurrent } from "./current/useForecastCurrent.js";
|
|
8
|
-
export { useForecastDaily } from "./daily/useForecastDaily.js";
|
|
9
|
-
export { useForecastHourly } from "./hourly/useForecastHourly.js";
|
|
10
|
-
export { weatherSymbol } from "./weatherSymbol/weatherSymbol.js";
|
package/src/OpenMeteo/types.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|