Every icon is rendered from web/scripts/logo-source.png by scripts/icons.mjs: trimmed to the artwork's own edge, transparent corners for the browser icons, a dark ground from the artwork's palette for iOS (which paints transparency black) and for Android's maskable icon, where the whole artwork sits inside the 80% safe circle. The login screen no longer crops the logo to a circle or repeats the wordmark. Service worker cache bumped so installed apps fetch the new files. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
18 lines
1.2 KiB
JavaScript
18 lines
1.2 KiB
JavaScript
// Ham Lab service worker: cache hashed assets, never the API, network-first for the shell.
|
|
const CACHE = 'hamlab-v3'; // bumped when files under /icons/ change: they are served cache-first
|
|
self.addEventListener('install', () => self.skipWaiting());
|
|
self.addEventListener('activate', (e) => {
|
|
e.waitUntil(caches.keys().then((ks) => Promise.all(ks.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' || url.origin !== location.origin || url.pathname.startsWith('/api/')) return;
|
|
if (url.pathname.startsWith('/assets/') || url.pathname.startsWith('/icons/')) {
|
|
e.respondWith(caches.open(CACHE).then(async (c) => (await c.match(e.request)) || fetch(e.request).then((r) => { if (r.ok) c.put(e.request, r.clone()); return r; })));
|
|
return;
|
|
}
|
|
// navigations + everything else: network first, fall back to cached index
|
|
e.respondWith(fetch(e.request).then((r) => { if (r.ok && e.request.mode === 'navigate') caches.open(CACHE).then((c) => c.put('/', r.clone())); return r; })
|
|
.catch(() => caches.match(e.request.mode === 'navigate' ? '/' : e.request)));
|
|
});
|