/** * ThumbnailHttpSource - Buffered HTTP source for thumbnail extraction. * * Uses a simple sliding buffer to cache data and reduce HTTP requests. * Each seek position triggers a larger chunk fetch, and subsequent reads * are served from the buffer until a new seek is needed. */ import type { SourceAdapter } from "./SourceAdapter"; /** * Minimal interface describing a source we can peek into without mutating. * HttpSource implements this structurally via peekMetadata() / peekRange(). */ export interface PeekableSource { peekMetadata(offset: number, length: number): Uint8Array | null; peekRange(offset: number, length: number): Uint8Array | null; } export declare class ThumbnailHttpSource implements SourceAdapter { private url; private headers; private size; private position; private abortController; private rangeUnsupported; private buffer; private bufferStart; private bufferEnd; private borrowSource; constructor(url: string, headers?: Record, borrowSource?: PeekableSource | null); setBorrowSource(source: PeekableSource | null): void; /** * Seed the file size from the main source so getSize() skips its own HEAD / * ranged-GET probe. Essential for non-range servers where that probe can't * recover a size (Cloudflare strips Content-Length on HEAD and may chunk the * 200 GET) — the main source already knows the size, so just reuse it. */ seedSize(size: number): void; getSize(): Promise; /** * Recover total size from a 1-byte ranged GET when HEAD lacks Content-Length. * Body is cancelled immediately — we only need the Content-Range header. */ private resolveSizeViaRange; /** * Check if requested data is in buffer */ private isInBuffer; /** * Read data - uses buffer cache to minimize HTTP requests */ read(offset: number, length: number): Promise; seek(offset: number): number; getPosition(): number; /** * Clear buffer to free memory when thumbnails aren't being actively generated * Call this after thumbnail generation is complete */ clearBuffer(): void; close(): void; getKey(): string; getUrl(): string; getBufferedEnd(): number; getBufferStart(): number; } export declare function createThumbnailHttpSource(url: string, headers?: Record): Promise; //# sourceMappingURL=ThumbnailHttpSource.d.ts.map