Files
simtrace-analyser/frontend/sw.js
T
catarrh 06c6e952a9 Change details: labelled APDU/time in the header, no zero counts (v2.7.4)
- the header's trailing meta is labelled instead of bare numbers:
  "ADF/EF_IMSI (6F07) — READ BINARY · APDU #490 · 0251.199 sec" (the record
  part already read "Record 2 / 5")
- the summary counts only what happened: "{c} bytes changed · {n} bytes newly
  observed" drops whichever part is zero ("4 bytes changed" alone when nothing
  was first observed) and an empty diff reads "No changes" instead of
  "0 bytes changed, 0 bytes newly observed"
- i18n: the combined key splits into '{c} bytes changed' / '{n} bytes newly
  observed' plus 'No changes', 'APDU' and 'sec' ('{c}','{n}' placeholders keep
  the existing replace-based substitution; the Russian keeps the established
  wording: «Изменено байт: {c}», «Впервые наблюдается байт: {n}», «с»)
- tests: the header and summary assertions follow the labels, a short-file
  case pins the omitted zero, and an empty-diff case pins 'No changes';
  527 Python + 76 Node tests
- PWA_VERSION/pyproject/version.py 2.7.4, SW cache simtrace-analyser-v84
2026-10-18 00:46:42 +03:00

49 lines
1.4 KiB
JavaScript

const CACHE = 'simtrace-analyser-v84';
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))
);
});