/* Vramwise offline cache. © 2026 CyberMax. All rights reserved. */ /* 16 Oct 2026: './' is not precached: the Hugging Face static host answers 404 for a folder URL, which made the whole install fail (no offline). Navigations fall back to index.html. */ var CACHE = "vramwise-v5"; var FILES = ["index.html", "style.css", "pro.js", "fit.css", "vramwise.js", "app.js", "manifest.webmanifest", "icon.svg", "icon-192.png", "icon-512.png"]; self.addEventListener("install", function (e) { e.waitUntil(caches.open(CACHE).then(function (c) { return c.addAll(FILES); }).then(function () { return self.skipWaiting(); })); }); self.addEventListener("activate", function (e) { e.waitUntil(caches.keys().then(function (keys) { return Promise.all(keys.filter(function (k) { return k !== CACHE; }).map(function (k) { return caches.delete(k); })); }).then(function () { return self.clients.claim(); })); }); self.addEventListener("fetch", function (e) { if (e.request.method !== "GET" || new URL(e.request.url).origin !== location.origin) return; // Network first so updates arrive quickly; cache as offline fallback. e.respondWith(fetch(e.request).then(function (r) { var copy = r.clone(); caches.open(CACHE).then(function (c) { c.put(e.request, copy); }); return r; }).catch(function () { return caches.match(e.request, { ignoreSearch: true }).then(function (h) { return h || (e.request.mode === "navigate" ? caches.match("index.html") : h); }); })); });