const cacheName = "Hololight-Hololight Stream-2025.0.1";
const contentToCache = [
    "Build/2025.0.1-Web.loader.js",
    "Build/2025.0.1-Web.framework.js",
    "StreamingAssets/signaling.js",
    "Build/2025.0.1-Web.data",
    "Build/2025.0.1-Web.wasm",
    "TemplateData/style.css"

];

self.addEventListener('install', function (e) {
    e.waitUntil((async function () {
        const cache = await caches.open(cacheName);
        await cache.addAll(contentToCache);
        contentToCache.forEach(function (c) {
            console.log(`${c}`);
        })
    })());
});

self.addEventListener('fetch', function (e) {
    e.respondWith((async function () {
        let response = await caches.match(e.request);
        if (response) { return response; }

        response = await fetch(e.request);
        const cache = await caches.open(cacheName);
        cache.put(e.request, response.clone());
        return response;
    })());
});
