Skip to content

Commit

Permalink
Add webrunner
Browse files Browse the repository at this point in the history
  • Loading branch information
Saverio976 committed Jan 14, 2024
1 parent 1559875 commit 9b46bef
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ jobs:
if: steps.filter.outputs.docs == 'true' || steps.filter.outputs.docs2 == 'true' || steps.filter.outputs.workflow == 'true' || github.ref == 'refs/heads/main'
run: mdbook build

- name: Copy OnlineRunner
if: steps.filter.outputs.docs == 'true' || steps.filter.outputs.docs2 == 'true' || steps.filter.outputs.workflow == 'true' || github.ref == 'refs/heads/main'
run: cp ./lvtext/webrunner/index.html ./book/OnlineVm.html

- name: Setup Pages
if: github.ref == 'refs/heads/main'
uses: actions/configure-pages@v3
Expand Down
Empty file added docs/OnlineVm.md
Empty file.
1 change: 1 addition & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ made in Haskell.
[Byte Code Spec Ex](ByteCodeSpecEx.md)
[Syntax Highlighting Extension](SyntaxHighlighting.md)
[BNF](BNF.md)
[Online VM](OnlineVM.md)
5 changes: 5 additions & 0 deletions lvtext/webrunner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# WebRunner

A simple static site that load a wasm and call the `start` exported function.

<https://x-r-g-b.github.io/Leviator/OnlineVm.html>
30 changes: 30 additions & 0 deletions lvtext/webrunner/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<head>
<title>Leviator Web Runner</title>
</head>
<body>
<h1>Leviator Web Runner</h1>
<a href="https://x-r-g-b.github.io/Leviator/">online docs</a><br/><br/>

<label for="fileWasm">Wasm File: </label><input type="file" id="fileWasm" />

<p>Output:<br/></p>
<pre><code id="output"></code></pre>

<script>
const importObject = {
imports: {},
};

document.getElementById("fileWasm").addEventListener("change", (event) => {
const reader = new FileReader();
reader.onload = () => {
const arrayBuffer = reader.result;
WebAssembly.instantiate(arrayBuffer, importObject).then((result) => {
const res = result.instance.exports.start();
document.getElementById("output").innerText = res;
})
}
reader.readAsArrayBuffer(event.target.files[0]);
})
</script>
</body>

0 comments on commit 9b46bef

Please sign in to comment.