import jszip from 'jszip'; export declare class Zip { /** --- zip 对象 --- */ private readonly _zip; /** --- 当前路径,以 / 开头以 / 结尾 --- */ private _path; constructor(zip: jszip); getContent(path: string): Promise; getContent(path: string, type: T): Promise; /** * --- 写入文件内容 --- * @param path 文件路径 * @param data 要写入的内容 * @param options 选项 */ putContent(path: string, data: IZipInputByType[T], options?: { 'base64'?: boolean; 'binary'?: boolean; 'date'?: Date; }): void; /** * --- 删除一个文件/文件夹(深度删除) --- * @param path 要删除的文件路径 */ unlink(path: string): void; /** * --- 获取对象是否存在,存在则返回 stats 对象,否则返回 null --- * @param path 对象路径 */ stats(path: string): IZipStats | null; /** * --- 判断是否是目录或目录是否存在,是的话返回 stats --- * @param path 判断路径 */ isDir(path: string): IZipStats | false; /** * --- 判断是否是文件或文件是否存在,是的话返回 stats --- * @param path 判断路径 */ isFile(path: string): IZipStats | false; /** --- 读取目录,hasChildren: false, hasDir: true, pathAsKey: false --- */ readDir(path?: string, opt?: { 'hasChildren'?: boolean; 'hasDir'?: boolean; 'pathAsKey'?: false; }): IZipItem[]; readDir(path?: string, opt?: { 'hasChildren'?: boolean; 'hasDir'?: boolean; 'pathAsKey': true; }): Record; private _readDir; /** --- 目录列表缓存 --- */ private _list; /** * --- 重建目录列表缓存 --- */ private _refreshList; /** * --- 获取当前目录,末尾不带 / --- * @return string */ pwd(): string; /** * --- 进入一个目录(不存在也能进入,需要自行判断) --- * --- 返回进入后的路径值 --- * @param dir 相对路径或绝对路径 */ cd(dir: string): string; /** * --- 打包 zip --- * @param options 选项 */ generate(options?: { 'type'?: T; 'level'?: number; 'onUpdate'?: (percent: number, currentFile: string | null) => void; }): Promise; /** * --- 获取 path 和 string/Blob 对应的文件列表 --- */ getList(): Promise>; } /** * --- 获取 zip 对象 --- * @param data 对象数据 */ export declare function get(data?: TZipInputFileFormat): Promise; export interface IZipItem { 'name': string; 'compressedSize': number; 'uncompressedSize': number; 'date': Date; 'isFile': boolean; 'isDirectory': boolean; 'path': string; } export interface IZipStats { 'compressedSize': number; 'uncompressedSize': number; 'date': Date; 'isFile': boolean; 'isDirectory': boolean; } export interface IZipOutputByType { 'base64': string; 'string': string; 'array': number[]; 'uint8array': Uint8Array; 'arraybuffer': ArrayBuffer; 'blob': Blob; } export type TZipOutputType = keyof IZipOutputByType; export interface IZipInputByType { 'base64': string; 'string': string; 'array': number[]; 'uint8array': Uint8Array; 'arraybuffer': ArrayBuffer; 'blob': Blob; } export type TZipInputType = keyof IZipInputByType; export type TZipInputFileFormat = IZipInputByType[keyof IZipInputByType]; export interface IZipMetadata { percent: number; currentFile: string | null; }