/** * TypeScript bindings for the Emscripten-compiled liblzma WASM module. * * Provides typed wrappers around the raw C functions exported by liblzma.wasm, * with proper memory management and error handling. */ import { type WasmLzmaStream } from './memory.js'; import { type LZMAModule } from './types.js'; /** * Initialize the WASM module. Must be called before any operation. * * The module is loaded once and cached. Subsequent calls return * the same instance. Can be called with a custom loader for * inline/bundled WASM scenarios. * * @param loader - Optional custom module loader (for inline WASM) * @returns The initialized Emscripten module */ export declare function initModule(loader?: () => Promise): Promise; /** * Get the initialized module, throwing if not yet loaded. */ export declare function getModule(): LZMAModule; /** * Reset module state (for testing purposes). */ export declare function resetModule(): void; /** * Initialize an easy encoder on the given lzma_stream. * * @param stream - Allocated WasmLzmaStream * @param preset - Compression preset (0-9, optionally OR'd with EXTREME flag) * @param check - Integrity check type (default: CRC64) * @throws LZMAError on initialization failure */ export declare function encoderInit(stream: WasmLzmaStream, preset: number, check?: number): void; /** * Initialize a stream decoder on the given lzma_stream. * * @param stream - Allocated WasmLzmaStream * @param memlimit - Memory limit in bytes (default: 256MB) * @throws LZMAOptionsError if memlimit is invalid * @throws LZMAError on initialization failure */ export declare function decoderInit(stream: WasmLzmaStream, memlimit?: number | bigint): void; /** * Initialize an auto decoder (detects format) on the given lzma_stream. * * @param stream - Allocated WasmLzmaStream * @param memlimit - Memory limit in bytes (default: 256MB) * @throws LZMAOptionsError if memlimit is invalid * @throws LZMAError on initialization failure */ export declare function autoDecoderInit(stream: WasmLzmaStream, memlimit?: number | bigint): void; /** * Run lzma_code on a stream (one step of encoding/decoding). * * @param stream - Active WasmLzmaStream * @param action - LZMA_RUN, LZMA_FINISH, etc. * @returns The lzma return code (LZMA_OK, LZMA_STREAM_END, or error) */ export declare function code(stream: WasmLzmaStream, action: number): number; /** * Finalize a stream and free its internal resources. */ export declare function end(stream: WasmLzmaStream): void; /** * Get the memory usage of a stream (in bytes). */ export declare function memusage(stream: WasmLzmaStream): number; /** * Compress a buffer using lzma_easy_buffer_encode. * * @param input - Data to compress * @param preset - Compression preset (0-9) * @param check - Integrity check type (default: CRC64) * @returns Compressed data * @throws LZMAError on compression failure */ export declare function easyBufferEncode(input: Uint8Array, preset: number, check?: number): Uint8Array; /** * Decompress a buffer using lzma_stream_buffer_decode. * * @param input - XZ compressed data * @param memlimit - Memory limit in bytes (default: 256MB) * @returns Decompressed data * @throws LZMAError on decompression failure */ /** * Validate a memlimit value before coercion to BigInt. * * BigInt() throws a native RangeError for NaN, Infinity, and non-integer * numbers (e.g. 1.5). Negative integers produce a huge unsigned value when * interpreted by the C ABI (uint64_t wrap-around). Numbers above * Number.MAX_SAFE_INTEGER (2^53 - 1) lose precision on coercion to BigInt. * All these cases are rejected here with LZMAOptionsError so callers always * get an LZMAError subclass. * * @throws LZMAOptionsError if the value is invalid */ export declare function validateMemlimit(memlimit: number | bigint): void; export declare function streamBufferDecode(input: Uint8Array, memlimit?: number | bigint): Uint8Array; /** * Process a full input buffer through an initialized encoder/decoder stream, * collecting all output chunks. * * This is used by the buffer APIs (xzAsync/unxzAsync) for streaming * encoding/decoding within a single call. * * @param stream - Initialized WasmLzmaStream (encoder or decoder) * @param input - Input data * @returns Concatenated output * @throws LZMAError on processing failure */ export declare function processStream(stream: WasmLzmaStream, input: Uint8Array): Uint8Array; /** * Get the liblzma version string (e.g. "5.6.3"). */ export declare function versionString(): string; /** * Check if a given integrity check type is supported. */ export declare function checkIsSupported(check: number): boolean; //# sourceMappingURL=bindings.d.ts.map