@angelrove/forecast-utils 1.1.17 → 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 +14 -14
- 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/index.ts +22 -0
- 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/index.js +0 -21
- /package/src/astronomy/{index.js → index.ts} +0 -0
- /package/src/geolocation/{index.js → index.ts} +0 -0
- /package/src/utils/{index.js → index.ts} +0 -0
|
@@ -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
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export { default as MoonCalc } from "./astronomy/moon/MoonCalc
|
|
2
|
-
export { default as SunCalc } from "./astronomy/sun/SunCalc
|
|
3
|
-
export { timeFromLocation } from "./geolocation/timeFromLocation
|
|
4
|
-
export { default as TimeDateStr } from "./utils/timehelpers
|
|
5
|
-
export { getGeolocation } from "./geolocation/getGeolocation
|
|
6
|
-
export { useForecastCurrent } from "./OpenMeteo/current/useForecastCurrent
|
|
7
|
-
export { useForecastDaily } from "./OpenMeteo/daily/useForecastDaily
|
|
8
|
-
export { useForecastHourly } from "./OpenMeteo/hourly/useForecastHourly
|
|
9
|
-
export { weatherSymbol } from "./OpenMeteo/weatherSymbol/weatherSymbol
|
|
10
|
-
export { degreesToCompass } from "./utils/degreesToCompass
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
1
|
+
export { default as MoonCalc } from "./astronomy/moon/MoonCalc";
|
|
2
|
+
export { default as SunCalc } from "./astronomy/sun/SunCalc";
|
|
3
|
+
export { timeFromLocation } from "./geolocation/timeFromLocation";
|
|
4
|
+
export { default as TimeDateStr } from "./utils/timehelpers";
|
|
5
|
+
export { getGeolocation } from "./geolocation/getGeolocation";
|
|
6
|
+
export { useForecastCurrent } from "./OpenMeteo/current/useForecastCurrent";
|
|
7
|
+
export { useForecastDaily } from "./OpenMeteo/daily/useForecastDaily";
|
|
8
|
+
export { useForecastHourly } from "./OpenMeteo/hourly/useForecastHourly";
|
|
9
|
+
export { weatherSymbol } from "./OpenMeteo/weatherSymbol/weatherSymbol";
|
|
10
|
+
export { degreesToCompass } from "./utils/degreesToCompass";
|
|
11
|
+
export { getWarning, getWarningByDays } from "./utils/warning";
|
|
12
|
+
export { WindArrow } from "./utils/wind/WindArrow";
|
|
13
|
+
export { windArrowTx } from "./utils/wind/windArrowTx";
|
|
14
|
+
export { getWindLevel } from "./utils/wind/windLevel";
|
|
@@ -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/index.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Astronomy
|
|
2
|
+
export { default as MoonCalc } from "./astronomy/moon/MoonCalc";
|
|
3
|
+
export { default as SunCalc } from "./astronomy/sun/SunCalc";
|
|
4
|
+
export { timeFromLocation } from "./geolocation/timeFromLocation";
|
|
5
|
+
export { default as TimeDateStr } from "./utils/timehelpers";
|
|
6
|
+
|
|
7
|
+
// Geolocation
|
|
8
|
+
export { getGeolocation } from "./geolocation/getGeolocation";
|
|
9
|
+
|
|
10
|
+
// OpenMeteo
|
|
11
|
+
export { useForecastCurrent } from "./OpenMeteo/current/useForecastCurrent";
|
|
12
|
+
export { useForecastDaily } from "./OpenMeteo/daily/useForecastDaily";
|
|
13
|
+
export { useForecastHourly } from "./OpenMeteo/hourly/useForecastHourly";
|
|
14
|
+
export { weatherSymbol } from "./OpenMeteo/weatherSymbol/weatherSymbol";
|
|
15
|
+
|
|
16
|
+
// utils
|
|
17
|
+
export { degreesToCompass } from "./utils/degreesToCompass";
|
|
18
|
+
export { getWarning, getWarningByDays } from "./utils/warning";
|
|
19
|
+
export { WindArrow } from "./utils/wind/WindArrow";
|
|
20
|
+
export { windArrowTx } from "./utils/wind/windArrowTx";
|
|
21
|
+
export { getWindLevel } from "./utils/wind/windLevel";
|
|
22
|
+
|
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
package/src/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Astronomy
|
|
2
|
-
export { default as MoonCalc } from "./astronomy/moon/MoonCalc.js";
|
|
3
|
-
export { default as SunCalc } from "./astronomy/sun/SunCalc.js";
|
|
4
|
-
export { timeFromLocation } from "./geolocation/timeFromLocation.js";
|
|
5
|
-
export { default as TimeDateStr } from "./utils/timehelpers.js";
|
|
6
|
-
|
|
7
|
-
// Geolocation
|
|
8
|
-
export { getGeolocation } from "./geolocation/getGeolocation.js";
|
|
9
|
-
|
|
10
|
-
// OpenMeteo
|
|
11
|
-
export { useForecastCurrent } from "./OpenMeteo/current/useForecastCurrent.js";
|
|
12
|
-
export { useForecastDaily } from "./OpenMeteo/daily/useForecastDaily.js";
|
|
13
|
-
export { useForecastHourly } from "./OpenMeteo/hourly/useForecastHourly.js";
|
|
14
|
-
export { weatherSymbol } from "./OpenMeteo/weatherSymbol/weatherSymbol.js";
|
|
15
|
-
|
|
16
|
-
// utils
|
|
17
|
-
export { degreesToCompass } from "./utils/degreesToCompass.js";
|
|
18
|
-
export { getWarning, getWarningByDays } from "./utils/warning.js";
|
|
19
|
-
export { WindArrow } from "./utils/wind/WindArrow.jsx";
|
|
20
|
-
export { windArrowTx } from "./utils/wind/windArrowTx.js";
|
|
21
|
-
export { getWindLevel } from "./utils/wind/windLevel.js";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|