From e149e4af22ac13865221f2daee9350c22a0c499d Mon Sep 17 00:00:00 2001 From: Percs <83934299+Percslol@users.noreply.github.com> Date: Tue, 17 Dec 2024 00:21:55 -0600 Subject: [PATCH] fix: make window check more robust and cleanup wasm and cookie once scramjet is done initializing --- src/client/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client/index.ts b/src/client/index.ts index 8710737..e692055 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -6,7 +6,7 @@ import { ScramjetClient } from "./client"; import { ScramjetContextInit } from "./events"; import { ScramjetServiceWorkerRuntime } from "./swruntime"; -export const iswindow = "window" in self; +export const iswindow = "window" in self && window instanceof Window; export const isworker = "WorkerGlobalScope" in self; export const issw = "ServiceWorkerGlobalScope" in self; export const isdedicated = "DedicatedWorkerGlobalScope" in self; @@ -34,6 +34,8 @@ if (!(SCRAMJETCLIENT in >self)) { client.frame?.dispatchEvent(ev); } +Reflect.deleteProperty(self, "WASM"); +Reflect.deleteProperty(self, "COOKIE"); if ("document" in self && document?.currentScript) { document.currentScript.remove(); }