d2bd2ed798
Elements using bare text-gray-300/400/500/600 (proactive log ids and timestamps, expand markers, event codes, ...) kept the light-theme gray values in dark mode, which made them hard to read on slate-800/900. - dark .text-gray-*:not([class*='dark:text-']) rules map them to the same level as the other dark muted text (slate-300 #cbd5e1, slate-200/100 for gray-700/800) - dark:text-gray-400/600 and dark:text-slate-500 normalized to #cbd5e1 - dark:border-slate-600/700/800 (+ /50) brightened one step - light theme unchanged - the whole contrast block moved to src/contrast.css, appended by the npm build scripts after Tailwind so it stays reproducible; SW cache v95 -> v96
56 lines
1.4 KiB
JavaScript
56 lines
1.4 KiB
JavaScript
const CACHE = 'otaman-v96';
|
|
const URLS = [
|
|
'index.html',
|
|
'help.html',
|
|
'help-ru.html',
|
|
'style.css',
|
|
'sim.png',
|
|
'favicon.svg',
|
|
'icon-192.png',
|
|
'icon-512.png',
|
|
'manifest.json',
|
|
'des-bundle.js',
|
|
'aes-bundle.js',
|
|
'sim.svg',
|
|
'sim_anim.svg',
|
|
'nosim.svg',
|
|
];
|
|
|
|
self.addEventListener('install', e => {
|
|
e.waitUntil(
|
|
caches.open(CACHE).then(c => c.addAll(URLS))
|
|
);
|
|
self.skipWaiting();
|
|
});
|
|
|
|
self.addEventListener('activate', e => {
|
|
e.waitUntil(
|
|
caches.keys().then(keys =>
|
|
Promise.all(keys.filter(k => k !== CACHE).map(k => caches.delete(k)))
|
|
).then(() => clients.claim())
|
|
);
|
|
});
|
|
|
|
self.addEventListener('fetch', e => {
|
|
if (!e.request.url.startsWith('http')) return;
|
|
if (new URL(e.request.url).pathname.startsWith('/api/')) return; // live data, never cache
|
|
if (e.request.method !== 'GET') return;
|
|
const isNavigate = e.request.mode === 'navigate' || e.request.url.endsWith('sw.js');
|
|
if (isNavigate) {
|
|
e.respondWith(
|
|
fetch(e.request).then(res => {
|
|
const clone = res.clone();
|
|
caches.open(CACHE).then(c => c.put(e.request, clone));
|
|
return res;
|
|
}).catch(() => caches.match(e.request))
|
|
);
|
|
} else {
|
|
e.respondWith(
|
|
caches.match(e.request).then(r => r || fetch(e.request).then(res => {
|
|
const clone = res.clone();
|
|
caches.open(CACHE).then(c => c.put(e.request, clone));
|
|
return res;
|
|
}))
|
|
);
|
|
}
|
|
}); |