UNPKG

filepond

Version:

FilePond, where files go to stretch their bits.

50 lines (49 loc) • 2.27 kB
import type { FilePondEntry, FilePondFileEntry } from '../types/index.js'; import type { XHRResponse } from '../utils/xhr.js'; import type { RequestResolverContext, ResolvedRequest } from './common/requestResolver.js'; export type { ResolvedRequest, RequestResolverContext }; export interface URLLoaderResponseResolverContext<Value> { value: Value; response: XHRResponse; entry: FilePondFileEntry; } export type URLLoaderRequestResolver = (request: RequestResolverContext<FilePondFileEntry>) => ResolvedRequest | Promise<ResolvedRequest>; export type URLLoaderResponseResolver<Value> = (response: URLLoaderResponseResolverContext<Value>) => Value; export interface URLLoaderOptions { /** Action to run to trigger the load operation, defaults to `'load'`. */ actionLoad?: string; /** Action to run to abort the load operation, defaults to `'abort'`. */ actionAbort?: string; /** Hook that runs when determining the name for a file. Defaults to `() => 'Untitled'`. */ getBasename?: (entry: FilePondEntry, blob: Blob) => string; /** An object with key value pairs describing mime type relation to extension. */ mimeTypeMap?: { [key: string]: string; }; /** Fetch remote metadata using HEAD request so file content length and type are updated sooner, defaults to `true`. */ fetchMetadata?: boolean; /** Maximum number of URLs to load in parallel, defaults to `2`. */ parallel?: number; /** Determines if we should use WebWorkers for the `XMLHttpRequest`, defaults to `true`. */ useWebWorkers?: boolean; /** Where the extension can find the WebWorker to use */ workersURL?: URL; /** Resolve the URL and options sent to `XMLHttpRequest`. */ resolveRequest?: { metadata?: URLLoaderRequestResolver; load?: URLLoaderRequestResolver; }; /** Resolve the value created from the `XMLHttpRequest` response. */ resolveResponse?: { load?: URLLoaderResponseResolver<File>; }; } export declare const URLLoader: import("./common/createExtension.js").Extension; declare module '../index.js' { interface FilePondElement { URLLoader: URLLoaderOptions; } interface DefineFilePondOptions { URLLoader?: URLLoaderOptions; } }