mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
Until now `/sw.js` registered only behind the Web-Push opt-in, so any user who never enabled notifications ran with no service worker — the offline shell cache, the precached app shell, and the network-first page cache were all inert. Add a production-gated `ServiceWorkerRegistrar` that installs the worker for everyone, deferred to the `load` event wrapped in `requestIdleCallback` so install/precache stays off the first-paint critical path. Mount it beside `VersionPoller` in the root providers. The registrar only installs. `VersionPoller` remains the sole owner of the update→reload path (poll `/api/version`, then unregister + cache-wipe + reload on a server-ahead deploy); no `updatefound`/`controllerchange` handling lives here so the two cannot double-fire. `updateViaCache: "none"` forces a network byte-check of `sw.js` on every update check so a cached worker can never mask a new deploy.