anydrop-core
The headless AnyDrop engine.
Classes
| Class | Description |
|---|---|
| AnyDropCore | The 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
| Interface | Description |
|---|---|
| AnyDropCoreOptions | Self is the type of this inside callbacks (the instance). |
| AnyDropEvents | Every event with its arguments. Events marked (ui) are emitted by @vedratech/anydrop-ui. |
| AnyDropFile | The public file object: the native File, with properties added. It can be passed to FormData, FileReader and URL.createObjectURL unchanged. |
| AnyDropUploadState | Upload bookkeeping on every file (file.upload). |
| ChunkInfo | A chunk of a file, passed to params(files, xhr, chunk) (with file and index). |
| ConnectionState | The connection as getConnectionState() reports it. |
| DataBlock | One blob of a request, passed to url(files, dataBlocks) and method(files, dataBlocks). |
| DataTransferLike | A DataTransfer (drop) or the clipboardData of a paste. |
| ErrorEntry | One entry per file that is currently in error. |
| FolderCounts | Per-status counters of every descendant file of a folder. |
| FolderNode | A folder in the tree. Nodes are live objects shared with events; do not change them. getTree() returns the virtual root (path: ''). |
| Transport | Sends requests. Replace the built-in XMLHttpRequest transport with the transport option (S3, tus, fetch adapters or a fake for tests). |
| TransportHandle | What Transport.send() returns: abort, progress and the response promise. |
| TransportRequest | One request core hands to a transport: an upload, a manifest, a finalize, a chunk-status or a probe request. |
| TransportResponse | What a transport resolves with. Any HTTP status, even 4xx or 5xx, is a response. |
| Unsubscribe | Returned by on() / once(): call it to remove the listener, or chain .on() / .once(). |
Type Aliases
| Type Alias | Description |
|---|---|
| AcceptDone | Callback passed to accept(): call with no argument to accept, or with a message to reject. |
| AnyDropCoreConfig | What the constructor and setOption accept: options plus event handlers. |
| AnyDropEventHandlers | Event handlers that can be passed as options, ({ success(file, res) {} }). |
| AnyDropEventName | - |
| AnyDropOptions | - |
| EntryLike | A FileSystemEntry (FileSystemFileEntry or FileSystemDirectoryEntry). |
| ErrorCode | A known code (autocomplete) or any string a backend sends. |
| FileStatus | Status of a file, and the rolled-up status of a folder. |
| KnownErrorCode | Codes core itself creates or the protocol defines (protocol section 6). A backend may send others. |
| Listener | - |
| PauseReason | - |
| PauseTarget | Payload of the paused and resumed events. |
Variables
| Variable | Description |
|---|---|
| ACCEPTED | Alias of QUEUED. |
| ADDED | Status 'added': accepted but not queued yet. |
| CANCELED | Status 'canceled'. |
| ERROR | Status 'error': rejected or failed. |
| PAUSED | Status 'paused'. |
| PROCESSING | Alias of UPLOADING. |
| QUEUED | Status 'queued': waiting for an upload slot. |
| SUCCESS | Status 'success': uploaded. |
| UPLOADING | Status 'uploading'. |
| VERSION | Library version, equal to the version in packages/core/package.json. |
| xhrTransport | The built-in transport, based on XMLHttpRequest (which has upload progress). Use it as the fallback in your own transport. |
Functions
| Function | Description |
|---|---|
| defaultOptions | Fresh defaults (a new object each call: instances share no state). |
| isValidFile | Whether 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. |
| uuidv4 | Creates a UUID version 4 (works without HTTPS). |