Skip to content

Commit

Permalink
fix: make window check more robust and cleanup wasm and cookie once s…
Browse files Browse the repository at this point in the history
…cramjet is done initializing
  • Loading branch information
Percslol committed Dec 17, 2024
1 parent 80592c8 commit e149e4a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -34,6 +34,8 @@ if (!(SCRAMJETCLIENT in <Partial<typeof self>>self)) {
client.frame?.dispatchEvent(ev);
}

Reflect.deleteProperty(self, "WASM");
Reflect.deleteProperty(self, "COOKIE");
if ("document" in self && document?.currentScript) {
document.currentScript.remove();
}

0 comments on commit e149e4a

Please sign in to comment.