This commit is contained in:
2025-11-01 10:01:59 -07:00
parent eeab08af75
commit 53fdd24093
7 changed files with 421 additions and 171 deletions

View File

@@ -18,7 +18,51 @@ export async function startScript(
worker.terminate();
}
worker = new Worker(new URL("./worker.ts", import.meta.url));
worker = new Worker(new URL("./worker_human.ts", import.meta.url));
worker.onmessage = (event) => {
const { type, line, error } = event.data;
if (type === "output") {
appendOutput(line);
} else if (type === "terminal") {
appendTerminal(line);
} else if (type === "complete") {
worker?.terminate();
worker = null;
resolve();
} else if (type === "error") {
worker?.terminate();
worker = null;
reject(new Error(error));
} else if (type === "stopped") {
worker?.terminate();
worker = null;
resolve();
}
};
worker.onerror = (error) => {
worker?.terminate();
worker = null;
reject(error);
};
worker.postMessage({ type: "run", script });
});
}
export async function startScriptBulk(
script: string,
appendOutput: (line: string) => void,
appendTerminal: (line: string) => void
): Promise<void> {
return new Promise((resolve, reject) => {
if (worker) {
worker.terminate();
}
worker = new Worker(new URL("./worker_bulk.ts", import.meta.url));
worker.onmessage = (event) => {
const { type, line, error } = event.data;