Remove PWA support
Build Docker Image & Security / build-scan-push (push) Successful in 2m5s

This commit is contained in:
2026-07-07 15:33:02 +01:00
parent 12dafef7d3
commit 8f60b5dcda
5 changed files with 6 additions and 162 deletions
+5 -77
View File
@@ -1,85 +1,13 @@
const CACHE_NAME = 'sysadmin-arcade-v2';
const PRECACHE_URLS = [
'./',
'./index.html',
'./games.json',
'./manifest.webmanifest',
'./favicon/arcade-favicon.ico',
'./favicon/arcade-favicon-16.png',
'./favicon/arcade-favicon-32.png',
'./favicon/arcade-favicon-180.png',
'./favicon/arcade-favicon-192.png',
'./favicon/arcade-favicon-512.png',
'./games/uptime/uptime-incident-response.html',
'./games/uptime/manifest.webmanifest',
'./games/uptime/favicon/favicon.svg',
'./games/uptime/favicon/favicon.ico',
'./games/uptime/favicon/favicon-16.png',
'./games/uptime/favicon/favicon-32.png',
'./games/uptime/favicon/favicon-180.png',
'./games/uptime/favicon/favicon-192.png',
'./games/uptime/favicon/favicon-512.png'
];
const cacheUrl = (path) => new URL(path, self.registration.scope).href;
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(CACHE_NAME)
.then((cache) => cache.addAll(PRECACHE_URLS.map(cacheUrl)))
.then(() => self.skipWaiting())
);
event.waitUntil(self.skipWaiting());
});
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys()
.then((keys) => Promise.all(
keys
.filter((key) => key !== CACHE_NAME)
.map((key) => caches.delete(key))
))
.then(() => self.clients.claim())
);
});
self.addEventListener('fetch', (event) => {
const { request } = event;
const url = new URL(request.url);
if (request.method !== 'GET' || url.origin !== self.location.origin) return;
if (request.mode === 'navigate') {
event.respondWith(
fetch(request)
.then((response) => {
const responseCopy = response.clone();
caches.open(CACHE_NAME).then((cache) => cache.put(request, responseCopy));
return response;
})
.catch(async () => {
const fallback = url.pathname.includes('/games/uptime/')
? './games/uptime/uptime-incident-response.html'
: './index.html';
return await caches.match(request) || await caches.match(cacheUrl(fallback));
})
);
return;
}
event.respondWith(
caches.match(request).then((cachedResponse) => {
if (cachedResponse) return cachedResponse;
return fetch(request).then((response) => {
if (!response || response.status !== 200 || response.type !== 'basic') return response;
const responseCopy = response.clone();
caches.open(CACHE_NAME).then((cache) => cache.put(request, responseCopy));
return response;
});
})
.then((keys) => Promise.all(keys.map((key) => caches.delete(key))))
.then(() => self.registration.unregister())
.then(() => self.clients.matchAll({ type: 'window' }))
.then((clients) => clients.forEach((client) => client.navigate(client.url)))
);
});