Commitfdf94122Recorded31 Mar 2026Repositorysigil-web-repl
Convert to standalone package
Message
Rename from sigil-playground to sigil-web-repl, convert from-workspace deps to from-git (sigil-sxml and sigil-markdown point at their own Codeberg repos, others at the sigil monorepo). Add configs, dev redirects, emsdk-shell build script, gitignore, and README.
Changed
.gitignore | 1 +
README.md | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
dev-redirects.sgl | 12 ++++++++++++
package.sgl | 43 ++++++++++++++++++++++++++++++-------------
scripts/emsdk-shell | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 201 insertions(+), 13 deletions(-)Diff
.gitignoreadded
@@ -0,0 +1 @@
+1
build/README.mdadded
@@ -0,0 +1,60 @@
+1
# sigil-web-repl+2
+3
A web-based REPL and playground for trying [Sigil](https://codeberg.org/sigil/sigil) in the browser. Uses `sigil-web-run` as the WebAssembly runtime and delimited continuations for interactive input/output between JavaScript and Sigil.+4
+5
## How it works+6
+7
The playground runs a Sigil REPL compiled to WebAssembly via Emscripten. It uses delimited continuations (prompts) to yield control back to JavaScript when waiting for user input:+8
+9
1. `playground-start` begins the REPL and yields waiting for input+10
2. JavaScript collects input from the user+11
3. JavaScript calls back into WASM with `web-input-resume`+12
4. The saved continuation is invoked with the input+13
5. The REPL evaluates the expression and yields again for the next input+14
+15
## Requirements+16
+17
Building this package requires [Emscripten](https://emscripten.org/) and the `sigil-web-run` C runtime. This is not a standard Sigil package build; it produces `.js` and `.wasm` output files for browser deployment.+18
+19
## Dependencies+20
+21
- `sigil-web-run` - WebAssembly C runtime (from sigil monorepo)+22
- `sigil-stdlib` - Standard library+23
- `sigil-repl` - REPL commands+24
- `sigil-sxml` - SXML processing+25
- `sigil-json` - JSON handling+26
- `sigil-ansi` - Terminal color codes+27
- `sigil-format` - String formatting+28
- `sigil-markdown` - Markdown processing+29
+30
## Building+31
+32
Building requires the Emscripten SDK. On Guix systems, use the included helper script to set up an FHS container with emsdk:+33
+34
```bash+35
# Enter an Emscripten shell (installs emsdk on first run, ~400MB)+36
./scripts/emsdk-shell+37
+38
# Then build inside the shell+39
sigil build --redirects dev-redirects.sgl+40
```+41
+42
Or run the build directly:+43
+44
```bash+45
./scripts/emsdk-shell sigil build --redirects dev-redirects.sgl+46
```+47
+48
This compiles the Sigil modules, links them into a web application (`sigil-playground.js` and `sigil-playground.wasm`), and copies the HTML assets to the output directory.+49
+50
## Usage+51
+52
Add as a dependency in your `package.sgl`:+53
+54
```scheme+55
(from-git url: "codeberg:sigil/sigil-web-repl")+56
```+57
+58
## License+59
+60
BSD-3-Clausedev-redirects.sgladded
@@ -0,0 +1,12 @@
+1
;; Development redirects — point dependencies at local checkouts+2
(redirects+3
repos: (list+4
(for-repo+5
url: "codeberg:sigil/sigil"+6
use: (from-path dir: "../sigil"))+7
(for-repo+8
url: "codeberg:sigil/sigil-sxml"+9
use: (from-path dir: "../sigil-sxml"))+10
(for-repo+11
url: "codeberg:sigil/sigil-markdown"+12
use: (from-path dir: "../sigil-markdown"))))package.sglmodified
@@ -1,23 +1,41 @@
−1
;;; sigil-playground - Interactive Sigil playground for the web+1
;;; sigil-web-repl - Interactive Sigil playground for the web 2
;;; 3
;;; A web-based REPL and code editor for trying Sigil in the browser.−4
;;; Uses sigil-web-run as the runtime.+4
;;; Uses sigil-web-run as the runtime and delimited continuations for+5
;;; interactive input/output.+6
+7
(define sigil-repo "codeberg:sigil/sigil") 8
9
(package−7
name: "sigil-playground"+10
name: "sigil-web-repl" 11
version: "0.7.0"−9
description: "Interactive Sigil playground for the web"+12
description: "Interactive Sigil web REPL and playground"+13
url: "https://codeberg.org/sigil/sigil-web-repl"+14
license: "BSD-3-Clause"+15
authors: (list "David Wilson <[email protected]>") 16
entry: "(sigil playground)" 17
+18
configs: (list+19
(config+20
name: 'dev+21
output-dir: "build/dev"+22
debug?: #t+23
optimize: 0)+24
(config+25
name: 'release+26
output-dir: "build/release"+27
debug?: #f+28
optimize: 2))+29
30
dependencies: (list−13
(from-workspace name: "sigil-web-run")−14
(from-workspace name: "sigil-stdlib")−15
(from-workspace name: "sigil-repl")−16
(from-workspace name: "sigil-sxml")−17
(from-workspace name: "sigil-json")−18
(from-workspace name: "sigil-ansi")−19
(from-workspace name: "sigil-format")−20
(from-workspace name: "sigil-markdown"))+31
(from-git url: sigil-repo package: "sigil-web-run")+32
(from-git url: sigil-repo package: "sigil-stdlib")+33
(from-git url: sigil-repo package: "sigil-repl")+34
(from-git url: "codeberg:sigil/sigil-sxml")+35
(from-git url: sigil-repo package: "sigil-json")+36
(from-git url: sigil-repo package: "sigil-ansi")+37
(from-git url: sigil-repo package: "sigil-format")+38
(from-git url: "codeberg:sigil/sigil-markdown")) 39
40
tasks: (list 41
(task@@ -25,7 +43,6 @@
43
description: "Build the playground web application" 44
steps: (list 45
;; Compile Sigil modules (the playground's own code)−28
;; Output goes to consolidated lib/ directory 46
(compile-sigil-modules 47
sources: "src/**/*.sgl") 48
scripts/emsdk-shelladded
@@ -0,0 +1,98 @@
+1
#!/usr/bin/env bash+2
#+3
# emsdk-shell - Run commands in an Emscripten environment on Guix+4
#+5
# This script creates an FHS-compatible container with emsdk available.+6
# emsdk is installed to ~/.emsdk/emsdk and persists between invocations.+7
#+8
# Usage:+9
# ./scripts/emsdk-shell # Interactive shell with emcc available+10
# ./scripts/emsdk-shell emcc --help # Run a single command+11
# ./scripts/emsdk-shell make wasm # Run make with wasm target+12
#+13
# First run will install emsdk (~400MB download).+14
#+15
+16
set -e+17
+18
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+19
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"+20
EMSDK_HOME="${EMSDK_HOME:-$HOME/.emsdk}"+21
+22
# Packages needed for FHS container+23
GUIX_PACKAGES=(+24
coreutils+25
bash+26
gcc-toolchain+27
python+28
git+29
node+30
xz+31
nss-certs+32
tar+33
gzip+34
zlib+35
make+36
grep+37
sed+38
)+39
+40
# Ensure emsdk directory exists+41
mkdir -p "$EMSDK_HOME"+42
+43
# Build the guix shell command+44
GUIX_CMD=(+45
guix shell+46
--container+47
--emulate-fhs+48
--network+49
--share="$PROJECT_DIR=/project"+50
--share="$EMSDK_HOME=/emsdk-home"+51
)+52
+53
# Add all packages+54
for pkg in "${GUIX_PACKAGES[@]}"; do+55
GUIX_CMD+=("$pkg")+56
done+57
+58
# Setup script to run inside the container+59
SETUP_SCRIPT='+60
export SSL_CERT_DIR=/etc/ssl/certs+61
export EMSDK_QUIET=1+62
+63
# Prevent Emscripten from finding host headers+64
# These vars would cause emcc to use host includes, which breaks the build+65
unset CPATH+66
unset C_INCLUDE_PATH+67
unset CPLUS_INCLUDE_PATH+68
+69
# Install emsdk if not present+70
if [ ! -d "/emsdk-home/emsdk" ]; then+71
echo "Installing emsdk (first-time setup)..."+72
cd /emsdk-home+73
git clone https://github.com/emscripten-core/emsdk.git+74
cd emsdk+75
./emsdk install latest+76
./emsdk activate latest+77
echo "emsdk installation complete."+78
fi+79
+80
# Activate emsdk+81
cd /emsdk-home/emsdk+82
source ./emsdk_env.sh 2>/dev/null+83
+84
# Change to project directory+85
cd /project+86
'+87
+88
if [ $# -eq 0 ]; then+89
# Interactive shell+90
FULL_SCRIPT="$SETUP_SCRIPT+91
exec bash"+92
exec "${GUIX_CMD[@]}" -- bash -c "$FULL_SCRIPT"+93
else+94
# Run provided command+95
FULL_SCRIPT="$SETUP_SCRIPT+96
$*"+97
exec "${GUIX_CMD[@]}" -- bash -c "$FULL_SCRIPT"+98
fi