* Show errors in logs always. nullLogger --> justErrorsLogger
Reasoning: too often we ended up showing errors in the Informer bubble, but not in the console, which is wrong and annoying. Devs still have an option to silence logs or direct them elsewhere by setting a custom logger
* Hide pause/resume buttons when error occures
* Update tests
* Update website/src/docs/uppy.md
Co-Authored-By: Renée Kooi <renee@kooi.me>
Co-authored-by: Renée Kooi <renee@kooi.me>
* 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>
* Add a method to update options in Core
* Add a method to update options in Plugin (for any plugins)
* Allow re-initializing i18n locales after they’ve been updated with .setOptions
* use rest spread instead of Object.assign
* override setOptions in plugins to include i18nInit
* merge restrictions object in setOptions
* check that newOpts exists
* add spread ...
* don’t double merge
* add i18nInit to all plugins that use translation strings
* add setOptions tests to Core and Dashboard
* add setOptions docs for Core and Plugins
* fix tests for thumbnail-generator by adding plugins: {} to mock core
cause ThumbnailGenerator now calls this.setPluginState, which expects `core.state.plugins`
* also update meta with setOptions if it’s passed, change the way this.opts is set in core
@goto-bus-stop does this look ok? merging restrictions opts in core
* if locale was passed to setOptions(), call plugin.setOptions() on all plugins, so that i18n updates
* add Dashboard test that checks if locale is updated from Core via setOptions()
* Reafactor website Dashboard example to use setOptions and allow selecting a locale
🎉
We were already doing `if (file.error)` in places, now that is
guaranteed to work even if the error message was empty or the error
object is custom and doesn't have a `.message` property.
* 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
* Warn that we can’t bundle remote files when uploading in xhr-upload
* allow for `error` type logs in `onError` callback
* refactor error handling
* tweak error copy
* add Promise.reject
* throw always
* update docs to reflect that we now send global metadata with xhr, and that bundle: true is not possible with remote uploads
* 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
* everywhere - decorative changes
* /examples - fix duplicate logs in examples
* @uppy/dashboard - only fire the safety resize if we're not in a closed modal
* website/examples - made sure console.debug works in IE10
Makes it a bit easier to follow. It also logs a warning now when you do
`.retryUpload(SomeNonsenseFileID)` instead of silently adding an invalid
object to the state.
* return file id of added files
* add documentation for returned value
* fix linting
* update test to new addFile API
* add docs for the change in the addFile API
* lerna link convert
* ci: use npm ci
* update lockfile
* companion: set `bin` to source file
Since typescript doesn't actually transform anything, we can just use
this.
In a next major version we could set `noEmit: true` in the tsconfig and
stop publishing `lib`.
* companion: do chmod +x on start-server.js
* build: remove obsolete lerna config
* build: explicitly install latest versions when building e2e tests for ci
* Remove versions from private packages
* fix regex
* try fix
* ci: force npm to install to endtoend folder
* ci: fold up e2e build output
* Update netlify deploy preview command
* Remove mentions of npm run bootstrap
* Edit .github/CONTRIBUTING.md instead
* companion: add proxy executable
* companion: fix publish
* Downgrade jest to appease create-react-app
* Select 5 files --> Select 5, because there are also folders
not ideal, but better
* selectXFiles --> selectX
* update selectX in all locales
* Update fi_FI.js
* 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
* Set file.type before calling onBeforeFileAdded, throw in upload so .catch works, emit restriction-failed for minNumberOfFiles, too
We must throw in upload onError, otherwise .catch won’t catch
* It seems startUpload is not used in Dashboard, used in StatusBar instead
probably a leftover from before StautsBar became a standalone plugin
* only log non-restriction errors
* throw early if restrictions.allowedFileTypes is not an array
* flip condition: do emit the event if err.isRestriction
* @uppy/locales - updated Nl translation as per Kevin
* @uppy/provider-views - moved all translations to Core, removed dependency on Dashboard
* @uppy/locales - added missing translations for 'Add more'
* Add an option to supply customLogger that will receive message and type from uppy.log
* Always use logger function, set to nullLogger by default
Co-Authored-By: Renée Kooi <github@kooi.me>
* add tests for logging and not logging with a function and debug: true
* Update packages/@uppy/core/src/loggers.js
account for `debug` not being available in IE10
Co-Authored-By: Renée Kooi <renee@kooi.me>
* add .call
* fix tests
* expose Uppy.debugLogger
* document logger
* core cleanup
* add logger to defaultOptions in docs too
* debug: true — only override logger if it has not been set in opts
* Log error in uppy.addFile try/catch
* Add `.isRestriction` to a custom RestrictionError, check for that before logging
* keep throwing for robodog.upload
//cc @goto-bus-stop