Commit19560fdbRecorded31 Mar 2026Repositorysigil-web-repl

Disable WASI debug logging, support extra lib modules

Message

Add debug: false to WASI constructor to suppress console logs. Add lib-manifest.json fallback for loading extra modules not included in the main lib.bundle (e.g. sigil-sxml, sigil-match added by sigil-site). Add comments to examples that need external dependencies.

Changed
 assets/index.html | 67 ++++++++++++++++++++++++++++++++++++++++++++++---------------------
 1 file changed, 46 insertions(+), 21 deletions(-)
Diff
assets/index.htmlmodified
@@ -538,6 +538,7 @@
538
539
match: `;;; Pattern Matching
540
;;; Destructuring data with match
+541
;;; Requires sigil-match (not bundled, loaded separately)
542
543
(import (sigil match))
544
@@ -612,6 +613,7 @@
613
614
sxml: `;;; SXML Library
615
;;; Represent HTML/XML as S-expressions
+616
;;; Requires sigil-sxml (not bundled, loaded separately)
617
618
(import (sigil sxml))
619
@@ -1118,38 +1120,61 @@
1120
term.onData(handleInput);
1121
window.addEventListener('resize', () => { if (ready) fitAddon.fit(); });
1122
1121
// Load module bundle into virtual filesystem
+1123
// Load module bundle + any extra loose files into virtual filesystem
1124
// Bundle format: [uint32 count] then per file:
1125
// [uint16 path-len] [path bytes] [uint32 data-len] [data bytes]
1126
async function buildFs() {
1127
const { File, Directory } = await import("https://cdn.jsdelivr.net/npm/@bjorn3/[email protected]/dist/index.js");
1128
const files = {};
+1129
+1130
function addFile(path, data) {
+1131
const parts = path.split('/');
+1132
let dir = files;
+1133
for (let j = 0; j < parts.length - 1; j++) {
+1134
if (!dir[parts[j]]) dir[parts[j]] = {};
+1135
dir = dir[parts[j]];
+1136
}
+1137
dir[parts[parts.length - 1]] = new File(new Uint8Array(data));
+1138
}
+1139
+1140
// Load main bundle
1141
try {
1142
const resp = await fetch('lib.bundle');
1129
if (!resp.ok) return { files, File, Directory };
1130
const buf = await resp.arrayBuffer();
1131
const view = new DataView(buf);
1132
const decoder = new TextDecoder();
1133
let offset = 0;
1134
1135
const count = view.getUint32(offset, true); offset += 4;
1136
for (let i = 0; i < count; i++) {
1137
const pathLen = view.getUint16(offset, true); offset += 2;
1138
const path = decoder.decode(new Uint8Array(buf, offset, pathLen)); offset += pathLen;
1139
const dataLen = view.getUint32(offset, true); offset += 4;
1140
const data = new Uint8Array(buf, offset, dataLen); offset += dataLen;
1141
1142
const parts = path.split('/');
1143
let dir = files;
1144
for (let j = 0; j < parts.length - 1; j++) {
1145
if (!dir[parts[j]]) dir[parts[j]] = {};
1146
dir = dir[parts[j]];
+1143
if (resp.ok) {
+1144
const buf = await resp.arrayBuffer();
+1145
const view = new DataView(buf);
+1146
const decoder = new TextDecoder();
+1147
let offset = 0;
+1148
+1149
const count = view.getUint32(offset, true); offset += 4;
+1150
for (let i = 0; i < count; i++) {
+1151
const pathLen = view.getUint16(offset, true); offset += 2;
+1152
const path = decoder.decode(new Uint8Array(buf, offset, pathLen)); offset += pathLen;
+1153
const dataLen = view.getUint32(offset, true); offset += 4;
+1154
const data = new Uint8Array(buf, offset, dataLen); offset += dataLen;
+1155
addFile(path, data);
1156
}
1148
dir[parts[parts.length - 1]] = new File(new Uint8Array(data));
1157
}
1158
} catch (e) {
1159
console.warn('Bundle loading:', e.message);
1160
}
+1161
+1162
// Load extra modules not in the bundle (e.g. sigil-sxml, sigil-match)
+1163
try {
+1164
const resp = await fetch('lib-manifest.json');
+1165
if (resp.ok) {
+1166
const manifest = await resp.json();
+1167
await Promise.all(manifest.map(async (path) => {
+1168
const fileResp = await fetch('lib/' + path);
+1169
if (fileResp.ok) {
+1170
addFile(path, await fileResp.arrayBuffer());
+1171
}
+1172
}));
+1173
}
+1174
} catch (e) {
+1175
// No extra modules, that's fine
+1176
}
+1177
1178
return { files, File, Directory };
1179
}
1180
@@ -1207,7 +1232,7 @@
1232
])),
1233
];
1234
1210
const wasi = new WASI(["sigil-web"], [], fds);
+1235
const wasi = new WASI(["sigil-web"], [], fds, { debug: false });
1236
1237
try {
1238
const wasmModule = await WebAssembly.compileStreaming(fetch('sigil-web-repl.wasm'));