diff --git a/dist/index.html b/dist/index.html index 7e0404d..7a950fa 100644 --- a/dist/index.html +++ b/dist/index.html @@ -5211,7 +5211,6 @@ var init_db = __esmMin((() => { source: "open-meteo", refreshInterval: 30, alertsEnabled: true, - showLightning: false, notificationTypes: { storm: true, precip: true, @@ -5876,7 +5875,6 @@ var AppStore = class { source: "open-meteo", refreshInterval: 30, alertsEnabled: true, - showLightning: false, notificationTypes: { storm: true, precip: true, @@ -7721,59 +7719,6 @@ function WeatherDetail($$anchor, $$props) { pop(); } //#endregion -//#region src/lib/api/lightning.js -/** -* Lightning strike API helper. -* -* The browser cannot talk directly to the Blitzortung feed (WebSocket + -* binary protocol, no CORS), so this app reads strikes through a small CORS -* relay at https://cors.thecookiejar.me. The relay is NOT deployed yet, so -* every request here must fail gracefully: callers catch the error and show a -* "lightning unavailable" state rather than crashing/blocking the radar. -* -* Expected relay contract (once it exists): -* GET /lightning?lat=&lon=&radiusKm=&limit= -* -> 200 { "source": "blitzortung", "generatedAt": , -* "strikes": [ { "lat": , "lon": , -* "time": , "strength": } ] } -* -* The relay is intended to hold a recent WS connection to Blitzortung and -* answer point-in-radius queries for recent strikes in that area. -*/ -var LIGHTNING_PROXY_BASE = "https://cors.thecookiejar.me/lightning"; -/** -* Fetch recent lightning strikes within radiusKm of a location. -* -* @param {Object} opts -* @param {number} opts.lat -* @param {number} opts.lon -* @param {number} [opts.radiusKm=150] -* @param {number} [opts.limit=200] -* @returns {Promise>} -* Resolves to the strike list. Throws if the relay is unreachable, returns a -* non-OK status, or the response is malformed. -*/ -async function fetchLightningStrikes({ lat, lon, radiusKm = 150, limit = 200 } = {}) { - const url = `${LIGHTNING_PROXY_BASE}?${new URLSearchParams({ - lat: lat.toString(), - lon: lon.toString(), - radiusKm: radiusKm.toString(), - limit: limit.toString() - }).toString()}`; - const controller = new AbortController(); - const timer = setTimeout(() => controller.abort(), 8e3); - let res; - try { - res = await fetch(url, { signal: controller.signal }); - } finally { - clearTimeout(timer); - } - if (!res.ok) throw new Error(`Lightning relay error: ${res.status} ${res.statusText}`); - const data = await res.json(); - if (!data || !Array.isArray(data.strikes)) throw new Error("Lightning relay returned an invalid response"); - return data.strikes; -} -//#endregion //#region src/components/PrecipitationRadar.svelte var root$4 = /* @__PURE__ */ from_html(`
`); var root_1$4 = /* @__PURE__ */ from_html(``); @@ -7808,11 +7753,6 @@ function PrecipitationRadar($$anchor, $$props) { const TILE_SIZE = 256; const RADAR_COLOR = 4; const loc = /* @__PURE__ */ user_derived(() => app$1.selectedLocation); - let strikes = /* @__PURE__ */ state(proxy([])); - let lightningError = /* @__PURE__ */ state(""); - let lightningLoading = /* @__PURE__ */ state(false); - let lightningTimer = null; - const LIGHTNING_REFRESH_MS = 3e4; user_effect(() => { if (get(loc)) { set(panX, 0); @@ -7838,49 +7778,6 @@ function PrecipitationRadar($$anchor, $$props) { set(loading, false); } } - async function loadLightning() { - if (!get(loc)) return; - set(lightningLoading, true); - set(lightningError, ""); - try { - const radiusKm = Math.max(40, Math.min(400, 160 * Math.pow(2, 6 - get(zoom)))); - set(strikes, await fetchLightningStrikes({ - lat: get(loc).lat, - lon: get(loc).lon, - radiusKm, - limit: 400 - }), true); - } catch (e) { - set(strikes, [], true); - set(lightningError, e.name === "AbortError" ? "Lightning layer timed out" : e.message || "Lightning layer unavailable", true); - console.warn("Lightning layer unavailable:", e.message); - } finally { - set(lightningLoading, false); - } - } - function startLightningTimer() { - stopLightningTimer(); - lightningTimer = setInterval(loadLightning, LIGHTNING_REFRESH_MS); - } - function stopLightningTimer() { - if (lightningTimer) { - clearInterval(lightningTimer); - lightningTimer = null; - } - } - user_effect(() => { - if (get(loc)) { - loadLightning(); - startLightningTimer(); - return () => { - stopLightningTimer(); - }; - } else { - stopLightningTimer(); - set(strikes, [], true); - set(lightningError, ""); - } - }); const pastFrames = /* @__PURE__ */ user_derived(() => get(radarData)?.radar?.past || []); const nowcastFrames = /* @__PURE__ */ user_derived(() => get(radarData)?.radar?.nowcast || []); const allFrames = /* @__PURE__ */ user_derived(() => [...get(pastFrames), ...get(nowcastFrames)]); @@ -9195,7 +9092,7 @@ delegate([ ]); //#endregion //#region src/main.js -console.info({ commit_hash: "86acc5614316d179e884e15c8c697a00896da03e" }); +console.info({ commit_hash: "ef4a8b4756296e88b382778369971e5db6e43331" }); registerServiceWorker(); mount(App, { target: document.getElementById("app") }); //#endregion diff --git a/src/components/PrecipitationRadar.svelte b/src/components/PrecipitationRadar.svelte index 9eb7f60..420cfff 100644 --- a/src/components/PrecipitationRadar.svelte +++ b/src/components/PrecipitationRadar.svelte @@ -1,7 +1,6 @@