1// Klipio service worker â makes the app installable + a basic network-first offline shell. 2// It never touches /api or /share (downloads + the share target must always hit the network). 3const CACHE = "klipio-v4-studio1"; 4const SHELL = ["/"]; 5 6self.addEventListener("install", (e) => { 7 self.skipWaiting(); 8 e.waitUntil(caches.open(CACHE).then((c) => c.addAll(SHELL).catch(() => {}))); 9}); 10 11self.addEventListener("activate", (e) => { 12 e.waitUntil(Promise.all([ 13 caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))), 14 self.clients.claim(), 15 ])); 16}); 17 18self.addEventListener("fetch", (e) => { 19 const url = new URL(e.request.url); 20 if (e.request.method !== "GET" || url.origin !== self.location.origin || url.pathname.startsWith("/api") || url.pathname.startsWith("/share") || url.pathname.startsWith("/b/")) return; 21 e.respondWith( 22 fetch(e.request) 23 .then((r) => { 24 if (r.ok && url.origin === self.location.origin) { 25 const copy = r.clone(); 26 caches.open(CACHE).then((c) => c.put(e.request, copy)); 27 } 28 return r; 29 }) 30 .catch(() => 31 caches.match(e.request).then((r) => { 32 if (r) return r; 33 // Only fall back to the app shell for page navigations. NEVER return index.html for a failed 34 // JS/CSS/asset request â that serves HTML where the browser expects a script and breaks the app. 35 if (e.request.mode === "navigate") return caches.match("/"); 36 return Response.error(); 37 }) 38 ) 39 ); 40});
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.