feat(ui): installable offline PWA (F5) #31
@@ -4,6 +4,7 @@
|
||||
import { onMount } from "svelte";
|
||||
import { goto } from "$app/navigation";
|
||||
import { page } from "$app/state";
|
||||
import { dev } from "$app/environment";
|
||||
import { i18n } from "$lib/i18n/index.svelte";
|
||||
import { session } from "$lib/session-store.svelte";
|
||||
import { eventStream } from "../api/events.svelte";
|
||||
@@ -21,6 +22,12 @@
|
||||
|
||||
onMount(() => {
|
||||
void session.init();
|
||||
// Production-only service-worker registration (auto-register is off
|
||||
// in svelte.config.js) so `vite dev` and the dev-server e2e suite
|
||||
// run without the worker intercepting requests.
|
||||
if (!dev && "serviceWorker" in navigator) {
|
||||
void navigator.serviceWorker.register("/service-worker.js");
|
||||
}
|
||||
return () => {
|
||||
eventStream.stop();
|
||||
streamSessionId = null;
|
||||
|
||||
@@ -11,5 +11,11 @@ export default {
|
||||
fallback: "index.html",
|
||||
strict: true,
|
||||
}),
|
||||
serviceWorker: {
|
||||
// Registered manually in the root layout for production only.
|
||||
// SvelteKit's auto-registration also runs under `vite dev`, where
|
||||
// the worker would intercept and cache the dev-server e2e suite.
|
||||
register: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user