Skip to content

feat(deps): migrate to SunCalc 2.0 (supersedes #47) - #55

Merged
timothybrown merged 1 commit into
mainfrom
feat/suncalc-2-migration
Sep 5, 2026
Merged

feat(deps): migrate to SunCalc 2.0 (supersedes #47)#55
timothybrown merged 1 commit into
mainfrom
feat/suncalc-2-migration

Conversation

@timothybrown

Copy link
Copy Markdown
Owner

Supersedes #47, which cannot be merged as a plain version bump — suncalc 2.0 is a precision-focused rewrite with breaking changes to units and API shape.

Closes #47.

What changed

Change Caught by Sites
ESM named exports, no default tsc (TS1192) SunCard.tsx, MoonCard.tsx, console/page.tsx
Angles now degrees, not radians nothing SunCard.tsx — current altitude + 61-sample arc loop
getTimes returns Date | null per event tsc SunCard.tsx, console/page.tsx
getMoonTimes dropped inUTC, scans UTC day nothing MoonCard.tsx
v2 ships own typings dropped @types/suncalc

The two middle-column "nothing" rows are the reason this needed a branch rather than a rubber stamp.

Degrees vs radians. Left in place, the old * 180 / Math.PI scales a real 45° altitude to ~2578. altToY's deg / 90 then clamps every arc sample to the top of the card, silently flattening the astronomical sun curve into a straight line. No type error, no test failure.

Moon times. v2 scans the UTC calendar day of the instant it is given. Passing now makes the card flip to tomorrow's moonrise/set at 20:00 EDT (00:00 UTC) every evening. Passing local midnight keeps the window on today's local date.

Azimuth also became north-based, but nothing in the app reads azimuth. getMoonIllumination gained a waxing flag; getPhaseName already derives waxing/waning from the phase value, so it is unchanged.

Verification

tsc ✓ · eslint ✓ · 601 tests ✓ · next build

The suite mocks SunCalc entirely, so it is no evidence for the unit change. Verified independently instead:

  • Arc math against the real library — peak altitude matches 90 − lat + declination at 39.125°N: 57.5° today, 74.3° at summer solstice, 27.4° at winter. Arc anchors at the horizon both ends; seasonal height variation preserved.
  • Every rendered value cross-checked against SunCalc output on live Pi data — sunrise 06:43, sunset 19:35, solar noon 13:09, golden hour 18:59, day length 12h 51m, delta −2m 28s, altitude 32°, moonrise 00:03, moonset 16:06, illumination 36%. All exact.
  • Sun arc and Lunar card rendered and inspected in-browser; Console page sun block verified too.

🤖 Generated with Claude Code

https://claude.ai/code/session_0151MxVqVhjffC7xAThxpyV2

Supersedes Dependabot PR #47, which could not be merged as-is: suncalc 2.0
is a precision-focused rewrite with breaking changes to units and API shape,
so it needs code changes rather than a version bump.

- ESM named exports (no default): `import * as SunCalc` at all three call
  sites (SunCard, MoonCard, console page)
- Angles are now degrees, not radians: drop the `* 180 / Math.PI` conversion
  in SunCard at both the current-altitude readout and the 61-sample arc loop.
  Left in place this scales ~45deg to ~2578 and pins every arc sample to the
  top of the card, silently flattening the astronomical curve into a straight
  line — no type error and no test failure
- `getTimes` now returns `Date | null` per event (polar day/night); guard the
  sunrise/sunset pair and fall back to the card's existing "no data" branch.
  `goldenHour` stays nullable, so `fmtTime` now renders an em-dash for absent
  times, matching MoonCard's convention
- `getMoonTimes` dropped its `inUTC` arg and scans the UTC calendar day; pass
  local midnight so the window stays pinned to today's local date instead of
  rolling over to tomorrow's rise/set after 20:00 EDT
- Drop `@types/suncalc`; v2 ships its own typings

Azimuth also changed to north-based, but nothing in the app reads azimuth.
`getMoonIllumination` gained a `waxing` flag; `getPhaseName` already derives
waxing/waning from the phase value, so it is left alone.

Verified: tsc, eslint, 601 tests, production build. Since the suite mocks
SunCalc entirely it cannot catch the unit change, so the arc math was checked
against the real library (peak altitude matches 90 - lat + declination across
solstices) and every rendered Sun/Lunar value was cross-checked against
SunCalc output on the live Pi data.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0151MxVqVhjffC7xAThxpyV2
@timothybrown
timothybrown merged commit f359ba2 into main Sep 5, 2026
2 checks passed
@timothybrown
timothybrown deleted the feat/suncalc-2-migration branch September 5, 2026 13:50
timothybrown added a commit that referenced this pull request Sep 5, 2026
CalVer bump covering the SunCalc 2.0 migration (#55) and the minor-and-patch
group + advisory-floor remediation (#56).

backend/uv.lock records the editable package's own version, so it is refreshed
alongside pyproject.toml — otherwise `uv sync --frozen` fails in CI and on the
Pi deploy. The lock diff is that single line; no dependency churn.


Claude-Session: https://claude.ai/code/session_0151MxVqVhjffC7xAThxpyV2

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant