Offline shell (precache, offline notice) and accessibility layer (skip link, button names, sheet focus and Escape)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
nmemmertandClaude Sonnet 5.5 committed 2026-10-22 07:46:10 -04:00
1 parent df8c6ce586
commit 4625848048
5 files changed
+81 -7

No files matched your search

+16 -5
View File
@@ -1,11 +1,22 @@
// App-shell cache only; Seafile/API traffic always goes to the network.
const CACHE = 'hub-v6';
const CACHE = 'hub-v7';
const SHELL = ['/icon.svg', '/manifest.webmanifest', '/icons/icon-192.png', '/icons/apple-touch-icon.png'];
self.addEventListener('install', e => {
e.waitUntil(caches.open(CACHE).then(c => c.addAll(SHELL)));
self.skipWaiting();
});
// Install: keep the icons, and (when signed in) the page itself with the scripts and styles it names, so the app opens offline.
async function precache() {
const c = await caches.open(CACHE);
await c.addAll(SHELL);
try {
const r = await fetch('/', { credentials: 'same-origin', redirect: 'manual' });
if (r.ok) {
const html = await r.clone().text();
await c.put('/', r);
const urls = [...html.matchAll(/(?:src|href)="(\/[^"]+\.(?:js|css)(?:\?[^"]*)?)"/g)].map(m => m[1]);
await Promise.all(urls.map(u => c.add(u).catch(() => {})));
}
} catch { /* signed out or offline: it is cached the first time it is used */ }
}
self.addEventListener('install', e => { e.waitUntil(precache()); self.skipWaiting(); });
self.addEventListener('activate', e => {
e.waitUntil(caches.keys().then(ks => Promise.all(ks.filter(k => k !== CACHE).map(k => caches.delete(k)))));
self.clients.claim();