refactoring in playground, use zip file for web
This commit is contained in:
@@ -6,15 +6,11 @@ const handleMessage = async function (ev: { data: CompileReq }) {
|
||||
console.log("message", ev.data);
|
||||
await preload;
|
||||
shim.archive = archive;
|
||||
let { src } = ev.data;
|
||||
let module = "Main";
|
||||
let m = src.match(/module (\w+)/);
|
||||
if (m) module = m[1];
|
||||
let fn = `${module}.newt`;
|
||||
let { src, fileName } = ev.data;
|
||||
const outfile = "out.js";
|
||||
shim.process.argv = ["", "", fn, "-o", outfile, "--top"];
|
||||
shim.process.argv = ["", "", fileName, "-o", outfile, "--top"];
|
||||
console.log("Using args", shim.process.argv);
|
||||
shim.files[fn] = new TextEncoder().encode(src);
|
||||
shim.files[fileName] = new TextEncoder().encode(src);
|
||||
shim.files[outfile] = new TextEncoder().encode("No JS output");
|
||||
shim.stdout = "";
|
||||
const start = +new Date();
|
||||
@@ -27,10 +23,10 @@ const handleMessage = async function (ev: { data: CompileReq }) {
|
||||
shim.stdout += "\n" + String(e);
|
||||
}
|
||||
let duration = +new Date() - start;
|
||||
console.log(`process ${fn} in ${duration} ms`);
|
||||
console.log(`process ${fileName} in ${duration} ms`);
|
||||
let javascript = new TextDecoder().decode(shim.files[outfile]);
|
||||
let output = shim.stdout;
|
||||
sendResponse({ javascript, output, duration });
|
||||
sendResponse({ type: 'compileResult', javascript, output, duration });
|
||||
};
|
||||
|
||||
// hooks for worker.html to override
|
||||
|
||||
Reference in New Issue
Block a user