refactr
This commit is contained in:
@@ -3,7 +3,7 @@ import { Metadata } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Minimax",
|
||||
description: "An interactive Rhai scripting language playground",
|
||||
description: "",
|
||||
};
|
||||
|
||||
export const viewport = {
|
||||
|
||||
@@ -87,12 +87,11 @@ export default function Playground() {
|
||||
}
|
||||
);
|
||||
} catch (ex) {
|
||||
const errorMsg = `\nEXCEPTION: "${ex}"\n`;
|
||||
if (resultRef.current) {
|
||||
resultRef.current.value += errorMsg;
|
||||
resultRef.current.value += `\nScript exited with error:\n${ex}\n`;
|
||||
}
|
||||
terminalRef.current?.write(
|
||||
"\r\n\x1B[1;31mEXCEPTION:\x1B[0m " + String(ex) + "\r\n"
|
||||
"\r\n\x1B[1;31mScript exited with error:\x1B[0m\n\r" + String(ex).replace("\n", "\n\r") + "\r\n"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -132,12 +131,11 @@ export default function Playground() {
|
||||
}
|
||||
);
|
||||
} catch (ex) {
|
||||
const errorMsg = `\nEXCEPTION: "${ex}"\n`;
|
||||
if (resultRef.current) {
|
||||
resultRef.current.value += errorMsg;
|
||||
if (resultRef.current) {
|
||||
resultRef.current.value += `\nScript exited with error:\n${ex}\n`;
|
||||
}
|
||||
terminalRef.current?.write(
|
||||
"\r\n\x1B[1;31mEXCEPTION:\x1B[0m " + String(ex) + "\r\n"
|
||||
"\r\n\x1B[1;31mScript exited with error:\x1B[0m\n\r" + String(ex).replace("\n", "\n\r") + "\r\n"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,9 +89,9 @@ async function init_term(
|
||||
|
||||
const term = new Terminal({
|
||||
//"fontFamily": "Fantasque",
|
||||
rows: 24,
|
||||
fontSize: 16,
|
||||
tabStopWidth: 8,
|
||||
rows: 30,
|
||||
fontSize: 18,
|
||||
tabStopWidth: 4,
|
||||
cursorBlink: false,
|
||||
cursorStyle: "block",
|
||||
cursorInactiveStyle: "none",
|
||||
|
||||
@@ -54,13 +54,10 @@ self.onmessage = async (event) => {
|
||||
|
||||
currentGame = new GameState(
|
||||
event_data.script,
|
||||
"max",
|
||||
() => {},
|
||||
() => {},
|
||||
|
||||
// TODO: pick opponent
|
||||
event_data.script,
|
||||
"min",
|
||||
() => {},
|
||||
() => {},
|
||||
|
||||
|
||||
@@ -54,9 +54,7 @@ self.onmessage = async (event) => {
|
||||
};
|
||||
|
||||
currentGame = new GameStateHuman(
|
||||
true,
|
||||
event_data.script,
|
||||
"Agent",
|
||||
appendOutput,
|
||||
appendOutput,
|
||||
appendTerminal
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
}
|
||||
|
||||
.terminalPanel {
|
||||
flex: 1;
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-bottom: 1px solid #333;
|
||||
@@ -69,7 +69,7 @@
|
||||
}
|
||||
|
||||
.terminalContainer {
|
||||
flex: 1;
|
||||
flex: 0 0 auto;
|
||||
overflow: hidden;
|
||||
padding: 8px;
|
||||
background: #1D1F21;
|
||||
|
||||
@@ -47,10 +47,12 @@ export const initRhaiMode = (CodeMirror: any) => {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Function to preload all WASM modules used by the application
|
||||
export const loadAllWasm = async (): Promise<void> => {
|
||||
try {
|
||||
// Load Rhai CodeMirror WASM
|
||||
|
||||
await loadRhaiWasm();
|
||||
|
||||
// Load Script Runner WASM by creating and immediately terminating a worker
|
||||
@@ -79,9 +81,9 @@ export const loadAllWasm = async (): Promise<void> => {
|
||||
};
|
||||
});
|
||||
|
||||
console.log("✅ All WASM modules loaded successfully");
|
||||
console.log("All WASM modules loaded successfully");
|
||||
} catch (error) {
|
||||
console.error("❌ Failed to load WASM modules:", error);
|
||||
console.error("Failed to load WASM modules:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
"name": "next"
|
||||
}
|
||||
],
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user