From c004ebb3ab4993f87e4e86021bf047850aac4ee6 Mon Sep 17 00:00:00 2001 From: Rob Blanckaert Date: Sat, 22 Nov 2025 14:28:35 -0800 Subject: [PATCH] Use global this for scheduler access This makes libv86 work inside shared workers again. --- src/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index 30a85db9..2e45b98e 100644 --- a/src/main.js +++ b/src/main.js @@ -114,12 +114,12 @@ if(typeof process !== "undefined") v86.prototype.register_yield = function() {}; v86.prototype.unregister_yield = function() {}; } -else if(window["scheduler"] && typeof window["scheduler"]["postTask"] === "function" && location.href.includes("use-scheduling-api")) +else if(globalThis["scheduler"] && typeof globalThis["scheduler"]["postTask"] === "function" && location.href.includes("use-scheduling-api")) { v86.prototype.yield = function(t, tick) { t = Math.max(0, t); - window["scheduler"]["postTask"](() => this.yield_callback(tick), { delay: t }); + globalThis["scheduler"]["postTask"](() => this.yield_callback(tick), { delay: t }); }; v86.prototype.register_yield = function() {};