Skip to content

feat(pwa): play offline, with updates offered on the map - #55

Merged
amide-init merged 1 commit into
mainfrom
feat/offline-pwa
Sep 26, 2026
Merged

amide-init merged 1 commit into
mainfrom
feat/offline-pwa

Conversation

@amide-init

Copy link
Copy Markdown
Owner

Summary

The README and AGENTS say the game "works offline"; now it does, following ARCHITECTURE §11 (updated to match what's built).

  • Offline: vite-plugin-pwa generates a Workbox service worker that precaches the whole app on the first visit: page, both JS chunks, CSS, the Latin font subsets, manifest (14 entries, ~860 KB before compression; all v1 level data is bundled, so everything is playable offline). Non-Latin font subsets load on demand instead. clientsClaim makes the first worker control the page immediately; without it, a level opened before any reload failed offline (found in the browser check below).
  • Updates never interrupt play: registerType: 'prompt', no skipWaiting. platform/AppUpdate records a waiting version; the map (and only the map) shows "A new version of ML Quest is ready." [Update now], which hands over to the new worker and reloads.
  • Registration: platform/ServiceWorker uses workbox-window directly (not the plugin's virtual: module, which dependency-cruiser can't resolve, so no rule had to be loosened), only in production builds, and loaded lazily.
  • Web app manifest (name, theme colour, SVG icon) and <meta name="theme-color">; the manifest resolves under /ml-quest/ on Pages.

Dependencies (RULES §10)

  • workbox-window 7.4.1 (runtime): registers the worker and handles the update hand-off. 2.2 kB gzip, in a lazy chunk: first load stays 163.8 / 170 kB.
  • vite-plugin-pwa 1.3.0 (dev only): generates sw.js and the manifest at build time; supports Vite 8.

Verification

  • typecheck, lint, format, 350 tests (AppUpdate: an update waits until asked, then applies with reload; app test: the banner appears on the map but not on a level, and "Update now" applies it), 118 pass-bot runs, levels:validate, build, size: all green.
  • Browser check on a production build with the server stopped: the worker installs on the first visit (12 files cached) and controls the page; then, offline, opening Draw the Line from the running page works, and a full fresh load of #/w/2/l/5 renders Tame It completely.
  • Update flow in a real browser: served a temporary "v2" build; the open app kept showing v1 (no auto-reload) and the map showed the banner; "Update now" switched to v2 with progress intact. The temporary change was reverted and the test worker and cache removed.

🤖 Generated with Claude Code

vite-plugin-pwa (dev) generates a Workbox service worker that precaches the
whole app on the first visit (page, JS, CSS, Latin fonts, manifest), with
clientsClaim so a level opened before any reload works offline too. Updates
never auto-reload: platform/AppUpdate records a waiting version and the map
shows 'A new version of ML Quest is ready. Update now'. Registration via
workbox-window (runtime dep, 2.2 kB gzip, lazy) in production builds only.
Adds a web app manifest and theme colour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@amide-init
amide-init merged commit 2cdcc79 into main Sep 26, 2026
1 check passed
@amide-init
amide-init deleted the feat/offline-pwa branch September 26, 2026 19:59
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