use-weather-forecast 0.1.0

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 ADDED
@@ -0,0 +1,85 @@
1
+ # use-weather-forecast
2
+
3
+ React weather forecast component using Open-Meteo for current, hourly, and daily forecasts and Cloudflare/ip-api for IP geolocation.
4
+
5
+ ## Features
6
+
7
+ - Current weather.
8
+ - Next hours forecast.
9
+ - Next days forecast.
10
+ - IP geolocation fallback.
11
+ - Latitude/longitude override.
12
+ - Split SVG weather icon components.
13
+ - TypeScript + tsup library scaffold.
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ npm install use-weather-forecast
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```tsx
24
+ import { WeatherForecast } from 'use-weather-forecast';
25
+
26
+ export default function App() {
27
+ return (
28
+ <WeatherForecast
29
+ forecastDays={5}
30
+ forecastHours={12}
31
+ temperatureUnit="fahrenheit"
32
+ geoEndpoint={import.meta.env.VITE_GEO_WORKER_URL}
33
+ />
34
+ );
35
+ }
36
+ ```
37
+
38
+ ## Direct API usage
39
+
40
+ ```ts
41
+ import { getWeatherForecast } from 'use-weather-forecast';
42
+
43
+ const data = await getWeatherForecast({
44
+ latitude: 37.3688,
45
+ longitude: -122.0363,
46
+ forecastDays: 5,
47
+ forecastHours: 12,
48
+ temperatureUnit: 'fahrenheit',
49
+ });
50
+ ```
51
+
52
+ ## Build
53
+
54
+ ```bash
55
+ npm install
56
+ npm run build
57
+ ```
58
+
59
+ ## IP geolocation
60
+
61
+ This package no longer uses ipinfo.io. Instead:
62
+
63
+ - Pass `geoEndpoint` pointing at a deployed instance of the bundled Cloudflare Worker
64
+ (`worker/geo-worker.ts`) for accurate results. The worker reads Cloudflare's built-in
65
+ geolocation (`request.cf`) for the visitor's own IP, and falls back to `ip-api.com`
66
+ when a `?ip=` query param (or the `ip` prop) is supplied for an arbitrary address.
67
+ - If `geoEndpoint` is omitted, the package falls back to calling `ip-api.com` directly
68
+ from the browser. **Note:** ip-api.com's free tier only serves plain HTTP, so this
69
+ fallback will be blocked as mixed content on pages served over HTTPS — deploy the
70
+ worker and pass `geoEndpoint` for any HTTPS site.
71
+
72
+ ### Deploying the geo worker
73
+
74
+ ```bash
75
+ cd packages/react-weather-forecast
76
+ npm run worker:deploy
77
+ ```
78
+
79
+ This deploys `worker/geo-worker.ts` via Wrangler. Use the resulting `*.workers.dev` URL
80
+ (or a custom route) as `geoEndpoint`.
81
+
82
+ ## Notes
83
+
84
+ - Open-Meteo powers the forecast data.
85
+ - Cloudflare's `request.cf` and ip-api.com power IP geolocation (see above).
package/dist/index.cjs ADDED
@@ -0,0 +1,407 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ WeatherForecast: () => WeatherForecast,
24
+ WeatherIcon: () => WeatherIcon,
25
+ getClientLocation: () => getClientLocation,
26
+ getWeatherForecast: () => getWeatherForecast,
27
+ getWeatherIcon: () => getWeatherIcon,
28
+ useWeatherForecast: () => useWeatherForecast
29
+ });
30
+ module.exports = __toCommonJS(index_exports);
31
+
32
+ // src/weatherCodes.ts
33
+ function getWeatherIcon(code, isDay = 1) {
34
+ if (code === 0) return "sun";
35
+ if ([1, 2].includes(code)) return isDay ? "cloud-sun" : "clouds";
36
+ if (code === 3) return "clouds";
37
+ if ([45, 48].includes(code)) return "cloud-fog";
38
+ if ([51, 53, 55, 56, 57].includes(code)) return "cloud-drizzle";
39
+ if ([61, 63].includes(code)) return "cloud-showers";
40
+ if ([65, 66, 67, 80, 81, 82].includes(code)) return "cloud-showers-heavy";
41
+ if ([71, 73, 75, 77, 85, 86].includes(code)) return "cloud-snow";
42
+ if (code === 95) return "cloud-bolt";
43
+ if ([96, 99].includes(code)) return "cloud-hail";
44
+ return "clouds";
45
+ }
46
+
47
+ // src/api/geolocation.ts
48
+ var DEFAULT_IP_API_URL = "http://ip-api.com/json/";
49
+ async function getClientLocation(geoEndpoint, ip) {
50
+ if (geoEndpoint) {
51
+ const url = ip ? `${geoEndpoint}?ip=${encodeURIComponent(ip)}` : geoEndpoint;
52
+ const res2 = await fetch(url);
53
+ if (!res2.ok) throw new Error(`Geolocation worker lookup failed: ${res2.status}`);
54
+ const data2 = await res2.json();
55
+ return {
56
+ city: data2.city,
57
+ region: data2.region,
58
+ country: data2.country,
59
+ timezone: data2.timezone,
60
+ latitude: Number(data2.latitude),
61
+ longitude: Number(data2.longitude)
62
+ };
63
+ }
64
+ const res = await fetch(`${DEFAULT_IP_API_URL}${ip ? encodeURIComponent(ip) : ""}`);
65
+ if (!res.ok) throw new Error(`ip-api lookup failed: ${res.status}`);
66
+ const data = await res.json();
67
+ if (data.status === "fail") {
68
+ throw new Error(`ip-api lookup failed: ${data.message ?? "unknown error"}`);
69
+ }
70
+ return {
71
+ city: data.city,
72
+ region: data.regionName,
73
+ country: data.country,
74
+ timezone: data.timezone,
75
+ latitude: Number(data.lat),
76
+ longitude: Number(data.lon)
77
+ };
78
+ }
79
+
80
+ // src/api/forecast.ts
81
+ function buildUrl(latitude, longitude, options) {
82
+ const params = new URLSearchParams({
83
+ latitude: String(latitude),
84
+ longitude: String(longitude),
85
+ timezone: options.location?.timezone || "auto",
86
+ temperature_unit: options.temperatureUnit || "fahrenheit",
87
+ wind_speed_unit: options.windSpeedUnit || "mph",
88
+ forecast_days: String(options.forecastDays ?? 5),
89
+ forecast_hours: String(options.forecastHours ?? 24),
90
+ current: [
91
+ "temperature_2m",
92
+ "weather_code",
93
+ "is_day",
94
+ "rain",
95
+ "showers",
96
+ "snowfall",
97
+ "wind_speed_10m"
98
+ ].join(","),
99
+ hourly: [
100
+ "temperature_2m",
101
+ "weather_code",
102
+ "precipitation_probability",
103
+ "rain",
104
+ "showers",
105
+ "snowfall"
106
+ ].join(","),
107
+ daily: [
108
+ "temperature_2m_max",
109
+ "temperature_2m_min",
110
+ "weather_code",
111
+ "precipitation_probability_max"
112
+ ].join(",")
113
+ });
114
+ return `https://api.open-meteo.com/v1/forecast?${params.toString()}`;
115
+ }
116
+ async function getWeatherForecast(options = {}) {
117
+ let location;
118
+ if (typeof options.latitude === "number" && typeof options.longitude === "number") {
119
+ location = {
120
+ ...options.location,
121
+ latitude: options.latitude,
122
+ longitude: options.longitude
123
+ };
124
+ } else {
125
+ location = await getClientLocation(options.geoEndpoint, options.ip);
126
+ }
127
+ const url = buildUrl(location.latitude, location.longitude, { ...options, location });
128
+ const response = await fetch(url, { headers: { "Content-Type": "application/json" } });
129
+ if (!response.ok) {
130
+ throw new Error(`Weather request failed: ${response.status} ${response.statusText}`);
131
+ }
132
+ const data = await response.json();
133
+ if (!data?.current || !data?.hourly || !data?.daily) {
134
+ throw new Error("Invalid weather response");
135
+ }
136
+ return {
137
+ location,
138
+ current: {
139
+ time: data.current.time,
140
+ temperature: Math.round(data.current.temperature_2m),
141
+ weatherCode: data.current.weather_code,
142
+ icon: getWeatherIcon(data.current.weather_code, data.current.is_day),
143
+ isDay: data.current.is_day,
144
+ rain: data.current.rain,
145
+ showers: data.current.showers,
146
+ snowfall: data.current.snowfall,
147
+ windSpeed: data.current.wind_speed_10m
148
+ },
149
+ hourly: data.hourly.time.map((time, index) => ({
150
+ time,
151
+ temperature: Math.round(data.hourly.temperature_2m[index]),
152
+ weatherCode: data.hourly.weather_code[index],
153
+ precipitationProbability: data.hourly.precipitation_probability?.[index],
154
+ rain: data.hourly.rain?.[index],
155
+ showers: data.hourly.showers?.[index],
156
+ snowfall: data.hourly.snowfall?.[index],
157
+ icon: getWeatherIcon(data.hourly.weather_code[index])
158
+ })),
159
+ daily: data.daily.time.map((date, index) => ({
160
+ date,
161
+ min: Math.round(data.daily.temperature_2m_min[index]),
162
+ max: Math.round(data.daily.temperature_2m_max[index]),
163
+ weatherCode: data.daily.weather_code[index],
164
+ precipitationProbabilityMax: data.daily.precipitation_probability_max?.[index],
165
+ icon: getWeatherIcon(data.daily.weather_code[index])
166
+ }))
167
+ };
168
+ }
169
+
170
+ // src/hooks/useWeatherForecast.ts
171
+ var import_react = require("react");
172
+ function useWeatherForecast(options = {}) {
173
+ const [data, setData] = (0, import_react.useState)(null);
174
+ const [error, setError] = (0, import_react.useState)(null);
175
+ const [loading, setLoading] = (0, import_react.useState)(true);
176
+ (0, import_react.useEffect)(() => {
177
+ let active = true;
178
+ setLoading(true);
179
+ setError(null);
180
+ getWeatherForecast(options).then((result) => {
181
+ if (active) setData(result);
182
+ }).catch((err) => {
183
+ if (active) setError(err instanceof Error ? err : new Error("Unknown error"));
184
+ }).finally(() => {
185
+ if (active) setLoading(false);
186
+ });
187
+ return () => {
188
+ active = false;
189
+ };
190
+ }, [
191
+ options.latitude,
192
+ options.longitude,
193
+ options.geoEndpoint,
194
+ options.ip,
195
+ options.forecastDays,
196
+ options.forecastHours,
197
+ options.temperatureUnit,
198
+ options.windSpeedUnit,
199
+ options.location?.timezone
200
+ ]);
201
+ return { data, error, loading };
202
+ }
203
+
204
+ // src/icons/BaseIcon.tsx
205
+ var import_jsx_runtime = require("react/jsx-runtime");
206
+ function BaseIcon({ title, children, ...props }) {
207
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
208
+ "svg",
209
+ {
210
+ viewBox: "0 0 24 24",
211
+ fill: "none",
212
+ stroke: "currentColor",
213
+ strokeLinecap: "round",
214
+ strokeLinejoin: "round",
215
+ role: title ? "img" : "presentation",
216
+ "aria-hidden": title ? void 0 : true,
217
+ "aria-label": title,
218
+ ...props,
219
+ children: [
220
+ title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", { children: title }) : null,
221
+ children
222
+ ]
223
+ }
224
+ );
225
+ }
226
+
227
+ // src/icons/weather-icons.tsx
228
+ var import_jsx_runtime2 = require("react/jsx-runtime");
229
+ var CloudBoltIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BaseIcon, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M7 18a4.815 4.815 0 0 1-3.327-1.318A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 0 7h-1m-4.75-5L11 17.5h3.375l-2.25 4.5" }) });
230
+ var CloudDrizzleIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BaseIcon, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 18v1m-3-4v1m6-1v1m2 3v1M7 19v1m-3-3.034a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662" }) });
231
+ var CloudFogIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BaseIcon, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M4 16.966a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662M5 21h7m4 0h3M8 17h8" }) });
232
+ var CloudHailIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BaseIcon, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M8 17.45v.1m-1.5 3.9v.1m10.5-4.1v.1m-1.5 3.9v.1m-3-4.1v.1m-1.5 3.9v.1m10.475-4.575A3.5 3.5 0 0 0 19 11h-1c.146-.65.148-1.32.006-1.97a4.784 4.784 0 0 0-.831-1.823 5.36 5.36 0 0 0-1.544-1.398 5.964 5.964 0 0 0-2.02-.759 6.224 6.224 0 0 0-2.19-.006 5.971 5.971 0 0 0-2.024.749C8.157 6.533 7.295 7.687 7 9a4.815 4.815 0 0 0-3.327 1.318A4.403 4.403 0 0 0 2.295 13.5c0 1.194.496 2.338 1.378 3.182.105.1.214.195.327.284m4.5.534a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm-1.5 4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm10.5-4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm-1.5 4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm-3-4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm-1.5 4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Z" }) });
233
+ var CloudShowersIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BaseIcon, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M4 16.966a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662M12 13v2m0 3v2m4-5v2m0 3v2m-8-7v2m0 3v2" }) });
234
+ var CloudShowersHeavyIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BaseIcon, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M4 16.966a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662M16 15v6m-8-6v6m4-8v6" }) });
235
+ var CloudSleetIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BaseIcon, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M13.5 17.45a1 1 0 1 0-2 0h2Zm-2 .1a1 1 0 1 0 2 0h-2Zm.5 3.9a1 1 0 1 0-2 0h2Zm-2 .1a1 1 0 1 0 2 0h-2Zm-6.327-4.868.692-.723-.692.723ZM7 9v1a1 1 0 0 0 .976-.781L7 9Zm2.397-3.207.512.858-.512-.858ZM18 11l-.976-.219A1 1 0 0 0 18 12v-1Zm2.768 5.268a1 1 0 0 0 1.414 1.414l-.707-.707-.707-.707ZM3.379 17.75a1 1 0 0 0 1.242-1.567L4 16.966l-.62.784Zm5.55-.379a1 1 0 0 0-1.857-.742L8 17l.928.371ZM5.071 21.63a1 1 0 0 0 1.856.742L6 22l-.928-.371Zm13.857-4.258a1 1 0 0 0-1.857-.742L18 17l.928.371Zm-3.857 4.258a1 1 0 0 0 1.857.742L16 22l-.928-.371ZM13 17.5h-1a.5.5 0 0 1 .5-.5v2a1.5 1.5 0 0 0 1.5-1.5h-1Zm-.5.5v-1a.5.5 0 0 1 .5.5h-2a1.5 1.5 0 0 0 1.5 1.5v-1Zm-.5-.5h1a.5.5 0 0 1-.5.5v-2a1.5 1.5 0 0 0-1.5 1.5h1Zm.5-.5v1a.5.5 0 0 1-.5-.5h2a1.5 1.5 0 0 0-1.5-1.5v1Zm0 .45h-1v.1h2v-.1h-1Zm-1 4.05h-1a.5.5 0 0 1 .5-.5v2a1.5 1.5 0 0 0 1.5-1.5h-1Zm-.5.5v-1a.5.5 0 0 1 .5.5h-2A1.5 1.5 0 0 0 11 23v-1Zm-.5-.5h1a.5.5 0 0 1-.5.5v-2a1.5 1.5 0 0 0-1.5 1.5h1Zm.5-.5v1a.5.5 0 0 1-.5-.5h2A1.5 1.5 0 0 0 11 20v1Zm0 .45h-1v.1h2v-.1h-1Zm-7.327-4.768.692-.723a3.403 3.403 0 0 1-1.07-2.459h-2c0 1.473.613 2.877 1.687 3.905l.691-.723ZM2.295 13.5h1c0-.914.38-1.8 1.07-2.46l-.692-.722-.69-.723A5.403 5.403 0 0 0 1.294 13.5h1Zm1.378-3.182.692.723A3.815 3.815 0 0 1 7 10V8c-1.499 0-2.945.57-4.018 1.595l.691.723ZM7 9l.976.219c.23-1.024.91-1.956 1.933-2.568l-.512-.858-.513-.859c-1.456.87-2.5 2.245-2.86 3.847L7 9Zm2.397-3.207.512.858a4.972 4.972 0 0 1 1.686-.622l-.173-.985-.174-.985a6.971 6.971 0 0 0-2.364.875l.513.859Zm2.025-.749.173.985a5.223 5.223 0 0 1 1.837.005l.18-.984.178-.984a7.223 7.223 0 0 0-2.542-.007l.174.985Zm2.19.006-.18.984c.606.11 1.177.326 1.681.631l.518-.856.518-.855a6.963 6.963 0 0 0-2.359-.888l-.179.984Zm2.02.76-.519.855c.505.305.93.693 1.257 1.136l.805-.594.805-.594a6.361 6.361 0 0 0-1.831-1.659l-.518.855Zm1.543 1.397-.805.594c.326.442.549.932.66 1.441l.976-.212.978-.213a5.786 5.786 0 0 0-1.005-2.204l-.804.594Zm.831 1.823-.977.212c.111.509.11 1.031-.005 1.539L18 11l.976.219c.178-.792.18-1.609.008-2.402l-.978.213ZM18 11v1h1v-2h-1v1Zm1 0v1a2.5 2.5 0 0 1 1.768.732l.707-.707.707-.707A4.5 4.5 0 0 0 19 10v1Zm2.475 1.025-.707.707A2.5 2.5 0 0 1 21.5 14.5h2a4.5 4.5 0 0 0-1.318-3.182l-.707.707ZM22.5 14.5h-1a2.5 2.5 0 0 1-.732 1.768l.707.707.707.707A4.5 4.5 0 0 0 23.5 14.5h-1ZM4 16.966l.62-.784a3.684 3.684 0 0 1-.255-.223l-.692.723-.69.723c.126.121.259.237.396.345L4 16.966ZM8 17l-.928-.371-2 5L6 22l.928.371 2-5L8 17Zm10 0-.928-.371-2 5L16 22l.928.371 2-5L18 17Z" }) });
236
+ var CloudSnowIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BaseIcon, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M8 15h2m-1-1v2m5-1h2m-1-1v2M5 21h2m-1-1v2m5-2h2m-1-1v2m5 0h2m-1-1v2M4 16.966a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662" }) });
237
+ var CloudSunIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BaseIcon, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M10.201 19.997c-1.977 0-3.58-1.544-3.58-3.448 0-1.903 1.603-3.446 3.58-3.446.303-1.355 1.38-2.461 2.827-2.902 1.445-.44 3.042-.148 4.186.77 1.144.915 1.663 2.312 1.361 3.667h.761c1.472 0 2.664 1.2 2.664 2.68A2.672 2.672 0 0 1 19.336 20h-9.134m2.66-12.934a4.166 4.166 0 0 0-2.677-1.732m2.677 1.732 2.744-1.892m-2.744 1.892c.55.796.802 1.754.723 2.709m-3.4-4.44a4.167 4.167 0 0 0-3.118.667m3.118-.668.602-3.278m-3.72 3.946A4.167 4.167 0 0 0 5.334 8.68m1.733-2.678L5.174 3.26m.16 5.42c-.2 1.088.041 2.21.669 3.12m-.669-3.12-3.278-.601m3.947 3.72-2.744 1.893m2.744-1.893a4.167 4.167 0 0 0 2.174 1.607" }) });
238
+ var CloudsIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BaseIcon, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M8.958 21.05C6.772 21.05 5 19.344 5 17.24s1.772-3.81 3.958-3.81c.335-1.498 1.525-2.72 3.124-3.207 1.598-.487 3.363-.164 4.628.85 1.264 1.011 1.837 2.556 1.504 4.053h.842A2.953 2.953 0 0 1 22 18.09a2.954 2.954 0 0 1-2.945 2.964H8.958M18 8c-.5-2.5-3.532-3.401-5.5-2.5a3.117 3.117 0 0 0-2.11-2.312c-1.352-.411-2.845-.138-3.915.72-1.07.855-1.554 2.161-1.273 3.428h-.711A2.498 2.498 0 0 0 2 9.843c0 1.094.695 2.023 1.666 2.366" }) });
239
+ var SnowflakeIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BaseIcon, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m9.25 4-1 2H6m-2.25 4L5 12m0 0-1.25 2M5 12h3m-3 0H2.5m17.75-2L19 12l1.25 2M6 18h2.25l1 2M14 9h-4m4 0 3-5m-3 5 2 3m-6-3L7 4m3 5-2 3m0 0 2 3m0 0-3 5m3-5h4m2-3-2 3m2-3h5.5M14 15l3 5M14.75 4l1 2H18m0 12h-2.25l-1 2" }) });
240
+ var SunIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BaseIcon, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 4V2m0 20v-2m10-8h-2M4 12H2m15.657-5.657 1.414-1.414M4.93 19.07l1.414-1.414m12.728 1.414-1.414-1.414M6.343 6.343 4.93 4.929M7 12a5 5 0 1 0 10 0 5 5 0 0 0-10 0Z" }) });
241
+ var WindIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BaseIcon, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M9.59 4.59A2 2 0 1 1 11 8H2m10.59 11.41A2 2 0 1 0 14 16H2m15.73-8.27A2.5 2.5 0 1 1 19.5 12H2" }) });
242
+
243
+ // src/icons/WeatherIcon.tsx
244
+ var import_jsx_runtime3 = require("react/jsx-runtime");
245
+ var iconMap = {
246
+ sun: SunIcon,
247
+ "cloud-sun": CloudSunIcon,
248
+ clouds: CloudsIcon,
249
+ "cloud-fog": CloudFogIcon,
250
+ "cloud-drizzle": CloudDrizzleIcon,
251
+ "cloud-showers": CloudShowersIcon,
252
+ "cloud-showers-heavy": CloudShowersHeavyIcon,
253
+ "cloud-sleet": CloudSleetIcon,
254
+ "cloud-snow": CloudSnowIcon,
255
+ snowflake: SnowflakeIcon,
256
+ "cloud-bolt": CloudBoltIcon,
257
+ "cloud-hail": CloudHailIcon
258
+ };
259
+ function WeatherIcon({ condition, ...props }) {
260
+ const Icon = iconMap[condition] || CloudsIcon;
261
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { ...props });
262
+ }
263
+
264
+ // src/components/WeatherForecast.tsx
265
+ var import_jsx_runtime4 = require("react/jsx-runtime");
266
+ var WIND_SPEED_UNIT_LABELS = {
267
+ kmh: "km/h",
268
+ mph: "mph",
269
+ ms: "m/s",
270
+ kn: "kn"
271
+ };
272
+ function closestHour(hourly, targetTime) {
273
+ return hourly.reduce((closest, hour) => {
274
+ const diff = Math.abs(new Date(hour.time).getTime() - targetTime.getTime());
275
+ const closestDiff = closest ? Math.abs(new Date(closest.time).getTime() - targetTime.getTime()) : Infinity;
276
+ return diff < closestDiff ? hour : closest;
277
+ }, void 0);
278
+ }
279
+ var styles = {
280
+ root: {
281
+ fontFamily: "system-ui, sans-serif",
282
+ border: "1px solid #e5e7eb",
283
+ borderRadius: 12,
284
+ padding: 16,
285
+ background: "#fff",
286
+ color: "#111827",
287
+ maxWidth: 640
288
+ },
289
+ row: { display: "flex", alignItems: "center", gap: 8 },
290
+ hours: { display: "flex", gap: 12, overflowX: "auto", paddingBottom: 4 },
291
+ hourCard: { minWidth: 72, textAlign: "center", padding: 8, borderRadius: 8, background: "#f9fafb" },
292
+ dayRow: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 10, padding: "8px 0", borderBottom: "1px solid #f3f4f6" },
293
+ compactRoot: { fontFamily: "system-ui, sans-serif", display: "flex", flexDirection: "column", gap: 8, padding: "10px 14px", borderRadius: 8 },
294
+ compactHeader: { display: "flex", alignItems: "center", gap: 10 },
295
+ compactHeaderText: { display: "flex", alignItems: "baseline", gap: 8, flexWrap: "wrap" },
296
+ compactDateTime: { fontSize: 11, opacity: 0.7 },
297
+ compactStats: { display: "flex", flexWrap: "wrap", gap: 12, fontSize: 12, opacity: 0.9 },
298
+ compactStat: { display: "flex", alignItems: "center", gap: 4, whiteSpace: "nowrap" }
299
+ };
300
+ function WeatherForecast(props) {
301
+ const { data, loading, error } = useWeatherForecast(props);
302
+ if (loading) return null;
303
+ if (error) return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: props.className, style: props.style, children: [
304
+ "Error: ",
305
+ error.message
306
+ ] });
307
+ if (!data) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: props.className, style: props.style, children: "No forecast available." });
308
+ if (props.compact) {
309
+ const now = new Date(data.current.time);
310
+ const today = data.daily[0];
311
+ const tomorrow = data.daily[1];
312
+ const in6Hours = closestHour(data.hourly, new Date(now.getTime() + 6 * 60 * 60 * 1e3));
313
+ const windSpeedUnitLabel = WIND_SPEED_UNIT_LABELS[props.windSpeedUnit ?? "mph"];
314
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: props.className, style: { ...styles.compactRoot, ...props.style }, children: [
315
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: styles.compactHeader, children: [
316
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(WeatherIcon, { condition: data.current.icon, width: 24, height: 24, title: "Current weather" }),
317
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
318
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: styles.compactHeaderText, children: [
319
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("strong", { style: { fontSize: 16 }, children: [
320
+ data.current.temperature,
321
+ "\xB0"
322
+ ] }),
323
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontSize: 14, opacity: 0.8 }, children: data.location?.city || "Current location" })
324
+ ] }),
325
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: styles.compactDateTime, children: [
326
+ now.toLocaleDateString([], { weekday: "short", month: "short", day: "numeric" }),
327
+ " \xB7 ",
328
+ now.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" })
329
+ ] })
330
+ ] })
331
+ ] }),
332
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: styles.compactStats, children: [
333
+ today && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: styles.compactStat, children: [
334
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(WeatherIcon, { condition: today.icon, width: 16, height: 16, title: "Today's high and low" }),
335
+ today.max,
336
+ "\xB0 / ",
337
+ today.min,
338
+ "\xB0"
339
+ ] }),
340
+ tomorrow && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: styles.compactStat, children: [
341
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(WeatherIcon, { condition: tomorrow.icon, width: 16, height: 16, title: "Tomorrow" }),
342
+ "Tomorrow ",
343
+ tomorrow.max,
344
+ "\xB0"
345
+ ] }),
346
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: styles.compactStat, children: [
347
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(WindIcon, { width: 16, height: 16, title: "Wind speed" }),
348
+ data.current.windSpeed !== void 0 ? `${Math.round(data.current.windSpeed)} ${windSpeedUnitLabel}` : "\u2014"
349
+ ] }),
350
+ in6Hours && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: styles.compactStat, children: [
351
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(WeatherIcon, { condition: in6Hours.icon, width: 16, height: 16, title: "In 6 hours" }),
352
+ in6Hours.temperature,
353
+ "\xB0 in 6h"
354
+ ] })
355
+ ] })
356
+ ] });
357
+ }
358
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: props.className, style: { ...styles.root, ...props.style }, children: [
359
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
360
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("h3", { style: { margin: 0, fontSize: 20 }, children: [
361
+ data.location?.city || "Current location",
362
+ data.location?.region ? `, ${data.location.region}` : ""
363
+ ] }),
364
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { ...styles.row, marginTop: 8 }, children: [
365
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(WeatherIcon, { condition: data.current.icon, width: 28, height: 28, title: "Current weather" }),
366
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("strong", { style: { fontSize: 28 }, children: [
367
+ data.current.temperature,
368
+ "\xB0"
369
+ ] })
370
+ ] })
371
+ ] }),
372
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { marginTop: 20 }, children: [
373
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h4", { style: { margin: "0 0 10px 0" }, children: "Next hours" }),
374
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: styles.hours, children: data.hourly.slice(0, props.forecastHours ?? 12).map((hour) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: styles.hourCard, children: [
375
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { fontSize: 12 }, children: new Date(hour.time).toLocaleTimeString([], { hour: "numeric" }) }),
376
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(WeatherIcon, { condition: hour.icon, width: 20, height: 20, style: { margin: "6px auto" } }),
377
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
378
+ hour.temperature,
379
+ "\xB0"
380
+ ] })
381
+ ] }, hour.time)) })
382
+ ] }),
383
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { marginTop: 20 }, children: [
384
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h4", { style: { margin: "0 0 10px 0" }, children: "Next days" }),
385
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: data.daily.map((day) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: styles.dayRow, children: [
386
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { width: 120 }, children: new Date(day.date).toLocaleDateString([], { weekday: "short", month: "short", day: "numeric" }) }),
387
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(WeatherIcon, { condition: day.icon, width: 20, height: 20 }),
388
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
389
+ day.min,
390
+ "\xB0 / ",
391
+ day.max,
392
+ "\xB0"
393
+ ] })
394
+ ] }, day.date)) })
395
+ ] })
396
+ ] });
397
+ }
398
+ // Annotate the CommonJS export names for ESM import in node:
399
+ 0 && (module.exports = {
400
+ WeatherForecast,
401
+ WeatherIcon,
402
+ getClientLocation,
403
+ getWeatherForecast,
404
+ getWeatherIcon,
405
+ useWeatherForecast
406
+ });
407
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/weatherCodes.ts","../src/api/geolocation.ts","../src/api/forecast.ts","../src/hooks/useWeatherForecast.ts","../src/icons/BaseIcon.tsx","../src/icons/weather-icons.tsx","../src/icons/WeatherIcon.tsx","../src/components/WeatherForecast.tsx"],"sourcesContent":["export * from './types';\nexport * from './weatherCodes';\nexport * from './api/geolocation';\nexport * from './api/forecast';\nexport * from './hooks/useWeatherForecast';\nexport * from './icons/WeatherIcon';\nexport * from './components/WeatherForecast';\n","import type { WeatherCondition } from './types';\n\nexport function getWeatherIcon(code: number, isDay = 1): WeatherCondition {\n if (code === 0) return 'sun';\n if ([1, 2].includes(code)) return isDay ? 'cloud-sun' : 'clouds';\n if (code === 3) return 'clouds';\n if ([45, 48].includes(code)) return 'cloud-fog';\n if ([51, 53, 55, 56, 57].includes(code)) return 'cloud-drizzle';\n if ([61, 63].includes(code)) return 'cloud-showers';\n if ([65, 66, 67, 80, 81, 82].includes(code)) return 'cloud-showers-heavy';\n if ([71, 73, 75, 77, 85, 86].includes(code)) return 'cloud-snow';\n if (code === 95) return 'cloud-bolt';\n if ([96, 99].includes(code)) return 'cloud-hail';\n return 'clouds';\n}\n","import type { WeatherLocation } from '../types';\n\n// ip-api.com's free tier only serves plain HTTP (HTTPS requires their paid plan),\n// so this default will be blocked as mixed content on pages served over HTTPS.\n// Deploy worker/geo-worker.ts and pass its URL as `geoEndpoint` to avoid that.\nconst DEFAULT_IP_API_URL = 'http://ip-api.com/json/';\n\ntype IpApiResponse = {\n status: 'success' | 'fail';\n city?: string;\n regionName?: string;\n country?: string;\n timezone?: string;\n lat?: number;\n lon?: number;\n message?: string;\n};\n\ntype GeoWorkerResponse = {\n city?: string;\n region?: string;\n country?: string;\n timezone?: string;\n latitude?: number | string;\n longitude?: number | string;\n};\n\nexport async function getClientLocation(geoEndpoint?: string, ip?: string): Promise<WeatherLocation> {\n if (geoEndpoint) {\n const url = ip ? `${geoEndpoint}?ip=${encodeURIComponent(ip)}` : geoEndpoint;\n const res = await fetch(url);\n if (!res.ok) throw new Error(`Geolocation worker lookup failed: ${res.status}`);\n const data: GeoWorkerResponse = await res.json();\n\n return {\n city: data.city,\n region: data.region,\n country: data.country,\n timezone: data.timezone,\n latitude: Number(data.latitude),\n longitude: Number(data.longitude),\n };\n }\n\n const res = await fetch(`${DEFAULT_IP_API_URL}${ip ? encodeURIComponent(ip) : ''}`);\n if (!res.ok) throw new Error(`ip-api lookup failed: ${res.status}`);\n const data: IpApiResponse = await res.json();\n\n if (data.status === 'fail') {\n throw new Error(`ip-api lookup failed: ${data.message ?? 'unknown error'}`);\n }\n\n return {\n city: data.city,\n region: data.regionName,\n country: data.country,\n timezone: data.timezone,\n latitude: Number(data.lat),\n longitude: Number(data.lon),\n };\n}\n","import type { WeatherForecastData, WeatherForecastOptions, WeatherLocation } from '../types';\nimport { getWeatherIcon } from '../weatherCodes';\nimport { getClientLocation } from './geolocation';\n\nfunction buildUrl(latitude: number, longitude: number, options: WeatherForecastOptions) {\n const params = new URLSearchParams({\n latitude: String(latitude),\n longitude: String(longitude),\n timezone: options.location?.timezone || 'auto',\n temperature_unit: options.temperatureUnit || 'fahrenheit',\n wind_speed_unit: options.windSpeedUnit || 'mph',\n forecast_days: String(options.forecastDays ?? 5),\n forecast_hours: String(options.forecastHours ?? 24),\n current: [\n 'temperature_2m',\n 'weather_code',\n 'is_day',\n 'rain',\n 'showers',\n 'snowfall',\n 'wind_speed_10m',\n ].join(','),\n hourly: [\n 'temperature_2m',\n 'weather_code',\n 'precipitation_probability',\n 'rain',\n 'showers',\n 'snowfall',\n ].join(','),\n daily: [\n 'temperature_2m_max',\n 'temperature_2m_min',\n 'weather_code',\n 'precipitation_probability_max',\n ].join(','),\n });\n\n return `https://api.open-meteo.com/v1/forecast?${params.toString()}`;\n}\n\nexport async function getWeatherForecast(\n options: WeatherForecastOptions = {}\n): Promise<WeatherForecastData> {\n let location: WeatherLocation;\n\n if (typeof options.latitude === 'number' && typeof options.longitude === 'number') {\n location = {\n ...options.location,\n latitude: options.latitude,\n longitude: options.longitude,\n };\n } else {\n location = await getClientLocation(options.geoEndpoint, options.ip);\n }\n\n const url = buildUrl(location.latitude, location.longitude, { ...options, location });\n const response = await fetch(url, { headers: { 'Content-Type': 'application/json' } });\n\n if (!response.ok) {\n throw new Error(`Weather request failed: ${response.status} ${response.statusText}`);\n }\n\n const data = await response.json();\n\n if (!data?.current || !data?.hourly || !data?.daily) {\n throw new Error('Invalid weather response');\n }\n\n return {\n location,\n current: {\n time: data.current.time,\n temperature: Math.round(data.current.temperature_2m),\n weatherCode: data.current.weather_code,\n icon: getWeatherIcon(data.current.weather_code, data.current.is_day),\n isDay: data.current.is_day,\n rain: data.current.rain,\n showers: data.current.showers,\n snowfall: data.current.snowfall,\n windSpeed: data.current.wind_speed_10m,\n },\n hourly: data.hourly.time.map((time: string, index: number) => ({\n time,\n temperature: Math.round(data.hourly.temperature_2m[index]),\n weatherCode: data.hourly.weather_code[index],\n precipitationProbability: data.hourly.precipitation_probability?.[index],\n rain: data.hourly.rain?.[index],\n showers: data.hourly.showers?.[index],\n snowfall: data.hourly.snowfall?.[index],\n icon: getWeatherIcon(data.hourly.weather_code[index]),\n })),\n daily: data.daily.time.map((date: string, index: number) => ({\n date,\n min: Math.round(data.daily.temperature_2m_min[index]),\n max: Math.round(data.daily.temperature_2m_max[index]),\n weatherCode: data.daily.weather_code[index],\n precipitationProbabilityMax: data.daily.precipitation_probability_max?.[index],\n icon: getWeatherIcon(data.daily.weather_code[index]),\n })),\n };\n}\n","import { useEffect, useState } from 'react';\nimport type { WeatherForecastData, WeatherForecastOptions } from '../types';\nimport { getWeatherForecast } from '../api/forecast';\n\nexport function useWeatherForecast(options: WeatherForecastOptions = {}) {\n const [data, setData] = useState<WeatherForecastData | null>(null);\n const [error, setError] = useState<Error | null>(null);\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n let active = true;\n setLoading(true);\n setError(null);\n\n getWeatherForecast(options)\n .then((result) => { if (active) setData(result); })\n .catch((err) => { if (active) setError(err instanceof Error ? err : new Error('Unknown error')); })\n .finally(() => { if (active) setLoading(false); });\n\n return () => { active = false; };\n }, [\n options.latitude,\n options.longitude,\n options.geoEndpoint,\n options.ip,\n options.forecastDays,\n options.forecastHours,\n options.temperatureUnit,\n options.windSpeedUnit,\n options.location?.timezone,\n ]);\n\n return { data, error, loading };\n}\n","import React from 'react';\nimport type { IconProps } from '../types';\n\nexport function BaseIcon({ title, children, ...props }: IconProps & { children: React.ReactNode }) {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n role={title ? 'img' : 'presentation'}\n aria-hidden={title ? undefined : true}\n aria-label={title}\n {...props}\n >\n {title ? <title>{title}</title> : null}\n {children}\n </svg>\n );\n}\n","import React from 'react';\nimport type { IconProps } from '../types';\nimport { BaseIcon } from './BaseIcon';\n\nexport const CloudBoltIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M7 18a4.815 4.815 0 0 1-3.327-1.318A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 0 7h-1m-4.75-5L11 17.5h3.375l-2.25 4.5\" /></BaseIcon>\n);\nexport const CloudDrizzleIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M12 18v1m-3-4v1m6-1v1m2 3v1M7 19v1m-3-3.034a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662\" /></BaseIcon>\n);\nexport const CloudFogIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M4 16.966a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662M5 21h7m4 0h3M8 17h8\" /></BaseIcon>\n);\nexport const CloudHailIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M8 17.45v.1m-1.5 3.9v.1m10.5-4.1v.1m-1.5 3.9v.1m-3-4.1v.1m-1.5 3.9v.1m10.475-4.575A3.5 3.5 0 0 0 19 11h-1c.146-.65.148-1.32.006-1.97a4.784 4.784 0 0 0-.831-1.823 5.36 5.36 0 0 0-1.544-1.398 5.964 5.964 0 0 0-2.02-.759 6.224 6.224 0 0 0-2.19-.006 5.971 5.971 0 0 0-2.024.749C8.157 6.533 7.295 7.687 7 9a4.815 4.815 0 0 0-3.327 1.318A4.403 4.403 0 0 0 2.295 13.5c0 1.194.496 2.338 1.378 3.182.105.1.214.195.327.284m4.5.534a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm-1.5 4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm10.5-4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm-1.5 4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm-3-4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm-1.5 4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Z\" /></BaseIcon>\n);\nexport const CloudShowersIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M4 16.966a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662M12 13v2m0 3v2m4-5v2m0 3v2m-8-7v2m0 3v2\" /></BaseIcon>\n);\nexport const CloudShowersHeavyIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M4 16.966a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662M16 15v6m-8-6v6m4-8v6\" /></BaseIcon>\n);\nexport const CloudSleetIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M13.5 17.45a1 1 0 1 0-2 0h2Zm-2 .1a1 1 0 1 0 2 0h-2Zm.5 3.9a1 1 0 1 0-2 0h2Zm-2 .1a1 1 0 1 0 2 0h-2Zm-6.327-4.868.692-.723-.692.723ZM7 9v1a1 1 0 0 0 .976-.781L7 9Zm2.397-3.207.512.858-.512-.858ZM18 11l-.976-.219A1 1 0 0 0 18 12v-1Zm2.768 5.268a1 1 0 0 0 1.414 1.414l-.707-.707-.707-.707ZM3.379 17.75a1 1 0 0 0 1.242-1.567L4 16.966l-.62.784Zm5.55-.379a1 1 0 0 0-1.857-.742L8 17l.928.371ZM5.071 21.63a1 1 0 0 0 1.856.742L6 22l-.928-.371Zm13.857-4.258a1 1 0 0 0-1.857-.742L18 17l.928.371Zm-3.857 4.258a1 1 0 0 0 1.857.742L16 22l-.928-.371ZM13 17.5h-1a.5.5 0 0 1 .5-.5v2a1.5 1.5 0 0 0 1.5-1.5h-1Zm-.5.5v-1a.5.5 0 0 1 .5.5h-2a1.5 1.5 0 0 0 1.5 1.5v-1Zm-.5-.5h1a.5.5 0 0 1-.5.5v-2a1.5 1.5 0 0 0-1.5 1.5h1Zm.5-.5v1a.5.5 0 0 1-.5-.5h2a1.5 1.5 0 0 0-1.5-1.5v1Zm0 .45h-1v.1h2v-.1h-1Zm-1 4.05h-1a.5.5 0 0 1 .5-.5v2a1.5 1.5 0 0 0 1.5-1.5h-1Zm-.5.5v-1a.5.5 0 0 1 .5.5h-2A1.5 1.5 0 0 0 11 23v-1Zm-.5-.5h1a.5.5 0 0 1-.5.5v-2a1.5 1.5 0 0 0-1.5 1.5h1Zm.5-.5v1a.5.5 0 0 1-.5-.5h2A1.5 1.5 0 0 0 11 20v1Zm0 .45h-1v.1h2v-.1h-1Zm-7.327-4.768.692-.723a3.403 3.403 0 0 1-1.07-2.459h-2c0 1.473.613 2.877 1.687 3.905l.691-.723ZM2.295 13.5h1c0-.914.38-1.8 1.07-2.46l-.692-.722-.69-.723A5.403 5.403 0 0 0 1.294 13.5h1Zm1.378-3.182.692.723A3.815 3.815 0 0 1 7 10V8c-1.499 0-2.945.57-4.018 1.595l.691.723ZM7 9l.976.219c.23-1.024.91-1.956 1.933-2.568l-.512-.858-.513-.859c-1.456.87-2.5 2.245-2.86 3.847L7 9Zm2.397-3.207.512.858a4.972 4.972 0 0 1 1.686-.622l-.173-.985-.174-.985a6.971 6.971 0 0 0-2.364.875l.513.859Zm2.025-.749.173.985a5.223 5.223 0 0 1 1.837.005l.18-.984.178-.984a7.223 7.223 0 0 0-2.542-.007l.174.985Zm2.19.006-.18.984c.606.11 1.177.326 1.681.631l.518-.856.518-.855a6.963 6.963 0 0 0-2.359-.888l-.179.984Zm2.02.76-.519.855c.505.305.93.693 1.257 1.136l.805-.594.805-.594a6.361 6.361 0 0 0-1.831-1.659l-.518.855Zm1.543 1.397-.805.594c.326.442.549.932.66 1.441l.976-.212.978-.213a5.786 5.786 0 0 0-1.005-2.204l-.804.594Zm.831 1.823-.977.212c.111.509.11 1.031-.005 1.539L18 11l.976.219c.178-.792.18-1.609.008-2.402l-.978.213ZM18 11v1h1v-2h-1v1Zm1 0v1a2.5 2.5 0 0 1 1.768.732l.707-.707.707-.707A4.5 4.5 0 0 0 19 10v1Zm2.475 1.025-.707.707A2.5 2.5 0 0 1 21.5 14.5h2a4.5 4.5 0 0 0-1.318-3.182l-.707.707ZM22.5 14.5h-1a2.5 2.5 0 0 1-.732 1.768l.707.707.707.707A4.5 4.5 0 0 0 23.5 14.5h-1ZM4 16.966l.62-.784a3.684 3.684 0 0 1-.255-.223l-.692.723-.69.723c.126.121.259.237.396.345L4 16.966ZM8 17l-.928-.371-2 5L6 22l.928.371 2-5L8 17Zm10 0-.928-.371-2 5L16 22l.928.371 2-5L18 17Z\" /></BaseIcon>\n);\nexport const CloudSnowIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M8 15h2m-1-1v2m5-1h2m-1-1v2M5 21h2m-1-1v2m5-2h2m-1-1v2m5 0h2m-1-1v2M4 16.966a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662\" /></BaseIcon>\n);\nexport const CloudSunIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M10.201 19.997c-1.977 0-3.58-1.544-3.58-3.448 0-1.903 1.603-3.446 3.58-3.446.303-1.355 1.38-2.461 2.827-2.902 1.445-.44 3.042-.148 4.186.77 1.144.915 1.663 2.312 1.361 3.667h.761c1.472 0 2.664 1.2 2.664 2.68A2.672 2.672 0 0 1 19.336 20h-9.134m2.66-12.934a4.166 4.166 0 0 0-2.677-1.732m2.677 1.732 2.744-1.892m-2.744 1.892c.55.796.802 1.754.723 2.709m-3.4-4.44a4.167 4.167 0 0 0-3.118.667m3.118-.668.602-3.278m-3.72 3.946A4.167 4.167 0 0 0 5.334 8.68m1.733-2.678L5.174 3.26m.16 5.42c-.2 1.088.041 2.21.669 3.12m-.669-3.12-3.278-.601m3.947 3.72-2.744 1.893m2.744-1.893a4.167 4.167 0 0 0 2.174 1.607\" /></BaseIcon>\n);\nexport const CloudsIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M8.958 21.05C6.772 21.05 5 19.344 5 17.24s1.772-3.81 3.958-3.81c.335-1.498 1.525-2.72 3.124-3.207 1.598-.487 3.363-.164 4.628.85 1.264 1.011 1.837 2.556 1.504 4.053h.842A2.953 2.953 0 0 1 22 18.09a2.954 2.954 0 0 1-2.945 2.964H8.958M18 8c-.5-2.5-3.532-3.401-5.5-2.5a3.117 3.117 0 0 0-2.11-2.312c-1.352-.411-2.845-.138-3.915.72-1.07.855-1.554 2.161-1.273 3.428h-.711A2.498 2.498 0 0 0 2 9.843c0 1.094.695 2.023 1.666 2.366\" /></BaseIcon>\n);\nexport const SnowflakeIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"m9.25 4-1 2H6m-2.25 4L5 12m0 0-1.25 2M5 12h3m-3 0H2.5m17.75-2L19 12l1.25 2M6 18h2.25l1 2M14 9h-4m4 0 3-5m-3 5 2 3m-6-3L7 4m3 5-2 3m0 0 2 3m0 0-3 5m3-5h4m2-3-2 3m2-3h5.5M14 15l3 5M14.75 4l1 2H18m0 12h-2.25l-1 2\" /></BaseIcon>\n);\nexport const SunIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M12 4V2m0 20v-2m10-8h-2M4 12H2m15.657-5.657 1.414-1.414M4.93 19.07l1.414-1.414m12.728 1.414-1.414-1.414M6.343 6.343 4.93 4.929M7 12a5 5 0 1 0 10 0 5 5 0 0 0-10 0Z\" /></BaseIcon>\n);\nexport const WindIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M9.59 4.59A2 2 0 1 1 11 8H2m10.59 11.41A2 2 0 1 0 14 16H2m15.73-8.27A2.5 2.5 0 1 1 19.5 12H2\" /></BaseIcon>\n);\n","import React from 'react';\nimport type { IconProps, WeatherCondition } from '../types';\nimport {\n CloudBoltIcon,\n CloudDrizzleIcon,\n CloudFogIcon,\n CloudHailIcon,\n CloudShowersHeavyIcon,\n CloudShowersIcon,\n CloudSleetIcon,\n CloudSnowIcon,\n CloudSunIcon,\n CloudsIcon,\n SnowflakeIcon,\n SunIcon,\n} from './weather-icons';\n\nconst iconMap: Record<WeatherCondition, React.ComponentType<IconProps>> = {\n sun: SunIcon,\n 'cloud-sun': CloudSunIcon,\n clouds: CloudsIcon,\n 'cloud-fog': CloudFogIcon,\n 'cloud-drizzle': CloudDrizzleIcon,\n 'cloud-showers': CloudShowersIcon,\n 'cloud-showers-heavy': CloudShowersHeavyIcon,\n 'cloud-sleet': CloudSleetIcon,\n 'cloud-snow': CloudSnowIcon,\n snowflake: SnowflakeIcon,\n 'cloud-bolt': CloudBoltIcon,\n 'cloud-hail': CloudHailIcon,\n};\n\nexport function WeatherIcon({ condition, ...props }: IconProps & { condition: WeatherCondition }) {\n const Icon = iconMap[condition] || CloudsIcon;\n return <Icon {...props} />;\n}\n","import React from 'react';\nimport { useWeatherForecast } from '../hooks/useWeatherForecast';\nimport type { HourlyWeather, WeatherForecastOptions, WindSpeedUnit } from '../types';\nimport { WeatherIcon } from '../icons/WeatherIcon';\nimport { WindIcon } from '../icons/weather-icons';\n\ntype Props = WeatherForecastOptions & {\n className?: string;\n style?: React.CSSProperties;\n compact?: boolean;\n};\n\nconst WIND_SPEED_UNIT_LABELS: Record<WindSpeedUnit, string> = {\n kmh: 'km/h',\n mph: 'mph',\n ms: 'm/s',\n kn: 'kn',\n};\n\nfunction closestHour(hourly: HourlyWeather[], targetTime: Date): HourlyWeather | undefined {\n return hourly.reduce<HourlyWeather | undefined>((closest, hour) => {\n const diff = Math.abs(new Date(hour.time).getTime() - targetTime.getTime());\n const closestDiff = closest ? Math.abs(new Date(closest.time).getTime() - targetTime.getTime()) : Infinity;\n return diff < closestDiff ? hour : closest;\n }, undefined);\n}\n\nconst styles = {\n root: {\n fontFamily: 'system-ui, sans-serif',\n border: '1px solid #e5e7eb',\n borderRadius: 12,\n padding: 16,\n background: '#fff',\n color: '#111827',\n maxWidth: 640,\n } as React.CSSProperties,\n row: { display: 'flex', alignItems: 'center', gap: 8 } as React.CSSProperties,\n hours: { display: 'flex', gap: 12, overflowX: 'auto', paddingBottom: 4 } as React.CSSProperties,\n hourCard: { minWidth: 72, textAlign: 'center' as const, padding: 8, borderRadius: 8, background: '#f9fafb' },\n dayRow: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 10, padding: '8px 0', borderBottom: '1px solid #f3f4f6' } as React.CSSProperties,\n compactRoot: { fontFamily: 'system-ui, sans-serif', display: 'flex', flexDirection: 'column', gap: 8, padding: '10px 14px', borderRadius: 8 } as React.CSSProperties,\n compactHeader: { display: 'flex', alignItems: 'center', gap: 10 } as React.CSSProperties,\n compactHeaderText: { display: 'flex', alignItems: 'baseline', gap: 8, flexWrap: 'wrap' } as React.CSSProperties,\n compactDateTime: { fontSize: 11, opacity: 0.7 } as React.CSSProperties,\n compactStats: { display: 'flex', flexWrap: 'wrap', gap: 12, fontSize: 12, opacity: 0.9 } as React.CSSProperties,\n compactStat: { display: 'flex', alignItems: 'center', gap: 4, whiteSpace: 'nowrap' } as React.CSSProperties,\n};\n\nexport function WeatherForecast(props: Props) {\n const { data, loading, error } = useWeatherForecast(props);\n\n if (loading) return null;\n if (error) return <div className={props.className} style={props.style}>Error: {error.message}</div>;\n if (!data) return <div className={props.className} style={props.style}>No forecast available.</div>;\n\n if (props.compact) {\n const now = new Date(data.current.time);\n const today = data.daily[0];\n const tomorrow = data.daily[1];\n const in6Hours = closestHour(data.hourly, new Date(now.getTime() + 6 * 60 * 60 * 1000));\n const windSpeedUnitLabel = WIND_SPEED_UNIT_LABELS[props.windSpeedUnit ?? 'mph'];\n\n return (\n <div className={props.className} style={{ ...styles.compactRoot, ...props.style }}>\n <div style={styles.compactHeader}>\n <WeatherIcon condition={data.current.icon} width={24} height={24} title=\"Current weather\" />\n <div>\n <div style={styles.compactHeaderText}>\n <strong style={{ fontSize: 16 }}>{data.current.temperature}°</strong>\n <span style={{ fontSize: 14, opacity: 0.8 }}>\n {data.location?.city || 'Current location'}\n </span>\n </div>\n <div style={styles.compactDateTime}>\n {now.toLocaleDateString([], { weekday: 'short', month: 'short', day: 'numeric' })}\n {' · '}\n {now.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' })}\n </div>\n </div>\n </div>\n\n <div style={styles.compactStats}>\n {today && (\n <span style={styles.compactStat}>\n <WeatherIcon condition={today.icon} width={16} height={16} title=\"Today's high and low\" />\n {today.max}° / {today.min}°\n </span>\n )}\n {tomorrow && (\n <span style={styles.compactStat}>\n <WeatherIcon condition={tomorrow.icon} width={16} height={16} title=\"Tomorrow\" />\n Tomorrow {tomorrow.max}°\n </span>\n )}\n <span style={styles.compactStat}>\n <WindIcon width={16} height={16} title=\"Wind speed\" />\n {data.current.windSpeed !== undefined ? `${Math.round(data.current.windSpeed)} ${windSpeedUnitLabel}` : '—'}\n </span>\n {in6Hours && (\n <span style={styles.compactStat}>\n <WeatherIcon condition={in6Hours.icon} width={16} height={16} title=\"In 6 hours\" />\n {in6Hours.temperature}° in 6h\n </span>\n )}\n </div>\n </div>\n );\n }\n\n return (\n <div className={props.className} style={{ ...styles.root, ...props.style }}>\n <div>\n <h3 style={{ margin: 0, fontSize: 20 }}>\n {data.location?.city || 'Current location'}\n {data.location?.region ? `, ${data.location.region}` : ''}\n </h3>\n <div style={{ ...styles.row, marginTop: 8 }}>\n <WeatherIcon condition={data.current.icon} width={28} height={28} title=\"Current weather\" />\n <strong style={{ fontSize: 28 }}>{data.current.temperature}°</strong>\n </div>\n </div>\n\n <div style={{ marginTop: 20 }}>\n <h4 style={{ margin: '0 0 10px 0' }}>Next hours</h4>\n <div style={styles.hours}>\n {data.hourly.slice(0, props.forecastHours ?? 12).map((hour) => (\n <div key={hour.time} style={styles.hourCard}>\n <div style={{ fontSize: 12 }}>{new Date(hour.time).toLocaleTimeString([], { hour: 'numeric' })}</div>\n <WeatherIcon condition={hour.icon} width={20} height={20} style={{ margin: '6px auto' }} />\n <div>{hour.temperature}°</div>\n </div>\n ))}\n </div>\n </div>\n\n <div style={{ marginTop: 20 }}>\n <h4 style={{ margin: '0 0 10px 0' }}>Next days</h4>\n <div>\n {data.daily.map((day) => (\n <div key={day.date} style={styles.dayRow}>\n <div style={{ width: 120 }}>{new Date(day.date).toLocaleDateString([], { weekday: 'short', month: 'short', day: 'numeric' })}</div>\n <Weat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I,IAAI,EAAE,mBAAmB,CAAC,GAAG,EAAE,SAAS,SAAS,OAAO,SAAS,KAAK,UAAU,CAAC,GAAE;AAAA,QAC7H,6CAAC,eAAY,WAAW,IAAI,MAAM,OAAO,IAAI,QAAQ,IAAI;AAAA,QACzD,8CAAC,SAAK;AAAA,cAAI;AAAA,UAAI;AAAA,UAAK,IAAI;AAAA,UAAI;AAAA,WAAC;AAAA,WAHpB,IAAI,IAId,CACD,GACH;AAAA,OACF;AAAA,KACF;AAEJ;","names":["res","data","import_jsx_runtime","import_jsx_runtime","import_jsx_runtime"]}
@@ -0,0 +1,87 @@
1
+ import React from 'react';
2
+
3
+ type TemperatureUnit = 'celsius' | 'fahrenheit';
4
+ type WindSpeedUnit = 'kmh' | 'mph' | 'ms' | 'kn';
5
+ type WeatherLocation = {
6
+ city?: string;
7
+ region?: string;
8
+ country?: string;
9
+ timezone?: string;
10
+ latitude: number;
11
+ longitude: number;
12
+ };
13
+ type WeatherCondition = 'sun' | 'cloud-sun' | 'clouds' | 'cloud-fog' | 'cloud-drizzle' | 'cloud-showers' | 'cloud-showers-heavy' | 'cloud-sleet' | 'cloud-snow' | 'snowflake' | 'cloud-bolt' | 'cloud-hail';
14
+ type CurrentWeather = {
15
+ time: string;
16
+ temperature: number;
17
+ weatherCode: number;
18
+ icon: WeatherCondition;
19
+ isDay?: number;
20
+ rain?: number;
21
+ showers?: number;
22
+ snowfall?: number;
23
+ windSpeed?: number;
24
+ };
25
+ type HourlyWeather = {
26
+ time: string;
27
+ temperature: number;
28
+ weatherCode: number;
29
+ precipitationProbability?: number;
30
+ rain?: number;
31
+ showers?: number;
32
+ snowfall?: number;
33
+ icon: WeatherCondition;
34
+ };
35
+ type DailyWeather = {
36
+ date: string;
37
+ min: number;
38
+ max: number;
39
+ weatherCode: number;
40
+ precipitationProbabilityMax?: number;
41
+ icon: WeatherCondition;
42
+ };
43
+ type WeatherForecastData = {
44
+ location?: WeatherLocation;
45
+ current: CurrentWeather;
46
+ hourly: HourlyWeather[];
47
+ daily: DailyWeather[];
48
+ };
49
+ type WeatherForecastOptions = {
50
+ latitude?: number;
51
+ longitude?: number;
52
+ location?: Partial<WeatherLocation>;
53
+ geoEndpoint?: string;
54
+ ip?: string;
55
+ forecastDays?: number;
56
+ forecastHours?: number;
57
+ temperatureUnit?: TemperatureUnit;
58
+ windSpeedUnit?: WindSpeedUnit;
59
+ };
60
+ type IconProps = React.SVGProps<SVGSVGElement> & {
61
+ title?: string;
62
+ };
63
+
64
+ declare function getWeatherIcon(code: number, isDay?: number): WeatherCondition;
65
+
66
+ declare function getClientLocation(geoEndpoint?: string, ip?: string): Promise<WeatherLocation>;
67
+
68
+ declare function getWeatherForecast(options?: WeatherForecastOptions): Promise<WeatherForecastData>;
69
+
70
+ declare function useWeatherForecast(options?: WeatherForecastOptions): {
71
+ data: WeatherForecastData | null;
72
+ error: Error | null;
73
+ loading: boolean;
74
+ };
75
+
76
+ declare function WeatherIcon({ condition, ...props }: IconProps & {
77
+ condition: WeatherCondition;
78
+ }): React.JSX.Element;
79
+
80
+ type Props = WeatherForecastOptions & {
81
+ className?: string;
82
+ style?: React.CSSProperties;
83
+ compact?: boolean;
84
+ };
85
+ declare function WeatherForecast(props: Props): React.JSX.Element | null;
86
+
87
+ export { type CurrentWeather, type DailyWeather, type HourlyWeather, type IconProps, type TemperatureUnit, type WeatherCondition, WeatherForecast, type WeatherForecastData, type WeatherForecastOptions, WeatherIcon, type WeatherLocation, type WindSpeedUnit, getClientLocation, getWeatherForecast, getWeatherIcon, useWeatherForecast };
@@ -0,0 +1,87 @@
1
+ import React from 'react';
2
+
3
+ type TemperatureUnit = 'celsius' | 'fahrenheit';
4
+ type WindSpeedUnit = 'kmh' | 'mph' | 'ms' | 'kn';
5
+ type WeatherLocation = {
6
+ city?: string;
7
+ region?: string;
8
+ country?: string;
9
+ timezone?: string;
10
+ latitude: number;
11
+ longitude: number;
12
+ };
13
+ type WeatherCondition = 'sun' | 'cloud-sun' | 'clouds' | 'cloud-fog' | 'cloud-drizzle' | 'cloud-showers' | 'cloud-showers-heavy' | 'cloud-sleet' | 'cloud-snow' | 'snowflake' | 'cloud-bolt' | 'cloud-hail';
14
+ type CurrentWeather = {
15
+ time: string;
16
+ temperature: number;
17
+ weatherCode: number;
18
+ icon: WeatherCondition;
19
+ isDay?: number;
20
+ rain?: number;
21
+ showers?: number;
22
+ snowfall?: number;
23
+ windSpeed?: number;
24
+ };
25
+ type HourlyWeather = {
26
+ time: string;
27
+ temperature: number;
28
+ weatherCode: number;
29
+ precipitationProbability?: number;
30
+ rain?: number;
31
+ showers?: number;
32
+ snowfall?: number;
33
+ icon: WeatherCondition;
34
+ };
35
+ type DailyWeather = {
36
+ date: string;
37
+ min: number;
38
+ max: number;
39
+ weatherCode: number;
40
+ precipitationProbabilityMax?: number;
41
+ icon: WeatherCondition;
42
+ };
43
+ type WeatherForecastData = {
44
+ location?: WeatherLocation;
45
+ current: CurrentWeather;
46
+ hourly: HourlyWeather[];
47
+ daily: DailyWeather[];
48
+ };
49
+ type WeatherForecastOptions = {
50
+ latitude?: number;
51
+ longitude?: number;
52
+ location?: Partial<WeatherLocation>;
53
+ geoEndpoint?: string;
54
+ ip?: string;
55
+ forecastDays?: number;
56
+ forecastHours?: number;
57
+ temperatureUnit?: TemperatureUnit;
58
+ windSpeedUnit?: WindSpeedUnit;
59
+ };
60
+ type IconProps = React.SVGProps<SVGSVGElement> & {
61
+ title?: string;
62
+ };
63
+
64
+ declare function getWeatherIcon(code: number, isDay?: number): WeatherCondition;
65
+
66
+ declare function getClientLocation(geoEndpoint?: string, ip?: string): Promise<WeatherLocation>;
67
+
68
+ declare function getWeatherForecast(options?: WeatherForecastOptions): Promise<WeatherForecastData>;
69
+
70
+ declare function useWeatherForecast(options?: WeatherForecastOptions): {
71
+ data: WeatherForecastData | null;
72
+ error: Error | null;
73
+ loading: boolean;
74
+ };
75
+
76
+ declare function WeatherIcon({ condition, ...props }: IconProps & {
77
+ condition: WeatherCondition;
78
+ }): React.JSX.Element;
79
+
80
+ type Props = WeatherForecastOptions & {
81
+ className?: string;
82
+ style?: React.CSSProperties;
83
+ compact?: boolean;
84
+ };
85
+ declare function WeatherForecast(props: Props): React.JSX.Element | null;
86
+
87
+ export { type CurrentWeather, type DailyWeather, type HourlyWeather, type IconProps, type TemperatureUnit, type WeatherCondition, WeatherForecast, type WeatherForecastData, type WeatherForecastOptions, WeatherIcon, type WeatherLocation, type WindSpeedUnit, getClientLocation, getWeatherForecast, getWeatherIcon, useWeatherForecast };
package/dist/index.js ADDED
@@ -0,0 +1,375 @@
1
+ // src/weatherCodes.ts
2
+ function getWeatherIcon(code, isDay = 1) {
3
+ if (code === 0) return "sun";
4
+ if ([1, 2].includes(code)) return isDay ? "cloud-sun" : "clouds";
5
+ if (code === 3) return "clouds";
6
+ if ([45, 48].includes(code)) return "cloud-fog";
7
+ if ([51, 53, 55, 56, 57].includes(code)) return "cloud-drizzle";
8
+ if ([61, 63].includes(code)) return "cloud-showers";
9
+ if ([65, 66, 67, 80, 81, 82].includes(code)) return "cloud-showers-heavy";
10
+ if ([71, 73, 75, 77, 85, 86].includes(code)) return "cloud-snow";
11
+ if (code === 95) return "cloud-bolt";
12
+ if ([96, 99].includes(code)) return "cloud-hail";
13
+ return "clouds";
14
+ }
15
+
16
+ // src/api/geolocation.ts
17
+ var DEFAULT_IP_API_URL = "http://ip-api.com/json/";
18
+ async function getClientLocation(geoEndpoint, ip) {
19
+ if (geoEndpoint) {
20
+ const url = ip ? `${geoEndpoint}?ip=${encodeURIComponent(ip)}` : geoEndpoint;
21
+ const res2 = await fetch(url);
22
+ if (!res2.ok) throw new Error(`Geolocation worker lookup failed: ${res2.status}`);
23
+ const data2 = await res2.json();
24
+ return {
25
+ city: data2.city,
26
+ region: data2.region,
27
+ country: data2.country,
28
+ timezone: data2.timezone,
29
+ latitude: Number(data2.latitude),
30
+ longitude: Number(data2.longitude)
31
+ };
32
+ }
33
+ const res = await fetch(`${DEFAULT_IP_API_URL}${ip ? encodeURIComponent(ip) : ""}`);
34
+ if (!res.ok) throw new Error(`ip-api lookup failed: ${res.status}`);
35
+ const data = await res.json();
36
+ if (data.status === "fail") {
37
+ throw new Error(`ip-api lookup failed: ${data.message ?? "unknown error"}`);
38
+ }
39
+ return {
40
+ city: data.city,
41
+ region: data.regionName,
42
+ country: data.country,
43
+ timezone: data.timezone,
44
+ latitude: Number(data.lat),
45
+ longitude: Number(data.lon)
46
+ };
47
+ }
48
+
49
+ // src/api/forecast.ts
50
+ function buildUrl(latitude, longitude, options) {
51
+ const params = new URLSearchParams({
52
+ latitude: String(latitude),
53
+ longitude: String(longitude),
54
+ timezone: options.location?.timezone || "auto",
55
+ temperature_unit: options.temperatureUnit || "fahrenheit",
56
+ wind_speed_unit: options.windSpeedUnit || "mph",
57
+ forecast_days: String(options.forecastDays ?? 5),
58
+ forecast_hours: String(options.forecastHours ?? 24),
59
+ current: [
60
+ "temperature_2m",
61
+ "weather_code",
62
+ "is_day",
63
+ "rain",
64
+ "showers",
65
+ "snowfall",
66
+ "wind_speed_10m"
67
+ ].join(","),
68
+ hourly: [
69
+ "temperature_2m",
70
+ "weather_code",
71
+ "precipitation_probability",
72
+ "rain",
73
+ "showers",
74
+ "snowfall"
75
+ ].join(","),
76
+ daily: [
77
+ "temperature_2m_max",
78
+ "temperature_2m_min",
79
+ "weather_code",
80
+ "precipitation_probability_max"
81
+ ].join(",")
82
+ });
83
+ return `https://api.open-meteo.com/v1/forecast?${params.toString()}`;
84
+ }
85
+ async function getWeatherForecast(options = {}) {
86
+ let location;
87
+ if (typeof options.latitude === "number" && typeof options.longitude === "number") {
88
+ location = {
89
+ ...options.location,
90
+ latitude: options.latitude,
91
+ longitude: options.longitude
92
+ };
93
+ } else {
94
+ location = await getClientLocation(options.geoEndpoint, options.ip);
95
+ }
96
+ const url = buildUrl(location.latitude, location.longitude, { ...options, location });
97
+ const response = await fetch(url, { headers: { "Content-Type": "application/json" } });
98
+ if (!response.ok) {
99
+ throw new Error(`Weather request failed: ${response.status} ${response.statusText}`);
100
+ }
101
+ const data = await response.json();
102
+ if (!data?.current || !data?.hourly || !data?.daily) {
103
+ throw new Error("Invalid weather response");
104
+ }
105
+ return {
106
+ location,
107
+ current: {
108
+ time: data.current.time,
109
+ temperature: Math.round(data.current.temperature_2m),
110
+ weatherCode: data.current.weather_code,
111
+ icon: getWeatherIcon(data.current.weather_code, data.current.is_day),
112
+ isDay: data.current.is_day,
113
+ rain: data.current.rain,
114
+ showers: data.current.showers,
115
+ snowfall: data.current.snowfall,
116
+ windSpeed: data.current.wind_speed_10m
117
+ },
118
+ hourly: data.hourly.time.map((time, index) => ({
119
+ time,
120
+ temperature: Math.round(data.hourly.temperature_2m[index]),
121
+ weatherCode: data.hourly.weather_code[index],
122
+ precipitationProbability: data.hourly.precipitation_probability?.[index],
123
+ rain: data.hourly.rain?.[index],
124
+ showers: data.hourly.showers?.[index],
125
+ snowfall: data.hourly.snowfall?.[index],
126
+ icon: getWeatherIcon(data.hourly.weather_code[index])
127
+ })),
128
+ daily: data.daily.time.map((date, index) => ({
129
+ date,
130
+ min: Math.round(data.daily.temperature_2m_min[index]),
131
+ max: Math.round(data.daily.temperature_2m_max[index]),
132
+ weatherCode: data.daily.weather_code[index],
133
+ precipitationProbabilityMax: data.daily.precipitation_probability_max?.[index],
134
+ icon: getWeatherIcon(data.daily.weather_code[index])
135
+ }))
136
+ };
137
+ }
138
+
139
+ // src/hooks/useWeatherForecast.ts
140
+ import { useEffect, useState } from "react";
141
+ function useWeatherForecast(options = {}) {
142
+ const [data, setData] = useState(null);
143
+ const [error, setError] = useState(null);
144
+ const [loading, setLoading] = useState(true);
145
+ useEffect(() => {
146
+ let active = true;
147
+ setLoading(true);
148
+ setError(null);
149
+ getWeatherForecast(options).then((result) => {
150
+ if (active) setData(result);
151
+ }).catch((err) => {
152
+ if (active) setError(err instanceof Error ? err : new Error("Unknown error"));
153
+ }).finally(() => {
154
+ if (active) setLoading(false);
155
+ });
156
+ return () => {
157
+ active = false;
158
+ };
159
+ }, [
160
+ options.latitude,
161
+ options.longitude,
162
+ options.geoEndpoint,
163
+ options.ip,
164
+ options.forecastDays,
165
+ options.forecastHours,
166
+ options.temperatureUnit,
167
+ options.windSpeedUnit,
168
+ options.location?.timezone
169
+ ]);
170
+ return { data, error, loading };
171
+ }
172
+
173
+ // src/icons/BaseIcon.tsx
174
+ import { jsx, jsxs } from "react/jsx-runtime";
175
+ function BaseIcon({ title, children, ...props }) {
176
+ return /* @__PURE__ */ jsxs(
177
+ "svg",
178
+ {
179
+ viewBox: "0 0 24 24",
180
+ fill: "none",
181
+ stroke: "currentColor",
182
+ strokeLinecap: "round",
183
+ strokeLinejoin: "round",
184
+ role: title ? "img" : "presentation",
185
+ "aria-hidden": title ? void 0 : true,
186
+ "aria-label": title,
187
+ ...props,
188
+ children: [
189
+ title ? /* @__PURE__ */ jsx("title", { children: title }) : null,
190
+ children
191
+ ]
192
+ }
193
+ );
194
+ }
195
+
196
+ // src/icons/weather-icons.tsx
197
+ import { jsx as jsx2 } from "react/jsx-runtime";
198
+ var CloudBoltIcon = (props) => /* @__PURE__ */ jsx2(BaseIcon, { ...props, children: /* @__PURE__ */ jsx2("path", { d: "M7 18a4.815 4.815 0 0 1-3.327-1.318A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 0 7h-1m-4.75-5L11 17.5h3.375l-2.25 4.5" }) });
199
+ var CloudDrizzleIcon = (props) => /* @__PURE__ */ jsx2(BaseIcon, { ...props, children: /* @__PURE__ */ jsx2("path", { d: "M12 18v1m-3-4v1m6-1v1m2 3v1M7 19v1m-3-3.034a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662" }) });
200
+ var CloudFogIcon = (props) => /* @__PURE__ */ jsx2(BaseIcon, { ...props, children: /* @__PURE__ */ jsx2("path", { d: "M4 16.966a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662M5 21h7m4 0h3M8 17h8" }) });
201
+ var CloudHailIcon = (props) => /* @__PURE__ */ jsx2(BaseIcon, { ...props, children: /* @__PURE__ */ jsx2("path", { d: "M8 17.45v.1m-1.5 3.9v.1m10.5-4.1v.1m-1.5 3.9v.1m-3-4.1v.1m-1.5 3.9v.1m10.475-4.575A3.5 3.5 0 0 0 19 11h-1c.146-.65.148-1.32.006-1.97a4.784 4.784 0 0 0-.831-1.823 5.36 5.36 0 0 0-1.544-1.398 5.964 5.964 0 0 0-2.02-.759 6.224 6.224 0 0 0-2.19-.006 5.971 5.971 0 0 0-2.024.749C8.157 6.533 7.295 7.687 7 9a4.815 4.815 0 0 0-3.327 1.318A4.403 4.403 0 0 0 2.295 13.5c0 1.194.496 2.338 1.378 3.182.105.1.214.195.327.284m4.5.534a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm-1.5 4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm10.5-4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm-1.5 4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm-3-4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm-1.5 4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Z" }) });
202
+ var CloudShowersIcon = (props) => /* @__PURE__ */ jsx2(BaseIcon, { ...props, children: /* @__PURE__ */ jsx2("path", { d: "M4 16.966a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662M12 13v2m0 3v2m4-5v2m0 3v2m-8-7v2m0 3v2" }) });
203
+ var CloudShowersHeavyIcon = (props) => /* @__PURE__ */ jsx2(BaseIcon, { ...props, children: /* @__PURE__ */ jsx2("path", { d: "M4 16.966a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662M16 15v6m-8-6v6m4-8v6" }) });
204
+ var CloudSleetIcon = (props) => /* @__PURE__ */ jsx2(BaseIcon, { ...props, children: /* @__PURE__ */ jsx2("path", { d: "M13.5 17.45a1 1 0 1 0-2 0h2Zm-2 .1a1 1 0 1 0 2 0h-2Zm.5 3.9a1 1 0 1 0-2 0h2Zm-2 .1a1 1 0 1 0 2 0h-2Zm-6.327-4.868.692-.723-.692.723ZM7 9v1a1 1 0 0 0 .976-.781L7 9Zm2.397-3.207.512.858-.512-.858ZM18 11l-.976-.219A1 1 0 0 0 18 12v-1Zm2.768 5.268a1 1 0 0 0 1.414 1.414l-.707-.707-.707-.707ZM3.379 17.75a1 1 0 0 0 1.242-1.567L4 16.966l-.62.784Zm5.55-.379a1 1 0 0 0-1.857-.742L8 17l.928.371ZM5.071 21.63a1 1 0 0 0 1.856.742L6 22l-.928-.371Zm13.857-4.258a1 1 0 0 0-1.857-.742L18 17l.928.371Zm-3.857 4.258a1 1 0 0 0 1.857.742L16 22l-.928-.371ZM13 17.5h-1a.5.5 0 0 1 .5-.5v2a1.5 1.5 0 0 0 1.5-1.5h-1Zm-.5.5v-1a.5.5 0 0 1 .5.5h-2a1.5 1.5 0 0 0 1.5 1.5v-1Zm-.5-.5h1a.5.5 0 0 1-.5.5v-2a1.5 1.5 0 0 0-1.5 1.5h1Zm.5-.5v1a.5.5 0 0 1-.5-.5h2a1.5 1.5 0 0 0-1.5-1.5v1Zm0 .45h-1v.1h2v-.1h-1Zm-1 4.05h-1a.5.5 0 0 1 .5-.5v2a1.5 1.5 0 0 0 1.5-1.5h-1Zm-.5.5v-1a.5.5 0 0 1 .5.5h-2A1.5 1.5 0 0 0 11 23v-1Zm-.5-.5h1a.5.5 0 0 1-.5.5v-2a1.5 1.5 0 0 0-1.5 1.5h1Zm.5-.5v1a.5.5 0 0 1-.5-.5h2A1.5 1.5 0 0 0 11 20v1Zm0 .45h-1v.1h2v-.1h-1Zm-7.327-4.768.692-.723a3.403 3.403 0 0 1-1.07-2.459h-2c0 1.473.613 2.877 1.687 3.905l.691-.723ZM2.295 13.5h1c0-.914.38-1.8 1.07-2.46l-.692-.722-.69-.723A5.403 5.403 0 0 0 1.294 13.5h1Zm1.378-3.182.692.723A3.815 3.815 0 0 1 7 10V8c-1.499 0-2.945.57-4.018 1.595l.691.723ZM7 9l.976.219c.23-1.024.91-1.956 1.933-2.568l-.512-.858-.513-.859c-1.456.87-2.5 2.245-2.86 3.847L7 9Zm2.397-3.207.512.858a4.972 4.972 0 0 1 1.686-.622l-.173-.985-.174-.985a6.971 6.971 0 0 0-2.364.875l.513.859Zm2.025-.749.173.985a5.223 5.223 0 0 1 1.837.005l.18-.984.178-.984a7.223 7.223 0 0 0-2.542-.007l.174.985Zm2.19.006-.18.984c.606.11 1.177.326 1.681.631l.518-.856.518-.855a6.963 6.963 0 0 0-2.359-.888l-.179.984Zm2.02.76-.519.855c.505.305.93.693 1.257 1.136l.805-.594.805-.594a6.361 6.361 0 0 0-1.831-1.659l-.518.855Zm1.543 1.397-.805.594c.326.442.549.932.66 1.441l.976-.212.978-.213a5.786 5.786 0 0 0-1.005-2.204l-.804.594Zm.831 1.823-.977.212c.111.509.11 1.031-.005 1.539L18 11l.976.219c.178-.792.18-1.609.008-2.402l-.978.213ZM18 11v1h1v-2h-1v1Zm1 0v1a2.5 2.5 0 0 1 1.768.732l.707-.707.707-.707A4.5 4.5 0 0 0 19 10v1Zm2.475 1.025-.707.707A2.5 2.5 0 0 1 21.5 14.5h2a4.5 4.5 0 0 0-1.318-3.182l-.707.707ZM22.5 14.5h-1a2.5 2.5 0 0 1-.732 1.768l.707.707.707.707A4.5 4.5 0 0 0 23.5 14.5h-1ZM4 16.966l.62-.784a3.684 3.684 0 0 1-.255-.223l-.692.723-.69.723c.126.121.259.237.396.345L4 16.966ZM8 17l-.928-.371-2 5L6 22l.928.371 2-5L8 17Zm10 0-.928-.371-2 5L16 22l.928.371 2-5L18 17Z" }) });
205
+ var CloudSnowIcon = (props) => /* @__PURE__ */ jsx2(BaseIcon, { ...props, children: /* @__PURE__ */ jsx2("path", { d: "M8 15h2m-1-1v2m5-1h2m-1-1v2M5 21h2m-1-1v2m5-2h2m-1-1v2m5 0h2m-1-1v2M4 16.966a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662" }) });
206
+ var CloudSunIcon = (props) => /* @__PURE__ */ jsx2(BaseIcon, { ...props, children: /* @__PURE__ */ jsx2("path", { d: "M10.201 19.997c-1.977 0-3.58-1.544-3.58-3.448 0-1.903 1.603-3.446 3.58-3.446.303-1.355 1.38-2.461 2.827-2.902 1.445-.44 3.042-.148 4.186.77 1.144.915 1.663 2.312 1.361 3.667h.761c1.472 0 2.664 1.2 2.664 2.68A2.672 2.672 0 0 1 19.336 20h-9.134m2.66-12.934a4.166 4.166 0 0 0-2.677-1.732m2.677 1.732 2.744-1.892m-2.744 1.892c.55.796.802 1.754.723 2.709m-3.4-4.44a4.167 4.167 0 0 0-3.118.667m3.118-.668.602-3.278m-3.72 3.946A4.167 4.167 0 0 0 5.334 8.68m1.733-2.678L5.174 3.26m.16 5.42c-.2 1.088.041 2.21.669 3.12m-.669-3.12-3.278-.601m3.947 3.72-2.744 1.893m2.744-1.893a4.167 4.167 0 0 0 2.174 1.607" }) });
207
+ var CloudsIcon = (props) => /* @__PURE__ */ jsx2(BaseIcon, { ...props, children: /* @__PURE__ */ jsx2("path", { d: "M8.958 21.05C6.772 21.05 5 19.344 5 17.24s1.772-3.81 3.958-3.81c.335-1.498 1.525-2.72 3.124-3.207 1.598-.487 3.363-.164 4.628.85 1.264 1.011 1.837 2.556 1.504 4.053h.842A2.953 2.953 0 0 1 22 18.09a2.954 2.954 0 0 1-2.945 2.964H8.958M18 8c-.5-2.5-3.532-3.401-5.5-2.5a3.117 3.117 0 0 0-2.11-2.312c-1.352-.411-2.845-.138-3.915.72-1.07.855-1.554 2.161-1.273 3.428h-.711A2.498 2.498 0 0 0 2 9.843c0 1.094.695 2.023 1.666 2.366" }) });
208
+ var SnowflakeIcon = (props) => /* @__PURE__ */ jsx2(BaseIcon, { ...props, children: /* @__PURE__ */ jsx2("path", { d: "m9.25 4-1 2H6m-2.25 4L5 12m0 0-1.25 2M5 12h3m-3 0H2.5m17.75-2L19 12l1.25 2M6 18h2.25l1 2M14 9h-4m4 0 3-5m-3 5 2 3m-6-3L7 4m3 5-2 3m0 0 2 3m0 0-3 5m3-5h4m2-3-2 3m2-3h5.5M14 15l3 5M14.75 4l1 2H18m0 12h-2.25l-1 2" }) });
209
+ var SunIcon = (props) => /* @__PURE__ */ jsx2(BaseIcon, { ...props, children: /* @__PURE__ */ jsx2("path", { d: "M12 4V2m0 20v-2m10-8h-2M4 12H2m15.657-5.657 1.414-1.414M4.93 19.07l1.414-1.414m12.728 1.414-1.414-1.414M6.343 6.343 4.93 4.929M7 12a5 5 0 1 0 10 0 5 5 0 0 0-10 0Z" }) });
210
+ var WindIcon = (props) => /* @__PURE__ */ jsx2(BaseIcon, { ...props, children: /* @__PURE__ */ jsx2("path", { d: "M9.59 4.59A2 2 0 1 1 11 8H2m10.59 11.41A2 2 0 1 0 14 16H2m15.73-8.27A2.5 2.5 0 1 1 19.5 12H2" }) });
211
+
212
+ // src/icons/WeatherIcon.tsx
213
+ import { jsx as jsx3 } from "react/jsx-runtime";
214
+ var iconMap = {
215
+ sun: SunIcon,
216
+ "cloud-sun": CloudSunIcon,
217
+ clouds: CloudsIcon,
218
+ "cloud-fog": CloudFogIcon,
219
+ "cloud-drizzle": CloudDrizzleIcon,
220
+ "cloud-showers": CloudShowersIcon,
221
+ "cloud-showers-heavy": CloudShowersHeavyIcon,
222
+ "cloud-sleet": CloudSleetIcon,
223
+ "cloud-snow": CloudSnowIcon,
224
+ snowflake: SnowflakeIcon,
225
+ "cloud-bolt": CloudBoltIcon,
226
+ "cloud-hail": CloudHailIcon
227
+ };
228
+ function WeatherIcon({ condition, ...props }) {
229
+ const Icon = iconMap[condition] || CloudsIcon;
230
+ return /* @__PURE__ */ jsx3(Icon, { ...props });
231
+ }
232
+
233
+ // src/components/WeatherForecast.tsx
234
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
235
+ var WIND_SPEED_UNIT_LABELS = {
236
+ kmh: "km/h",
237
+ mph: "mph",
238
+ ms: "m/s",
239
+ kn: "kn"
240
+ };
241
+ function closestHour(hourly, targetTime) {
242
+ return hourly.reduce((closest, hour) => {
243
+ const diff = Math.abs(new Date(hour.time).getTime() - targetTime.getTime());
244
+ const closestDiff = closest ? Math.abs(new Date(closest.time).getTime() - targetTime.getTime()) : Infinity;
245
+ return diff < closestDiff ? hour : closest;
246
+ }, void 0);
247
+ }
248
+ var styles = {
249
+ root: {
250
+ fontFamily: "system-ui, sans-serif",
251
+ border: "1px solid #e5e7eb",
252
+ borderRadius: 12,
253
+ padding: 16,
254
+ background: "#fff",
255
+ color: "#111827",
256
+ maxWidth: 640
257
+ },
258
+ row: { display: "flex", alignItems: "center", gap: 8 },
259
+ hours: { display: "flex", gap: 12, overflowX: "auto", paddingBottom: 4 },
260
+ hourCard: { minWidth: 72, textAlign: "center", padding: 8, borderRadius: 8, background: "#f9fafb" },
261
+ dayRow: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 10, padding: "8px 0", borderBottom: "1px solid #f3f4f6" },
262
+ compactRoot: { fontFamily: "system-ui, sans-serif", display: "flex", flexDirection: "column", gap: 8, padding: "10px 14px", borderRadius: 8 },
263
+ compactHeader: { display: "flex", alignItems: "center", gap: 10 },
264
+ compactHeaderText: { display: "flex", alignItems: "baseline", gap: 8, flexWrap: "wrap" },
265
+ compactDateTime: { fontSize: 11, opacity: 0.7 },
266
+ compactStats: { display: "flex", flexWrap: "wrap", gap: 12, fontSize: 12, opacity: 0.9 },
267
+ compactStat: { display: "flex", alignItems: "center", gap: 4, whiteSpace: "nowrap" }
268
+ };
269
+ function WeatherForecast(props) {
270
+ const { data, loading, error } = useWeatherForecast(props);
271
+ if (loading) return null;
272
+ if (error) return /* @__PURE__ */ jsxs2("div", { className: props.className, style: props.style, children: [
273
+ "Error: ",
274
+ error.message
275
+ ] });
276
+ if (!data) return /* @__PURE__ */ jsx4("div", { className: props.className, style: props.style, children: "No forecast available." });
277
+ if (props.compact) {
278
+ const now = new Date(data.current.time);
279
+ const today = data.daily[0];
280
+ const tomorrow = data.daily[1];
281
+ const in6Hours = closestHour(data.hourly, new Date(now.getTime() + 6 * 60 * 60 * 1e3));
282
+ const windSpeedUnitLabel = WIND_SPEED_UNIT_LABELS[props.windSpeedUnit ?? "mph"];
283
+ return /* @__PURE__ */ jsxs2("div", { className: props.className, style: { ...styles.compactRoot, ...props.style }, children: [
284
+ /* @__PURE__ */ jsxs2("div", { style: styles.compactHeader, children: [
285
+ /* @__PURE__ */ jsx4(WeatherIcon, { condition: data.current.icon, width: 24, height: 24, title: "Current weather" }),
286
+ /* @__PURE__ */ jsxs2("div", { children: [
287
+ /* @__PURE__ */ jsxs2("div", { style: styles.compactHeaderText, children: [
288
+ /* @__PURE__ */ jsxs2("strong", { style: { fontSize: 16 }, children: [
289
+ data.current.temperature,
290
+ "\xB0"
291
+ ] }),
292
+ /* @__PURE__ */ jsx4("span", { style: { fontSize: 14, opacity: 0.8 }, children: data.location?.city || "Current location" })
293
+ ] }),
294
+ /* @__PURE__ */ jsxs2("div", { style: styles.compactDateTime, children: [
295
+ now.toLocaleDateString([], { weekday: "short", month: "short", day: "numeric" }),
296
+ " \xB7 ",
297
+ now.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" })
298
+ ] })
299
+ ] })
300
+ ] }),
301
+ /* @__PURE__ */ jsxs2("div", { style: styles.compactStats, children: [
302
+ today && /* @__PURE__ */ jsxs2("span", { style: styles.compactStat, children: [
303
+ /* @__PURE__ */ jsx4(WeatherIcon, { condition: today.icon, width: 16, height: 16, title: "Today's high and low" }),
304
+ today.max,
305
+ "\xB0 / ",
306
+ today.min,
307
+ "\xB0"
308
+ ] }),
309
+ tomorrow && /* @__PURE__ */ jsxs2("span", { style: styles.compactStat, children: [
310
+ /* @__PURE__ */ jsx4(WeatherIcon, { condition: tomorrow.icon, width: 16, height: 16, title: "Tomorrow" }),
311
+ "Tomorrow ",
312
+ tomorrow.max,
313
+ "\xB0"
314
+ ] }),
315
+ /* @__PURE__ */ jsxs2("span", { style: styles.compactStat, children: [
316
+ /* @__PURE__ */ jsx4(WindIcon, { width: 16, height: 16, title: "Wind speed" }),
317
+ data.current.windSpeed !== void 0 ? `${Math.round(data.current.windSpeed)} ${windSpeedUnitLabel}` : "\u2014"
318
+ ] }),
319
+ in6Hours && /* @__PURE__ */ jsxs2("span", { style: styles.compactStat, children: [
320
+ /* @__PURE__ */ jsx4(WeatherIcon, { condition: in6Hours.icon, width: 16, height: 16, title: "In 6 hours" }),
321
+ in6Hours.temperature,
322
+ "\xB0 in 6h"
323
+ ] })
324
+ ] })
325
+ ] });
326
+ }
327
+ return /* @__PURE__ */ jsxs2("div", { className: props.className, style: { ...styles.root, ...props.style }, children: [
328
+ /* @__PURE__ */ jsxs2("div", { children: [
329
+ /* @__PURE__ */ jsxs2("h3", { style: { margin: 0, fontSize: 20 }, children: [
330
+ data.location?.city || "Current location",
331
+ data.location?.region ? `, ${data.location.region}` : ""
332
+ ] }),
333
+ /* @__PURE__ */ jsxs2("div", { style: { ...styles.row, marginTop: 8 }, children: [
334
+ /* @__PURE__ */ jsx4(WeatherIcon, { condition: data.current.icon, width: 28, height: 28, title: "Current weather" }),
335
+ /* @__PURE__ */ jsxs2("strong", { style: { fontSize: 28 }, children: [
336
+ data.current.temperature,
337
+ "\xB0"
338
+ ] })
339
+ ] })
340
+ ] }),
341
+ /* @__PURE__ */ jsxs2("div", { style: { marginTop: 20 }, children: [
342
+ /* @__PURE__ */ jsx4("h4", { style: { margin: "0 0 10px 0" }, children: "Next hours" }),
343
+ /* @__PURE__ */ jsx4("div", { style: styles.hours, children: data.hourly.slice(0, props.forecastHours ?? 12).map((hour) => /* @__PURE__ */ jsxs2("div", { style: styles.hourCard, children: [
344
+ /* @__PURE__ */ jsx4("div", { style: { fontSize: 12 }, children: new Date(hour.time).toLocaleTimeString([], { hour: "numeric" }) }),
345
+ /* @__PURE__ */ jsx4(WeatherIcon, { condition: hour.icon, width: 20, height: 20, style: { margin: "6px auto" } }),
346
+ /* @__PURE__ */ jsxs2("div", { children: [
347
+ hour.temperature,
348
+ "\xB0"
349
+ ] })
350
+ ] }, hour.time)) })
351
+ ] }),
352
+ /* @__PURE__ */ jsxs2("div", { style: { marginTop: 20 }, children: [
353
+ /* @__PURE__ */ jsx4("h4", { style: { margin: "0 0 10px 0" }, children: "Next days" }),
354
+ /* @__PURE__ */ jsx4("div", { children: data.daily.map((day) => /* @__PURE__ */ jsxs2("div", { style: styles.dayRow, children: [
355
+ /* @__PURE__ */ jsx4("div", { style: { width: 120 }, children: new Date(day.date).toLocaleDateString([], { weekday: "short", month: "short", day: "numeric" }) }),
356
+ /* @__PURE__ */ jsx4(WeatherIcon, { condition: day.icon, width: 20, height: 20 }),
357
+ /* @__PURE__ */ jsxs2("div", { children: [
358
+ day.min,
359
+ "\xB0 / ",
360
+ day.max,
361
+ "\xB0"
362
+ ] })
363
+ ] }, day.date)) })
364
+ ] })
365
+ ] });
366
+ }
367
+ export {
368
+ WeatherForecast,
369
+ WeatherIcon,
370
+ getClientLocation,
371
+ getWeatherForecast,
372
+ getWeatherIcon,
373
+ useWeatherForecast
374
+ };
375
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/weatherCodes.ts","../src/api/geolocation.ts","../src/api/forecast.ts","../src/hooks/useWeatherForecast.ts","../src/icons/BaseIcon.tsx","../src/icons/weather-icons.tsx","../src/icons/WeatherIcon.tsx","../src/components/WeatherForecast.tsx"],"sourcesContent":["import type { WeatherCondition } from './types';\n\nexport function getWeatherIcon(code: number, isDay = 1): WeatherCondition {\n if (code === 0) return 'sun';\n if ([1, 2].includes(code)) return isDay ? 'cloud-sun' : 'clouds';\n if (code === 3) return 'clouds';\n if ([45, 48].includes(code)) return 'cloud-fog';\n if ([51, 53, 55, 56, 57].includes(code)) return 'cloud-drizzle';\n if ([61, 63].includes(code)) return 'cloud-showers';\n if ([65, 66, 67, 80, 81, 82].includes(code)) return 'cloud-showers-heavy';\n if ([71, 73, 75, 77, 85, 86].includes(code)) return 'cloud-snow';\n if (code === 95) return 'cloud-bolt';\n if ([96, 99].includes(code)) return 'cloud-hail';\n return 'clouds';\n}\n","import type { WeatherLocation } from '../types';\n\n// ip-api.com's free tier only serves plain HTTP (HTTPS requires their paid plan),\n// so this default will be blocked as mixed content on pages served over HTTPS.\n// Deploy worker/geo-worker.ts and pass its URL as `geoEndpoint` to avoid that.\nconst DEFAULT_IP_API_URL = 'http://ip-api.com/json/';\n\ntype IpApiResponse = {\n status: 'success' | 'fail';\n city?: string;\n regionName?: string;\n country?: string;\n timezone?: string;\n lat?: number;\n lon?: number;\n message?: string;\n};\n\ntype GeoWorkerResponse = {\n city?: string;\n region?: string;\n country?: string;\n timezone?: string;\n latitude?: number | string;\n longitude?: number | string;\n};\n\nexport async function getClientLocation(geoEndpoint?: string, ip?: string): Promise<WeatherLocation> {\n if (geoEndpoint) {\n const url = ip ? `${geoEndpoint}?ip=${encodeURIComponent(ip)}` : geoEndpoint;\n const res = await fetch(url);\n if (!res.ok) throw new Error(`Geolocation worker lookup failed: ${res.status}`);\n const data: GeoWorkerResponse = await res.json();\n\n return {\n city: data.city,\n region: data.region,\n country: data.country,\n timezone: data.timezone,\n latitude: Number(data.latitude),\n longitude: Number(data.longitude),\n };\n }\n\n const res = await fetch(`${DEFAULT_IP_API_URL}${ip ? encodeURIComponent(ip) : ''}`);\n if (!res.ok) throw new Error(`ip-api lookup failed: ${res.status}`);\n const data: IpApiResponse = await res.json();\n\n if (data.status === 'fail') {\n throw new Error(`ip-api lookup failed: ${data.message ?? 'unknown error'}`);\n }\n\n return {\n city: data.city,\n region: data.regionName,\n country: data.country,\n timezone: data.timezone,\n latitude: Number(data.lat),\n longitude: Number(data.lon),\n };\n}\n","import type { WeatherForecastData, WeatherForecastOptions, WeatherLocation } from '../types';\nimport { getWeatherIcon } from '../weatherCodes';\nimport { getClientLocation } from './geolocation';\n\nfunction buildUrl(latitude: number, longitude: number, options: WeatherForecastOptions) {\n const params = new URLSearchParams({\n latitude: String(latitude),\n longitude: String(longitude),\n timezone: options.location?.timezone || 'auto',\n temperature_unit: options.temperatureUnit || 'fahrenheit',\n wind_speed_unit: options.windSpeedUnit || 'mph',\n forecast_days: String(options.forecastDays ?? 5),\n forecast_hours: String(options.forecastHours ?? 24),\n current: [\n 'temperature_2m',\n 'weather_code',\n 'is_day',\n 'rain',\n 'showers',\n 'snowfall',\n 'wind_speed_10m',\n ].join(','),\n hourly: [\n 'temperature_2m',\n 'weather_code',\n 'precipitation_probability',\n 'rain',\n 'showers',\n 'snowfall',\n ].join(','),\n daily: [\n 'temperature_2m_max',\n 'temperature_2m_min',\n 'weather_code',\n 'precipitation_probability_max',\n ].join(','),\n });\n\n return `https://api.open-meteo.com/v1/forecast?${params.toString()}`;\n}\n\nexport async function getWeatherForecast(\n options: WeatherForecastOptions = {}\n): Promise<WeatherForecastData> {\n let location: WeatherLocation;\n\n if (typeof options.latitude === 'number' && typeof options.longitude === 'number') {\n location = {\n ...options.location,\n latitude: options.latitude,\n longitude: options.longitude,\n };\n } else {\n location = await getClientLocation(options.geoEndpoint, options.ip);\n }\n\n const url = buildUrl(location.latitude, location.longitude, { ...options, location });\n const response = await fetch(url, { headers: { 'Content-Type': 'application/json' } });\n\n if (!response.ok) {\n throw new Error(`Weather request failed: ${response.status} ${response.statusText}`);\n }\n\n const data = await response.json();\n\n if (!data?.current || !data?.hourly || !data?.daily) {\n throw new Error('Invalid weather response');\n }\n\n return {\n location,\n current: {\n time: data.current.time,\n temperature: Math.round(data.current.temperature_2m),\n weatherCode: data.current.weather_code,\n icon: getWeatherIcon(data.current.weather_code, data.current.is_day),\n isDay: data.current.is_day,\n rain: data.current.rain,\n showers: data.current.showers,\n snowfall: data.current.snowfall,\n windSpeed: data.current.wind_speed_10m,\n },\n hourly: data.hourly.time.map((time: string, index: number) => ({\n time,\n temperature: Math.round(data.hourly.temperature_2m[index]),\n weatherCode: data.hourly.weather_code[index],\n precipitationProbability: data.hourly.precipitation_probability?.[index],\n rain: data.hourly.rain?.[index],\n showers: data.hourly.showers?.[index],\n snowfall: data.hourly.snowfall?.[index],\n icon: getWeatherIcon(data.hourly.weather_code[index]),\n })),\n daily: data.daily.time.map((date: string, index: number) => ({\n date,\n min: Math.round(data.daily.temperature_2m_min[index]),\n max: Math.round(data.daily.temperature_2m_max[index]),\n weatherCode: data.daily.weather_code[index],\n precipitationProbabilityMax: data.daily.precipitation_probability_max?.[index],\n icon: getWeatherIcon(data.daily.weather_code[index]),\n })),\n };\n}\n","import { useEffect, useState } from 'react';\nimport type { WeatherForecastData, WeatherForecastOptions } from '../types';\nimport { getWeatherForecast } from '../api/forecast';\n\nexport function useWeatherForecast(options: WeatherForecastOptions = {}) {\n const [data, setData] = useState<WeatherForecastData | null>(null);\n const [error, setError] = useState<Error | null>(null);\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n let active = true;\n setLoading(true);\n setError(null);\n\n getWeatherForecast(options)\n .then((result) => { if (active) setData(result); })\n .catch((err) => { if (active) setError(err instanceof Error ? err : new Error('Unknown error')); })\n .finally(() => { if (active) setLoading(false); });\n\n return () => { active = false; };\n }, [\n options.latitude,\n options.longitude,\n options.geoEndpoint,\n options.ip,\n options.forecastDays,\n options.forecastHours,\n options.temperatureUnit,\n options.windSpeedUnit,\n options.location?.timezone,\n ]);\n\n return { data, error, loading };\n}\n","import React from 'react';\nimport type { IconProps } from '../types';\n\nexport function BaseIcon({ title, children, ...props }: IconProps & { children: React.ReactNode }) {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n role={title ? 'img' : 'presentation'}\n aria-hidden={title ? undefined : true}\n aria-label={title}\n {...props}\n >\n {title ? <title>{title}</title> : null}\n {children}\n </svg>\n );\n}\n","import React from 'react';\nimport type { IconProps } from '../types';\nimport { BaseIcon } from './BaseIcon';\n\nexport const CloudBoltIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M7 18a4.815 4.815 0 0 1-3.327-1.318A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 0 7h-1m-4.75-5L11 17.5h3.375l-2.25 4.5\" /></BaseIcon>\n);\nexport const CloudDrizzleIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M12 18v1m-3-4v1m6-1v1m2 3v1M7 19v1m-3-3.034a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662\" /></BaseIcon>\n);\nexport const CloudFogIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M4 16.966a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662M5 21h7m4 0h3M8 17h8\" /></BaseIcon>\n);\nexport const CloudHailIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M8 17.45v.1m-1.5 3.9v.1m10.5-4.1v.1m-1.5 3.9v.1m-3-4.1v.1m-1.5 3.9v.1m10.475-4.575A3.5 3.5 0 0 0 19 11h-1c.146-.65.148-1.32.006-1.97a4.784 4.784 0 0 0-.831-1.823 5.36 5.36 0 0 0-1.544-1.398 5.964 5.964 0 0 0-2.02-.759 6.224 6.224 0 0 0-2.19-.006 5.971 5.971 0 0 0-2.024.749C8.157 6.533 7.295 7.687 7 9a4.815 4.815 0 0 0-3.327 1.318A4.403 4.403 0 0 0 2.295 13.5c0 1.194.496 2.338 1.378 3.182.105.1.214.195.327.284m4.5.534a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm-1.5 4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm10.5-4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm-1.5 4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm-3-4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm-1.5 4a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Z\" /></BaseIcon>\n);\nexport const CloudShowersIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M4 16.966a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662M12 13v2m0 3v2m4-5v2m0 3v2m-8-7v2m0 3v2\" /></BaseIcon>\n);\nexport const CloudShowersHeavyIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M4 16.966a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662M16 15v6m-8-6v6m4-8v6\" /></BaseIcon>\n);\nexport const CloudSleetIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M13.5 17.45a1 1 0 1 0-2 0h2Zm-2 .1a1 1 0 1 0 2 0h-2Zm.5 3.9a1 1 0 1 0-2 0h2Zm-2 .1a1 1 0 1 0 2 0h-2Zm-6.327-4.868.692-.723-.692.723ZM7 9v1a1 1 0 0 0 .976-.781L7 9Zm2.397-3.207.512.858-.512-.858ZM18 11l-.976-.219A1 1 0 0 0 18 12v-1Zm2.768 5.268a1 1 0 0 0 1.414 1.414l-.707-.707-.707-.707ZM3.379 17.75a1 1 0 0 0 1.242-1.567L4 16.966l-.62.784Zm5.55-.379a1 1 0 0 0-1.857-.742L8 17l.928.371ZM5.071 21.63a1 1 0 0 0 1.856.742L6 22l-.928-.371Zm13.857-4.258a1 1 0 0 0-1.857-.742L18 17l.928.371Zm-3.857 4.258a1 1 0 0 0 1.857.742L16 22l-.928-.371ZM13 17.5h-1a.5.5 0 0 1 .5-.5v2a1.5 1.5 0 0 0 1.5-1.5h-1Zm-.5.5v-1a.5.5 0 0 1 .5.5h-2a1.5 1.5 0 0 0 1.5 1.5v-1Zm-.5-.5h1a.5.5 0 0 1-.5.5v-2a1.5 1.5 0 0 0-1.5 1.5h1Zm.5-.5v1a.5.5 0 0 1-.5-.5h2a1.5 1.5 0 0 0-1.5-1.5v1Zm0 .45h-1v.1h2v-.1h-1Zm-1 4.05h-1a.5.5 0 0 1 .5-.5v2a1.5 1.5 0 0 0 1.5-1.5h-1Zm-.5.5v-1a.5.5 0 0 1 .5.5h-2A1.5 1.5 0 0 0 11 23v-1Zm-.5-.5h1a.5.5 0 0 1-.5.5v-2a1.5 1.5 0 0 0-1.5 1.5h1Zm.5-.5v1a.5.5 0 0 1-.5-.5h2A1.5 1.5 0 0 0 11 20v1Zm0 .45h-1v.1h2v-.1h-1Zm-7.327-4.768.692-.723a3.403 3.403 0 0 1-1.07-2.459h-2c0 1.473.613 2.877 1.687 3.905l.691-.723ZM2.295 13.5h1c0-.914.38-1.8 1.07-2.46l-.692-.722-.69-.723A5.403 5.403 0 0 0 1.294 13.5h1Zm1.378-3.182.692.723A3.815 3.815 0 0 1 7 10V8c-1.499 0-2.945.57-4.018 1.595l.691.723ZM7 9l.976.219c.23-1.024.91-1.956 1.933-2.568l-.512-.858-.513-.859c-1.456.87-2.5 2.245-2.86 3.847L7 9Zm2.397-3.207.512.858a4.972 4.972 0 0 1 1.686-.622l-.173-.985-.174-.985a6.971 6.971 0 0 0-2.364.875l.513.859Zm2.025-.749.173.985a5.223 5.223 0 0 1 1.837.005l.18-.984.178-.984a7.223 7.223 0 0 0-2.542-.007l.174.985Zm2.19.006-.18.984c.606.11 1.177.326 1.681.631l.518-.856.518-.855a6.963 6.963 0 0 0-2.359-.888l-.179.984Zm2.02.76-.519.855c.505.305.93.693 1.257 1.136l.805-.594.805-.594a6.361 6.361 0 0 0-1.831-1.659l-.518.855Zm1.543 1.397-.805.594c.326.442.549.932.66 1.441l.976-.212.978-.213a5.786 5.786 0 0 0-1.005-2.204l-.804.594Zm.831 1.823-.977.212c.111.509.11 1.031-.005 1.539L18 11l.976.219c.178-.792.18-1.609.008-2.402l-.978.213ZM18 11v1h1v-2h-1v1Zm1 0v1a2.5 2.5 0 0 1 1.768.732l.707-.707.707-.707A4.5 4.5 0 0 0 19 10v1Zm2.475 1.025-.707.707A2.5 2.5 0 0 1 21.5 14.5h2a4.5 4.5 0 0 0-1.318-3.182l-.707.707ZM22.5 14.5h-1a2.5 2.5 0 0 1-.732 1.768l.707.707.707.707A4.5 4.5 0 0 0 23.5 14.5h-1ZM4 16.966l.62-.784a3.684 3.684 0 0 1-.255-.223l-.692.723-.69.723c.126.121.259.237.396.345L4 16.966ZM8 17l-.928-.371-2 5L6 22l.928.371 2-5L8 17Zm10 0-.928-.371-2 5L16 22l.928.371 2-5L18 17Z\" /></BaseIcon>\n);\nexport const CloudSnowIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M8 15h2m-1-1v2m5-1h2m-1-1v2M5 21h2m-1-1v2m5-2h2m-1-1v2m5 0h2m-1-1v2M4 16.966a4.63 4.63 0 0 1-.327-.284A4.403 4.403 0 0 1 2.295 13.5c0-1.194.496-2.338 1.378-3.182A4.815 4.815 0 0 1 7 9c.295-1.313 1.157-2.466 2.397-3.207a5.971 5.971 0 0 1 2.025-.749 6.224 6.224 0 0 1 2.19.006c.721.131 1.408.39 2.02.76a5.36 5.36 0 0 1 1.543 1.397c.407.552.69 1.172.831 1.823.142.65.14 1.32-.006 1.97h1a3.5 3.5 0 0 1 1.5 6.662\" /></BaseIcon>\n);\nexport const CloudSunIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M10.201 19.997c-1.977 0-3.58-1.544-3.58-3.448 0-1.903 1.603-3.446 3.58-3.446.303-1.355 1.38-2.461 2.827-2.902 1.445-.44 3.042-.148 4.186.77 1.144.915 1.663 2.312 1.361 3.667h.761c1.472 0 2.664 1.2 2.664 2.68A2.672 2.672 0 0 1 19.336 20h-9.134m2.66-12.934a4.166 4.166 0 0 0-2.677-1.732m2.677 1.732 2.744-1.892m-2.744 1.892c.55.796.802 1.754.723 2.709m-3.4-4.44a4.167 4.167 0 0 0-3.118.667m3.118-.668.602-3.278m-3.72 3.946A4.167 4.167 0 0 0 5.334 8.68m1.733-2.678L5.174 3.26m.16 5.42c-.2 1.088.041 2.21.669 3.12m-.669-3.12-3.278-.601m3.947 3.72-2.744 1.893m2.744-1.893a4.167 4.167 0 0 0 2.174 1.607\" /></BaseIcon>\n);\nexport const CloudsIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M8.958 21.05C6.772 21.05 5 19.344 5 17.24s1.772-3.81 3.958-3.81c.335-1.498 1.525-2.72 3.124-3.207 1.598-.487 3.363-.164 4.628.85 1.264 1.011 1.837 2.556 1.504 4.053h.842A2.953 2.953 0 0 1 22 18.09a2.954 2.954 0 0 1-2.945 2.964H8.958M18 8c-.5-2.5-3.532-3.401-5.5-2.5a3.117 3.117 0 0 0-2.11-2.312c-1.352-.411-2.845-.138-3.915.72-1.07.855-1.554 2.161-1.273 3.428h-.711A2.498 2.498 0 0 0 2 9.843c0 1.094.695 2.023 1.666 2.366\" /></BaseIcon>\n);\nexport const SnowflakeIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"m9.25 4-1 2H6m-2.25 4L5 12m0 0-1.25 2M5 12h3m-3 0H2.5m17.75-2L19 12l1.25 2M6 18h2.25l1 2M14 9h-4m4 0 3-5m-3 5 2 3m-6-3L7 4m3 5-2 3m0 0 2 3m0 0-3 5m3-5h4m2-3-2 3m2-3h5.5M14 15l3 5M14.75 4l1 2H18m0 12h-2.25l-1 2\" /></BaseIcon>\n);\nexport const SunIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M12 4V2m0 20v-2m10-8h-2M4 12H2m15.657-5.657 1.414-1.414M4.93 19.07l1.414-1.414m12.728 1.414-1.414-1.414M6.343 6.343 4.93 4.929M7 12a5 5 0 1 0 10 0 5 5 0 0 0-10 0Z\" /></BaseIcon>\n);\nexport const WindIcon = (props: IconProps) => (\n <BaseIcon {...props}><path d=\"M9.59 4.59A2 2 0 1 1 11 8H2m10.59 11.41A2 2 0 1 0 14 16H2m15.73-8.27A2.5 2.5 0 1 1 19.5 12H2\" /></BaseIcon>\n);\n","import React from 'react';\nimport type { IconProps, WeatherCondition } from '../types';\nimport {\n CloudBoltIcon,\n CloudDrizzleIcon,\n CloudFogIcon,\n CloudHailIcon,\n CloudShowersHeavyIcon,\n CloudShowersIcon,\n CloudSleetIcon,\n CloudSnowIcon,\n CloudSunIcon,\n CloudsIcon,\n SnowflakeIcon,\n SunIcon,\n} from './weather-icons';\n\nconst iconMap: Record<WeatherCondition, React.ComponentType<IconProps>> = {\n sun: SunIcon,\n 'cloud-sun': CloudSunIcon,\n clouds: CloudsIcon,\n 'cloud-fog': CloudFogIcon,\n 'cloud-drizzle': CloudDrizzleIcon,\n 'cloud-showers': CloudShowersIcon,\n 'cloud-showers-heavy': CloudShowersHeavyIcon,\n 'cloud-sleet': CloudSleetIcon,\n 'cloud-snow': CloudSnowIcon,\n snowflake: SnowflakeIcon,\n 'cloud-bolt': CloudBoltIcon,\n 'cloud-hail': CloudHailIcon,\n};\n\nexport function WeatherIcon({ condition, ...props }: IconProps & { condition: WeatherCondition }) {\n const Icon = iconMap[condition] || CloudsIcon;\n return <Icon {...props} />;\n}\n","import React from 'react';\nimport { useWeatherForecast } from '../hooks/useWeatherForecast';\nimport type { HourlyWeather, WeatherForecastOptions, WindSpeedUnit } from '../types';\nimport { WeatherIcon } from '../icons/WeatherIcon';\nimport { WindIcon } from '../icons/weather-icons';\n\ntype Props = WeatherForecastOptions & {\n className?: string;\n style?: React.CSSProperties;\n compact?: boolean;\n};\n\nconst WIND_SPEED_UNIT_LABELS: Record<WindSpeedUnit, string> = {\n kmh: 'km/h',\n mph: 'mph',\n ms: 'm/s',\n kn: 'kn',\n};\n\nfunction closestHour(hourly: HourlyWeather[], targetTime: Date): HourlyWeather | undefined {\n return hourly.reduce<HourlyWeather | undefined>((closest, hour) => {\n const diff = Math.abs(new Date(hour.time).getTime() - targetTime.getTime());\n const closestDiff = closest ? Math.abs(new Date(closest.time).getTime() - targetTime.getTime()) : Infinity;\n return diff < closestDiff ? hour : closest;\n }, undefined);\n}\n\nconst styles = {\n root: {\n fontFamily: 'system-ui, sans-serif',\n border: '1px solid #e5e7eb',\n borderRadius: 12,\n padding: 16,\n background: '#fff',\n color: '#111827',\n maxWidth: 640,\n } as React.CSSProperties,\n row: { display: 'flex', alignItems: 'center', gap: 8 } as React.CSSProperties,\n hours: { display: 'flex', gap: 12, overflowX: 'auto', paddingBottom: 4 } as React.CSSProperties,\n hourCard: { minWidth: 72, textAlign: 'center' as const, padding: 8, borderRadius: 8, background: '#f9fafb' },\n dayRow: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 10, padding: '8px 0', borderBottom: '1px solid #f3f4f6' } as React.CSSProperties,\n compactRoot: { fontFamily: 'system-ui, sans-serif', display: 'flex', flexDirection: 'column', gap: 8, padding: '10px 14px', borderRadius: 8 } as React.CSSProperties,\n compactHeader: { display: 'flex', alignItems: 'center', gap: 10 } as React.CSSProperties,\n compactHeaderText: { display: 'flex', alignItems: 'baseline', gap: 8, flexWrap: 'wrap' } as React.CSSProperties,\n compactDateTime: { fontSize: 11, opacity: 0.7 } as React.CSSProperties,\n compactStats: { display: 'flex', flexWrap: 'wrap', gap: 12, fontSize: 12, opacity: 0.9 } as React.CSSProperties,\n compactStat: { display: 'flex', alignItems: 'center', gap: 4, whiteSpace: 'nowrap' } as React.CSSProperties,\n};\n\nexport function WeatherForecast(props: Props) {\n const { data, loading, error } = useWeatherForecast(props);\n\n if (loading) return null;\n if (error) return <div className={props.className} style={props.style}>Error: {error.message}</div>;\n if (!data) return <div className={props.className} style={props.style}>No forecast available.</div>;\n\n if (props.compact) {\n const now = new Date(data.current.time);\n const today = data.daily[0];\n const tomorrow = data.daily[1];\n const in6Hours = closestHour(data.hourly, new Date(now.getTime() + 6 * 60 * 60 * 1000));\n const windSpeedUnitLabel = WIND_SPEED_UNIT_LABELS[props.windSpeedUnit ?? 'mph'];\n\n return (\n <div className={props.className} style={{ ...styles.compactRoot, ...props.style }}>\n <div style={styles.compactHeader}>\n <WeatherIcon condition={data.current.icon} width={24} height={24} title=\"Current weather\" />\n <div>\n <div style={styles.compactHeaderText}>\n <strong style={{ fontSize: 16 }}>{data.current.temperature}°</strong>\n <span style={{ fontSize: 14, opacity: 0.8 }}>\n {data.location?.city || 'Current location'}\n </span>\n </div>\n <div style={styles.compactDateTime}>\n {now.toLocaleDateString([], { weekday: 'short', month: 'short', day: 'numeric' })}\n {' · '}\n {now.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' })}\n </div>\n </div>\n </div>\n\n <div style={styles.compactStats}>\n {today && (\n <span style={styles.compactStat}>\n <WeatherIcon condition={today.icon} width={16} height={16} title=\"Today's high and low\" />\n {today.max}° / {today.min}°\n </span>\n )}\n {tomorrow && (\n <span style={styles.compactStat}>\n <WeatherIcon condition={tomorrow.icon} width={16} height={16} title=\"Tomorrow\" />\n Tomorrow {tomorrow.max}°\n </span>\n )}\n <span style={styles.compactStat}>\n <WindIcon width={16} height={16} title=\"Wind speed\" />\n {data.current.windSpeed !== undefined ? `${Math.round(data.current.windSpeed)} ${windSpeedUnitLabel}` : '—'}\n </span>\n {in6Hours && (\n <span style={styles.compactStat}>\n <WeatherIcon condition={in6Hours.icon} width={16} height={16} title=\"In 6 hours\" />\n {in6Hours.temperature}° in 6h\n </span>\n )}\n </div>\n </div>\n );\n }\n\n return (\n <div className={props.className} style={{ ...styles.root, ...props.style }}>\n <div>\n <h3 style={{ margin: 0, fontSize: 20 }}>\n {data.location?.city || 'Current location'}\n {data.location?.region ? `, ${data.location.region}` : ''}\n </h3>\n <div style={{ ...styles.row, marginTop: 8 }}>\n <WeatherIcon condition={data.current.icon} width={28} height={28} title=\"Current weather\" />\n <strong style={{ fontSize: 28 }}>{data.current.temperature}°</strong>\n </div>\n </div>\n\n <div style={{ marginTop: 20 }}>\n <h4 style={{ margin: '0 0 10px 0' }}>Next hours</h4>\n <div style={styles.hours}>\n {data.hourly.slice(0, props.forecastHours ?? 12).map((hour) => (\n <div key={hour.time} style={styles.hourCard}>\n <div style={{ fontSize: 12 }}>{new Date(hour.time).toLocaleTimeString([], { hour: 'numeric' })}</div>\n <WeatherIcon condition={hour.icon} width={20} height={20} style={{ margin: '6px auto' }} />\n <div>{hour.temperature}°</div>\n </div>\n ))}\n </div>\n </div>\n\n <div style={{ marginTop: 20 }}>\n <h4 style={{ margin: '0 0 10px 0' }}>Next days</h4>\n <div>\n {data.daily.map((day) => (\n <div key={day.date} style={styles.dayRow}>\n <div style={{ width: 120 }}>{new Date(day.date).toLocaleDateString([], { weekday: 'short', month: 'short', day: 'numeric' })}</div>\n <WeatherIcon condition={day.icon} width={20} height={20} />\n <div>{day.min}° / {day.max}°</div>\n </div>\n ))}\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";AAEO,SAAS,eAAe,MAAc,QAAQ,GAAqB;AACxE,MAAI,SAAS,EAAG,QAAO;AACvB,MAAI,CAAC,GAAG,CAAC,EAAE,SAAS,IAAI,EAAG,QAAO,QAAQ,cAAc;AACxD,MAAI,SAAS,EAAG,QAAO;AACvB,MAAI,CAAC,IAAI,EAAE,EAAE,SAAS,IAAI,EAAG,QAAO;AACpC,MAAI,CAAC,IAAI,IAAI,IAAI,IAAI,EAAE,EAAE,SAAS,IAAI,EAAG,QAAO;AAChD,MAAI,CAAC,IAAI,EAAE,EAAE,SAAS,IAAI,EAAG,QAAO;AACpC,MAAI,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE,EAAE,SAAS,IAAI,EAAG,QAAO;AACpD,MAAI,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE,EAAE,SAAS,IAAI,EAAG,QAAO;AACpD,MAAI,SAAS,GAAI,QAAO;AACxB,MAAI,CAAC,IAAI,EAAE,EAAE,SAAS,IAAI,EAAG,QAAO;AACpC,SAAO;AACT;;;ACTA,IAAM,qBAAqB;AAsB3B,eAAsB,kBAAkB,aAAsB,IAAuC;AACnG,MAAI,aAAa;AACf,UAAM,MAAM,KAAK,GAAG,WAAW,OAAO,mBAAmB,EAAE,CAAC,KAAK;AACjE,UAAMA,OAAM,MAAM,MAAM,GAAG;AAC3B,QAAI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gBAAAC,MAAC,SAAoB,OAAO,OAAO,UACjC;AAAA,wBAAAD,KAAC,SAAI,OAAO,EAAE,UAAU,GAAG,GAAI,cAAI,KAAK,KAAK,IAAI,EAAE,mBAAmB,CAAC,GAAG,EAAE,MAAM,UAAU,CAAC,GAAE;AAAA,QAC/F,gBAAAA,KAAC,eAAY,WAAW,KAAK,MAAM,OAAO,IAAI,QAAQ,IAAI,OAAO,EAAE,QAAQ,WAAW,GAAG;AAAA,QACzF,gBAAAC,MAAC,SAAK;AAAA,eAAK;AAAA,UAAY;AAAA,WAAC;AAAA,WAHhB,KAAK,IAIf,CACD,GACH;AAAA,OACF;AAAA,IAEA,gBAAAA,MAAC,SAAI,OAAO,EAAE,WAAW,GAAG,GAC1B;AAAA,sBAAAD,KAAC,QAAG,OAAO,EAAE,QAAQ,aAAa,GAAG,uBAAS;AAAA,MAC9C,gBAAAA,KAAC,SACE,eAAK,MAAM,IAAI,CAAC,QACf,gBAAAC,MAAC,SAAmB,OAAO,OAAO,QAChC;AAAA,wBAAAD,KAAC,SAAI,OAAO,EAAE,OAAO,IAAI,GAAI,cAAI,KAAK,IAAI,IAAI,EAAE,mBAAmB,CAAC,GAAG,EAAE,SAAS,SAAS,OAAO,SAAS,KAAK,UAAU,CAAC,GAAE;AAAA,QAC7H,gBAAAA,KAAC,eAAY,WAAW,IAAI,MAAM,OAAO,IAAI,QAAQ,IAAI;AAAA,QACzD,gBAAAC,MAAC,SAAK;AAAA,cAAI;AAAA,UAAI;AAAA,UAAK,IAAI;AAAA,UAAI;AAAA,WAAC;AAAA,WAHpB,IAAI,IAId,CACD,GACH;AAAA,OACF;AAAA,KACF;AAEJ;","names":["res","data","jsx","jsx","jsx","jsxs"]}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "use-weather-forecast",
3
+ "version": "0.1.0",
4
+ "description": "React weather forecast component using Open-Meteo and IP geolocation",
5
+ "keywords": [
6
+ "react",
7
+ "weather",
8
+ "forecast",
9
+ "open-meteo",
10
+ "cloudflare",
11
+ "ip-api",
12
+ "component-library"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/OpenSourceAGI/qwksearch-research-agent.git",
17
+ "directory": "packages/react-weather-forecast"
18
+ },
19
+ "type": "module",
20
+ "main": "./dist/index.js",
21
+ "module": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js",
27
+ "require": "./dist/index.cjs"
28
+ }
29
+ },
30
+ "files": [
31
+ "dist",
32
+ "README.md",
33
+ "LICENSE"
34
+ ],
35
+ "sideEffects": false,
36
+ "peerDependencies": {
37
+ "react": "^18 || ^19",
38
+ "react-dom": "^18 || ^19"
39
+ },
40
+ "devDependencies": {
41
+ "@cloudflare/workers-types": "^4.20250115.0",
42
+ "@types/react": "^19.0.0",
43
+ "@types/react-dom": "^19.0.0",
44
+ "tsup": "^8.2.4",
45
+ "typescript": "^5.6.3",
46
+ "wrangler": "^3.88.0"
47
+ },
48
+ "scripts": {
49
+ "build": "tsup",
50
+ "typecheck": "tsc --noEmit",
51
+ "worker:typecheck": "tsc --noEmit -p worker/tsconfig.json",
52
+ "worker:dev": "wrangler dev --config worker/wrangler.jsonc",
53
+ "worker:deploy": "wrangler deploy --config worker/wrangler.jsonc"
54
+ }
55
+ }