diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-29 20:19:34 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-29 20:19:34 +0300 |
| commit | 4a70c0ea083306cb79d0fa325d331ffa4333154a (patch) | |
| tree | 84df7e2f781974ef45ac8c34f1a59e80fdd5c41d /web/sw.js | |
| parent | cf30414c2a0696cc75c615f4da66ea85d0522c42 (diff) | |
feat: create web PWA frontend
Diffstat (limited to 'web/sw.js')
| -rw-r--r-- | web/sw.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/web/sw.js b/web/sw.js new file mode 100644 index 0000000..aef24d5 --- /dev/null +++ b/web/sw.js @@ -0,0 +1,41 @@ +const CACHE = 'kiss-v1'; +const ASSETS = [ + '/', + '/index.html', + '/login.html', + '/bootstrap.html', + '/css/theme.css', + '/css/layout.css', + '/css/components.css', + '/css/player.css', + '/css/login.css', + '/js/app.js', + '/js/state.js', + '/js/api.js', + '/js/keyboard.js', + '/js/selection.js', + '/js/player.js', + '/js/search.js', + '/js/shuffle.js', + '/js/themes.js', + '/js/notes.js', + '/js/admin.js', + '/js/pwa.js', + '/manifest.json', +]; + +self.addEventListener('install', (e) => { + e.waitUntil(caches.open(CACHE).then((c) => c.addAll(ASSETS))); +}); + +self.addEventListener('activate', (e) => { + e.waitUntil( + caches.keys().then((keys) => + Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k))) + ) + ); +}); + +self.addEventListener('fetch', (e) => { + e.respondWith(caches.match(e.request).then((res) => res || fetch(e.request))); +}); |
