Initial commit: Premier Gunner tracker + StartOS 0.4.0 s9pk package

This commit is contained in:
Keysat
2026-05-31 21:04:48 -05:00
commit 0265699504
67 changed files with 4578 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
const CACHE = 'premier-gunner-v1';
const SHELL = [
'/', '/index.html', '/login.html',
'/css/styles.css',
'/js/app.js', '/js/api.js', '/js/dashboard.js',
'/vendor/chart.umd.min.js',
'/manifest.webmanifest',
'/icons/logo.svg', '/icons/favicon.svg',
'/icons/icon-192.png', '/icons/icon-512.png',
];
self.addEventListener('install', (e) => {
e.waitUntil(caches.open(CACHE).then((c) => c.addAll(SHELL)).then(() => self.skipWaiting()));
});
self.addEventListener('activate', (e) => {
e.waitUntil(
caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k))))
.then(() => self.clients.claim())
);
});
self.addEventListener('fetch', (e) => {
const url = new URL(e.request.url);
if (e.request.method !== 'GET') return;
// Never cache the API — always go to network so data stays fresh and auth works.
if (url.pathname.startsWith('/api/')) return;
e.respondWith(
caches.match(e.request).then((cached) => {
const network = fetch(e.request).then((res) => {
if (res.ok && url.origin === location.origin) {
const copy = res.clone();
caches.open(CACHE).then((c) => c.put(e.request, copy));
}
return res;
}).catch(() => cached);
return cached || network;
})
);
});