Skip to content

Make the calculators installable and usable offline - #24

Merged
ehcrea merged 1 commit into
mainfrom
claude/project-thread-mq981r
Nov 22, 2026
Merged

ehcrea merged 1 commit into
mainfrom
claude/project-thread-mq981r

Conversation

@ehcrea

@ehcrea ehcrea commented Nov 22, 2026

Copy link
Copy Markdown
Owner

Requested by Eren · project thread

Makes the calculator an installable Progressive Web App that works fully offline (Chrome/Edge "Install", Safari on macOS "File › Add to Dock").

Changes

  • sw.js: service worker generated by tools/build-sw.js from tools/sw.template.js. It precaches every page, language page and asset; the cache name is a hash of all files, so every deploy gets a new cache and old ones are deleted (cache names are prefixed per repo, since all calculators share the ehcrea.github.io origin).
  • Online: network first (4 s timeout), so updates appear immediately and the offline copy is refreshed. Offline: served from the cache; unknown pages fall back to the start page.
  • Third-party files (PDF/Excel libraries, web fonts) where the tool uses them are cached best-effort.
  • Service worker registration appended to the app script; manifest gets id, lang and a maskable icon where missing.
  • node tools/build-sw.js --check runs in CI (new Tests workflow where the repo had none) so a stale sw.js fails.
  • README: "Install as an app and use it offline" section with the maintainer note.

Testing

  • Existing tests pass; build-sw.js --check passes.
  • Playwright (Chromium, served under /<repo>/ like GitHub Pages): Chrome reports no installability errors; after the first visit the site was taken offline and every language page reloaded correctly in light and dark mode with no script errors; a simulated deploy replaced the cache and the offline copy picked up the change.

Generated by Claude Code

Adds a generated service worker (sw.js, built by tools/build-sw.js) that
precaches every page, language and asset under a content-hash cache
version, serves network-first when online and from the cache when
offline, and removes old caches after an update. Registration is added
to the app script; the web manifest gets an id and maskable icon so
Chrome/Edge offer "Install" and Safari's "Add to Dock" works. The tests
check that sw.js is up to date.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DtSyM8REeQdPhYZ6eSWmgc
@ehcrea ehcrea self-assigned this Nov 22, 2026
@ehcrea
ehcrea merged commit 73e3c70 into main Nov 22, 2026
2 checks passed
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.

2 participants