/** * Avoid adding new code here. @wp-playground/common should remain * as lean as possible. * * This package exists to avoid circular dependencies. Let's not * use it as a default place to add code that doesn't seem to fit * anywhere else. If there's no good place for your code, perhaps * it needs to be restructured? Or maybe there's a need for a new package? * Let's always consider these questions before adding new code here. */ import type { UniversalPHP } from '@php-wasm/universal'; export { createMemoizedFetch } from './create-memoized-fetch'; export declare const RecommendedPHPVersion = "8.3"; /** * Reports cumulative progress through non-directory ZIP entries. * * Byte counts use declared uncompressed sizes and advance only between * entries. Entries skipped because overwriting is disabled still count as * processed. */ export interface UnzipProgress { /** Number of non-directory entries processed so far. */ filesProcessed: number; /** Total number of non-directory entries in the archive. */ totalFiles: number; /** Declared uncompressed bytes processed so far. */ uncompressedBytesProcessed: number; /** Declared uncompressed bytes across all non-directory entries. */ totalUncompressedBytes: number; } /** * Extracts a ZIP archive into Playground's virtual filesystem. * * `ZipArchive::extractTo()` has no extraction-progress callback in any * supported PHP version, so this function calls it in batches. Each batch ends * after either 100 files or 400 KiB of declared uncompressed data. * * For example, 250 one-byte files are extracted as three batches of 100, 100, * and 50 files. An `onProgress` callback receives an update after each batch. * Entries remain atomic, so a single file larger than 400 KiB finishes before * the update. * * `ZipArchive` follows symlinks already present in the destination. Do not * extract into a directory containing untrusted symlinks. * * @param php - PHP runtime whose filesystem contains the archive and target. * @param zipPath - Archive path in the PHP filesystem, or a browser `File`. * @param extractToPath - Destination directory, created when it does not exist. * @param overwriteFiles - Whether archive entries may replace existing paths. * Defaults to `true`. * @param onProgress - Optional callback for cumulative extraction progress. * @returns A promise that resolves when extraction finishes. * @throws When extraction fails or the progress callback throws. */ export declare const unzipFile: (php: UniversalPHP, zipPath: string | File, extractToPath: string, overwriteFiles?: boolean, onProgress?: (progress: UnzipProgress) => void) => Promise; export declare const zipDirectory: (php: UniversalPHP, directoryPath: string) => Promise;