const staticLooper = "looper-app-v1";
const assets = [
    "/",
    "/index.html",
    "/shell.js",
    "/icon.png",
    "/icon.svg",
    "/index.wasm",
    "/index.js"
];
const devAssets = [
    "/index.html.symbols",
    "/index.wasm.map"
];
self.addEventListener("message", (event) => {
    if (event.data) {
        switch (event.data.type) {
            case "UNREGISTER": {
                self.unregister();
            } break;
            case "UPDATE": {
                caches.open(staticLooper).then(async cache => {
                    await cache.addAll(assets);
                    try {
                        await cache.addAll(devAssets);
                    } catch (e) {
                        console.warn("Could not add developer assets!");
                    }
                })
            } break;
        }
    }
})
self.addEventListener("install", installEvent => {
    installEvent.waitUntil(
        self.postMessage({
            type: "UPDATE"
        })
    )
});
self.addEventListener("fetch", fetchEvent => {
    fetchEvent.respondWith(
        caches.match(fetchEvent.request).then(res => {
            return res || fetch(fetchEvent.request);
        })
    )
});