tco working, update playground to self-hosted newt

This commit is contained in:
2025-03-17 18:43:42 -07:00
parent 1219e8d4e5
commit 9d7e6097f3
12 changed files with 377 additions and 395 deletions

View File

@@ -2,20 +2,23 @@ import { shim } from "./emul";
import { archive, preload } from "./preload";
import { CompileReq, CompileRes } from "./types";
console.log = (m) => {
shim.stdout += '\n' + m
}
const handleMessage = async function (ev: { data: CompileReq }) {
console.log("message", ev.data);
await preload;
shim.archive = archive;
let { src, fileName } = ev.data;
const outfile = "out.js";
shim.process.argv = ["", "", fileName, "-o", outfile, "--top"];
console.log("Using args", shim.process.argv);
shim.process.argv = ["browser", "newt", fileName, "-o", outfile, "--top"];
shim.files[fileName] = new TextEncoder().encode(src);
shim.files[outfile] = new TextEncoder().encode("No JS output");
shim.stdout = "";
const start = +new Date();
try {
newtMain();
Main_main();
} catch (e) {
// make it clickable in console
console.error(e);