@uppy/utils
Version:
Shared utility functions for Uppy Core and plugins maintained by the Uppy team.
383 lines (232 loc) • 13.4 kB
Markdown
# /utils
## 7.1.5
### Patch Changes
- 648f245: Fix `complete` event never firing for XHR and make sure the fetch aborts immediately if Uppy is cancelled before the fetch starts.
## 7.1.4
### Patch Changes
- ac12f35: Fix: Move completed uploads exclusion logic into uploaders. This fixes the problem where postprocessors would not run for already uploaded files.
## 7.1.3
### Patch Changes
- ad50314: Allow `getSafeFileId` to accept `UppyFile`
## 7.1.2
### Patch Changes
- 08b64f9: fix ts issue with generateFileID and `exactOptionalPropertyTypes`
## 7.1.1
### Patch Changes
- 0c16fe4: - Make `file.data` nullable - Because for ghosts it will be `undefined` and we don't have any type to distinguish ghosts from other (local) files. This caused a crash, because we didn't check for `undefined` everywhere (when trying to store a blob that was `undefined`)
- Introduce new field `progress`.`complete`: if there is a post-processing step, set it to `true` once post processing is complete. If not, set it to `true` once upload has finished.
- Throw a proper `Nonexistent upload` error message if trying to upload a non-existent upload, instead of TypeError
- Rewrite `Uppy.upload()` - this fixes two bugs:
1. No more duplicate emit call when this.#restricter.validateMinNumberOfFiles throws (`#informAndEmit` and `this.emit('error')`)
2. 'restriction-failed' now also gets correctly called when `checkRequiredMetaFields` check errors.
- Don't re-upload completed files #5930
- Split UppyFile into two intefaces distinguished by the `isRemote` boolean:
- LocalUppyFile
- RemoteUppyFile
- Remove TagFile type - Use UppyFile instead.
- Make `name` required on UppyFile (it is in reality always set)
- Fix bug: `RestrictionError` sometimes thrown with a `file` property that was _not_ a `UppyFile`, but a `File`. This would happen if someone passed a `File` instead of a `MinimalRequiredUppyFile` into `core.addFile` (which is valid to do according to our API)
- Improve some log messages
- Simplify Uppy `postprocess-complete` handler
## 7.1.0
### Minor Changes
- 5ba2c1c: Introduce the concept of server-side search and add support for it for the Dropbox provider. Previously, only client-side filtering in the currently viewed folder was possible, which was limiting. Now users using Companion with Dropbox can perform a search across their entire account.
## 7.0.2
### Patch Changes
- 975317d: Removed "main" from package.json, since export maps serve as the contract for the public API.
- 9bac4c8: Fix `TypeError: Cannot use 'in' operator to search for 'draggable' in null`
## 7.0.1
### Patch Changes
- 49522ec: Remove preact/compat imports in favor of preact, preventing JSX type issues in certain setups.
## 7.0.0
### Major Changes
- d301c01: Updated export maps for /utils: removed nested subpath exports; all utilities are now exported from the root index.js.
**Before :**
```typescript
import getFileTypeExtension from "@uppy/utils/lib/getFileTypeExtension";
```
**After :**
```typescript
import { getFileTypeExtension } from "@uppy/utils";
```
- c5b51f6: ### Export maps for all packages
All packages now have export maps. This is a breaking change in two cases:
1. The css imports have changed from `[package]/dist/styles.min.css` to `[package]/css/styles.min.css`
2. You were importing something that wasn't exported from the root, for instance `/core/lib/foo.js`. You can now only import things we explicitly exported.
#### Changed imports for `/react`, `@uppy/vue`, and `/svelte`
Some components, like Dashboard, require a peer dependency to work but since all components were exported from a single file you were forced to install all peer dependencies. Even if you never imported, for instance, the status bar component.
Every component that requires a peer dependency has now been moved to a subpath, such as `/react/dashboard`, so you only need to install the peer dependencies you need.
**Example for `/react`:**
**Before:**
```javascript
import { Dashboard, StatusBar } from "@uppy/react";
```
**Now:**
```javascript
import Dashboard from "@uppy/react/dashboard";
import StatusBar from "@uppy/react/status-bar";
```
## 6.2.2
### Patch Changes
- 1b1a9e3: Define "files" in package.json
## 6.2.0
### Minor Changes
- 0c24c5a: Use TypeScript compiler instead of Babel
## 6.1.4
Released: 2025-05-18
Included in: Uppy v4.16.0
- /audio,@uppy/box,/core,@uppy/dashboard,/drag-drop,@uppy/dropbox,/facebook,@uppy/file-input,/google-drive-picker,@uppy/google-drive,/google-photos-picker,@uppy/image-editor,/instagram,@uppy/onedrive,/remote-sources,@uppy/screen-capture,/unsplash,@uppy/url,/utils,@uppy/webcam,/webdav,@uppy/zoom: ts: make locale strings optional (Merlijn Vos / #5728)
## 6.1.3
Released: 2025-04-08
Included in: Uppy v4.14.0
- /utils: add msg mimetype (Merlijn Vos / #5699)
## 6.1.2
Released: 2025-02-03
Included in: Uppy v4.13.2
- /utils: do not strip www in getSocketHost (Merlijn Vos / #5621)
## 6.1.0
Released: 2025-01-06
Included in: Uppy v4.11.0
- /utils: Use .js(x) for all imports instead .ts(x) (Merlijn Vos / #5573)
## 6.0.6
Released: 2024-12-17
Included in: Uppy v4.9.0
- e2e,/status-bar,@uppy/utils: Companion stream upload unknown size files (Mikael Finstad / #5489)
## 6.0.5
Released: 2024-12-05
Included in: Uppy v4.8.0
- /audio,@uppy/aws-s3,/box,@uppy/companion-client,/compressor,@uppy/core,/dashboard,@uppy/drag-drop,/drop-target,@uppy/dropbox,/facebook,@uppy/file-input,/form,@uppy/golden-retriever,/google-drive,@uppy/google-photos,/image-editor,@uppy/informer,/instagram,@uppy/locales,/onedrive,@uppy/progress-bar,/provider-views,@uppy/react,/remote-sources,@uppy/screen-capture,/status-bar,@uppy/store-default,/thumbnail-generator,@uppy/transloadit,/tus,@uppy/unsplash,/url,@uppy/utils,/vue,@uppy/webcam,/xhr-upload,@uppy/zoom: cleanup tsconfig (Mikael Finstad / #5520)
## 6.0.4
Released: 2024-10-31
Included in: Uppy v4.6.0
- /aws-s3,@uppy/box,/companion-client,@uppy/core,/dashboard,@uppy/drag-drop,/dropbox,@uppy/facebook,/file-input,@uppy/form,/golden-retriever,@uppy/google-drive,/google-photos,@uppy/image-editor,/informer,@uppy/instagram,/locales,@uppy/onedrive,/progress-bar,@uppy/provider-views,/react-native,@uppy/react,/redux-dev-tools,@uppy/screen-capture,/status-bar,@uppy/store-default,/store-redux,@uppy/svelte,/thumbnail-generator,@uppy/transloadit,/tus,@uppy/unsplash,/url,@uppy/utils,/vue,@uppy/webcam,/xhr-upload,@uppy/zoom: Fix links (Anthony Veaudry / #5492)
## 6.0.0-beta.8
Released: 2024-06-04
Included in: Uppy v4.0.0-beta.10
- /utils: remove unused `settle` (Antoine du Hamel / #5210)
- /aws-s3,@uppy/tus,/utils,@uppy/xhr-upload: remove `uploader` from `upload-progress` event (Mikael Finstad / #5200)
## 6.0.0-beta.5
Released: 2024-05-03
Included in: Uppy v4.0.0-beta.5
- /audio,@uppy/compressor,/core,@uppy/dashboard,/remote-sources,@uppy/tus,/utils: Format (Murderlon)
## 6.0.0-beta.4
Released: 2024-04-29
Included in: Uppy v4.0.0-beta.4
- /utils: fix fetcher export (Murderlon)
- /utils: improve return type of `dataURItoFile` (Antoine du Hamel / #5112)
- /utils: add fetcher (Merlijn Vos / #5073)
## 6.0.0-beta.1
Released: 2024-03-28
Included in: Uppy v4.0.0-beta.1
- /aws-s3-multipart,@uppy/tus,/utils,@uppy/xhr-upload: Make `allowedMetaFields` consistent (Merlijn Vos / #5011)
- /utils: fix `RateLimitedQueue#wrapPromiseFunction` types (Antoine du Hamel / #5007)
- /utils: fix `findAllDOMElements` type (Antoine du Hamel / #4997)
- /utils: fix `AbortablePromise` type (Antoine du Hamel / #4988)
- /utils: migrate RateLimitedQueue to TS (Merlijn Vos / #4981)
## 5.9.0
Released: 2024-04-29
Included in: Uppy v3.25.0
- /utils: improve return type of `dataURItoFile` (Antoine du Hamel / #5112)
## 5.8.0
Released: 2024-04-16
Included in: Uppy v3.24.3
- /utils: add fetcher (Merlijn Vos / #5073)
## 5.7.5
Released: 2024-03-27
Included in: Uppy v3.24.0
- /utils: fix `RateLimitedQueue#wrapPromiseFunction` types (Antoine du Hamel / #5007)
- /utils: fix `findAllDOMElements` type (Antoine du Hamel / #4997)
- /utils: fix `AbortablePromise` type (Antoine du Hamel / #4988)
- /utils: migrate RateLimitedQueue to TS (Merlijn Vos / #4981)
## 5.7.4
Released: 2024-02-28
Included in: Uppy v3.23.0
- /companion-client,@uppy/utils,/xhr-upload: improvements for #4922 (Mikael Finstad / #4960)
- /utils: fix various type issues (Mikael Finstad / #4958)
- /utils: simplify `findDOMElements` (Mikael Finstad / #4957)
## 5.7.3
Released: 2024-02-22
Included in: Uppy v3.22.2
- /core,@uppy/utils: Introduce `ValidateableFile` & move `MinimalRequiredUppyFile` into utils (Antoine du Hamel / #4944)
- /utils: remove EventManager circular reference (Merlijn Vos / #4949)
## 5.7.1
Released: 2024-02-19
Included in: Uppy v3.22.0
- /utils: improve types for `finddomelement` (antoine du hamel / #4873)
- /utils: improve `preprocess` and `postprocess` types (antoine du hamel / #4841)
## 5.7.0
Released: 2023-12-12
Included in: Uppy v3.21.0
- /utils: fix import in test files (Antoine du Hamel / #4806)
## 5.6.0
Released: 2023-11-08
Included in: Uppy v3.19.0
- /utils: refactor to TS (Antoine du Hamel / #4699)
## 5.5.1
Released: 2023-09-29
Included in: Uppy v3.17.0
- /utils: test: migrate to Vitest for Uppy core and Uppy plugins (Antoine du Hamel / #4700)
## 5.5.0
Released: 2023-09-05
Included in: Uppy v3.15.0
- /aws-s3-multipart,@uppy/aws-s3,/companion-client,@uppy/core,/tus,@uppy/utils,/xhr-upload: Move remote file upload logic into companion-client (Merlijn Vos / #4573)
## 5.4.3
Released: 2023-07-24
Included in: Uppy v3.13.1
- /utils: align version of `preact` with the UI plugins (Antoine du Hamel / #4599)
## 5.4.0
Released: 2023-06-19
Included in: Uppy v3.10.0
- /companion,@uppy/core,/dashboard,@uppy/golden-retriever,/status-bar,@uppy/utils: Migrate all lodash' per-method-packages usage to lodash. (LinusMain / #4274)
- /aws-s3-multipart,@uppy/aws-s3,/tus,@uppy/utils,/xhr-upload: When file is removed (or all are canceled), controller.abort queued requests (Artur Paikin / #4504)
- /utils: rename `EventTracker` -> `EventManager` (Stephen Wooten / #4481)
## 5.1.3
Released: 2023-03-07
Included in: Uppy v3.6.0
- /utils: workaround chrome crash (Mikael Finstad / #4310)
## 5.1.2
Released: 2023-01-26
Included in: Uppy v3.4.0
- /utils: better fallbacks for the drag & drop API (Antoine du Hamel / #4260)
- /utils: Fix getSpeed type (referenced `bytesTotal` instead of `uploadStarted`) (Pascal Wengerter / #4263)
## 5.1.1
Released: 2022-11-16
Included in: Uppy v3.3.1
- /utils: fix types (Antoine du Hamel / #4212)
## 5.1.0
Released: 2022-11-10
Included in: Uppy v3.3.0
- /utils: update typings for `RateLimitedQueue` (Antoine du Hamel / #4204)
- /utils: add `cause` support for `AbortError`s (Antoine du Hamel / #4198)
## 5.0.2
Released: 2022-09-25
Included in: Uppy v3.1.0
- /audio,@uppy/aws-s3-multipart,/aws-s3,@uppy/box,/companion-client,@uppy/companion,/compressor,@uppy/core,/dashboard,@uppy/drag-drop,/drop-target,@uppy/dropbox,/facebook,@uppy/file-input,/form,@uppy/golden-retriever,/google-drive,@uppy/image-editor,/informer,@uppy/instagram,/locales,@uppy/onedrive,/progress-bar,@uppy/provider-views,/react,@uppy/redux-dev-tools,/remote-sources,@uppy/screen-capture,/status-bar,@uppy/store-default,/store-redux,@uppy/svelte,/thumbnail-generator,@uppy/transloadit,/tus,@uppy/unsplash,/url,@uppy/utils,/vue,@uppy/webcam,/xhr-upload,@uppy/zoom: add missing entries to changelog for individual packages (Antoine du Hamel / #4092)
## 5.0.1
Released: 2022-08-30
Included in: Uppy v3.0.1
- /utils: fix `relativePath` when drag&dropping a folder (Antoine du Hamel / #4043)
- /utils: Post-release website fixes (Merlijn Vos / #4038)
## 5.0.0
Released: 2022-08-22
Included in: Uppy v3.0.0
- /utils: fix drop of multiple files on Chromium browsers (Antoine du Hamel / #3998)
- /utils: Fix @uppy/utils microtip.scss export (Merlijn Vos / #3995)
- Switch to ESM
## 5.0.0-beta.1
Released: 2022-08-16
Included in: Uppy v3.0.0-beta.5
- /utils: Fix webp mimetype (Merlijn Vos / #3961)
- /utils: modernize `getDroppedFiles` (Antoine du Hamel / #3534)
## 4.1.0
Released: 2022-05-30
Included in: Uppy v2.11.0
- /utils: refactor to ESM (Antoine du Hamel / #3721)
## 4.0.7
Released: 2022-04-27
Included in: Uppy v2.9.4
- /utils: Fix getFileType for dicom images (Merlijn Vos / #3610)
## 4.0.6
Released: 2022-04-07
Included in: Uppy v2.9.2
- /aws-s3,@uppy/companion-client,/transloadit,@uppy/utils: Propagate `isNetworkError` through error wrappers (Renée Kooi / #3620)