mirror of
https://github.com/GuerillaStudio/souvenir.git
synced 2025-01-20 18:30:20 +00:00
15 lines
431 B
JavaScript
15 lines
431 B
JavaScript
import { manifest, version } from '@parcel/service-worker'
|
|
|
|
async function install () {
|
|
const cache = await caches.open(version)
|
|
await cache.addAll(manifest)
|
|
}
|
|
addEventListener('install', e => e.waitUntil(install()))
|
|
|
|
async function activate () {
|
|
const keys = await caches.keys()
|
|
await Promise.all(
|
|
keys.map(key => key !== version && caches.delete(key))
|
|
)
|
|
}
|
|
addEventListener('activate', e => e.waitUntil(activate()))
|