/** Codes for errors generated within this library */
export declare const FlateErrorCode: {
    readonly UnexpectedEOF: 0;
    readonly InvalidBlockType: 1;
    readonly InvalidLengthLiteral: 2;
    readonly InvalidDistance: 3;
    readonly StreamFinished: 4;
    readonly NoStreamHandler: 5;
    readonly InvalidHeader: 6;
    readonly NoCallback: 7;
    readonly InvalidUTF8: 8;
    readonly ExtraFieldTooLong: 9;
    readonly InvalidDate: 10;
    readonly FilenameTooLong: 11;
    readonly StreamFinishing: 12;
    readonly InvalidZipData: 13;
    readonly UnknownCompressionMethod: 14;
};
/** An error generated within this library */
export interface FlateError extends Error {
    /** The code associated with this error */
    code: number;
}
/** Options for compressing data into a DEFLATE format */
export interface DeflateOptions {
    /**
        The level of compression to use, ranging from 0-9.
        
        0 will store the data without compression.
        1 is fastest but compresses the worst, 9 is slowest but compresses the best.
        The default level is 6.
        
        Typically, binary data benefits much more from higher values than text data.
        In both cases, higher values usually take disproportionately longer than the reduction in final size that results.
        
        For example, a 1 MB text file could:
        - become 1.01 MB with level 0 in 1ms
        - become 400 kB with level 1 in 10ms
        - become 320 kB with level 9 in 100ms
    */
    level?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
    /**
        The memory level to use, ranging from 0-12. Increasing this increases speed and compression ratio at the cost of memory.
        
        Note that this is exponential: while level 0 uses 4 kB, level 4 uses 64 kB, level 8 uses 1 MB, and level 12 uses 16 MB.
        It is recommended not to lower the value below 4, since that tends to hurt performance.
        In addition, values above 8 tend to help very little on most data and can even hurt performance.
        
        The default value is automatically determined based on the size of the input data.
    */
    mem?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
}
/** Options for compressing data into a GZIP format */
export interface GzipOptions extends DeflateOptions {
    /**
        When the file was last modified. Defaults to the current time.
        Set this to 0 to avoid revealing a modification date entirely.
    */
    mtime?: Date | string | number;
    /**
        The filename of the data. If the `gunzip` command is used to decompress the data, it will output a file
        with this name instead of the name of the compressed file.
    */
    filename?: string;
}
/** Options for compressing data into a Zlib format */
export interface ZlibOptions extends DeflateOptions {
}
/**
    Handler for data (de)compression streams
    @param data The data output from the stream processor
    @param final Whether this is the final block
*/
export type FlateStreamHandler = (data: Uint8Array, final: boolean) => void;
/**
    Callback for asynchronous (de)compression methods
    @param err Any error that occurred
    @param data The resulting data. Only present if `err` is null
*/
export type FlateCallback = (err: FlateError | null, data: Uint8Array) => void;
/** Streaming DEFLATE compression */
export declare class Deflate {
    /**
        Creates a DEFLATE stream
        @param opts The compression options
        @param cb The callback to call whenever data is deflated
    */
    constructor(opts: DeflateOptions, cb?: FlateStreamHandler);
    constructor(cb?: FlateStreamHandler);
    private o;
    private d;
    /** The handler to call whenever data is available */
    ondata: FlateStreamHandler;
    private p;
    /**
        Pushes a chunk to be deflated
        @param chunk The chunk to push
        @param final Whether this is the last chunk
    */
    push(chunk: Uint8Array, final?: boolean): void;
}
/**
    Expands DEFLATE data with no wrapper
    @param data The data to decompress
    @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
    @returns The decompressed version of the data
*/
export declare function inflateSync(data: Uint8Array, out?: Uint8Array): Uint8Array<ArrayBufferLike>;
/** Streaming GZIP compression */
export declare class Gzip {
    private c;
    private l;
    private v;
    private o;
    /** The handler to call whenever data is available */
    ondata: FlateStreamHandler;
    /**
        Creates a GZIP stream
        @param opts The compression options
        @param cb The callback to call whenever data is deflated
    */
    constructor(opts: GzipOptions, cb?: FlateStreamHandler);
    /**
        Creates a GZIP stream
        @param cb The callback to call whenever data is deflated
    */
    constructor(cb?: FlateStreamHandler);
    /**
        Pushes a chunk to be GZIPped
        @param chunk The chunk to push
        @param final Whether this is the last chunk
    */
    push(chunk: Uint8Array, final?: boolean): void;
    private p;
}
/**
    Compresses data with GZIP
    @param data The data to compress
    @param opts The compression options
    @returns The gzipped version of the data
*/
export declare function gzipSync(data: Uint8Array, opts?: GzipOptions): Uint8Array<ArrayBuffer>;
/**
    Expands GZIP data
    @param data The data to decompress
    @param out Where to write the data. GZIP already encodes the output size, so providing this doesn't save memory.
    @returns The decompressed version of the data
*/
export declare function gunzipSync(data: Uint8Array, out?: Uint8Array): Uint8Array<ArrayBufferLike>;
/** Streaming Zlib compression */
export declare class Zlib {
    private c;
    private v;
    private o;
    /** The handler to call whenever data is available */
    ondata: FlateStreamHandler;
    /**
        Creates a Zlib stream
        @param opts The compression options
        @param cb The callback to call whenever data is deflated
    */
    constructor(opts: ZlibOptions, cb?: FlateStreamHandler);
    /**
        Creates a Zlib stream
        @param cb The callback to call whenever data is deflated
    */
    constructor(cb?: FlateStreamHandler);
    /**
        Pushes a chunk to be zlibbed
        @param chunk The chunk to push
        @param final Whether this is the last chunk
    */
    push(chunk: Uint8Array, final?: boolean): void;
    private p;
}
/**
    Compress data with Zlib
    @param data The data to compress
    @param opts The compression options
    @returns The zlib-compressed version of the data
*/
export declare function zlibSync(data: Uint8Array, opts?: ZlibOptions): Uint8Array<ArrayBuffer>;
/**
    Expands Zlib data
    @param data The data to decompress
    @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
    @returns The decompressed version of the data
*/
export declare function unzlibSync(data: Uint8Array, out?: Uint8Array): Uint8Array<ArrayBufferLike>;
/**
    Expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format
    @param data The data to decompress
    @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
    @returns The decompressed version of the data
*/
export declare function decompressSync(data: Uint8Array, out?: Uint8Array): Uint8Array<ArrayBufferLike>;
/** Attributes for files added to a ZIP archive object */
export interface ZipAttributes {
    /**
        The operating system of origin for this file. The value is defined
        by PKZIP's APPNOTE.txt, section 4.4.2.2. For example, 0 (the default)
        is MS/DOS, 3 is Unix, 19 is macOS.
    */
    os?: number;
    /**
        The file's attributes. These are traditionally somewhat complicated
        and platform-dependent, so using them is scarcely necessary. However,
        here is a representation of what this is, bit by bit:
        
        `TTTTugtrwxrwxrwx0000000000ADVSHR`
        
        TTTT = file type (rarely useful)
        
        u = setuid, g = setgid, t = sticky
        
        rwx = user permissions, rwx = group permissions, rwx = other permissions
        
        0000000000 = unused
        
        A = archive, D = directory, V = volume label, S = system file, H = hidden, R = read-only
        
        If you want to set the Unix permissions, for instance, just bit shift by 16, e.g. 0o644 << 16.
        Note that attributes usually only work in conjunction with the `os` setting: you must use
        `os` = 3 (Unix) if you want to set Unix permissions
    */
    attrs?: number;
    /**
        Extra metadata to add to the file. This field is defined by PKZIP's APPNOTE.txt,
        section 4.4.28. At most 65,535 bytes may be used in each ID. The ID must be an
        integer between 0 and 65,535, inclusive.
        
        This field is incredibly rare and almost never needed except for compliance with
        proprietary standards and software.
    */
    extra?: Record<number, Uint8Array>;
    /**
        The comment to attach to the file. This field is defined by PKZIP's APPNOTE.txt,
        section 4.4.26. The comment must be at most 65,535 bytes long UTF-8 encoded. This
        field is not read by consumer software.
    */
    comment?: string;
    /** When the file was last modified. Defaults to the current time. */
    mtime?: GzipOptions['mtime'];
}
/** Options for creating a ZIP archive */
export interface ZipOptions extends DeflateOptions, ZipAttributes {
}
/** Options for expanding a ZIP archive */
export interface UnzipOptions {
    /** A filter function to extract only certain files from a ZIP archive */
    filter?: UnzipFileFilter;
    decoder(buf: Uint8Array): string;
}
/** A file that can be used to create a ZIP archive */
export type ZippableFile = Uint8Array | Zippable | [Uint8Array | Zippable, ZipOptions];
/** The complete directory structure of a ZIPpable archive */
export interface Zippable {
    [path: string]: ZippableFile;
}
/**
    An unzipped archive. The full path of each file is used as the key,
    and the file is the value
*/
export interface Unzipped {
    [path: string]: Uint8Array;
}
/**
    Handler for string generation streams
    @param data The string output from the stream processor
    @param final Whether this is the final block
*/
export type StringStreamHandler = (data: string, final: boolean) => void;
/**
    Callback for asynchronous ZIP decompression
    @param err Any error that occurred
    @param data The decompressed ZIP archive
*/
export type UnzipCallback = (err: FlateError | null, data: Unzipped) => void;
/** Streaming UTF-8 decoding */
export declare class DecodeUTF8 {
    private p;
    private t;
    /**
        Creates a UTF-8 decoding stream
        @param cb The callback to call whenever data is decoded
    */
    constructor(cb?: StringStreamHandler);
    /**
        Pushes a chunk to be decoded from UTF-8 binary
        @param chunk The chunk to push
        @param final Whether this is the last chunk
    */
    push(chunk: Uint8Array, final?: boolean): void;
    /** The handler to call whenever data is available */
    ondata: StringStreamHandler;
}
/** Streaming UTF-8 encoding */
export declare class EncodeUTF8 {
    private d;
    /**
        Creates a UTF-8 decoding stream
        @param cb The callback to call whenever data is encoded
    */
    constructor(cb?: FlateStreamHandler);
    /**
        Pushes a chunk to be encoded to UTF-8
        @param chunk The string data to push
        @param final Whether this is the last chunk
    */
    push(chunk: string, final?: boolean): void;
    /** The handler to call whenever data is available */
    ondata: FlateStreamHandler;
}
/**
    Converts a string into a Uint8Array for use with compression/decompression methods
    @param str The string to encode
    @param latin1 Whether or not to interpret the data as Latin-1. This should
                  not need to be true unless decoding a binary string.
    @returns The string encoded in UTF-8/Latin-1 binary
*/
export declare function strToU8(str: string, latin1?: boolean): Uint8Array;
/**
    Converts a Uint8Array to a string
    @param dat The data to decode to string
    @param latin1 Whether or not to interpret the data as Latin-1. This should
                  not need to be true unless encoding to binary string.
    @returns The original UTF-8/Latin-1 string
*/
export declare function strFromU8(dat: Uint8Array, decoder: UnzipOptions['decoder']): string;
/** Information about a file to be extracted from a ZIP archive */
export interface UnzipFileInfo {
    /** The name of the file */
    name: string;
    /** The compressed size of the file */
    size: number;
    /** The original size of the file */
    originalSize: number;
    /**
        The compression format for the data stream. This number is determined by
        the spec in PKZIP's APPNOTE.txt, section 4.4.5. For example, 0 = no
        compression, 8 = deflate, 14 = LZMA. If the filter function returns true
        but this value is not 8, the unzip function will throw.
    */
    compression: number;
}
/**
    A filter for files to be extracted during the unzipping process
    @param file The info for the current file being processed
    @returns Whether or not to extract the current file
*/
export type UnzipFileFilter = (file: UnzipFileInfo) => boolean;
/**
    Synchronously decompresses a ZIP archive. Prefer using `unzip` for better
    performance with more than one file.
    @param data The raw compressed ZIP file
    @param opts The ZIP extraction options
    @returns The decompressed files
*/
export declare function unzipSync(data: Uint8Array, opts: UnzipOptions): Unzipped;
