- Full UI dictionaries for French, Italian and Spanish (all views, wizard, legal gate, templates); browser-language auto-detection extended to all five locales - Fallback architecture: LText now carries optional fr/it/es entries; regulatory legal texts (content pack, classify reasons, document strings) fall back to English until legal translations land — clearly stated in the language setting - Locale-aware date formatting (DE dots, FR/IT/ES slashes, EN ISO) - PWA: web app manifest, network-first service worker with offline cache fallback, generated icons (512/192/apple-touch) — installable on phone home screen and macOS dock - 2 new tests incl. dictionary-completeness check for FR/IT/ES (58 total) Claude-Session: https://claude.ai/code/session_017YjohVNx1ZGNM4MX7tHpfv
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
/*
|
|
* Service Worker des AI-Act-Kompass.
|
|
* Strategie: Network-first mit Cache-Fallback — die App bleibt offline
|
|
* nutzbar (Handy/Mac), lädt aber online immer die aktuelle Version.
|
|
* Es werden ausschließlich eigene (same-origin) GET-Antworten gecacht.
|
|
*/
|
|
const CACHE = 'ai-act-kompass-v1';
|
|
|
|
self.addEventListener('install', () => {
|
|
self.skipWaiting();
|
|
});
|
|
|
|
self.addEventListener('activate', (event) => {
|
|
event.waitUntil(
|
|
caches
|
|
.keys()
|
|
.then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k))))
|
|
.then(() => self.clients.claim()),
|
|
);
|
|
});
|
|
|
|
self.addEventListener('fetch', (event) => {
|
|
const { request } = event;
|
|
if (request.method !== 'GET' || new URL(request.url).origin !== location.origin) {
|
|
return;
|
|
}
|
|
event.respondWith(
|
|
caches.open(CACHE).then(async (cache) => {
|
|
try {
|
|
const fresh = await fetch(request);
|
|
if (fresh.ok) {
|
|
cache.put(request, fresh.clone());
|
|
}
|
|
return fresh;
|
|
} catch (err) {
|
|
const cached = await cache.match(request, { ignoreSearch: true });
|
|
if (cached) return cached;
|
|
if (request.mode === 'navigate') {
|
|
const shell = await cache.match('./index.html');
|
|
if (shell) return shell;
|
|
}
|
|
throw err;
|
|
}
|
|
}),
|
|
);
|
|
});
|