feat(platform): 开源发布 - 初始化 Open AI Canvas

This commit is contained in:
ddCat committed 2026-07-22 14:29:10 +08:00
commit aea35896eb
365 files changed
+66410

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
import { unzipSync, zipSync } from "fflate";
type ZipFile = {
name: string;
data: BlobPart;
};
export async function createZip(files: ZipFile[]) {
const entries = await Promise.all(
files.map(async (file) => {
const data = new Uint8Array(await new Blob([file.data]).arrayBuffer());
return [file.name, data] as const;
}),
);
return new Blob([zipSync(Object.fromEntries(entries), { level: 0 })], { type: "application/zip" });
}
export async function readZip(file: Blob) {
const entries = unzipSync(new Uint8Array(await file.arrayBuffer()));
return new Map(Object.entries(entries).map(([name, data]) => [name, new Blob([data])]));
}