This commit is contained in:
seb
2026-10-05 16:09:23 +02:00
parent bac2d9a202
commit 5c48d1be65
6 changed files with 293 additions and 29 deletions

View File

@@ -11,6 +11,8 @@ import { installCssVars } from './colors';
// Side-effect imports: each module registers its automat and subscribes to
// authAutomat, so the stores must be evaluated before the session bootstraps.
import './automats';
import { initPwa } from './automats';
import PwaUpdateDialog from './components/PwaUpdateDialog';
import './index.css';
// Publish the color tokens as CSS custom properties so index.css (and any
@@ -37,18 +39,8 @@ if (import.meta.env.DEV) {
void clearDevServiceWorker();
}
// PWA auto-update: reload the page as soon as a new build's service worker
// takes control. The virtual module only exists in production builds (the
// plugin is registered for `build` only), hence the dynamic import.
if (import.meta.env.PROD && 'serviceWorker' in navigator) {
import('virtual:pwa-register')
.then(({ registerSW }) => {
registerSW({ immediate: true });
})
.catch(() => {
// No SW in this build — app still works, just without offline support.
});
}
// Initialize PWA service worker registration and update listener in production
initPwa();
createRoot(document.getElementById('root')).render(
<ThemeProvider theme={getActiveTheme()}>
@@ -71,6 +63,7 @@ createRoot(document.getElementById('root')).render(
</Suspense>
) : null}
</Box>
<PwaUpdateDialog />
</AuthBootstrap>
</SnackbarProvider>
</ThemeProvider>,