Add features:
- manifest.json with PNG icon set. - reset option against QuickLinks storage - 'Preferences' store, ready for preferences page - including location boolean... Important! - Minor service-worker improvements for better offline fallbacks
This commit is contained in:
@@ -6,9 +6,17 @@ import { build, files, version } from '$service-worker';
|
||||
|
||||
const sw = self as unknown as ServiceWorkerGlobalScope;
|
||||
const CACHE_NAME = `owlboard-cache-${version}`;
|
||||
const ASSETS = [...build, ...files, '/'];
|
||||
const ASSETS = [
|
||||
...build,
|
||||
...files.filter(file =>
|
||||
!file.endsWith('manifest.json') &&
|
||||
!file.startsWith('/icons/')
|
||||
),
|
||||
'/',
|
||||
];
|
||||
|
||||
sw.addEventListener('install', (event) => {
|
||||
sw.skipWaiting();
|
||||
event.waitUntil(
|
||||
caches.open(CACHE_NAME).then((cache) => cache.addAll(ASSETS))
|
||||
);
|
||||
@@ -16,11 +24,14 @@ sw.addEventListener('install', (event) => {
|
||||
|
||||
sw.addEventListener('activate', (event) => {
|
||||
event.waitUntil(
|
||||
caches.keys().then((keys) => {
|
||||
return Promise.all(
|
||||
keys.filter((key) => key !== CACHE_NAME).map((key) => caches.delete(key))
|
||||
);
|
||||
})
|
||||
Promise.all([
|
||||
caches.keys().then((keys) => {
|
||||
return Promise.all(
|
||||
keys.filter((key) => key !== CACHE_NAME).map((key) => caches.delete(key))
|
||||
);
|
||||
}),
|
||||
sw.clients.claim()
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
@@ -30,6 +41,12 @@ sw.addEventListener('fetch', (event) => {
|
||||
|
||||
const url = new URL(request.url);
|
||||
|
||||
// Uncached static assets
|
||||
if (url.pathname.endsWith('manifest.json') || url.pathname.includes('/icons/')) {
|
||||
event.respondWith(fetch(request));
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. Static Assets (Cache-First)
|
||||
if (ASSETS.includes(url.pathname) || url.pathname.startsWith('/_app/')) {
|
||||
event.respondWith(
|
||||
|
||||
Reference in New Issue
Block a user