diff options
author | Matt Strapp <matt@mattstrapp.net> | 2023-09-13 16:04:12 -0500 |
---|---|---|
committer | Matt Strapp <matt@mattstrapp.net> | 2023-09-14 13:26:23 -0500 |
commit | 319a10b9a106e768ea2d3fb6d7134817911208ce (patch) | |
tree | d4d71c83665ff583071f387309980b6cdb893d88 /app/src/routes/+layout.svelte | |
parent | Initial commit (diff) | |
download | trinkets-319a10b9a106e768ea2d3fb6d7134817911208ce.tar trinkets-319a10b9a106e768ea2d3fb6d7134817911208ce.tar.gz trinkets-319a10b9a106e768ea2d3fb6d7134817911208ce.tar.bz2 trinkets-319a10b9a106e768ea2d3fb6d7134817911208ce.tar.lz trinkets-319a10b9a106e768ea2d3fb6d7134817911208ce.tar.xz trinkets-319a10b9a106e768ea2d3fb6d7134817911208ce.tar.zst trinkets-319a10b9a106e768ea2d3fb6d7134817911208ce.zip |
Add basic PWA support
TODO: draw the rest of the owl
Diffstat (limited to '')
-rw-r--r-- | app/src/routes/+layout.svelte | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/app/src/routes/+layout.svelte b/app/src/routes/+layout.svelte index 3d5c07f..93a41b1 100644 --- a/app/src/routes/+layout.svelte +++ b/app/src/routes/+layout.svelte @@ -1,4 +1,8 @@ <script lang="ts"> + import { registerSW } from 'virtual:pwa-register' + import { pwaInfo } from 'virtual:pwa-info'; + import { onMount } from 'svelte' + import '../app.postcss'; import { AppShell, AppBar } from '@skeletonlabs/skeleton'; @@ -6,8 +10,31 @@ import { computePosition, autoUpdate, flip, shift, offset, arrow } from '@floating-ui/dom'; import { storePopup } from '@skeletonlabs/skeleton'; storePopup.set({ computePosition, autoUpdate, flip, shift, offset, arrow }); + + onMount(async () => { + if (pwaInfo) { + registerSW({ + immediate: true, + onRegistered(r) { + console.log(`SW Registered: ${r}`) + }, + onRegisterError(error) { + console.log('SW registration error', error) + }, + onOfflineReady() { + console.log('SW Offline Ready') + } + }) + } + }) + + $: webManifestLink = pwaInfo ? pwaInfo.webManifest.linkTag : '' </script> +<svelte:head> + {@html webManifestLink} +</svelte:head> + <!-- App Shell --> <AppShell> <svelte:fragment slot="header"> |