From 54e811ef9541b3b61cad80cc18c6829849bcb77e Mon Sep 17 00:00:00 2001 From: Roman Priesol Date: Thu, 12 Nov 2026 11:52:17 +0000 Subject: [PATCH] chore(deps): update dependency suncalc to v2.1.4 --- package-lock.json | 8 ++++---- package.json | 2 +- public/vendor/suncalc/suncalc.js | 14 +++++++++----- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index f694f46..dda0877 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "maplibre-gl": "6.17.0", "maplibre-gl-lanes": "1.4.1", "pmtiles": "4.5.0", - "suncalc": "2.1.3" + "suncalc": "2.1.4" } }, "node_modules/@mapbox/jsonlint-lines-primitives": { @@ -304,9 +304,9 @@ } }, "node_modules/suncalc": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/suncalc/-/suncalc-2.1.3.tgz", - "integrity": "sha512-7DWCsxPKRPMtylyGqSrgNBr+pseyczJGqb4NCpW2EziwNHaSuHc9w1lL4i91IyDw5CnPUWqBNBWyd/vFjr4rTw==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/suncalc/-/suncalc-2.1.4.tgz", + "integrity": "sha512-V7oSdbSezigEpbqnNWKujDlZaE/QA/0w5IbP/vXX+eIF+EtiE8e9BkSapsOFZc84jJkI3QlklYTWtMqzj9tZQg==", "dev": true }, "node_modules/tinyqueue": { diff --git a/package.json b/package.json index 653d6ec..9a58251 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,6 @@ "maplibre-gl": "6.17.0", "maplibre-gl-lanes": "1.4.1", "pmtiles": "4.5.0", - "suncalc": "2.1.3" + "suncalc": "2.1.4" } } diff --git a/public/vendor/suncalc/suncalc.js b/public/vendor/suncalc/suncalc.js index 11ca8b8..cae2e2b 100644 --- a/public/vendor/suncalc/suncalc.js +++ b/public/vendor/suncalc/suncalc.js @@ -142,16 +142,18 @@ function solarTransit(dt, lw) { // time the Sun reaches altitude h0 within the half day [a, b] between transit and nadir, given the // sine of its altitude at both ends; NaN if it doesn't cross h0 there (altitude is monotonic over the // half day, so a sign change means exactly one crossing). Seeds from the hour angle at transit -// declination, then Newton on sin(h) kept inside a shrinking bracket, bisecting whenever a step -// leaves it — on near-grazing days the slope is tiny and plain Newton steps land days away. +// declination, then Newton on sin(h) kept inside a shrinking bracket, bisecting whenever a step leaves +// it or fails to halve the previous step (as in rtsafe) — on near-grazing days the slope is tiny, so +// plain Newton steps land days away or ping-pong inside the bracket, barely shrinking it. function getSetJ(h0, a, b, sa, sb, dt, lw, phi, decT) { const s0 = sin(h0); const rising = sa < sb; - if ((sa - s0) * (sb - s0) > 0) return NaN; // sun stays above / below this altitude all half day + if (!((sa - s0) * (sb - s0) <= 0)) return NaN; // stays above / below h0 all half day, or NaN input const cosH0 = (s0 - sin(phi) * sin(decT)) / (cos(phi) * cos(decT)); const H0 = cosH0 <= -1 ? PI : cosH0 >= 1 ? 0 : acos(cosH0); let d = dt + (rising ? -H0 : H0) / (2 * PI); + let dx = b - a; for (;;) { const c = sunCoords(toDaysTT(d)); @@ -161,11 +163,13 @@ function getSetJ(h0, a, b, sa, sb, dt, lw, phi, decT) { if ((f < 0) === rising) a = d; else b = d; const step = f / (2 * PI * k * sin(H)); - if (d + step > a && d + step < b) { + if (d + step > a && d + step < b && abs(step) <= abs(dx) / 2) { + dx = step; d += step; if (abs(step) < 1e-5) return d; // ~1 s step, so quadratic convergence leaves ~µs error } else { - d = (a + b) / 2; + dx = (b - a) / 2; + d = a + dx; if (b - a < 1e-8) return d; } }