diff --git a/index.html b/index.html index caf727e..da25ef9 100644 --- a/index.html +++ b/index.html @@ -36,7 +36,6 @@
- diff --git a/src/main.tsx b/src/main.tsx index 30ce843..fc860c9 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -2,6 +2,19 @@ import ReactDOM from 'react-dom/client' import App from './App' import { NavigationProvider } from '~/file-router/Navigation' +if (!window.isSecureContext) { + console.log("Not registering service worker because the site is not hosted on HTTPS.") +} else { + navigator.serviceWorker.register('./sw.js') + .then(registration => { + console.log(`Service worker registered: scope "${registration.scope}"`) + registration.addEventListener("updatefound", () => window.location.reload()) + if (registration.active && !navigator.serviceWorker.controller) { + window.location.reload() + } + }) +} + ReactDOM.createRoot(document.getElementById('root')!).render( diff --git a/src/register.ts b/src/register.ts deleted file mode 100644 index aa0d7a3..0000000 --- a/src/register.ts +++ /dev/null @@ -1,13 +0,0 @@ -const controlling = navigator.serviceWorker && navigator.serviceWorker.controller -if (!window.isSecureContext) { - console.log("Not registering service worker because the site is not hosted on HTTPS.") -} else { - navigator.serviceWorker.register('./sw.js') - .then(registration => { - console.log(`Service worker registered: scope "${registration.scope}"`) - registration.addEventListener("updatefound", () => window.location.reload()) - if (registration.active && !navigator.serviceWorker.controller) { - window.location.reload() - } - }) -} \ No newline at end of file