/** Anything addressable by offset and length can be a source. */
export interface Source {
    /**
     * The length in bytes.
     *
     * @param signal The signal of the read that asks, for a source that has to fetch to know.
     */
    size(signal?: AbortSignal): Promise<number>;
    /**
     * Returns as much as was asked for.
     *
     * A short answer anywhere but at the end of the file is read as the source having stopped.
     *
     * @param into A buffer the source may write into and return a subarray of, or ignore;
     * the returned view is what counts. It must not be touched once the read resolves.
     *
     * @param signal The signal of the read that asks, for a source that can cut a read in flight.
     */
    read(at: number, length: number, into?: Uint8Array, signal?: AbortSignal): Promise<Uint8Array>;
    /** Never called on a source handed in: whoever opened a source closes it. */
    close?(): Promise<void>;
    /** A source that states none is read as `remote`. */
    trip?: Trip;
}
/**
 * What kind of round trip a read to this source is.
 *
 * - `local`: a disk on this machine.
 *
 * - `mount`: a network share read as files, such as SMB, NFS or SSHFS.
 *
 * - `remote`: a server across a network, such as one answering HTTP Range requests.
 */
export type Trip = "local" | "mount" | "remote";
export interface SizedSource {
    source: Source;
    fileSize: number;
}
export interface Range {
    at: number;
    length: number;
}
/** What a preset sets for one trip. */
export interface FetchKnobs {
    /** Two ranges closer than this are fetched as one, gap included. */
    gapBytes: number;
    /** How far past its stated size to look at each point the plan names. */
    cueAheadBytes: number;
    /** How far past a block the walk reads ahead when it reads that block. */
    blockAheadBytes: number;
    concurrency: number;
}
export type IndexFetch = Pick<FetchKnobs, "gapBytes" | "cueAheadBytes" | "concurrency">;
export type WalkFetch = Pick<FetchKnobs, "blockAheadBytes" | "concurrency">;
/**
 * Undoes zlib's deflate into a buffer of its own.
 *
 * It rejects bytes past the stream's end, and a stream that inflates past `most` bytes, stopping there.
 */
export type Inflate = (deflated: Uint8Array, most: number) => Promise<Uint8Array>;
export interface Watch {
    onProgress: ReportBytes;
    signal: AbortSignal;
}
/** A signal that fires with the first of the signals it links, or at its own abort, and then listens to none. */
export interface Link {
    signal: AbortSignal;
    abort: (reason?: unknown) => void;
    unlink: () => void;
}
type ReportBytes = (done: number, total: number) => void;
/** The opening read, wide enough for a typical header in one round trip. */
export declare const HEAD_BYTES: number;
/**
 * From this size a file Source stops zero-filling, and the pool makes no slot or loan below it.
 *
 * On a large read the zero-fill costs as much as the read.
 */
export declare const LARGE_READ_BYTES: number;
export declare const MAX_SPAN_BYTES: number;
/** The most any stored stream is undone to, where ffmpeg stops growing a frame's buffer. */
export declare const MAX_INFLATED_BYTES = 10000000;
export declare const lend: (into: Uint8Array | undefined, bounded: number) => Uint8Array | null;
export declare const givenSignal: (signal: AbortSignal | null | undefined) => AbortSignal | undefined;
export declare function abortReason(signal: AbortSignal | undefined): Error | null;
export declare function stopIfAborted(signal: AbortSignal | undefined): void;
/** A Watch whose report cannot end the read by throwing, and is not made once the signal fires. */
export declare function watchOver(signal: AbortSignal, report: ReportBytes): Watch;
export declare function available(at: number, length: number, size: number): number;
export declare function linkedSignal(...signals: ReadonlyArray<AbortSignal | undefined>): Link;
export declare function untilAborted<T>(answer: Promise<T>, signal: AbortSignal | undefined): Promise<T>;
export declare function onAbort(signal: AbortSignal | undefined, run: () => void): () => void;
export {};
