diff --git a/Graphia.wasm b/Graphia.wasm index 1313616..56153f5 100755 Binary files a/Graphia.wasm and b/Graphia.wasm differ diff --git a/coi-serviceworker.js b/coi-serviceworker.js index 9901474..72cc646 100644 --- a/coi-serviceworker.js +++ b/coi-serviceworker.js @@ -60,46 +60,23 @@ if (typeof window === 'undefined') { } else { (() => { - const reloadedBySelf = window.sessionStorage.getItem("coiReloadedBySelf"); - window.sessionStorage.removeItem("coiReloadedBySelf"); - const coepDegrading = (reloadedBySelf == "coepdegrade"); - // You can customize the behavior of this script through a global `coi` variable. const coi = { - shouldRegister: () => !reloadedBySelf, + shouldRegister: () => true, shouldDeregister: () => false, - coepCredentialless: () => true, - coepDegrade: () => true, + coepCredentialless: () => !(window.chrome || window.netscape), doReload: () => window.location.reload(), quiet: false, ...window.coi }; const n = navigator; - const controlling = n.serviceWorker && n.serviceWorker.controller; - - // Record the failure if the page is served by serviceWorker. - if (controlling && !window.crossOriginIsolated) { - window.sessionStorage.setItem("coiCoepHasFailed", "true"); - } - const coepHasFailed = window.sessionStorage.getItem("coiCoepHasFailed"); - if (controlling) { - // Reload only on the first failure. - const reloadToDegrade = coi.coepDegrade() && !( - coepDegrading || window.crossOriginIsolated - ); + if (n.serviceWorker && n.serviceWorker.controller) { n.serviceWorker.controller.postMessage({ type: "coepCredentialless", - value: (reloadToDegrade || coepHasFailed && coi.coepDegrade()) - ? false - : coi.coepCredentialless(), + value: coi.coepCredentialless(), }); - if (reloadToDegrade) { - !coi.quiet && console.log("Reloading page to degrade COEP."); - window.sessionStorage.setItem("coiReloadedBySelf", "coepdegrade"); - coi.doReload("coepdegrade"); - } if (coi.shouldDeregister()) { n.serviceWorker.controller.postMessage({ type: "deregister" }); @@ -115,32 +92,27 @@ if (typeof window === 'undefined') { return; } - // In some environments (e.g. Firefox private mode) this won't be available - if (!n.serviceWorker) { - !coi.quiet && console.error("COOP/COEP Service Worker not registered, perhaps due to private mode."); - return; - } - - n.serviceWorker.register(window.document.currentScript.src).then( - (registration) => { - !coi.quiet && console.log("COOP/COEP Service Worker registered", registration.scope); + // In some environments (e.g. Chrome incognito mode) this won't be available + if (n.serviceWorker) { + n.serviceWorker.register(window.document.currentScript.src).then( + (registration) => { + !coi.quiet && console.log("COOP/COEP Service Worker registered", registration.scope); - registration.addEventListener("updatefound", () => { - !coi.quiet && console.log("Reloading page to make use of updated COOP/COEP Service Worker."); - window.sessionStorage.setItem("coiReloadedBySelf", "updatefound"); - coi.doReload(); - }); + registration.addEventListener("updatefound", () => { + !coi.quiet && console.log("Reloading page to make use of updated COOP/COEP Service Worker."); + coi.doReload(); + }); - // If the registration is active, but it's not controlling the page - if (registration.active && !n.serviceWorker.controller) { - !coi.quiet && console.log("Reloading page to make use of COOP/COEP Service Worker."); - window.sessionStorage.setItem("coiReloadedBySelf", "notcontrolling"); - coi.doReload(); + // If the registration is active, but it's not controlling the page + if (registration.active && !n.serviceWorker.controller) { + !coi.quiet && console.log("Reloading page to make use of COOP/COEP Service Worker."); + coi.doReload(); + } + }, + (err) => { + !coi.quiet && console.error("COOP/COEP Service Worker failed to register:", err); } - }, - (err) => { - !coi.quiet && console.error("COOP/COEP Service Worker failed to register:", err); - } - ); + ); + } })(); } diff --git a/index.html b/index.html index 741790e..3e1c3ef 100644 --- a/index.html +++ b/index.html @@ -1,6 +1,7 @@
+