Download static/sw.js from CVNSS/dich: direct link, hf CLI and curl.
- Browser
- Download file 961 Bytes
-
https://huggingface.co/spaces/CVNSS/dich/resolve/main/static/sw.js
- Command line
-
hf download hf://spaces/CVNSS/dich/static/sw.js
-
curl -L -o sw.js https://huggingface.co/spaces/CVNSS/dich/resolve/main/static/sw.js
961 Bytes
| const CACHE = "bila-translator-shell-v4"; | |
| const ASSETS = ["/", "/static/index.html", "/static/style.css", "/static/app.js", "/static/cvnss.js", "/static/manifest.webmanifest"]; | |
| 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))))); | |
| self.clients.claim(); | |
| }); | |
| self.addEventListener("fetch", event => { | |
| const url = new URL(event.request.url); | |
| if (event.request.method !== "GET") return; | |
| if (url.pathname.startsWith("/api/")) return; | |
| event.respondWith(caches.match(event.request).then(hit => hit || fetch(event.request).then(res => { | |
| const copy = res.clone(); | |
| caches.open(CACHE).then(cache => cache.put(event.request, copy)); | |
| return res; | |
| }).catch(() => caches.match("/")))); | |
| }); | |