Commitc404a39aRecorded11 Jun 2026Repositorysigil-site
Ship the REPL page from the same build as its wasm
Message
assets/repl/index.html was a March-era snapshot while publish.sh kept refreshing the wasm and lib.bundle around it. The stale page JS drove the new wasm's eval/input ABI into a hang: the live REPL booted but every evaluation stalled until interrupted. Refresh the checked-in page and make publish.sh copy index.html from the REPL build alongside the wasm so the pair can never diverge again.
Changed
assets/repl/index.html | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
publish.sh | 4 ++++
2 files changed, 56 insertions(+), 3 deletions(-)Diff
assets/repl/index.htmlmodified
@@ -1193,6 +1193,44 @@
1193
return fd; 1194
} 1195
+1196
async function loadOptionalBridgeLoader() {+1197
const response = await fetch('sigil-wasm-bridges.js', { method: 'HEAD' });+1198
if (!response.ok) {+1199
return null;+1200
}+1201
+1202
await new Promise((resolve, reject) => {+1203
const script = document.createElement('script');+1204
script.src = 'sigil-wasm-bridges.js';+1205
script.onload = resolve;+1206
script.onerror = () => reject(new Error('Failed to load sigil-wasm-bridges.js'));+1207
document.head.appendChild(script);+1208
});+1209
+1210
if (!window.SigilWasmBridges) {+1211
return null;+1212
}+1213
+1214
return window.SigilWasmBridges.load();+1215
}+1216
+1217
function makeWasmNetStubImports() {+1218
return {+1219
sigil_wasm_net: {+1220
websocket_open() { return 0; },+1221
websocket_send() { return 0; },+1222
websocket_close() { return 0; },+1223
websocket_poll() { return 0; },+1224
current_event_code() { return 0; },+1225
current_event_was_clean() { return 0; },+1226
current_event_data_length() { return 0; },+1227
current_event_reason_length() { return 0; },+1228
copy_current_event_data() { return 0; },+1229
copy_current_event_reason() { return 0; },+1230
},+1231
};+1232
}+1233
1234
// Initialize WASI and load WASM 1235
async function init() { 1236
const wasiModule = await import("https://cdn.jsdelivr.net/npm/@bjorn3/[email protected]/dist/index.js");@@ -1209,16 +1247,27 @@
1247
])), 1248
]; 1249
−1212
const wasi = new WASI(["sigil-web"], [], fds, { debug: false });+1250
const wasi = new WASI(["sigil-web-repl"], [], fds, { debug: false }); 1251
1252
try {+1253
const bridgeManifest = await loadOptionalBridgeLoader();+1254
const bridgeImports = {+1255
...makeWasmNetStubImports(),+1256
...(bridgeManifest+1257
? window.SigilWasmBridges.createImports(bridgeManifest)+1258
: {}),+1259
}; 1260
const wasmModule = await WebAssembly.compileStreaming(fetch('sigil-web-repl.wasm')); 1261
const instance = await WebAssembly.instantiate(wasmModule, { 1262
wasi_snapshot_preview1: wasi.wasiImport,+1263
...bridgeImports, 1264
});+1265
if (bridgeManifest) {+1266
window.SigilWasmBridges.setInstance(bridgeManifest, instance);+1267
} 1268
−1220
sigilInput = (str) => callWithString(instance, instance.exports.sigil_web_input, str);−1221
sigilEval = (str) => callWithString(instance, instance.exports.sigil_web_eval, str);+1269
sigilInput = (str) => callWithString(instance, instance.exports.sigil_wasm_input, str);+1270
sigilEval = (str) => callWithString(instance, instance.exports.sigil_wasm_eval, str); 1271
1272
// Start the VM 1273
wasi.start(instance);publish.shmodified
@@ -352,6 +352,10 @@ REDIR_EOF
352
if [[ -f "$REPL_BUILD/sigil-web-repl.wasm" ]]; then 353
echo " Copying WASM artifacts..." 354
cp "$REPL_BUILD/sigil-web-repl.wasm" "$SCRIPT_DIR/assets/repl/"+355
# The page JS and the wasm are a matched pair: a stale page driving+356
# a fresh wasm hung evaluation on the live site (the eval/input ABI+357
# plumbing had moved on). Always ship the page from the same build.+358
cp "$REPL_BUILD/index.html" "$SCRIPT_DIR/assets/repl/index.html" 359
360
# Generate merged lib.bundle (web-repl modules + extras for REPL examples). 361
# generate-web-bundle lets LATER dirs override earlier ones, so the