From 0f4e285a0b7892924c9b2fc7f26fa213fea758ed Mon Sep 17 00:00:00 2001 From: NeroBurner Date: Thu, 31 Mar 2022 20:50:50 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20InfiniTi?= =?UTF-8?q?meOrg/InfiniSim@99a5c95c930cc836c4fb0169f10e7387df5cd1e0=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- coi-serviceworker.js | 93 +++++++++++++++++++++++++++++++++++++++++++ infinisim.html | 2 +- infinisim.wasm | Bin 1170230 -> 1170230 bytes 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 coi-serviceworker.js diff --git a/coi-serviceworker.js b/coi-serviceworker.js new file mode 100644 index 0000000..baa08a0 --- /dev/null +++ b/coi-serviceworker.js @@ -0,0 +1,93 @@ +/*! coi-serviceworker v0.1.6 - Guido Zuidhof, licensed under MIT */ +if (typeof window === 'undefined') { + self.addEventListener("install", () => self.skipWaiting()); + self.addEventListener("activate", (event) => event.waitUntil(self.clients.claim())); + + self.addEventListener("message", (ev) => { + if (ev.data && ev.data.type === "deregister") { + self.registration + .unregister() + .then(() => { + return self.clients.matchAll(); + }) + .then(clients => { + clients.forEach((client) => client.navigate(client.url)); + }); + } + }); + + self.addEventListener("fetch", function (event) { + if (event.request.cache === "only-if-cached" && event.request.mode !== "same-origin") { + return; + } + + event.respondWith( + fetch(event.request) + .then((response) => { + if (response.status === 0) { + return response; + } + + const newHeaders = new Headers(response.headers); + newHeaders.set("Cross-Origin-Embedder-Policy", "require-corp"); + newHeaders.set("Cross-Origin-Opener-Policy", "same-origin"); + + return new Response(response.body, { + status: response.status, + statusText: response.statusText, + headers: newHeaders, + }); + }) + .catch((e) => console.error(e)) + ); + }); + +} else { + (() => { + // You can customize the behavior of this script through a global `coi` variable. + const coi = { + shouldRegister: () => true, + shouldDeregister: () => false, + doReload: () => window.location.reload(), + quiet: false, + ...window.coi + } + + const n = navigator; + if (coi.shouldDeregister() && n.serviceWorker && n.serviceWorker.controller) { + n.serviceWorker.controller.postMessage({ type: "deregister" }); + } + + // If we're already coi: do nothing. Perhaps it's due to this script doing its job, or COOP/COEP are + // already set from the origin server. Also if the browser has no notion of crossOriginIsolated, just give up here. + if (window.crossOriginIsolated !== false || !coi.shouldRegister()) return; + + if (!window.isSecureContext) { + !coi.quiet && console.log("COOP/COEP Service Worker not registered, a secure context is required."); + return; + } + + // 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."); + 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); + } + ); + } + })(); +} diff --git a/infinisim.html b/infinisim.html index bc45fec..359d925 100644 --- a/infinisim.html +++ b/infinisim.html @@ -1 +1 @@ -Emscripten-Generated Codeimage/svg+xml
Downloading...
Resize canvasLock/hide mouse pointer    
\ No newline at end of file +Emscripten-Generated Codeimage/svg+xml
Downloading...
Resize canvasLock/hide mouse pointer    
\ No newline at end of file diff --git a/infinisim.wasm b/infinisim.wasm index aee136085859954b0d067a59accee05f342e76d0..e7ff842c782308fdc28e07655f22504d37a1cf2b 100755 GIT binary patch delta 147 zcmdnC&3)T8_l6e67N#xC`Sy&H+6(NNftUq|S%H`hh}nUd1Bf}d7ua*DuVMPSYx~UC zT;Xm^O}pDa8FB+L4-oSLG2ix2hWyD}VYOSOt}iFxG5;ep1k15CB~ZF{=Oo