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