Skip to content

Commit 026cf2d

Browse files
committed
Update playground setup
1 parent 3910d78 commit 026cf2d

5 files changed

Lines changed: 42 additions & 20 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
dist
22
node_modules
3-
playground/parser.js
3+
playground/*.js

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"lint": "oxlint",
3232
"prepack": "tsc",
3333
"test": "node --test test/*.test.ts",
34-
"playground": "rolldown dist/parser.js -f esm -m -o playground/parser.js && rolldown dist/printer.js -f esm -m -o playground/printer.js && cd playground && zip -r ./playground.zip ."
34+
"playground": "npx rolldown src/parser.ts -f esm -m -o playground/parser.js && npx rolldown src/printer.ts -f esm -m -o playground/printer.js"
3535
},
3636
"devDependencies": {
3737
"@ericcornelissen/bash-parser": "^0.5.3",

playground/index.html

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,74 @@
66
<style>
77
* {
88
margin: 0;
9+
box-sizing: border-box;
910
}
1011
body {
1112
font-family: monospace;
1213
height: 100vh;
13-
display: flex;
14+
display: grid;
15+
grid-template-columns: 1fr 1fr;
16+
grid-template-rows: auto 1fr;
1417
}
1518
textarea,
16-
pre {
17-
width: 50%;
19+
#print {
20+
grid-column: 1;
21+
}
22+
textarea {
1823
padding: 1rem;
1924
border: none;
25+
border-right: 1px solid grey;
26+
border-bottom: 1px solid grey;
2027
outline: none;
2128
resize: none;
29+
height: 65vh;
2230
}
23-
textarea {
31+
#print {
32+
padding: 1rem;
2433
border-right: 1px solid grey;
34+
white-space: pre-wrap;
35+
word-break: break-word;
36+
overflow: auto;
37+
background: dimgray;
38+
color: whitesmoke;
2539
}
26-
pre {
40+
#parse {
41+
white-space: pre;
42+
padding: 1rem;
2743
overflow: auto;
2844
background: whitesmoke;
45+
grid-column: 2;
46+
grid-row: 1 / -1;
2947
}
3048
</style>
3149
</head>
3250
<body>
33-
<textarea id="in" spellcheck="false">
51+
<textarea id="input" spellcheck="false">
3452
echo "hello $USER"
3553
for f in *.log; do
3654
cat "$f" | grep ERROR
3755
done</textarea
3856
>
39-
<pre id="out"></pre>
57+
<output id="parse"></output>
58+
<output id="print"></output>
4059
<script type="module">
4160
import { parse } from "/parser.js";
42-
const _in = document.getElementById("in");
43-
const _out = document.getElementById("out");
61+
import { print } from "/printer.js";
62+
const _input = document.getElementById("input");
63+
const _parse = document.querySelector("output#parse");
64+
const _print = document.querySelector("output#print");
4465
const update = () => {
4566
try {
46-
_out.textContent = JSON.stringify(parse(_in.value), null, 2);
67+
const src = _input.value;
68+
const ast = parse(src);
69+
_parse.textContent = JSON.stringify(ast, null, 2);
70+
_print.textContent = print(ast);
4771
} catch (e) {
48-
_out.textContent = e.message;
72+
_parse.textContent = e.message;
73+
_print.textContent = e.message;
4974
}
5075
};
51-
_in.oninput = update;
76+
_input.oninput = update;
5277
update();
5378
</script>
5479
</body>

playground/parser.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

statichost.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build-image: node:24-alpine
2+
build-command: npm run playground
3+
public: playground

0 commit comments

Comments
 (0)