Theta Playground is an interactive web-based environment for experimenting with WebAssembly (WASM) modules generated from the Theta programming language. It provides a simple and intuitive interface to load, display, and execute WebAssembly code directly in the browser.
Theta implements some experimental WebAssembly features. In order for the browser to support all of Theta's language features, make sure "Experimental WebAssembly" is enabled in chrome://flags/
:
- Dynamic WebAssembly Loading: The playground dynamically fetches and loads WebAssembly modules specified in a configuration file (
wasmSource.json
), allowing for easy updates and modifications without changing the HTML structure. - Hexdump Display: Visualize the binary content of the loaded WebAssembly module in a hexdump format, helping users understand the raw binary data.
- Console Output Redirection: JavaScript console outputs are redirected to an on-screen console, making it easier to debug and observe the program's behavior in real-time.
- Execution of WebAssembly Functions: Execute exported functions from the WebAssembly module and display the results, providing immediate feedback on the execution.
- index.html: The main HTML file that sets up the playground interface.
- watch_source.sh: A shell script to monitor changes in the source Theta file, recompile it to WASM, and refresh the playground automatically.
To set up the Theta Playground, follow these steps:
-
Clone the Repository:
git clone https://github.com/alexdovzhanyn/theta-browser-playground.git cd theta-playground
-
Ensure fswatch is Installed: Install
fswatch
if it's not already installed on your system. On macOS, you can use Homebrew:brew install fswatch
On Linux, you can follow the instructions for your distribution to install
fswatch
. -
Ensure browser-sync is Installed: Install
browser-sync
if it's not already installed on your system:npm i -g browser-sync
-
Run the Script: The
watch_source.sh
script will start a local server usingbrowser-sync
and open your default browser tolocalhost:3000
../watch_source.sh path/to/theta/source/file.th