Add PWA manifest, service worker, and install hint.

Enables home-screen installation with per-viewer scope and platform-specific guidance in EN/DE.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-20 11:08:32 +02:00
parent 6df10e5498
commit 562a229fa0
14 changed files with 287 additions and 3 deletions
+38
View File
@@ -0,0 +1,38 @@
const CACHE = "if-viewer-static-v1";
const ASSETS = [
"/static/style.css",
"/static/favicon.svg",
"/static/icon-192.png",
"/static/icon-512.png",
"/static/i18n.js",
"/static/locales/en.json",
"/static/locales/de.json",
];
self.addEventListener("install", (event) => {
event.waitUntil(
caches.open(CACHE)
.then((cache) => cache.addAll(ASSETS))
.then(() => 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) => {
if (event.request.method !== "GET") return;
const url = new URL(event.request.url);
if (url.pathname.includes("/api/")) return;
if (!url.pathname.startsWith("/static/")) return;
event.respondWith(
caches.match(event.request).then((cached) => cached || fetch(event.request))
);
});