diff --git a/deno.jsonc b/deno.jsonc index 9d2c33f..c75dfd0 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,3 +1,4 @@ { - "fmt": { "indentWidth": 4 } + "fmt": { "indentWidth": 4 }, + "lib": ["dom", "dom.iterable", "dom.asynciterable", "deno.ns"] } diff --git a/js/code-runner.js b/js/code-runner.js index ea2233f..c860d58 100644 --- a/js/code-runner.js +++ b/js/code-runner.js @@ -14,10 +14,12 @@ export class CodeRunner { this.console.log("Running code..."); // Stored globally so lib.js can access it - window.libInternalAbortController = new AbortController(); + globalThis.libInternalAbortController = new AbortController(); // Use RNG to prevent caching - const encodedText = encodeURIComponent(this.code + `/*(tph): ${Math.random()}*/`); + const encodedText = encodeURIComponent( + this.code + `/*(tph): ${Math.random()}*/`, + ); try { await import(`data:text/javascript;charset=utf-8,${encodedText}`); @@ -29,7 +31,7 @@ export class CodeRunner { stop() { this.isRunning = false; - window.libInternalAbortController?.abort(); + globalThis.libInternalAbortController?.abort(); } toggle() { @@ -37,4 +39,3 @@ export class CodeRunner { else this.run(); } } - diff --git a/js/index.js b/js/index.js index 46e88e9..3379c0d 100644 --- a/js/index.js +++ b/js/index.js @@ -4,7 +4,9 @@ import { Debounce } from "./debounce.js"; import { PlaygroundConsole } from "./playground-console.js"; import { CodeRunner } from "./code-runner.js"; -const playgroundConsole = new PlaygroundConsole(document.querySelector("#console-code")); +const playgroundConsole = new PlaygroundConsole( + document.querySelector("#console-code"), +); const codeRunner = new CodeRunner(playgroundConsole); const editor = ace.edit("editor"); diff --git a/js/lib.js b/js/lib.js index 9ede8e6..12942f1 100644 --- a/js/lib.js +++ b/js/lib.js @@ -40,7 +40,7 @@ export function startGameLoop(loopFunction) { loopFunction(deltaT); }, 16); - const abortSignal = window.libInternalAbortController.signal; + const abortSignal = globalThis.libInternalAbortController.signal; if (abortSignal) { if (abortSignal.aborted) { clearInterval(loopInterval); diff --git a/js/playground-console.js b/js/playground-console.js index 2191731..5929708 100644 --- a/js/playground-console.js +++ b/js/playground-console.js @@ -7,4 +7,3 @@ export class PlaygroundConsole { this.elem.textContent += `\n${text}\n`; } } -