@angelrove/forecast-utils 1.1.19 → 1.1.21

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.
Files changed (45) hide show
  1. package/dist/types/OpenMeteo/index.d.ts +2 -1
  2. package/dist/types/OpenMeteo/types.d.ts +0 -1
  3. package/dist/types/OpenMeteo/weatherSymbol/weatherSymbol.d.ts +0 -1
  4. package/dist/types/astronomy/index.d.ts +7 -2
  5. package/dist/types/astronomy/moon/MoonCalc.d.ts +23 -77
  6. package/dist/types/astronomy/moon/types.d.ts +33 -0
  7. package/dist/types/astronomy/sun/SunCalc.d.ts +14 -21
  8. package/dist/types/geolocation/getGeolocation.d.ts +3 -27
  9. package/dist/types/geolocation/index.d.ts +3 -2
  10. package/dist/types/geolocation/lib/reversegeocoding.d.ts +3 -11
  11. package/dist/types/geolocation/timeFromLocation.d.ts +0 -2
  12. package/dist/types/geolocation/types.d.ts +16 -0
  13. package/dist/types/index.d.ts +3 -3
  14. package/dist/types/utils/degreesToCompass.d.ts +0 -1
  15. package/dist/types/utils/index.d.ts +7 -6
  16. package/dist/types/utils/timehelpers.d.ts +2 -6
  17. package/dist/types/utils/warning.d.ts +0 -3
  18. package/dist/types/utils/wind/WindArrow.d.ts +0 -2
  19. package/dist/types/utils/wind/windArrowTx.d.ts +0 -1
  20. package/dist/types/utils/wind/windLevel.d.ts +7 -23
  21. package/package.json +6 -3
  22. package/src/OpenMeteo/index.ts +2 -1
  23. package/src/OpenMeteo/types.ts +0 -1
  24. package/src/OpenMeteo/weatherSymbol/weatherSymbol.ts +0 -1
  25. package/src/astronomy/index.ts +9 -2
  26. package/src/astronomy/moon/{MoonCalc.js → MoonCalc.ts} +34 -91
  27. package/src/astronomy/moon/parseBasicData.js +2 -2
  28. package/src/astronomy/moon/types.ts +36 -0
  29. package/src/astronomy/sun/SunCalc.js +13 -15
  30. package/src/geolocation/{getGeolocation.js → getGeolocation.ts} +9 -26
  31. package/src/geolocation/index.ts +4 -2
  32. package/src/geolocation/lib/{geolocation.js → geolocation.ts} +2 -2
  33. package/src/geolocation/lib/{reversegeocoding.js → reversegeocoding.ts} +10 -10
  34. package/src/geolocation/timeFromLocation.js +1 -3
  35. package/src/geolocation/types.ts +18 -0
  36. package/src/index.ts +3 -3
  37. package/src/utils/degreesToCompass.js +0 -4
  38. package/src/utils/index.ts +8 -6
  39. package/src/utils/timehelpers.js +1 -6
  40. package/src/utils/warning.js +0 -5
  41. package/src/utils/wind/WindArrow.jsx +0 -2
  42. package/src/utils/wind/windArrowTx.js +0 -1
  43. package/src/utils/wind/{windLevel.js → windLevel.ts} +11 -20
  44. package/README.md +0 -376
  45. /package/src/geolocation/lib/{geolocationCapacitor.js → geolocationCapacitor.ts} +0 -0
@@ -1,20 +1,12 @@
1
- /**
2
- * @typedef {object} WindLevel
3
- * @property {number} id - Level ID
4
- * @property {number} speed - Minimum wind speed for this level
5
- * @property {string} color - Color representing this level
6
- * @property {string} tx - Text representing this level
7
- * @property {string} txEn - Text representing this level
8
- * @memberof module:Utils
9
- */
1
+ export type WindLevel = {
2
+ id: number; // Level ID
3
+ speed: number; // Minimum wind speed for this level
4
+ color: string;
5
+ tx: string;
6
+ txEn: string;
7
+ };
10
8
 
11
- /**
12
- * Ordered list of wind levels.
13
- *
14
- * @type {WindLevel[]}
15
- * @memberof module:Utils
16
- */
17
- const WIND_LEVELS = [
9
+ const WIND_LEVELS: WindLevel[] = [
18
10
  { id: 1, speed: 8, color: "green", tx: "Brisa", txEn: "Breeze" },
19
11
  { id: 2, speed: 16, color: "orange", tx: "Ligero", txEn: "Light" },
20
12
  { id: 3, speed: 23, color: "red", tx: "Moderado", txEn: "Moderate" },
@@ -32,11 +24,10 @@ const WIND_LEVELS = [
32
24
  /**
33
25
  * Return the wind level based on the speed.
34
26
  *
35
- * @param {number} speed Wind speed in km/h
36
- * @return {WindLevel | null} Wind level object or null if speed is null
37
- * @memberof module:Utils
27
+ * @param speed Wind speed in km/h
28
+ * @return Wind level object or null if speed is null
38
29
  */
39
- export function getWindLevel(speed) {
30
+ export function getWindLevel(speed: number): WindLevel | null {
40
31
  if (typeof speed !== "number") return null;
41
32
 
42
33
  const theSpeed = Math.round(speed);
package/README.md DELETED
@@ -1,376 +0,0 @@
1
- # @forecast-utils
2
-
3
- Several utility libraries for my "tierracolora.com" project.
4
-
5
- Includes directory `images/ws` with weather images (symbols)
6
-
7
- I use private libraries for the following:
8
- - Astronomy calculations: `suncalc3`
9
-
10
- # Documentation
11
- ## Modules
12
-
13
- <dl>
14
- <dt><a href="#module_Astronomy/MoonCalc">Astronomy/MoonCalc</a></dt>
15
- <dd><p>MoonCalc for calculating moon times, positions, and phases.</p>
16
- <p> import { MoonCalc } from ...</p>
17
- <p>Importante!:
18
- ¡Solo proporcionar HORA LOCAL DEL SISTEMA!: &#39;new Date()&#39;</p>
19
- </dd>
20
- <dt><a href="#module_Astronomy/SunCalc">Astronomy/SunCalc</a></dt>
21
- <dd><p>SunCalc for calculating solar times, positions, and phases.</p>
22
- <p> import { SunCalc } from ...</p>
23
- <p>Importante:
24
- ¡Solo proporcionar HORA LOCAL DEL SISTEMA!: &#39;new Date()&#39;
25
- Con excepción de &#39;getSolarTime()&#39;: recibe la hora local correspondiente a la localización dada.</p>
26
- </dd>
27
- <dt><a href="#module_Utils/TimeDateStr">Utils/TimeDateStr</a></dt>
28
- <dd><p>Helpers for get date and time formeted strings</p>
29
- </dd>
30
- </dl>
31
-
32
- <a name="module_Astronomy/MoonCalc"></a>
33
-
34
- ## Astronomy/MoonCalc
35
- MoonCalc for calculating moon times, positions, and phases.
36
-
37
- import { MoonCalc } from ...
38
-
39
- Importante!:
40
- ¡Solo proporcionar HORA LOCAL DEL SISTEMA!: 'new Date()'
41
-
42
-
43
- * [Astronomy/MoonCalc](#module_Astronomy/MoonCalc)
44
- * [.phasesES](#module_Astronomy/MoonCalc.phasesES) : <code>Object.&lt;string, string&gt;</code>
45
- * [.data(latitude, longitude, [date], [language])](#module_Astronomy/MoonCalc.data) ⇒ <code>MoonData</code>
46
- * [.dataExt(latitude, longitude, [date], [language])](#module_Astronomy/MoonCalc.dataExt) ⇒ <code>MoonDataExt</code>
47
- * [.emoji(latitude, longitude, [date])](#module_Astronomy/MoonCalc.emoji) ⇒ <code>string</code>
48
- * [.times(latitude, longitude, timezoneId, date)](#module_Astronomy/MoonCalc.times) ⇒ <code>Object</code>
49
- * [.getUpOrDown(altitude, highest)](#module_Astronomy/MoonCalc.getUpOrDown) ⇒ <code>string</code>
50
- * [.MoonDataExt](#module_Astronomy/MoonCalc.MoonDataExt) : <code>object</code>
51
- * [.MoonData](#module_Astronomy/MoonCalc.MoonData) : <code>object</code>
52
-
53
-
54
- * * *
55
-
56
- <a name="module_Astronomy/MoonCalc.phasesES"></a>
57
-
58
- ### Astronomy/MoonCalc.phasesES : <code>Object.&lt;string, string&gt;</code>
59
- Mapa de fases lunares.
60
- { phaseId, phaseName }
61
-
62
- **Kind**: static constant of [<code>Astronomy/MoonCalc</code>](#module_Astronomy/MoonCalc)
63
-
64
- * * *
65
-
66
- <a name="module_Astronomy/MoonCalc.data"></a>
67
-
68
- ### Astronomy/MoonCalc.data(latitude, longitude, [date], [language]) ⇒ <code>MoonData</code>
69
- **Kind**: static method of [<code>Astronomy/MoonCalc</code>](#module_Astronomy/MoonCalc)
70
- **Returns**: <code>MoonData</code> - Moon info object
71
-
72
- | Param | Type | Default |
73
- | --- | --- | --- |
74
- | latitude | <code>number</code> | |
75
- | longitude | <code>number</code> | |
76
- | [date] | <code>Date</code> | <code>new Date()</code> |
77
- | [language] | <code>string</code> | <code>&quot;es-ES&quot;</code> |
78
-
79
-
80
- * * *
81
-
82
- <a name="module_Astronomy/MoonCalc.dataExt"></a>
83
-
84
- ### Astronomy/MoonCalc.dataExt(latitude, longitude, [date], [language]) ⇒ <code>MoonDataExt</code>
85
- Información de la luna para una fecha y hora dadas.
86
- La fecha y hora se devolverán en la zona horaria local.
87
-
88
- **Kind**: static method of [<code>Astronomy/MoonCalc</code>](#module_Astronomy/MoonCalc)
89
- **Returns**: <code>MoonDataExt</code> - Full information
90
-
91
- | Param | Type | Default |
92
- | --- | --- | --- |
93
- | latitude | <code>number</code> | |
94
- | longitude | <code>number</code> | |
95
- | [date] | <code>Date</code> | <code>new Date()</code> |
96
- | [language] | <code>string</code> | <code>&quot;es-ES&quot;</code> |
97
-
98
-
99
- * * *
100
-
101
- <a name="module_Astronomy/MoonCalc.emoji"></a>
102
-
103
- ### Astronomy/MoonCalc.emoji(latitude, longitude, [date]) ⇒ <code>string</code>
104
- **Kind**: static method of [<code>Astronomy/MoonCalc</code>](#module_Astronomy/MoonCalc)
105
- **Returns**: <code>string</code> - Emoji of the moon phase
106
-
107
- | Param | Type | Default |
108
- | --- | --- | --- |
109
- | latitude | <code>number</code> | |
110
- | longitude | <code>number</code> | |
111
- | [date] | <code>Date</code> | <code>new Date()</code> |
112
-
113
-
114
- * * *
115
-
116
- <a name="module_Astronomy/MoonCalc.times"></a>
117
-
118
- ### Astronomy/MoonCalc.times(latitude, longitude, timezoneId, date) ⇒ <code>Object</code>
119
- **Kind**: static method of [<code>Astronomy/MoonCalc</code>](#module_Astronomy/MoonCalc)
120
- **Returns**: <code>Object</code> - Moon times
121
-
122
- | Param | Type |
123
- | --- | --- |
124
- | latitude | <code>number</code> |
125
- | longitude | <code>number</code> |
126
- | timezoneId | <code>string</code> |
127
- | date | <code>Date</code> |
128
-
129
-
130
- * * *
131
-
132
- <a name="module_Astronomy/MoonCalc.getUpOrDown"></a>
133
-
134
- ### Astronomy/MoonCalc.getUpOrDown(altitude, highest) ⇒ <code>string</code>
135
- **Kind**: static method of [<code>Astronomy/MoonCalc</code>](#module_Astronomy/MoonCalc)
136
- **Returns**: <code>string</code> - - Up or down emoji
137
-
138
- | Param | Type |
139
- | --- | --- |
140
- | altitude | <code>number</code> |
141
- | highest | <code>Date</code> |
142
-
143
-
144
- * * *
145
-
146
- <a name="module_Astronomy/MoonCalc.MoonDataExt"></a>
147
-
148
- ### Astronomy/MoonCalc.MoonDataExt : <code>object</code>
149
- **Kind**: static typedef of [<code>Astronomy/MoonCalc</code>](#module_Astronomy/MoonCalc)
150
- **Properties**
151
-
152
- | Name | Type |
153
- | --- | --- |
154
- | date | <code>string</code> |
155
- | time | <code>string</code> |
156
- | illumination | <code>string</code> |
157
- | phase | <code>string</code> |
158
- | phaseId | <code>string</code> |
159
- | emoji | <code>string</code> |
160
- | parallacticAngle | <code>number</code> |
161
- | angle | <code>number</code> |
162
- | position | <code>AstroPosition</code> |
163
- | next | <code>object</code> |
164
-
165
-
166
- * * *
167
-
168
- <a name="module_Astronomy/MoonCalc.MoonData"></a>
169
-
170
- ### Astronomy/MoonCalc.MoonData : <code>object</code>
171
- **Kind**: static typedef of [<code>Astronomy/MoonCalc</code>](#module_Astronomy/MoonCalc)
172
- **Properties**
173
-
174
- | Name | Type | Description |
175
- | --- | --- | --- |
176
- | position | <code>AstroPosition</code> | |
177
- | next | <code>object</code> | |
178
- | next.newMoon | <code>string</code> | Date of the next new moon. |
179
- | next.fullMoon | <code>string</code> | Date of the next full moon. |
180
-
181
-
182
- * * *
183
-
184
- <a name="module_Astronomy/SunCalc"></a>
185
-
186
- ## Astronomy/SunCalc
187
- SunCalc for calculating solar times, positions, and phases.
188
-
189
- import { SunCalc } from ...
190
-
191
- Importante:
192
- ¡Solo proporcionar HORA LOCAL DEL SISTEMA!: 'new Date()'
193
- Con excepción de 'getSolarTime()': recibe la hora local correspondiente a la localización dada.
194
-
195
-
196
- * [Astronomy/SunCalc](#module_Astronomy/SunCalc)
197
- * [.all(date, latitude, longitude, timezoneId)](#module_Astronomy/SunCalc.all) ⇒ <code>Object</code>
198
- * [.times(date, latitude, longitude, timezoneId)](#module_Astronomy/SunCalc.times) ⇒ <code>Object</code>
199
- * [.getSolarTime(date, lng, offsetSign, offset)](#module_Astronomy/SunCalc.getSolarTime) ⇒ <code>string</code>
200
- * [.position(latitude, longitude)](#module_Astronomy/SunCalc.position) ⇒ <code>Object</code>
201
- * [.getIsNight(lat, lon, timezoneId, date, dateStr)](#module_Astronomy/SunCalc.getIsNight) ⇒ <code>boolean</code>
202
- * [.getPhase(altitude, noon)](#module_Astronomy/SunCalc.getPhase) ⇒ <code>string</code>
203
-
204
-
205
- * * *
206
-
207
- <a name="module_Astronomy/SunCalc.all"></a>
208
-
209
- ### Astronomy/SunCalc.all(date, latitude, longitude, timezoneId) ⇒ <code>Object</code>
210
- **Kind**: static method of [<code>Astronomy/SunCalc</code>](#module_Astronomy/SunCalc)
211
- **Returns**: <code>Object</code> - { sunTimes: object, sunPosition: object, sunPhase: string }
212
-
213
- | Param | Type |
214
- | --- | --- |
215
- | date | <code>Date</code> |
216
- | latitude | <code>number</code> |
217
- | longitude | <code>number</code> |
218
- | timezoneId | <code>string</code> |
219
-
220
-
221
- * * *
222
-
223
- <a name="module_Astronomy/SunCalc.times"></a>
224
-
225
- ### Astronomy/SunCalc.times(date, latitude, longitude, timezoneId) ⇒ <code>Object</code>
226
- **Kind**: static method of [<code>Astronomy/SunCalc</code>](#module_Astronomy/SunCalc)
227
- **Returns**: <code>Object</code> - { date: Date, sunrise: string, sunset: string, noon: string, dawn: string, dusk: string }
228
-
229
- | Param | Type |
230
- | --- | --- |
231
- | date | <code>Date</code> |
232
- | latitude | <code>number</code> |
233
- | longitude | <code>number</code> |
234
- | timezoneId | <code>string</code> |
235
-
236
-
237
- * * *
238
-
239
- <a name="module_Astronomy/SunCalc.getSolarTime"></a>
240
-
241
- ### Astronomy/SunCalc.getSolarTime(date, lng, offsetSign, offset) ⇒ <code>string</code>
242
- **Kind**: static method of [<code>Astronomy/SunCalc</code>](#module_Astronomy/SunCalc)
243
- **Returns**: <code>string</code> - Local time in "HH:mm" format
244
-
245
- | Param | Type | Description |
246
- | --- | --- | --- |
247
- | date | <code>Date</code> | |
248
- | lng | <code>number</code> | |
249
- | offsetSign | <code>string</code> | "+" or "-" |
250
- | offset | <code>number</code> | UTC offset in hours |
251
-
252
-
253
- * * *
254
-
255
- <a name="module_Astronomy/SunCalc.position"></a>
256
-
257
- ### Astronomy/SunCalc.position(latitude, longitude) ⇒ <code>Object</code>
258
- **Kind**: static method of [<code>Astronomy/SunCalc</code>](#module_Astronomy/SunCalc)
259
- **Returns**: <code>Object</code> - {date: string, azimuth: number, direction: string, direction_full: string, altitude: number, zenith: number, declination: number}
260
-
261
- | Param | Type |
262
- | --- | --- |
263
- | latitude | <code>number</code> |
264
- | longitude | <code>number</code> |
265
-
266
-
267
- * * *
268
-
269
- <a name="module_Astronomy/SunCalc.getIsNight"></a>
270
-
271
- ### Astronomy/SunCalc.getIsNight(lat, lon, timezoneId, date, dateStr) ⇒ <code>boolean</code>
272
- **Kind**: static method of [<code>Astronomy/SunCalc</code>](#module_Astronomy/SunCalc)
273
- **Returns**: <code>boolean</code> - true if it's night, false otherwise
274
-
275
- | Param | Type |
276
- | --- | --- |
277
- | lat | <code>number</code> |
278
- | lon | <code>number</code> |
279
- | timezoneId | <code>string</code> |
280
- | date | <code>number</code> \| <code>Date</code> |
281
- | dateStr | <code>string</code> |
282
-
283
-
284
- * * *
285
-
286
- <a name="module_Astronomy/SunCalc.getPhase"></a>
287
-
288
- ### Astronomy/SunCalc.getPhase(altitude, noon) ⇒ <code>string</code>
289
- **Kind**: static method of [<code>Astronomy/SunCalc</code>](#module_Astronomy/SunCalc)
290
- **Returns**: <code>string</code> - The phase of the sun based on its altitude
291
-
292
- | Param | Type |
293
- | --- | --- |
294
- | altitude | <code>number</code> |
295
- | noon | <code>string</code> |
296
-
297
-
298
- * * *
299
-
300
- <a name="module_Utils/TimeDateStr"></a>
301
-
302
- ## Utils/TimeDateStr
303
- Helpers for get date and time formeted strings
304
-
305
-
306
- * [Utils/TimeDateStr](#module_Utils/TimeDateStr)
307
- * [.dateFormat([date])](#module_Utils/TimeDateStr.dateFormat) ⇒ <code>string</code>
308
- * [.timeString([date], [sec])](#module_Utils/TimeDateStr.timeString) ⇒ <code>string</code>
309
- * [.nowString(sec)](#module_Utils/TimeDateStr.nowString) ⇒ <code>String</code>
310
- * [.getLocalTimeFromTz(timeZone, [date])](#module_Utils/TimeDateStr.getLocalTimeFromTz) ⇒ <code>string</code>
311
-
312
-
313
- * * *
314
-
315
- <a name="module_Utils/TimeDateStr.dateFormat"></a>
316
-
317
- ### Utils/TimeDateStr.dateFormat([date]) ⇒ <code>string</code>
318
- Returns a date as a formated string.
319
-
320
- **Kind**: static method of [<code>Utils/TimeDateStr</code>](#module_Utils/TimeDateStr)
321
- **Returns**: <code>string</code> - La fecha formateada.
322
-
323
- | Param | Type | Default | Description |
324
- | --- | --- | --- | --- |
325
- | [date] | <code>Date</code> | <code>new Date()</code> | La fecha a formatear. |
326
-
327
-
328
- * * *
329
-
330
- <a name="module_Utils/TimeDateStr.timeString"></a>
331
-
332
- ### Utils/TimeDateStr.timeString([date], [sec]) ⇒ <code>string</code>
333
- Returns a time as a formated string.
334
-
335
- **Kind**: static method of [<code>Utils/TimeDateStr</code>](#module_Utils/TimeDateStr)
336
- **Returns**: <code>string</code> - La fecha formateada.
337
-
338
- | Param | Type | Default |
339
- | --- | --- | --- |
340
- | [date] | <code>Date</code> | |
341
- | [sec] | <code>boolean</code> | <code>false</code> |
342
-
343
-
344
- * * *
345
-
346
- <a name="module_Utils/TimeDateStr.nowString"></a>
347
-
348
- ### Utils/TimeDateStr.nowString(sec) ⇒ <code>String</code>
349
- Returns a now time as a formated string.
350
-
351
- **Kind**: static method of [<code>Utils/TimeDateStr</code>](#module_Utils/TimeDateStr)
352
- **Returns**: <code>String</code> - now time as a formated string
353
-
354
- | Param | Type | Default |
355
- | --- | --- | --- |
356
- | sec | <code>boolean</code> | <code>false</code> |
357
-
358
-
359
- * * *
360
-
361
- <a name="module_Utils/TimeDateStr.getLocalTimeFromTz"></a>
362
-
363
- ### Utils/TimeDateStr.getLocalTimeFromTz(timeZone, [date]) ⇒ <code>string</code>
364
- Return the local time string from a given timezone.
365
-
366
- **Kind**: static method of [<code>Utils/TimeDateStr</code>](#module_Utils/TimeDateStr)
367
- **Returns**: <code>string</code> - - The formatted local time string.
368
-
369
- | Param | Type | Default | Description |
370
- | --- | --- | --- | --- |
371
- | timeZone | <code>string</code> | | The timezone string (e.g., 'America/New_York'). |
372
- | [date] | <code>Date</code> \| <code>number</code> | <code>new Date()</code> | The date object to format. Defaults to the current date. |
373
-
374
-
375
- * * *
376
-