mirror of
https://github.com/transloadit/uppy.git
synced 2026-01-23 02:25:07 +00:00
[v4.x] remove manual types (#4803)
This commit is contained in:
parent
cb829d8c2a
commit
a0657db5a0
131 changed files with 10 additions and 3579 deletions
25
.github/workflows/ci.yml
vendored
25
.github/workflows/ci.yml
vendored
|
|
@ -95,30 +95,5 @@ jobs:
|
|||
env:
|
||||
# https://docs.cypress.io/guides/references/advanced-installation#Skipping-installation
|
||||
CYPRESS_INSTALL_BINARY: 0
|
||||
# Need to do a bunch of work to generate the locale typings 🙃
|
||||
- name: Prepare type declarations
|
||||
run: |
|
||||
corepack yarn run build:lib
|
||||
corepack yarn run build:companion
|
||||
corepack yarn run build:locale-pack
|
||||
- name: Run type tests
|
||||
run: corepack yarn run test:type
|
||||
- name: Drop manual tyoes
|
||||
# For backward compatiblity reasons, Uppy plugins ship a manual crafted d.ts file.
|
||||
# We don't want to remove that file to not break users.
|
||||
# However, we want to validate the types based on the types inferred from source.
|
||||
run: |
|
||||
node --input-type=module <<'EOF'
|
||||
import { existsSync } from 'node:fs';
|
||||
import { opendir, readFile, writeFile } from 'node:fs/promises';
|
||||
for await (const dirent of await opendir('./packages/@uppy')) {
|
||||
if (existsSync(`./packages/@uppy/${dirent.name}/tsconfig.build.json`)) {
|
||||
const pjsonPath = `./packages/@uppy/${dirent.name}/package.json`
|
||||
const pjson = JSON.parse(await readFile(pjsonPath));
|
||||
delete pjson.types
|
||||
await writeFile(pjsonPath, JSON.stringify(pjson))
|
||||
}
|
||||
}
|
||||
EOF
|
||||
- name: Attempt building TS packages
|
||||
run: corepack yarn run build:ts
|
||||
|
|
|
|||
|
|
@ -107,7 +107,6 @@
|
|||
"stylelint-config-standard": "^34.0.0",
|
||||
"stylelint-config-standard-scss": "^10.0.0",
|
||||
"tar": "^6.1.0",
|
||||
"tsd": "^0.28.0",
|
||||
"typescript": "~5.1",
|
||||
"vitest": "^0.34.5",
|
||||
"vue-template-compiler": "workspace:*"
|
||||
|
|
@ -153,7 +152,6 @@
|
|||
"test:locale-packs": "yarn locale-packs:unused && yarn locale-packs:warnings",
|
||||
"test:locale-packs:unused": "yarn workspace @uppy-dev/locale-pack test unused",
|
||||
"test:locale-packs:warnings": "yarn workspace @uppy-dev/locale-pack test warnings",
|
||||
"test:type": "yarn workspaces foreach -piv --include '@uppy/*' --exclude '@uppy/{angular,react-native,locales,companion,provider-views,robodog,svelte}' exec tsd",
|
||||
"test:unit": "yarn run build:lib && yarn test:watch",
|
||||
"test:watch": "vitest --environment jsdom --dir packages/@uppy",
|
||||
"test": "npm-run-all lint test:locale-packs:unused test:unit test:type test:companion",
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"style": "dist/style.min.css",
|
||||
"types": "types/index.d.ts",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
"uppy",
|
||||
|
|
|
|||
12
packages/@uppy/audio/types/index.d.ts
vendored
12
packages/@uppy/audio/types/index.d.ts
vendored
|
|
@ -1,12 +0,0 @@
|
|||
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
|
||||
import type AudioLocale from './generatedLocale'
|
||||
|
||||
export interface AudioOptions extends UIPluginOptions {
|
||||
target?: PluginTarget
|
||||
showAudioSourceDropdown?: boolean
|
||||
locale?: AudioLocale
|
||||
}
|
||||
|
||||
declare class Audio extends UIPlugin<AudioOptions> {}
|
||||
|
||||
export default Audio
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
import Uppy from '@uppy/core'
|
||||
import Audio from '..'
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
|
||||
uppy.use(Audio, {
|
||||
target: 'body',
|
||||
})
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"type": "module",
|
||||
"types": "types/index.d.ts",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
"aws s3",
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
export interface Chunk {
|
||||
getData: () => Blob
|
||||
onProgress: (ev: ProgressEvent) => void
|
||||
onComplete: (etag: string) => void
|
||||
shouldUseMultipart: boolean
|
||||
setAsUploaded?: () => void
|
||||
}
|
||||
178
packages/@uppy/aws-s3-multipart/types/index.d.ts
vendored
178
packages/@uppy/aws-s3-multipart/types/index.d.ts
vendored
|
|
@ -1,178 +0,0 @@
|
|||
import type { BasePlugin, PluginOptions, UppyFile } from '@uppy/core'
|
||||
|
||||
type MaybePromise<T> = T | Promise<T>
|
||||
|
||||
export type AwsS3UploadParameters =
|
||||
| {
|
||||
method: 'POST'
|
||||
url: string
|
||||
fields: Record<string, string>
|
||||
expires?: number
|
||||
headers?: Record<string, string>
|
||||
}
|
||||
| {
|
||||
method?: 'PUT'
|
||||
url: string
|
||||
fields?: Record<string, never>
|
||||
expires?: number
|
||||
headers?: Record<string, string>
|
||||
}
|
||||
|
||||
export interface AwsS3Part {
|
||||
PartNumber?: number
|
||||
Size?: number
|
||||
ETag?: string
|
||||
}
|
||||
/**
|
||||
* @deprecated use {@link AwsS3UploadParameters} instead
|
||||
*/
|
||||
export interface AwsS3SignedPart {
|
||||
url: string
|
||||
headers?: Record<string, string>
|
||||
}
|
||||
export interface AwsS3STSResponse {
|
||||
credentials: {
|
||||
AccessKeyId: string
|
||||
SecretAccessKey: string
|
||||
SessionToken: string
|
||||
Expiration?: string
|
||||
}
|
||||
bucket: string
|
||||
region: string
|
||||
}
|
||||
|
||||
type AWSS3NonMultipartWithCompanionMandatory = {
|
||||
getUploadParameters?: never
|
||||
}
|
||||
|
||||
type AWSS3NonMultipartWithoutCompanionMandatory = {
|
||||
getUploadParameters: (file: UppyFile) => MaybePromise<AwsS3UploadParameters>
|
||||
}
|
||||
type AWSS3NonMultipartWithCompanion = AWSS3WithCompanion &
|
||||
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
|
||||
}
|
||||
|
||||
type AWSS3MultipartWithoutCompanionMandatory = {
|
||||
getChunkSize?: (file: UppyFile) => number
|
||||
createMultipartUpload: (
|
||||
file: UppyFile,
|
||||
) => MaybePromise<{ uploadId: string; key: string }>
|
||||
listParts: (
|
||||
file: UppyFile,
|
||||
opts: { uploadId: string; key: string; signal: AbortSignal },
|
||||
) => MaybePromise<AwsS3Part[]>
|
||||
abortMultipartUpload: (
|
||||
file: UppyFile,
|
||||
opts: { uploadId: string; key: string; signal: AbortSignal },
|
||||
) => MaybePromise<void>
|
||||
completeMultipartUpload: (
|
||||
file: UppyFile,
|
||||
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<AwsS3UploadParameters>
|
||||
}
|
||||
| {
|
||||
/** @deprecated Use signPart instead */
|
||||
prepareUploadParts: (
|
||||
file: UppyFile,
|
||||
partData: {
|
||||
uploadId: string
|
||||
key: string
|
||||
parts: [{ number: number; chunk: Blob }]
|
||||
},
|
||||
) => MaybePromise<{
|
||||
presignedUrls: Record<number, string>
|
||||
headers?: Record<number, Record<string, string>>
|
||||
}>
|
||||
}
|
||||
)
|
||||
type AWSS3MultipartWithoutCompanion = AWSS3WithoutCompanion &
|
||||
AWSS3MultipartWithoutCompanionMandatory & {
|
||||
shouldUseMultipart?: true
|
||||
getUploadParameters?: never
|
||||
}
|
||||
|
||||
type AWSS3MultipartWithCompanion = AWSS3WithCompanion &
|
||||
Partial<AWSS3MultipartWithoutCompanionMandatory> & {
|
||||
shouldUseMultipart?: true
|
||||
getUploadParameters?: never
|
||||
}
|
||||
|
||||
type AWSS3MaybeMultipartWithCompanion = AWSS3WithCompanion &
|
||||
Partial<AWSS3MultipartWithoutCompanionMandatory> &
|
||||
AWSS3NonMultipartWithCompanionMandatory & {
|
||||
shouldUseMultipart: (file: UppyFile) => boolean
|
||||
}
|
||||
|
||||
type AWSS3MaybeMultipartWithoutCompanion = AWSS3WithoutCompanion &
|
||||
AWSS3MultipartWithoutCompanionMandatory &
|
||||
AWSS3NonMultipartWithoutCompanionMandatory & {
|
||||
shouldUseMultipart: (file: UppyFile) => boolean
|
||||
}
|
||||
|
||||
type AWSS3WithCompanion = {
|
||||
companionUrl: string
|
||||
companionHeaders?: Record<string, string>
|
||||
companionCookiesRule?: string
|
||||
getTemporarySecurityCredentials?: true
|
||||
}
|
||||
type AWSS3WithoutCompanion = {
|
||||
companionUrl?: never
|
||||
companionHeaders?: never
|
||||
companionCookiesRule?: never
|
||||
getTemporarySecurityCredentials?: (options?: {
|
||||
signal?: AbortSignal
|
||||
}) => MaybePromise<AwsS3STSResponse>
|
||||
}
|
||||
|
||||
interface _AwsS3MultipartOptions extends PluginOptions {
|
||||
allowedMetaFields?: string[] | null
|
||||
limit?: number
|
||||
retryDelays?: number[] | null
|
||||
}
|
||||
|
||||
export type AwsS3MultipartOptions = _AwsS3MultipartOptions &
|
||||
(
|
||||
| AWSS3NonMultipartWithCompanion
|
||||
| AWSS3NonMultipartWithoutCompanion
|
||||
| AWSS3MultipartWithCompanion
|
||||
| AWSS3MultipartWithoutCompanion
|
||||
| AWSS3MaybeMultipartWithCompanion
|
||||
| AWSS3MaybeMultipartWithoutCompanion
|
||||
)
|
||||
|
||||
declare class AwsS3Multipart extends BasePlugin<AwsS3MultipartOptions> {}
|
||||
|
||||
export default AwsS3Multipart
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
import { expectError, expectType } from 'tsd'
|
||||
import Uppy from '@uppy/core'
|
||||
import type { UppyFile } from '@uppy/core'
|
||||
import AwsS3Multipart from '..'
|
||||
import type { AwsS3Part } from '..'
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.use(AwsS3Multipart, {
|
||||
shouldUseMultipart: true,
|
||||
createMultipartUpload(file) {
|
||||
expectType<UppyFile>(file)
|
||||
return { uploadId: '', key: '' }
|
||||
},
|
||||
listParts(file, opts) {
|
||||
expectType<UppyFile>(file)
|
||||
expectType<string>(opts.uploadId)
|
||||
expectType<string>(opts.key)
|
||||
return []
|
||||
},
|
||||
signPart(file, opts) {
|
||||
expectType<UppyFile>(file)
|
||||
expectType<string>(opts.uploadId)
|
||||
expectType<string>(opts.key)
|
||||
expectType<Blob>(opts.body)
|
||||
expectType<AbortSignal>(opts.signal)
|
||||
return { url: '' }
|
||||
},
|
||||
abortMultipartUpload(file, opts) {
|
||||
expectType<UppyFile>(file)
|
||||
expectType<string>(opts.uploadId)
|
||||
expectType<string>(opts.key)
|
||||
},
|
||||
completeMultipartUpload(file, opts) {
|
||||
expectType<UppyFile>(file)
|
||||
expectType<string>(opts.uploadId)
|
||||
expectType<string>(opts.key)
|
||||
expectType<AwsS3Part>(opts.parts[0])
|
||||
return {}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
expectError(uppy.use(AwsS3Multipart, { companionUrl: '', getChunkSize: 100 }))
|
||||
expectError(
|
||||
uppy.use(AwsS3Multipart, {
|
||||
companionUrl: '',
|
||||
getChunkSize: () => 'not a number',
|
||||
}),
|
||||
)
|
||||
uppy.use(AwsS3Multipart, { companionUrl: '', getChunkSize: () => 100 })
|
||||
uppy.use(AwsS3Multipart, {
|
||||
companionUrl: '',
|
||||
getChunkSize: (file) => file.size,
|
||||
})
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"type": "module",
|
||||
"types": "types/index.d.ts",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
"aws s3",
|
||||
|
|
|
|||
39
packages/@uppy/aws-s3/types/index.d.ts
vendored
39
packages/@uppy/aws-s3/types/index.d.ts
vendored
|
|
@ -1,39 +0,0 @@
|
|||
import { AwsS3MultipartOptions } from '@uppy/aws-s3-multipart'
|
||||
import type { BasePlugin, Locale, PluginOptions, UppyFile } from '@uppy/core'
|
||||
|
||||
type MaybePromise<T> = T | Promise<T>
|
||||
|
||||
export type AwsS3UploadParameters =
|
||||
| {
|
||||
method?: 'POST'
|
||||
url: string
|
||||
fields?: Record<string, string>
|
||||
expires?: number
|
||||
headers?: Record<string, string>
|
||||
}
|
||||
| {
|
||||
method: 'PUT'
|
||||
url: string
|
||||
fields?: Record<string, never>
|
||||
expires?: number
|
||||
headers?: Record<string, string>
|
||||
}
|
||||
|
||||
interface LegacyAwsS3Options extends PluginOptions {
|
||||
shouldUseMultipart?: never
|
||||
companionUrl?: string | null
|
||||
companionHeaders?: Record<string, string>
|
||||
allowedMetaFields?: Array<string> | null
|
||||
getUploadParameters?: (file: UppyFile) => MaybePromise<AwsS3UploadParameters>
|
||||
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
|
||||
|
||||
declare class AwsS3 extends BasePlugin<AwsS3Options> {}
|
||||
|
||||
export default AwsS3
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
import { Uppy, type UppyFile } from '@uppy/core'
|
||||
import { expectType, expectError } from 'tsd'
|
||||
import type { AwsS3Part } from '@uppy/aws-s3-multipart'
|
||||
import AwsS3 from '..'
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.use(AwsS3, {
|
||||
getUploadParameters(file) {
|
||||
expectType<UppyFile>(file)
|
||||
return { method: 'POST', url: '' }
|
||||
},
|
||||
})
|
||||
expectError(
|
||||
uppy.use(AwsS3, {
|
||||
shouldUseMultipart: false,
|
||||
getUploadParameters(file) {
|
||||
expectType<UppyFile>(file)
|
||||
return { method: 'POST', url: '' }
|
||||
},
|
||||
}),
|
||||
)
|
||||
uppy.use(AwsS3, {
|
||||
shouldUseMultipart: false,
|
||||
getUploadParameters(file) {
|
||||
expectType<UppyFile>(file)
|
||||
return { method: 'POST', url: '', fields: {} }
|
||||
},
|
||||
})
|
||||
expectError(
|
||||
uppy.use(AwsS3, {
|
||||
shouldUseMultipart: true,
|
||||
getUploadParameters(file) {
|
||||
expectType<UppyFile>(file)
|
||||
return { method: 'PUT', url: '' }
|
||||
},
|
||||
}),
|
||||
)
|
||||
uppy.use(AwsS3, {
|
||||
shouldUseMultipart: () => Math.random() > 0.5,
|
||||
getUploadParameters(file) {
|
||||
expectType<UppyFile>(file)
|
||||
return { method: 'PUT', url: '' }
|
||||
},
|
||||
createMultipartUpload(file) {
|
||||
expectType<UppyFile>(file)
|
||||
return { uploadId: '', key: '' }
|
||||
},
|
||||
listParts(file, opts) {
|
||||
expectType<UppyFile>(file)
|
||||
expectType<string>(opts.uploadId)
|
||||
expectType<string>(opts.key)
|
||||
return []
|
||||
},
|
||||
signPart(file, opts) {
|
||||
expectType<UppyFile>(file)
|
||||
expectType<string>(opts.uploadId)
|
||||
expectType<string>(opts.key)
|
||||
expectType<Blob>(opts.body)
|
||||
expectType<AbortSignal>(opts.signal)
|
||||
return { url: '' }
|
||||
},
|
||||
abortMultipartUpload(file, opts) {
|
||||
expectType<UppyFile>(file)
|
||||
expectType<string>(opts.uploadId)
|
||||
expectType<string>(opts.key)
|
||||
},
|
||||
completeMultipartUpload(file, opts) {
|
||||
expectType<UppyFile>(file)
|
||||
expectType<string>(opts.uploadId)
|
||||
expectType<string>(opts.key)
|
||||
expectType<AwsS3Part>(opts.parts[0])
|
||||
return {}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"type": "module",
|
||||
"types": "types/index.d.ts",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
"uppy",
|
||||
|
|
|
|||
15
packages/@uppy/box/types/index.d.ts
vendored
15
packages/@uppy/box/types/index.d.ts
vendored
|
|
@ -1,15 +0,0 @@
|
|||
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
|
||||
import type {
|
||||
PublicProviderOptions,
|
||||
TokenStorage,
|
||||
} from '@uppy/companion-client'
|
||||
|
||||
interface BoxOptions extends UIPluginOptions, PublicProviderOptions {
|
||||
target?: PluginTarget
|
||||
title?: string
|
||||
storage?: TokenStorage
|
||||
}
|
||||
|
||||
declare class Box extends UIPlugin<BoxOptions> {}
|
||||
|
||||
export default Box
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
import Uppy from '@uppy/core'
|
||||
import Box from '..'
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.use(Box, {
|
||||
companionUrl: '',
|
||||
companionCookiesRule: 'same-origin',
|
||||
target: 'body',
|
||||
title: 'title',
|
||||
})
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
"version": "3.6.0",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
129
packages/@uppy/companion-client/types/index.d.ts
vendored
129
packages/@uppy/companion-client/types/index.d.ts
vendored
|
|
@ -1,129 +0,0 @@
|
|||
import type { Uppy } from '@uppy/core'
|
||||
|
||||
/**
|
||||
* Async storage interface, similar to `localStorage`. This can be used to
|
||||
* implement custom storages for authentication tokens.
|
||||
*/
|
||||
export interface TokenStorage {
|
||||
setItem: (key: string, value: string) => Promise<void>
|
||||
getItem: (key: string) => Promise<string>
|
||||
removeItem: (key: string) => Promise<void>
|
||||
}
|
||||
|
||||
type CompanionHeaders = Record<string, string>
|
||||
|
||||
type CompanionKeys = {
|
||||
key: string
|
||||
credentialsName: string
|
||||
}
|
||||
|
||||
export interface RequestClientOptions {
|
||||
companionUrl: string
|
||||
companionHeaders?: CompanionHeaders
|
||||
companionCookiesRule?: RequestCredentials
|
||||
companionKeysParams?: CompanionKeys
|
||||
}
|
||||
|
||||
type RequestOptions = {
|
||||
skipPostResponse?: boolean
|
||||
signal?: AbortSignal
|
||||
}
|
||||
|
||||
export class RequestClient {
|
||||
constructor(uppy: Uppy, opts: RequestClientOptions)
|
||||
|
||||
readonly hostname: string
|
||||
|
||||
setCompanionHeaders(headers: CompanionHeaders): void
|
||||
|
||||
get<T = unknown>(path: string, options?: RequestOptions): Promise<T>
|
||||
|
||||
/** @deprecated use option bag instead */
|
||||
get<T = unknown>(path: string, skipPostResponse: boolean): Promise<T>
|
||||
|
||||
post<T = unknown>(
|
||||
path: string,
|
||||
data: Record<string, unknown>,
|
||||
options?: RequestOptions,
|
||||
): Promise<T>
|
||||
|
||||
/** @deprecated use option bag instead */
|
||||
post<T = unknown>(
|
||||
path: string,
|
||||
data: Record<string, unknown>,
|
||||
skipPostResponse: boolean,
|
||||
): Promise<T>
|
||||
|
||||
delete<T = unknown>(
|
||||
path: string,
|
||||
data?: Record<string, unknown>,
|
||||
options?: RequestOptions,
|
||||
): Promise<T>
|
||||
|
||||
/** @deprecated use option bag instead */
|
||||
delete<T = unknown>(
|
||||
path: string,
|
||||
data: Record<string, unknown>,
|
||||
skipPostResponse: boolean,
|
||||
): Promise<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for Providers that can be passed in by Uppy users through
|
||||
* Plugin constructors.
|
||||
*/
|
||||
export interface PublicProviderOptions extends RequestClientOptions {
|
||||
companionAllowedHosts?: string | RegExp | Array<string | RegExp>
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for Providers, including internal options that Plugins can set.
|
||||
*/
|
||||
export interface ProviderOptions extends PublicProviderOptions {
|
||||
provider: string
|
||||
name?: string
|
||||
pluginId: string
|
||||
}
|
||||
|
||||
export class Provider extends RequestClient {
|
||||
constructor(uppy: Uppy, opts: ProviderOptions)
|
||||
|
||||
checkAuth(): Promise<boolean>
|
||||
|
||||
authUrl(): string
|
||||
|
||||
fileUrl(id: string): string
|
||||
|
||||
list(directory: string): Promise<any>
|
||||
|
||||
logout(redirect?: string): Promise<any>
|
||||
|
||||
static initPlugin(
|
||||
plugin: unknown,
|
||||
opts: Record<string, unknown>,
|
||||
defaultOpts?: Record<string, unknown>,
|
||||
): void
|
||||
}
|
||||
|
||||
export interface SocketOptions {
|
||||
target: string
|
||||
autoOpen?: boolean
|
||||
}
|
||||
|
||||
export class Socket {
|
||||
readonly isOpen: boolean
|
||||
|
||||
constructor(opts: SocketOptions)
|
||||
|
||||
open(): void
|
||||
|
||||
close(): void
|
||||
|
||||
send(action: string, payload: unknown): void
|
||||
|
||||
on(action: string, handler: (param: any) => void): void
|
||||
|
||||
once(action: string, handler: (param: any) => void): void
|
||||
|
||||
emit(action: string, payload: (param: any) => void): void
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
// import { RequestClient, Provider, Socket } from '..'
|
||||
// TODO tests
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"style": "dist/style.min.css",
|
||||
"types": "types/index.d.ts",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
"uppy",
|
||||
|
|
|
|||
23
packages/@uppy/compressor/types/index.d.ts
vendored
23
packages/@uppy/compressor/types/index.d.ts
vendored
|
|
@ -1,23 +0,0 @@
|
|||
import type { PluginOptions, BasePlugin } from '@uppy/core'
|
||||
import { UppyFile } from '@uppy/utils'
|
||||
import type CompressorLocale from './generatedLocale'
|
||||
|
||||
export interface CompressorOptions extends PluginOptions {
|
||||
quality?: number
|
||||
limit?: number
|
||||
locale?: CompressorLocale
|
||||
}
|
||||
|
||||
export type CompressorCompleteCallback<TMeta> = (
|
||||
files: UppyFile<TMeta>[],
|
||||
) => void
|
||||
|
||||
declare module '@uppy/core' {
|
||||
export interface UppyEventMap<TMeta> {
|
||||
'compressor:complete': CompressorCompleteCallback<TMeta>
|
||||
}
|
||||
}
|
||||
|
||||
declare class Compressor extends BasePlugin<CompressorOptions> {}
|
||||
|
||||
export default Compressor
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
import Uppy from '@uppy/core'
|
||||
import Compressor from '..'
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.use(Compressor)
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"style": "dist/style.min.css",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"sideEffects": [
|
||||
"*.css"
|
||||
|
|
|
|||
430
packages/@uppy/core/types/index.d.ts
vendored
430
packages/@uppy/core/types/index.d.ts
vendored
|
|
@ -1,430 +0,0 @@
|
|||
// This references the old types on purpose, to make sure to not create breaking changes for TS consumers.
|
||||
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
||||
/// <reference path="../../utils/types/index.d.ts"/>
|
||||
import * as UppyUtils from '@uppy/utils'
|
||||
|
||||
// Utility types
|
||||
type OmitKey<T, Key> = Pick<T, Exclude<keyof T, Key>>
|
||||
|
||||
type UploadHandler = (fileIDs: string[]) => Promise<void>
|
||||
|
||||
export interface IndexedObject<T> {
|
||||
[key: string]: T
|
||||
[key: number]: T
|
||||
}
|
||||
|
||||
// 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<any> = Record<string, unknown>,
|
||||
TBody extends IndexedObject<any> = Record<string, unknown>,
|
||||
> = UppyUtils.UppyFile<TMeta, TBody>
|
||||
|
||||
export type FileProgress = UppyUtils.FileProgress
|
||||
|
||||
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<
|
||||
TMeta extends IndexedObject<any>,
|
||||
TBody extends IndexedObject<any>,
|
||||
> = OmitKey<UppyFile<TMeta, TBody>, 'meta'>
|
||||
|
||||
type LocaleStrings<TNames extends string> = {
|
||||
[K in TNames]?: string | { [n: number]: string }
|
||||
}
|
||||
|
||||
type LogLevel = 'info' | 'warning' | 'error'
|
||||
|
||||
type CancelOptions = { reason: 'user' | 'unmount' }
|
||||
|
||||
export type Store = UppyUtils.Store
|
||||
|
||||
export type InternalMetadata = UppyUtils.InternalMetadata
|
||||
|
||||
export interface UploadedUppyFile<
|
||||
TMeta extends IndexedObject<any>,
|
||||
TBody extends IndexedObject<any>,
|
||||
> extends UppyFile<TMeta, TBody> {
|
||||
uploadURL: string
|
||||
}
|
||||
|
||||
export interface FailedUppyFile<
|
||||
TMeta extends IndexedObject<any>,
|
||||
TBody extends IndexedObject<any>,
|
||||
> extends UppyFile<TMeta, TBody> {
|
||||
error: string
|
||||
}
|
||||
|
||||
export interface AddFileOptions<
|
||||
TMeta extends IndexedObject<any> = IndexedObject<any>,
|
||||
TBody extends IndexedObject<any> = IndexedObject<any>,
|
||||
> extends Partial<UppyFileWithoutMeta<TMeta, TBody>> {
|
||||
// `.data` is the only required property here.
|
||||
data: Blob | File
|
||||
meta?: Partial<InternalMetadata> & TMeta
|
||||
}
|
||||
|
||||
export interface PluginOptions {
|
||||
id?: string
|
||||
}
|
||||
|
||||
export interface UIPluginOptions extends PluginOptions {
|
||||
replaceTargetContent?: boolean
|
||||
}
|
||||
|
||||
export interface DefaultPluginOptions extends PluginOptions {
|
||||
[prop: string]: any
|
||||
}
|
||||
|
||||
export class BasePlugin<TOptions extends PluginOptions = DefaultPluginOptions> {
|
||||
id: string
|
||||
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
uppy: Uppy
|
||||
|
||||
type: string
|
||||
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
constructor(uppy: Uppy, opts?: TOptions)
|
||||
|
||||
setOptions(update: Partial<TOptions>): void
|
||||
|
||||
getPluginState(): Record<string, unknown>
|
||||
|
||||
setPluginState(update: IndexedObject<any>): Record<string, unknown>
|
||||
|
||||
install(): void
|
||||
|
||||
uninstall(): void
|
||||
}
|
||||
|
||||
export class UIPlugin<
|
||||
TOptions extends UIPluginOptions = DefaultPluginOptions,
|
||||
> extends BasePlugin<TOptions> {
|
||||
id: string
|
||||
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
uppy: Uppy
|
||||
|
||||
type: string
|
||||
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
constructor(uppy: Uppy, opts?: TOptions)
|
||||
|
||||
update(state?: Record<string, unknown>): void
|
||||
|
||||
getTargetPlugin(target: PluginTarget): UIPlugin | undefined
|
||||
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
mount(target: PluginTarget, plugin: UIPlugin): void
|
||||
|
||||
render(state: Record<string, unknown>): void
|
||||
|
||||
addTarget<TPlugin extends UIPlugin>(plugin: TPlugin): void
|
||||
|
||||
unmount(): void
|
||||
|
||||
onMount(): void
|
||||
|
||||
onUnmount(): void
|
||||
}
|
||||
|
||||
export type PluginTarget =
|
||||
| string
|
||||
| Element
|
||||
| typeof BasePlugin
|
||||
| typeof UIPlugin
|
||||
| BasePlugin
|
||||
|
||||
export interface Locale<TNames extends string = string> {
|
||||
strings: LocaleStrings<TNames>
|
||||
pluralize?: (n: number) => number
|
||||
}
|
||||
|
||||
export interface Logger {
|
||||
debug: (...args: any[]) => void
|
||||
warn: (...args: any[]) => void
|
||||
error: (...args: any[]) => void
|
||||
}
|
||||
|
||||
export interface Restrictions {
|
||||
maxFileSize?: number | null
|
||||
minFileSize?: number | null
|
||||
maxTotalFileSize?: number | null
|
||||
maxNumberOfFiles?: number | null
|
||||
minNumberOfFiles?: number | null
|
||||
allowedFileTypes?: string[] | null
|
||||
}
|
||||
|
||||
export interface UppyOptions<
|
||||
TMeta extends IndexedObject<any> = Record<string, unknown>,
|
||||
> {
|
||||
id?: string
|
||||
autoProceed?: boolean
|
||||
/**
|
||||
* @deprecated Use allowMultipleUploadBatches
|
||||
*/
|
||||
allowMultipleUploads?: boolean
|
||||
allowMultipleUploadBatches?: boolean
|
||||
logger?: Logger
|
||||
debug?: boolean
|
||||
restrictions?: Restrictions
|
||||
meta?: TMeta
|
||||
onBeforeFileAdded?: (
|
||||
currentFile: UppyFile<TMeta>,
|
||||
files: { [key: string]: UppyFile<TMeta> },
|
||||
) => UppyFile<TMeta> | boolean | undefined
|
||||
onBeforeUpload?: (files: {
|
||||
[key: string]: UppyFile<TMeta>
|
||||
}) => { [key: string]: UppyFile<TMeta> } | boolean
|
||||
locale?: Locale
|
||||
store?: Store
|
||||
infoTimeout?: number
|
||||
}
|
||||
|
||||
export interface UploadResult<
|
||||
TMeta extends IndexedObject<any> = Record<string, unknown>,
|
||||
TBody extends IndexedObject<any> = Record<string, unknown>,
|
||||
> {
|
||||
successful: UploadedUppyFile<TMeta, TBody>[]
|
||||
failed: FailedUppyFile<TMeta, TBody>[]
|
||||
}
|
||||
|
||||
export interface State<
|
||||
TMeta extends IndexedObject<any> = Record<string, unknown>,
|
||||
TBody extends IndexedObject<any> = Record<string, unknown>,
|
||||
> extends IndexedObject<any> {
|
||||
capabilities?: { resumableUploads?: boolean }
|
||||
currentUploads: Record<string, unknown>
|
||||
error?: string
|
||||
files: {
|
||||
[key: string]: UploadedUppyFile<TMeta, TBody> | FailedUppyFile<TMeta, TBody>
|
||||
}
|
||||
info?: Array<{
|
||||
isHidden: boolean
|
||||
type: LogLevel
|
||||
message: string
|
||||
details: string | null
|
||||
}>
|
||||
plugins?: IndexedObject<any>
|
||||
totalProgress: number
|
||||
}
|
||||
|
||||
export interface ErrorResponse {
|
||||
status: number
|
||||
body: any
|
||||
}
|
||||
|
||||
export interface SuccessResponse {
|
||||
uploadURL?: string
|
||||
status?: number
|
||||
body?: any
|
||||
bytesUploaded?: number
|
||||
}
|
||||
|
||||
export type GenericEventCallback = () => void
|
||||
export type FileAddedCallback<TMeta extends IndexedObject<any>> = (
|
||||
file: UppyFile<TMeta>,
|
||||
) => void
|
||||
export type FilesAddedCallback<TMeta extends IndexedObject<any>> = (
|
||||
files: UppyFile<TMeta>[],
|
||||
) => void
|
||||
export type FileRemovedCallback<TMeta extends IndexedObject<any>> = (
|
||||
file: UppyFile<TMeta>,
|
||||
reason: FileRemoveReason,
|
||||
) => void
|
||||
export type UploadCallback = (data: { id: string; fileIDs: string[] }) => void
|
||||
export type ProgressCallback = (progress: number) => void
|
||||
export type PreProcessCompleteCallback<TMeta extends IndexedObject<any>> = (
|
||||
file: UppyFile<TMeta> | undefined,
|
||||
) => void
|
||||
export type UploadPauseCallback = (
|
||||
fileID: UppyFile['id'] | undefined,
|
||||
isPaused: boolean,
|
||||
) => void
|
||||
export type UploadProgressCallback<TMeta extends IndexedObject<any>> = (
|
||||
file: UppyFile<TMeta> | undefined,
|
||||
progress: FileProgress,
|
||||
) => void
|
||||
export type UploadSuccessCallback<TMeta extends IndexedObject<any>> = (
|
||||
file: UppyFile<TMeta> | undefined,
|
||||
response: SuccessResponse,
|
||||
) => void
|
||||
export type UploadCompleteCallback<TMeta extends IndexedObject<any>> = (
|
||||
result: UploadResult<TMeta>,
|
||||
) => void
|
||||
export type ErrorCallback = (error: Error) => void
|
||||
export type UploadErrorCallback<TMeta extends IndexedObject<any>> = (
|
||||
file: UppyFile<TMeta> | undefined,
|
||||
error: Error,
|
||||
response?: ErrorResponse,
|
||||
) => void
|
||||
export type UploadRetryCallback = (fileID: string) => void
|
||||
export type PauseAllCallback = (fileIDs: string[]) => void
|
||||
export type ResumeAllCallback = (fileIDs: string[]) => void
|
||||
export type RetryAllCallback = (fileIDs: string[]) => void
|
||||
export type RestrictionFailedCallback<TMeta extends IndexedObject<any>> = (
|
||||
file: UppyFile<TMeta> | undefined,
|
||||
error: Error,
|
||||
) => void
|
||||
|
||||
export interface UppyEventMap<
|
||||
TMeta extends IndexedObject<any> = Record<string, unknown>,
|
||||
> {
|
||||
'cancel-all': GenericEventCallback
|
||||
complete: UploadCompleteCallback<TMeta>
|
||||
error: ErrorCallback
|
||||
'file-added': FileAddedCallback<TMeta>
|
||||
'file-removed': FileRemovedCallback<TMeta>
|
||||
'files-added': FilesAddedCallback<TMeta>
|
||||
'info-hidden': GenericEventCallback
|
||||
'info-visible': GenericEventCallback
|
||||
'pause-all': PauseAllCallback
|
||||
'preprocess-complete': PreProcessCompleteCallback<TMeta>
|
||||
progress: ProgressCallback
|
||||
'reset-progress': GenericEventCallback
|
||||
'resume-all': ResumeAllCallback
|
||||
'restriction-failed': RestrictionFailedCallback<TMeta>
|
||||
'retry-all': RetryAllCallback
|
||||
'upload-error': UploadErrorCallback<TMeta>
|
||||
'upload-pause': UploadPauseCallback
|
||||
'upload-progress': UploadProgressCallback<TMeta>
|
||||
'upload-retry': UploadRetryCallback
|
||||
'upload-success': UploadSuccessCallback<TMeta>
|
||||
upload: UploadCallback
|
||||
}
|
||||
|
||||
export class Uppy<
|
||||
TMeta extends IndexedObject<any> = Record<string, unknown>,
|
||||
TBody extends IndexedObject<any> = Record<string, unknown>,
|
||||
> {
|
||||
constructor(opts?: UppyOptions)
|
||||
|
||||
on<K extends keyof UppyEventMap>(
|
||||
event: K,
|
||||
callback: UppyEventMap<TMeta>[K],
|
||||
): this
|
||||
|
||||
once<K extends keyof UppyEventMap>(
|
||||
event: K,
|
||||
callback: UppyEventMap<TMeta>[K],
|
||||
): this
|
||||
|
||||
off<K extends keyof UppyEventMap>(
|
||||
event: K,
|
||||
callback: UppyEventMap<TMeta>[K],
|
||||
): this
|
||||
|
||||
/**
|
||||
* For use by plugins only.
|
||||
*/
|
||||
emit(event: string, ...args: any[]): void
|
||||
|
||||
updateAll(state: Record<string, unknown>): void
|
||||
|
||||
setOptions(update: Partial<UppyOptions>): void
|
||||
|
||||
setState(patch: Record<string, unknown>): void
|
||||
|
||||
getState(): State<TMeta>
|
||||
|
||||
setFileState(fileID: string, state: Record<string, unknown>): void
|
||||
|
||||
resetProgress(): void
|
||||
|
||||
addPreProcessor(fn: UploadHandler): void
|
||||
|
||||
removePreProcessor(fn: UploadHandler): void
|
||||
|
||||
addPostProcessor(fn: UploadHandler): void
|
||||
|
||||
removePostProcessor(fn: UploadHandler): void
|
||||
|
||||
addUploader(fn: UploadHandler): void
|
||||
|
||||
removeUploader(fn: UploadHandler): void
|
||||
|
||||
setMeta(data: TMeta): void
|
||||
|
||||
setFileMeta(fileID: string, data: TMeta): void
|
||||
|
||||
getFile(fileID: string): UppyFile<TMeta, TBody>
|
||||
|
||||
getFiles(): Array<UppyFile<TMeta, TBody>>
|
||||
|
||||
getObjectOfFilesPerState(): {
|
||||
newFiles: Array<UppyFile>
|
||||
startedFiles: Array<UppyFile>
|
||||
uploadStartedFiles: Array<UppyFile>
|
||||
pausedFiles: Array<UppyFile>
|
||||
completeFiles: Array<UppyFile>
|
||||
erroredFiles: Array<UppyFile>
|
||||
inProgressFiles: Array<UppyFile>
|
||||
inProgressNotPausedFiles: Array<UppyFile>
|
||||
processingFiles: Array<UppyFile>
|
||||
isUploadStarted: boolean
|
||||
isAllComplete: boolean
|
||||
isAllErrored: boolean
|
||||
isAllPaused: boolean
|
||||
isUploadInProgress: boolean
|
||||
isSomeGhost: boolean
|
||||
}
|
||||
|
||||
addFile(file: AddFileOptions<TMeta>): string
|
||||
|
||||
addFiles(files: AddFileOptions<TMeta>[]): void
|
||||
|
||||
removeFile(fileID: string, reason?: FileRemoveReason): void
|
||||
|
||||
pauseResume(fileID: string): boolean
|
||||
|
||||
pauseAll(): void
|
||||
|
||||
resumeAll(): void
|
||||
|
||||
retryAll(): Promise<UploadResult<TMeta>>
|
||||
|
||||
cancelAll(options?: CancelOptions): void
|
||||
|
||||
retryUpload(fileID: string): Promise<UploadResult<TMeta>>
|
||||
|
||||
getID(): string
|
||||
|
||||
use<
|
||||
TOptions extends PluginOptions,
|
||||
TInstance extends UIPlugin | BasePlugin<TOptions>,
|
||||
>(
|
||||
pluginClass: new (uppy: this, opts?: TOptions) => TInstance,
|
||||
opts?: TOptions,
|
||||
): this
|
||||
|
||||
getPlugin<TPlugin extends UIPlugin | BasePlugin>(
|
||||
name: string,
|
||||
): TPlugin | undefined
|
||||
|
||||
iteratePlugins(callback: (plugin: UIPlugin | BasePlugin) => void): void
|
||||
|
||||
removePlugin(instance: UIPlugin | BasePlugin): void
|
||||
|
||||
close(options?: CancelOptions): void
|
||||
|
||||
logout(): void
|
||||
|
||||
info(
|
||||
message: string | { message: string; details: string },
|
||||
type?: LogLevel,
|
||||
duration?: number,
|
||||
): void
|
||||
|
||||
hideInfo(): void
|
||||
|
||||
log(msg: string, type?: LogLevel): void
|
||||
|
||||
restore(uploadID: string): Promise<UploadResult<TMeta>>
|
||||
|
||||
addResultData(uploadID: string, data: Record<string, unknown>): void
|
||||
|
||||
upload(): Promise<UploadResult<TMeta>>
|
||||
}
|
||||
|
||||
export default Uppy
|
||||
|
|
@ -1,167 +0,0 @@
|
|||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
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 '..'
|
||||
|
||||
type anyObject = Record<string, unknown>
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.addFile({
|
||||
data: new Blob([new ArrayBuffer(1024)], {
|
||||
type: 'application/octet-stream',
|
||||
}),
|
||||
})
|
||||
|
||||
uppy.upload().then((result) => {
|
||||
expectType<UploadedUppyFile<anyObject, anyObject>>(result.successful[0])
|
||||
expectType<FailedUppyFile<anyObject, anyObject>>(result.failed[0])
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
const store = new DefaultStore()
|
||||
new Uppy({ store }) // eslint-disable-line no-new
|
||||
}
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
// this doesn't exist but type checking works anyway :)
|
||||
const f = uppy.getFile('virtual')
|
||||
if (f && f.progress && f.progress.uploadStarted === null) {
|
||||
f.progress.uploadStarted = Date.now()
|
||||
}
|
||||
|
||||
if (f && f.response && f.response.status === 200) {
|
||||
expectType(f.response.body)
|
||||
}
|
||||
expectType<number>(f.response!.status) // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
||||
}
|
||||
|
||||
{
|
||||
type Meta = Record<string, never>
|
||||
type ResponseBody = {
|
||||
averageColor: string
|
||||
}
|
||||
const uppy = new Uppy<Meta, ResponseBody>()
|
||||
const f = uppy.getFile('virtual')
|
||||
expectType<ResponseBody>(f.response!.body) // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
||||
}
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.addFile({
|
||||
name: 'empty.json',
|
||||
data: new Blob(['null'], { type: 'application/json' }),
|
||||
meta: { path: 'path/to/file' },
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
interface SomeOptions extends PluginOptions {
|
||||
types: 'are checked'
|
||||
}
|
||||
class SomePlugin extends UIPlugin<SomeOptions> {}
|
||||
const typedUppy = new Uppy()
|
||||
|
||||
expectError(typedUppy.use(SomePlugin, { types: 'error' }))
|
||||
|
||||
typedUppy.use(SomePlugin, { types: 'are checked' })
|
||||
}
|
||||
|
||||
{
|
||||
// Meta signature
|
||||
type Meta = { myCustomMetadata: string }
|
||||
/* eslint-disable @typescript-eslint/no-empty-function */
|
||||
const uppy = new Uppy<Meta>()
|
||||
// can emit events with internal event types
|
||||
uppy.emit('upload')
|
||||
uppy.emit('complete', () => {})
|
||||
uppy.emit('error', () => {})
|
||||
|
||||
// can emit events with custom event types
|
||||
uppy.emit('dashboard:modal-closed', () => {})
|
||||
|
||||
// can register listeners for internal events
|
||||
uppy.on('upload', () => {})
|
||||
uppy.on('complete', () => {})
|
||||
uppy.on('error', () => {})
|
||||
uppy.once('upload', () => {})
|
||||
uppy.once('complete', () => {})
|
||||
uppy.once('error', () => {})
|
||||
/* eslint-enable @typescript-eslint/no-empty-function */
|
||||
|
||||
// Normal event signature
|
||||
uppy.on('complete', (result) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const successResults = result.successful
|
||||
})
|
||||
|
||||
uppy.on('complete', (result) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const meta = result.successful[0].meta.myCustomMetadata
|
||||
})
|
||||
|
||||
// Separate event handlers
|
||||
const handleUpload = (file?: UppyFile<Meta>) => {
|
||||
const meta = file?.meta.myCustomMetadata
|
||||
}
|
||||
|
||||
uppy.off('upload-success', handleUpload)
|
||||
|
||||
interface CustomResponse extends SuccessResponse {
|
||||
body?: { someValue: string }
|
||||
}
|
||||
|
||||
const onUploadSuccess = async (
|
||||
file: UppyFile<Meta, any> | undefined,
|
||||
response: CustomResponse,
|
||||
) => {
|
||||
const res = response.body?.someValue
|
||||
}
|
||||
uppy.on('upload-success', onUploadSuccess)
|
||||
}
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.setOptions({
|
||||
restrictions: {
|
||||
allowedFileTypes: ['.png'],
|
||||
},
|
||||
})
|
||||
expectError(uppy.setOptions({ restrictions: false }))
|
||||
expectError(uppy.setOptions({ unknownKey: false }))
|
||||
}
|
||||
|
||||
{
|
||||
interface TestOptions extends PluginOptions {
|
||||
testOption: string
|
||||
}
|
||||
class TestPlugin extends UIPlugin<TestOptions> {}
|
||||
|
||||
const strict = new Uppy().use(TestPlugin, { testOption: 'hello' })
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
strict
|
||||
.getPlugin<TestPlugin>('TestPlugin')!
|
||||
.setOptions({ testOption: 'world' })
|
||||
|
||||
expectError(
|
||||
strict.getPlugin<TestPlugin>('TestPlugin')!.setOptions({ testOption: 0 }),
|
||||
)
|
||||
|
||||
expectError(
|
||||
strict
|
||||
.getPlugin<TestPlugin>('TestPlugin')!
|
||||
.setOptions({ unknownKey: false }),
|
||||
)
|
||||
/* eslint-enable @typescript-eslint/no-non-null-assertion */
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"style": "dist/style.min.css",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
115
packages/@uppy/dashboard/types/index.d.ts
vendored
115
packages/@uppy/dashboard/types/index.d.ts
vendored
|
|
@ -1,115 +0,0 @@
|
|||
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
|
||||
onChange: (newVal: string) => void
|
||||
fieldCSSClasses: { text: string }
|
||||
required: boolean
|
||||
form: string
|
||||
}
|
||||
|
||||
type PreactRender = (
|
||||
node: any,
|
||||
params: Record<string, unknown> | null,
|
||||
...children: any[]
|
||||
) => any
|
||||
|
||||
interface MetaField {
|
||||
id: string
|
||||
name: string
|
||||
placeholder?: string
|
||||
render?: (field: FieldRenderOptions, h: PreactRender) => any
|
||||
}
|
||||
|
||||
type Options = UIPluginOptions & ThumbnailOptions
|
||||
|
||||
export interface DashboardOptions extends Options {
|
||||
animateOpenClose?: boolean
|
||||
browserBackButtonClose?: boolean
|
||||
closeAfterFinish?: boolean
|
||||
singleFileFullScreen?: boolean
|
||||
closeModalOnClickOutside?: boolean
|
||||
disableInformer?: boolean
|
||||
disablePageScrollWhenModalOpen?: boolean
|
||||
disableStatusBar?: boolean
|
||||
disableThumbnailGenerator?: boolean
|
||||
height?: string | number
|
||||
hideCancelButton?: boolean
|
||||
hidePauseResumeButton?: boolean
|
||||
hideProgressAfterFinish?: boolean
|
||||
hideRetryButton?: boolean
|
||||
hideUploadButton?: boolean
|
||||
inline?: boolean
|
||||
locale?: DashboardLocale & StatusBarLocale
|
||||
metaFields?: MetaField[] | ((file: UppyFile) => MetaField[])
|
||||
note?: string | null
|
||||
plugins?: string[]
|
||||
fileManagerSelectionType?: 'files' | 'folders' | 'both'
|
||||
proudlyDisplayPoweredByUppy?: boolean
|
||||
showLinkToFileUploadResult?: boolean
|
||||
showProgressDetails?: boolean
|
||||
showSelectedFiles?: boolean
|
||||
showRemoveButtonAfterComplete?: boolean
|
||||
showNativePhotoCameraButton?: boolean
|
||||
showNativeVideoCameraButton?: boolean
|
||||
target?: PluginTarget
|
||||
theme?: 'auto' | 'dark' | 'light'
|
||||
trigger?: string
|
||||
width?: string | number
|
||||
autoOpenFileEditor?: boolean
|
||||
disabled?: boolean
|
||||
disableLocalFiles?: boolean
|
||||
onRequestCloseModal?: () => void
|
||||
doneButtonHandler?: () => void
|
||||
onDragOver?: (event: DragEvent) => void
|
||||
onDragLeave?: (event: DragEvent) => void
|
||||
onDrop?: (event: DragEvent) => void
|
||||
}
|
||||
|
||||
declare class Dashboard extends UIPlugin<DashboardOptions> {
|
||||
addTarget(plugin: UIPlugin): HTMLElement
|
||||
|
||||
hideAllPanels(): void
|
||||
|
||||
openModal(): void
|
||||
|
||||
closeModal(): void
|
||||
|
||||
isModalOpen(): boolean
|
||||
|
||||
render(state: Record<string, unknown>): void
|
||||
|
||||
install(): void
|
||||
|
||||
uninstall(): void
|
||||
}
|
||||
|
||||
export default Dashboard
|
||||
|
||||
// Events
|
||||
|
||||
export type DashboardFileEditStartCallback<TMeta extends IndexedObject<any>> = (
|
||||
file?: UppyFile<TMeta>,
|
||||
) => void
|
||||
export type DashboardFileEditCompleteCallback<
|
||||
TMeta extends IndexedObject<any>,
|
||||
> = (file?: UppyFile<TMeta>) => void
|
||||
export type DashboardShowPlanelCallback = (id: string) => void
|
||||
declare module '@uppy/core' {
|
||||
export interface UppyEventMap<TMeta> {
|
||||
'dashboard:modal-open': GenericEventCallback
|
||||
'dashboard:modal-closed': GenericEventCallback
|
||||
'dashboard:show-panel': DashboardShowPlanelCallback
|
||||
'dashboard:file-edit-start': DashboardFileEditStartCallback<TMeta>
|
||||
'dashboard:file-edit-complete': DashboardFileEditCompleteCallback<TMeta>
|
||||
}
|
||||
}
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
import { expectType, expectError } from 'tsd'
|
||||
import Uppy from '@uppy/core'
|
||||
import Dashboard from '..'
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.use(Dashboard, {
|
||||
target: 'body',
|
||||
})
|
||||
|
||||
const plugin = uppy.getPlugin<Dashboard>('Dashboard') ?? ({} as never)
|
||||
plugin.openModal()
|
||||
expectType<boolean>(plugin.isModalOpen())
|
||||
plugin.closeModal()
|
||||
}
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.use(Dashboard, {
|
||||
width: '100%',
|
||||
height: 700,
|
||||
metaFields: [
|
||||
{ id: 'caption', name: 'Caption' },
|
||||
{
|
||||
id: 'license',
|
||||
name: 'License',
|
||||
placeholder: 'Creative Commons, Apache 2.0, ...',
|
||||
},
|
||||
{
|
||||
id: 'public',
|
||||
name: 'Public',
|
||||
render({ value, onChange }, h) {
|
||||
expectType<string>(value)
|
||||
expectType<(val: string) => void>(onChange)
|
||||
// `h` should be the Preact `h`
|
||||
expectError(h([], 'error'))
|
||||
/* Currently `h` typings are limited because of a JSX type conflict between React and Preact.
|
||||
return h('input', {
|
||||
type: 'checkbox',
|
||||
checked: value === 'yes',
|
||||
onChange: (event) => {
|
||||
expectType<Event>(event)
|
||||
onChange((event.target as HTMLInputElement).checked ? 'yes' : 'no')
|
||||
}
|
||||
})
|
||||
*/
|
||||
},
|
||||
},
|
||||
],
|
||||
onDragOver: (event) => event.clientX,
|
||||
onDrop: (event) => event.clientX,
|
||||
onDragLeave: (event) => event.clientX,
|
||||
})
|
||||
|
||||
uppy.on('dashboard:file-edit-start', (file) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const fileName = file?.name
|
||||
})
|
||||
uppy.on('dashboard:show-panel', (id) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const pluginId = id
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.use(Dashboard, {
|
||||
locale: {
|
||||
strings: {
|
||||
// Dashboard string
|
||||
addMoreFiles: 'yaddayadda',
|
||||
// StatusBar string
|
||||
uploading: '^^^^',
|
||||
},
|
||||
},
|
||||
})
|
||||
expectError(
|
||||
uppy.use(Dashboard, {
|
||||
locale: {
|
||||
strings: {
|
||||
somethingThatDoesNotExist: 'wrong',
|
||||
},
|
||||
},
|
||||
}),
|
||||
)
|
||||
const wrongType = 1234
|
||||
expectError(
|
||||
uppy.use(Dashboard, {
|
||||
locale: {
|
||||
strings: {
|
||||
addMoreFiles: wrongType,
|
||||
},
|
||||
},
|
||||
}),
|
||||
)
|
||||
}
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
expectError(uppy.use(Dashboard, { height: {} }))
|
||||
}
|
||||
|
|
@ -6,7 +6,6 @@
|
|||
"main": "lib/index.js",
|
||||
"style": "dist/style.min.css",
|
||||
"type": "module",
|
||||
"types": "types/index.d.ts",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
"uppy",
|
||||
|
|
|
|||
19
packages/@uppy/drag-drop/types/index.d.ts
vendored
19
packages/@uppy/drag-drop/types/index.d.ts
vendored
|
|
@ -1,19 +0,0 @@
|
|||
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
|
||||
import DragDropLocale from './generatedLocale'
|
||||
|
||||
export interface DragDropOptions extends UIPluginOptions {
|
||||
target?: PluginTarget
|
||||
inputName?: string
|
||||
allowMultipleFiles?: boolean
|
||||
width?: string | number
|
||||
height?: string | number
|
||||
note?: string
|
||||
locale?: DragDropLocale
|
||||
onDragOver?: (event: DragEvent) => void
|
||||
onDragLeave?: (event: DragEvent) => void
|
||||
onDrop?: (event: DragEvent) => void
|
||||
}
|
||||
|
||||
declare class DragDrop extends UIPlugin<DragDropOptions> {}
|
||||
|
||||
export default DragDrop
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
import Uppy from '@uppy/core'
|
||||
|
||||
import DragDrop from '..'
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
|
||||
uppy.use(DragDrop, {
|
||||
target: 'body',
|
||||
inputName: 'test',
|
||||
allowMultipleFiles: true,
|
||||
width: 100,
|
||||
height: '100',
|
||||
note: 'note',
|
||||
locale: {
|
||||
strings: {
|
||||
dropHereOr: 'test',
|
||||
browse: 'test',
|
||||
},
|
||||
},
|
||||
onDragOver: (event) => event.clientX,
|
||||
onDragLeave: (event) => event.clientY,
|
||||
onDrop: (event) => event,
|
||||
})
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"type": "module",
|
||||
"types": "types/index.d.ts",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
"uppy",
|
||||
|
|
|
|||
12
packages/@uppy/drop-target/types/index.d.ts
vendored
12
packages/@uppy/drop-target/types/index.d.ts
vendored
|
|
@ -1,12 +0,0 @@
|
|||
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
|
||||
}
|
||||
|
||||
declare class DropTarget extends BasePlugin<DropTargetOptions> {}
|
||||
|
||||
export default DropTarget
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
import Uppy from '@uppy/core'
|
||||
import DropTarget from '..'
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
|
||||
uppy.use(DropTarget, {
|
||||
target: 'body',
|
||||
onDragOver: (event) => event.clientX,
|
||||
onDrop: (event) => event.clientX,
|
||||
onDragLeave: (event) => event.clientX,
|
||||
})
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"type": "module",
|
||||
"types": "types/index.d.ts",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
"uppy",
|
||||
|
|
|
|||
15
packages/@uppy/dropbox/types/index.d.ts
vendored
15
packages/@uppy/dropbox/types/index.d.ts
vendored
|
|
@ -1,15 +0,0 @@
|
|||
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
|
||||
import type {
|
||||
PublicProviderOptions,
|
||||
TokenStorage,
|
||||
} from '@uppy/companion-client'
|
||||
|
||||
export interface DropboxOptions extends UIPluginOptions, PublicProviderOptions {
|
||||
target?: PluginTarget
|
||||
title?: string
|
||||
storage?: TokenStorage
|
||||
}
|
||||
|
||||
declare class Dropbox extends UIPlugin<DropboxOptions> {}
|
||||
|
||||
export default Dropbox
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
import Uppy from '@uppy/core'
|
||||
import Dropbox from '..'
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.use(Dropbox, {
|
||||
companionUrl: '',
|
||||
companionCookiesRule: 'same-origin',
|
||||
target: 'body',
|
||||
title: 'title',
|
||||
})
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"type": "module",
|
||||
"types": "types/index.d.ts",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
"uppy",
|
||||
|
|
|
|||
17
packages/@uppy/facebook/types/index.d.ts
vendored
17
packages/@uppy/facebook/types/index.d.ts
vendored
|
|
@ -1,17 +0,0 @@
|
|||
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
|
||||
import type {
|
||||
PublicProviderOptions,
|
||||
TokenStorage,
|
||||
} from '@uppy/companion-client'
|
||||
|
||||
export interface FacebookOptions
|
||||
extends UIPluginOptions,
|
||||
PublicProviderOptions {
|
||||
target?: PluginTarget
|
||||
title?: string
|
||||
storage?: TokenStorage
|
||||
}
|
||||
|
||||
declare class Facebook extends UIPlugin<FacebookOptions> {}
|
||||
|
||||
export default Facebook
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
import Uppy from '@uppy/core'
|
||||
import Facebook from '..'
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.use(Facebook, {
|
||||
companionUrl: '',
|
||||
companionCookiesRule: 'same-origin',
|
||||
target: 'body',
|
||||
title: 'title',
|
||||
})
|
||||
}
|
||||
|
|
@ -6,7 +6,6 @@
|
|||
"main": "lib/index.js",
|
||||
"style": "dist/style.min.css",
|
||||
"type": "module",
|
||||
"types": "types/index.d.ts",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
"upload",
|
||||
|
|
|
|||
13
packages/@uppy/file-input/types/index.d.ts
vendored
13
packages/@uppy/file-input/types/index.d.ts
vendored
|
|
@ -1,13 +0,0 @@
|
|||
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
|
||||
}
|
||||
|
||||
declare class FileInput extends UIPlugin<FileInputOptions> {}
|
||||
|
||||
export default FileInput
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
// import FileInput from '..'
|
||||
// TODO implement
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"type": "module",
|
||||
"types": "types/index.d.ts",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
"uppy",
|
||||
|
|
|
|||
14
packages/@uppy/form/types/index.d.ts
vendored
14
packages/@uppy/form/types/index.d.ts
vendored
|
|
@ -1,14 +0,0 @@
|
|||
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
|
||||
}
|
||||
|
||||
declare class Form extends BasePlugin<FormOptions> {}
|
||||
|
||||
export default Form
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
// import Form from '..'
|
||||
// TODO implement
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
"version": "3.1.1",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
11
packages/@uppy/golden-retriever/types/index.d.ts
vendored
11
packages/@uppy/golden-retriever/types/index.d.ts
vendored
|
|
@ -1,11 +0,0 @@
|
|||
import type { PluginOptions, BasePlugin } from '@uppy/core'
|
||||
|
||||
interface GoldenRetrieverOptions extends PluginOptions {
|
||||
expires?: number
|
||||
serviceWorker?: boolean
|
||||
indexedDB?: any
|
||||
}
|
||||
|
||||
declare class GoldenRetriever extends BasePlugin<GoldenRetrieverOptions> {}
|
||||
|
||||
export default GoldenRetriever
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
// import GoldenRetriever from '..'
|
||||
// TODO implements
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
"version": "3.3.0",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
17
packages/@uppy/google-drive/types/index.d.ts
vendored
17
packages/@uppy/google-drive/types/index.d.ts
vendored
|
|
@ -1,17 +0,0 @@
|
|||
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
|
||||
import type {
|
||||
PublicProviderOptions,
|
||||
TokenStorage,
|
||||
} from '@uppy/companion-client'
|
||||
|
||||
export interface GoogleDriveOptions
|
||||
extends UIPluginOptions,
|
||||
PublicProviderOptions {
|
||||
target?: PluginTarget
|
||||
title?: string
|
||||
storage?: TokenStorage
|
||||
}
|
||||
|
||||
declare class GoogleDrive extends UIPlugin<GoogleDriveOptions> {}
|
||||
|
||||
export default GoogleDrive
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
import Uppy, { UIPlugin, type UIPluginOptions } from '@uppy/core'
|
||||
import GoogleDrive from '..'
|
||||
|
||||
class SomePlugin extends UIPlugin<UIPluginOptions> {}
|
||||
|
||||
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: '',
|
||||
})
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"style": "dist/style.min.css",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
57
packages/@uppy/image-editor/types/index.d.ts
vendored
57
packages/@uppy/image-editor/types/index.d.ts
vendored
|
|
@ -1,57 +0,0 @@
|
|||
import type {
|
||||
IndexedObject,
|
||||
PluginTarget,
|
||||
UIPlugin,
|
||||
UIPluginOptions,
|
||||
UppyFile,
|
||||
} from '@uppy/core'
|
||||
import type Cropper from 'cropperjs'
|
||||
import ImageEditorLocale from './generatedLocale'
|
||||
|
||||
type Actions = {
|
||||
revert: boolean
|
||||
rotate: boolean
|
||||
granularRotate: boolean
|
||||
flip: boolean
|
||||
zoomIn: boolean
|
||||
zoomOut: boolean
|
||||
cropSquare: boolean
|
||||
cropWidescreen: boolean
|
||||
cropWidescreenVertical: boolean
|
||||
}
|
||||
|
||||
interface UppyCropperOptions extends Cropper.Options {
|
||||
croppedCanvasOptions: Cropper.GetCroppedCanvasOptions
|
||||
}
|
||||
|
||||
export interface ImageEditorOptions extends UIPluginOptions {
|
||||
cropperOptions?: UppyCropperOptions
|
||||
actions?: Actions
|
||||
quality?: number
|
||||
target?: PluginTarget
|
||||
locale?: ImageEditorLocale
|
||||
}
|
||||
|
||||
declare class ImageEditor extends UIPlugin<ImageEditorOptions> {}
|
||||
|
||||
export default ImageEditor
|
||||
|
||||
// Events
|
||||
|
||||
export type FileEditorStartCallback<TMeta extends IndexedObject<any>> = (
|
||||
file: UppyFile<TMeta>,
|
||||
) => void
|
||||
export type FileEditorCompleteCallback<TMeta extends IndexedObject<any>> = (
|
||||
updatedFile: UppyFile<TMeta>,
|
||||
) => void
|
||||
export type FileEditorCancelCallback<TMeta extends IndexedObject<any>> = (
|
||||
file: UppyFile<TMeta>,
|
||||
) => void
|
||||
|
||||
declare module '@uppy/core' {
|
||||
export interface UppyEventMap<TMeta extends IndexedObject<any>> {
|
||||
'file-editor:start': FileEditorStartCallback<TMeta>
|
||||
'file-editor:complete': FileEditorCompleteCallback<TMeta>
|
||||
'file-editor:cancel': FileEditorCancelCallback<TMeta>
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
// TODO implement
|
||||
|
||||
import Uppy from '@uppy/core'
|
||||
import ImageEditor from '..'
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
|
||||
uppy.use(ImageEditor)
|
||||
|
||||
uppy.on('file-editor:start', (file) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const fileName = file.name
|
||||
})
|
||||
uppy.on('file-editor:complete', (file) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const fileName = file.name
|
||||
})
|
||||
uppy.on('file-editor:cancel', (file) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const fileName = file.name
|
||||
})
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"style": "dist/style.min.css",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
9
packages/@uppy/informer/types/index.d.ts
vendored
9
packages/@uppy/informer/types/index.d.ts
vendored
|
|
@ -1,9 +0,0 @@
|
|||
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
|
||||
|
||||
interface InformerOptions extends UIPluginOptions {
|
||||
target?: PluginTarget
|
||||
}
|
||||
|
||||
declare class Informer extends UIPlugin<InformerOptions> {}
|
||||
|
||||
export default Informer
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
// import Informer from '..'
|
||||
// TODO implement
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
"version": "3.1.3",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
17
packages/@uppy/instagram/types/index.d.ts
vendored
17
packages/@uppy/instagram/types/index.d.ts
vendored
|
|
@ -1,17 +0,0 @@
|
|||
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
|
||||
import type {
|
||||
PublicProviderOptions,
|
||||
TokenStorage,
|
||||
} from '@uppy/companion-client'
|
||||
|
||||
export interface InstagramOptions
|
||||
extends UIPluginOptions,
|
||||
PublicProviderOptions {
|
||||
target?: PluginTarget
|
||||
title?: string
|
||||
storage?: TokenStorage
|
||||
}
|
||||
|
||||
declare class Instagram extends UIPlugin<InstagramOptions> {}
|
||||
|
||||
export default Instagram
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
import Uppy from '@uppy/core'
|
||||
import Instagram from '..'
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.use(Instagram, {
|
||||
companionUrl: '',
|
||||
companionCookiesRule: 'same-origin',
|
||||
target: 'body',
|
||||
title: 'title',
|
||||
})
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
"version": "3.1.4",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
17
packages/@uppy/onedrive/types/index.d.ts
vendored
17
packages/@uppy/onedrive/types/index.d.ts
vendored
|
|
@ -1,17 +0,0 @@
|
|||
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
|
||||
import type {
|
||||
PublicProviderOptions,
|
||||
TokenStorage,
|
||||
} from '@uppy/companion-client'
|
||||
|
||||
export interface OneDriveOptions
|
||||
extends UIPluginOptions,
|
||||
PublicProviderOptions {
|
||||
target?: PluginTarget
|
||||
title?: string
|
||||
storage?: TokenStorage
|
||||
}
|
||||
|
||||
declare class OneDrive extends UIPlugin<OneDriveOptions> {}
|
||||
|
||||
export default OneDrive
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
import Uppy from '@uppy/core'
|
||||
import OneDrive from '..'
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.use(OneDrive, {
|
||||
companionUrl: '',
|
||||
companionCookiesRule: 'same-origin',
|
||||
target: 'body',
|
||||
title: 'title',
|
||||
})
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"style": "dist/style.min.css",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
11
packages/@uppy/progress-bar/types/index.d.ts
vendored
11
packages/@uppy/progress-bar/types/index.d.ts
vendored
|
|
@ -1,11 +0,0 @@
|
|||
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
|
||||
|
||||
export interface ProgressBarOptions extends UIPluginOptions {
|
||||
target?: PluginTarget
|
||||
hideAfterFinish?: boolean
|
||||
fixed?: boolean
|
||||
}
|
||||
|
||||
declare class ProgressBar extends UIPlugin<ProgressBarOptions> {}
|
||||
|
||||
export default ProgressBar
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
import Uppy from '@uppy/core'
|
||||
import ProgressBar from '..'
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.use(ProgressBar, {
|
||||
target: 'body',
|
||||
hideAfterFinish: true,
|
||||
fixed: true,
|
||||
})
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"style": "dist/style.min.css",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
21
packages/@uppy/provider-views/types/index.d.ts
vendored
21
packages/@uppy/provider-views/types/index.d.ts
vendored
|
|
@ -1,21 +0,0 @@
|
|||
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
|
||||
}
|
||||
|
||||
interface OnFirstRenderer {
|
||||
onFirstRender: () => any
|
||||
}
|
||||
|
||||
declare class ProviderView {
|
||||
constructor(plugin: UIPlugin & OnFirstRenderer, opts: ProviderViewOptions)
|
||||
// @todo add other provider view methods
|
||||
}
|
||||
|
||||
export default ProviderView
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
"version": "3.2.1",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
7
packages/@uppy/react/types/index.d.ts
vendored
7
packages/@uppy/react/types/index.d.ts
vendored
|
|
@ -1,7 +0,0 @@
|
|||
export { default as Dashboard } from '../src/Dashboard'
|
||||
export { default as DashboardModal } from '../src/DashboardModal'
|
||||
export { default as DragDrop } from '../src/DragDrop'
|
||||
export { default as ProgressBar } from '../src/ProgressBar'
|
||||
export { default as StatusBar } from '../src/StatusBar'
|
||||
export { default as FileInput } from '../src/FileInput'
|
||||
export { default as useUppy } from '../src/useUppy'
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
import * as React from 'react'
|
||||
import Uppy from '@uppy/core'
|
||||
import { expectType, expectError } from 'tsd'
|
||||
import * as components from '../'
|
||||
|
||||
const { useUppy } = components
|
||||
|
||||
const uppy = new Uppy()
|
||||
|
||||
{
|
||||
function TestComponent() {
|
||||
return (
|
||||
<components.Dashboard uppy={uppy} closeAfterFinish hideCancelButton />
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
expectError(<components.Dashboard target="body" />)
|
||||
}
|
||||
|
||||
// inline option should be removed from proptypes because it is always overridden
|
||||
// by the component
|
||||
{
|
||||
expectError(<components.Dashboard inline />)
|
||||
expectError(<components.DashboardModal inline />)
|
||||
}
|
||||
|
||||
{
|
||||
const el = (
|
||||
<components.DragDrop
|
||||
width={200}
|
||||
height={200}
|
||||
note="Images up to 200×200px"
|
||||
uppy={uppy}
|
||||
locale={{
|
||||
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}',
|
||||
// Used as the label for the link that opens the system file selection dialog.
|
||||
browse: 'browse',
|
||||
},
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
{
|
||||
const el = (
|
||||
<components.DashboardModal
|
||||
target="body"
|
||||
uppy={uppy}
|
||||
open
|
||||
animateOpenClose
|
||||
onRequestClose={() => {
|
||||
alert('no')
|
||||
}}
|
||||
/>
|
||||
)
|
||||
|
||||
// use onRequestClose instead.
|
||||
expectError(<components.DashboardModal onRequestCloseModal />)
|
||||
}
|
||||
|
||||
{
|
||||
function TestHook() {
|
||||
expectType<Uppy>(useUppy(() => uppy))
|
||||
expectType<Uppy>(useUppy(() => new Uppy()))
|
||||
expectError(useUppy(uppy))
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
"version": "3.0.3",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
import type { UIPlugin, UIPluginOptions } from '@uppy/core'
|
||||
|
||||
type ReduxDevToolsOptions = UIPluginOptions
|
||||
|
||||
declare class ReduxDevTools extends UIPlugin<ReduxDevToolsOptions> {}
|
||||
|
||||
export default ReduxDevTools
|
||||
|
|
@ -1 +0,0 @@
|
|||
// import ReduxDevTools from '..'
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
"version": "1.1.0",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
13
packages/@uppy/remote-sources/types/index.d.ts
vendored
13
packages/@uppy/remote-sources/types/index.d.ts
vendored
|
|
@ -1,13 +0,0 @@
|
|||
import type { PluginOptions, BasePlugin, PluginTarget } from '@uppy/core'
|
||||
import type { RequestClientOptions } from '@uppy/companion-client'
|
||||
|
||||
interface RemoteTargetOptions extends PluginOptions, RequestClientOptions {
|
||||
target?: PluginTarget
|
||||
sources?: Array<string>
|
||||
title?: string
|
||||
companionUrl: string
|
||||
}
|
||||
|
||||
declare class RemoteTarget extends BasePlugin<RemoteTargetOptions> {}
|
||||
|
||||
export default RemoteTarget
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
import Uppy from '@uppy/core'
|
||||
import RemoteSources from '..'
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.use(RemoteSources, {
|
||||
sources: ['Instagram', 'Url'],
|
||||
companionUrl: '',
|
||||
companionCookiesRule: 'same-origin',
|
||||
})
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"style": "dist/style.min.css",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
25
packages/@uppy/screen-capture/types/index.d.ts
vendored
25
packages/@uppy/screen-capture/types/index.d.ts
vendored
|
|
@ -1,25 +0,0 @@
|
|||
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
|
||||
})
|
||||
}
|
||||
|
||||
export interface ScreenCaptureOptions extends UIPluginOptions {
|
||||
target?: PluginTarget
|
||||
displayMediaConstraints?: DisplayMediaStreamConstraints
|
||||
userMediaConstraints?: MediaStreamConstraints
|
||||
preferredVideoMimeType?: string
|
||||
}
|
||||
|
||||
declare class ScreenCapture extends UIPlugin<ScreenCaptureOptions> {}
|
||||
|
||||
export default ScreenCapture
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
import { expectError } from 'tsd'
|
||||
import Uppy from '@uppy/core'
|
||||
import ScreenCapture from '..'
|
||||
|
||||
new Uppy().use(ScreenCapture)
|
||||
new Uppy().use(ScreenCapture, {})
|
||||
new Uppy().use(ScreenCapture, { preferredVideoMimeType: 'video/mp4' })
|
||||
expectError(new Uppy().use(ScreenCapture, { preferredVideoMimeType: 10 }))
|
||||
|
||||
new Uppy().use(ScreenCapture, {
|
||||
displayMediaConstraints: {
|
||||
video: { displaySurface: 'window' },
|
||||
},
|
||||
})
|
||||
expectError(
|
||||
new Uppy().use(ScreenCapture, {
|
||||
displayMediaConstraints: {
|
||||
video: { displaySurface: 'some nonsense' },
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"style": "dist/style.min.css",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
20
packages/@uppy/status-bar/types/index.d.ts
vendored
20
packages/@uppy/status-bar/types/index.d.ts
vendored
|
|
@ -1,20 +0,0 @@
|
|||
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
|
||||
import GeneratedLocale from './generatedLocale'
|
||||
|
||||
export type StatusBarLocale = GeneratedLocale
|
||||
|
||||
export interface StatusBarOptions extends UIPluginOptions {
|
||||
target?: PluginTarget
|
||||
showProgressDetails?: boolean
|
||||
hideUploadButton?: boolean
|
||||
hideAfterFinish?: boolean
|
||||
hideRetryButton?: boolean
|
||||
hidePauseResumeButton?: boolean
|
||||
hideCancelButton?: boolean
|
||||
doneButtonHandler?: () => void
|
||||
locale?: StatusBarLocale
|
||||
}
|
||||
|
||||
declare class StatusBar extends UIPlugin<StatusBarOptions> {}
|
||||
|
||||
export default StatusBar
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
import Uppy from '@uppy/core'
|
||||
import StatusBar from '..'
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.use(StatusBar, {
|
||||
target: 'body',
|
||||
showProgressDetails: true,
|
||||
hideUploadButton: false,
|
||||
hideAfterFinish: false,
|
||||
hideRetryButton: false,
|
||||
hidePauseResumeButton: false,
|
||||
hideCancelButton: false,
|
||||
doneButtonHandler: () => {
|
||||
// something
|
||||
},
|
||||
locale: {
|
||||
strings: {
|
||||
uploading: '',
|
||||
upload: '',
|
||||
complete: '',
|
||||
uploadFailed: '',
|
||||
paused: '',
|
||||
retry: '',
|
||||
retryUpload: '',
|
||||
cancel: '',
|
||||
pause: '',
|
||||
resume: '',
|
||||
done: '',
|
||||
filesUploadedOfTotal: '',
|
||||
dataUploadedOfTotal: '',
|
||||
xTimeLeft: '',
|
||||
uploadXFiles: '',
|
||||
uploadXNewFiles: '',
|
||||
xMoreFilesAdded: '',
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
"version": "3.0.5",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
18
packages/@uppy/store-default/types/index.d.ts
vendored
18
packages/@uppy/store-default/types/index.d.ts
vendored
|
|
@ -1,18 +0,0 @@
|
|||
import type { Store } from '@uppy/utils'
|
||||
|
||||
type State = Record<string, unknown>
|
||||
type StateChangeListener = (
|
||||
prevState: State,
|
||||
nextState: State,
|
||||
patch: State,
|
||||
) => void
|
||||
|
||||
export default class DefaultStore implements Store {
|
||||
constructor()
|
||||
|
||||
getState(): State
|
||||
|
||||
setState(patch: State): void
|
||||
|
||||
subscribe(listener: StateChangeListener): () => void
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
import DefaultStore from '..'
|
||||
|
||||
const store = new DefaultStore()
|
||||
|
||||
store.setState({ a: 'b' })
|
||||
store.getState()
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
"version": "3.0.5",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
31
packages/@uppy/store-redux/types/index.d.ts
vendored
31
packages/@uppy/store-redux/types/index.d.ts
vendored
|
|
@ -1,31 +0,0 @@
|
|||
import type { Store } from '@uppy/utils'
|
||||
import type { Reducer, Middleware, Store as Redux } from 'redux'
|
||||
|
||||
type State = Record<string, unknown>
|
||||
type StateChangeListener = (
|
||||
prevState: State,
|
||||
nextState: State,
|
||||
patch: State,
|
||||
) => void
|
||||
|
||||
interface ReduxStoreOptions {
|
||||
store: Redux<State>
|
||||
id?: string
|
||||
selector?: (state: any) => State
|
||||
}
|
||||
|
||||
export class ReduxStore implements Store {
|
||||
constructor(opts: ReduxStoreOptions)
|
||||
|
||||
getState(): State
|
||||
|
||||
setState(patch: State): void
|
||||
|
||||
subscribe(listener: StateChangeListener): () => void
|
||||
}
|
||||
|
||||
export const reducer: Reducer<any>
|
||||
export const middleware: Middleware
|
||||
export const STATE_UPDATE: string
|
||||
|
||||
export default ReduxStore
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { createStore, combineReducers } from 'redux'
|
||||
// eslint-disable-next-line import/no-named-as-default
|
||||
import ReduxStore, { reducer as uppy } from '..'
|
||||
|
||||
const reducer = combineReducers({ uppy })
|
||||
|
||||
const store = new ReduxStore({
|
||||
store: createStore(reducer),
|
||||
})
|
||||
|
||||
store.setState({ a: 1 })
|
||||
store.getState()
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
"version": "3.0.6",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
import type {
|
||||
IndexedObject,
|
||||
UIPlugin,
|
||||
UIPluginOptions,
|
||||
UppyFile,
|
||||
} from '@uppy/core'
|
||||
|
||||
import ThumbnailGeneratorLocale from './generatedLocale'
|
||||
|
||||
export interface ThumbnailOptions extends UIPluginOptions {
|
||||
thumbnailWidth?: number
|
||||
thumbnailHeight?: number
|
||||
thumbnailType?: string
|
||||
waitForThumbnailsBeforeUpload?: boolean
|
||||
lazy?: boolean
|
||||
}
|
||||
|
||||
interface Options extends ThumbnailOptions {
|
||||
locale?: ThumbnailGeneratorLocale
|
||||
}
|
||||
|
||||
declare class ThumbnailGenerator extends UIPlugin<Options> {}
|
||||
|
||||
export default ThumbnailGenerator
|
||||
|
||||
// Events
|
||||
|
||||
export type ThumbnailGeneratedCallback<TMeta extends IndexedObject<any>> = (
|
||||
file: UppyFile<TMeta>,
|
||||
preview: string,
|
||||
) => void
|
||||
|
||||
declare module '@uppy/core' {
|
||||
export interface UppyEventMap<TMeta> {
|
||||
'thumbnail:generated': ThumbnailGeneratedCallback<TMeta>
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
import Uppy from '@uppy/core'
|
||||
import ThumbnailGenerator from '..'
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.use(ThumbnailGenerator, {
|
||||
thumbnailWidth: 100,
|
||||
thumbnailHeight: 100,
|
||||
thumbnailType: 'type',
|
||||
waitForThumbnailsBeforeUpload: true,
|
||||
lazy: true,
|
||||
locale: {
|
||||
strings: {
|
||||
generatingThumbnails: '',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
uppy.on('thumbnail:generated', (file, preview) => {
|
||||
const img = document.createElement('img')
|
||||
img.src = preview
|
||||
img.width = 100
|
||||
document.body.appendChild(img)
|
||||
})
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
"version": "3.4.0",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
194
packages/@uppy/transloadit/types/index.d.ts
vendored
194
packages/@uppy/transloadit/types/index.d.ts
vendored
|
|
@ -1,194 +0,0 @@
|
|||
import type { PluginOptions, UppyFile, BasePlugin } from '@uppy/core'
|
||||
import TransloaditLocale from './generatedLocale'
|
||||
|
||||
export interface FileInfo {
|
||||
id: string
|
||||
name: string
|
||||
basename: string
|
||||
ext: string
|
||||
size: number
|
||||
mime: string
|
||||
type: string
|
||||
field: string
|
||||
md5hash: string
|
||||
is_tus_file: boolean
|
||||
original_md5hash: string
|
||||
original_id: string
|
||||
original_name: string
|
||||
original_basename: string
|
||||
original_path: string
|
||||
url: string
|
||||
ssl_url: string
|
||||
tus_upload_url: string
|
||||
meta: Record<string, any>
|
||||
}
|
||||
|
||||
export interface Result extends FileInfo {
|
||||
cost: number
|
||||
execTime: number
|
||||
queue: string
|
||||
queueTime: number
|
||||
localId: string | null
|
||||
}
|
||||
|
||||
export interface Assembly {
|
||||
ok?: string
|
||||
message?: string
|
||||
assembly_id: string
|
||||
parent_id?: string
|
||||
account_id: string
|
||||
template_id?: string
|
||||
instance: string
|
||||
assembly_url: string
|
||||
assembly_ssl_url: string
|
||||
uppyserver_url: string
|
||||
companion_url: string
|
||||
websocket_url: string
|
||||
tus_url: string
|
||||
bytes_received: number
|
||||
bytes_expected: number
|
||||
upload_duration: number
|
||||
client_agent?: string
|
||||
client_ip?: string
|
||||
client_referer?: string
|
||||
transloadit_client: string
|
||||
start_date: string
|
||||
upload_meta_data_extracted: boolean
|
||||
warnings: any[]
|
||||
is_infinite: boolean
|
||||
has_dupe_jobs: boolean
|
||||
execution_start: string
|
||||
execution_duration: number
|
||||
queue_duration: number
|
||||
jobs_queue_duration: number
|
||||
notify_start?: any
|
||||
notify_url?: string
|
||||
notify_status?: any
|
||||
notify_response_code?: any
|
||||
notify_duration?: any
|
||||
last_job_completed?: string
|
||||
fields: Record<string, any>
|
||||
running_jobs: any[]
|
||||
bytes_usage: number
|
||||
executing_jobs: any[]
|
||||
started_jobs: string[]
|
||||
parent_assembly_status: any
|
||||
params: string
|
||||
template?: any
|
||||
merged_params: string
|
||||
uploads: FileInfo[]
|
||||
results: Record<string, Result[]>
|
||||
build_id: string
|
||||
error?: string
|
||||
stderr?: string
|
||||
stdout?: string
|
||||
reason?: string
|
||||
}
|
||||
|
||||
interface AssemblyParameters {
|
||||
auth: {
|
||||
key: string
|
||||
expires?: string
|
||||
}
|
||||
template_id?: string
|
||||
steps?: { [step: string]: Record<string, unknown> }
|
||||
fields?: { [name: string]: number | string }
|
||||
notify_url?: string
|
||||
}
|
||||
|
||||
interface AssemblyOptions {
|
||||
params?: AssemblyParameters
|
||||
fields?: { [name: string]: number | string } | string[]
|
||||
signature?: string
|
||||
}
|
||||
|
||||
interface Options extends PluginOptions {
|
||||
service?: string
|
||||
errorReporting?: boolean
|
||||
waitForEncoding?: boolean
|
||||
waitForMetadata?: boolean
|
||||
importFromUploadURLs?: boolean
|
||||
alwaysRunAssembly?: boolean
|
||||
locale?: TransloaditLocale
|
||||
limit?: number
|
||||
}
|
||||
|
||||
export type TransloaditOptions = Options &
|
||||
(
|
||||
| {
|
||||
assemblyOptions?:
|
||||
| AssemblyOptions
|
||||
| ((file?: UppyFile) => Promise<AssemblyOptions> | AssemblyOptions)
|
||||
/** @deprecated use `assemblyOptions` instead */
|
||||
getAssemblyOptions?: never
|
||||
/** @deprecated use `assemblyOptions` instead */
|
||||
params?: never
|
||||
/** @deprecated use `assemblyOptions` instead */
|
||||
fields?: never
|
||||
/** @deprecated use `assemblyOptions` instead */
|
||||
signature?: never
|
||||
}
|
||||
| {
|
||||
/** @deprecated use `assemblyOptions` instead */
|
||||
getAssemblyOptions?: (
|
||||
file?: UppyFile,
|
||||
) => AssemblyOptions | Promise<AssemblyOptions>
|
||||
assemblyOptions?: never
|
||||
/** @deprecated use `assemblyOptions` instead */
|
||||
params?: never
|
||||
/** @deprecated use `assemblyOptions` instead */
|
||||
fields?: never
|
||||
/** @deprecated use `assemblyOptions` instead */
|
||||
signature?: never
|
||||
}
|
||||
| {
|
||||
/** @deprecated use `assemblyOptions` instead */
|
||||
params?: AssemblyParameters
|
||||
/** @deprecated use `assemblyOptions` instead */
|
||||
fields?: { [name: string]: number | string } | string[]
|
||||
/** @deprecated use `assemblyOptions` instead */
|
||||
signature?: string
|
||||
/** @deprecated use `assemblyOptions` instead */
|
||||
getAssemblyOptions?: never
|
||||
assemblyOptions?: never
|
||||
}
|
||||
)
|
||||
|
||||
export default class Transloadit extends BasePlugin<TransloaditOptions> {
|
||||
/** @deprecated use `import { COMPANION_URL } from '@uppy/transloadit'` instead. */
|
||||
static COMPANION: string
|
||||
|
||||
/** @deprecated use `import { COMPANION_ALLOWED_HOSTS } from '@uppy/transloadit'` instead. */
|
||||
static COMPANION_PATTERN: RegExp
|
||||
}
|
||||
|
||||
export const COMPANION_URL: string
|
||||
export const COMPANION_ALLOWED_HOSTS: RegExp
|
||||
|
||||
// Events
|
||||
|
||||
export type TransloaditAssemblyCreatedCallback = (
|
||||
assembly: Assembly,
|
||||
fileIDs: string[],
|
||||
) => void
|
||||
export type TransloaditUploadedCallback = (
|
||||
file: FileInfo,
|
||||
assembly: Assembly,
|
||||
) => void
|
||||
export type TransloaditAssemblyExecutingCallback = (assembly: Assembly) => void
|
||||
export type TransloaditResultCallback = (
|
||||
stepName: string,
|
||||
result: Result,
|
||||
assembly: Assembly,
|
||||
) => void
|
||||
export type TransloaditCompleteCallback = (assembly: Assembly) => void
|
||||
|
||||
declare module '@uppy/core' {
|
||||
export interface UppyEventMap {
|
||||
'transloadit:assembly-created': TransloaditAssemblyCreatedCallback
|
||||
'transloadit:upload': TransloaditUploadedCallback
|
||||
'transloadit:assembly-executing': TransloaditAssemblyExecutingCallback
|
||||
'transloadit:result': TransloaditResultCallback
|
||||
'transloadit:complete': TransloaditCompleteCallback
|
||||
}
|
||||
}
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
import { expectError, expectType } from 'tsd'
|
||||
import Uppy from '@uppy/core'
|
||||
import type { UppyFile } from '@uppy/core'
|
||||
import Transloadit, { COMPANION_ALLOWED_HOSTS, COMPANION_URL } from '..'
|
||||
|
||||
expectType<string>(Transloadit.COMPANION)
|
||||
expectType<string>(COMPANION_URL)
|
||||
expectType<RegExp>(Transloadit.COMPANION_PATTERN)
|
||||
expectType<RegExp>(COMPANION_ALLOWED_HOSTS)
|
||||
|
||||
const validParams = {
|
||||
auth: { key: 'not so secret key' },
|
||||
}
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.use(Transloadit, {
|
||||
getAssemblyOptions(file) {
|
||||
expectType<UppyFile | undefined>(file)
|
||||
return { params: validParams }
|
||||
},
|
||||
waitForEncoding: false,
|
||||
waitForMetadata: true,
|
||||
importFromUploadURLs: false,
|
||||
})
|
||||
// Access to both transloadit events and core events
|
||||
uppy.on('transloadit:assembly-created', (assembly) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const status = assembly.ok
|
||||
})
|
||||
|
||||
uppy.on('complete', (result) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const success = result.successful
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.use(Transloadit, {
|
||||
async assemblyOptions(file) {
|
||||
expectType<UppyFile | undefined>(file)
|
||||
return { params: validParams }
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
uppy.use(Transloadit, {
|
||||
assemblyOptions: { params: validParams },
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
expectError(
|
||||
uppy.use(Transloadit, {
|
||||
getAssemblyOptions() {
|
||||
return { params: validParams }
|
||||
},
|
||||
assemblyOptions: { params: validParams },
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
expectError(
|
||||
uppy.use(Transloadit, {
|
||||
params: validParams,
|
||||
assemblyOptions: { params: validParams },
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
// must be bools
|
||||
expectError(
|
||||
uppy.use(Transloadit, { waitForEncoding: null, params: validParams }),
|
||||
)
|
||||
expectError(
|
||||
uppy.use(Transloadit, { waitForMetadata: null, params: validParams }),
|
||||
)
|
||||
}
|
||||
|
||||
{
|
||||
const uppy = new Uppy()
|
||||
// params.auth.key must be string
|
||||
expectError(uppy.use(Transloadit, { params: {} }))
|
||||
expectError(uppy.use(Transloadit, { params: { auth: {} } }))
|
||||
expectError(
|
||||
uppy.use(Transloadit, {
|
||||
params: {
|
||||
auth: { key: null },
|
||||
},
|
||||
}),
|
||||
)
|
||||
expectError(
|
||||
uppy.use(Transloadit, {
|
||||
params: {
|
||||
auth: { key: 'abc' },
|
||||
steps: 'test',
|
||||
},
|
||||
}),
|
||||
)
|
||||
uppy.use(Transloadit, {
|
||||
params: {
|
||||
auth: { key: 'abc' },
|
||||
steps: { name: {} },
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
"version": "3.4.0",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
42
packages/@uppy/tus/types/index.d.ts
vendored
42
packages/@uppy/tus/types/index.d.ts
vendored
|
|
@ -1,42 +0,0 @@
|
|||
import type { PluginOptions, BasePlugin, UppyFile } from '@uppy/core'
|
||||
import type { UploadOptions, HttpRequest } from 'tus-js-client'
|
||||
|
||||
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
|
||||
|
||||
export interface TusOptions extends PluginOptions, TusUploadOptions {
|
||||
allowedMetaFields?: string[] | null
|
||||
limit?: number
|
||||
withCredentials?: boolean
|
||||
onShouldRetry?: (
|
||||
err: Error | undefined,
|
||||
retryAttempt: number,
|
||||
options: TusOptions,
|
||||
next: Next,
|
||||
) => boolean
|
||||
onBeforeRequest?: (req: HttpRequest, file: UppyFile) => Promise<void>
|
||||
}
|
||||
|
||||
declare class Tus extends BasePlugin<TusOptions> {}
|
||||
|
||||
export default Tus
|
||||
|
|
@ -1 +0,0 @@
|
|||
// import Tus from '../'
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
"version": "3.2.3",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"file uploader",
|
||||
|
|
|
|||
11
packages/@uppy/unsplash/types/index.d.ts
vendored
11
packages/@uppy/unsplash/types/index.d.ts
vendored
|
|
@ -1,11 +0,0 @@
|
|||
import type { RequestClientOptions } from '@uppy/companion-client'
|
||||
import type { PluginTarget, UIPlugin, UIPluginOptions } from '@uppy/core'
|
||||
|
||||
interface UnsplashOptions extends UIPluginOptions, RequestClientOptions {
|
||||
target?: PluginTarget
|
||||
title?: string
|
||||
}
|
||||
|
||||
declare class Unsplash extends UIPlugin<UnsplashOptions> {}
|
||||
|
||||
export default Unsplash
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue