From 525b30c9bb827811fc3d8c0b439d0a29ea3277f9 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Mon, 1 Aug 2022 09:01:00 +0200 Subject: [PATCH] Revert adding empty `window` object to node sandbox --- packages/plugos/environments/node_worker.ts | 1 - packages/plugos/environments/sandbox_worker.ts | 10 +--------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/packages/plugos/environments/node_worker.ts b/packages/plugos/environments/node_worker.ts index 0fe9f96..1de9666 100644 --- a/packages/plugos/environments/node_worker.ts +++ b/packages/plugos/environments/node_worker.ts @@ -39,7 +39,6 @@ let vm = new VM({ clearTimeout, setInterval, URL, - window: {}, clearInterval, fetch: require(`${nodeModulesPath}/node-fetch`), WebSocket: require(`${nodeModulesPath}/ws`), diff --git a/packages/plugos/environments/sandbox_worker.ts b/packages/plugos/environments/sandbox_worker.ts index 90a991d..a8961c8 100644 --- a/packages/plugos/environments/sandbox_worker.ts +++ b/packages/plugos/environments/sandbox_worker.ts @@ -11,16 +11,8 @@ let pendingRequests = new Map< } >(); -let isWorker = false; - -if (typeof window === "undefined") { - // @ts-ignore - window = {}; - isWorker = true; -} - function workerPostMessage(msg: ControllerMessage) { - if (!isWorker && window.parent !== window) { + if (typeof window !== "undefined" && window.parent !== window) { window.parent.postMessage(msg, "*"); } else { self.postMessage(msg);