@angelrove/forecast-utils 1.1.1
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 +1046 -0
- package/dist/types/OpenMeteo/conf.d.ts +13 -0
- package/dist/types/OpenMeteo/current/fetchParams.d.ts +1 -0
- package/dist/types/OpenMeteo/current/transformer.d.ts +13 -0
- package/dist/types/OpenMeteo/current/useForecastCurrent.d.ts +14 -0
- package/dist/types/OpenMeteo/daily/fetchParams.d.ts +1 -0
- package/dist/types/OpenMeteo/daily/transformer.d.ts +9 -0
- package/dist/types/OpenMeteo/daily/useForecastDaily.d.ts +14 -0
- package/dist/types/OpenMeteo/helpers.d.ts +10 -0
- package/dist/types/OpenMeteo/hourly/fetchParams.d.ts +1 -0
- package/dist/types/OpenMeteo/hourly/useForecastHourly.d.ts +15 -0
- package/dist/types/OpenMeteo/weatherSymbol/lib/WeatherCodesEn.d.ts +43 -0
- package/dist/types/OpenMeteo/weatherSymbol/lib/WeatherCodesEs.d.ts +43 -0
- package/dist/types/OpenMeteo/weatherSymbol/lib/getWeatherCodeEntry.d.ts +7 -0
- package/dist/types/OpenMeteo/weatherSymbol/weatherSymbol.d.ts +13 -0
- package/dist/types/astronomy/moon/MoonCalc.d.ts +63 -0
- package/dist/types/astronomy/moon/parseBasicData.d.ts +8 -0
- package/dist/types/astronomy/sun/SunCalc.d.ts +73 -0
- package/dist/types/astronomy/sun/helpers.d.ts +0 -0
- package/dist/types/astronomy/timeZoneInfo.d.ts +10 -0
- package/dist/types/astronomy/timehelpers.d.ts +27 -0
- package/dist/types/astronomy/types.d.ts +43 -0
- package/dist/types/geolocation/getGeolocation.d.ts +12 -0
- package/dist/types/geolocation/lib/geolocation.d.ts +10 -0
- package/dist/types/geolocation/lib/geolocationCapacitor.d.ts +10 -0
- package/dist/types/geolocation/lib/reversegeocoding.d.ts +19 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/utils/degreesToCompass.d.ts +11 -0
- package/dist/types/utils/warning.d.ts +46 -0
- package/dist/types/utils/wind/WindArrow.d.ts +32 -0
- package/dist/types/utils/wind/windArrowTx.d.ts +9 -0
- package/dist/types/utils/wind/windLevel.d.ts +29 -0
- package/package.json +40 -0
- package/src/OpenMeteo/conf.js +47 -0
- package/src/OpenMeteo/current/fetchParams.js +21 -0
- package/src/OpenMeteo/current/transformer.js +37 -0
- package/src/OpenMeteo/current/useForecastCurrent.js +34 -0
- package/src/OpenMeteo/daily/fetchParams.js +9 -0
- package/src/OpenMeteo/daily/transformer.js +21 -0
- package/src/OpenMeteo/daily/useForecastDaily.js +38 -0
- package/src/OpenMeteo/helpers.js +19 -0
- package/src/OpenMeteo/hourly/fetchParams.js +12 -0
- package/src/OpenMeteo/hourly/useForecastHourly.js +42 -0
- package/src/OpenMeteo/weatherSymbol/lib/WeatherCodesEn.js +89 -0
- package/src/OpenMeteo/weatherSymbol/lib/WeatherCodesEs.js +81 -0
- package/src/OpenMeteo/weatherSymbol/lib/getWeatherCodeEntry.js +12 -0
- package/src/OpenMeteo/weatherSymbol/weatherSymbol.js +60 -0
- package/src/astronomy/moon/MoonCalc.js +171 -0
- package/src/astronomy/moon/parseBasicData.js +38 -0
- package/src/astronomy/sun/SunCalc.js +167 -0
- package/src/astronomy/sun/helpers.js +0 -0
- package/src/astronomy/timeZoneInfo.js +89 -0
- package/src/astronomy/timehelpers.js +69 -0
- package/src/astronomy/types.js +30 -0
- package/src/geolocation/getGeolocation.js +49 -0
- package/src/geolocation/lib/geolocation.js +44 -0
- package/src/geolocation/lib/geolocationCapacitor.js +21 -0
- package/src/geolocation/lib/reversegeocoding.js +109 -0
- package/src/index.js +38 -0
- package/src/utils/degreesToCompass.js +51 -0
- package/src/utils/warning.js +130 -0
- package/src/utils/wind/WindArrow.jsx +53 -0
- package/src/utils/wind/windArrowTx.js +24 -0
- package/src/utils/wind/windLevel.js +49 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {string} url
|
|
3
|
+
*/
|
|
4
|
+
export function fetcher(url: string): Promise<any>;
|
|
5
|
+
/**
|
|
6
|
+
* Get path for OpenMeteo API
|
|
7
|
+
*
|
|
8
|
+
* @param {number} lat
|
|
9
|
+
* @param {number} lon
|
|
10
|
+
* @param {string} path
|
|
11
|
+
* @returns {string}
|
|
12
|
+
*/
|
|
13
|
+
export function getPath(lat: number, lon: number, path: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const fetchParams: string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transforms the OpenMeteo API data into a more usable format.
|
|
3
|
+
*
|
|
4
|
+
* @param {{current: any, daily: any, hourly: any, latitude: number, longitude: number}} data - The data object to transform.
|
|
5
|
+
* @returns {Object|null} - The transformed data object or null if the input is invalid.
|
|
6
|
+
*/
|
|
7
|
+
export default function transformer(data: {
|
|
8
|
+
current: any;
|
|
9
|
+
daily: any;
|
|
10
|
+
hourly: any;
|
|
11
|
+
latitude: number;
|
|
12
|
+
longitude: number;
|
|
13
|
+
}): Object | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 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 {{ data: any, apiUrl: string, isLoading: boolean, isError: any }}
|
|
8
|
+
*/
|
|
9
|
+
export function useForecastCurrent(lat: number, lon: number, refreshIntervalMin?: number): {
|
|
10
|
+
data: any;
|
|
11
|
+
apiUrl: string;
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
isError: any;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const fetchParams: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transforms the OpenMeteo API data into a more usable format.
|
|
3
|
+
*
|
|
4
|
+
* @param {{daily: any}} data - The data object to transform.
|
|
5
|
+
* @returns {Object|null} - The transformed data object or null if the input is invalid.
|
|
6
|
+
*/
|
|
7
|
+
export default function transformer(data: {
|
|
8
|
+
daily: any;
|
|
9
|
+
}): Object | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom hook to fetch daily forecast (10 days) data from OpenMeteo API.
|
|
3
|
+
* https://api.open-meteo.com/v1/forecast?timezone=auto&latitude=36.6644363&longitude=-4.5108962&forecast_days=10&daily=weathercode
|
|
4
|
+
*
|
|
5
|
+
* @param {number} lat
|
|
6
|
+
* @param {number} lon
|
|
7
|
+
* @param {number} refreshIntervalMin
|
|
8
|
+
* @returns {{ data: any, isLoading: boolean, isError: any }}
|
|
9
|
+
*/
|
|
10
|
+
export function useForecastDaily(lat: number, lon: number, refreshIntervalMin?: number): {
|
|
11
|
+
data: any;
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
isError: any;
|
|
14
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the start and end dates based on the number of days from today.
|
|
3
|
+
*
|
|
4
|
+
* @param {number} numDay
|
|
5
|
+
* @returns {{startDate: string, endDate: string}} - An object containing the start and end dates in YYYY-MM-DD format.
|
|
6
|
+
*/
|
|
7
|
+
export function getDatesFromNumDays(numDay: number): {
|
|
8
|
+
startDate: string;
|
|
9
|
+
endDate: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const fetchParams: string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 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 {{ data: any, isLoading: boolean, isError: any }}
|
|
7
|
+
*/
|
|
8
|
+
export function useForecastHourly(location: {
|
|
9
|
+
latitude: number;
|
|
10
|
+
longitude: number;
|
|
11
|
+
}, dayNum: number): {
|
|
12
|
+
data: any;
|
|
13
|
+
isLoading: boolean;
|
|
14
|
+
isError: any;
|
|
15
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WMO Weather interpretation codes (WW)
|
|
3
|
+
*
|
|
4
|
+
* @link https://open-meteo.com/en/docs?hourly=temperature_2m,weather_code&daily=weather_code#weather_variable_documentation
|
|
5
|
+
* @link https://www.meteomatics.com/en/api/available-parameters/derived-weather-and-convenience-parameters/general-weather-state/
|
|
6
|
+
*
|
|
7
|
+
* Code Description
|
|
8
|
+
* 0 Clear sky
|
|
9
|
+
* 1, 2, 3 Mainly clear, partly cloudy, and overcast
|
|
10
|
+
* 45, 48 Fog and depositing rime fog
|
|
11
|
+
* 51, 53, 55 Drizzle: Light, moderate, and dense intensity
|
|
12
|
+
* 56, 57 Freezing Drizzle: Light and dense intensity
|
|
13
|
+
* 61, 63, 65 Rain: Slight, moderate and heavy intensity
|
|
14
|
+
* 66, 67 Freezing Rain: Light and heavy intensity
|
|
15
|
+
* 71, 73, 75 Snow fall: Slight, moderate, and heavy intensity
|
|
16
|
+
* 77 Snow grains
|
|
17
|
+
* 80, 81, 82 Rain showers: Slight, moderate, and violent
|
|
18
|
+
* 85, 86 Snow showers slight and heavy
|
|
19
|
+
* 95 * Thunderstorm: Slight or moderate
|
|
20
|
+
* 96, 99 * Thunderstorm with slight and heavy hail
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {Object} WeatherCodeEntry
|
|
24
|
+
* @property {number} code - WMO Weather interpretation codes (WW).
|
|
25
|
+
* @property {string} icon - Icon name.
|
|
26
|
+
* @property {string} description - Description.
|
|
27
|
+
*/
|
|
28
|
+
/** @type {WeatherCodeEntry[]} */
|
|
29
|
+
export const weatherCodes: WeatherCodeEntry[];
|
|
30
|
+
export type WeatherCodeEntry = {
|
|
31
|
+
/**
|
|
32
|
+
* - WMO Weather interpretation codes (WW).
|
|
33
|
+
*/
|
|
34
|
+
code: number;
|
|
35
|
+
/**
|
|
36
|
+
* - Icon name.
|
|
37
|
+
*/
|
|
38
|
+
icon: string;
|
|
39
|
+
/**
|
|
40
|
+
* - Description.
|
|
41
|
+
*/
|
|
42
|
+
description: string;
|
|
43
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WMO Weather interpretation codes (WW)
|
|
3
|
+
*
|
|
4
|
+
* @link https://open-meteo.com/en/docs?hourly=temperature_2m,weather_code&daily=weather_code#weather_variable_documentation
|
|
5
|
+
* @link https://www.meteomatics.com/en/api/available-parameters/derived-weather-and-convenience-parameters/general-weather-state/
|
|
6
|
+
*
|
|
7
|
+
* Code Description
|
|
8
|
+
* 0 Clear sky
|
|
9
|
+
* 1, 2, 3 Mainly clear, partly cloudy, and overcast
|
|
10
|
+
* 45, 48 Fog and depositing rime fog
|
|
11
|
+
* 51, 53, 55 Drizzle: Light, moderate, and dense intensity
|
|
12
|
+
* 56, 57 Freezing Drizzle: Light and dense intensity
|
|
13
|
+
* 61, 63, 65 Rain: Slight, moderate and heavy intensity
|
|
14
|
+
* 66, 67 Freezing Rain: Light and heavy intensity
|
|
15
|
+
* 71, 73, 75 Snow fall: Slight, moderate, and heavy intensity
|
|
16
|
+
* 77 Snow grains
|
|
17
|
+
* 80, 81, 82 Rain showers: Slight, moderate, and violent
|
|
18
|
+
* 85, 86 Snow showers slight and heavy
|
|
19
|
+
* 95 * Thunderstorm: Slight or moderate
|
|
20
|
+
* 96, 99 * Thunderstorm with slight and heavy hail
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {Object} WeatherCodeEntry
|
|
24
|
+
* @property {number} code - WMO Weather interpretation codes (WW).
|
|
25
|
+
* @property {string} icon - Icon name.
|
|
26
|
+
* @property {string} description - Description.
|
|
27
|
+
*/
|
|
28
|
+
/** @type {WeatherCodeEntry[]} */
|
|
29
|
+
export const weatherCodes: WeatherCodeEntry[];
|
|
30
|
+
export type WeatherCodeEntry = {
|
|
31
|
+
/**
|
|
32
|
+
* - WMO Weather interpretation codes (WW).
|
|
33
|
+
*/
|
|
34
|
+
code: number;
|
|
35
|
+
/**
|
|
36
|
+
* - Icon name.
|
|
37
|
+
*/
|
|
38
|
+
icon: string;
|
|
39
|
+
/**
|
|
40
|
+
* - Description.
|
|
41
|
+
*/
|
|
42
|
+
description: string;
|
|
43
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 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
|
+
*/
|
|
10
|
+
export function weatherSymbol(code: any, precipitation?: number | undefined, night?: boolean, dark?: boolean): {
|
|
11
|
+
icon: string;
|
|
12
|
+
description: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export default MoonCalc;
|
|
2
|
+
declare namespace MoonCalc {
|
|
3
|
+
export { data };
|
|
4
|
+
export { dataExt };
|
|
5
|
+
export { times };
|
|
6
|
+
export { emoji };
|
|
7
|
+
export { getUpOrDown };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @param {number} latitude
|
|
11
|
+
* @param {number} longitude
|
|
12
|
+
* @param {Date} [date=new Date()]
|
|
13
|
+
* @param {string} [language=es-ES]
|
|
14
|
+
* @returns {MoonData}
|
|
15
|
+
*/
|
|
16
|
+
declare function data(latitude: number, longitude: number, date?: Date | undefined, language?: string | undefined): MoonData;
|
|
17
|
+
/**
|
|
18
|
+
* Información de la luna para una fecha y hora dadas.
|
|
19
|
+
* La fecha y hora se devolverán en la zona horaria local.
|
|
20
|
+
*
|
|
21
|
+
* @param {number} latitude
|
|
22
|
+
* @param {number} longitude
|
|
23
|
+
* @param {Date} [date=new Date()]
|
|
24
|
+
* @param {string} [language=es-ES]
|
|
25
|
+
* @returns {{ date: string, time: string, illumination: string, phase: string, phaseId: string, emoji: string, parallacticAngle: number, angle: number, position: AstroPosition, next: object }}
|
|
26
|
+
*/
|
|
27
|
+
declare function dataExt(latitude: number, longitude: number, date?: Date | undefined, language?: string | undefined): {
|
|
28
|
+
date: string;
|
|
29
|
+
time: string;
|
|
30
|
+
illumination: string;
|
|
31
|
+
phase: string;
|
|
32
|
+
phaseId: string;
|
|
33
|
+
emoji: string;
|
|
34
|
+
parallacticAngle: number;
|
|
35
|
+
angle: number;
|
|
36
|
+
position: AstroPosition;
|
|
37
|
+
next: object;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* @param {number} latitude
|
|
41
|
+
* @param {number} longitude
|
|
42
|
+
* @param {string} timezoneId
|
|
43
|
+
* @param {Date} date
|
|
44
|
+
* @returns {{rise: string, set: string, highest: string}}
|
|
45
|
+
*/
|
|
46
|
+
declare function times(latitude: number, longitude: number, timezoneId: string, date?: Date): {
|
|
47
|
+
rise: string;
|
|
48
|
+
set: string;
|
|
49
|
+
highest: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* @param {number} latitude
|
|
53
|
+
* @param {number} longitude
|
|
54
|
+
* @param {Date} [date=new Date()]
|
|
55
|
+
* @returns {string} - Emoji of the moon phase
|
|
56
|
+
*/
|
|
57
|
+
declare function emoji(latitude: number, longitude: number, date?: Date | undefined): string;
|
|
58
|
+
/**
|
|
59
|
+
* @param {number} altitude
|
|
60
|
+
* @param {Date} highest
|
|
61
|
+
* @returns {string} - Up or down emoji
|
|
62
|
+
*/
|
|
63
|
+
declare function getUpOrDown(altitude: number, highest: Date): string;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export default SunCalc;
|
|
2
|
+
declare namespace SunCalc {
|
|
3
|
+
export { all };
|
|
4
|
+
export { times };
|
|
5
|
+
export { getSolarTime };
|
|
6
|
+
export { position };
|
|
7
|
+
export { getIsNight };
|
|
8
|
+
export { getPhase };
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @param {Date} date
|
|
12
|
+
* @param {number} latitude
|
|
13
|
+
* @param {number} longitude
|
|
14
|
+
* @param {string} timezoneId
|
|
15
|
+
* @returns {{ sunTimes: object, sunPosition: object, sunPhase: string }}
|
|
16
|
+
*/
|
|
17
|
+
declare function all(date: Date, latitude: number, longitude: number, timezoneId: string): {
|
|
18
|
+
sunTimes: object;
|
|
19
|
+
sunPosition: object;
|
|
20
|
+
sunPhase: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* @param {Date} date
|
|
24
|
+
* @param {number} latitude
|
|
25
|
+
* @param {number} longitude
|
|
26
|
+
* @param {string} timezoneId
|
|
27
|
+
* @returns {{ date: Date, sunrise: string, sunset: string, noon: string, dawn: string, dusk: string }}
|
|
28
|
+
*/
|
|
29
|
+
declare function times(date: Date, latitude: number, longitude: number, timezoneId: string): {
|
|
30
|
+
date: Date;
|
|
31
|
+
sunrise: string;
|
|
32
|
+
sunset: string;
|
|
33
|
+
noon: string;
|
|
34
|
+
dawn: string;
|
|
35
|
+
dusk: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* @param {Date} date
|
|
39
|
+
* @param {number} lng
|
|
40
|
+
* @param {string} offsetSign - "+" or "-"
|
|
41
|
+
* @param {number} offset - UTC offset in hours
|
|
42
|
+
* @returns {string} - Local time in "HH:mm" format
|
|
43
|
+
*/
|
|
44
|
+
declare function getSolarTime(date: Date, lng: number, offsetSign: string, offset: number): string;
|
|
45
|
+
/**
|
|
46
|
+
* @param {number} latitude
|
|
47
|
+
* @param {number} longitude
|
|
48
|
+
* @returns {{date: string, azimuth: number, direction: string, direction_full: string, altitude: number, zenith: number, declination: number}}
|
|
49
|
+
*/
|
|
50
|
+
declare function position(latitude: number, longitude: number, date?: Date, language?: string): {
|
|
51
|
+
date: string;
|
|
52
|
+
azimuth: number;
|
|
53
|
+
direction: string;
|
|
54
|
+
direction_full: string;
|
|
55
|
+
altitude: number;
|
|
56
|
+
zenith: number;
|
|
57
|
+
declination: number;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* @param {number} lat
|
|
61
|
+
* @param {number} lon
|
|
62
|
+
* @param {string} timezoneId
|
|
63
|
+
* @param {number | Date} date
|
|
64
|
+
* @param {string} dateStr
|
|
65
|
+
* @returns {boolean} - true if it's night, false otherwise
|
|
66
|
+
*/
|
|
67
|
+
declare function getIsNight(lat: number, lon: number, timezoneId: string, date: number | Date, dateStr: string): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* @param {number} altitude
|
|
70
|
+
* @param {string} noon
|
|
71
|
+
* @returns {string} - The phase of the sun based on its altitude
|
|
72
|
+
*/
|
|
73
|
+
declare function getPhase(altitude: number, noon: string): string;
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google API: Get local time from any location
|
|
3
|
+
*
|
|
4
|
+
* @param {string} apiKey - GoogleMaps API key.
|
|
5
|
+
* @param {number} lat
|
|
6
|
+
* @param {number} lng
|
|
7
|
+
* @returns {Promise<any | LocalTimeData>} - An object containing the local time and timezone information:
|
|
8
|
+
* @throws {Error} - If the API request fails or returns an error status.
|
|
9
|
+
*/
|
|
10
|
+
export function getLocalTimeInfo(apiKey: string, lat: number, lng: number): Promise<any | LocalTimeData>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module astronomy/time-date
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Formatea una fecha a un string legible.
|
|
6
|
+
*
|
|
7
|
+
* @param {Date} [date]
|
|
8
|
+
* @param {boolean} [sec=false]
|
|
9
|
+
* @returns {string} La fecha formateada.
|
|
10
|
+
*/
|
|
11
|
+
export function timeString(date?: Date | undefined, sec?: boolean | undefined): string;
|
|
12
|
+
export function nowString(sec?: boolean): string;
|
|
13
|
+
/**
|
|
14
|
+
* Formatea una fecha a un string legible.
|
|
15
|
+
*
|
|
16
|
+
* @param {Date} [date=new Date()] La fecha a formatear.
|
|
17
|
+
* @returns {string} La fecha formateada.
|
|
18
|
+
*/
|
|
19
|
+
export function dateFormat(date?: Date | undefined): string;
|
|
20
|
+
/**
|
|
21
|
+
* Get local time from timezone
|
|
22
|
+
*
|
|
23
|
+
* @param {string} timeZone - The timezone string (e.g., 'America/New_York').
|
|
24
|
+
* @param {Date | number} [date=new Date()] - The date object to format. Defaults to the current date.
|
|
25
|
+
* @returns {string} - The formatted local time string.
|
|
26
|
+
*/
|
|
27
|
+
export function getLocalTimeFromTz(timeZone: string, date?: number | Date | undefined): string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
type AstroPosition = {
|
|
2
|
+
altitude: number;
|
|
3
|
+
azimuth: number;
|
|
4
|
+
direction: string;
|
|
5
|
+
direction_full: string;
|
|
6
|
+
};
|
|
7
|
+
type MoonData = {
|
|
8
|
+
position: AstroPosition;
|
|
9
|
+
next: {
|
|
10
|
+
newMoon: string;
|
|
11
|
+
fullMoon: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
type LocalTimeData = {
|
|
15
|
+
/**
|
|
16
|
+
* - The local time.
|
|
17
|
+
*/
|
|
18
|
+
time: Date;
|
|
19
|
+
/**
|
|
20
|
+
* - The formatted local time string.
|
|
21
|
+
*/
|
|
22
|
+
timeStr: string;
|
|
23
|
+
/**
|
|
24
|
+
* - The timezone name.
|
|
25
|
+
*/
|
|
26
|
+
timezone: string;
|
|
27
|
+
/**
|
|
28
|
+
* - The timezone ID.
|
|
29
|
+
*/
|
|
30
|
+
timezoneId: string;
|
|
31
|
+
/**
|
|
32
|
+
* - The UTC offset in hours.
|
|
33
|
+
*/
|
|
34
|
+
offset: number;
|
|
35
|
+
/**
|
|
36
|
+
* - The sign of the offset ('+' or '-').
|
|
37
|
+
*/
|
|
38
|
+
offsetSign: string;
|
|
39
|
+
/**
|
|
40
|
+
* - The DST offset in hours.
|
|
41
|
+
*/
|
|
42
|
+
dstOffset: number;
|
|
43
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the current geolocation of the device and reverse
|
|
3
|
+
* geocode it to get the address.
|
|
4
|
+
*
|
|
5
|
+
* @returns {Promise<{latitude: number, longitude: number, formatted_address: string}>}
|
|
6
|
+
* @throws {Error} If geolocation is not supported or permission is denied.
|
|
7
|
+
*/
|
|
8
|
+
export function getGeolocation(): Promise<{
|
|
9
|
+
latitude: number;
|
|
10
|
+
longitude: number;
|
|
11
|
+
formatted_address: string;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the current geolocation of the device with the browser.
|
|
3
|
+
*
|
|
4
|
+
* @returns {Promise<{latitude: number, longitude: number}>}
|
|
5
|
+
* @throws {Error} If geolocation is not supported or permission is denied.
|
|
6
|
+
*/
|
|
7
|
+
export default function geolocation(): Promise<{
|
|
8
|
+
latitude: number;
|
|
9
|
+
longitude: number;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the current GPS location of the device with Capacitor.
|
|
3
|
+
*
|
|
4
|
+
* @returns {Promise<{latitude: number, longitude: number}>}
|
|
5
|
+
* @throws {Error} If geolocation is not supported or permission is denied.
|
|
6
|
+
*/
|
|
7
|
+
export default function geolocationCapacitor(): Promise<{
|
|
8
|
+
latitude: number;
|
|
9
|
+
longitude: number;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reverse Geocoding with GoogleMaps API
|
|
3
|
+
*
|
|
4
|
+
* @see https://developers.google.com/maps/documentation/geocoding/requests-reverse-geocoding?hl=es-419
|
|
5
|
+
* @see https://maps.googleapis.com/maps/api/geocode/json?latlng=36.7248,-4.541&key=[api_key]&result_type=sublocality
|
|
6
|
+
*
|
|
7
|
+
* @param {number} latitude - Latitude of the location.
|
|
8
|
+
* @param {number} longitude - Longitude of the location.
|
|
9
|
+
* @param {string} api_key - Google Maps API key.
|
|
10
|
+
* @returns {Promise<{ sublocality: string; locality: string; country: string; country_short: string; formatted_address: string; }>} - The address components.
|
|
11
|
+
* @throws {Error} - If the API key is invalid or the request fails.
|
|
12
|
+
*/
|
|
13
|
+
export default function reverseGeocoding(latitude: number, longitude: number, api_key: string): Promise<{
|
|
14
|
+
sublocality: string;
|
|
15
|
+
locality: string;
|
|
16
|
+
country: string;
|
|
17
|
+
country_short: string;
|
|
18
|
+
formatted_address: string;
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { default as MoonCalc } from "./astronomy/moon/MoonCalc.js";
|
|
2
|
+
export { default as SunCalc } from "./astronomy/sun/SunCalc.js";
|
|
3
|
+
export { getLocalTimeInfo as getLocalTime } from "./astronomy/timeZoneInfo.js";
|
|
4
|
+
export { getGeolocation } from "./geolocation/getGeolocation.js";
|
|
5
|
+
export { useForecastCurrent } from "./OpenMeteo/current/useForecastCurrent.js";
|
|
6
|
+
export { useForecastDaily } from "./OpenMeteo/daily/useForecastDaily.js";
|
|
7
|
+
export { useForecastHourly } from "./OpenMeteo/hourly/useForecastHourly.js";
|
|
8
|
+
export { weatherSymbol } from "./OpenMeteo/weatherSymbol/weatherSymbol.js";
|
|
9
|
+
export { degreesToCompass } from "./utils/degreesToCompass.js";
|
|
10
|
+
export { WindArrow } from "./utils/wind/WindArrow.jsx";
|
|
11
|
+
export { windArrowTx } from "./utils/wind/windArrowTx.js";
|
|
12
|
+
export { getWindLevel } from "./utils/wind/windLevel.js";
|
|
13
|
+
export { dateFormat, getLocalTimeFromTz, nowString, timeString } from "./astronomy/timehelpers.js";
|
|
14
|
+
export { getWarning, getWarningByDays } from "./utils/warning.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert degrees to compass designation
|
|
3
|
+
*
|
|
4
|
+
* @param {number} degrees
|
|
5
|
+
* @param {string} language - Language code ("en-US", "es-ES", "auto")
|
|
6
|
+
* @returns {{short: string, full: string}}
|
|
7
|
+
*/
|
|
8
|
+
export function degreesToCompass(degrees: number, language?: string): {
|
|
9
|
+
short: string;
|
|
10
|
+
full: string;
|
|
11
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get warning by today and tomorrow
|
|
3
|
+
*
|
|
4
|
+
* @param {number} precipitationSumToday
|
|
5
|
+
* @param {number} precipitationSumTomorrow
|
|
6
|
+
* @param {number} showersSumToday
|
|
7
|
+
* @param {number} showersSumTomorrow
|
|
8
|
+
* @returns {{ levelNum: number, level: string, message: string, day: number } | null}
|
|
9
|
+
*/
|
|
10
|
+
export function getWarningByDays(precipitationSumToday: number, precipitationSumTomorrow: number, showersSumToday: number, showersSumTomorrow: number): {
|
|
11
|
+
levelNum: number;
|
|
12
|
+
level: string;
|
|
13
|
+
message: string;
|
|
14
|
+
day: number;
|
|
15
|
+
} | null;
|
|
16
|
+
/**
|
|
17
|
+
* Get warning by precipitation and showers
|
|
18
|
+
*
|
|
19
|
+
* @export
|
|
20
|
+
* @param {number} precipitation
|
|
21
|
+
* @param {number} showers
|
|
22
|
+
* @returns {{ levelNum: number, level: string, message: string } | null}
|
|
23
|
+
*/
|
|
24
|
+
export function getWarning(precipitation: number, showers: number): {
|
|
25
|
+
levelNum: number;
|
|
26
|
+
level: string;
|
|
27
|
+
message: string;
|
|
28
|
+
} | null;
|
|
29
|
+
export type AlertLevel = {
|
|
30
|
+
/**
|
|
31
|
+
* - The alert level number.
|
|
32
|
+
*/
|
|
33
|
+
levelNum: number;
|
|
34
|
+
/**
|
|
35
|
+
* - The alert level string (e.g., "red", "orange", "yellow").
|
|
36
|
+
*/
|
|
37
|
+
level: string;
|
|
38
|
+
/**
|
|
39
|
+
* - The precipitation threshold for the alert level.
|
|
40
|
+
*/
|
|
41
|
+
precipitation: number;
|
|
42
|
+
/**
|
|
43
|
+
* - The showers threshold for the alert level.
|
|
44
|
+
*/
|
|
45
|
+
showers: number;
|
|
46
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module utils:WindArrow
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} WindArrowProps
|
|
6
|
+
* @property {number} props.deg - Wind direction in degrees
|
|
7
|
+
* @property {string} [props.size] - Size of the arrow (Tailwind CSS size: 'size-10')
|
|
8
|
+
* @property {number} [props.strokeWidth] - Stroke width of the arrow (1 to 6)
|
|
9
|
+
* @property {string} [props.className]
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Wind direction arrow component (svg image).
|
|
13
|
+
*
|
|
14
|
+
* @component
|
|
15
|
+
* @param {WindArrowProps} props
|
|
16
|
+
*/
|
|
17
|
+
export function WindArrow({ deg, size, strokeWidth, className, }: WindArrowProps): any;
|
|
18
|
+
export type WindArrowProps = {
|
|
19
|
+
/**
|
|
20
|
+
* - Wind direction in degrees
|
|
21
|
+
*/
|
|
22
|
+
deg: number;
|
|
23
|
+
/**
|
|
24
|
+
* - Size of the arrow (Tailwind CSS size: 'size-10')
|
|
25
|
+
*/
|
|
26
|
+
size?: string;
|
|
27
|
+
/**
|
|
28
|
+
* - Stroke width of the arrow (1 to 6)
|
|
29
|
+
*/
|
|
30
|
+
strokeWidth?: number;
|
|
31
|
+
className?: string;
|
|
32
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module utils
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Convert wind direction in degrees to an arrow representation.
|
|
6
|
+
*
|
|
7
|
+
* @param {number} deg - Wind direction in degrees.
|
|
8
|
+
*/
|
|
9
|
+
export function windArrowTx(deg: number): "deg?" | "↓" | "↙" | "←" | "↖" | "↑" | "↗" | "→" | "↘" | undefined;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return the wind level based on the speed.
|
|
3
|
+
*
|
|
4
|
+
* @param {number} speed Wind speed in km/h
|
|
5
|
+
* @return {WindLevel | null} Wind level object or null if speed is null
|
|
6
|
+
*/
|
|
7
|
+
export function getWindLevel(speed: number): WindLevel | null;
|
|
8
|
+
export type WindLevel = {
|
|
9
|
+
/**
|
|
10
|
+
* - Level ID
|
|
11
|
+
*/
|
|
12
|
+
id: number;
|
|
13
|
+
/**
|
|
14
|
+
* - Minimum wind speed for this level
|
|
15
|
+
*/
|
|
16
|
+
speed: number;
|
|
17
|
+
/**
|
|
18
|
+
* - Color representing this level
|
|
19
|
+
*/
|
|
20
|
+
color: string;
|
|
21
|
+
/**
|
|
22
|
+
* - Text representing this level
|
|
23
|
+
*/
|
|
24
|
+
tx: string;
|
|
25
|
+
/**
|
|
26
|
+
* - Text representing this level
|
|
27
|
+
*/
|
|
28
|
+
txEn: string;
|
|
29
|
+
};
|