04c7f6e68a
Tests · UI / test (push) Failing after 7m31s
Native SvelteKit service worker (src/service-worker.ts): a version-keyed cache precaches the app shell + build artefacts (incl. core.wasm) + static files; activate purges old caches; the gateway is never intercepted; navigations fall back to the cached shell offline. Adds static/manifest.webmanifest, a generated placeholder icon set (scripts/gen-pwa-icons.mjs — dependency-free pure-Node PNG encoder), and manifest / theme-color / apple-touch tags in app.html. Gated by Playwright against a production preview (playwright.pwa.config.ts + tests/pwa/pwa.spec.ts via `pnpm test:pwa`, wired into ui-test): manifest + installable icons, SW registration + a single version-keyed cache, and offline shell load. Lighthouse is not used — its PWA category was removed in v12. Docs: ui/docs/pwa-strategy.md (+ index); F5 marked done. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2.4 KiB
2.4 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.
Pieces
src/service-worker.ts— the worker. SvelteKit registers it automatically in the production build. It precaches the app shell (/), the build artefacts (JS/CSS +core.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,start_url/scope/, 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.