1const CACHE_NAME = "chinski-shell-v2"; 2const CORE_ASSETS = ["/", "/manifest.webmanifest", "/app-icon-192-v2.png", "/app-icon-512-v2.png", "/art-icons-book-v1.png", "/chinese-writing-book.jpg"]; 3 4self.addEventListener("install", (event) => { 5 event.waitUntil(caches.open(CACHE_NAME).then((cache) => cache.addAll(CORE_ASSETS)).then(() => self.skipWaiting())); 6}); 7 8self.addEventListener("activate", (event) => { 9 event.waitUntil(caches.keys().then((keys) => Promise.all(keys.filter((key) => key.startsWith("chinski-shell-") && key !== CACHE_NAME).map((key) => caches.delete(key)))).then(() => self.clients.claim())); 10}); 11 12self.addEventListener("fetch", (event) => { 13 const url = new URL(event.request.url); 14 if (event.request.method !== "GET" || url.origin !== self.location.origin || url.pathname.startsWith("/api/")) return; 15 event.respondWith(fetch(event.request).then((response) => { 16 if (response.ok) void caches.open(CACHE_NAME).then((cache) => cache.put(event.request, response.clone())); 17 return response; 18 }).catch(() => caches.match(event.request).then((cached) => cached || caches.match("/")))); 19});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.