Initial commit

This commit is contained in:
Kerboul
2026-03-09 07:44:27 -07:00
commit 14031f73a3
7 changed files with 589 additions and 0 deletions

48
sw.js Normal file
View File

@@ -0,0 +1,48 @@
const CACHE_NAME = 'amusement-pwa-cache-v1';
const urlsToCache = [
'./',
'./index.html',
'./style.css',
'./app.js',
'./manifest.json',
'./icon.svg',
'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700;800&family=Outfit:wght@400;600;800&display=swap'
];
self.addEventListener('install', event => {
event.waitUntil(
caches.open(CACHE_NAME)
.then(cache => {
return cache.addAll(urlsToCache);
})
);
});
self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request)
.then(response => {
// Cache hit - return response
if (response) {
return response;
}
return fetch(event.request);
}
)
);
});
self.addEventListener('activate', event => {
const cacheWhitelist = [CACHE_NAME];
event.waitUntil(
caches.keys().then(cacheNames => {
return Promise.all(
cacheNames.map(cacheName => {
if (cacheWhitelist.indexOf(cacheName) === -1) {
return caches.delete(cacheName);
}
})
);
})
);
});