You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
HTML
51 lines
1.4 KiB
HTML
|
4 hours ago
|
<!doctype html>
|
||
|
|
<html lang="en">
|
||
|
|
<head>
|
||
|
|
<meta charset="UTF-8" />
|
||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||
|
|
<title>Verto</title>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<div id="root"></div>
|
||
|
|
<script type="module">
|
||
|
|
const loadApp = () => import('/src/main.tsx');
|
||
|
|
const SW_CLEANUP_FLAG = '__sw_cleanup_done__';
|
||
|
|
|
||
|
|
const cleanupServiceWorkers = async () => {
|
||
|
|
if (!navigator.serviceWorker.getRegistrations) {
|
||
|
|
loadApp();
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
try {
|
||
|
|
const registrations = await navigator.serviceWorker.getRegistrations();
|
||
|
|
|
||
|
|
if (registrations.length === 0) {
|
||
|
|
sessionStorage.removeItem(SW_CLEANUP_FLAG);
|
||
|
|
loadApp();
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
await Promise.all(registrations.map((registration) => registration.unregister()));
|
||
|
|
|
||
|
|
// Force a single reload so the page is no longer controlled by a stale SW.
|
||
|
|
sessionStorage.setItem(SW_CLEANUP_FLAG, 'true');
|
||
|
|
window.location.reload();
|
||
|
|
} catch (error) {
|
||
|
|
console.warn('Failed to clean up service workers', error);
|
||
|
|
loadApp();
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
if (sessionStorage.getItem(SW_CLEANUP_FLAG)) {
|
||
|
|
sessionStorage.removeItem(SW_CLEANUP_FLAG);
|
||
|
|
loadApp();
|
||
|
|
} else if (import.meta.env.DEV && 'serviceWorker' in navigator) {
|
||
|
|
cleanupServiceWorkers();
|
||
|
|
} else {
|
||
|
|
loadApp();
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
</body>
|
||
|
|
</html>
|