mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-23 23:27:09 +00:00
Improve item display (#283)
* Refactor item display to separate component * Load assets and render item models * Cache rendered items
This commit is contained in:
@@ -297,12 +297,12 @@ export class BiMap<A, B> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function readZip(file: File): Promise<[string, string][]> {
|
||||
const buffer = await file.arrayBuffer()
|
||||
export async function readZip(file: File | ArrayBuffer, predicate: (name: string) => boolean = () => true): Promise<[string, string][]> {
|
||||
const buffer = file instanceof File ? await file.arrayBuffer() : file
|
||||
const reader = new zip.ZipReader(new zip.BlobReader(new Blob([buffer])))
|
||||
const entries = await reader.getEntries()
|
||||
return await Promise.all(entries
|
||||
.filter(e => !e.directory)
|
||||
.filter(e => !e.directory && predicate(e.filename))
|
||||
.map(async e => {
|
||||
const writer = new zip.TextWriter('utf-8')
|
||||
return [e.filename, await e.getData?.(writer)] as [string, string]
|
||||
|
||||
Reference in New Issue
Block a user