2024-02-18 00:29:58 +01:00
|
|
|
import { evaluate, getOutputIndex } from "./eval.js";
|
2024-02-17 14:56:17 +01:00
|
|
|
|
|
|
|
let debugLog = console.log;
|
|
|
|
|
|
|
|
globalThis.console = {
|
2024-02-16 22:01:19 +01:00
|
|
|
log(...message) {
|
|
|
|
postMessage({
|
|
|
|
kind: "output",
|
|
|
|
output: {
|
|
|
|
kind: "log",
|
|
|
|
message: [...message],
|
2024-02-17 14:56:17 +01:00
|
|
|
},
|
2024-02-18 00:29:58 +01:00
|
|
|
outputIndex: getOutputIndex(),
|
2024-02-16 22:01:19 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-02-17 14:56:17 +01:00
|
|
|
addEventListener("message", async event => {
|
2024-02-16 22:01:19 +01:00
|
|
|
let message = event.data;
|
|
|
|
if (message.action == "eval") {
|
2024-02-18 00:29:58 +01:00
|
|
|
evaluate(message.input);
|
2024-02-16 22:01:19 +01:00
|
|
|
}
|
|
|
|
});
|