modularize playground (prep for persistent/modular file handling)

This commit is contained in:
2024-12-07 16:58:10 -08:00
parent 421f5ea208
commit ba70845c09
11 changed files with 673 additions and 193 deletions

21
playground/src/preload.ts Normal file
View File

@@ -0,0 +1,21 @@
import {ZipFile} from './zipfile'
export let archive: ZipFile | undefined;
export let preload = (async function () {
// We pull down an archive of .ttc and support shim.files
try {
let res = await self.fetch("files.zip");
if (res.status === 200) {
let data = await res.arrayBuffer();
archive = new ZipFile(new Uint8Array(data));
let entries = archive.entries;
let count = Object.keys(entries).length;
console.log(`preloaded ${count} files`);
} else {
console.error(
`fetch of files.zip got status ${res.status}: ${res.statusText}`
);
}
} catch (e) {
console.error("preload failed", e);
}
})();