-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into provider-views-ts
* main: Image editor: make compressor work after the image editor, too (#4918) meta: exclude `tsconfig` files from npm bundles (#4916) @uppy/compressor: migrate to TS (#4907) Update uppy-ProviderBrowser-viewType--list.scss (#4913) @uppy/tus: migrate to TS (#4899)
- Loading branch information
Showing
30 changed files
with
470 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tsconfig.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tsconfig.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tsconfig.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"extends": "../../../tsconfig.shared", | ||
"compilerOptions": { | ||
"noImplicitAny": false, | ||
"outDir": "./lib", | ||
"paths": { | ||
"@uppy/utils/lib/*": ["../utils/src/*"], | ||
"@uppy/core": ["../core/src/index.js"], | ||
"@uppy/core/lib/*": ["../core/src/*"] | ||
}, | ||
"resolveJsonModule": false, | ||
"rootDir": "./src", | ||
"skipLibCheck": true | ||
}, | ||
"include": ["./src/**/*.*"], | ||
"exclude": ["./src/**/*.test.ts"], | ||
"references": [ | ||
{ | ||
"path": "../utils/tsconfig.build.json" | ||
}, | ||
{ | ||
"path": "../core/tsconfig.build.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"extends": "../../../tsconfig.shared", | ||
"compilerOptions": { | ||
"emitDeclarationOnly": false, | ||
"noEmit": true, | ||
"paths": { | ||
"@uppy/utils/lib/*": ["../utils/src/*"], | ||
"@uppy/core": ["../core/src/index.js"], | ||
"@uppy/core/lib/*": ["../core/src/*"], | ||
}, | ||
}, | ||
"include": ["./package.json", "./src/**/*.*"], | ||
"references": [ | ||
{ | ||
"path": "../utils/tsconfig.build.json", | ||
}, | ||
{ | ||
"path": "../core/tsconfig.build.json", | ||
}, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tsconfig.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tsconfig.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tsconfig.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tsconfig.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tsconfig.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tsconfig.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tsconfig.* |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile' | ||
import * as tus from 'tus-js-client' | ||
|
||
function isCordova() { | ||
return ( | ||
typeof window !== 'undefined' && | ||
// @ts-expect-error may exist | ||
(typeof window.PhoneGap !== 'undefined' || | ||
// @ts-expect-error may exist | ||
typeof window.Cordova !== 'undefined' || | ||
// @ts-expect-error may exist | ||
typeof window.cordova !== 'undefined') | ||
) | ||
} | ||
|
||
function isReactNative() { | ||
return ( | ||
typeof navigator !== 'undefined' && | ||
typeof navigator.product === 'string' && | ||
navigator.product.toLowerCase() === 'reactnative' | ||
) | ||
} | ||
|
||
// We override tus fingerprint to uppy’s `file.id`, since the `file.id` | ||
// now also includes `relativePath` for files added from folders. | ||
// This means you can add 2 identical files, if one is in folder a, | ||
// the other in folder b — `a/file.jpg` and `b/file.jpg`, when added | ||
// together with a folder, will be treated as 2 separate files. | ||
// | ||
// For React Native and Cordova, we let tus-js-client’s default | ||
// fingerprint handling take charge. | ||
export default function getFingerprint<M extends Meta, B extends Body>( | ||
uppyFile: UppyFile<M, B>, | ||
): tus.UploadOptions['fingerprint'] { | ||
return (file, options) => { | ||
if (isCordova() || isReactNative()) { | ||
return tus.defaultOptions.fingerprint!(file, options) | ||
} | ||
|
||
const uppyFingerprint = ['tus', uppyFile.id, options!.endpoint].join('-') | ||
|
||
return Promise.resolve(uppyFingerprint) | ||
} | ||
} |
17 changes: 13 additions & 4 deletions
17
packages/@uppy/tus/src/index.test.js → packages/@uppy/tus/src/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,38 @@ | ||
import { describe, expect, it } from 'vitest' | ||
import Core from '@uppy/core' | ||
import Tus from './index.js' | ||
import Tus from './index.ts' | ||
|
||
describe('Tus', () => { | ||
it('Throws errors if autoRetry option is true', () => { | ||
const uppy = new Core() | ||
|
||
expect(() => { | ||
// @ts-expect-error removed | ||
uppy.use(Tus, { autoRetry: true }) | ||
}).toThrowError(/The `autoRetry` option was deprecated and has been removed/) | ||
}).toThrowError( | ||
/The `autoRetry` option was deprecated and has been removed/, | ||
) | ||
}) | ||
|
||
it('Throws errors if autoRetry option is false', () => { | ||
const uppy = new Core() | ||
|
||
expect(() => { | ||
// @ts-expect-error removed | ||
uppy.use(Tus, { autoRetry: false }) | ||
}).toThrowError(/The `autoRetry` option was deprecated and has been removed/) | ||
}).toThrowError( | ||
/The `autoRetry` option was deprecated and has been removed/, | ||
) | ||
}) | ||
|
||
it('Throws errors if autoRetry option is `undefined`', () => { | ||
const uppy = new Core() | ||
|
||
expect(() => { | ||
// @ts-expect-error removed | ||
uppy.use(Tus, { autoRetry: undefined }) | ||
}).toThrowError(/The `autoRetry` option was deprecated and has been removed/) | ||
}).toThrowError( | ||
/The `autoRetry` option was deprecated and has been removed/, | ||
) | ||
}) | ||
}) |
Oops, something went wrong.