SLC_Game/04_Tablet-Quiz/app/sw.js
breitenbach76 7f0e847561 Companion-App: zur deploybaren PWA ausgebaut (statisch)
- 04_Tablet-Quiz/prototype -> app/ (deploybarer Stand).
- PWA: manifest.webmanifest + sw.js (Offline-App-Shell) + icon.svg, im <head>
  eingebunden, Service-Worker-Registrierung.
- Debrief-Export als Datei-Download (Markdown UND JSON) ergaenzt.
- DEPLOY.md: Anleitung fuer statisches Hosting (nginx/Caddy, HTTPS, Verifikation).
- README: Umsetzungsstand + MVP-Haken aktualisiert.
- .claude/launch.json (lokale Preview), settings.local.json ge-gitignored.

Verifiziert: 40 Stationen / 3 Gates / 45 Quizfragen, JS+SW-Syntax + Manifest
valide, alle Assets via http 200. (Inhalte noch in index.html eingebettet;
YAML-Pipeline = naechster Schritt.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-05 14:37:38 +02:00

33 lines
957 B
JavaScript

/* Service Worker — SLC-Workshop Companion (App-Shell, offline-first) */
const CACHE = "slc-companion-v1";
const ASSETS = ["./", "index.html", "manifest.webmanifest", "icon.svg"];
self.addEventListener("install", (e) => {
e.waitUntil(
caches.open(CACHE).then((c) => c.addAll(ASSETS)).then(() => self.skipWaiting())
);
});
self.addEventListener("activate", (e) => {
e.waitUntil(
caches.keys()
.then((ks) => Promise.all(ks.filter((k) => k !== CACHE).map((k) => caches.delete(k))))
.then(() => self.clients.claim())
);
});
self.addEventListener("fetch", (e) => {
if (e.request.method !== "GET") return;
e.respondWith(
caches.match(e.request).then((hit) =>
hit ||
fetch(e.request)
.then((resp) => {
const copy = resp.clone();
caches.open(CACHE).then((c) => c.put(e.request, copy));
return resp;
})
.catch(() => caches.match("index.html"))
)
);
});