Skip to content

anydrop-core ​

The headless AnyDrop engine.

Classes ​

ClassDescription
AnyDropCoreThe headless upload engine: reads dropped and picked files and folders, validates them, builds the folder tree and uploads in chunks, with pause, resume and retry. Configure it with options, methods and events.

Interfaces ​

InterfaceDescription
AnyDropCoreOptionsSelf is the type of this inside callbacks (the instance).
AnyDropEventsEvery event with its arguments. Events marked (ui) are emitted by @vedratech/anydrop-ui.
AnyDropFileThe public file object: the native File, with properties added. It can be passed to FormData, FileReader and URL.createObjectURL unchanged.
AnyDropUploadStateUpload bookkeeping on every file (file.upload).
ChunkInfoA chunk of a file, passed to params(files, xhr, chunk) (with file and index).
ConnectionStateThe connection as getConnectionState() reports it.
DataBlockOne blob of a request, passed to url(files, dataBlocks) and method(files, dataBlocks).
DataTransferLikeA DataTransfer (drop) or the clipboardData of a paste.
ErrorEntryOne entry per file that is currently in error.
FolderCountsPer-status counters of every descendant file of a folder.
FolderNodeA folder in the tree. Nodes are live objects shared with events; do not change them. getTree() returns the virtual root (path: '').
TransportSends requests. Replace the built-in XMLHttpRequest transport with the transport option (S3, tus, fetch adapters or a fake for tests).
TransportHandleWhat Transport.send() returns: abort, progress and the response promise.
TransportRequestOne request core hands to a transport: an upload, a manifest, a finalize, a chunk-status or a probe request.
TransportResponseWhat a transport resolves with. Any HTTP status, even 4xx or 5xx, is a response.
UnsubscribeReturned by on() / once(): call it to remove the listener, or chain .on() / .once().

Type Aliases ​

Type AliasDescription
AcceptDoneCallback passed to accept(): call with no argument to accept, or with a message to reject.
AnyDropCoreConfigWhat the constructor and setOption accept: options plus event handlers.
AnyDropEventHandlersEvent handlers that can be passed as options, ({ success(file, res) {} }).
AnyDropEventName-
AnyDropOptions-
EntryLikeA FileSystemEntry (FileSystemFileEntry or FileSystemDirectoryEntry).
ErrorCodeA known code (autocomplete) or any string a backend sends.
FileStatusStatus of a file, and the rolled-up status of a folder.
KnownErrorCodeCodes core itself creates or the protocol defines (protocol section 6). A backend may send others.
Listener-
PauseReason-
PauseTargetPayload of the paused and resumed events.

Variables ​

VariableDescription
ACCEPTEDAlias of QUEUED.
ADDEDStatus 'added': accepted but not queued yet.
CANCELEDStatus 'canceled'.
ERRORStatus 'error': rejected or failed.
PAUSEDStatus 'paused'.
PROCESSINGAlias of UPLOADING.
QUEUEDStatus 'queued': waiting for an upload slot.
SUCCESSStatus 'success': uploaded.
UPLOADINGStatus 'uploading'.
VERSIONLibrary version, equal to the version in packages/core/package.json.
xhrTransportThe built-in transport, based on XMLHttpRequest (which has upload progress). Use it as the fallback in your own transport.

Functions ​

FunctionDescription
defaultOptionsFresh defaults (a new object each call: instances share no state).
isValidFileWhether a file passes a type list such as 'image/*,.pdf' (the syntax of the HTML accept attribute). An empty list accepts everything. A file with an empty MIME type is judged by the type its extension suggests.
uuidv4Creates a UUID version 4 (works without HTTPS).

Released under the MIT License.