Files
simtrace-analyser/frontend/sw.js
T
catarrh b8d9c4cc63 COMPRION import dialog: full-width file-name line + RU label rename
- the slot layout now wraps: the label and "Choose file…" share the first
  line, the selected file name gets its own full-width line (the fixed
  200 px label left only ~200 px for the name and overflowed on narrow
  screens); the ellipsis styling is unchanged and only kicks in for
  genuinely long names
- RU label "Импорт трассы COMPRION" -> "Импорт трейсов COMPRION" (the
  button/dialog title and the PCAP-path hint that quotes it); EN strings
  and LANG_RU keys unchanged
- SW cache simtrace-analyser-v62 (label/layout-only, no version bump)
2026-10-17 00:57:43 +03:00

49 lines
1.4 KiB
JavaScript

const CACHE = 'simtrace-analyser-v62';
const PRECACHE = [
'index.html',
'manifest.json',
'icon-192.png',
'icon-512.png',
'favicon.png',
'sim-analyser.svg',
'sim-analyser-light.svg',
];
self.addEventListener('install', e => {
self.skipWaiting();
e.waitUntil(
caches.open(CACHE)
.then(cache => cache.addAll(PRECACHE))
.then(() => console.log('SW: precache done'))
.catch(err => console.error('SW: precache failed', err))
);
});
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())
.then(() => console.log('SW: activated, controlling clients'))
);
});
self.addEventListener('fetch', e => {
// Network-first: the local server is always up, so always serve fresh
// content and fall back to cache only when offline.
if (!e.request.url.startsWith('http')) return;
if (e.request.method !== 'GET') return;
e.respondWith(
fetch(e.request)
.then(r => {
const clone = r.clone();
caches.open(CACHE).then(c => c.put(e.request, clone)).catch(() => {});
return r;
})
.catch(() => caches.match(e.request))
);
});