Improvements to playground editor
This commit is contained in:
@@ -3,8 +3,8 @@ import { archive, preload } from "./preload";
|
||||
import { CompileReq, CompileRes } from "./types";
|
||||
|
||||
console.log = (m) => {
|
||||
shim.stdout += '\n' + m
|
||||
}
|
||||
shim.stdout += "\n" + m;
|
||||
};
|
||||
|
||||
const handleMessage = async function (ev: { data: CompileReq }) {
|
||||
console.log("message", ev.data);
|
||||
@@ -12,7 +12,10 @@ const handleMessage = async function (ev: { data: CompileReq }) {
|
||||
shim.archive = archive;
|
||||
let { id, src, fileName } = ev.data;
|
||||
const outfile = "out.js";
|
||||
shim.process.argv = ["browser", "newt", fileName, "-o", outfile, "--top"];
|
||||
if (ev.data.compile)
|
||||
shim.process.argv = ["browser", "newt", fileName, "-o", outfile, "--top"];
|
||||
else
|
||||
shim.process.argv = ["browser", "newt", fileName, "--top"];
|
||||
shim.files[fileName] = new TextEncoder().encode(src);
|
||||
shim.files[outfile] = new TextEncoder().encode("No JS output");
|
||||
shim.stdout = "";
|
||||
@@ -29,7 +32,7 @@ const handleMessage = async function (ev: { data: CompileReq }) {
|
||||
console.log(`process ${fileName} in ${duration} ms`);
|
||||
let javascript = new TextDecoder().decode(shim.files[outfile]);
|
||||
let output = shim.stdout;
|
||||
sendResponse({ id, type: 'compileResult', javascript, output, duration });
|
||||
sendResponse({ id, type: "compileResult", javascript, output, duration });
|
||||
};
|
||||
|
||||
// hooks for worker.html to override
|
||||
|
||||
Reference in New Issue
Block a user