An interactive mruby playground that runs entirely in your browser using WebAssembly.
- 💻 Write and execute mruby code in the browser
- 🎨 Beautiful console-style interface
- 🚀 Powered by mruby/edge and Emscripten
- 📦 No server required - runs completely client-side
- Rust (rustup)
- Emscripten toolchain
rustup target add wasm32-unknown-emscripten# Clone Emscripten SDK
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
# Install latest version
./emsdk install latest
./emsdk activate latest
# Set environment variables (run for each session)
source ./emsdk_env.shBuild options are configured in .cargo/config.toml, so you can build with the following command:
cargo build --target wasm32-unknown-emscripten --releaseThis will generate the following files in the docs/ directory:
docs/playground.js- JS glue code generated by Emscriptendocs/playground.wasm- Compiled WebAssembly binary
# Using Python
cd docs
python3 -m http.server 8000
# Or using npm serve
npx serve docsAccess http://localhost:8000 to use the playground. Architecture
src/main.rs exports functions that can be called from JavaScript:
- load_ruby_script: Compiles and executes mruby code, returns the result
- systemMessage: JavaScript callback for system messages (defined in
library.js)
The playground uses Emscripten's Module interface to bridge Rust and JavaScript.
- Push your changes including the
docs/directory - Go to your repository Settings → Pages
- Set Source to "Deploy from a branch"
- Select branch:
main(or your default branch) - Select folder:
/docs - Save and wait for deployment
The playground will be available at https://<username>.github.io/<repository>/
src/main.rs outputs messages to the console in two ways:
- println! macro: Emscripten automatically redirects to console.log
- emscripten_run_script: Directly executes JavaScript code
Opening files directly with the file:// protocol will cause CORS errors. Always use a local HTTP server.
Make sure Emscripten environment variables are properly set:
source /path/to/emsdk/emsdk_env.sh