Repository navigation
Make the calculators installable and usable offline - #24
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 bytools/build-sw.jsfromtools/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).id,langand a maskable icon where missing.node tools/build-sw.js --checkruns in CI (newTestsworkflow where the repo had none) so a stalesw.jsfails.Testing
build-sw.js --checkpasses./<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