Commit graph

43 commits

Author SHA1 Message Date
Artur Paikin
013f5958d2 add tsv and tab (#2056) 2020-02-08 16:25:47 +03:00
Renée Kooi
1463ee79ce
Improve performance of adding and removing files (#1949)
* 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:

![Flamegraph](https://i.imgur.com/08veuoU.png)

All of the downward peaks are `setState()` calls and GC.

Now it takes around 60ms, and looks like this:

![Flamegraph](https://i.imgur.com/xFdwVBV.png)

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.

![Flamegraph](https://i.imgur.com/KhuD035.png)

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.

![Flamegraph](https://i.imgur.com/ZQ1IhxI.png)

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>
2020-01-13 12:29:08 +01:00
Artur Paikin
5cfd5495ff thumbnail-generator: Add webp to the list of supported types (#1961)
* Add webp to the list of supported types

* add webp to tests too
2019-12-04 11:07:47 +01:00
Renée Kooi
0f269fc054
utils: accept sync functions in wrapPromiseFunction() (#1910)
* utils: add failing test for wrapPromiseFunction(syncFn)

* utils: promisify non-promise-returning functions in wrapPromiseFunction()
2019-10-25 11:07:06 +02:00
Renée Kooi
12e005019e
aws-s3-multipart: fix queueing behaviours (#1855)
* 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
2019-10-09 19:55:29 +02:00
Renée Kooi
bb8b66d918
Use more cancellation-friendly strategy for limit: N uploads (#1736)
* 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
2019-09-25 15:21:17 +02:00
Artur Paikin
e82ac0f137
core: Don’t add/overwrite existing files, allow duplicates from different folders (#1767)
* 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
2019-09-19 16:43:51 +03:00
Evgenia Karunus
cc8c6540af getDroppedFiles.js: handle exceptions better (#1797)
* @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
2019-08-30 14:45:21 +03:00
Renée Kooi
c62ec3665d Update eslint to v6 (#1777)
* 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
2019-08-13 21:45:30 +03:00
Artur Paikin
4aef626a52
core: Added heic file type, refactor getFileType (#1734)
* add .heic and .heif file types

* refactor getFileType — we don’t need special condition for isRemote anymore
2019-07-17 19:54:06 +02:00
Renée Kooi
b42f904f2b core: adjust ID generation to keep non-latin characters (#1722)
* 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.
2019-07-17 16:12:51 +02:00
Artur Paikin
7873f057ca
utils: prettyBytes 1000 --> 1024 (#1732)
* 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
2019-07-16 15:21:47 +02:00
Evgenia Karunus
f88b0c5bc1 Add translations for aria labels in provider views (#1696)
* @uppy/provider-views - added translations for aria-labels

* @uppy/locales - added translations for provider views
2019-07-05 15:37:13 +03:00
Artur Paikin
81a45a01ed eslint jsdoc fixes 2019-06-25 18:27:48 +03:00
Evgenia Karunus
6bcf2040e9 Feature/accessibility (#1507)
* @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
2019-06-11 19:10:32 +03:00
Evgenia Karunus
8be2004826 Feature/replace dnd in drag drop package (#1565)
* /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
2019-06-05 17:04:34 +03:00
Evgenia Karunus
450ab8ceb1 @uppy/utils - made getDroppedFiles.js work for IE11 (#1630) 2019-06-04 19:19:39 +03:00
Evgenia Karunus
2476e97459 getDroppedFiles.js - made .relativePath of nonfoldered files null (#1602) 2019-05-29 19:37:51 +03:00
Renée Kooi
3b1d5b933f
Update eslint-plugin-compat and eslint-plugin-jest 2019-05-20 11:29:10 +02:00
Renée Kooi
f97b3931bb
Upgrade eslint. 2019-05-20 11:28:44 +02:00
Evgenia Karunus
3fdaaa8bab mimeTypes.js - added pdf&txt mime types 2019-05-16 06:11:02 +05:00
Renée Kooi
3efb5662b9
Commit improved code formatting suggestion
Co-Authored-By: Tiarhai <garyedwardthomas@yahoo.ie>
2019-04-28 13:16:01 +01:00
Tiarhai
b9863c5029 Status Bar: Hide seconds if more than 1 hour 2019-04-27 21:56:42 +01:00
Renée Kooi
e55757455d
dashboard,utils: fix import paths 2019-04-18 16:55:39 +02:00
Evgenia Karunus
97ad62b4cc UrlPlugin - made sure url drop/paste is browser-compatible 2019-04-17 21:12:03 +02:00
Evgenia Karunus
bcd9472da5 getDroppedFiles.js - moved into @uppy/utils, refactored 2019-04-17 01:30:32 +02:00
Ifedapo Olarewaju
62305be8b9 companion-client: remove the use of window.location 2019-04-01 14:44:03 +01:00
Artur Paikin
a0355dbbe8 use stubs instead of removed locales 2019-03-19 14:45:56 +03:00
Renée Kooi
8c51a8340a
tl-wrapper: Embeddable dashboard part 1 2018-12-20 14:50:31 +01:00
Jonathan Derrough
4633abc143 Fixed getFileType() when passed a file with an upper case extension
Updated the unit tests
2018-11-23 15:13:08 +01:00
Artur Paikin
4efc27675c Allow locale inheritance: defaultLocale, this.uppy.locale, this.opts.locale
Mostly what @goto-bus-stop did in 4f51deaaf7 (diff-989af75a364b65c408abe1fc3e7ac0f4R34)

> This patch allows locale keys passed to the main Uppy instance to override default keys in plugins. It's just one idea to kick things off, I'm not attached to this particular implementation.
>
> If we do this we need to make sure that all keys have unique names and that things specific to eg. a single service are "namespaced" (`transloaditEncoding` instead of `encoding`).
>
> The benefit to this is that there is a central point of configuration for languages, so there could be language packs with strings for eg Czech at `@uppy/lang-cz` (or `@uppy/langs/cz`) that would be very easy to use.
2018-10-20 12:49:06 -04:00
Renée Kooi
626f511ebd
Support mime types with additional data, fixes #1074 2018-10-08 15:26:32 +02:00
Renée Kooi
e9bb066f29
utils: Previews can be generated for image/jpg mime type 2018-10-08 14:23:31 +02:00
Renée Kooi
f958638455 utils: Add fallback to getFileType (#1022)
If we can't determine the file type, use the generic
'application/octet-stream' type. This way `file.type` will always be
defined and uploaders don't have to worry about it being `null` or
whatever.
2018-08-27 14:33:56 +02:00
Renée Kooi
632c95a094
Remove unused runPromiseSequence util. 2018-06-28 14:15:17 +02:00
Renée Kooi
07eb4fc0b9
Move truncateString util into @uppy/dashboard. 2018-06-28 14:00:17 +02:00
Renée Kooi
a59efea878
Remove unused getArrayBuffer util. 2018-06-28 13:58:03 +02:00
Renée Kooi
e875df7996
Move copyToClipboard util into @uppy/dashboard. 2018-06-28 13:56:40 +02:00
Renée Kooi
d494e7df3c
Unit test fixes. 2018-06-18 15:49:59 +02:00
Renée Kooi
382f4fba95
Move stylesheets into packages. 2018-06-18 12:35:47 +02:00
Renée Kooi
2c4e7eaa68
Move Translator into @uppy/utils package.
Available as `@uppy/utils/lib/Translator`.
The Translator tests were using `Core()` instead of `Translator()`, so I
changed it to using `Translator` instances directly. The functionality
being tested did not change.

Steps taken:

```bash
git mv src/core/Translator.* packages/@uppy/utils/src
sed -i 's/[./]*\/core\/Translator/@uppy\/utils\/lib\/Translator/' src/**/*.js
vim packages/@uppy/utils/src/Translator.test.js # Fix tests
```
2018-06-14 16:31:19 +02:00
Renée Kooi
2e257b7e55
Move utils files to @uppy/utils package.
And rewrite all the require calls.

```bash
git mv src/utils/* packages/@uppy/utils/src
sed -i 's/[./]*\/utils\//@uppy\/utils\/lib\//' src/**/*.js # transform (../)*utils → @uppy/utils
```
2018-06-14 16:31:19 +02:00
Renée Kooi
c1d378de21
Add @uppy/utils skeleton.
```bash
mkdir -p packages/@uppy
cp -R package-template packages/@uppy/utils
vim packages/@uppy/utils/{README.md,package.json}
```

Next up, copying the implementation.
2018-06-14 16:31:19 +02:00