// NOTE: This file creates a service worker that cross-origin-isolates the page (read more here: https://web.dev/coop-coep/) which allows us to use wasm threads.
// Normally you would set the COOP and COEP headers on the server to do this, but Github Pages doesn't allow this, so this is a hack to do that.
/* Edited version of: coi-serviceworker v0.1.6 - Guido Zuidhof, licensed under MIT */
// From here: https://github.com/gzuidhof/coi-serviceworker
if(request.mode==="no-cors"){// We need to set `credentials` to "omit" for no-cors requests, per this comment: https://bugs.chromium.org/p/chromium/issues/detail?id=1309901#c7
letregistration=awaitnavigator.serviceWorker.register(window.document.currentScript.src).catch(e=>console.error("COOP/COEP Service Worker failed to register:",e));
if(registration){
console.log("COOP/COEP Service Worker registered",registration.scope);
registration.addEventListener("updatefound",()=>{
console.log("Reloading page to make use of updated COOP/COEP Service Worker.");
window.location.reload();
});
// If the registration is active, but it's not controlling the page