- move the analysis server out of simtrace2_pysniff into simtrace_analyser; simtrace2_pysniff stays as the simtrace2-sniff replacement capture utility - new server CLI: simtrace-analyser-server; python -m simtrace_analyser (simtrace2-pysniff-server and python -m simtrace2_pysniff.server dropped) - simtrace2_pysniff lazy-imports hardware symbols, so the server no longer pulls PyUSB at startup; the GSMTAP/PCAP codecs work without libusb - version 2.0.0 everywhere (was 1.22.21); PWA SW cache simtrace-analyser-v54 - frontend: server name, clone URL and i18n strings updated; vendored-parser reference otaman -> SIMple - README/README_RUS reworked product-first (analyser first, utility second) - DB dir ~/.simtrace-analyser, /api status payload and hosted PWA unchanged
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
const CACHE = 'simtrace-analyser-v54';
|
|
|
|
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))
|
|
);
|
|
});
|