playground improvements
This commit is contained in:
4
playground/.gitignore
vendored
Normal file
4
playground/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
public
|
||||
dist
|
||||
.vite
|
||||
node_modules
|
||||
@@ -15,7 +15,6 @@ function run(src: string) {
|
||||
}
|
||||
|
||||
newtWorker.onmessage = (ev) => {
|
||||
console.log("worker sent", ev.data);
|
||||
state.output.value = ev.data.output;
|
||||
state.javascript.value = ev.data.javascript;
|
||||
};
|
||||
@@ -67,11 +66,12 @@ function Editor({ initialValue }: EditorProps) {
|
||||
state.editor.value = editor;
|
||||
|
||||
editor.onDidChangeModelContent((ev) => {
|
||||
console.log("mc", ev);
|
||||
let value = editor.getValue();
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => run(value), 1000);
|
||||
timeout = setTimeout(() => {
|
||||
let value = editor.getValue()
|
||||
run(value)
|
||||
localStorage.code = value;
|
||||
}, 1000);
|
||||
});
|
||||
run(initialValue);
|
||||
}, []);
|
||||
|
||||
@@ -120,15 +120,21 @@ process.stdout.write = (s) => {
|
||||
};
|
||||
|
||||
onmessage = function (e) {
|
||||
console.log('worker got', e.data)
|
||||
let {src} = e.data
|
||||
process.argv = ["", "", "src/Main.newt", "-o", "out.js"];
|
||||
console.log("args", process.argv);
|
||||
files["src/Main.newt"] = src;
|
||||
files['out.js'] = 'No JS output';
|
||||
stdout = ''
|
||||
try {
|
||||
newtMain();
|
||||
} catch (e) {
|
||||
// make it clickable
|
||||
console.error(e)
|
||||
// make it visable
|
||||
stdout += '\n' + String(e)
|
||||
}
|
||||
let javascript = files['out.js']
|
||||
let output = stdout
|
||||
console.log('WORKER POSTS', {javascript, output})
|
||||
postMessage({javascript, output})
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
}
|
||||
.wrapper > div {
|
||||
flex: 1 1;
|
||||
/* allow smaller than natural */
|
||||
width: 100px;
|
||||
}
|
||||
.tabPanel {
|
||||
@@ -22,7 +23,7 @@
|
||||
display:flex;
|
||||
flex-direction: row;
|
||||
gap: 10px;
|
||||
margin: 10px 0;
|
||||
margin: 10px 0 0 0;
|
||||
border-bottom: solid 1px black;
|
||||
}
|
||||
.tab {
|
||||
@@ -33,9 +34,11 @@
|
||||
border: solid 1px black;
|
||||
border-bottom: 0px
|
||||
}
|
||||
|
||||
#result, #javascript {
|
||||
.tabBody {
|
||||
overflow: auto;
|
||||
flex: 1 1;
|
||||
}
|
||||
#result, #javascript {
|
||||
font-family: 'Comic Code', monospace;
|
||||
font-size: 12px;
|
||||
white-space: pre;
|
||||
|
||||
Reference in New Issue
Block a user