mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-13 04:36:12 +01:00
21 lines
523 B
TypeScript
21 lines
523 B
TypeScript
import { HTTPRangeReader, unzip, ZipEntry } from "unzipit";
|
|||
|
|
import { AbstractVFS } from "./abstract";
|
||
|
|
|
||
|
|
export class ZipVFS extends AbstractVFS {
|
||
|
|
entries: Record<string, ZipEntry> = {};
|
||
|
|
|
||
|
|
constructor(private url: string, private root = "app/") {
|
||
|
|
super();
|
||
|
|
}
|
||
|
|
|
||
|
|
async init() {
|
||
|
|
const reader = new HTTPRangeReader(this.url);
|
||
|
|
const { entries } = await unzip(reader);
|
||
|
|
|
||
|
|
for (const entry of Object.values(entries)) {
|
||
|
|
this.entries[entry.name.slice(this.root.length)] = entry;
|
||
|
|
}
|
||
|
|
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
}
|