Commit43c73081Recorded31 Mar 2026Repositorysigil-web-repl
Simplify JS loader to use bundle only
Message
Remove lib-manifest.json fallback — all modules should be in the bundle. The hosting site (e.g. sigil-site) is responsible for rebuilding the bundle with any extra modules it needs.
Changed
assets/index.html | 63 ++++++++++++++++++++-------------------------------------------
1 file changed, 20 insertions(+), 43 deletions(-)Diff
assets/index.htmlmodified
@@ -1120,61 +1120,38 @@
1120
term.onData(handleInput); 1121
window.addEventListener('resize', () => { if (ready) fitAddon.fit(); }); 1122
−1123
// Load module bundle + any extra loose files into virtual filesystem+1123
// Load module bundle 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 1129
try { 1130
const resp = await fetch('lib.bundle');−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);+1131
if (!resp.ok) return { files, File, Directory };+1132
const buf = await resp.arrayBuffer();+1133
const view = new DataView(buf);+1134
const decoder = new TextDecoder();+1135
let offset = 0;+1136
+1137
const count = view.getUint32(offset, true); offset += 4;+1138
for (let i = 0; i < count; i++) {+1139
const pathLen = view.getUint16(offset, true); offset += 2;+1140
const path = decoder.decode(new Uint8Array(buf, offset, pathLen)); offset += pathLen;+1141
const dataLen = view.getUint32(offset, true); offset += 4;+1142
const data = new Uint8Array(buf, offset, dataLen); offset += dataLen;+1143
+1144
const parts = path.split('/');+1145
let dir = files;+1146
for (let j = 0; j < parts.length - 1; j++) {+1147
if (!dir[parts[j]]) dir[parts[j]] = {};+1148
dir = dir[parts[j]]; 1149
}+1150
dir[parts[parts.length - 1]] = new File(new Uint8Array(data)); 1151
} 1152
} catch (e) { 1153
console.warn('Bundle loading:', e.message); 1154
}−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
1155
return { files, File, Directory }; 1156
} 1157