diff --git a/pyodide/serviceworker.js b/pyodide/serviceworker.js index 2f84cfc..feffa74 100644 --- a/pyodide/serviceworker.js +++ b/pyodide/serviceworker.js @@ -11,6 +11,8 @@ self.addEventListener("fetch", (event) => { event.respondWith( fetch(event.request).then(response => { + // if (!response.url.includes("/some/page/that/hosts/the/editor")) { return; } + const body = response.body; const status = response.status; const headers = new Headers(response.headers); diff --git a/pyodide/webworker.js b/pyodide/webworker.js index 394b864..a6e714b 100644 --- a/pyodide/webworker.js +++ b/pyodide/webworker.js @@ -1,3 +1,24 @@ +const supportsAllFeatures = typeof SharedArrayBuffer !== "undefined"; + +if (!supportsAllFeatures && name !== "incremental-features") { + console.warn([ + "The code editor will not be able to capture standard input or stop execution because these HTTP headers are not set:", + " - Cross-Origin-Opener-Policy: same-origin", + " - Cross-Origin-Embedder-Policy: require-corp", + "", + "If your app can cope with or without these features, please initialize the web worker with { name: 'incremental-features' } to silence this warning.", + "You can then check for the presence of { stdinBuffer, interruptBuffer } in the handleLoaded message to check whether these features are supported.", + "", + "If you definitely need these features, either configure your server to respond with the HTTP headers above, or register a service worker.", + "Once the HTTP headers are set, the browser will block cross-domain resources so you will need to add 'crossorigin' to