import { EventEmitter } from 'eventemitter3'; import { XHRMethod, XHRResponseType } from './xhr'; import { ByteRange } from './byte-range'; import { ResourceRequestMaker, ResourceRequestResponseData } from './resource-request'; export declare enum ResourceEvents { BUFFER_SET = "buffer:set", BUFFER_CLEAR = "buffer:clear", FETCH_PROGRESS = "fetch:progress", FETCH_ABORTED = "fetch:aborted", FETCH_ERRORED = "fetch:errored", FETCH_SUCCEEDED = "fetch:succeeded", FETCH_SUCCEEDED_NOT = "fetch:succeeded-not" } export interface ParseableResource extends Resource { hasBeenParsed(): boolean; parse(): Promise; } export interface SegmentableResource extends Resource { getSegments(): Promise; } export interface DecryptableResource extends Resource { decrypt(): Promise; } export declare class Resource extends EventEmitter { private uri_; private baseUri_; private byteRange_; private ab_; private abortedCnt_; private fetchAttemptCnt_; private requestMaker_; private request_; private requestResponseData_; private requestBytesLoaded_; private requestBytesTotal_; private mimeType_; private fetchLatency_; private fetchResolve_; private fetchReject_; /** * * @param uri may be relative or absolute * @param byteRange * @param baseUri * @param mimeType */ constructor(uri: string, byteRange?: ByteRange, baseUri?: string, mimeType?: string); get uri(): string; get baseUri(): string; get byteRange(): ByteRange; get mimeType(): string; get hasBuffer(): boolean; get hasRequestResponses(): boolean; get hasData(): boolean; get buffer(): ArrayBuffer; get timesAborted(): number; get timesFetchAttempted(): number; get isFetching(): boolean; get fetchLatency(): number; get requestedBytesLoaded(): number; get requestedBytesTotal(): number; getRecordedTransmissionRateBps(): number; setBaseUri(baseUri: string): void; /** * Tries to resolve the resource's URI to an absolute URL, * with the given `baseUri` at construction or the optional argument * (which overrides the base of this instance for this resolution, but does not overwrite it). * Create a new resource object to do that. */ getUrl(base?: string): string; setBuffer(ab: ArrayBuffer): void; clearBuffer(ab: any): void; fetch(responseType?: XHRResponseType, method?: XHRMethod): Promise; abort(): void; /** * * @param rm passing null means use default */ setRequestMaker(rm: ResourceRequestMaker | null): void; getRequestMaker(): ResourceRequestMaker; hasCustomRequestMaker(): boolean; getRequestResponses(): ResourceRequestResponseData[]; flushAllRequestResponses(): void; getRequestResponse(pop?: boolean): ResourceRequestResponseData; setExternalyFetchedBytes(loaded: number, total: number, latency: number): void; private onRequestCallback_; }