From 8138b459780c5a77e283c43e83bb6c2af3583291 Mon Sep 17 00:00:00 2001 From: Merlijn Vos Date: Thu, 28 Sep 2023 16:09:02 +0200 Subject: [PATCH 1/9] @uppy/aws-s3-multipart: retry signature request (#4691) Co-authored-by: Antoine du Hamel Co-authored-by: Mikael Finstad --- .../dashboard-aws-multipart.spec.ts | 22 +++++++--- packages/@uppy/aws-s3-multipart/src/index.js | 44 ++++++++++++++----- .../@uppy/aws-s3-multipart/src/index.test.js | 2 +- 3 files changed, 49 insertions(+), 19 deletions(-) diff --git a/e2e/cypress/integration/dashboard-aws-multipart.spec.ts b/e2e/cypress/integration/dashboard-aws-multipart.spec.ts index 3db45f0ecd..cc1e57f75f 100644 --- a/e2e/cypress/integration/dashboard-aws-multipart.spec.ts +++ b/e2e/cypress/integration/dashboard-aws-multipart.spec.ts @@ -72,12 +72,20 @@ describe('Dashboard with @uppy/aws-s3-multipart', () => { cy.get('.uppy-StatusBar-statusPrimary').should('contain', 'Upload failed') cy.intercept('POST', '/s3/multipart', { statusCode: 200, times: 1, body: JSON.stringify({ key:'mocked-key-attempt3', uploadId:'mocked-uploadId-attempt3' }) }).as('createMultipartUpload-attempt3') - cy.intercept('GET', '/s3/multipart/mocked-uploadId-attempt3/1?key=mocked-key-attempt3', { - statusCode: 200, - headers: { - ETag: 'ETag-attempt3', - }, - body: JSON.stringify({ url:'/put-success-attempt3', expires:8 }), + let intercepted = 0 + cy.intercept('GET', '/s3/multipart/mocked-uploadId-attempt3/1?key=mocked-key-attempt3', (req) => { + if (intercepted++ < 2) { + // Ensure that Uppy can recover from at least 2 network errors at this stage. + req.destroy() + return + } + req.reply({ + statusCode: 200, + headers: { + ETag: 'ETag-attempt3', + }, + body: JSON.stringify({ url:'/put-success-attempt3', expires:8 }), + }) }).as('signPart-attempt3') cy.intercept('PUT', '/put-success-attempt3', { statusCode: 200, @@ -92,7 +100,7 @@ describe('Dashboard with @uppy/aws-s3-multipart', () => { }), }).as('completeMultipartUpload-attempt3') cy.get('.uppy-StatusBar-actions > .uppy-c-btn').click() - cy.wait(['@createMultipartUpload-attempt3', '@signPart-attempt3', '@put-attempt3', '@completeMultipartUpload-attempt3']) + cy.wait(['@createMultipartUpload-attempt3', ...Array(3).fill('@signPart-attempt3'), '@put-attempt3', '@completeMultipartUpload-attempt3']) cy.get('.uppy-StatusBar-statusPrimary').should('contain', 'Complete') }) diff --git a/packages/@uppy/aws-s3-multipart/src/index.js b/packages/@uppy/aws-s3-multipart/src/index.js index 3ca43bd8bb..6d26e17616 100644 --- a/packages/@uppy/aws-s3-multipart/src/index.js +++ b/packages/@uppy/aws-s3-multipart/src/index.js @@ -76,7 +76,7 @@ class HTTPCommunicationQueue { #requests - #retryDelayIterator + #retryDelays #sendCompletionRequest @@ -112,7 +112,7 @@ class HTTPCommunicationQueue { this.#sendCompletionRequest = requests.wrapPromiseFunction(options.completeMultipartUpload, { priority:1 }) } if ('retryDelays' in options) { - this.#retryDelayIterator = options.retryDelays?.values() + this.#retryDelays = options.retryDelays ?? [] } if ('uploadPartBytes' in options) { this.#uploadPartBytes = requests.wrapPromiseFunction(options.uploadPartBytes, { priority:Infinity }) @@ -122,7 +122,7 @@ class HTTPCommunicationQueue { } } - async #shouldRetry (err) { + async #shouldRetry (err, retryDelayIterator) { const requests = this.#requests const status = err?.source?.status @@ -137,7 +137,7 @@ class HTTPCommunicationQueue { // more than one request in parallel, to give slower connection a chance // to catch up with the expiry set in Companion. if (requests.limit === 1 || this.#previousRetryDelay == null) { - const next = this.#retryDelayIterator?.next() + const next = retryDelayIterator.next() if (next == null || next.done) { return false } @@ -156,7 +156,7 @@ class HTTPCommunicationQueue { } else if (status === 429) { // HTTP 429 Too Many Requests => to avoid the whole download to fail, pause all requests. if (!requests.isPaused) { - const next = this.#retryDelayIterator?.next() + const next = retryDelayIterator.next() if (next == null || next.done) { return false } @@ -175,7 +175,7 @@ class HTTPCommunicationQueue { } } else { // Other error code means the request can be retried later. - const next = this.#retryDelayIterator?.next() + const next = retryDelayIterator.next() if (next == null || next.done) { return false } @@ -348,14 +348,36 @@ class HTTPCommunicationQueue { async uploadChunk (file, partNumber, chunk, signal) { throwIfAborted(signal) const { uploadId, key } = await this.getUploadId(file, signal) - throwIfAborted(signal) + + const signatureRetryIterator = this.#retryDelays.values() + const chunkRetryIterator = this.#retryDelays.values() + const shouldRetrySignature = () => { + const next = signatureRetryIterator.next() + if (next == null || next.done) { + return null + } + return next.value + } + for (;;) { + throwIfAborted(signal) const chunkData = chunk.getData() const { onProgress, onComplete } = chunk + let signature - const signature = await this.#fetchSignature(this.#getFile(file), { - uploadId, key, partNumber, body: chunkData, signal, - }).abortOn(signal) + try { + signature = await this.#fetchSignature(this.#getFile(file), { + uploadId, key, partNumber, body: chunkData, signal, + }).abortOn(signal) + } catch (err) { + const timeout = shouldRetrySignature() + if (timeout == null || signal.aborted) { + throw err + } + await new Promise(resolve => setTimeout(resolve, timeout)) + // eslint-disable-next-line no-continue + continue + } throwIfAborted(signal) try { @@ -366,7 +388,7 @@ class HTTPCommunicationQueue { }).abortOn(signal), } } catch (err) { - if (!await this.#shouldRetry(err)) throw err + if (!await this.#shouldRetry(err, chunkRetryIterator)) throw err } } } diff --git a/packages/@uppy/aws-s3-multipart/src/index.test.js b/packages/@uppy/aws-s3-multipart/src/index.test.js index e77afd346c..33c94eedd6 100644 --- a/packages/@uppy/aws-s3-multipart/src/index.test.js +++ b/packages/@uppy/aws-s3-multipart/src/index.test.js @@ -390,7 +390,7 @@ describe('AwsS3Multipart', () => { await expect(core.upload()).rejects.toEqual({ source: { status: 500 } }) - expect(awsS3Multipart.opts.uploadPartBytes.mock.calls.length).toEqual(2) + expect(awsS3Multipart.opts.uploadPartBytes.mock.calls.length).toEqual(3) expect(mock.mock.calls.length).toEqual(1) }) }) From 2f691acd3f8449f182168e084797656ba22f011a Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 28 Sep 2023 15:47:52 +0100 Subject: [PATCH 2/9] meta: add Prettier (#4707) JS files are ignored for now because we want to migrate them to TS anyway. MD files are also ignored to minimize the diff. ESLint is run twice twice on TS files in case it conflicts with Prettier. --- .eslintrc.js | 19 ++++++++++++++++--- .prettierignore | 7 +++++++ .prettierrc.js | 14 ++++++++++++++ e2e/clients/index.html | 2 +- examples/transloadit/index.html | 2 +- package.json | 9 ++++++++- yarn.lock | 22 ++++++++++++++++++++++ 7 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc.js diff --git a/.eslintrc.js b/.eslintrc.js index 84b9bee40b..0b6c416759 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -8,7 +8,7 @@ const svgPresentationAttributes = [ module.exports = { root: true, - extends: ['transloadit'], + extends: ['transloadit', 'prettier'], env: { es6: true, jest: true, @@ -63,7 +63,6 @@ module.exports = { // rules we want to enforce 'array-callback-return': 'error', 'func-names': 'error', - 'implicit-arrow-linebreak': 'error', 'import/no-dynamic-require': 'error', 'import/no-extraneous-dependencies': 'error', 'max-len': 'error', @@ -142,6 +141,7 @@ module.exports = { { files: [ '*.jsx', + '*.tsx', 'packages/@uppy/react-native/**/*.js', ], parser: 'espree', @@ -358,6 +358,7 @@ module.exports = { 'test/**/*.ts', '*.test.js', '*.test-d.ts', + '*.test-d.tsx', 'postcss.config.js', '.eslintrc.js', 'private/**/*.js', @@ -474,11 +475,23 @@ module.exports = { }, }, { - files: ['**/react/*.md/*.js', '**/react.md/*.js', '**/react-*.md/*.js'], + files: ['**/react/*.md/*.js', '**/react.md/*.js', '**/react-*.md/*.js', '**/react/**/*.test-d.tsx'], settings: { react: { pragma: 'React' }, }, }, + { + files: ['**/react/**/*.test-d.tsx'], + rules: { + 'import/extensions': 'off', + 'import/no-useless-path-segments': 'off', + 'no-alert': 'off', + 'no-inner-declarations': 'off', + 'no-lone-blocks': 'off', + 'no-unused-expressions': 'off', + 'no-unused-vars': 'off', + }, + }, { files: ['e2e/**/*.ts'], extends: ['plugin:cypress/recommended'], diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000000..cfebd2d979 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,7 @@ +node_modules/ +*.js +*.jsx +*.cjs +*.mjs +*.md +*.lock diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000000..df02f7bc1f --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,14 @@ +module.exports = { + proseWrap: 'always', + singleQuote: true, + trailingComma: 'all', + semi: false, + overrides: [ + { + files: 'packages/@uppy/angular/**', + options: { + semi: true, + }, + }, + ], +} diff --git a/e2e/clients/index.html b/e2e/clients/index.html index 05311bd03d..398cc569ae 100644 --- a/e2e/clients/index.html +++ b/e2e/clients/index.html @@ -18,6 +18,6 @@

Test apps

  • dashboard-ui
  • dashboard-vue
  • - diff --git a/examples/transloadit/index.html b/examples/transloadit/index.html index 22c8045904..e695fda9c6 100644 --- a/examples/transloadit/index.html +++ b/examples/transloadit/index.html @@ -56,7 +56,7 @@

    Form

    -
    +

    +

    - + -
    +

    Form with inline Dashboard

    -

    - You can also use the Dashboard UI inside a plain old HTML form. -

    -
    +

    You can also use the Dashboard UI inside a plain old HTML form.

    +

    leave a message

    -

    -

    @@ -91,39 +119,47 @@

    Form with inline Dashboard

    - +

    - +
    -
    +

    Inline Dashboard

    - The robodog.dashboard API allows you to embed a Dashboard at any location. Users can continuously upload files through this UI, so please make sure this fits your use case! + The robodog.dashboard API allows you to embed a Dashboard + at any location. Users can continuously upload files through this UI, so + please make sure this fits your use case!

    -
    +

    Dashboard Modal

    - This API is a one-shot upload UI using a modal overlay. Call the function and receive a listen to an event with upload results ✌️ + This API is a one-shot upload UI using a modal overlay. Call the + function and receive a listen to an event with upload results ✌️

    uppy.upload()

    +

    An <input type=file> backed by uppy.upload():

    - An <input type=file> backed by uppy.upload(): -

    -

    - +

    -
    
    +        
    
             
    
           
    diff --git a/examples/uppy-with-companion/client/index.html b/examples/uppy-with-companion/client/index.html index 5206c7c291..f21eeeaeec 100644 --- a/examples/uppy-with-companion/client/index.html +++ b/examples/uppy-with-companion/client/index.html @@ -1,21 +1,36 @@ - + - - - + + + - - - - - + + + + - - - + + + + diff --git a/packages/@uppy/angular/.eslintrc.json b/packages/@uppy/angular/.eslintrc.json index 2304954633..54e1cd9a19 100644 --- a/packages/@uppy/angular/.eslintrc.json +++ b/packages/@uppy/angular/.eslintrc.json @@ -1,12 +1,8 @@ { - "ignorePatterns": [ - "projects/**/*" - ], + "ignorePatterns": ["projects/**/*"], "overrides": [ { - "files": [ - "*.ts" - ], + "files": ["*.ts"], "extends": [ "eslint:recommended", "plugin:@typescript-eslint/recommended", @@ -14,6 +10,7 @@ "plugin:@angular-eslint/template/process-inline-templates" ], "rules": { + // eslint-disable-line import/newline-after-import "@angular-eslint/directive-selector": [ "error", { @@ -37,9 +34,7 @@ } }, { - "files": [ - "*.html" - ], + "files": ["*.html"], "extends": [ "plugin:@angular-eslint/template/recommended", "plugin:@angular-eslint/template/accessibility" diff --git a/packages/@uppy/angular/angular.json b/packages/@uppy/angular/angular.json index b0febadbde..3aa602c2de 100644 --- a/packages/@uppy/angular/angular.json +++ b/packages/@uppy/angular/angular.json @@ -28,10 +28,7 @@ "builder": "@angular-devkit/build-angular:karma", "options": { "tsConfig": "projects/uppy/angular/tsconfig.spec.json", - "polyfills": [ - "zone.js", - "zone.js/testing" - ] + "polyfills": ["zone.js", "zone.js/testing"] } } } diff --git a/packages/@uppy/angular/projects/uppy/angular/.eslintrc.json b/packages/@uppy/angular/projects/uppy/angular/.eslintrc.json index 2ab1305077..67ef3094ec 100644 --- a/packages/@uppy/angular/projects/uppy/angular/.eslintrc.json +++ b/packages/@uppy/angular/projects/uppy/angular/.eslintrc.json @@ -1,13 +1,9 @@ { "extends": "../../../.eslintrc.json", - "ignorePatterns": [ - "!**/*" - ], + "ignorePatterns": ["!**/*"], "overrides": [ { - "files": [ - "*.ts" - ], + "files": ["*.ts"], "parserOptions": { "project": [ "packages/@uppy/angular/projects/angular/tsconfig.lib.json", @@ -43,9 +39,7 @@ } }, { - "files": [ - "*.html" - ], + "files": ["*.html"], "rules": {} } ] diff --git a/packages/@uppy/angular/projects/uppy/angular/ng-package.json b/packages/@uppy/angular/projects/uppy/angular/ng-package.json index 5d14d4e69f..fab7346366 100644 --- a/packages/@uppy/angular/projects/uppy/angular/ng-package.json +++ b/packages/@uppy/angular/projects/uppy/angular/ng-package.json @@ -4,4 +4,4 @@ "lib": { "entryFile": "src/public-api.ts" } -} \ No newline at end of file +} diff --git a/packages/@uppy/angular/projects/uppy/angular/src/public-api.ts b/packages/@uppy/angular/projects/uppy/angular/src/public-api.ts index 4351587147..8a4b78bf92 100644 --- a/packages/@uppy/angular/projects/uppy/angular/src/public-api.ts +++ b/packages/@uppy/angular/projects/uppy/angular/src/public-api.ts @@ -2,13 +2,13 @@ * Public API Surface of @uppy/angular */ -export { UppyAngularDashboardModule } from './lib/components/dashboard/dashboard.module' -export { UppyAngularDashboardModalModule } from './lib/components/dashboard-modal/dashboard-modal.module' -export { UppyAngularProgressBarModule } from './lib/components/progress-bar/progress-bar.module' -export { UppyAngularStatusBarModule } from './lib/components/status-bar/status-bar.module' -export { UppyAngularDragDropModule } from './lib/components/drag-drop/drag-drop.module' -export { StatusBarComponent } from './lib/components/status-bar/status-bar.component' -export { ProgressBarComponent } from './lib/components/progress-bar/progress-bar.component' -export { DragDropComponent } from './lib/components/drag-drop/drag-drop.component' -export { DashboardComponent } from './lib/components/dashboard/dashboard.component' -export { DashboardModalComponent } from './lib/components/dashboard-modal/dashboard-modal.component' +export { UppyAngularDashboardModule } from './lib/components/dashboard/dashboard.module'; +export { UppyAngularDashboardModalModule } from './lib/components/dashboard-modal/dashboard-modal.module'; +export { UppyAngularProgressBarModule } from './lib/components/progress-bar/progress-bar.module'; +export { UppyAngularStatusBarModule } from './lib/components/status-bar/status-bar.module'; +export { UppyAngularDragDropModule } from './lib/components/drag-drop/drag-drop.module'; +export { StatusBarComponent } from './lib/components/status-bar/status-bar.component'; +export { ProgressBarComponent } from './lib/components/progress-bar/progress-bar.component'; +export { DragDropComponent } from './lib/components/drag-drop/drag-drop.component'; +export { DashboardComponent } from './lib/components/dashboard/dashboard.component'; +export { DashboardModalComponent } from './lib/components/dashboard-modal/dashboard-modal.component'; diff --git a/packages/@uppy/angular/projects/uppy/angular/tsconfig.lib.json b/packages/@uppy/angular/projects/uppy/angular/tsconfig.lib.json index 879250df42..f73c766cf7 100644 --- a/packages/@uppy/angular/projects/uppy/angular/tsconfig.lib.json +++ b/packages/@uppy/angular/projects/uppy/angular/tsconfig.lib.json @@ -8,7 +8,5 @@ "inlineSources": true, "types": [] }, - "exclude": [ - "**/*.spec.ts" - ] + "exclude": ["**/*.spec.ts"] } diff --git a/packages/@uppy/angular/projects/uppy/angular/tsconfig.spec.json b/packages/@uppy/angular/projects/uppy/angular/tsconfig.spec.json index 80f875ef27..3a8a02edf6 100644 --- a/packages/@uppy/angular/projects/uppy/angular/tsconfig.spec.json +++ b/packages/@uppy/angular/projects/uppy/angular/tsconfig.spec.json @@ -3,12 +3,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../../../out-tsc/spec", - "types": [ - "jasmine" - ] + "types": ["jasmine"] }, - "include": [ - "**/*.spec.ts", - "**/*.d.ts" - ] + "include": ["**/*.spec.ts", "**/*.d.ts"] } diff --git a/packages/@uppy/angular/tsconfig.json b/packages/@uppy/angular/tsconfig.json index 8ee11a4611..ccfa195bcb 100644 --- a/packages/@uppy/angular/tsconfig.json +++ b/packages/@uppy/angular/tsconfig.json @@ -3,9 +3,7 @@ "compileOnSave": false, "compilerOptions": { "paths": { - "@uppy/angular": [ - "dist/uppy/angular" - ] + "@uppy/angular": ["dist/uppy/angular"] }, "baseUrl": "./", "outDir": "./dist/out-tsc", @@ -24,10 +22,7 @@ "target": "ES2022", "module": "ES2022", "useDefineForClassFields": false, - "lib": [ - "ES2022", - "dom" - ] + "lib": ["ES2022", "dom"] }, "angularCompilerOptions": { "enableI18nLegacyMessageIdFormat": false, diff --git a/packages/@uppy/audio/src/style.scss b/packages/@uppy/audio/src/style.scss index e5f9ed6a64..692a31088f 100644 --- a/packages/@uppy/audio/src/style.scss +++ b/packages/@uppy/audio/src/style.scss @@ -59,14 +59,18 @@ display: block; font-size: 16px; line-height: 1.2; - padding: .4em 1em .3em .4em; + padding: 0.4em 1em 0.3em 0.4em; width: 100%; max-width: 90%; border: 1px solid $gray-600; background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23757575%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E'); background-repeat: no-repeat; - background-position: right .4em top 50%, 0 0; - background-size: .65em auto, 100%; + background-position: + right 0.4em top 50%, + 0 0; + background-size: + 0.65em auto, + 100%; margin: auto; margin-bottom: 10px; white-space: nowrap; @@ -78,9 +82,9 @@ } } - .uppy-Audio-audioSource-select::-ms-expand { - display: none; - } +.uppy-Audio-audioSource-select::-ms-expand { + display: none; +} .uppy-Audio-buttonContainer { width: 50%; @@ -120,7 +124,7 @@ background-color: darken($red, 5%); } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { @include blue-border-focus--dark; } } @@ -187,7 +191,7 @@ text-align: center; color: $gray-800; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; } } diff --git a/packages/@uppy/aws-s3-multipart/types/chunk.d.ts b/packages/@uppy/aws-s3-multipart/types/chunk.d.ts index 2a9980d33b..a01c6b5289 100644 --- a/packages/@uppy/aws-s3-multipart/types/chunk.d.ts +++ b/packages/@uppy/aws-s3-multipart/types/chunk.d.ts @@ -1,7 +1,7 @@ export interface Chunk { - getData: () => Blob - onProgress: (ev: ProgressEvent) => void - onComplete: (etag: string) => void - shouldUseMultipart: boolean - setAsUploaded?: () => void + getData: () => Blob + onProgress: (ev: ProgressEvent) => void + onComplete: (etag: string) => void + shouldUseMultipart: boolean + setAsUploaded?: () => void } diff --git a/packages/@uppy/aws-s3-multipart/types/index.d.ts b/packages/@uppy/aws-s3-multipart/types/index.d.ts index ef53079b9f..40adc5b8ea 100644 --- a/packages/@uppy/aws-s3-multipart/types/index.d.ts +++ b/packages/@uppy/aws-s3-multipart/types/index.d.ts @@ -2,19 +2,21 @@ import type { BasePlugin, PluginOptions, UppyFile } from '@uppy/core' type MaybePromise = T | Promise -export type AwsS3UploadParameters = { - method: 'POST' - url: string - fields: Record - expires?: number - headers?: Record -} | { - method?: 'PUT' - url: string - fields?: Record - expires?: number - headers?: Record -} +export type AwsS3UploadParameters = + | { + method: 'POST' + url: string + fields: Record + expires?: number + headers?: Record + } + | { + method?: 'PUT' + url: string + fields?: Record + expires?: number + headers?: Record + } export interface AwsS3Part { PartNumber?: number @@ -44,88 +46,101 @@ type AWSS3NonMultipartWithCompanionMandatory = { } type AWSS3NonMultipartWithoutCompanionMandatory = { - getUploadParameters: ( - file: UppyFile - ) => MaybePromise + getUploadParameters: (file: UppyFile) => MaybePromise } type AWSS3NonMultipartWithCompanion = AWSS3WithCompanion & - AWSS3NonMultipartWithCompanionMandatory & - { - shouldUseMultipart: false - createMultipartUpload?: never - listParts?: never - signPart?: never - abortMultipartUpload?: never - completeMultipartUpload?: never - } + AWSS3NonMultipartWithCompanionMandatory & { + shouldUseMultipart: false + createMultipartUpload?: never + listParts?: never + signPart?: never + abortMultipartUpload?: never + completeMultipartUpload?: never + } type AWSS3NonMultipartWithoutCompanion = AWSS3WithoutCompanion & - AWSS3NonMultipartWithoutCompanionMandatory & - { - shouldUseMultipart: false - createMultipartUpload?: never - listParts?: never - signPart?: never - abortMultipartUpload?: never - completeMultipartUpload?: never - } + AWSS3NonMultipartWithoutCompanionMandatory & { + shouldUseMultipart: false + createMultipartUpload?: never + listParts?: never + signPart?: never + abortMultipartUpload?: never + completeMultipartUpload?: never + } type AWSS3MultipartWithoutCompanionMandatory = { getChunkSize?: (file: UppyFile) => number createMultipartUpload: ( - file: UppyFile + file: UppyFile, ) => MaybePromise<{ uploadId: string; key: string }> listParts: ( file: UppyFile, - opts: { uploadId: string; key: string; signal: AbortSignal } + opts: { uploadId: string; key: string; signal: AbortSignal }, ) => MaybePromise abortMultipartUpload: ( file: UppyFile, - opts: { uploadId: string; key: string; signal: AbortSignal } + opts: { uploadId: string; key: string; signal: AbortSignal }, ) => MaybePromise completeMultipartUpload: ( file: UppyFile, - opts: { uploadId: string; key: string; parts: AwsS3Part[]; signal: AbortSignal } + opts: { + uploadId: string + key: string + parts: AwsS3Part[] + signal: AbortSignal + }, ) => MaybePromise<{ location?: string }> -} & ({ - signPart: ( - file: UppyFile, - opts: { uploadId: string; key: string; partNumber: number; body: Blob; signal: AbortSignal } - ) => MaybePromise -} | { - /** @deprecated Use signPart instead */ - prepareUploadParts: ( - file: UppyFile, - partData: { uploadId: string; key: string; parts: [{ number: number, chunk: Blob }] } - ) => MaybePromise<{ presignedUrls: Record, headers?: Record> }> -}) +} & ( + | { + signPart: ( + file: UppyFile, + opts: { + uploadId: string + key: string + partNumber: number + body: Blob + signal: AbortSignal + }, + ) => MaybePromise + } + | { + /** @deprecated Use signPart instead */ + prepareUploadParts: ( + file: UppyFile, + partData: { + uploadId: string + key: string + parts: [{ number: number; chunk: Blob }] + }, + ) => MaybePromise<{ + presignedUrls: Record + headers?: Record> + }> + } +) type AWSS3MultipartWithoutCompanion = AWSS3WithoutCompanion & - AWSS3MultipartWithoutCompanionMandatory & - { - shouldUseMultipart?: true - getUploadParameters?: never - } + AWSS3MultipartWithoutCompanionMandatory & { + shouldUseMultipart?: true + getUploadParameters?: never + } type AWSS3MultipartWithCompanion = AWSS3WithCompanion & - Partial & - { - shouldUseMultipart?: true - getUploadParameters?: never - } + Partial & { + shouldUseMultipart?: true + getUploadParameters?: never + } type AWSS3MaybeMultipartWithCompanion = AWSS3WithCompanion & - Partial & - AWSS3NonMultipartWithCompanionMandatory & - { - shouldUseMultipart: ((file: UppyFile) => boolean) - } + Partial & + AWSS3NonMultipartWithCompanionMandatory & { + shouldUseMultipart: (file: UppyFile) => boolean + } type AWSS3MaybeMultipartWithoutCompanion = AWSS3WithoutCompanion & - AWSS3MultipartWithoutCompanionMandatory & - AWSS3NonMultipartWithoutCompanionMandatory & - { - shouldUseMultipart: ((file: UppyFile) => boolean) - } + AWSS3MultipartWithoutCompanionMandatory & + AWSS3NonMultipartWithoutCompanionMandatory & { + shouldUseMultipart: (file: UppyFile) => boolean + } type AWSS3WithCompanion = { companionUrl: string @@ -137,24 +152,27 @@ type AWSS3WithoutCompanion = { companionUrl?: never companionHeaders?: never companionCookiesRule?: never - getTemporarySecurityCredentials?: (options?: {signal?: AbortSignal}) => MaybePromise + getTemporarySecurityCredentials?: (options?: { + signal?: AbortSignal + }) => MaybePromise } interface _AwsS3MultipartOptions extends PluginOptions { - allowedMetaFields?: string[] | null - limit?: number - retryDelays?: number[] | null + allowedMetaFields?: string[] | null + limit?: number + retryDelays?: number[] | null } -export type AwsS3MultipartOptions = _AwsS3MultipartOptions & (AWSS3NonMultipartWithCompanion | - AWSS3NonMultipartWithoutCompanion | - AWSS3MultipartWithCompanion | - AWSS3MultipartWithoutCompanion | - AWSS3MaybeMultipartWithCompanion | - AWSS3MaybeMultipartWithoutCompanion) +export type AwsS3MultipartOptions = _AwsS3MultipartOptions & + ( + | AWSS3NonMultipartWithCompanion + | AWSS3NonMultipartWithoutCompanion + | AWSS3MultipartWithCompanion + | AWSS3MultipartWithoutCompanion + | AWSS3MaybeMultipartWithCompanion + | AWSS3MaybeMultipartWithoutCompanion + ) -declare class AwsS3Multipart extends BasePlugin< - AwsS3MultipartOptions -> {} +declare class AwsS3Multipart extends BasePlugin {} export default AwsS3Multipart diff --git a/packages/@uppy/aws-s3-multipart/types/index.test-d.ts b/packages/@uppy/aws-s3-multipart/types/index.test-d.ts index 4ccadd71a8..1287eca958 100644 --- a/packages/@uppy/aws-s3-multipart/types/index.test-d.ts +++ b/packages/@uppy/aws-s3-multipart/types/index.test-d.ts @@ -8,17 +8,17 @@ import type { AwsS3Part } from '..' const uppy = new Uppy() uppy.use(AwsS3Multipart, { shouldUseMultipart: true, - createMultipartUpload (file) { + createMultipartUpload(file) { expectType(file) return { uploadId: '', key: '' } }, - listParts (file, opts) { + listParts(file, opts) { expectType(file) expectType(opts.uploadId) expectType(opts.key) return [] }, - signPart (file, opts) { + signPart(file, opts) { expectType(file) expectType(opts.uploadId) expectType(opts.key) @@ -26,12 +26,12 @@ import type { AwsS3Part } from '..' expectType(opts.signal) return { url: '' } }, - abortMultipartUpload (file, opts) { + abortMultipartUpload(file, opts) { expectType(file) expectType(opts.uploadId) expectType(opts.key) }, - completeMultipartUpload (file, opts) { + completeMultipartUpload(file, opts) { expectType(file) expectType(opts.uploadId) expectType(opts.key) @@ -44,7 +44,15 @@ import type { AwsS3Part } from '..' { const uppy = new Uppy() expectError(uppy.use(AwsS3Multipart, { companionUrl: '', getChunkSize: 100 })) - expectError(uppy.use(AwsS3Multipart, { companionUrl: '', getChunkSize: () => 'not a number' })) + expectError( + uppy.use(AwsS3Multipart, { + companionUrl: '', + getChunkSize: () => 'not a number', + }), + ) uppy.use(AwsS3Multipart, { companionUrl: '', getChunkSize: () => 100 }) - uppy.use(AwsS3Multipart, { companionUrl: '', getChunkSize: (file) => file.size }) + uppy.use(AwsS3Multipart, { + companionUrl: '', + getChunkSize: (file) => file.size, + }) } diff --git a/packages/@uppy/aws-s3/types/index.d.ts b/packages/@uppy/aws-s3/types/index.d.ts index 04b1104140..7a146aec15 100644 --- a/packages/@uppy/aws-s3/types/index.d.ts +++ b/packages/@uppy/aws-s3/types/index.d.ts @@ -3,34 +3,36 @@ import type { BasePlugin, Locale, PluginOptions, UppyFile } from '@uppy/core' type MaybePromise = T | Promise -export type AwsS3UploadParameters = { - method?: 'POST' - url: string - fields?: Record - expires?: number - headers?: Record -} | { - method: 'PUT' - url: string - fields?: Record - expires?: number - headers?: Record -} +export type AwsS3UploadParameters = + | { + method?: 'POST' + url: string + fields?: Record + expires?: number + headers?: Record + } + | { + method: 'PUT' + url: string + fields?: Record + expires?: number + headers?: Record + } interface LegacyAwsS3Options extends PluginOptions { - shouldUseMultipart?: never - companionUrl?: string | null - companionHeaders?: Record - allowedMetaFields?: Array | null - getUploadParameters?: (file: UppyFile) => MaybePromise - limit?: number - /** @deprecated this option will not be supported in future versions of this plugin */ - getResponseData?: (responseText: string, response: XMLHttpRequest) => void - locale?: Locale, - timeout?: number - } + shouldUseMultipart?: never + companionUrl?: string | null + companionHeaders?: Record + allowedMetaFields?: Array | null + getUploadParameters?: (file: UppyFile) => MaybePromise + limit?: number + /** @deprecated this option will not be supported in future versions of this plugin */ + getResponseData?: (responseText: string, response: XMLHttpRequest) => void + locale?: Locale + timeout?: number +} -export type AwsS3Options = LegacyAwsS3Options | AwsS3MultipartOptions; +export type AwsS3Options = LegacyAwsS3Options | AwsS3MultipartOptions declare class AwsS3 extends BasePlugin {} diff --git a/packages/@uppy/aws-s3/types/index.test-d.ts b/packages/@uppy/aws-s3/types/index.test-d.ts index 0e922b81bc..02f244f0e3 100644 --- a/packages/@uppy/aws-s3/types/index.test-d.ts +++ b/packages/@uppy/aws-s3/types/index.test-d.ts @@ -6,49 +6,53 @@ import AwsS3 from '..' { const uppy = new Uppy() uppy.use(AwsS3, { - getUploadParameters (file) { + getUploadParameters(file) { expectType(file) return { method: 'POST', url: '' } }, }) - expectError(uppy.use(AwsS3, { - shouldUseMultipart: false, - getUploadParameters (file) { - expectType(file) - return { method: 'POST', url: '' } - }, - })) + expectError( + uppy.use(AwsS3, { + shouldUseMultipart: false, + getUploadParameters(file) { + expectType(file) + return { method: 'POST', url: '' } + }, + }), + ) uppy.use(AwsS3, { shouldUseMultipart: false, - getUploadParameters (file) { + getUploadParameters(file) { expectType(file) return { method: 'POST', url: '', fields: {} } }, }) - expectError(uppy.use(AwsS3, { - shouldUseMultipart: true, - getUploadParameters (file) { - expectType(file) - return { method: 'PUT', url: '' } - }, - })) + expectError( + uppy.use(AwsS3, { + shouldUseMultipart: true, + getUploadParameters(file) { + expectType(file) + return { method: 'PUT', url: '' } + }, + }), + ) uppy.use(AwsS3, { shouldUseMultipart: () => Math.random() > 0.5, - getUploadParameters (file) { + getUploadParameters(file) { expectType(file) return { method: 'PUT', url: '' } }, - createMultipartUpload (file) { + createMultipartUpload(file) { expectType(file) return { uploadId: '', key: '' } }, - listParts (file, opts) { + listParts(file, opts) { expectType(file) expectType(opts.uploadId) expectType(opts.key) return [] }, - signPart (file, opts) { + signPart(file, opts) { expectType(file) expectType(opts.uploadId) expectType(opts.key) @@ -56,12 +60,12 @@ import AwsS3 from '..' expectType(opts.signal) return { url: '' } }, - abortMultipartUpload (file, opts) { + abortMultipartUpload(file, opts) { expectType(file) expectType(opts.uploadId) expectType(opts.key) }, - completeMultipartUpload (file, opts) { + completeMultipartUpload(file, opts) { expectType(file) expectType(opts.uploadId) expectType(opts.key) diff --git a/packages/@uppy/box/types/index.d.ts b/packages/@uppy/box/types/index.d.ts index e081c786f9..4700dcf8cc 100644 --- a/packages/@uppy/box/types/index.d.ts +++ b/packages/@uppy/box/types/index.d.ts @@ -1,10 +1,13 @@ import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core' -import type { PublicProviderOptions, TokenStorage } from '@uppy/companion-client' +import type { + PublicProviderOptions, + TokenStorage, +} from '@uppy/companion-client' interface BoxOptions extends UIPluginOptions, PublicProviderOptions { - target?: PluginTarget - title?: string - storage?: TokenStorage + target?: PluginTarget + title?: string + storage?: TokenStorage } declare class Box extends UIPlugin {} diff --git a/packages/@uppy/companion-client/types/index.d.ts b/packages/@uppy/companion-client/types/index.d.ts index 8cea2392d7..6f7c78c39a 100644 --- a/packages/@uppy/companion-client/types/index.d.ts +++ b/packages/@uppy/companion-client/types/index.d.ts @@ -19,31 +19,47 @@ export interface RequestClientOptions { } type RequestOptions = { - skipPostResponse?: boolean, - signal?: AbortSignal, + skipPostResponse?: boolean + signal?: AbortSignal } export class RequestClient { - constructor (uppy: Uppy, opts: RequestClientOptions) + constructor(uppy: Uppy, opts: RequestClientOptions) readonly hostname: string setCompanionHeaders(headers: CompanionHeaders): void - get (path: string, options?: RequestOptions): Promise + get(path: string, options?: RequestOptions): Promise /** @deprecated use option bag instead */ - get (path: string, skipPostResponse: boolean): Promise + get(path: string, skipPostResponse: boolean): Promise - post (path: string, data: Record, options?: RequestOptions): Promise + post( + path: string, + data: Record, + options?: RequestOptions, + ): Promise /** @deprecated use option bag instead */ - post (path: string, data: Record, skipPostResponse: boolean): Promise - - delete (path: string, data?: Record, options?: RequestOptions): Promise + post( + path: string, + data: Record, + skipPostResponse: boolean, + ): Promise + + delete( + path: string, + data?: Record, + options?: RequestOptions, + ): Promise /** @deprecated use option bag instead */ - delete (path: string, data: Record, skipPostResponse: boolean): Promise + delete( + path: string, + data: Record, + skipPostResponse: boolean, + ): Promise } /** @@ -64,19 +80,23 @@ export interface ProviderOptions extends PublicProviderOptions { } export class Provider extends RequestClient { - constructor (uppy: Uppy, opts: ProviderOptions) + constructor(uppy: Uppy, opts: ProviderOptions) - checkAuth (): Promise + checkAuth(): Promise - authUrl (): string + authUrl(): string - fileUrl (id: string): string + fileUrl(id: string): string - list (directory: string): Promise + list(directory: string): Promise - logout (redirect?: string): Promise + logout(redirect?: string): Promise - static initPlugin (plugin: unknown, opts: Record, defaultOpts?: Record): void + static initPlugin( + plugin: unknown, + opts: Record, + defaultOpts?: Record, + ): void } export interface SocketOptions { @@ -87,17 +107,17 @@ export interface SocketOptions { export class Socket { readonly isOpen: boolean - constructor (opts: SocketOptions) + constructor(opts: SocketOptions) - open (): void + open(): void - close (): void + close(): void - send (action: string, payload: unknown): void + send(action: string, payload: unknown): void - on (action: string, handler: (param: any) => void): void + on(action: string, handler: (param: any) => void): void - once (action: string, handler: (param: any) => void): void + once(action: string, handler: (param: any) => void): void - emit (action: string, payload: (param: any) => void): void + emit(action: string, payload: (param: any) => void): void } diff --git a/packages/@uppy/companion/infra/kube/companion/companion-kube.yaml b/packages/@uppy/companion/infra/kube/companion/companion-kube.yaml index d465ccd8da..05e13b8f67 100644 --- a/packages/@uppy/companion/infra/kube/companion/companion-kube.yaml +++ b/packages/@uppy/companion/infra/kube/companion/companion-kube.yaml @@ -3,13 +3,13 @@ kind: Service metadata: name: companion namespace: companion - labels: + labels: app: companion spec: ports: - - port: 80 - targetPort: 3020 - protocol: TCP + - port: 80 + targetPort: 3020 + protocol: TCP selector: app: companion --- @@ -25,32 +25,32 @@ spec: replicas: 2 updateStrategy: type: RollingUpdate - serviceName: "companion" + serviceName: 'companion' template: metadata: labels: app: companion spec: containers: - - image: docker.io/transloadit/companion:latest - imagePullPolicy: Always - name: companion - envFrom: - - secretRef: - name: companion-env - ports: - - containerPort: 3020 - volumeMounts: - - name: companion-data - mountPath: /mnt/companion-data + - image: docker.io/transloadit/companion:latest + imagePullPolicy: Always + name: companion + envFrom: + - secretRef: + name: companion-env + ports: + - containerPort: 3020 + volumeMounts: + - name: companion-data + mountPath: /mnt/companion-data volumeClaimTemplates: - - metadata: - name: companion-data - spec: - accessModes: [ "ReadWriteOnce" ] - resources: - requests: - storage: 10Gi + - metadata: + name: companion-data + spec: + accessModes: ['ReadWriteOnce'] + resources: + requests: + storage: 10Gi --- apiVersion: extensions/v1beta1 kind: Ingress @@ -58,10 +58,10 @@ metadata: name: companion namespace: companion annotations: - kubernetes.io/tls-acme: "true" - kubernetes.io/ingress.class: "nginx" - certmanager.k8s.io/cluster-issuer: "letsencrypt-prod" - certmanager.k8s.io/acme-http01-edit-in-place: "true" + kubernetes.io/tls-acme: 'true' + kubernetes.io/ingress.class: 'nginx' + certmanager.k8s.io/cluster-issuer: 'letsencrypt-prod' + certmanager.k8s.io/acme-http01-edit-in-place: 'true' spec: tls: - secretName: server-tls @@ -69,22 +69,22 @@ spec: - companion.uppy.io - secretName: uppy-tls hosts: - - server.uppy.io + - server.uppy.io rules: - - host: companion.uppy.io - http: - paths: - - path: / - backend: - serviceName: companion - servicePort: 80 - - host: server.uppy.io - http: - paths: - - path: / - backend: - serviceName: companion - servicePort: 80 + - host: companion.uppy.io + http: + paths: + - path: / + backend: + serviceName: companion + servicePort: 80 + - host: server.uppy.io + http: + paths: + - path: / + backend: + serviceName: companion + servicePort: 80 --- apiVersion: autoscaling/v1 kind: HorizontalPodAutoscaler @@ -98,4 +98,4 @@ spec: name: companion minReplicas: 1 maxReplicas: 5 - targetCPUUtilizationPercentage: 80 \ No newline at end of file + targetCPUUtilizationPercentage: 80 diff --git a/packages/@uppy/companion/nodemon.json b/packages/@uppy/companion/nodemon.json index 856a794505..42012c5513 100644 --- a/packages/@uppy/companion/nodemon.json +++ b/packages/@uppy/companion/nodemon.json @@ -1,13 +1,13 @@ { - "restartable": "rs", - "verbose": true, - "env": { - "NODE_ENV": "development", - "DEBUG": "app:*", - "DEBUG_COLORS": true - }, - "debug": true, - "watch": ["/app/", "/src/"], - "ext": "js dust html ejs css scss rb json htpasswd", - "exec": "node /app/lib/standalone/start-server.js" -} \ No newline at end of file + "restartable": "rs", + "verbose": true, + "env": { + "NODE_ENV": "development", + "DEBUG": "app:*", + "DEBUG_COLORS": true + }, + "debug": true, + "watch": ["/app/", "/src/"], + "ext": "js dust html ejs css scss rb json htpasswd", + "exec": "node /app/lib/standalone/start-server.js" +} diff --git a/packages/@uppy/companion/src/server/provider/error.d.ts b/packages/@uppy/companion/src/server/provider/error.d.ts index 29ce604bcf..e6aaed6288 100644 --- a/packages/@uppy/companion/src/server/provider/error.d.ts +++ b/packages/@uppy/companion/src/server/provider/error.d.ts @@ -11,6 +11,9 @@ export class ProviderAuthError extends ProviderApiError { constructor() } -export function errorToResponse(anyError: Error): { code: number, message: string } +export function errorToResponse(anyError: Error): { + code: number + message: string +} export function respondWithError(anyError: Error, res: any): boolean diff --git a/packages/@uppy/companion/tsconfig.json b/packages/@uppy/companion/tsconfig.json index cb42df19a1..ac532cc3d4 100644 --- a/packages/@uppy/companion/tsconfig.json +++ b/packages/@uppy/companion/tsconfig.json @@ -11,7 +11,5 @@ "checkJs": true, "noEmitOnError": true }, - "include": [ - "src/**/*" - ] + "include": ["src/**/*"] } diff --git a/packages/@uppy/compressor/types/index.d.ts b/packages/@uppy/compressor/types/index.d.ts index 8137a08010..5562d4badc 100644 --- a/packages/@uppy/compressor/types/index.d.ts +++ b/packages/@uppy/compressor/types/index.d.ts @@ -8,7 +8,9 @@ export interface CompressorOptions extends PluginOptions { locale?: CompressorLocale } -export type CompressorCompleteCallback = (files: UppyFile[]) => void; +export type CompressorCompleteCallback = ( + files: UppyFile[], +) => void declare module '@uppy/core' { export interface UppyEventMap { diff --git a/packages/@uppy/core/src/_common.scss b/packages/@uppy/core/src/_common.scss index 563e1eca66..1dcea0cc3f 100644 --- a/packages/@uppy/core/src/_common.scss +++ b/packages/@uppy/core/src/_common.scss @@ -15,8 +15,8 @@ // One selector uses the dir attribute declared by the page. If that does not exist, Uppy adds a // fallback dir attribute on the root element itself, and we need a second selector to match that. -[dir="rtl"] .uppy-Root, -.uppy-Root[dir="rtl"] { +[dir='rtl'] .uppy-Root, +.uppy-Root[dir='rtl'] { text-align: right; } @@ -40,7 +40,7 @@ line-height: 1; } -[dir="rtl"] .uppy-u-reset { +[dir='rtl'] .uppy-u-reset { text-align: right; } @@ -65,13 +65,13 @@ box-shadow: 0 0 0 3px rgba($blue, 0.15); } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; background-color: $gray-800; border-color: $gray-800; } - [data-uppy-theme="dark"] &:focus { + [data-uppy-theme='dark'] &:focus { border-color: $gray-700; box-shadow: none; } @@ -107,7 +107,9 @@ user-select: none; // Override right-to-left variant of the uppy-u-reset class - [dir="rtl"] & { text-align: center; } + [dir='rtl'] & { + text-align: center; + } } .uppy-c-btn:not(:disabled):not(.disabled) { @@ -138,7 +140,7 @@ padding: 13px 22px; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; @include blue-border-focus--dark; @@ -166,13 +168,13 @@ padding: 13px 18px; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; @include blue-border-focus--dark; } - [data-uppy-theme="dark"] &:hover { + [data-uppy-theme='dark'] &:hover { color: $gray-500; } } diff --git a/packages/@uppy/core/src/_utils.scss b/packages/@uppy/core/src/_utils.scss index 1e4264214b..77fc4a26d6 100644 --- a/packages/@uppy/core/src/_utils.scss +++ b/packages/@uppy/core/src/_utils.scss @@ -37,7 +37,7 @@ $focus-shadow: 0 0 0 3px rgba($blue, 0.5); background-color: $highlight; } - [data-uppy-theme="dark"] &:focus { + [data-uppy-theme='dark'] &:focus { background-color: $gray-800; } } diff --git a/packages/@uppy/core/src/_variables.scss b/packages/@uppy/core/src/_variables.scss index 1450a25733..500440719d 100644 --- a/packages/@uppy/core/src/_variables.scss +++ b/packages/@uppy/core/src/_variables.scss @@ -1,7 +1,10 @@ // Fonts -$font-family-base: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Segoe UI Symbol", "Segoe UI Emoji", "Apple Color Emoji", Roboto, Helvetica, Arial, sans-serif !default; -$font-family-mono: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace !default; +$font-family-base: -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', + 'Segoe UI Symbol', 'Segoe UI Emoji', 'Apple Color Emoji', Roboto, Helvetica, + Arial, sans-serif !default; +$font-family-mono: SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', + 'Courier New', monospace !default; // Colors diff --git a/packages/@uppy/core/types/index.d.ts b/packages/@uppy/core/types/index.d.ts index 1ba322e30f..8ee4a343b5 100644 --- a/packages/@uppy/core/types/index.d.ts +++ b/packages/@uppy/core/types/index.d.ts @@ -13,18 +13,18 @@ export interface IndexedObject { // These are defined in @uppy/utils instead of core so it can be used there without creating import cycles export type UppyFile< TMeta extends IndexedObject = Record, - TBody extends IndexedObject = Record - > = UppyUtils.UppyFile + TBody extends IndexedObject = Record, +> = UppyUtils.UppyFile -export type FileProgress = UppyUtils.FileProgress; +export type FileProgress = UppyUtils.FileProgress -export type FileRemoveReason = 'removed-by-user' | 'cancel-all'; +export type FileRemoveReason = 'removed-by-user' | 'cancel-all' // Replace the `meta` property type with one that allows omitting internal metadata addFile() will add that -type UppyFileWithoutMeta, TBody extends IndexedObject> = OmitKey< - UppyFile, - 'meta' -> +type UppyFileWithoutMeta< + TMeta extends IndexedObject, + TBody extends IndexedObject, +> = OmitKey, 'meta'> type LocaleStrings = { [K in TNames]?: string | { [n: number]: string } @@ -39,23 +39,23 @@ export type Store = UppyUtils.Store export type InternalMetadata = UppyUtils.InternalMetadata export interface UploadedUppyFile< - TMeta extends IndexedObject, - TBody extends IndexedObject - > extends UppyFile { + TMeta extends IndexedObject, + TBody extends IndexedObject, +> extends UppyFile { uploadURL: string } export interface FailedUppyFile< - TMeta extends IndexedObject, - TBody extends IndexedObject - > extends UppyFile { + TMeta extends IndexedObject, + TBody extends IndexedObject, +> extends UppyFile { error: string } export interface AddFileOptions< - TMeta extends IndexedObject = IndexedObject, - TBody extends IndexedObject = IndexedObject - > extends Partial> { + TMeta extends IndexedObject = IndexedObject, + TBody extends IndexedObject = IndexedObject, +> extends Partial> { // `.data` is the only required property here. data: Blob | File meta?: Partial & TMeta @@ -95,7 +95,9 @@ export class BasePlugin { uninstall(): void } -export class UIPlugin extends BasePlugin { +export class UIPlugin< + TOptions extends UIPluginOptions = DefaultPluginOptions, +> extends BasePlugin { id: string // eslint-disable-next-line no-use-before-define @@ -137,9 +139,9 @@ export interface Locale { } export interface Logger { - debug: (...args: any[]) => void; - warn: (...args: any[]) => void; - error: (...args: any[]) => void; + debug: (...args: any[]) => void + warn: (...args: any[]) => void + error: (...args: any[]) => void } export interface Restrictions { @@ -151,7 +153,9 @@ export interface Restrictions { allowedFileTypes?: string[] | null } -export interface UppyOptions = Record> { +export interface UppyOptions< + TMeta extends IndexedObject = Record, +> { id?: string autoProceed?: boolean /** @@ -165,7 +169,7 @@ export interface UppyOptions = Record, - files: { [key: string]: UppyFile } + files: { [key: string]: UppyFile }, ) => UppyFile | boolean | undefined onBeforeUpload?: (files: { [key: string]: UppyFile @@ -177,23 +181,21 @@ export interface UppyOptions = Record = Record, - TBody extends IndexedObject = Record - > { + TBody extends IndexedObject = Record, +> { successful: UploadedUppyFile[] failed: FailedUppyFile[] } export interface State< TMeta extends IndexedObject = Record, - TBody extends IndexedObject = Record - > extends IndexedObject { + TBody extends IndexedObject = Record, +> extends IndexedObject { capabilities?: { resumableUploads?: boolean } currentUploads: Record error?: string files: { - [key: string]: - | UploadedUppyFile - | FailedUppyFile + [key: string]: UploadedUppyFile | FailedUppyFile } info?: Array<{ isHidden: boolean @@ -213,42 +215,63 @@ export interface ErrorResponse { export interface SuccessResponse { uploadURL?: string status?: number - body?: any, + body?: any bytesUploaded?: number } -export type GenericEventCallback = () => void; -export type FileAddedCallback> = (file: UppyFile) => void; -export type FilesAddedCallback> = (files: UppyFile[]) => void; -export type FileRemovedCallback> = - (file: UppyFile, reason: FileRemoveReason) => void; -export type UploadCallback = (data: { id: string, fileIDs: string[] }) => void; -export type ProgressCallback = (progress: number) => void; -export type PreProcessCompleteCallback> = (file: UppyFile | undefined) => void; -export type UploadProgressCallback> = - (file: UppyFile | undefined, progress: FileProgress) => void; -export type UploadSuccessCallback> = - (file: UppyFile | undefined, response: SuccessResponse) => void -export type UploadCompleteCallback> = (result: UploadResult) => void -export type ErrorCallback = (error: Error) => void; -export type UploadErrorCallback> = - (file: UppyFile | undefined, error: Error, response?: ErrorResponse) => void; -export type UploadRetryCallback = (fileID: string) => void; -export type RetryAllCallback = (fileIDs: string[]) => void; -export type RestrictionFailedCallback> = - (file: UppyFile | undefined, error: Error) => void; - -export interface UppyEventMap = Record> { +export type GenericEventCallback = () => void +export type FileAddedCallback> = ( + file: UppyFile, +) => void +export type FilesAddedCallback> = ( + files: UppyFile[], +) => void +export type FileRemovedCallback> = ( + file: UppyFile, + reason: FileRemoveReason, +) => void +export type UploadCallback = (data: { id: string; fileIDs: string[] }) => void +export type ProgressCallback = (progress: number) => void +export type PreProcessCompleteCallback> = ( + file: UppyFile | undefined, +) => void +export type UploadProgressCallback> = ( + file: UppyFile | undefined, + progress: FileProgress, +) => void +export type UploadSuccessCallback> = ( + file: UppyFile | undefined, + response: SuccessResponse, +) => void +export type UploadCompleteCallback> = ( + result: UploadResult, +) => void +export type ErrorCallback = (error: Error) => void +export type UploadErrorCallback> = ( + file: UppyFile | undefined, + error: Error, + response?: ErrorResponse, +) => void +export type UploadRetryCallback = (fileID: string) => void +export type RetryAllCallback = (fileIDs: string[]) => void +export type RestrictionFailedCallback> = ( + file: UppyFile | undefined, + error: Error, +) => void + +export interface UppyEventMap< + TMeta extends IndexedObject = Record, +> { 'file-added': FileAddedCallback 'files-added': FilesAddedCallback 'file-removed': FileRemovedCallback - 'upload': UploadCallback - 'progress': ProgressCallback + upload: UploadCallback + progress: ProgressCallback 'preprocess-complete': PreProcessCompleteCallback 'upload-progress': UploadProgressCallback 'upload-success': UploadSuccessCallback - 'complete': UploadCompleteCallback - 'error': ErrorCallback + complete: UploadCompleteCallback + error: ErrorCallback 'upload-error': UploadErrorCallback 'upload-retry': UploadRetryCallback 'retry-all': RetryAllCallback @@ -264,15 +287,24 @@ export class Uppy { on(event: K, callback: UppyEventMap[K]): this - on>(event: K, callback: UppyEventMap[K]): this + on>( + event: K, + callback: UppyEventMap[K], + ): this once(event: K, callback: UppyEventMap[K]): this - once>(event: K, callback: UppyEventMap[K]): this + once>( + event: K, + callback: UppyEventMap[K], + ): this off(event: K, callback: UppyEventMap[K]): this - off>(event: K, callback: UppyEventMap[K]): this + off>( + event: K, + callback: UppyEventMap[K], + ): this /** * For use by plugins only. @@ -285,7 +317,9 @@ export class Uppy { setState(patch: Record): void - getState = Record>(): State + getState< + TMeta extends IndexedObject = Record, + >(): State setFileState(fileID: string, state: Record): void @@ -303,21 +337,23 @@ export class Uppy { removeUploader(fn: UploadHandler): void - setMeta = Record>(data: TMeta): void + setMeta = Record>( + data: TMeta, + ): void setFileMeta = Record>( fileID: string, - data: TMeta + data: TMeta, ): void getFile< TMeta extends IndexedObject = Record, - TBody extends IndexedObject = Record + TBody extends IndexedObject = Record, >(fileID: string): UppyFile getFiles< TMeta extends IndexedObject = Record, - TBody extends IndexedObject = Record + TBody extends IndexedObject = Record, >(): Array> getObjectOfFilesPerState(): { @@ -339,11 +375,11 @@ export class Uppy { } addFile = Record>( - file: AddFileOptions + file: AddFileOptions, ): string addFiles = Record>( - files: AddFileOptions[] + files: AddFileOptions[], ): void removeFile(fileID: string, reason?: FileRemoveReason): void @@ -354,24 +390,29 @@ export class Uppy { resumeAll(): void - retryAll = Record>(): Promise< - UploadResult - > + retryAll< + TMeta extends IndexedObject = Record, + >(): Promise> cancelAll(options?: CancelOptions): void retryUpload = Record>( - fileID: string + fileID: string, ): Promise> getID(): string - use>( + use< + TOptions extends PluginOptions, + TInstance extends UIPlugin | BasePlugin, + >( pluginClass: new (uppy: this, opts?: TOptions) => TInstance, - opts?: TOptions + opts?: TOptions, ): this - getPlugin(name: string): TPlugin | undefined + getPlugin( + name: string, + ): TPlugin | undefined iteratePlugins(callback: (plugin: UIPlugin | BasePlugin) => void): void @@ -384,7 +425,7 @@ export class Uppy { info( message: string | { message: string; details: string }, type?: LogLevel, - duration?: number + duration?: number, ): void hideInfo(): void @@ -392,12 +433,14 @@ export class Uppy { log(msg: string, type?: LogLevel): void restore = Record>( - uploadID: string + uploadID: string, ): Promise> addResultData(uploadID: string, data: Record): void - upload = Record>(): Promise> + upload = Record>(): Promise< + UploadResult + > } export default Uppy diff --git a/packages/@uppy/core/types/index.test-d.ts b/packages/@uppy/core/types/index.test-d.ts index b04184d2a9..d993cae7a1 100644 --- a/packages/@uppy/core/types/index.test-d.ts +++ b/packages/@uppy/core/types/index.test-d.ts @@ -3,7 +3,13 @@ import { expectError, expectType } from 'tsd' import DefaultStore from '@uppy/store-default' // eslint-disable-next-line import/no-named-as-default import Uppy, { UIPlugin } from '..' -import type { UploadedUppyFile, FailedUppyFile, PluginOptions, UppyFile, SuccessResponse } from '..' +import type { + UploadedUppyFile, + FailedUppyFile, + PluginOptions, + UppyFile, + SuccessResponse, +} from '..' type anyObject = Record @@ -98,7 +104,7 @@ type anyObject = Record }) // Meta signature - type Meta = {myCustomMetadata: string} + type Meta = { myCustomMetadata: string } uppy.on<'complete', Meta>('complete', (result) => { // eslint-disable-next-line @typescript-eslint/no-unused-vars const meta = result.successful[0].meta.myCustomMetadata @@ -115,7 +121,10 @@ type anyObject = Record body?: { someValue: string } } - const onUploadSuccess = async (file: UppyFile | undefined, response: CustomResponse) => { + const onUploadSuccess = async ( + file: UppyFile | undefined, + response: CustomResponse, + ) => { const res = response.body?.someValue } uppy.on<'upload-success', Meta>('upload-success', onUploadSuccess) @@ -136,16 +145,23 @@ type anyObject = Record interface TestOptions extends PluginOptions { testOption: string } - class TestPlugin extends UIPlugin { - } + class TestPlugin extends UIPlugin {} const strict = new Uppy().use(TestPlugin, { testOption: 'hello' }) /* eslint-disable @typescript-eslint/no-non-null-assertion */ - strict.getPlugin('TestPlugin')!.setOptions({ testOption: 'world' }) - - expectError(strict.getPlugin('TestPlugin')!.setOptions({ testOption: 0 })) - - expectError(strict.getPlugin('TestPlugin')!.setOptions({ unknownKey: false })) + strict + .getPlugin('TestPlugin')! + .setOptions({ testOption: 'world' }) + + expectError( + strict.getPlugin('TestPlugin')!.setOptions({ testOption: 0 }), + ) + + expectError( + strict + .getPlugin('TestPlugin')! + .setOptions({ unknownKey: false }), + ) /* eslint-enable @typescript-eslint/no-non-null-assertion */ } diff --git a/packages/@uppy/dashboard/src/components/FileCard/index.scss b/packages/@uppy/dashboard/src/components/FileCard/index.scss index a1a7950736..b8f5b23c51 100644 --- a/packages/@uppy/dashboard/src/components/FileCard/index.scss +++ b/packages/@uppy/dashboard/src/components/FileCard/index.scss @@ -49,7 +49,7 @@ min-height: 0; border-bottom: 1px solid $gray-200; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-800; border-bottom: 0; } @@ -91,7 +91,7 @@ overflow-y: auto; -webkit-overflow-scrolling: touch; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-900; } } @@ -116,7 +116,7 @@ font-size: 14px; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; } } @@ -143,7 +143,7 @@ height: 65px; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-900; border-top: 1px solid $gray-800; } diff --git a/packages/@uppy/dashboard/src/components/FileItem/Buttons/index.scss b/packages/@uppy/dashboard/src/components/FileItem/Buttons/index.scss index f794600fba..08f3c5b835 100644 --- a/packages/@uppy/dashboard/src/components/FileItem/Buttons/index.scss +++ b/packages/@uppy/dashboard/src/components/FileItem/Buttons/index.scss @@ -10,13 +10,13 @@ opacity: 1; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { @include blue-border-focus--dark; color: $gray-300; } - [data-uppy-theme="dark"] &:hover { + [data-uppy-theme='dark'] &:hover { color: $gray-200; } } @@ -50,17 +50,19 @@ top: 8px; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-700; } - [data-uppy-theme="dark"] &:hover { + [data-uppy-theme='dark'] &:hover { color: $gray-800; } } // Only for mobile screens -.uppy-Dashboard:not(.uppy-size--md):not(.uppy-Dashboard--singleFile.uppy-size--height-md) { +.uppy-Dashboard:not(.uppy-size--md):not( + .uppy-Dashboard--singleFile.uppy-size--height-md + ) { // Vertically center Edit&Remove buttons on mobile .uppy-Dashboard-Item-actionWrapper { display: flex; diff --git a/packages/@uppy/dashboard/src/components/FileItem/FileInfo/index.scss b/packages/@uppy/dashboard/src/components/FileItem/FileInfo/index.scss index ff62792f36..9d5f8b775b 100644 --- a/packages/@uppy/dashboard/src/components/FileItem/FileInfo/index.scss +++ b/packages/@uppy/dashboard/src/components/FileItem/FileInfo/index.scss @@ -20,7 +20,7 @@ word-wrap: anywhere; word-break: break-all; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; } @@ -59,7 +59,7 @@ font-size: 11px; line-height: 1; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-400; } } @@ -124,4 +124,3 @@ display: none; } } - diff --git a/packages/@uppy/dashboard/src/components/FileItem/FilePreviewAndLink/index.scss b/packages/@uppy/dashboard/src/components/FileItem/FilePreviewAndLink/index.scss index 16e4fc4848..485625700d 100644 --- a/packages/@uppy/dashboard/src/components/FileItem/FilePreviewAndLink/index.scss +++ b/packages/@uppy/dashboard/src/components/FileItem/FilePreviewAndLink/index.scss @@ -44,7 +44,7 @@ box-shadow: inset 0 0 0 3px lighten($blue, 20%); } - [data-uppy-theme="dark"] &:focus { + [data-uppy-theme='dark'] &:focus { box-shadow: inset 0 0 0 3px darken($highlight--dark, 20%); } } diff --git a/packages/@uppy/dashboard/src/components/FileItem/index.scss b/packages/@uppy/dashboard/src/components/FileItem/index.scss index 25d4071365..b564fe9326 100644 --- a/packages/@uppy/dashboard/src/components/FileItem/index.scss +++ b/packages/@uppy/dashboard/src/components/FileItem/index.scss @@ -13,7 +13,7 @@ padding-inline-end: 0; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { border-bottom: 1px solid $gray-800; } diff --git a/packages/@uppy/dashboard/src/style.scss b/packages/@uppy/dashboard/src/style.scss index 476abb211d..bc3490c84d 100644 --- a/packages/@uppy/dashboard/src/style.scss +++ b/packages/@uppy/dashboard/src/style.scss @@ -13,7 +13,9 @@ .uppy-transition-slideDownUp-enter { transform: translate3d(0, -105%, 0); opacity: 0.01; - transition: transform 0.25s ease-in-out, opacity 0.25s ease-in-out; + transition: + transform 0.25s ease-in-out, + opacity 0.25s ease-in-out; } .uppy-transition-slideDownUp-enter.uppy-transition-slideDownUp-enter-active { @@ -24,7 +26,9 @@ .uppy-transition-slideDownUp-leave { transform: translate3d(0, 0, 0); opacity: 1; - transition: transform 0.25s ease-in-out, opacity 0.25s ease-in-out; + transition: + transform 0.25s ease-in-out, + opacity 0.25s ease-in-out; } .uppy-transition-slideDownUp-leave.uppy-transition-slideDownUp-leave-active { @@ -35,13 +39,21 @@ // Modal open/close animations @keyframes uppy-Dashboard-fadeIn { - from { opacity: 0; } - to { opacity: 1; } + from { + opacity: 0; + } + to { + opacity: 1; + } } @keyframes uppy-Dashboard-fadeOut { - from { opacity: 1; } - to { opacity: 0; } + from { + opacity: 1; + } + to { + opacity: 0; + } } @keyframes uppy-Dashboard-slideDownAndFadeIn { @@ -98,31 +110,37 @@ z-index: $zIndex-2; } -.uppy-Dashboard--modal[aria-hidden=true] { +.uppy-Dashboard--modal[aria-hidden='true'] { display: none; } -.uppy-Dashboard--modal.uppy-Dashboard--animateOpenClose > .uppy-Dashboard-inner { - animation: uppy-Dashboard-slideDownAndFadeIn--small 0.3s cubic-bezier(0, 0, 0.2, 1); +.uppy-Dashboard--modal.uppy-Dashboard--animateOpenClose + > .uppy-Dashboard-inner { + animation: uppy-Dashboard-slideDownAndFadeIn--small 0.3s + cubic-bezier(0, 0, 0.2, 1); @media #{$screen-medium} { animation: uppy-Dashboard-slideDownAndFadeIn 0.3s cubic-bezier(0, 0, 0.2, 1); } } -.uppy-Dashboard--modal.uppy-Dashboard--animateOpenClose > .uppy-Dashboard-overlay { +.uppy-Dashboard--modal.uppy-Dashboard--animateOpenClose + > .uppy-Dashboard-overlay { animation: uppy-Dashboard-fadeIn 0.3s cubic-bezier(0, 0, 0.2, 1); } -.uppy-Dashboard--modal.uppy-Dashboard--animateOpenClose.uppy-Dashboard--isClosing > .uppy-Dashboard-inner { - animation: uppy-Dashboard-slideUpFadeOut--small 0.3s cubic-bezier(0, 0, 0.2, 1); +.uppy-Dashboard--modal.uppy-Dashboard--animateOpenClose.uppy-Dashboard--isClosing + > .uppy-Dashboard-inner { + animation: uppy-Dashboard-slideUpFadeOut--small 0.3s + cubic-bezier(0, 0, 0.2, 1); @media #{$screen-medium} { animation: uppy-Dashboard-slideUpFadeOut 0.3s cubic-bezier(0, 0, 0.2, 1); } } -.uppy-Dashboard--modal.uppy-Dashboard--animateOpenClose.uppy-Dashboard--isClosing > .uppy-Dashboard-overlay { +.uppy-Dashboard--modal.uppy-Dashboard--animateOpenClose.uppy-Dashboard--isClosing + > .uppy-Dashboard-overlay { animation: uppy-Dashboard-fadeOut 0.3s cubic-bezier(0, 0, 0.2, 1); } @@ -164,7 +182,7 @@ z-index: $zIndex-3; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-900; } @@ -200,7 +218,8 @@ // Disallow clicking on all interactive elements .uppy-Dashboard--isDisabled { - [disabled], [aria-disabled] { + [disabled], + [aria-disabled] { pointer-events: none; cursor: not-allowed; } @@ -265,7 +284,7 @@ line-height: 1.4; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; background-color: $gray-900; border-top: 1px solid $gray-800; @@ -290,7 +309,7 @@ font-size: inherit; vertical-align: initial; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: rgba($highlight--dark, 0.9); } } @@ -310,7 +329,7 @@ height: 100%; text-align: center; - [data-uppy-drag-drop-supported="true"] & { + [data-uppy-drag-drop-supported='true'] & { height: calc(100% - 14px); // to accomodate for the 7px margin margin: 7px; border: 1px dashed $gray-250; @@ -318,7 +337,9 @@ } .uppy-Dashboard-AddFilesPanel & { - height: calc(100% - 14px - 40px); // to accomodate for the 7px margin and 40px topbar height + height: calc( + 100% - 14px - 40px + ); // to accomodate for the 7px margin and 40px topbar height border: none; } @@ -326,13 +347,12 @@ border-color: $gray-300; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { border-color: $gray-600; } } .uppy-Dashboard-AddFiles-info { - // hide on short note and “powered by” on short screens // such as CodePen, or inline dashboard with height < 400px display: none; @@ -353,7 +373,7 @@ padding-bottom: 0; } - [data-uppy-num-acquirers="0"] & { + [data-uppy-num-acquirers='0'] & { margin-top: 0; } } @@ -369,12 +389,12 @@ border-bottom: 1px solid $blue; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: rgba($highlight--dark, 0.9); } - [data-uppy-theme="dark"] &:hover, - [data-uppy-theme="dark"] &:focus { + [data-uppy-theme='dark'] &:hover, + [data-uppy-theme='dark'] &:focus { border-bottom: 1px solid $highlight--dark; } } @@ -424,7 +444,7 @@ text-align: center; border-bottom: 1px solid $gray-200; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { border-bottom: 1px solid $gray-800; } @@ -460,7 +480,7 @@ margin-inline-end: 1px; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; } } @@ -472,7 +492,7 @@ .uppy-DashboardTab-btn:hover { background-color: $gray-200--highlighted; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-800; } } @@ -481,7 +501,7 @@ .uppy-DashboardTab-btn:focus { background-color: $highlight; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-700; } } @@ -503,20 +523,22 @@ height: 32px; border-radius: 8px; background-color: #fff; - box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1), - 0 1px 2px 0 rgba(0, 0, 0, 0.1), - 0 2px 3px 0 rgba(0, 0, 0, 0.02); + box-shadow: + 0 1px 1px 0 rgba(0, 0, 0, 0.1), + 0 1px 2px 0 rgba(0, 0, 0, 0.1), + 0 2px 3px 0 rgba(0, 0, 0, 0.02); margin-inline-end: 10px; .uppy-size--md & { margin-inline-end: 0; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: #323232; - box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.2), - 0 1px 2px 0 rgba(0, 0, 0, 0.2), - 0 2px 3px 0 rgba(0, 0, 0, 0.08); + box-shadow: + 0 1px 1px 0 rgba(0, 0, 0, 0.2), + 0 1px 2px 0 rgba(0, 0, 0, 0.2), + 0 2px 3px 0 rgba(0, 0, 0, 0.08); } } @@ -535,7 +557,7 @@ .uppy-DashboardTab-iconMyDevice { color: $blue; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $highlight--dark; } } @@ -543,7 +565,7 @@ .uppy-DashboardTab-iconBox { color: #0061d5; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; } } @@ -551,7 +573,7 @@ .uppy-DashboardTab-iconDropbox { color: #0061fe; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; } } @@ -559,7 +581,7 @@ .uppy-DashboardTab-iconUnsplash { color: #111; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; } } @@ -567,7 +589,7 @@ .uppy-DashboardTab-iconScreenRec { color: #2c3e50; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; } } @@ -575,7 +597,7 @@ .uppy-DashboardTab-iconAudio { color: #8030a3; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: #bf6ee3; } } @@ -590,7 +612,6 @@ } .uppy-DashboardContent-bar { - // For .uppy-DashboardContent-title's position: absolute position: relative; z-index: $zIndex-4; @@ -610,7 +631,7 @@ padding: 0 15px; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-900; border-bottom: 1px solid $gray-800; } @@ -639,7 +660,7 @@ line-height: 50px; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; } } @@ -661,7 +682,7 @@ font-size: 14px; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $highlight--dark; } } @@ -686,7 +707,7 @@ margin-inline-end: -8px; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $highlight--dark; } } @@ -741,9 +762,13 @@ border-radius: 5px; box-shadow: 0 0 10px 5px rgba($black, 0.15); - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-800; - background-image: linear-gradient(0deg, $gray-900 35%, rgba($gray-900, 0.85) 100%); + background-image: linear-gradient( + 0deg, + $gray-900 35%, + rgba($gray-900, 0.85) 100% + ); } } @@ -791,7 +816,7 @@ } } -.uppy-Dashboard--singleFile .uppy-Dashboard-filesInner { +.uppy-Dashboard--singleFile .uppy-Dashboard-filesInner { display: flex; justify-content: center; align-items: center; @@ -819,7 +844,7 @@ border-radius: 3px; visibility: hidden; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-400; background-image: url("data:image/svg+xml,%3Csvg width='48' height='48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M24 1v1C11.85 2 2 11.85 2 24s9.85 22 22 22 22-9.85 22-22S36.15 2 24 2V1zm0 0V0c13.254 0 24 10.746 24 24S37.254 48 24 48 0 37.254 0 24 10.746 0 24 0v1zm7.707 19.293a.999.999 0 1 1-1.414 1.414L25 16.414V34a1 1 0 1 1-2 0V16.414l-5.293 5.293a.999.999 0 1 1-1.414-1.414l7-7a.999.999 0 0 1 1.414 0l7 7z' fill='%2302BAF2' fill-rule='nonzero'/%3E%3C/svg%3E"); border-color: $highlight--dark; @@ -863,11 +888,11 @@ text-align: center; } - [data-uppy-num-acquirers="0"] & { + [data-uppy-num-acquirers='0'] & { text-align: center; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; } @@ -894,7 +919,7 @@ line-height: 1.35; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-300; } } diff --git a/packages/@uppy/dashboard/types/index.d.ts b/packages/@uppy/dashboard/types/index.d.ts index 3e16dbfe7c..ee83649d14 100644 --- a/packages/@uppy/dashboard/types/index.d.ts +++ b/packages/@uppy/dashboard/types/index.d.ts @@ -1,17 +1,27 @@ -import type { IndexedObject, PluginTarget, UIPlugin, UIPluginOptions, UppyFile } from '@uppy/core' +import type { + IndexedObject, + PluginTarget, + UIPlugin, + UIPluginOptions, + UppyFile, +} from '@uppy/core' import type { StatusBarLocale } from '@uppy/status-bar' import type { ThumbnailOptions } from '@uppy/thumbnail-generator' import DashboardLocale from './generatedLocale' type FieldRenderOptions = { - value: string, + value: string onChange: (newVal: string) => void fieldCSSClasses: { text: string } required: boolean form: string } -type PreactRender = (node: any, params: Record | null, ...children: any[]) => any +type PreactRender = ( + node: any, + params: Record | null, + ...children: any[] +) => any interface MetaField { id: string @@ -43,7 +53,7 @@ export interface DashboardOptions extends Options { metaFields?: MetaField[] | ((file: UppyFile) => MetaField[]) note?: string | null plugins?: string[] - fileManagerSelectionType?: 'files' | 'folders' | 'both'; + fileManagerSelectionType?: 'files' | 'folders' | 'both' proudlyDisplayPoweredByUppy?: boolean showLinkToFileUploadResult?: boolean showProgressDetails?: boolean @@ -66,30 +76,34 @@ export interface DashboardOptions extends Options { } declare class Dashboard extends UIPlugin { - addTarget (plugin: UIPlugin): HTMLElement + addTarget(plugin: UIPlugin): HTMLElement - hideAllPanels (): void + hideAllPanels(): void - openModal (): void + openModal(): void - closeModal (): void + closeModal(): void - isModalOpen (): boolean + isModalOpen(): boolean - render (state: Record): void + render(state: Record): void - install (): void + install(): void - uninstall (): void + uninstall(): void } export default Dashboard // Events -export type DashboardFileEditStartCallback> = (file?: UppyFile) => void; -export type DashboardFileEditCompleteCallback> = (file?: UppyFile) => void; -export type DashboardShowPlanelCallback = (id: string) => void; +export type DashboardFileEditStartCallback> = ( + file?: UppyFile, +) => void +export type DashboardFileEditCompleteCallback< + TMeta extends IndexedObject, +> = (file?: UppyFile) => void +export type DashboardShowPlanelCallback = (id: string) => void declare module '@uppy/core' { export interface UppyEventMap { 'dashboard:modal-open': GenericEventCallback diff --git a/packages/@uppy/dashboard/types/index.test-d.ts b/packages/@uppy/dashboard/types/index.test-d.ts index 21194a9ac6..dffa10cdc8 100644 --- a/packages/@uppy/dashboard/types/index.test-d.ts +++ b/packages/@uppy/dashboard/types/index.test-d.ts @@ -29,7 +29,7 @@ import Dashboard from '..' { id: 'public', name: 'Public', - render ({ value, onChange }, h) { + render({ value, onChange }, h) { expectType(value) expectType<(val: string) => void>(onChange) // `h` should be the Preact `h` @@ -74,21 +74,25 @@ import Dashboard from '..' }, }, }) - expectError(uppy.use(Dashboard, { - locale: { - strings: { - somethingThatDoesNotExist: 'wrong', + expectError( + uppy.use(Dashboard, { + locale: { + strings: { + somethingThatDoesNotExist: 'wrong', + }, }, - }, - })) + }), + ) const wrongType = 1234 - expectError(uppy.use(Dashboard, { - locale: { - strings: { - addMoreFiles: wrongType, + expectError( + uppy.use(Dashboard, { + locale: { + strings: { + addMoreFiles: wrongType, + }, }, - }, - })) + }), + ) } { const uppy = new Uppy() diff --git a/packages/@uppy/drop-target/types/index.d.ts b/packages/@uppy/drop-target/types/index.d.ts index 1688a7cae3..419a1bf898 100644 --- a/packages/@uppy/drop-target/types/index.d.ts +++ b/packages/@uppy/drop-target/types/index.d.ts @@ -1,10 +1,10 @@ import type { PluginOptions, BasePlugin } from '@uppy/core' interface DropTargetOptions extends PluginOptions { - target: string | Element; - onDragOver?: (event: MouseEvent) => void; - onDrop?: (event: MouseEvent) => void; - onDragLeave?: (event: MouseEvent) => void; + target: string | Element + onDragOver?: (event: MouseEvent) => void + onDrop?: (event: MouseEvent) => void + onDragLeave?: (event: MouseEvent) => void } declare class DropTarget extends BasePlugin {} diff --git a/packages/@uppy/dropbox/types/index.d.ts b/packages/@uppy/dropbox/types/index.d.ts index ec0d4608de..b9b6d5093e 100644 --- a/packages/@uppy/dropbox/types/index.d.ts +++ b/packages/@uppy/dropbox/types/index.d.ts @@ -1,10 +1,13 @@ import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core' -import type { PublicProviderOptions, TokenStorage } from '@uppy/companion-client' +import type { + PublicProviderOptions, + TokenStorage, +} from '@uppy/companion-client' export interface DropboxOptions extends UIPluginOptions, PublicProviderOptions { - target?: PluginTarget - title?: string - storage?: TokenStorage + target?: PluginTarget + title?: string + storage?: TokenStorage } declare class Dropbox extends UIPlugin {} diff --git a/packages/@uppy/facebook/types/index.d.ts b/packages/@uppy/facebook/types/index.d.ts index b29ddd4af8..922e6f5f85 100644 --- a/packages/@uppy/facebook/types/index.d.ts +++ b/packages/@uppy/facebook/types/index.d.ts @@ -1,12 +1,17 @@ import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core' -import type { PublicProviderOptions, TokenStorage } from '@uppy/companion-client' +import type { + PublicProviderOptions, + TokenStorage, +} from '@uppy/companion-client' -export interface FacebookOptions extends UIPluginOptions, PublicProviderOptions { - target?: PluginTarget - title?: string - storage?: TokenStorage +export interface FacebookOptions + extends UIPluginOptions, + PublicProviderOptions { + target?: PluginTarget + title?: string + storage?: TokenStorage } -declare class Facebook extends UIPlugin { } +declare class Facebook extends UIPlugin {} export default Facebook diff --git a/packages/@uppy/file-input/types/index.d.ts b/packages/@uppy/file-input/types/index.d.ts index 8de800f2ec..d5f4019fe5 100644 --- a/packages/@uppy/file-input/types/index.d.ts +++ b/packages/@uppy/file-input/types/index.d.ts @@ -2,10 +2,10 @@ import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core' import FileInputLocale from './generatedLocale' export interface FileInputOptions extends UIPluginOptions { - target?: PluginTarget - pretty?: boolean - inputName?: string - locale?: FileInputLocale + target?: PluginTarget + pretty?: boolean + inputName?: string + locale?: FileInputLocale } declare class FileInput extends UIPlugin {} diff --git a/packages/@uppy/form/types/index.d.ts b/packages/@uppy/form/types/index.d.ts index 9d5fc69c4a..1ce5199d61 100644 --- a/packages/@uppy/form/types/index.d.ts +++ b/packages/@uppy/form/types/index.d.ts @@ -1,12 +1,12 @@ import type { PluginOptions, PluginTarget, BasePlugin } from '@uppy/core' export interface FormOptions extends PluginOptions { - target?: PluginTarget - resultName?: string - getMetaFromForm?: boolean - addResultToForm?: boolean - submitOnSuccess?: boolean - triggerUploadOnSubmit?: boolean + target?: PluginTarget + resultName?: string + getMetaFromForm?: boolean + addResultToForm?: boolean + submitOnSuccess?: boolean + triggerUploadOnSubmit?: boolean } declare class Form extends BasePlugin {} diff --git a/packages/@uppy/golden-retriever/types/index.d.ts b/packages/@uppy/golden-retriever/types/index.d.ts index dfb3e18a15..38eff203e3 100644 --- a/packages/@uppy/golden-retriever/types/index.d.ts +++ b/packages/@uppy/golden-retriever/types/index.d.ts @@ -1,9 +1,9 @@ import type { PluginOptions, BasePlugin } from '@uppy/core' interface GoldenRetrieverOptions extends PluginOptions { - expires?: number - serviceWorker?: boolean - indexedDB?: any + expires?: number + serviceWorker?: boolean + indexedDB?: any } declare class GoldenRetriever extends BasePlugin {} diff --git a/packages/@uppy/google-drive/types/index.d.ts b/packages/@uppy/google-drive/types/index.d.ts index 4cdb85644b..223b546175 100644 --- a/packages/@uppy/google-drive/types/index.d.ts +++ b/packages/@uppy/google-drive/types/index.d.ts @@ -1,12 +1,17 @@ import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core' -import type { PublicProviderOptions, TokenStorage } from '@uppy/companion-client' +import type { + PublicProviderOptions, + TokenStorage, +} from '@uppy/companion-client' -export interface GoogleDriveOptions extends UIPluginOptions, PublicProviderOptions { - target?: PluginTarget - title?: string - storage?: TokenStorage +export interface GoogleDriveOptions + extends UIPluginOptions, + PublicProviderOptions { + target?: PluginTarget + title?: string + storage?: TokenStorage } -declare class GoogleDrive extends UIPlugin { } +declare class GoogleDrive extends UIPlugin {} export default GoogleDrive diff --git a/packages/@uppy/google-drive/types/index.test-d.ts b/packages/@uppy/google-drive/types/index.test-d.ts index 425eb1cdda..ffd9efa87f 100644 --- a/packages/@uppy/google-drive/types/index.test-d.ts +++ b/packages/@uppy/google-drive/types/index.test-d.ts @@ -6,4 +6,7 @@ class SomePlugin extends UIPlugin {} const uppy = new Uppy() uppy.use(GoogleDrive, { companionUrl: '' }) uppy.use(GoogleDrive, { target: SomePlugin, companionUrl: '' }) -uppy.use(GoogleDrive, { target: document.querySelector('#gdrive') || (undefined as never), companionUrl: '' }) +uppy.use(GoogleDrive, { + target: document.querySelector('#gdrive') || (undefined as never), + companionUrl: '', +}) diff --git a/packages/@uppy/image-editor/src/cropper.scss b/packages/@uppy/image-editor/src/cropper.scss index 7949fda736..2b28b3f4f8 100644 --- a/packages/@uppy/image-editor/src/cropper.scss +++ b/packages/@uppy/image-editor/src/cropper.scss @@ -66,7 +66,11 @@ overflow: hidden; outline: 1px solid #39f; outline-color: rgba(51, 153, 255, 0.75); - background: repeating-conic-gradient(rgba(0, 0, 0, 0.5) 0% 25%, rgba(255, 255, 255, 0.5) 0% 50%) 50% / 16px 16px; + background: repeating-conic-gradient( + rgba(0, 0, 0, 0.5) 0% 25%, + rgba(255, 255, 255, 0.5) 0% 50% + ) + 50% / 16px 16px; } .cropper-dashed { diff --git a/packages/@uppy/image-editor/src/inputrange.scss b/packages/@uppy/image-editor/src/inputrange.scss index 4c74472b3d..c758acfbe5 100644 --- a/packages/@uppy/image-editor/src/inputrange.scss +++ b/packages/@uppy/image-editor/src/inputrange.scss @@ -4,7 +4,7 @@ // Version 1.5.2 // MIT License -@use "sass:math"; +@use 'sass:math'; $track-color: rgba(#fff, 0.2); $thumb-color: #fff; @@ -32,7 +32,9 @@ $contrast: 5%; $ie-bottom-track-color: darken($track-color, $contrast); @mixin shadow($shadow-size, $shadow-blur, $shadow-color) { - box-shadow: $shadow-size $shadow-size $shadow-blur $shadow-color, 0 0 $shadow-size lighten($shadow-color, 5%); + box-shadow: + $shadow-size $shadow-size $shadow-blur $shadow-color, + 0 0 $shadow-size lighten($shadow-color, 5%); } @mixin track { @@ -82,7 +84,11 @@ $ie-bottom-track-color: darken($track-color, $contrast); &::-webkit-slider-runnable-track { @include track; - @include shadow($track-shadow-size, $track-shadow-blur, $track-shadow-color); + @include shadow( + $track-shadow-size, + $track-shadow-blur, + $track-shadow-color + ); background: $track-color; border: $track-border-width solid $track-border-color; @@ -92,12 +98,21 @@ $ie-bottom-track-color: darken($track-color, $contrast); &::-webkit-slider-thumb { @include thumb; - margin-top: (math.div((-$track-border-width * 2 + $track-height), 2) - math.div($thumb-height, 2)); + margin-top: ( + math.div((-$track-border-width * 2 + $track-height), 2) - math.div( + $thumb-height, + 2 + ) + ); -webkit-appearance: none; } &::-moz-range-track { - @include shadow($track-shadow-size, $track-shadow-blur, $track-shadow-color); + @include shadow( + $track-shadow-size, + $track-shadow-blur, + $track-shadow-color + ); @include track; height: $track-height; @@ -120,7 +135,11 @@ $ie-bottom-track-color: darken($track-color, $contrast); } &::-ms-fill-lower { - @include shadow($track-shadow-size, $track-shadow-blur, $track-shadow-color); + @include shadow( + $track-shadow-size, + $track-shadow-blur, + $track-shadow-color + ); background: $ie-bottom-track-color; border: $track-border-width solid $track-border-color; @@ -128,7 +147,11 @@ $ie-bottom-track-color: darken($track-color, $contrast); } &::-ms-fill-upper { - @include shadow($track-shadow-size, $track-shadow-blur, $track-shadow-color); + @include shadow( + $track-shadow-size, + $track-shadow-blur, + $track-shadow-color + ); background: $track-color; border: $track-border-width solid $track-border-color; diff --git a/packages/@uppy/image-editor/types/index.d.ts b/packages/@uppy/image-editor/types/index.d.ts index c1832a9d0d..1597b1bc8f 100644 --- a/packages/@uppy/image-editor/types/index.d.ts +++ b/packages/@uppy/image-editor/types/index.d.ts @@ -1,4 +1,10 @@ -import type { IndexedObject, PluginTarget, UIPlugin, UIPluginOptions, UppyFile } from '@uppy/core' +import type { + IndexedObject, + PluginTarget, + UIPlugin, + UIPluginOptions, + UppyFile, +} from '@uppy/core' import type Cropper from 'cropperjs' import ImageEditorLocale from './generatedLocale' @@ -32,13 +38,19 @@ export default ImageEditor // Events -export type FileEditorStartCallback> = (file: UppyFile) => void; -export type FileEditorCompleteCallback> = (updatedFile: UppyFile) => void; -export type FileEditorCancelCallback> = (file: UppyFile) => void; +export type FileEditorStartCallback> = ( + file: UppyFile, +) => void +export type FileEditorCompleteCallback> = ( + updatedFile: UppyFile, +) => void +export type FileEditorCancelCallback> = ( + file: UppyFile, +) => void declare module '@uppy/core' { export interface UppyEventMap> { - 'file-editor:start' : FileEditorStartCallback + 'file-editor:start': FileEditorStartCallback 'file-editor:complete': FileEditorCompleteCallback 'file-editor:cancel': FileEditorCancelCallback } diff --git a/packages/@uppy/informer/src/style.scss b/packages/@uppy/informer/src/style.scss index 0ca3c81b60..dd6fa30d8e 100644 --- a/packages/@uppy/informer/src/style.scss +++ b/packages/@uppy/informer/src/style.scss @@ -41,7 +41,7 @@ line-height: 1.3; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-800; } } diff --git a/packages/@uppy/instagram/types/index.d.ts b/packages/@uppy/instagram/types/index.d.ts index beec2e677c..84981fcb11 100644 --- a/packages/@uppy/instagram/types/index.d.ts +++ b/packages/@uppy/instagram/types/index.d.ts @@ -1,10 +1,15 @@ import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core' -import type { PublicProviderOptions, TokenStorage } from '@uppy/companion-client' +import type { + PublicProviderOptions, + TokenStorage, +} from '@uppy/companion-client' -export interface InstagramOptions extends UIPluginOptions, PublicProviderOptions { - target?: PluginTarget - title?: string - storage?: TokenStorage +export interface InstagramOptions + extends UIPluginOptions, + PublicProviderOptions { + target?: PluginTarget + title?: string + storage?: TokenStorage } declare class Instagram extends UIPlugin {} diff --git a/packages/@uppy/onedrive/types/index.d.ts b/packages/@uppy/onedrive/types/index.d.ts index 787a79c06e..6473fcce9e 100644 --- a/packages/@uppy/onedrive/types/index.d.ts +++ b/packages/@uppy/onedrive/types/index.d.ts @@ -1,10 +1,15 @@ import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core' -import type { PublicProviderOptions, TokenStorage } from '@uppy/companion-client' +import type { + PublicProviderOptions, + TokenStorage, +} from '@uppy/companion-client' -export interface OneDriveOptions extends UIPluginOptions, PublicProviderOptions { - target?: PluginTarget - title?: string - storage?: TokenStorage +export interface OneDriveOptions + extends UIPluginOptions, + PublicProviderOptions { + target?: PluginTarget + title?: string + storage?: TokenStorage } declare class OneDrive extends UIPlugin {} diff --git a/packages/@uppy/progress-bar/src/style.scss b/packages/@uppy/progress-bar/src/style.scss index 4ac6965994..f0843e3a03 100644 --- a/packages/@uppy/progress-bar/src/style.scss +++ b/packages/@uppy/progress-bar/src/style.scss @@ -12,7 +12,7 @@ transition: height 0.2s; } -.uppy-ProgressBar[aria-hidden=true] { +.uppy-ProgressBar[aria-hidden='true'] { /* no important */ height: 0; } diff --git a/packages/@uppy/provider-views/src/style.scss b/packages/@uppy/provider-views/src/style.scss index 4ec4a06cd3..1a7ce23176 100644 --- a/packages/@uppy/provider-views/src/style.scss +++ b/packages/@uppy/provider-views/src/style.scss @@ -11,7 +11,7 @@ align-items: center; justify-content: center; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-900; } } @@ -51,7 +51,7 @@ font-size: 20px; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-300; } } @@ -60,15 +60,15 @@ display: flex; align-items: center; padding: 8px 12px !important; - background: #4285F4; + background: #4285f4; &:hover { - background-color: darken(#4285F4, 10%); + background-color: darken(#4285f4, 10%); } &:focus { outline: none; - box-shadow: 0 0 0 3px rgba(#4285F4, 0.4); + box-shadow: 0 0 0 3px rgba(#4285f4, 0.4); } svg { @@ -87,7 +87,7 @@ margin-bottom: 0; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; } } @@ -130,7 +130,7 @@ cursor: pointer; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; } } @@ -150,7 +150,7 @@ color: $gray-800; font-weight: 500; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; } } @@ -168,7 +168,7 @@ z-index: $zIndex-2; border-bottom: 1px solid $gray-200; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { border-bottom: 1px solid $gray-800; } } @@ -186,7 +186,7 @@ align-items: center; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-900; } } @@ -236,7 +236,7 @@ display: none; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; background-color: $gray-900; } @@ -246,7 +246,7 @@ background-color: $gray-300; border: 0; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-800; } } @@ -299,7 +299,7 @@ text-decoration: underline; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; } } @@ -328,7 +328,7 @@ border-spacing: 0; -webkit-overflow-scrolling: touch; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-900; } @@ -355,7 +355,7 @@ margin-inline-end: 8px; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-900; border-top: 1px solid $gray-800; } diff --git a/packages/@uppy/provider-views/src/style/uppy-ProviderBrowser-viewType--grid.scss b/packages/@uppy/provider-views/src/style/uppy-ProviderBrowser-viewType--grid.scss index 45ca751903..761ab3d018 100644 --- a/packages/@uppy/provider-views/src/style/uppy-ProviderBrowser-viewType--grid.scss +++ b/packages/@uppy/provider-views/src/style/uppy-ProviderBrowser-viewType--grid.scss @@ -52,7 +52,7 @@ .uppy-ProviderBrowserItem-inner { background-color: rgba($gray-500, 0.2); - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: rgba($gray-200, 0.2); } } @@ -62,7 +62,7 @@ height: 30%; fill: rgba($black, 0.7); - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { fill: rgba($white, 0.8); } } @@ -89,7 +89,7 @@ } } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { box-shadow: 0 0 0 3px rgba($lightblue, 0.7); } diff --git a/packages/@uppy/provider-views/src/style/uppy-ProviderBrowser-viewType--list.scss b/packages/@uppy/provider-views/src/style/uppy-ProviderBrowser-viewType--list.scss index 42b0e208e5..95a4eb2c23 100644 --- a/packages/@uppy/provider-views/src/style/uppy-ProviderBrowser-viewType--list.scss +++ b/packages/@uppy/provider-views/src/style/uppy-ProviderBrowser-viewType--list.scss @@ -5,7 +5,7 @@ .uppy-ProviderBrowser-viewType--list { background-color: $white; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-900; } @@ -15,7 +15,7 @@ margin: 0; padding: 7px 15px; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; } } @@ -49,7 +49,7 @@ inset-inline-start: 3px; } - [data-uppy-theme="dark"] &:focus { + [data-uppy-theme='dark'] &:focus { border-color: rgba($highlight--dark, 0.7); box-shadow: 0 0 0 3px rgba($highlight--dark, 0.2); } diff --git a/packages/@uppy/provider-views/src/style/uppy-ProviderBrowserItem-checkbox.scss b/packages/@uppy/provider-views/src/style/uppy-ProviderBrowserItem-checkbox.scss index 6516aeb57c..39e9840ef0 100644 --- a/packages/@uppy/provider-views/src/style/uppy-ProviderBrowserItem-checkbox.scss +++ b/packages/@uppy/provider-views/src/style/uppy-ProviderBrowserItem-checkbox.scss @@ -23,14 +23,14 @@ cursor: default; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-900; border-color: $gray-500; } } .uppy-ProviderBrowserItem-checkbox--is-checked { - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-800; } } diff --git a/packages/@uppy/provider-views/src/style/uppy-SearchProvider-input.scss b/packages/@uppy/provider-views/src/style/uppy-SearchProvider-input.scss index 10c588b879..2548ae33e2 100644 --- a/packages/@uppy/provider-views/src/style/uppy-SearchProvider-input.scss +++ b/packages/@uppy/provider-views/src/style/uppy-SearchProvider-input.scss @@ -1,4 +1,3 @@ - .uppy-SearchProvider { display: flex; flex: 1; @@ -8,7 +7,7 @@ width: 100%; height: 100%; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-900; } } @@ -23,7 +22,7 @@ } &::-webkit-search-cancel-button { - display: none; + display: none; } } diff --git a/packages/@uppy/provider-views/types/index.d.ts b/packages/@uppy/provider-views/types/index.d.ts index f633a1a789..3930476062 100644 --- a/packages/@uppy/provider-views/types/index.d.ts +++ b/packages/@uppy/provider-views/types/index.d.ts @@ -2,19 +2,19 @@ import type { UIPlugin } from '@uppy/core' import type { Provider } from '@uppy/companion-client' interface ProviderViewOptions { - provider: Provider - viewType?: 'list' | 'grid' - showTitles?: boolean - showFilter?: boolean - showBreadcrumbs?: boolean + provider: Provider + viewType?: 'list' | 'grid' + showTitles?: boolean + showFilter?: boolean + showBreadcrumbs?: boolean } interface OnFirstRenderer { - onFirstRender: () => any + onFirstRender: () => any } declare class ProviderView { - constructor (plugin: UIPlugin & OnFirstRenderer, opts: ProviderViewOptions) + constructor(plugin: UIPlugin & OnFirstRenderer, opts: ProviderViewOptions) // @todo add other provider view methods } diff --git a/packages/@uppy/react/src/DashboardModal.d.ts b/packages/@uppy/react/src/DashboardModal.d.ts index 25c34edbd9..3e7b36bb65 100644 --- a/packages/@uppy/react/src/DashboardModal.d.ts +++ b/packages/@uppy/react/src/DashboardModal.d.ts @@ -9,7 +9,8 @@ type DashboardModalPropsInner = { ToUppyProps, // Remove the inline-only and force-overridden props 'inline' | 'onRequestCloseModal' -> & React.BaseHTMLAttributes +> & + React.BaseHTMLAttributes export type DashboardModalProps = { [K in keyof DashboardModalPropsInner]: DashboardModalPropsInner[K] diff --git a/packages/@uppy/react/src/DragDrop.d.ts b/packages/@uppy/react/src/DragDrop.d.ts index ea4bb3b4a2..55862e509c 100644 --- a/packages/@uppy/react/src/DragDrop.d.ts +++ b/packages/@uppy/react/src/DragDrop.d.ts @@ -1,7 +1,8 @@ import type { DragDropOptions } from '@uppy/drag-drop' import type { ToUppyProps } from './CommonTypes' -export type DragDropProps = ToUppyProps & React.BaseHTMLAttributes +export type DragDropProps = ToUppyProps & + React.BaseHTMLAttributes /** * React component that renders an area in which files can be dropped to be diff --git a/packages/@uppy/react/src/ProgressBar.d.ts b/packages/@uppy/react/src/ProgressBar.d.ts index 7c93657b9d..425c78b05f 100644 --- a/packages/@uppy/react/src/ProgressBar.d.ts +++ b/packages/@uppy/react/src/ProgressBar.d.ts @@ -1,7 +1,8 @@ import type { ProgressBarOptions } from '@uppy/progress-bar' import type { ToUppyProps } from './CommonTypes' -export type ProgressBarProps = ToUppyProps & React.BaseHTMLAttributes +export type ProgressBarProps = ToUppyProps & + React.BaseHTMLAttributes /** * React component that renders a progress bar at the top of the page. diff --git a/packages/@uppy/react/src/StatusBar.d.ts b/packages/@uppy/react/src/StatusBar.d.ts index 156da23219..22be1dedf7 100644 --- a/packages/@uppy/react/src/StatusBar.d.ts +++ b/packages/@uppy/react/src/StatusBar.d.ts @@ -1,7 +1,8 @@ import type { StatusBarOptions } from '@uppy/status-bar' import type { ToUppyProps } from './CommonTypes' -export type StatusBarProps = ToUppyProps & React.BaseHTMLAttributes +export type StatusBarProps = ToUppyProps & + React.BaseHTMLAttributes /** * React component that renders a status bar containing upload progress and speed, diff --git a/packages/@uppy/react/types/index.test-d.tsx b/packages/@uppy/react/types/index.test-d.tsx index 72010b2520..d408d306a9 100644 --- a/packages/@uppy/react/types/index.test-d.tsx +++ b/packages/@uppy/react/types/index.test-d.tsx @@ -1,7 +1,7 @@ -import * as React from "react" -import Uppy from "@uppy/core" -import { expectType, expectError } from "tsd" -import * as components from "../" +import * as React from 'react' +import Uppy from '@uppy/core' +import { expectType, expectError } from 'tsd' +import * as components from '../' const { useUppy } = components @@ -16,7 +16,7 @@ const uppy = new Uppy() } { - expectError() + expectError() } // inline option should be removed from proptypes because it is always overridden @@ -37,9 +37,9 @@ const uppy = new Uppy() strings: { // Text to show on the droppable area. // `%{browse}` is replaced with a link that opens the system file selection dialog. - dropHereOr: "Drop here or %{browse}", + dropHereOr: 'Drop here or %{browse}', // Used as the label for the link that opens the system file selection dialog. - browse: "browse", + browse: 'browse', }, }} /> @@ -54,7 +54,7 @@ const uppy = new Uppy() open animateOpenClose onRequestClose={() => { - alert("no") + alert('no') }} /> ) diff --git a/packages/@uppy/screen-capture/src/style.scss b/packages/@uppy/screen-capture/src/style.scss index 9a9ec6ef7b..869e770f2f 100644 --- a/packages/@uppy/screen-capture/src/style.scss +++ b/packages/@uppy/screen-capture/src/style.scss @@ -46,7 +46,7 @@ background-color: $white; border-top: 1px solid $gray-200; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-900; border-top: 1px solid $gray-800; } @@ -62,7 +62,7 @@ cursor: pointer; transition: all 0.3s; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { @include blue-border-focus--dark; } @@ -130,13 +130,20 @@ } .uppy-ScreenCapture-icon--streamActive svg { - animation: uppy-ScreenCapture-icon--blink 1s cubic-bezier(0.47, 0, 0.75, 0.72) infinite; + animation: uppy-ScreenCapture-icon--blink 1s cubic-bezier(0.47, 0, 0.75, 0.72) + infinite; } @keyframes uppy-ScreenCapture-icon--blink { - 0% { fill: $blue; } - 50% { fill: $gray-500; } - 100% { fill: $blue; } + 0% { + fill: $blue; + } + 50% { + fill: $gray-500; + } + 100% { + fill: $blue; + } } .uppy-ScreenCapture-button--video { diff --git a/packages/@uppy/screen-capture/types/index.d.ts b/packages/@uppy/screen-capture/types/index.d.ts index 5d3c6d493d..d9e56f3a04 100644 --- a/packages/@uppy/screen-capture/types/index.d.ts +++ b/packages/@uppy/screen-capture/types/index.d.ts @@ -1,22 +1,24 @@ import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core' - // https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#Properties_of_shared_screen_tracks - // TODO: use the global DisplayMediaStreamConstraints once typescript includes it by default - interface DisplayMediaStreamConstraints { - audio?: boolean | MediaTrackConstraints; - video?: boolean | (MediaTrackConstraints & { - cursor?: 'always' | 'motion' | 'never', - displaySurface?: 'application' | 'browser' | 'monitor' | 'window', - logicalSurface?: boolean - }); - } +// https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#Properties_of_shared_screen_tracks +// TODO: use the global DisplayMediaStreamConstraints once typescript includes it by default +interface DisplayMediaStreamConstraints { + audio?: boolean | MediaTrackConstraints + video?: + | boolean + | (MediaTrackConstraints & { + cursor?: 'always' | 'motion' | 'never' + displaySurface?: 'application' | 'browser' | 'monitor' | 'window' + logicalSurface?: boolean + }) +} export interface ScreenCaptureOptions extends UIPluginOptions { - target?: PluginTarget - displayMediaConstraints?: DisplayMediaStreamConstraints, - userMediaConstraints?: MediaStreamConstraints, - preferredVideoMimeType?: string - } + target?: PluginTarget + displayMediaConstraints?: DisplayMediaStreamConstraints + userMediaConstraints?: MediaStreamConstraints + preferredVideoMimeType?: string +} declare class ScreenCapture extends UIPlugin {} diff --git a/packages/@uppy/screen-capture/types/index.test-d.ts b/packages/@uppy/screen-capture/types/index.test-d.ts index a03a525b5c..6662c04c7f 100644 --- a/packages/@uppy/screen-capture/types/index.test-d.ts +++ b/packages/@uppy/screen-capture/types/index.test-d.ts @@ -12,8 +12,10 @@ new Uppy().use(ScreenCapture, { video: { displaySurface: 'window' }, }, }) -expectError(new Uppy().use(ScreenCapture, { - displayMediaConstraints: { - video: { displaySurface: 'some nonsense' }, - }, -})) +expectError( + new Uppy().use(ScreenCapture, { + displayMediaConstraints: { + video: { displaySurface: 'some nonsense' }, + }, + }), +) diff --git a/packages/@uppy/status-bar/src/style.scss b/packages/@uppy/status-bar/src/style.scss index 95c20a184f..0ea5526446 100644 --- a/packages/@uppy/status-bar/src/style.scss +++ b/packages/@uppy/status-bar/src/style.scss @@ -14,7 +14,7 @@ background-color: $white; transition: height 0.2s; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-900; } } @@ -30,12 +30,12 @@ background-color: $gray-200; content: ''; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-600; } } -.uppy-StatusBar[aria-hidden=true] { +.uppy-StatusBar[aria-hidden='true'] { height: 0; overflow-y: hidden; } @@ -56,12 +56,12 @@ color: $red; } -.uppy-StatusBar:not([aria-hidden=true]).is-waiting { +.uppy-StatusBar:not([aria-hidden='true']).is-waiting { height: 65px; background-color: $white; border-top: 1px solid $gray-200; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-900; border-top: 1px solid $gray-800; } @@ -72,20 +72,35 @@ z-index: $zIndex-2; height: 2px; background-color: $blue; - transition: background-color, width 0.3s ease-out; + transition: + background-color, + width 0.3s ease-out; &.is-indeterminate { $stripe-color: rgba(0, 0, 0, 0.3); - background-image: linear-gradient(45deg, $stripe-color 25%, transparent 25%, transparent 50%, $stripe-color 50%, $stripe-color 75%, transparent 75%, transparent); + background-image: linear-gradient( + 45deg, + $stripe-color 25%, + transparent 25%, + transparent 50%, + $stripe-color 50%, + $stripe-color 75%, + transparent 75%, + transparent + ); background-size: 64px 64px; animation: uppy-StatusBar-ProgressStripes 1s linear infinite; } } @keyframes uppy-StatusBar-ProgressStripes { - from { background-position: 0 0; } - to { background-position: 64px 0; } + from { + background-position: 0 0; + } + to { + background-position: 64px 0; + } } .uppy-StatusBar.is-preprocessing .uppy-StatusBar-progress, @@ -112,7 +127,7 @@ padding-inline-start: 15px; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; } } @@ -135,7 +150,7 @@ margin-left: 5px; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; } } @@ -148,7 +163,7 @@ line-height: 1.2; white-space: nowrap; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-400; } } @@ -192,12 +207,12 @@ padding: 0 15px; background-color: $gray-50; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-900; } } -.uppy-StatusBar:not([aria-hidden="true"]).is-waiting.has-ghosts { +.uppy-StatusBar:not([aria-hidden='true']).is-waiting.has-ghosts { flex-direction: column; height: 90px; @@ -225,7 +240,7 @@ cursor: pointer; opacity: 0.9; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { @include blue-border-focus--dark; } @@ -257,7 +272,7 @@ .uppy-StatusBar-actionBtn--disabled { opacity: 0.4; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { opacity: 0.7; } } @@ -274,7 +289,7 @@ border-radius: 8px; margin-inline-end: 6px; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { @include blue-border-focus--dark; } @@ -301,11 +316,11 @@ background-color: darken($green, 5%); } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $darkgreen; } - [data-uppy-theme="dark"] &:hover { + [data-uppy-theme='dark'] &:hover { background-color: darken($darkgreen, 5%); } } @@ -315,12 +330,15 @@ padding: 13px 22px; } -.uppy-StatusBar.is-waiting .uppy-StatusBar-actionBtn--upload.uppy-StatusBar-actionBtn--disabled:hover { +.uppy-StatusBar.is-waiting + .uppy-StatusBar-actionBtn--upload.uppy-StatusBar-actionBtn--disabled:hover { background-color: $green; cursor: not-allowed; } -[data-uppy-theme="dark"] .uppy-StatusBar.is-waiting .uppy-StatusBar-actionBtn--upload.uppy-StatusBar-actionBtn--disabled:hover { +[data-uppy-theme='dark'] + .uppy-StatusBar.is-waiting + .uppy-StatusBar-actionBtn--upload.uppy-StatusBar-actionBtn--disabled:hover { background-color: $darkgreen; } @@ -338,11 +356,11 @@ padding-bottom: 1px; border-radius: 3px; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { @include blue-border-focus--dark; } - .uppy-StatusBar.is-preprocessing &, + .uppy-StatusBar.is-preprocessing &, .uppy-StatusBar.is-postprocessing & { display: none; } @@ -355,7 +373,7 @@ line-height: 1; border-radius: 3px; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $highlight--dark; } } @@ -375,7 +393,7 @@ font-size: 14px; } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; } } diff --git a/packages/@uppy/status-bar/types/index.d.ts b/packages/@uppy/status-bar/types/index.d.ts index 845d4037d9..558344dfee 100644 --- a/packages/@uppy/status-bar/types/index.d.ts +++ b/packages/@uppy/status-bar/types/index.d.ts @@ -8,10 +8,10 @@ export interface StatusBarOptions extends UIPluginOptions { showProgressDetails?: boolean hideUploadButton?: boolean hideAfterFinish?: boolean - hideRetryButton?: boolean, - hidePauseResumeButton?: boolean, - hideCancelButton?: boolean, - doneButtonHandler?: () => void, + hideRetryButton?: boolean + hidePauseResumeButton?: boolean + hideCancelButton?: boolean + doneButtonHandler?: () => void locale?: StatusBarLocale } diff --git a/packages/@uppy/store-default/types/index.d.ts b/packages/@uppy/store-default/types/index.d.ts index 3d96f0846f..4a7ce1ee49 100644 --- a/packages/@uppy/store-default/types/index.d.ts +++ b/packages/@uppy/store-default/types/index.d.ts @@ -1,14 +1,18 @@ import type { Store } from '@uppy/utils' type State = Record -type StateChangeListener = (prevState: State, nextState: State, patch: State) => void +type StateChangeListener = ( + prevState: State, + nextState: State, + patch: State, +) => void export default class DefaultStore implements Store { - constructor () + constructor() - getState (): State + getState(): State - setState (patch: State): void + setState(patch: State): void - subscribe (listener: StateChangeListener): () => void + subscribe(listener: StateChangeListener): () => void } diff --git a/packages/@uppy/store-redux/types/index.d.ts b/packages/@uppy/store-redux/types/index.d.ts index c2906343c0..78488001ca 100644 --- a/packages/@uppy/store-redux/types/index.d.ts +++ b/packages/@uppy/store-redux/types/index.d.ts @@ -2,7 +2,11 @@ import type { Store } from '@uppy/utils' import type { Reducer, Middleware, Store as Redux } from 'redux' type State = Record -type StateChangeListener = (prevState: State, nextState: State, patch: State) => void +type StateChangeListener = ( + prevState: State, + nextState: State, + patch: State, +) => void interface ReduxStoreOptions { store: Redux @@ -11,13 +15,13 @@ interface ReduxStoreOptions { } export class ReduxStore implements Store { - constructor (opts: ReduxStoreOptions) + constructor(opts: ReduxStoreOptions) - getState (): State + getState(): State - setState (patch: State): void + setState(patch: State): void - subscribe (listener: StateChangeListener): () => void + subscribe(listener: StateChangeListener): () => void } export const reducer: Reducer diff --git a/packages/@uppy/svelte/tsconfig.json b/packages/@uppy/svelte/tsconfig.json index ae3d9b2759..4360a542dd 100644 --- a/packages/@uppy/svelte/tsconfig.json +++ b/packages/@uppy/svelte/tsconfig.json @@ -4,10 +4,6 @@ "esModuleInterop": true, "sourceMap": true }, - "include": [ - "src/**/*" - ], - "exclude": [ - "node_modules/*" - ] + "include": ["src/**/*"], + "exclude": ["node_modules/*"] } diff --git a/packages/@uppy/thumbnail-generator/types/index.d.ts b/packages/@uppy/thumbnail-generator/types/index.d.ts index 2a3046e195..6e82cdb1f1 100644 --- a/packages/@uppy/thumbnail-generator/types/index.d.ts +++ b/packages/@uppy/thumbnail-generator/types/index.d.ts @@ -1,4 +1,9 @@ -import type { IndexedObject, UIPlugin, UIPluginOptions, UppyFile } from '@uppy/core' +import type { + IndexedObject, + UIPlugin, + UIPluginOptions, + UppyFile, +} from '@uppy/core' import ThumbnailGeneratorLocale from './generatedLocale' @@ -22,7 +27,7 @@ export default ThumbnailGenerator export type ThumbnailGeneratedCallback> = ( file: UppyFile, - preview: string + preview: string, ) => void declare module '@uppy/core' { diff --git a/packages/@uppy/transloadit/types/index.d.ts b/packages/@uppy/transloadit/types/index.d.ts index 8fb52ca676..7f4841e79a 100644 --- a/packages/@uppy/transloadit/types/index.d.ts +++ b/packages/@uppy/transloadit/types/index.d.ts @@ -116,7 +116,9 @@ interface Options extends PluginOptions { export type TransloaditOptions = Options & ( | { - assemblyOptions?: AssemblyOptions | ((file?: UppyFile) => Promise | AssemblyOptions) + assemblyOptions?: + | AssemblyOptions + | ((file?: UppyFile) => Promise | AssemblyOptions) /** @deprecated use `assemblyOptions` instead */ getAssemblyOptions?: never /** @deprecated use `assemblyOptions` instead */ @@ -129,7 +131,7 @@ export type TransloaditOptions = Options & | { /** @deprecated use `assemblyOptions` instead */ getAssemblyOptions?: ( - file?: UppyFile + file?: UppyFile, ) => AssemblyOptions | Promise assemblyOptions?: never /** @deprecated use `assemblyOptions` instead */ @@ -167,14 +169,17 @@ export const COMPANION_ALLOWED_HOSTS: RegExp export type TransloaditAssemblyCreatedCallback = ( assembly: Assembly, - fileIDs: string[] + fileIDs: string[], +) => void +export type TransloaditUploadedCallback = ( + file: FileInfo, + assembly: Assembly, ) => void -export type TransloaditUploadedCallback = (file: FileInfo, assembly: Assembly) => void export type TransloaditAssemblyExecutingCallback = (assembly: Assembly) => void export type TransloaditResultCallback = ( stepName: string, result: Result, - assembly: Assembly + assembly: Assembly, ) => void export type TransloaditCompleteCallback = (assembly: Assembly) => void diff --git a/packages/@uppy/transloadit/types/index.test-d.ts b/packages/@uppy/transloadit/types/index.test-d.ts index 9e607092a3..5cd5d5b5d0 100644 --- a/packages/@uppy/transloadit/types/index.test-d.ts +++ b/packages/@uppy/transloadit/types/index.test-d.ts @@ -15,7 +15,7 @@ const validParams = { { const uppy = new Uppy() uppy.use(Transloadit, { - getAssemblyOptions (file) { + getAssemblyOptions(file) { expectType(file) return { params: validParams } }, @@ -38,7 +38,7 @@ const validParams = { { const uppy = new Uppy() uppy.use(Transloadit, { - async assemblyOptions (file) { + async assemblyOptions(file) { expectType(file) return { params: validParams } }, @@ -56,7 +56,7 @@ const validParams = { const uppy = new Uppy() expectError( uppy.use(Transloadit, { - getAssemblyOptions () { + getAssemblyOptions() { return { params: validParams } }, assemblyOptions: { params: validParams }, @@ -77,8 +77,12 @@ const validParams = { { const uppy = new Uppy() // must be bools - expectError(uppy.use(Transloadit, { waitForEncoding: null, params: validParams })) - expectError(uppy.use(Transloadit, { waitForMetadata: null, params: validParams })) + expectError( + uppy.use(Transloadit, { waitForEncoding: null, params: validParams }), + ) + expectError( + uppy.use(Transloadit, { waitForMetadata: null, params: validParams }), + ) } { diff --git a/packages/@uppy/tus/types/index.d.ts b/packages/@uppy/tus/types/index.d.ts index f741ada011..a3a431f3c5 100644 --- a/packages/@uppy/tus/types/index.d.ts +++ b/packages/@uppy/tus/types/index.d.ts @@ -1,29 +1,42 @@ import type { PluginOptions, BasePlugin, UppyFile } from '@uppy/core' import type { UploadOptions, HttpRequest } from 'tus-js-client' -type TusUploadOptions = Pick> +type TusUploadOptions = Pick< + UploadOptions, + Exclude< + keyof UploadOptions, + | 'fingerprint' + | 'metadata' + | 'onBeforeRequest' + | 'onProgress' + | 'onChunkComplete' + | 'onShouldRetry' + | 'onSuccess' + | 'onError' + | 'uploadUrl' + | 'uploadSize' + > +> -type Next = (err: Error | undefined, retryAttempt?: number, options?: TusOptions) => boolean +type Next = ( + err: Error | undefined, + retryAttempt?: number, + options?: TusOptions, +) => boolean export interface TusOptions extends PluginOptions, TusUploadOptions { - allowedMetaFields?: string[] | null - limit?: number - useFastRemoteRetry?: boolean - withCredentials?: boolean - onShouldRetry?: (err: Error | undefined, retryAttempt: number, options: TusOptions, next: Next) => boolean - onBeforeRequest?: (req: HttpRequest, file: UppyFile) => Promise - } + allowedMetaFields?: string[] | null + limit?: number + useFastRemoteRetry?: boolean + withCredentials?: boolean + onShouldRetry?: ( + err: Error | undefined, + retryAttempt: number, + options: TusOptions, + next: Next, + ) => boolean + onBeforeRequest?: (req: HttpRequest, file: UppyFile) => Promise +} declare class Tus extends BasePlugin {} diff --git a/packages/@uppy/unsplash/types/index.d.ts b/packages/@uppy/unsplash/types/index.d.ts index 00066d9f65..978ca1c5fd 100644 --- a/packages/@uppy/unsplash/types/index.d.ts +++ b/packages/@uppy/unsplash/types/index.d.ts @@ -2,8 +2,8 @@ import type { RequestClientOptions } from '@uppy/companion-client' import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core' interface UnsplashOptions extends UIPluginOptions, RequestClientOptions { - target?: PluginTarget - title?: string + target?: PluginTarget + title?: string } declare class Unsplash extends UIPlugin {} diff --git a/packages/@uppy/url/src/style.scss b/packages/@uppy/url/src/style.scss index c1ccdddd2f..6f43811f24 100644 --- a/packages/@uppy/url/src/style.scss +++ b/packages/@uppy/url/src/style.scss @@ -10,7 +10,7 @@ width: 100%; height: 100%; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { background-color: $gray-900; } } diff --git a/packages/@uppy/url/types/index.d.ts b/packages/@uppy/url/types/index.d.ts index e8446e9a73..fa9734c88c 100644 --- a/packages/@uppy/url/types/index.d.ts +++ b/packages/@uppy/url/types/index.d.ts @@ -1,15 +1,23 @@ import type { RequestClientOptions } from '@uppy/companion-client' -import type { IndexedObject, PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core' +import type { + IndexedObject, + PluginTarget, + UIPlugin, + UIPluginOptions, +} from '@uppy/core' import UrlLocale from './generatedLocale' export interface UrlOptions extends UIPluginOptions, RequestClientOptions { - target?: PluginTarget - title?: string - locale?: UrlLocale + target?: PluginTarget + title?: string + locale?: UrlLocale } declare class Url extends UIPlugin { - public addFile(url: string, meta?: IndexedObject): undefined | string | never + public addFile( + url: string, + meta?: IndexedObject, + ): undefined | string | never } export default Url diff --git a/packages/@uppy/url/types/index.test-d.ts b/packages/@uppy/url/types/index.test-d.ts index e703d97f22..b21c2584bb 100644 --- a/packages/@uppy/url/types/index.test-d.ts +++ b/packages/@uppy/url/types/index.test-d.ts @@ -4,19 +4,21 @@ import Url from '..' { const uppy = new Uppy() // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - uppy.use(Url, { - companionUrl: '', - companionCookiesRule: 'same-origin', - target: 'body', - title: 'title', - locale: { - strings: { - import: '', - enterUrlToImport: '', - failedToFetch: '', - enterCorrectUrl: '', + uppy + .use(Url, { + companionUrl: '', + companionCookiesRule: 'same-origin', + target: 'body', + title: 'title', + locale: { + strings: { + import: '', + enterUrlToImport: '', + failedToFetch: '', + enterCorrectUrl: '', + }, }, - }, - }) - .getPlugin('Url')!.addFile('https://via.placeholder.com/150') + }) + .getPlugin('Url')! + .addFile('https://via.placeholder.com/150') } diff --git a/packages/@uppy/utils/src/microtip.scss b/packages/@uppy/utils/src/microtip.scss index 1d952cea85..1e0a291e15 100644 --- a/packages/@uppy/utils/src/microtip.scss +++ b/packages/@uppy/utils/src/microtip.scss @@ -17,12 +17,12 @@ [1] Base Styles ------------------------------------------------- */ -.uppy-Root [aria-label][role~="tooltip"] { +.uppy-Root [aria-label][role~='tooltip'] { position: relative; } -.uppy-Root [aria-label][role~="tooltip"]::before, -.uppy-Root [aria-label][role~="tooltip"]::after { +.uppy-Root [aria-label][role~='tooltip']::before, +.uppy-Root [aria-label][role~='tooltip']::after { position: absolute; z-index: 10; box-sizing: border-box; @@ -31,17 +31,19 @@ -webkit-backface-visibility: hidden; backface-visibility: hidden; opacity: 0; - transition: all var(--microtip-transition-duration, 0.18s) var(--microtip-transition-easing, ease-in-out) var(--microtip-transition-delay, 0s); + transition: all var(--microtip-transition-duration, 0.18s) + var(--microtip-transition-easing, ease-in-out) + var(--microtip-transition-delay, 0s); pointer-events: none; will-change: transform; } -.uppy-Root [aria-label][role~="tooltip"]::before { +.uppy-Root [aria-label][role~='tooltip']::before { background-size: 100% auto !important; - content: ""; + content: ''; } -.uppy-Root [aria-label][role~="tooltip"]::after { +.uppy-Root [aria-label][role~='tooltip']::after { box-sizing: content-box; padding: 0.5em 1em; color: #fff; @@ -54,10 +56,10 @@ content: attr(aria-label); } -.uppy-Root [aria-label][role~="tooltip"]:hover::before, -.uppy-Root [aria-label][role~="tooltip"]:hover::after, -.uppy-Root [aria-label][role~="tooltip"]:focus::before, -.uppy-Root [aria-label][role~="tooltip"]:focus::after { +.uppy-Root [aria-label][role~='tooltip']:hover::before, +.uppy-Root [aria-label][role~='tooltip']:hover::after, +.uppy-Root [aria-label][role~='tooltip']:focus::before, +.uppy-Root [aria-label][role~='tooltip']:focus::after { opacity: 1; pointer-events: auto; } @@ -66,59 +68,60 @@ [2] Position Modifiers ------------------------------------------------- */ -.uppy-Root [role~="tooltip"][data-microtip-position|="top"]::before { +.uppy-Root [role~='tooltip'][data-microtip-position|='top']::before { bottom: 100%; left: 50%; width: 18px; height: 6px; margin-bottom: 5px; - background: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba%2817,%2017,%2017,%200.9%29%22%20transform%3D%22rotate%280%29%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E") no-repeat; + background: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba%2817,%2017,%2017,%200.9%29%22%20transform%3D%22rotate%280%29%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E') + no-repeat; transform: translate3d(-50%, 0, 0); } -.uppy-Root [role~="tooltip"][data-microtip-position|="top"]::after { +.uppy-Root [role~='tooltip'][data-microtip-position|='top']::after { bottom: 100%; left: 50%; margin-bottom: 11px; transform: translate3d(-50%, 0, 0); } -.uppy-Root [role~="tooltip"][data-microtip-position|="top"]:hover::before { +.uppy-Root [role~='tooltip'][data-microtip-position|='top']:hover::before { transform: translate3d(-50%, -5px, 0); } -.uppy-Root [role~="tooltip"][data-microtip-position="top"]:hover::after { +.uppy-Root [role~='tooltip'][data-microtip-position='top']:hover::after { transform: translate3d(-50%, -5px, 0); } /* ------------------------------------------------ [2.1] Top Left ------------------------------------------------- */ -.uppy-Root [role~="tooltip"][data-microtip-position="top-left"]::after { +.uppy-Root [role~='tooltip'][data-microtip-position='top-left']::after { bottom: 100%; transform: translate3d(calc(-100% + 16px), 0, 0); } -.uppy-Root [role~="tooltip"][data-microtip-position="top-left"]:hover::after { +.uppy-Root [role~='tooltip'][data-microtip-position='top-left']:hover::after { transform: translate3d(calc(-100% + 16px), -5px, 0); } /* ------------------------------------------------ [2.2] Top Right ------------------------------------------------- */ -.uppy-Root [role~="tooltip"][data-microtip-position="top-right"]::after { +.uppy-Root [role~='tooltip'][data-microtip-position='top-right']::after { bottom: 100%; transform: translate3d(calc(0% + -16px), 0, 0); } -.uppy-Root [role~="tooltip"][data-microtip-position="top-right"]:hover::after { +.uppy-Root [role~='tooltip'][data-microtip-position='top-right']:hover::after { transform: translate3d(calc(0% + -16px), -5px, 0); } /* ------------------------------------------------ [2.3] Bottom ------------------------------------------------- */ -.uppy-Root [role~="tooltip"][data-microtip-position|="bottom"]::before { +.uppy-Root [role~='tooltip'][data-microtip-position|='bottom']::before { top: 100%; bottom: auto; left: 50%; @@ -126,54 +129,57 @@ height: 6px; margin-top: 5px; margin-bottom: 0; - background: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba%2817,%2017,%2017,%200.9%29%22%20transform%3D%22rotate%28180%2018%206%29%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E") no-repeat; + background: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba%2817,%2017,%2017,%200.9%29%22%20transform%3D%22rotate%28180%2018%206%29%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E') + no-repeat; transform: translate3d(-50%, -10px, 0); } -.uppy-Root [role~="tooltip"][data-microtip-position|="bottom"]::after { +.uppy-Root [role~='tooltip'][data-microtip-position|='bottom']::after { top: 100%; left: 50%; margin-top: 11px; transform: translate3d(-50%, -10px, 0); } -.uppy-Root [role~="tooltip"][data-microtip-position|="bottom"]:hover::before { +.uppy-Root [role~='tooltip'][data-microtip-position|='bottom']:hover::before { transform: translate3d(-50%, 0, 0); } -.uppy-Root [role~="tooltip"][data-microtip-position="bottom"]:hover::after { +.uppy-Root [role~='tooltip'][data-microtip-position='bottom']:hover::after { transform: translate3d(-50%, 0, 0); } /* ------------------------------------------------ [2.4] Bottom Left ------------------------------------------------- */ -.uppy-Root [role~="tooltip"][data-microtip-position="bottom-left"]::after { +.uppy-Root [role~='tooltip'][data-microtip-position='bottom-left']::after { top: 100%; transform: translate3d(calc(-100% + 16px), -10px, 0); } -.uppy-Root [role~="tooltip"][data-microtip-position="bottom-left"]:hover::after { +.uppy-Root + [role~='tooltip'][data-microtip-position='bottom-left']:hover::after { transform: translate3d(calc(-100% + 16px), 0, 0); } /* ------------------------------------------------ [2.5] Bottom Right ------------------------------------------------- */ -.uppy-Root [role~="tooltip"][data-microtip-position="bottom-right"]::after { +.uppy-Root [role~='tooltip'][data-microtip-position='bottom-right']::after { top: 100%; transform: translate3d(calc(0% + -16px), -10px, 0); } -.uppy-Root [role~="tooltip"][data-microtip-position="bottom-right"]:hover::after { +.uppy-Root + [role~='tooltip'][data-microtip-position='bottom-right']:hover::after { transform: translate3d(calc(0% + -16px), 0, 0); } /* ------------------------------------------------ [2.6] Left ------------------------------------------------- */ -.uppy-Root [role~="tooltip"][data-microtip-position="left"]::before, -.uppy-Root [role~="tooltip"][data-microtip-position="left"]::after { +.uppy-Root [role~='tooltip'][data-microtip-position='left']::before, +.uppy-Root [role~='tooltip'][data-microtip-position='left']::after { top: 50%; right: 100%; bottom: auto; @@ -181,65 +187,67 @@ transform: translate3d(10px, -50%, 0); } -.uppy-Root [role~="tooltip"][data-microtip-position="left"]::before { +.uppy-Root [role~='tooltip'][data-microtip-position='left']::before { width: 6px; height: 18px; margin-right: 5px; margin-bottom: 0; - background: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba%2817,%2017,%2017,%200.9%29%22%20transform%3D%22rotate%28-90%2018%2018%29%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E") no-repeat; + background: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba%2817,%2017,%2017,%200.9%29%22%20transform%3D%22rotate%28-90%2018%2018%29%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E') + no-repeat; } -.uppy-Root [role~="tooltip"][data-microtip-position="left"]::after { +.uppy-Root [role~='tooltip'][data-microtip-position='left']::after { margin-right: 11px; } -.uppy-Root [role~="tooltip"][data-microtip-position="left"]:hover::before, -.uppy-Root [role~="tooltip"][data-microtip-position="left"]:hover::after { +.uppy-Root [role~='tooltip'][data-microtip-position='left']:hover::before, +.uppy-Root [role~='tooltip'][data-microtip-position='left']:hover::after { transform: translate3d(0, -50%, 0); } /* ------------------------------------------------ [2.7] Right ------------------------------------------------- */ -.uppy-Root [role~="tooltip"][data-microtip-position="right"]::before, -.uppy-Root [role~="tooltip"][data-microtip-position="right"]::after { +.uppy-Root [role~='tooltip'][data-microtip-position='right']::before, +.uppy-Root [role~='tooltip'][data-microtip-position='right']::after { top: 50%; bottom: auto; left: 100%; transform: translate3d(-10px, -50%, 0); } -.uppy-Root [role~="tooltip"][data-microtip-position="right"]::before { +.uppy-Root [role~='tooltip'][data-microtip-position='right']::before { width: 6px; height: 18px; margin-bottom: 0; margin-left: 5px; - background: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba%2817,%2017,%2017,%200.9%29%22%20transform%3D%22rotate%2890%206%206%29%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E") no-repeat; + background: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba%2817,%2017,%2017,%200.9%29%22%20transform%3D%22rotate%2890%206%206%29%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E') + no-repeat; } -.uppy-Root [role~="tooltip"][data-microtip-position="right"]::after { +.uppy-Root [role~='tooltip'][data-microtip-position='right']::after { margin-left: 11px; } -.uppy-Root [role~="tooltip"][data-microtip-position="right"]:hover::before, -.uppy-Root [role~="tooltip"][data-microtip-position="right"]:hover::after { +.uppy-Root [role~='tooltip'][data-microtip-position='right']:hover::before, +.uppy-Root [role~='tooltip'][data-microtip-position='right']:hover::after { transform: translate3d(0, -50%, 0); } /* ------------------------------------------------ [3] Size ------------------------------------------------- */ -.uppy-Root [role~="tooltip"][data-microtip-size="small"]::after { +.uppy-Root [role~='tooltip'][data-microtip-size='small']::after { width: 80px; white-space: initial; } -.uppy-Root [role~="tooltip"][data-microtip-size="medium"]::after { +.uppy-Root [role~='tooltip'][data-microtip-size='medium']::after { width: 150px; white-space: initial; } -.uppy-Root [role~="tooltip"][data-microtip-size="large"]::after { +.uppy-Root [role~='tooltip'][data-microtip-size='large']::after { width: 260px; white-space: initial; } diff --git a/packages/@uppy/utils/types/index.d.ts b/packages/@uppy/utils/types/index.d.ts index e1ad9276a2..b216156497 100644 --- a/packages/@uppy/utils/types/index.d.ts +++ b/packages/@uppy/utils/types/index.d.ts @@ -9,11 +9,11 @@ declare module '@uppy/utils/lib/Translator' { } class Translator { - constructor (opts: Translator.Locale | Translator.Locale[]) + constructor(opts: Translator.Locale | Translator.Locale[]) - translate (key: string, options: Record): string + translate(key: string, options: Record): string - translateArray (key: string, options: Record): any[] + translateArray(key: string, options: Record): any[] } export default Translator @@ -29,11 +29,11 @@ declare module '@uppy/utils/lib/EventManager' { } class EventManager { - constructor (emitter: EventManager.Emitter) + constructor(emitter: EventManager.Emitter) - on (event: string, handler: EventManager.EventHandler): void + on(event: string, handler: EventManager.EventHandler): void - remove (): void + remove(): void } export default EventManager @@ -41,11 +41,11 @@ declare module '@uppy/utils/lib/EventManager' { declare module '@uppy/utils/lib/ProgressTimeout' { class ProgressTimeout { - constructor (timeout: number, timeoutHandler: () => void) + constructor(timeout: number, timeoutHandler: () => void) - progress (): void + progress(): void - done (): void + done(): void } export default ProgressTimeout } @@ -58,8 +58,8 @@ declare module '@uppy/utils/lib/RateLimitedQueue' { abortOn(signal: AbortSignal): this } export type QueueEntry = { - abort: () => void, - done: () => void, + abort: () => void + done: () => void } export type QueueOptions = { priority?: number @@ -73,7 +73,7 @@ declare module '@uppy/utils/lib/RateLimitedQueue' { run( fn: () => RateLimitedQueue.AbortFunction, - queueOptions?: RateLimitedQueue.QueueOptions + queueOptions?: RateLimitedQueue.QueueOptions, ): RateLimitedQueue.QueueEntry rateLimit(duration: number): void @@ -84,7 +84,7 @@ declare module '@uppy/utils/lib/RateLimitedQueue' { wrapPromiseFunction( fn: () => (...args: any[]) => Promise, - queueOptions?: RateLimitedQueue.QueueOptions + queueOptions?: RateLimitedQueue.QueueOptions, ): (...args: any[]) => RateLimitedQueue.AbortablePromise } @@ -92,26 +92,26 @@ declare module '@uppy/utils/lib/RateLimitedQueue' { } declare module '@uppy/utils/lib/canvasToBlob' { - function canvasToBlob ( + function canvasToBlob( canvas: HTMLCanvasElement, type: string, - quality?: number + quality?: number, ): Promise export default canvasToBlob } declare module '@uppy/utils/lib/dataURItoBlob' { - function dataURItoBlob ( + function dataURItoBlob( dataURI: string, - opts: { mimeType?: string; name?: string } + opts: { mimeType?: string; name?: string }, ): Blob export default dataURItoBlob } declare module '@uppy/utils/lib/dataURItoFile' { - function dataURItoFile ( + function dataURItoFile( dataURI: string, - opts: { mimeType?: string; name?: string } + opts: { mimeType?: string; name?: string }, ): File export default dataURItoFile } @@ -125,33 +125,33 @@ declare module '@uppy/utils/lib/emitSocketProgress' { bytesTotal: number } - function emitSocketProgress ( + function emitSocketProgress( uploader: unknown, progressData: ProgressData, - file: UppyFile + file: UppyFile, ): void export default emitSocketProgress } declare module '@uppy/utils/lib/findAllDOMElements' { - function findAllDOMElements (element: string | HTMLElement): HTMLElement[] + function findAllDOMElements(element: string | HTMLElement): HTMLElement[] export default findAllDOMElements } declare module '@uppy/utils/lib/findDOMElement' { - function findDOMElement (element: string | HTMLElement): HTMLElement | null + function findDOMElement(element: string | HTMLElement): HTMLElement | null export default findDOMElement } declare module '@uppy/utils/lib/generateFileID' { import type { UppyFile } from '@uppy/utils' - function generateFileID (file: UppyFile): string + function generateFileID(file: UppyFile): string export default generateFileID } declare module '@uppy/utils/lib/getBytesRemaining' { - function getBytesRemaining (progress: { + function getBytesRemaining(progress: { bytesTotal: number bytesUploaded: number }): number @@ -159,36 +159,37 @@ declare module '@uppy/utils/lib/getBytesRemaining' { } declare module '@uppy/utils/lib/getETA' { - function getETA (progress: unknown): number + function getETA(progress: unknown): number export default getETA } declare module '@uppy/utils/lib/getFileNameAndExtension' { - function getFileNameAndExtension( - filename: string - ): { name: string, extension: string | undefined } + function getFileNameAndExtension(filename: string): { + name: string + extension: string | undefined + } export default getFileNameAndExtension } declare module '@uppy/utils/lib/getFileType' { import type { UppyFile } from '@uppy/utils' - function getFileType (file: UppyFile): string + function getFileType(file: UppyFile): string export default getFileType } declare module '@uppy/utils/lib/getFileTypeExtension' { - function getFileTypeExtension (mime: string): string + function getFileTypeExtension(mime: string): string export default getFileTypeExtension } declare module '@uppy/utils/lib/getSocketHost' { - function getSocketHost (url: string): string + function getSocketHost(url: string): string export default getSocketHost } declare module '@uppy/utils/lib/getSpeed' { - function getSpeed (progress: { + function getSpeed(progress: { bytesUploaded: number uploadStarted: number }): number @@ -196,54 +197,54 @@ declare module '@uppy/utils/lib/getSpeed' { } declare module '@uppy/utils/lib/getTimeStamp' { - function getTimeStamp (): string + function getTimeStamp(): string export default getTimeStamp } declare module '@uppy/utils/lib/isDOMElement' { - function isDOMElement (element: any): boolean + function isDOMElement(element: any): boolean export default isDOMElement } declare module '@uppy/utils/lib/isObjectURL' { - function isObjectURL (url: string): boolean + function isObjectURL(url: string): boolean export default isObjectURL } declare module '@uppy/utils/lib/isDragDropSupported' { - function isDragDropSupported (): boolean + function isDragDropSupported(): boolean export default isDragDropSupported } declare module '@uppy/utils/lib/isPreviewSupported' { - function isPreviewSupported (mime: string): boolean + function isPreviewSupported(mime: string): boolean export default isPreviewSupported } declare module '@uppy/utils/lib/isTouchDevice' { - function isTouchDevice (): boolean + function isTouchDevice(): boolean export default isTouchDevice } declare module '@uppy/utils/lib/prettyETA' { - function prettyETA (seconds: number): string + function prettyETA(seconds: number): string export default prettyETA } declare module '@uppy/utils/lib/secondsToTime' { - function secondsToTime (seconds: number): string + function secondsToTime(seconds: number): string export default secondsToTime } declare module '@uppy/utils/lib/settle' { - function settle ( - promises: Promise[] + function settle( + promises: Promise[], ): Promise<{ successful: T[]; failed: any[] }> export default settle } declare module '@uppy/utils/lib/toArray' { - function toArray (list: any): any[] + function toArray(list: any): any[] export default toArray } @@ -252,25 +253,27 @@ declare module '@uppy/utils/lib/AbortController' { export const AbortController: typeof globalThis.AbortController export const AbortSignal: typeof globalThis.AbortSignal - export function createAbortError(message?: string, options?: ErrorOptions): DOMException + export function createAbortError( + message?: string, + options?: ErrorOptions, + ): DOMException } declare module '@uppy/utils/lib/getDroppedFiles' { - function getDroppedFiles ( + function getDroppedFiles( dataTransfer: DataTransfer, - options?: Record + options?: Record, ): Promise export default getDroppedFiles } declare module '@uppy/utils/lib/getTextDirection' { - function getTextDirection (element: Node): string|undefined + function getTextDirection(element: Node): string | undefined export default getTextDirection } declare module '@uppy/utils/lib/isNetworkError' { - export default function isNetworkError (xhr: any): boolean - + export default function isNetworkError(xhr: any): boolean } declare module '@uppy/utils/lib/NetworkError' { @@ -281,7 +284,7 @@ declare module '@uppy/utils/lib/NetworkError' { readonly request?: XMLHttpRequest - constructor (error: any, xhr?: XMLHttpRequest) + constructor(error: any, xhr?: XMLHttpRequest) } export default NetworkError @@ -293,20 +296,27 @@ declare module '@uppy/utils/lib/FOCUSABLE_ELEMENTS' { } declare module '@uppy/utils/lib/truncateString' { - export default function truncateString (string: string, maxLength: number): string + export default function truncateString( + string: string, + maxLength: number, + ): string } declare module '@uppy/utils/lib/remoteFileObjToLocal' { - export default function remoteFileObjToLocal (file: object): Record + export default function remoteFileObjToLocal( + file: object, + ): Record } declare module '@uppy/utils/lib/fetchWithNetworkError' { - export default function fetchWithNetworkError (...options: unknown[]): Promise + export default function fetchWithNetworkError( + ...options: unknown[] + ): Promise } declare module '@uppy/utils/lib/ErrorWithCause' { interface ErrorOptions { - cause?: unknown; + cause?: unknown } export default class ErrorWithCause extends Error { @@ -314,16 +324,19 @@ declare module '@uppy/utils/lib/ErrorWithCause' { isNetworkError?: true - constructor (message: string, options?: ErrorOptions) + constructor(message: string, options?: ErrorOptions) } } declare module '@uppy/utils/lib/delay' { - export default function delay (ms:number, opts?: {signal: AbortSignal}): Promise + export default function delay( + ms: number, + opts?: { signal: AbortSignal }, + ): Promise } declare module '@uppy/utils/lib/hasProperty' { - export default function has (object: any, key: string): boolean + export default function has(object: any, key: string): boolean } declare module '@uppy/utils/lib/mimeTypes' { @@ -337,7 +350,7 @@ declare module '@uppy/utils' { [key: number]: T } export type InternalMetadata = { name: string; type?: string } - export interface FileProgress { + export interface FileProgress { uploadStarted: number | null uploadComplete: boolean percentage: number @@ -346,7 +359,7 @@ declare module '@uppy/utils' { } export interface UppyFile< TMeta = IndexedObject, - TBody = IndexedObject + TBody = IndexedObject, > { data: Blob | File extension: string @@ -372,8 +385,8 @@ declare module '@uppy/utils' { } } export interface Store { - getState (): Record - setState (patch: Record): void - subscribe (listener: any): () => void + getState(): Record + setState(patch: Record): void + subscribe(listener: any): () => void } } diff --git a/packages/@uppy/vue/types/dashboard-modal.d.ts b/packages/@uppy/vue/types/dashboard-modal.d.ts index ff23025e48..553219ee60 100644 --- a/packages/@uppy/vue/types/dashboard-modal.d.ts +++ b/packages/@uppy/vue/types/dashboard-modal.d.ts @@ -3,17 +3,23 @@ import type { Uppy, UIPlugin, BasePlugin } from '@uppy/core' import type DashboardPlugin from '@uppy/dashboard' interface Data { - plugin: DashboardPlugin; + plugin: DashboardPlugin } interface Props { - uppy: Uppy; - props: Record; - plugins: Array - open: boolean; + uppy: Uppy + props: Record + plugins: Array + open: boolean } interface Methods { - installPlugin(): void; - uninstallPlugin(uppy: Uppy): void; + installPlugin(): void + uninstallPlugin(uppy: Uppy): void } -declare const exports: import('vue/types/vue').ExtendedVue +declare const exports: import('vue/types/vue').ExtendedVue< + Vue, + Data, + Methods, + unknown, + Props +> export default exports diff --git a/packages/@uppy/vue/types/dashboard.d.ts b/packages/@uppy/vue/types/dashboard.d.ts index e22aa10989..e108769ce5 100644 --- a/packages/@uppy/vue/types/dashboard.d.ts +++ b/packages/@uppy/vue/types/dashboard.d.ts @@ -3,16 +3,22 @@ import type { Uppy, UIPlugin, BasePlugin } from '@uppy/core' import type DashboardPlugin from '@uppy/dashboard' interface Data { - plugin: DashboardPlugin; + plugin: DashboardPlugin } interface Props { - uppy: Uppy; - props: Record; - plugins: Array + uppy: Uppy + props: Record + plugins: Array } interface Methods { - installPlugin(): void; - uninstallPlugin(uppy: Uppy): void; + installPlugin(): void + uninstallPlugin(uppy: Uppy): void } -declare const exports: import('vue/types/vue').ExtendedVue +declare const exports: import('vue/types/vue').ExtendedVue< + Vue, + Data, + Methods, + unknown, + Props +> export default exports diff --git a/packages/@uppy/vue/types/drag-drop.d.ts b/packages/@uppy/vue/types/drag-drop.d.ts index 76968feff2..929ba0989e 100644 --- a/packages/@uppy/vue/types/drag-drop.d.ts +++ b/packages/@uppy/vue/types/drag-drop.d.ts @@ -2,16 +2,22 @@ import Vue from 'vue' import type { Uppy, UIPlugin, BasePlugin } from '@uppy/core' interface Data { - plugin: UIPlugin | BasePlugin; + plugin: UIPlugin | BasePlugin } interface Props { - uppy: Uppy; - props: Record; + uppy: Uppy + props: Record } interface Methods { - installPlugin(): void; - uninstallPlugin(uppy: Uppy): void; + installPlugin(): void + uninstallPlugin(uppy: Uppy): void } -declare const exports: import('vue/types/vue').ExtendedVue +declare const exports: import('vue/types/vue').ExtendedVue< + Vue, + Data, + Methods, + unknown, + Props +> export default exports diff --git a/packages/@uppy/vue/types/file-input.d.ts b/packages/@uppy/vue/types/file-input.d.ts index e74e08a73a..956f6b7a77 100644 --- a/packages/@uppy/vue/types/file-input.d.ts +++ b/packages/@uppy/vue/types/file-input.d.ts @@ -2,15 +2,21 @@ import Vue from 'vue' import type { Uppy, UIPlugin, BasePlugin } from '@uppy/core' interface Data { - plugin: UIPlugin | BasePlugin; + plugin: UIPlugin | BasePlugin } interface Props { - uppy: Uppy; - props: Record; + uppy: Uppy + props: Record } interface Methods { - installPlugin(): void; - uninstallPlugin(uppy: Uppy): void; + installPlugin(): void + uninstallPlugin(uppy: Uppy): void } -declare const exports: import('vue/types/vue').ExtendedVue +declare const exports: import('vue/types/vue').ExtendedVue< + Vue, + Data, + Methods, + unknown, + Props +> export default exports diff --git a/packages/@uppy/vue/types/progress-bar.d.ts b/packages/@uppy/vue/types/progress-bar.d.ts index e74e08a73a..956f6b7a77 100644 --- a/packages/@uppy/vue/types/progress-bar.d.ts +++ b/packages/@uppy/vue/types/progress-bar.d.ts @@ -2,15 +2,21 @@ import Vue from 'vue' import type { Uppy, UIPlugin, BasePlugin } from '@uppy/core' interface Data { - plugin: UIPlugin | BasePlugin; + plugin: UIPlugin | BasePlugin } interface Props { - uppy: Uppy; - props: Record; + uppy: Uppy + props: Record } interface Methods { - installPlugin(): void; - uninstallPlugin(uppy: Uppy): void; + installPlugin(): void + uninstallPlugin(uppy: Uppy): void } -declare const exports: import('vue/types/vue').ExtendedVue +declare const exports: import('vue/types/vue').ExtendedVue< + Vue, + Data, + Methods, + unknown, + Props +> export default exports diff --git a/packages/@uppy/vue/types/status-bar.d.ts b/packages/@uppy/vue/types/status-bar.d.ts index e74e08a73a..956f6b7a77 100644 --- a/packages/@uppy/vue/types/status-bar.d.ts +++ b/packages/@uppy/vue/types/status-bar.d.ts @@ -2,15 +2,21 @@ import Vue from 'vue' import type { Uppy, UIPlugin, BasePlugin } from '@uppy/core' interface Data { - plugin: UIPlugin | BasePlugin; + plugin: UIPlugin | BasePlugin } interface Props { - uppy: Uppy; - props: Record; + uppy: Uppy + props: Record } interface Methods { - installPlugin(): void; - uninstallPlugin(uppy: Uppy): void; + installPlugin(): void + uninstallPlugin(uppy: Uppy): void } -declare const exports: import('vue/types/vue').ExtendedVue +declare const exports: import('vue/types/vue').ExtendedVue< + Vue, + Data, + Methods, + unknown, + Props +> export default exports diff --git a/packages/@uppy/webcam/src/style.scss b/packages/@uppy/webcam/src/style.scss index 86c70e481f..34dc60ea3c 100644 --- a/packages/@uppy/webcam/src/style.scss +++ b/packages/@uppy/webcam/src/style.scss @@ -68,8 +68,12 @@ text-overflow: ellipsis; background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23757575%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E'); background-repeat: no-repeat; - background-position: right 0.4em top 50%, 0 0; - background-size: 0.65em auto, 100%; + background-position: + right 0.4em top 50%, + 0 0; + background-size: + 0.65em auto, + 100%; border: 1px solid $gray-600; .uppy-size--lg & { @@ -97,7 +101,8 @@ flex-grow: 0; width: 25%; color: $gray-600; - font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; + font-family: SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', + 'Courier New', monospace; text-align: right; } @@ -120,7 +125,7 @@ background-color: darken($red, 5%); } - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { @include blue-border-focus--dark; } } @@ -191,7 +196,7 @@ line-height: 1.35; text-align: center; - [data-uppy-theme="dark"] & { + [data-uppy-theme='dark'] & { color: $gray-200; } } diff --git a/packages/@uppy/webcam/types/index.d.ts b/packages/@uppy/webcam/types/index.d.ts index 88028dfde2..1fc6c987c0 100644 --- a/packages/@uppy/webcam/types/index.d.ts +++ b/packages/@uppy/webcam/types/index.d.ts @@ -1,30 +1,26 @@ import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core' import WebcamLocale from './generatedLocale' -export type WebcamMode = - | 'video-audio' - | 'video-only' - | 'audio-only' - | 'picture' +export type WebcamMode = 'video-audio' | 'video-only' | 'audio-only' | 'picture' export interface WebcamOptions extends UIPluginOptions { - target?: PluginTarget - onBeforeSnapshot?: () => Promise - countdown?: number | boolean - mirror?: boolean - /** - * @deprecated Use `videoConstraints.facingMode` instead. - */ - facingMode?: string - showVideoSourceDropdown?: boolean - modes?: WebcamMode[] - locale?: WebcamLocale - title?: string - videoConstraints?: MediaTrackConstraints - showRecordingLength?: boolean - preferredImageMimeType?: string - preferredVideoMimeType?: string - mobileNativeCamera?: boolean + target?: PluginTarget + onBeforeSnapshot?: () => Promise + countdown?: number | boolean + mirror?: boolean + /** + * @deprecated Use `videoConstraints.facingMode` instead. + */ + facingMode?: string + showVideoSourceDropdown?: boolean + modes?: WebcamMode[] + locale?: WebcamLocale + title?: string + videoConstraints?: MediaTrackConstraints + showRecordingLength?: boolean + preferredImageMimeType?: string + preferredVideoMimeType?: string + mobileNativeCamera?: boolean } declare class Webcam extends UIPlugin {} diff --git a/packages/@uppy/webcam/types/index.test-d.ts b/packages/@uppy/webcam/types/index.test-d.ts index b51e58ea22..c9c89daa4b 100644 --- a/packages/@uppy/webcam/types/index.test-d.ts +++ b/packages/@uppy/webcam/types/index.test-d.ts @@ -14,9 +14,11 @@ new Uppy().use(Webcam, { }, }) -expectError(new Uppy().use(Webcam, { - modes: ['video-only'], - videoConstraints: { - width: 'not a number har har', - }, -})) +expectError( + new Uppy().use(Webcam, { + modes: ['video-only'], + videoConstraints: { + width: 'not a number har har', + }, + }), +) diff --git a/packages/@uppy/xhr-upload/types/index.d.ts b/packages/@uppy/xhr-upload/types/index.d.ts index 0f2564c231..27ecbfd9ce 100644 --- a/packages/@uppy/xhr-upload/types/index.d.ts +++ b/packages/@uppy/xhr-upload/types/index.d.ts @@ -2,26 +2,30 @@ import type { PluginOptions, BasePlugin, UppyFile } from '@uppy/core' import XHRUploadLocale from './generatedLocale' export type Headers = { - [name: string]: string | number + [name: string]: string | number } export interface XHRUploadOptions extends PluginOptions { - limit?: number - bundle?: boolean - formData?: boolean - headers?: Headers | ((file: UppyFile) => Headers) - allowedMetaFields?: string[] | null - fieldName?: string - timeout?: number - responseUrlFieldName?: string - endpoint: string - method?: 'GET' | 'POST' | 'PUT' | 'HEAD' | 'get' | 'post' | 'put' | 'head' - locale?: XHRUploadLocale - responseType?: string - withCredentials?: boolean - validateStatus?: (statusCode: number, responseText: string, response: unknown) => boolean - getResponseData?: (responseText: string, response: unknown) => any - getResponseError?: (responseText: string, xhr: unknown) => Error + limit?: number + bundle?: boolean + formData?: boolean + headers?: Headers | ((file: UppyFile) => Headers) + allowedMetaFields?: string[] | null + fieldName?: string + timeout?: number + responseUrlFieldName?: string + endpoint: string + method?: 'GET' | 'POST' | 'PUT' | 'HEAD' | 'get' | 'post' | 'put' | 'head' + locale?: XHRUploadLocale + responseType?: string + withCredentials?: boolean + validateStatus?: ( + statusCode: number, + responseText: string, + response: unknown, + ) => boolean + getResponseData?: (responseText: string, response: unknown) => any + getResponseError?: (responseText: string, xhr: unknown) => Error } declare class XHRUpload extends BasePlugin {} diff --git a/packages/@uppy/zoom/types/index.d.ts b/packages/@uppy/zoom/types/index.d.ts index 6c380b675e..6f649d33ae 100644 --- a/packages/@uppy/zoom/types/index.d.ts +++ b/packages/@uppy/zoom/types/index.d.ts @@ -1,10 +1,13 @@ import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core' -import type { TokenStorage, PublicProviderOptions } from '@uppy/companion-client' +import type { + TokenStorage, + PublicProviderOptions, +} from '@uppy/companion-client' interface ZoomOptions extends UIPluginOptions, PublicProviderOptions { - target?: PluginTarget - title?: string - storage?: TokenStorage + target?: PluginTarget + title?: string + storage?: TokenStorage } declare class Zoom extends UIPlugin {} diff --git a/packages/uppy/types/index.test-d.ts b/packages/uppy/types/index.test-d.ts index bbbbf0b449..e2beab6fae 100644 --- a/packages/uppy/types/index.test-d.ts +++ b/packages/uppy/types/index.test-d.ts @@ -1,6 +1,6 @@ -import * as Uppy from '..'; - -(() => { +import * as Uppy from '..' +// eslint-disable-next-line import/newline-after-import +;(() => { const uppy = new Uppy.Uppy({ autoProceed: false }) uppy.use(Uppy.Dashboard, { trigger: '#up_load_file_01' }) uppy.use(Uppy.DragDrop, { target: '#ttt' }) @@ -12,13 +12,18 @@ import * as Uppy from '..'; uppy.on('upload-success', (fileCount, body, uploadurl) => { console.log(fileCount, body, uploadurl, ` files uploaded`) }) -})(); - -(() => { +})() +;(() => { new Uppy.Uppy({ autoProceed: false }) .use(Uppy.Dashboard, { trigger: '#select-files' }) - .use(Uppy.GoogleDrive, { target: Uppy.Dashboard, companionUrl: 'https://companion.uppy.io' }) - .use(Uppy.Instagram, { target: Uppy.Dashboard, companionUrl: 'https://companion.uppy.io' }) + .use(Uppy.GoogleDrive, { + target: Uppy.Dashboard, + companionUrl: 'https://companion.uppy.io', + }) + .use(Uppy.Instagram, { + target: Uppy.Dashboard, + companionUrl: 'https://companion.uppy.io', + }) .use(Uppy.Webcam, { target: Uppy.Dashboard }) .use(Uppy.ScreenCapture) .use(Uppy.Tus, { endpoint: 'https://tusd.tusdemo.net/files/' }) @@ -26,9 +31,8 @@ import * as Uppy from '..'; uppy.on('complete', (result) => { console.log('Upload result:', result) }) -})(); - -(() => { +})() +;(() => { const uppy = new Uppy.Uppy() uppy.use(Uppy.DragDrop, { target: '.UppyDragDrop' }) uppy.use(Uppy.Tus, { endpoint: '//tusd.tusdemo.net/files/' }) diff --git a/private/dev/dragdrop.html b/private/dev/dragdrop.html index 2cdfa09e96..7579101fa1 100644 --- a/private/dev/dragdrop.html +++ b/private/dev/dragdrop.html @@ -1,8 +1,8 @@ - + - - + + Drag-Drop @@ -16,10 +16,10 @@

    Drag-drop is here

    - +
    - +
    diff --git a/private/dev/index.html b/private/dev/index.html index c2f7b92e48..e5515afe32 100644 --- a/private/dev/index.html +++ b/private/dev/index.html @@ -1,8 +1,8 @@ - + - - + + Dashboard