Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
run: |
mkdir -p _site/pkg
cp playground/index.html _site/
cp playground/env.js _site/pkg/
cp crates/truss-wasm/pkg/truss_wasm.js _site/pkg/
cp crates/truss-wasm/pkg/truss_wasm_bg.wasm _site/pkg/

Expand Down
20 changes: 20 additions & 0 deletions playground/env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// WASM "env" shim — provides C stdlib stubs required by tree-sitter.
//
// tree-sitter compiles C code that references these symbols. The Rust
// allocator handles actual memory management via wasm-bindgen exports,
// so malloc/free/calloc/realloc here are never called at runtime. The
// I/O and clock functions are likewise unreachable in the browser
// context, but must be present for WebAssembly.instantiate to succeed.

export function malloc() { return 0; }
export function free() {}
export function calloc() { return 0; }
export function realloc() { return 0; }
export function abort() { throw new Error("abort"); }
export function fprintf() { return 0; }
export function snprintf() { return 0; }
export function vsnprintf() { return 0; }
export function fclose() { return 0; }
export function clock() { return 0; }
export function fwrite() { return 0; }
export function fputc() { return 0; }
3 changes: 3 additions & 0 deletions playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Truss Playground - GitHub Actions Workflow Validator</title>
<script type="importmap">
{ "imports": { "env": "./pkg/env.js" } }
</script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.16/codemirror.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.16/theme/dracula.min.css">
<style>
Expand Down