fmt + fix deno.jsonc.lib
This commit is contained in:
parent
e9719acb59
commit
6e641e5d6d
@ -1,3 +1,4 @@
|
||||
{
|
||||
"fmt": { "indentWidth": 4 }
|
||||
"fmt": { "indentWidth": 4 },
|
||||
"lib": ["dom", "dom.iterable", "dom.asynciterable", "deno.ns"]
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
|
@ -7,4 +7,3 @@ export class PlaygroundConsole {
|
||||
this.elem.textContent += `\n${text}\n`;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user