Commit graph

111 commits

Author SHA1 Message Date
ifedapoolarewaju
7bf5ca55a7
Release 2020-09-07 12:40:44 +01:00
Andrew
0533357d61
Remove the --save flag (#2503) 2020-09-04 14:32:21 +02:00
ifedapoolarewaju
36ab6f1d49
Release 2020-07-30 15:52:20 +01:00
Andrew
5bc704baf5
dash: Add support for AVIF images in thumbnails (#2406)
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)
2020-07-29 18:46:46 +02:00
Renée Kooi
2d91641ddd
Release 2020-07-29 16:50:45 +02:00
Renée Kooi
72965029f2
dashboard: mostly restore backwards compatibility for the browse strings (#2397) 2020-07-29 15:15:51 +02:00
Renée Kooi
16686fc0ca
Release 2020-07-15 13:59:56 +02:00
Renée Kooi
5012eb4124
aws-s3-multipart: implement retries (#2312) 2020-07-13 15:10:23 +02:00
Artur Paikin
b00ba13912 Release 2020-06-13 03:12:22 +01:00
Artur Paikin
ef5977643a Refactor to use fetchWithNetworkError 2020-06-12 15:27:00 +01:00
Renée Kooi
6a01523273
Release 2020-05-25 15:51:21 +02:00
Renée Kooi
58cf8e8deb
utils: fix Translator constructor type, fixes #2263 2020-05-13 13:02:04 +02:00
Kevin van Zonneveld
803611ed04
Move @uppy/utils/lib/prettyBytes -> @transloadit/prettier-bytes (#2231)
* 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>
2020-05-07 16:54:13 +02:00
ifedapoolarewaju
5528c6f6ea
Release 2020-04-30 12:52:46 +01:00
Renée Kooi
6e2dfd7c0f
Release 2020-04-29 17:45:02 +02:00
Artur Paikin
ed8a494875
Mark network errors as NetworkError (#2110)
* 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>
2020-04-21 10:36:49 +02:00
Ryan Schumacher
87c4deb45c
Remove duplicate check of element type (#2210) 2020-04-20 11:26:41 +02:00
ifedapoolarewaju
323233488f
Release 2020-04-15 20:07:42 +01:00
Artur Paikin
5752662a93 Release 2020-04-14 22:25:47 +02:00
Renée Kooi
7bf390abda
add markdown linting using remark (#2181)
* build: add markdown linting

* build: support markdown front matter

* build: fail remark lint on warnings

* Fix markdown lint warnings

* changelog: fix markdown errors, allow literal URLs

* ci: add markdown lint step

* website: regenerate contributing.md

* build: properly ignore vendor and built files from remark-lint

* build: add private packages to lerna config
2020-04-13 09:48:11 +02:00
ifedapoolarewaju
0481589f3b
Release 2020-04-08 17:37:56 +01:00
Renée Kooi
ab76448508
aws-s3: handle upload internally instead of deferring to xhr-up… (#2060)
* 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
2020-04-06 13:53:21 +02:00
ifedapoolarewaju
fa32da7cf3
Release 2020-03-25 12:37:44 +01:00
Renée Kooi
876f8a2fc0
webcam: Try to respect restrictions (#2090)
* 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>
2020-03-24 18:53:36 +01:00
Artur Paikin
5079d98584
dashboard: 2020 redesign 🍿 (#2015)
* 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
2020-03-24 18:05:11 +01:00
Renée Kooi
5e25b2a939
Fix translations that did not respect word order (#2077)
* 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>
2020-03-19 14:41:14 +01:00
Artur Paikin
2c98271103 Release 2020-02-14 23:17:48 +01:00
Renée Kooi
be66c47deb
Actually check types (#1918)
* types: stronger typings

* Remove remaining `declare module` things for uppy.use

* Format types standard-style-like

* Add `target` properties to plugin typings

* Add type for `replaceTargetContent` option

* xhr-upload: allow lowercase method

* opt in to stricter typechecks

* use the strictly typed version in all typings tests

* endtoend: use strict types in typescript test

* Add some comments to the typings file so IDEs will warn about untyped use()

* informer: remove obsolete option from typings

* react: generate prop types based on actual options types

* react: update types

* react: fix import in typings test

* companion-client: add `pluginId` property to ProviderOptions type

Co-Authored-By: Ifedapo .A. Olarewaju <ifedapoolarewaju@gmail.com>

* core: remove some `any` types

* *: add locale string types

* *: generate locale typings

* core: fix LocaleStrings<> type

* dashboard: add locale string type tests

* tus: inherit options typings from tus-js-client

* transloadit: add missing options types

* ci: do the required build steps before testing typings

* Support TokenStorage in types, add `title?: string` options

* form: update typings

* types: put TokenStorage type in dependents

* Document Uppy.StrictTypes

* if we pin at least we should use the latest

* Allow document.querySelector

I think it's a eslint-plugin-compat bug that it's marking querySelector
as not available in Android Chrome 78.

Co-authored-by: Ifedapo .A. Olarewaju <ifedapoolarewaju@gmail.com>
2020-02-12 16:22:09 +01:00
Artur Paikin
07e9909bfc Release 2020-02-12 12:24:41 +01:00
Artur Paikin
77ef346cb0 Release 2020-02-11 21:17:04 +01:00
Artur Paikin
013f5958d2 add tsv and tab (#2056) 2020-02-08 16:25:47 +03:00
Renée Kooi
2b91a96c95
Release 2020-01-15 16:39:45 +01: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
Renée Kooi
18180d5778
Release 2019-12-16 12:53:23 +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
c370dba0b6
Release 2019-11-04 10:56:06 +01:00
Aaron Ross
44bcea6d03 add UppyFile.response typing (#1882)
* add UppyFile.response typing

* add some `file.response` type tests
2019-10-25 16:23:30 +02: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
4e32e61d7c
Release 2019-10-09 21:00:46 +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
Artur Paikin
056a7114a1 Release 2019-08-30 15:24:04 +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
bd2beedcff Release 2019-07-18 17:21:42 +02: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