This repository was archived by the owner on Mar 21, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsw.js
More file actions
1 lines (1 loc) · 1.48 KB
/
Copy pathsw.js
File metadata and controls
1 lines (1 loc) · 1.48 KB
1
const e="portfolio-v1.0.3",t="127.0.0.1"===self.location.hostname||"localhost"===self.location.hostname,s=t?"":"/Portfolio",a=[`${s}/`,`${s}/index.html`,`${s}/main.css`,`${s}/main.js`,`${s}/manifest.json`,`${s}/Images/Logo/Character.webp`,`${s}/Images/Logo/Character 2.webp`,`${s}/Images/Logo/About me.webp`,`${s}/Images/Favicon/Favicon.png`,`${s}/Images/Favicon/Favicon.webp`,`${s}/Images/Favicon/Favicon-192.png`,`${s}/Images/Favicon/Favicon-512.png`,`${s}/Images/Favicon/Favicon-maskable-192.png`,`${s}/Images/Favicon/Favicon-maskable-512.png`,`${s}/Images/Screenshots/desktop.png`,`${s}/Images/Screenshots/mobile.png`,`${s}/Images/Projects/1.gif`];self.addEventListener("install",t=>{self.skipWaiting(),t.waitUntil(caches.open(e).then(e=>e.addAll(a)))}),self.addEventListener("activate",t=>{t.waitUntil(Promise.all([self.clients.claim(),caches.keys().then(t=>Promise.all(t.map(t=>{if(t!==e)return caches.delete(t)})))]))}),self.addEventListener("fetch",t=>{"GET"===t.request.method&&(t.request.headers.get("accept").includes("text/html")?t.respondWith(fetch(t.request).then(s=>{const a=s.clone();return caches.open(e).then(e=>{e.put(t.request,a)}),s}).catch(()=>caches.match(t.request))):t.respondWith(caches.match(t.request).then(a=>a||fetch(t.request).then(s=>{if(!s||200!==s.status||"basic"!==s.type)return s;const a=s.clone();return caches.open(e).then(e=>{t.request.url.includes("/api/")||e.put(t.request,a)}),s}).catch(()=>{if("navigate"===t.request.mode)return caches.match(`${s}/index.html`)}))))});