/** * Generic JS→C ABI dispatcher. * * Per-algorithm modules (algorithms//index.ts) call `createBindings` * with their algorithm enum + wasm URL; that factory returns the public * surface (compress, decompress, streams, version, etc.) bound to a * lazily-instantiated wasm module. The dispatcher itself doesn't ship in * any user bundle — only the slice of it the algorithm uses, after * tree-shaking. */ import { type WasmExports } from "./loader.js"; import { type Algorithm, type AlgorithmName, type CompressOptions, type DecompressOptions } from "./types.js"; /** Tracks allocations so a single try/finally can free them all. */ declare class Arena { private readonly exports; private readonly ptrs; constructor(exports: WasmExports); alloc(bytes: number, algoName: AlgorithmName): number; freeAll(): void; } export declare class Dispatcher { readonly algorithm: Algorithm; readonly algorithmName: AlgorithmName; /** @internal */ readonly exports: WasmExports; constructor(exports: WasmExports, algorithm: Algorithm, algorithmName: AlgorithmName); version(): string; setMaxDecompressedSize(bytes: number): void; compress(input: Uint8Array, opts?: CompressOptions): Uint8Array; decompress(input: Uint8Array, opts?: DecompressOptions): Uint8Array; private decompressStreaming; private tryProbeSize; createCompressStream(opts?: CompressOptions): CompressStream; createDecompressStream(): DecompressStream; /** @internal */ writeBytes(ptr: number, src: Uint8Array): void; /** @internal */ readBytes(ptr: number, len: number): Uint8Array; /** @internal */ writeU32(ptr: number, value: number): void; /** @internal */ readU32(ptr: number): number; /** @internal */ newArena(): Arena; } declare abstract class StreamBase { protected readonly dispatcher: Dispatcher; protected handle: number; protected finished: boolean; private readonly cleanup; constructor(dispatcher: Dispatcher, handle: number, destroyFn: (handle: number) => void); protected ensureLive(): void; destroy(): void; /** Symbol.dispose — enables `using stream = await create*()`. */ [Symbol.dispose](): void; } export declare class CompressStream extends StreamBase { constructor(dispatcher: Dispatcher, handle: number); write(chunk: Uint8Array): Uint8Array; finish(): Uint8Array; } export declare class DecompressStream extends StreamBase { constructor(dispatcher: Dispatcher, handle: number); write(chunk: Uint8Array): Uint8Array; finish(): Uint8Array; } export interface AlgorithmBindings { compress(input: Uint8Array, opts?: CompressOptions): Promise; decompress(input: Uint8Array, opts?: DecompressOptions): Promise; createCompressStream(opts?: CompressOptions): Promise; createDecompressStream(): Promise; /** TransformStream that compresses bytes as they flow through. */ compressionStream(opts?: CompressOptions): TransformStream; /** TransformStream that decompresses bytes as they flow through. */ decompressionStream(): TransformStream; /** Library version, e.g. "0.6.0". */ version(): Promise; /** * Cap on decompressed size (bytes) for the one-shot decompress path. * Defaults to 1 GiB. Set 0 to disable. Streaming decompress is not * affected — bound your own buffer there. Thread-local in C; in WASM * it's effectively global to this module instance. */ setMaxDecompressedSize(bytes: number): Promise; } export type WasmResolver = (url: URL) => Promise>; export declare function createBindings(algorithm: Algorithm, name: AlgorithmName, wasmUrl: URL, resolveWasm: WasmResolver): AlgorithmBindings; export {}; //# sourceMappingURL=dispatch.d.ts.map