Rewrite ui/docs (navigation, order-composer, auth-flow, pwa-strategy, game-state + secondary topic docs) and ui/README for the single-URL app-shell (in-memory screens/views, Back→lobby via shallow routing, sessionStorage restore + validation, return-to-lobby). ui/PLAN.md gets a Phase-10 supersede note (implemented; standalone-compatible). Fix stale code comments (session-store auth gate, report-sections spec contract). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3.0 KiB
PWA strategy
The web client is an installable, offline-tolerant PWA. It uses SvelteKit's native service worker (no Workbox) so there is no extra build dependency and the cache logic stays explicit.
The single-URL app-shell (see navigation.md) makes
the offline story simpler: the whole game UI lives at one route
(${base}/, i.e. /game/ under the single-origin deployment), so
there is exactly one navigation target to precache and fall back to —
no per-screen routes to enumerate. The service-worker scope and the
manifest are unchanged by that refactor; both were already base-aware
(the SW keys everything off $service-worker's base, and the
manifest uses relative ./ start_url / scope).
Pieces
src/service-worker.ts— the worker. SvelteKit registers it automatically in the production build. It precaches the app shell (${base}/), the build artefacts (JS/CSScore.wasm), and the static files under a version-keyed cache (galaxy-cache-<version>,versionfrom$service-worker). Onactivateit deletes every other cache, so a new deploy never serves stale code. Strategy: cache-first for the version-keyed build/files; network-first with cache fallback for everything else; the cached shell answers navigations when fully offline. The gateway (cross- origin) is never intercepted — it is always live network.
static/manifest.webmanifest— name,standalonedisplay, relative./start_url/scope(so it resolves under whateverbasethe build is deployed at), darktheme_color/background_color, and the icon set.static/icons/—192/512(any), a512maskable, and a180apple-touch icon. They are placeholder artwork generated fromstatic/favicon.svgbyscripts/gen-pwa-icons.mjs(a dependency-free pure-Node PNG encoder); swap in real artwork at the same paths and the manifest is unchanged.src/app.html— the manifest link, the apple-touch-icon link, and light/darktheme-colormetas matching the design tokens.
Testing
PWA behaviour is gated by Playwright against a production preview
build (playwright.pwa.config.ts
tests/pwa/pwa.spec.ts, run bypnpm test:pwain CI): the manifest is linked with installable icons, the service worker registers and controls the page under exactly one version-keyed cache, and the app shell loads offline from that cache. The spec needs a real build because$service-worker'sbuildlist is empty undervite dev.
Lighthouse is intentionally not used: its PWA category was removed in Lighthouse 12 (the current line is 13.x), so "Lighthouse PWA ≥ 90" is no longer a meaningful gate. The Playwright checks above verify the same install/offline behaviour directly.