Skip to content

Commit

Permalink
Add version to online interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrk24 committed May 3, 2024
1 parent c6639d7 commit e34190e
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. See [Keep a

### Added

- The language version is now displayed on the online interpreter.
- RND (`$`) now works in compiled programs, though backed by a different source of randomness.

### Changed
Expand Down
4 changes: 2 additions & 2 deletions wasm/build_wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ case "$1" in
cp worker.js ldworker.js
} &
# emcc is so much slower than the civet and sass compilers that parallelizing them doesn't matter much
civet --js --inline-map -c in.civet -o index.js
civet --js --inline-map --comptime -c in.civet -o index.js
civet --js --inline-map -c Colors.civet -o Colors.js
sass in.scss:index.css lowdata.scss:lowdata.css --embed-source-map
;;
Expand All @@ -38,7 +38,7 @@ case "$1" in
emcc ../src/*.cpp "${common_emcc_args[@]}" -O3 -o worker.js &
emcc ../src/*.cpp "${common_emcc_args[@]}" -Oz -o ldworker.js &

civet --js -c in.civet -o - | terser -c unsafe=true,unsafe_arrows=true -mo index.js --ecma 13 \
civet --js --comptime -c in.civet -o - | terser -c unsafe=true,unsafe_arrows=true -mo index.js --ecma 13 \
-f wrap_func_args=false
civet --js -c Colors.civet -o - | terser -cmf wrap_func_args=false -o Colors.js --ecma 13
sass in.scss:index.css lowdata.scss:lowdata.css --no-source-map -s compressed
Expand Down
5 changes: 5 additions & 0 deletions wasm/in.civet
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ declare global
WORKER_URL: string
get isPaused(): boolean
playPause: =>
version: string

let worker: Worker?
stdoutBuffer: number[] .= []
Expand Down Expand Up @@ -70,6 +71,10 @@ copyURL := :void =>
elements.copyAlert.className = ''
setTimeout :void => elements.copyAlert.className = 'hide-slow'

window.version = comptime
// @ts-ignore 'require' is provided by the Civet compiler
require('child_process').execSync('git describe --tags').toString().trimEnd()

generateURL := :void =>
url := new URL location.href
url.hash = '#' + encodeURIComponent generateContracted()
Expand Down
3 changes: 3 additions & 0 deletions wasm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
ppButton.addEventListener('click', function() {
this.title = this.textContent === window.PLAY_TEXT ? 'play' : 'pause';
}, { passive: true });

document.querySelector('footer .center')
.prepend('Version ', window.version, document.createElement('br'));
}, { once: true });
</script>
<main class="grid">
Expand Down
2 changes: 1 addition & 1 deletion wasm/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -e
engine-check
stylelint ./*.scss

civet -c ./*.civet -o .ts
civet --comptime -c ./*.civet -o .ts
eslint ./*.ts

cd ..
Expand Down
2 changes: 1 addition & 1 deletion wasm/lowdata.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
o " " " o "
" , W r " ! 3
l o o o d o : o
o " " " o ' ( @ .</textarea><div id=debug-program hidden class=textarea></div></fieldset><fieldset id=input-container><legend>Input</legend><div><input type=checkbox id=include-input><label for=include-input>Include input in URL</label></div><textarea id=stdin rows=10 class=textarea></textarea></fieldset></div><button type=button onclick=clearOutput()>Clear output &amp; errors</button><p>Output</p><pre id=stdout></pre><p>Errors</p><p id=stderr></p></main><div id=debug-info hidden><div id=debug-header><button type=button id=step onclick=step()>Step</button><button type=button id=slower onclick=slower()>Slower</button><button type=button id=play-pause onclick=playPause()></button><button type=button id=faster onclick=faster()>Faster</button><button type=button onclick=toggleColorPicker()>Colors</button></div><div id=color-picker></div><table><thead><tr><th>Thread&nbsp;#</th><th>Stack</th></tr></thead><tbody id=threads></tbody></table></div><div class=spacer></div><footer>© 2023 William Baker <a rel=license href="https://github.com/bbrk24/Trilangle/blob/master/LICENSE">MIT License</a><br><a href="https://github.com/bbrk24/Trilangle">GitHub page</a><br><a rel=alternate href="./index.html" hreflang=en-US type="text/html">Rich version</a></footer><script>window.WORKER_URL=new URL('ldworker.js',location);window.PLAY_TEXT='Play';window.PAUSE_TEXT='Pause'</script></body></html>
o " " " o ' ( @ .</textarea><div id=debug-program hidden class=textarea></div></fieldset><fieldset id=input-container><legend>Input</legend><div><input type=checkbox id=include-input><label for=include-input>Include input in URL</label></div><textarea id=stdin rows=10 class=textarea></textarea></fieldset></div><button type=button onclick=clearOutput()>Clear output &amp; errors</button><p>Output</p><pre id=stdout></pre><p>Errors</p><p id=stderr></p></main><div id=debug-info hidden><div id=debug-header><button type=button id=step onclick=step()>Step</button><button type=button id=slower onclick=slower()>Slower</button><button type=button id=play-pause onclick=playPause()></button><button type=button id=faster onclick=faster()>Faster</button><button type=button onclick=toggleColorPicker()>Colors</button></div><div id=color-picker></div><table><thead><tr><th>Thread&nbsp;#</th><th>Stack</th></tr></thead><tbody id=threads></tbody></table></div><div class=spacer></div><footer>© 2023 William Baker <a rel=license href="https://github.com/bbrk24/Trilangle/blob/master/LICENSE">MIT License</a><br><a id=gh href="https://github.com/bbrk24/Trilangle">GitHub page</a><br><a rel=alternate href="./index.html" hreflang=en-US type="text/html">Rich version</a></footer><script>window.WORKER_URL=new URL('ldworker.js',location);window.PLAY_TEXT='Play';window.PAUSE_TEXT='Pause';addEventListener('DOMContentLoaded',()=>document.querySelector('footer').insertBefore(document.createTextNode(`v${version} `),gh),{once:!0})</script></body></html>
8 changes: 4 additions & 4 deletions wasm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wasm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"@danielx/civet": "~0.7.1",
"@danielx/civet": "~0.7.5",
"sass": "^1.72.0",
"terser": "^5.27.2"
},
Expand Down

0 comments on commit e34190e

Please sign in to comment.