/** * Pure JavaScript DEFLATE implementation for browsers without CompressionStream support * * This fallback supports: * - Decompression: Full DEFLATE decompression (RFC 1951) * - Compression: STORE mode only (no compression, but valid DEFLATE format) * * Used automatically when CompressionStream with "deflate-raw" is unavailable: * - Firefox < 113 * - Safari < 16.4 * - Chrome < 103 */ /** * Decompress DEFLATE data (raw format, no zlib header) * * @param data - Compressed data in deflate-raw format * @returns Decompressed data */ export declare function inflateRaw(data: Uint8Array): Uint8Array; /** * Compress data using DEFLATE STORE mode (no compression) * * This creates valid DEFLATE data but without actual compression. * Files will be larger but this works on all browsers. * * @param data - Data to "compress" * @returns DEFLATE-formatted data (stored, not compressed) */ export declare function deflateRawStore(data: Uint8Array): Uint8Array; /** * Compress data using DEFLATE with Dynamic Huffman codes (BTYPE=2). * * Uses LZ77 with hash chains and lazy matching for match finding, then builds * optimal Huffman trees from the symbol frequencies for entropy coding. * * @param data - Data to compress * @param level - Compression level (1-9, default 6) * @returns Compressed data in deflate-raw format */ export declare function deflateRawCompressed(data: Uint8Array, level?: number): Uint8Array; /** * Stateful synchronous DEFLATE compressor with Dynamic Huffman encoding. * * Unlike `deflateRawCompressed` (which is a one-shot function), this class * maintains state across multiple `write()` calls: * * - **LZ77 sliding window**: back-references can span across chunks. * - **Hash chains**: match positions persist across chunks with typed-array * hash tables for fast lookup. * - **Lazy matching**: configurable per compression level. * - **Dynamic Huffman**: each block builds optimal Huffman trees from * actual symbol frequencies (BTYPE=2), producing significantly smaller * output than fixed Huffman (BTYPE=1). * - **Bit writer**: bit position is preserved, so consecutive blocks form * a single valid DEFLATE bit-stream without alignment issues. * * Each `write()` emits one non-final Dynamic Huffman block (BFINAL=0). * `finish()` emits a final empty fixed-Huffman block (BFINAL=1). * * This is the pure-JS equivalent of Node.js `zlib.deflateRawSync` with * `Z_SYNC_FLUSH`, used by the streaming ZIP writer (`pushSync`) to achieve * constant-memory streaming in both Node.js and browsers. * * @param level - Compression level (0-9). Level 0 emits STORE blocks. * Default: 6 (matching zlib default). */ export declare class SyncDeflater { private _output; private _config; private _level; private _state; constructor(level?: number); /** * Compress a chunk and return the compressed bytes produced so far. * The output is a valid prefix of a DEFLATE stream (one or more non-final blocks). */ write(data: Uint8Array): Uint8Array; /** * Finalize the DEFLATE stream. Emits a final empty fixed-Huffman block * and returns any remaining bytes (including partial-byte padding). */ finish(): Uint8Array; /** * Write STORE (uncompressed) blocks for level=0. * Each block is non-final (BFINAL=0); the final block is emitted by finish(). */ private _writeStore; }