- the hex views padded every line to 16 bytes with '--', so a 2-byte file looked like it was missing data; the row now ends at the known file/record length (from the FCP — hexImageRows gained the size parameter), while '--' still marks bytes *inside* the file that were never observed (an unknown length keeps the old row padding, nothing better is available) - the offset column is shown only when a view spans more than one row — a four-hex-digit 0000 above two bytes was noise - the legend lists only the marks actually rendered: 'never observed' is gone from a short/fully-observed view, and 'newly observed' when nothing was first observed (the summary line still counts both) - tests: pure hexImageRows cases (the 2-byte file, a 9-byte record with an unobserved tail, the unknown-size fallback) plus two renderFileDiff cases pinning the missing filler/offset and the trimmed legend; 527 Python + 75 Node tests - README/README_RUS describe the new hex-view behaviour; PWA_VERSION/pyproject/version.py 2.7.3, SW cache simtrace-analyser-v83
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
const CACHE = 'simtrace-analyser-v83';
|
|
|
|
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))
|
|
);
|
|
});
|