@angelrove/forecast-utils 1.1.2 → 1.1.3

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 (43) hide show
  1. package/README.md +357 -716
  2. package/dist/types/OpenMeteo/current/useForecastCurrent.d.ts +1 -0
  3. package/dist/types/OpenMeteo/daily/useForecastDaily.d.ts +1 -0
  4. package/dist/types/OpenMeteo/hourly/useForecastHourly.d.ts +1 -0
  5. package/dist/types/OpenMeteo/index.d.ts +4 -0
  6. package/dist/types/OpenMeteo/weatherSymbol/weatherSymbol.d.ts +1 -0
  7. package/dist/types/astronomy/index.d.ts +4 -0
  8. package/dist/types/astronomy/moon/MoonCalc.d.ts +12 -0
  9. package/dist/types/astronomy/moon/parseBasicData.d.ts +2 -1
  10. package/dist/types/astronomy/sun/SunCalc.d.ts +6 -0
  11. package/dist/types/astronomy/timeZoneInfo.d.ts +2 -1
  12. package/dist/types/astronomy/timehelpers.d.ts +9 -3
  13. package/dist/types/astronomy/types.d.ts +0 -7
  14. package/dist/types/geolocation/getGeolocation.d.ts +2 -2
  15. package/dist/types/geolocation/index.d.ts +1 -0
  16. package/dist/types/utils/degreesToCompass.d.ts +11 -0
  17. package/dist/types/utils/index.d.ts +5 -0
  18. package/dist/types/utils/warning.d.ts +2 -0
  19. package/dist/types/utils/wind/WindArrow.d.ts +2 -1
  20. package/dist/types/utils/wind/windArrowTx.d.ts +2 -1
  21. package/dist/types/utils/wind/windLevel.d.ts +1 -0
  22. package/package.json +2 -2
  23. package/src/OpenMeteo/current/useForecastCurrent.js +2 -1
  24. package/src/OpenMeteo/daily/useForecastDaily.js +2 -1
  25. package/src/OpenMeteo/hourly/useForecastHourly.js +2 -1
  26. package/src/OpenMeteo/index.js +9 -0
  27. package/src/OpenMeteo/weatherSymbol/weatherSymbol.js +2 -1
  28. package/src/astronomy/index.js +13 -0
  29. package/src/astronomy/moon/MoonCalc.js +33 -14
  30. package/src/astronomy/moon/parseBasicData.js +2 -0
  31. package/src/astronomy/sun/SunCalc.js +17 -10
  32. package/src/astronomy/timeZoneInfo.js +5 -2
  33. package/src/astronomy/timehelpers.js +9 -4
  34. package/src/astronomy/types.js +2 -12
  35. package/src/geolocation/getGeolocation.js +7 -5
  36. package/src/geolocation/index.js +5 -0
  37. package/src/index.js +2 -3
  38. package/src/utils/degreesToCompass.js +25 -1
  39. package/src/utils/index.js +9 -0
  40. package/src/utils/warning.js +6 -7
  41. package/src/utils/wind/WindArrow.jsx +2 -1
  42. package/src/utils/wind/windArrowTx.js +2 -1
  43. package/src/utils/wind/windLevel.js +4 -1
@@ -5,6 +5,7 @@
5
5
  * @param {number} lon
6
6
  * @param {number} refreshIntervalMin
7
7
  * @returns {{ data: any, apiUrl: string, isLoading: boolean, isError: any }}
8
+ * @memberof module:OpenMeteo
8
9
  */
9
10
  export function useForecastCurrent(lat: number, lon: number, refreshIntervalMin?: number): {
10
11
  data: any;
@@ -6,6 +6,7 @@
6
6
  * @param {number} lon
7
7
  * @param {number} refreshIntervalMin
8
8
  * @returns {{ data: any, isLoading: boolean, isError: any }}
9
+ * @memberof module:OpenMeteo
9
10
  */
10
11
  export function useForecastDaily(lat: number, lon: number, refreshIntervalMin?: number): {
11
12
  data: any;
@@ -4,6 +4,7 @@
4
4
  * @param {{ latitude: number, longitude: number }} location
5
5
  * @param {number} dayNum - Number of days from today: -1 = 24 hours, 0 = today, 1 = tomorrow, ...
6
6
  * @returns {{ data: any, isLoading: boolean, isError: any }}
7
+ * @memberof module:OpenMeteo
7
8
  */
8
9
  export function useForecastHourly(location: {
9
10
  latitude: number;
@@ -0,0 +1,4 @@
1
+ export { useForecastCurrent } from "./current/useForecastCurrent.js";
2
+ export { useForecastDaily } from "./daily/useForecastDaily.js";
3
+ export { useForecastHourly } from "./hourly/useForecastHourly.js";
4
+ export { weatherSymbol } from "./weatherSymbol/weatherSymbol.js";
@@ -6,6 +6,7 @@
6
6
  * @param {boolean} night
7
7
  * @param {boolean} dark
8
8
  * @returns {{ icon: string, description: string }}
9
+ * @memberof module:OpenMeteo
9
10
  */
10
11
  export function weatherSymbol(code: any, precipitation?: number | undefined, night?: boolean, dark?: boolean): {
11
12
  icon: string;
@@ -0,0 +1,4 @@
1
+ export { default as MoonCalc } from "./moon/MoonCalc.js";
2
+ export { default as SunCalc } from "./sun/SunCalc.js";
3
+ export { getLocalTimeInfo as getLocalTime } from "./timeZoneInfo.js";
4
+ export { dateFormat, getLocalTimeFromTz, nowString, timeString } from "./timehelpers.js";
@@ -1,4 +1,11 @@
1
1
  export default MoonCalc;
2
+ export type MoonData = {
3
+ position: AstroPosition;
4
+ next: {
5
+ newMoon: string;
6
+ fullMoon: string;
7
+ };
8
+ };
2
9
  declare namespace MoonCalc {
3
10
  export { data };
4
11
  export { dataExt };
@@ -12,6 +19,7 @@ declare namespace MoonCalc {
12
19
  * @param {Date} [date=new Date()]
13
20
  * @param {string} [language=es-ES]
14
21
  * @returns {MoonData}
22
+ * @memberof module:Astronomy/MoonCalc
15
23
  */
16
24
  declare function data(latitude: number, longitude: number, date?: Date | undefined, language?: string | undefined): MoonData;
17
25
  /**
@@ -23,6 +31,7 @@ declare function data(latitude: number, longitude: number, date?: Date | undefin
23
31
  * @param {Date} [date=new Date()]
24
32
  * @param {string} [language=es-ES]
25
33
  * @returns {{ date: string, time: string, illumination: string, phase: string, phaseId: string, emoji: string, parallacticAngle: number, angle: number, position: AstroPosition, next: object }}
34
+ * @memberof module:Astronomy/MoonCalc
26
35
  */
27
36
  declare function dataExt(latitude: number, longitude: number, date?: Date | undefined, language?: string | undefined): {
28
37
  date: string;
@@ -42,6 +51,7 @@ declare function dataExt(latitude: number, longitude: number, date?: Date | unde
42
51
  * @param {string} timezoneId
43
52
  * @param {Date} date
44
53
  * @returns {{rise: string, set: string, highest: string}}
54
+ * @memberof module:Astronomy/MoonCalc
45
55
  */
46
56
  declare function times(latitude: number, longitude: number, timezoneId: string, date?: Date): {
47
57
  rise: string;
@@ -53,11 +63,13 @@ declare function times(latitude: number, longitude: number, timezoneId: string,
53
63
  * @param {number} longitude
54
64
  * @param {Date} [date=new Date()]
55
65
  * @returns {string} - Emoji of the moon phase
66
+ * @memberof module:Astronomy/MoonCalc
56
67
  */
57
68
  declare function emoji(latitude: number, longitude: number, date?: Date | undefined): string;
58
69
  /**
59
70
  * @param {number} altitude
60
71
  * @param {Date} highest
61
72
  * @returns {string} - Up or down emoji
73
+ * @memberof module:Astronomy/MoonCalc
62
74
  */
63
75
  declare function getUpOrDown(altitude: number, highest: Date): string;
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Parse basic data from SunCalc
3
3
  *
4
+ * @private
4
5
  * @param {any} data
5
6
  * @param {string} language
6
7
  * @returns {MoonData}
7
8
  */
8
- export function parseBasicData(data: any, language: string): MoonData;
9
+ export function parseBasicData(data: any, language: string): any;
@@ -13,6 +13,7 @@ declare namespace SunCalc {
13
13
  * @param {number} longitude
14
14
  * @param {string} timezoneId
15
15
  * @returns {{ sunTimes: object, sunPosition: object, sunPhase: string }}
16
+ * @memberof module:Astronomy/SunCalc
16
17
  */
17
18
  declare function all(date: Date, latitude: number, longitude: number, timezoneId: string): {
18
19
  sunTimes: object;
@@ -25,6 +26,7 @@ declare function all(date: Date, latitude: number, longitude: number, timezoneId
25
26
  * @param {number} longitude
26
27
  * @param {string} timezoneId
27
28
  * @returns {{ date: Date, sunrise: string, sunset: string, noon: string, dawn: string, dusk: string }}
29
+ * @memberof module:Astronomy/SunCalc
28
30
  */
29
31
  declare function times(date: Date, latitude: number, longitude: number, timezoneId: string): {
30
32
  date: Date;
@@ -40,12 +42,14 @@ declare function times(date: Date, latitude: number, longitude: number, timezone
40
42
  * @param {string} offsetSign - "+" or "-"
41
43
  * @param {number} offset - UTC offset in hours
42
44
  * @returns {string} - Local time in "HH:mm" format
45
+ * @memberof module:Astronomy/SunCalc
43
46
  */
44
47
  declare function getSolarTime(date: Date, lng: number, offsetSign: string, offset: number): string;
45
48
  /**
46
49
  * @param {number} latitude
47
50
  * @param {number} longitude
48
51
  * @returns {{date: string, azimuth: number, direction: string, direction_full: string, altitude: number, zenith: number, declination: number}}
52
+ * @memberof module:Astronomy/SunCalc
49
53
  */
50
54
  declare function position(latitude: number, longitude: number, date?: Date, language?: string): {
51
55
  date: string;
@@ -63,11 +67,13 @@ declare function position(latitude: number, longitude: number, date?: Date, lang
63
67
  * @param {number | Date} date
64
68
  * @param {string} dateStr
65
69
  * @returns {boolean} - true if it's night, false otherwise
70
+ * @memberof module:Astronomy/SunCalc
66
71
  */
67
72
  declare function getIsNight(lat: number, lon: number, timezoneId: string, date: number | Date, dateStr: string): boolean;
68
73
  /**
69
74
  * @param {number} altitude
70
75
  * @param {string} noon
71
76
  * @returns {string} - The phase of the sun based on its altitude
77
+ * @memberof module:Astronomy/SunCalc
72
78
  */
73
79
  declare function getPhase(altitude: number, noon: string): string;
@@ -1,10 +1,11 @@
1
1
  /**
2
- * Google API: Get local time from any location
2
+ * Get local time from any location using Google Maps TimeZone API.
3
3
  *
4
4
  * @param {string} apiKey - GoogleMaps API key.
5
5
  * @param {number} lat
6
6
  * @param {number} lng
7
7
  * @returns {Promise<any | LocalTimeData>} - An object containing the local time and timezone information:
8
8
  * @throws {Error} - If the API request fails or returns an error status.
9
+ * @memberof module:Astronomy
9
10
  */
10
11
  export function getLocalTimeInfo(apiKey: string, lat: number, lng: number): Promise<any | LocalTimeData>;
@@ -1,20 +1,25 @@
1
- /**
2
- * @module astronomy/time-date
3
- */
4
1
  /**
5
2
  * Formatea una fecha a un string legible.
6
3
  *
7
4
  * @param {Date} [date]
8
5
  * @param {boolean} [sec=false]
9
6
  * @returns {string} La fecha formateada.
7
+ * @memberof module:Astronomy
10
8
  */
11
9
  export function timeString(date?: Date | undefined, sec?: boolean | undefined): string;
10
+ /**
11
+ *
12
+ * @param {boolean} sec
13
+ * @returns {String}
14
+ * @memberof module:Astronomy
15
+ */
12
16
  export function nowString(sec?: boolean): string;
13
17
  /**
14
18
  * Formatea una fecha a un string legible.
15
19
  *
16
20
  * @param {Date} [date=new Date()] La fecha a formatear.
17
21
  * @returns {string} La fecha formateada.
22
+ * @memberof module:Astronomy
18
23
  */
19
24
  export function dateFormat(date?: Date | undefined): string;
20
25
  /**
@@ -23,5 +28,6 @@ export function dateFormat(date?: Date | undefined): string;
23
28
  * @param {string} timeZone - The timezone string (e.g., 'America/New_York').
24
29
  * @param {Date | number} [date=new Date()] - The date object to format. Defaults to the current date.
25
30
  * @returns {string} - The formatted local time string.
31
+ * @memberof module:Astronomy
26
32
  */
27
33
  export function getLocalTimeFromTz(timeZone: string, date?: number | Date | undefined): string;
@@ -4,13 +4,6 @@ type AstroPosition = {
4
4
  direction: string;
5
5
  direction_full: string;
6
6
  };
7
- type MoonData = {
8
- position: AstroPosition;
9
- next: {
10
- newMoon: string;
11
- fullMoon: string;
12
- };
13
- };
14
7
  type LocalTimeData = {
15
8
  /**
16
9
  * - The local time.
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Get the current geolocation of the device and reverse
3
- * geocode it to get the address.
2
+ * Get the current geolocation of the device and reverse geocode it to get the address.
4
3
  *
5
4
  * @returns {Promise<{latitude: number, longitude: number, formatted_address: string}>}
6
5
  * @throws {Error} If geolocation is not supported or permission is denied.
6
+ * @memberof module:Geolocation
7
7
  */
8
8
  export function getGeolocation(): Promise<{
9
9
  latitude: number;
@@ -0,0 +1 @@
1
+ export { getGeolocation } from "./getGeolocation.js";
@@ -4,8 +4,19 @@
4
4
  * @param {number} degrees
5
5
  * @param {string} language - Language code ("en-US", "es-ES", "auto")
6
6
  * @returns {{short: string, full: string}}
7
+ * @memberof module:Utils
7
8
  */
8
9
  export function degreesToCompass(degrees: number, language?: string): {
9
10
  short: string;
10
11
  full: string;
11
12
  };
13
+ export type Compass = {
14
+ /**
15
+ * - Short compass designation
16
+ */
17
+ short: string;
18
+ /**
19
+ * - Full compass designation
20
+ */
21
+ full: string;
22
+ };
@@ -0,0 +1,5 @@
1
+ export { degreesToCompass } from "./degreesToCompass.js";
2
+ export { WindArrow } from "./wind/WindArrow.jsx";
3
+ export { windArrowTx } from "./wind/windArrowTx.js";
4
+ export { getWindLevel } from "./wind/windLevel.js";
5
+ export { getWarning, getWarningByDays } from "./warning.js";
@@ -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
+ * @memberof module:Utils
9
10
  */
10
11
  export function getWarningByDays(precipitationSumToday: number, precipitationSumTomorrow: number, showersSumToday: number, showersSumTomorrow: number): {
11
12
  levelNum: number;
@@ -20,6 +21,7 @@ export function getWarningByDays(precipitationSumToday: number, precipitationSum
20
21
  * @param {number} precipitation
21
22
  * @param {number} showers
22
23
  * @returns {{ levelNum: number, level: string, message: string } | null}
24
+ * @memberof module:Utils
23
25
  */
24
26
  export function getWarning(precipitation: number, showers: number): {
25
27
  levelNum: number;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @module utils:WindArrow
2
+ * Wind direction arrow component (svg image).
3
3
  */
4
4
  /**
5
5
  * @typedef {Object} WindArrowProps
@@ -13,6 +13,7 @@
13
13
  *
14
14
  * @component
15
15
  * @param {WindArrowProps} props
16
+ * @memberof module:Utils
16
17
  */
17
18
  export function WindArrow({ deg, size, strokeWidth, className, }: WindArrowProps): any;
18
19
  export type WindArrowProps = {
@@ -1,9 +1,10 @@
1
1
  /**
2
- * @module utils
2
+ * Convert wind direction in degrees to an arrow representation.
3
3
  */
4
4
  /**
5
5
  * Convert wind direction in degrees to an arrow representation.
6
6
  *
7
7
  * @param {number} deg - Wind direction in degrees.
8
+ * @memberof module:Utils
8
9
  */
9
10
  export function windArrowTx(deg: number): "deg?" | "↓" | "↙" | "←" | "↖" | "↑" | "↗" | "→" | "↘" | undefined;
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * @param {number} speed Wind speed in km/h
5
5
  * @return {WindLevel | null} Wind level object or null if speed is null
6
+ * @memberof module:Utils
6
7
  */
7
8
  export function getWindLevel(speed: number): WindLevel | null;
8
9
  export type WindLevel = {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@angelrove/forecast-utils",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "author": "Jose Angel Romero Vegas",
5
5
  "license": "MIT",
6
6
  "description": "Utilities for obtaining weather and astronomy forecast data.",
7
7
  "homepage": "https://github.com/angelrove/forecast-utils",
8
8
  "type": "module",
9
9
  "scripts": {
10
- "docs:md": "bunx jsdoc2md $(cat doc-files.txt) > README.md"
10
+ "docs:md": "bunx jsdoc2md --separators $(cat jsdoc-files.txt) > README.md"
11
11
  },
12
12
  "types": "dist/types/index.d.ts",
13
13
  "exports": {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @module OpenMeteo:current
2
+ * Custom hook to fetch current weather data from OpenMeteo API.
3
3
  */
4
4
 
5
5
  import useSWR from "swr";
@@ -14,6 +14,7 @@ import transformer from "./transformer.js";
14
14
  * @param {number} lon
15
15
  * @param {number} refreshIntervalMin
16
16
  * @returns {{ data: any, apiUrl: string, isLoading: boolean, isError: any }}
17
+ * @memberof module:OpenMeteo
17
18
  */
18
19
  export function useForecastCurrent(lat, lon, refreshIntervalMin = 0) {
19
20
  if (!lat || !lon) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @module OpenMeteo:daily
2
+ * Custom hook to fetch daily forecast (10 days) data from OpenMeteo API.
3
3
  */
4
4
 
5
5
  import useSWR from "swr";
@@ -15,6 +15,7 @@ import transformer from "./transformer.js";
15
15
  * @param {number} lon
16
16
  * @param {number} refreshIntervalMin
17
17
  * @returns {{ data: any, isLoading: boolean, isError: any }}
18
+ * @memberof module:OpenMeteo
18
19
  */
19
20
  export function useForecastDaily(lat, lon, refreshIntervalMin = 0) {
20
21
  // Validate --
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @module OpenMeteo:hourly
2
+ * Custom hook to fetch hourly forecast data for a given location and number of days from OpenMeteo API.
3
3
  */
4
4
 
5
5
  import useSWR from "swr";
@@ -13,6 +13,7 @@ import { fetchParams } from "./fetchParams.js";
13
13
  * @param {{ latitude: number, longitude: number }} location
14
14
  * @param {number} dayNum - Number of days from today: -1 = 24 hours, 0 = today, 1 = tomorrow, ...
15
15
  * @returns {{ data: any, isLoading: boolean, isError: any }}
16
+ * @memberof module:OpenMeteo
16
17
  */
17
18
  export function useForecastHourly(location, dayNum) {
18
19
  if (!location.latitude || !location.longitude) {
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @module OpenMeteo
3
+ *
4
+ */
5
+
6
+ export { useForecastCurrent } from "./current/useForecastCurrent.js";
7
+ export { useForecastDaily } from "./daily/useForecastDaily.js";
8
+ export { useForecastHourly } from "./hourly/useForecastHourly.js";
9
+ export { weatherSymbol } from "./weatherSymbol/weatherSymbol.js";
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @module OpenMeteo:weatherSymbol
2
+ * Get weather symbol and description based on the weather code.
3
3
  */
4
4
 
5
5
  import { getWeatherCodeEntry } from "./lib/getWeatherCodeEntry.js";
@@ -12,6 +12,7 @@ import { getWeatherCodeEntry } from "./lib/getWeatherCodeEntry.js";
12
12
  * @param {boolean} night
13
13
  * @param {boolean} dark
14
14
  * @returns {{ icon: string, description: string }}
15
+ * @memberof module:OpenMeteo
15
16
  */
16
17
  export function weatherSymbol(
17
18
  code,
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @module Astronomy
3
+ */
4
+
5
+ export { default as MoonCalc } from "./moon/MoonCalc.js";
6
+ export { default as SunCalc } from "./sun/SunCalc.js";
7
+ export {
8
+ dateFormat,
9
+ getLocalTimeFromTz,
10
+ nowString,
11
+ timeString,
12
+ } from "./timehelpers.js";
13
+ export { getLocalTimeInfo as getLocalTime } from "./timeZoneInfo.js";
@@ -1,9 +1,13 @@
1
1
  // @ts-nocheck
2
2
  /**
3
- * @module MoonCalc
4
- * @description
5
3
  * MoonCalc for calculating moon times, positions, and phases.
6
- * - import { MoonCalc } from '@angelrov/forecast';
4
+ *
5
+ * import { MoonCalc } from ...
6
+ *
7
+ * Importante!:
8
+ * ¡Solo proporcionar HORA LOCAL DEL SISTEMA!: 'new Date()'
9
+ *
10
+ * @module Astronomy/MoonCalc
7
11
  */
8
12
 
9
13
  // @ts-ignore
@@ -12,14 +16,33 @@ import { dateFormat, getLocalTimeFromTz, timeString } from "../timehelpers.js";
12
16
  import { parseBasicData } from "./parseBasicData.js";
13
17
 
14
18
  /**
15
- * IMPORTANTE!!:
16
- * ¡Solo proporcionar HORA LOCAL DEL SISTEMA!: 'new Date()'
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.
17
25
  */
18
26
 
27
+ /**
28
+ * Export
29
+ * @ignore
30
+ */
31
+ const MoonCalc = {
32
+ data,
33
+ dataExt,
34
+ times,
35
+ emoji,
36
+ getUpOrDown,
37
+ };
38
+ export default MoonCalc;
39
+
19
40
  /**
20
41
  * Mapa de fases lunares.
42
+ * { phaseId, phaseName }
21
43
  *
22
44
  * @type {Object.<string, string>}
45
+ * @memberof module:Astronomy/MoonCalc
23
46
  */
24
47
  const phasesES = {
25
48
  newMoon: "Luna Nueva",
@@ -32,15 +55,6 @@ const phasesES = {
32
55
  waningCrescentMoon: "Luna Menguante",
33
56
  };
34
57
 
35
- const MoonCalc = {
36
- data,
37
- dataExt,
38
- times,
39
- emoji,
40
- getUpOrDown,
41
- };
42
- export default MoonCalc;
43
-
44
58
  //--------------------------------------------------------------------
45
59
  /**
46
60
  * @param {number} latitude
@@ -48,6 +62,7 @@ export default MoonCalc;
48
62
  * @param {Date} [date=new Date()]
49
63
  * @param {string} [language=es-ES]
50
64
  * @returns {MoonData}
65
+ * @memberof module:Astronomy/MoonCalc
51
66
  */
52
67
  function data(latitude, longitude, date = new Date(), language = "es-ES") {
53
68
  // date.setHours(date.getHours() + 0); // debug
@@ -66,6 +81,7 @@ function data(latitude, longitude, date = new Date(), language = "es-ES") {
66
81
  * @param {Date} [date=new Date()]
67
82
  * @param {string} [language=es-ES]
68
83
  * @returns {{ date: string, time: string, illumination: string, phase: string, phaseId: string, emoji: string, parallacticAngle: number, angle: number, position: AstroPosition, next: object }}
84
+ * @memberof module:Astronomy/MoonCalc
69
85
  */
70
86
  function dataExt(latitude, longitude, date = new Date(), language = "es-ES") {
71
87
  const data = SunCalc.getMoonData(date, latitude, longitude);
@@ -107,6 +123,7 @@ function dataExt(latitude, longitude, date = new Date(), language = "es-ES") {
107
123
  * @param {number} longitude
108
124
  * @param {Date} [date=new Date()]
109
125
  * @returns {string} - Emoji of the moon phase
126
+ * @memberof module:Astronomy/MoonCalc
110
127
  */
111
128
  function emoji(latitude, longitude, date = new Date()) {
112
129
  const data = SunCalc.getMoonData(date, latitude, longitude);
@@ -119,6 +136,7 @@ function emoji(latitude, longitude, date = new Date()) {
119
136
  * @param {string} timezoneId
120
137
  * @param {Date} date
121
138
  * @returns {{rise: string, set: string, highest: string}}
139
+ * @memberof module:Astronomy/MoonCalc
122
140
  */
123
141
  function times(latitude, longitude, timezoneId, date = new Date()) {
124
142
  const ret = {
@@ -152,6 +170,7 @@ function times(latitude, longitude, timezoneId, date = new Date()) {
152
170
  * @param {number} altitude
153
171
  * @param {Date} highest
154
172
  * @returns {string} - Up or down emoji
173
+ * @memberof module:Astronomy/MoonCalc
155
174
  */
156
175
  function getUpOrDown(altitude, highest) {
157
176
  const now = new Date();
@@ -1,9 +1,11 @@
1
+ // @ts-nocheck
1
2
  import { degreesToCompass } from "../../utils/degreesToCompass.js";
2
3
  import { dateFormat } from "../timehelpers.js";
3
4
 
4
5
  /**
5
6
  * Parse basic data from SunCalc
6
7
  *
8
+ * @private
7
9
  * @param {any} data
8
10
  * @param {string} language
9
11
  * @returns {MoonData}
@@ -1,8 +1,13 @@
1
1
  /**
2
- * @module SunCalc
3
- * @description
4
- * SunCalc for calculating solar times, positions, and phases.
5
- * - import { SunCalc } from '@angelrov/forecast';
2
+ * SunCalc for calculating solar times, positions, and phases.
3
+ *
4
+ * import { SunCalc } from ...
5
+ *
6
+ * Importante:
7
+ * ¡Solo proporcionar HORA LOCAL DEL SISTEMA!: 'new Date()'
8
+ * Con excepción de 'getSolarTime()': recibe la hora local correspondiente a la localización dada.
9
+ *
10
+ * @module Astronomy/SunCalc
6
11
  */
7
12
 
8
13
  // @ts-ignore
@@ -16,12 +21,9 @@ import {
16
21
  } from "../timehelpers.js";
17
22
 
18
23
  /**
19
- * IMPORTANTE!!:
20
- * ¡Solo proporcionar HORA LOCAL DEL SISTEMA!: 'new Date()'
21
- * La única excepción es 'getSolarTime()': hay que darle la hora local correspondiente a la localización dada.
24
+ * Export
25
+ * @ignore
22
26
  */
23
-
24
- // Export ----
25
27
  const SunCalc = {
26
28
  all,
27
29
  times,
@@ -30,7 +32,6 @@ const SunCalc = {
30
32
  getIsNight,
31
33
  getPhase,
32
34
  };
33
-
34
35
  export default SunCalc;
35
36
 
36
37
  //-------------------------------------------------------
@@ -40,6 +41,7 @@ export default SunCalc;
40
41
  * @param {number} longitude
41
42
  * @param {string} timezoneId
42
43
  * @returns {{ sunTimes: object, sunPosition: object, sunPhase: string }}
44
+ * @memberof module:Astronomy/SunCalc
43
45
  */
44
46
  function all(date, latitude, longitude, timezoneId) {
45
47
  const sunTimes = SunCalc.times(date, latitude, longitude, timezoneId);
@@ -60,6 +62,7 @@ function all(date, latitude, longitude, timezoneId) {
60
62
  * @param {number} longitude
61
63
  * @param {string} timezoneId
62
64
  * @returns {{ date: Date, sunrise: string, sunset: string, noon: string, dawn: string, dusk: string }}
65
+ * @memberof module:Astronomy/SunCalc
63
66
  */
64
67
  function times(date, latitude, longitude, timezoneId) {
65
68
  const times = SunCalc3.getSunTimes(date, latitude, longitude);
@@ -83,6 +86,7 @@ function times(date, latitude, longitude, timezoneId) {
83
86
  * @param {string} offsetSign - "+" or "-"
84
87
  * @param {number} offset - UTC offset in hours
85
88
  * @returns {string} - Local time in "HH:mm" format
89
+ * @memberof module:Astronomy/SunCalc
86
90
  */
87
91
  function getSolarTime(date, lng, offsetSign, offset) {
88
92
  // Convert offsetSign and offset to a numeric UTC offset (e.g., -3, +2)
@@ -95,6 +99,7 @@ function getSolarTime(date, lng, offsetSign, offset) {
95
99
  * @param {number} latitude
96
100
  * @param {number} longitude
97
101
  * @returns {{date: string, azimuth: number, direction: string, direction_full: string, altitude: number, zenith: number, declination: number}}
102
+ * @memberof module:Astronomy/SunCalc
98
103
  */
99
104
  function position(latitude, longitude, date = new Date(), language = "es-ES") {
100
105
  const position = SunCalc3.getPosition(date, latitude, longitude);
@@ -122,6 +127,7 @@ function position(latitude, longitude, date = new Date(), language = "es-ES") {
122
127
  * @param {number | Date} date
123
128
  * @param {string} dateStr
124
129
  * @returns {boolean} - true if it's night, false otherwise
130
+ * @memberof module:Astronomy/SunCalc
125
131
  */
126
132
  function getIsNight(lat, lon, timezoneId, date, dateStr) {
127
133
  const times = SunCalc3.getSunTimes(date, lat, lon);
@@ -141,6 +147,7 @@ function getIsNight(lat, lon, timezoneId, date, dateStr) {
141
147
  * @param {number} altitude
142
148
  * @param {string} noon
143
149
  * @returns {string} - The phase of the sun based on its altitude
150
+ * @memberof module:Astronomy/SunCalc
144
151
  */
145
152
  function getPhase(altitude, noon) {
146
153
  const nowTime = nowString();
@@ -1,19 +1,22 @@
1
1
  // @ts-nocheck
2
2
  /**
3
- * @module astronomy/time-date
3
+ * Get local time from any location using Google Maps TimeZone API.
4
+ * - import { getLocalTimeInfo } from '@angelrov/forecast';
5
+ *
4
6
  */
5
7
 
6
8
  import { timeString } from "./timehelpers.js";
7
9
 
8
10
  //------------------------------------------------------
9
11
  /**
10
- * Google API: Get local time from any location
12
+ * Get local time from any location using Google Maps TimeZone API.
11
13
  *
12
14
  * @param {string} apiKey - GoogleMaps API key.
13
15
  * @param {number} lat
14
16
  * @param {number} lng
15
17
  * @returns {Promise<any | LocalTimeData>} - An object containing the local time and timezone information:
16
18
  * @throws {Error} - If the API request fails or returns an error status.
19
+ * @memberof module:Astronomy
17
20
  */
18
21
  export async function getLocalTimeInfo(apiKey, lat, lng) {
19
22
  const timestamp = Math.floor(Date.now() / 1000);