* move findIndex to @uppy/utils, add tests
* use Array.findIndex instead of Array.indexOf in uppy.removePlugin
because strict comparison started failing with Vue3 Proxies
* dashboard: fix modal position on rtl pages, fixes#2495
* Align text to the right on right-to-left pages
* core: fix default text alignment on right-to-left pages
* dashboard: fix margin in provider browser on right-to-left pages
* dashboard: use direction-aware offset properties
* provider-views: use logical offset CSS properties
* status-bar: use logical offset CSS properties
* dashboard: fix addMore icon margin on RTL pages
* dashboard: some more logical properties
* build: compile logical properties to old CSS
* dashboard: set dir attribute if page did not provide one
* status-bar: set fallback text direction if not provided
* support direction option for inline and modal dashboard
* use companion.uppy.io on deploy previews
* provider-views: fix RTL alignment of file icons
* put the dir attribute on a wrapper div
* fix icon alignment in RTL provider views
* informer: fix ? alignment in RTL mode
* add passesRestrictions(file) and utilize it in provider-views
* disallow selecting more than maxNumberOfFiles
* add restriction reason and include folders
* let’s leave folder out of this for now — otherwise not only you can’t select them, but navigate too
* disallow selecting if totalCurrentSelectionFileSize is over maxTotalFileSize
* handle maxNumberOfFiles not being set 🙈
* fix totalCurrentSelectionFileSize and handle no file.name
* support grid in restrictions
* refactor the restriction reason logic, rename to validateRestrictions, wrap icon in a container
* add uppyFileSizes 🙈
* get rid of canSelectMore in favor of validateRestrictions (file, files)
* handle shift key bulk selection
* remove unused props
* use infoTimeout
I added support to load thumbnails when uploading AVIF images, by adding 'avif' to the regex. I also updated the unit test.
Note that support for this is dependant on browser support, and currently only Chrome 85+ and Firefox 77+ support it (Firefox requires flag to be set to allow it)
* Move @uppy/utils/lib/prettyBytes -> @transloadit/prettier-bytes so we can more easily re-use it across projects
* Switch to MIT licensed @transloadit/prettier-bytes
* lockfile fun
* build: add dep for website/inject.js
Co-authored-by: Renée Kooi <renee@kooi.me>
* Add NetworkError error type and isNetworkError utility check
* Detect network errors in tus and xhr-upload
Co-Authored-By: Ifedapo .A. Olarewaju <ifedapoolarewaju@gmail.com>
* add NetworkError check to RequestClient in companion-client
* return false if !xhr 🙈
* move catch so that only errors from _checkMinNumberOfFiles are caught — errors from uploads are logged in `upload-error` already
//cc @goto-bus-stop
* Add NetworkError to MiniXHRUpload in aws-s3
//cc @goto-bus-stop
* Add tests
//cc @ifedapoolarewaju
* pass xhr to NetworkError
* add logging in catch of uppy.upload()
* start error message with “This looks like a network error”
* originalRequest --> request, return NetworkError right away
* check for NetworkError in `delete` as well
do we need it in preflight too, @ifedapoolarewaju?
* remove redundant error message re-declaration
* _showOrLogErrorAndThrow, but don’t showInformer
Co-authored-by: Ifedapo .A. Olarewaju <ifedapoolarewaju@gmail.com>
* aws-s3: handle actual upload internally instead of deferring to XHRUpload
* aws-s3: add a comment explaining the mess
* aws-s3: move XHRUpload code into a separate class
* utils: support prioritization in rate limiting queue
* aws-s3: remove old implementation
* core,status-bar: account for pre/postprocessing files in progress calculations
* changelog: add entry for this PR
* utils: Support cancellation in `RateLimitedQueue#wrapPromiseFunction`
* s3: remove preprocessing stage, only use upload-* events
* utils: remove console.log
* aws-s3: comment out duplicate `upload-started`
* xhr-upload: reorder `ProgressTimeout` creation for readability
* aws-s3: apply 7d972e0 to MiniXHRUpload
* aws-s3: apply 4ed7508 to MiniXHRUpload
* webcam: request a video mime type listed in `allowedFileTypes`
* webcam: stop recording when we are about to reach the max file size
* webcam: request an image mime type listed in `allowedFileTypes`
* docs: add Webcam#preferredImageMimeType
* locale: add `recordingStoppedMaxSize` string
* changelog: check webcam restrictions
Co-authored-by: Artur Paikin <artur@arturpaikin.com>
* ProviderViews: Improve Instagram’s “video thumbnail”
* Update all provider icons to nicer round ones
* Change “drop files” copy depending on number of acquirers and Dashboard width
* Translator: support multiple components in options
When the source contains multiple placeholders for interpolation, we should ignore chunks that are not strings, because those can be JSX objects and will be otherwise incorrectly turned into strings.
Without this condition we’d get this: [object Object] hello [object Object] my <button>
* Remove unused locale strings
* Rever renderSingleInlineProvider, use Browse button instead of link, tweak styles
* Try “Browse My Device” button
* Introduce “Dark Mode“: new Dashboard option 'theme': 'light', 'dark' or 'auto'
* Refactor to also add uninstall/removeListener for the darkModeMediaQuery; remove all bindings in favor of class properties
* More dark mode styles: Providers, FileCard, tweaking focus, inputs, etc
* My Device: mobile and desktop icons
* add isMobileDevice capability, very simple detection
* More dark mode styles
* refactor
* switch back to single simple my device icon
* chrome 78 for android doesn’t support document.querySelector 👌
* nobr --> span white-space: nowrap
* Major style tweaks for mobile provider list, show dashed borders only when DnD is supported
* Add color after “import from”
just for Russian for now, because I’m thinking if this should be a part of the language string or html? @goto-bus-stop @kvz, what do you think?
* improve isMobileDevice, add tests
* don’t set the isMobileDevice capability in core for now
* add checks for typeof window !== 'undefined', otherwise fails in Node/RN
* update locales
* refactor renderDropFilesSubtitle
* Fix translations that did not respect word order
Fixes#2069
We were still using raw string concatenation in these two places. To
maintain backwards compatibility, this commit adds _new_ translations
that are substitution-based instead of concatenation-based. The old
translation is passed in as a possible substitution parameter
`backwardsCompat`, and the default (English) translations use this
parameter.
With this, if you are using a custom locale that overrides eg. the
`exceedsSize` string, Uppy will first get your `exceedsSize`
translation, and then use the default `exceedsSize2` translation which
concatenates that result and the file size. So it works the same as it
did in the past.
If a translation requires a different word order, it can override the
`exceedsSize2` translation instead.
```js
new Uppy({
locale: {
strings: {
exceedsSize2: 'Maximum file size of %{size} exceeded',
poweredBy2: '%{uppy} made this!'
}
}
})
```
In 2.0, we can remove all the old strings and only use `poweredBy2` (and
probably rename them to `poweredBy` too, heh)
* website: add missing dashboard strings to docs
* locales: remove unused second plural form from EN and NL
* build: allow different numbers of plural forms
* utils: add test for new throwing behaviour
* docs: insert PR url
* locales: revert ko_KR changes
* changelog: add 2.0 backlog entry
* locales: var → const
* docs: add brief note that translators should supply a pluralize function
* locales: update en_US with new template
* fix HEIGHT_MD = 400
Co-authored-by: Artur Paikin <artur@arturpaikin.com>
* core: add an addFiles() method that only updates state once
Previously, adding 1300-ish files took around 260ms, and looked like
this in Firefox's performance tab:

All of the downward peaks are `setState()` calls and GC.
Now it takes around 60ms, and looks like this:

Here, most of the time is spent generating file IDs and guessing file
types. Those would be areas to look at next.
* dashboard: prevent frequent state update if nothing changed
After the last commit, `addFiles()` still spends a lot of time in
`emit()` and `hideAllPanels()`. The reason is that `addFiles()` still
emits all the hundreds of file-added events, and the Dashboard responds
to each with `hideAllPanels()`, which does a state update. But this all
happens synchronously, and the state almost certainly did not change
since the last `file-added` event that fired a millisecond ago.
This adds a check to avoid the state update if it is not necessary.

Adding 1300 files takes about 40ms now.
With this change, the `addFiles()` call is no longer the slowest
part—now preact rendering all the items is!
* utils: optimize generateFileID and getFileNameAndExtension
Replaces some clever things with more mundane and faster things!
Now, generateFileID is a bunch of string concatenations.
Now, getFileNameAndExtension uses `lastIndexOf()` instead of a regex.

Adding 1300 files takes about 25ms.
* dashboard: use preact-virtual-list
* thumbnail-generator: add `lazy` option
* dashboard: request thumbnails once file item renders the first time
* dashboard: fork preact-virtual-list
* core: add removeFiles() to remove files in bulk
* Implement removeFile() in terms of removeFiles()
* thumbnail-generator: only queue files that can be previewed
* rename size constants to accommodate WIDTH/HEIGHT
* Use new uppy.addFiles in DragDrop and FileInput
* utils: fix getFileNameAndExtension() type
* Rip out the lazy thumbnail generation
* Rip out virtualization.
* Remove virtualization leftovers
* tell future people that this is intentionally verbose
* Update package-lock.json
* henlo i am spell
* Make `addFiles()` respect maxNumberOfFiles
* core: show an informer error if some files fail in bulk add
* locales: fix quotes to make build:locale-pack happy
Co-authored-by: Artur Paikin <artur@arturpaikin.com>
* aws-s3-multipart: prevent deadlock in rate limit queue
* utils: fix RateLimitedQueue thrashing when aborting all items
* aws-s3-multipart: only send abort request if upload was already created, fixes#1146
* xhr-upload: redo limit option using different strategy
* xhr-upload: fix marking requests as done
* Move duplicate createEventTracker definitions to @uppy/utils
* tus: new cancellation for local uploads
* tus: fix cancelling queued uploads
* tus: fix wrong name
* aws-s3-multipart: smol refactor
* aws-s3-multipart: new cancellation style
* aws-s3: new cancellation
* utils: port limitPromises test to RateLimitedQueue
* timing fix?
* tus: new cancellation on websocket
* xhr-upload: implement cancellation for remote uploads
* aws-s3-multipart: port to new cancellation
* utils: remove limitPromises
* xhr-upload: remove pause/resume code
* xhr-upload: clean up event listeners
* xhr-upload: extract progress timer to separate class
* Move ProgressTimeout class to utils
* utils: update typings
* Fix lint
* tus: make pause/resume respect the rate limiting queue
* tus: try to explain some of the tricky things at play in the Tus#upload method
* aws-s3-multipart: add missing { abort: true }
* aws-s3-multipart: make pause/resume respect the rate limiting queue
* eslintrc.json - fixed eslint warnings for jsdoc
* Revert "eslintrc.json - fixed eslint warnings for jsdoc"
This reverts commit 50b24773ce.
* eslintrc.json - allow indentation in jsdoc comments
* xhr-upload: fix promise return value
* tus: fix promise return value
* tus: add missing `return () => {}`
* utils: typing export type fixes
* tus: add more jsdoc
* companion-client: add missing SocketOptions type
* utils: fix more export typings
* core,companion-client,tus: more typings tweaking
* companion-client: test fix 😩
* companion-client: add type for Socket#open
* tus: fix emit() call
* add local cancellation fuzz....ish? test
* Add file.data.relativePath to the file.id
* Don’t add/overwrite a file if a file with the same id already exsists, issue a warning
* override @uppy/tus fingerprint to uppy’s file.id
* combine cordove/react native handling, don’t log twice
* always use onError for errors in addFile
* use file.meta.relativePath instead of file.data.relativePath
what do you think, @lakesare?
* update tests to include allowing/diallowing duplicates and file.id generation with relativePath
* update tus-js-client
* refactor error handling for addFile and upload into a mutual _showOrLogErrorAndThrow method
* explain duplicate files and relativePath
* throw TypeError vs Error when allowedFileTypes is not an array
* fix tests
* tweak docs
* Emit restriction-failed for all restriction errors, move it to _showOrLogErrorAndThrow
* @utils/getDroppedFiles.js - mild refactoring
* @utils/getDroppedFiles.js - added .info and .log on drop error
* @utils/getDroppedFiles.js - one more refactor
* @utils/getDroppedFiles.js - log error objects instead of strings
* Update eslint
* Do eslint --fix
* Do not access Object.prototype method 'hasOwnProperty' from target object
* utils: add hasProperty
* eslint --fix
* Disable quote-props for locale files
* add back quotes in locale files
* revert locale files to state on master
* Update react-scripts
* core: add test for ID generation with non-latin names
* core: adjust ID generation to keep non-latin characters
This shouldn't be bc-breaking!
Now, non-latin characters are encoded as their charcode in base 32, so
files that only differ by name in a non-latin language will generate
different IDs.
* Replace prettier-bytes with its copy, only use 1024 instead of 1000 to justify KB vs kB
* Add tests
* added License
* pretty-bytes to @uppy/utils/lib/prettyBytes everywhere
* @uppy/provider-views - added accessibility
* @uppy/provider-views - simplified checkbox css
* @uppy/dashboard - on tab set focus to the current verlay
* @uppy/dashboard - factored out code related to focus into a separate file
* @uppy/dashboard, and connected plugins - made focus travel well, and be managed in a single place in Dashboard
* @uppy/dashboard - made modal opener button focus keep focus on modal close
* @uppy/dashboard - focus management for uploaded-files
* @uppy/dashboard - made informer read messages without interruption
* @uppy/provider-views - removed the bug of focus jumping on safari
* @uppy/dashboard - made focus travel well in instagram in firefox
* @uppy - moved lodash.debounce dependency from / to @uppy/dashboard
* everywhere - made <ul>s not focusable for firefox
* @uppy/provider-views - unnested scss, copypasted alex's :focus changes
* Added JSDoc eslint package and rules, and fixed some JSDoc comments
* .eslintrc - made jsdoc errors warnings instead
* package-lock.json for new package.json
* eslint fix
* @uppy/dashboard - avoid forcing focus when we are inline
* @uppy/dashboard - in firefox, made sure superfocus is not switching back to uppy
* @uppy/dashboard - no focus jump for .info() inline, fix for firefox
Made focus not interrupt .info() when we are in the inline mode;
Made firefox start superfocusing when we either tab into, or click on some element in Uppy
* @uppy/dashboard - only listen to click/focus on uppy
* @uppy/dashboard - started trapping focus in inline mode too
* @uppy/dashboard - restricted trapFocus() event listener to this.el
* @uppy/core - started throttling progress emits.
1. To fix heat up in firefox
2. To fix focus in firefox
* @uppy/core - fixed tests by adding .flush()-s for progress emits
* @uppy/dashboard - stopped trapping focus in inline mode, made background inert
* @uppy/dashboard - added MutationObserver polyfill
* tests - made locale-packs.js pass
* REVERTED last 3 commits that introduced inert
Inert requires too many polyfills, atm tests fail in IE 10.0, wicg-inert library reportedly has performance issues. We decided to at least wait until _some_ browser introduce inert html property natively.
* @uppy/dashboard - IE11 fix for focusing
* @uppy/dashboard - fix for a bug in Safari for long uploads with checkbox clicking
* RERUN TESTS - tiny commit to rerun tests
* @uppy/dashboard - removed useless touchstart event listener
* Cancel superFocus in recordIfFocusedOnUppyRecently, when focus moves away from Uppy
* @uppy/provider-views - made Filter not swallow letters
* @uppy/dashboard - stopped superfocus from refocusing if we're already in the overlay
* /examples/dev - added drag-drop plugin dev environment
* @uppy/drag-drop - moved isDragDropSupported() to @uppy/utils
* @uppy/drag-drop - got rid of drag-drop npm library
* examples/dev - made compiled files placed in /output instead of /lib
* ~/examples/dev - made watchify only watch files once
* @uppy/drag-drop - add onPaste
* /examples/dev - readded html css override-attempts
* @uppy/drag-drop - made whole area clickable, and made it accessible
* @uppy/drag-drop - removed excessive outline in firefox
* REVERTED last 2 commits