import { ZipEntry } from 'node:zlib'; import { type Encoding } from './file.ts'; export interface ZipOptions { dirname?: string; print?: { info: boolean; files: boolean; }; } /** 将文件夹或文件列表压缩为 zip,返回生成的压缩包路径 (fp_zip) - data: - fpd_src: 被压缩文件夹路径 (string) 或 - entries: 文件列表 (Record<压缩后相对路径, 原文件绝对路径 (string) | 数据 (Uint8Array)>) - fp_zip: 生成的压缩包路径 (string) - options?: - dirname?: `fpd_src.fname` 传入 fpd_src 才生效,修改 zip 中顶层的文件夹的名字(需要以 / 结尾),如 'web/', 为空字符串时去掉顶层文件夹,不要多一个文件夹层级 (flat) - print?: - info?: `true` 开始压缩、压缩完成 - files?: `true` 打印压缩文件列表 */ export declare function fzip(data: string | Record, fp_zip: string, options?: ZipOptions): Promise; /** 将文件夹或文件列表压缩为 zip,返回压缩包数据 (Uint8Array) - data: - fpd_src: 被压缩文件夹路径 (string) 或 - entries: 文件列表 (Record<压缩后相对路径, 原文件绝对路径 (string) | 数据 (Uint8Array)>) - options?: - dirname?: `fpd_src.fname` 传入 fpd_src 才生效,修改 zip 中顶层的文件夹的名字(需要以 / 结尾),如 'web/', 为空字符串时去掉顶层文件夹,不要多一个文件夹层级 (flat) - print?: - info?: `true` 开始压缩、压缩完成 - files?: `true` 打印压缩文件列表 */ export declare function zip(data: string | Record, options?: ZipOptions): Promise; export interface ZipEntry { name: string; nameBuffer: Buffer; size: number; contentIterator(): AsyncIterable; content(): Promise; } export interface UnzipOptions { encoding?: Encoding; dryrun?: boolean; print?: { info: boolean; files: boolean; }; strip?: boolean; clean?: boolean; filter?(file: ZipEntry): boolean; } /** 解压 zip 包至文件夹,返回 fpd_out - zip: - 包路径 (string) 或 - 包数据 (Uint8Array | ArrayBuffer) - fpd_out: 解压到文件夹的完整路径 (string) - options?: - encoding?: `utf-8` 压缩包文件名编码 - dryrun?: 只是打印一下文件名列表,看看编码是否正确,不实际解压 - print?: - info?: `true` 开始解压、解压完成 - files?: `true` 打印解压缩的文件列表 - strip?: `true` 压缩包内只有一个顶层文件夹时自动去除该层级 - clean?: `true` 忽略解压 ftrashes 这些垃圾文件 - filter?: 用于过滤要解压的文件, 返回 falsy 值时忽略这个文件,要注意 file.name 为完整的相对路径(没有 strip) */ export declare function funzip(zip: string | Uint8Array | ArrayBuffer, fpd_out: string, options?: UnzipOptions): Promise; /** 解压 zip 包至内存,返回解压后的数据 (Record<文件或文件夹 (以 / 结尾) 的相对路径, Uint8Array>) - zip: - 压缩文件路径 (string) 或 - 压缩文件内容 (buffer) - options?: - encoding?: `utf-8` 压缩包文件名编码 - dryrun?: 只是打印一下文件名列表,看看编码是否正确,不实际解压 - print?: - info?: `true` 开始解压、解压完成 - files?: `true` 打印解压缩的文件列表 - strip?: `true` 压缩包内只有一个顶层文件夹时自动去除该层级 - clean?: `true` 忽略解压 ftrashes 这些垃圾文件 - filter?: 用于过滤要解压的文件, 返回 falsy 值时忽略这个文件,要注意 file.name 为完整的相对路径(没有 strip) */ export declare function unzip(zip: string | Uint8Array | ArrayBuffer, options?: UnzipOptions): Promise>;