- HTML 95%
- Shell 5%
|
David Wilson
82f1801283
Load optional WASM bridge imports
Teach the web REPL host page to load sigil-wasm-bridges.js when present, create bridge import objects before instantiation, and attach the instance after instantiation. When no bridge manifest is emitted, provide no-op sigil_wasm_net imports so strict Zig/WASI runtime builds still instantiate. Verification: SIGIL_REDIRECTS=dev-redirects.sgl ../sigil/build/dev/bin/sigil build --config web --force --no-bundle; final WASM imports sigil_wasm_net.*. |
||
|---|---|---|
| assets | Load optional WASM bridge imports | |
| scripts | Convert to standalone package | |
| src | Use sigil-wasm-runtime in web REPL | |
| .gitignore | Ignore Sigil dependency state | |
| CHANGELOG.md | Release: version bumps | |
| dev-redirects.sgl | Use sigil-wasm-runtime in web REPL | |
| package.sgl | Use sigil-wasm-runtime in web REPL | |
| README.md | Use sigil-wasm-runtime in web REPL | |
| sigil.lock | Migrate to 0.9.1 transitive deps with version ranges | |
sigil-web-repl
A web-based REPL for trying Sigil in the browser. Uses sigil-wasm-runtime as the WebAssembly runtime and delimited continuations for interactive input/output between JavaScript and Sigil.
How it works
The REPL runs Sigil compiled to WebAssembly via Emscripten. It uses delimited continuations (prompts) to yield control back to JavaScript when waiting for user input:
repl-startbegins the REPL and yields waiting for input- JavaScript collects input from the user
- JavaScript calls back into WASM with
web-input-resume - The saved continuation is invoked with the input
- The REPL evaluates the expression and yields again for the next input
Requirements
Building this package requires Emscripten and the sigil-wasm-runtime C runtime. This is not a standard Sigil package build; it produces .js and .wasm output files for browser deployment.
Dependencies
sigil-wasm-runtime- WebAssembly C runtime (from sigil monorepo)sigil-stdlib- Standard librarysigil-repl- REPL commandssigil-ansi- Terminal color codes
Building
Building requires the Emscripten SDK. On Guix systems, use the included helper script to set up an FHS container with emsdk:
# Enter an Emscripten shell (installs emsdk on first run, ~400MB)
./scripts/emsdk-shell
# Install dependencies and build inside the shell
sigil deps install
sigil build
Or run the build directly:
./scripts/emsdk-shell sigil deps install && ./scripts/emsdk-shell sigil build
This compiles the Sigil modules, links them into a web application (sigil-web-repl.js and sigil-web-repl.wasm), and copies the HTML assets to the output directory.
Usage
Add as a dependency in your package.sgl:
(from-git url: "codeberg:sigil/sigil-web-repl")
License
BSD-3-Clause