use-tus 0.3.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -33
- package/dist/TusClientProvider/TusClientProvider.d.ts +6 -4
- package/dist/TusClientProvider/constants.d.ts +4 -0
- package/dist/TusClientProvider/index.d.ts +3 -2
- package/dist/{core → TusClientProvider/store}/contexts.d.ts +7 -7
- package/dist/{core → TusClientProvider/store}/tucClientActions.d.ts +49 -47
- package/dist/{core → TusClientProvider/store}/tusClientReducer.d.ts +18 -18
- package/dist/TusClientProvider/types.d.ts +2 -0
- package/dist/__stories__/Basic.stories.d.ts +5 -0
- package/dist/__stories__/CacheKey.stories.d.ts +5 -0
- package/dist/__stories__/DefaultOptions.stories.d.ts +5 -0
- package/dist/__stories__/components/BasicButton/BasicButton.d.ts +9 -0
- package/dist/__stories__/components/BasicButton/index.d.ts +1 -0
- package/dist/__stories__/components/LoadingCircle/LoadingCircle.d.ts +2 -0
- package/dist/__stories__/components/LoadingCircle/index.d.ts +1 -0
- package/dist/__stories__/components/ProgressBar/ProgressBar.d.ts +7 -0
- package/dist/__stories__/components/ProgressBar/index.d.ts +1 -0
- package/dist/__stories__/components/UploadIcon/UploadIcon.d.ts +2 -0
- package/dist/__stories__/components/UploadIcon/index.d.ts +1 -0
- package/dist/__stories__/constants.d.ts +1 -0
- package/dist/__tests__/TusClientProvider.test.d.ts +1 -0
- package/dist/__tests__/useTus.test.d.ts +1 -0
- package/dist/__tests__/useTusStore.test.d.ts +1 -0
- package/dist/__tests__/utils/getBlob.d.ts +1 -0
- package/dist/__tests__/utils/getDefaultOptions.d.ts +2 -0
- package/dist/__tests__/utils/mock.d.ts +6 -0
- package/dist/index.cjs.js +289 -1751
- package/dist/index.d.ts +3 -4
- package/dist/index.esm.js +280 -1719
- package/dist/index.js +345 -0
- package/dist/useTus/index.d.ts +3 -2
- package/dist/useTus/types.d.ts +14 -15
- package/dist/useTus/useTus.d.ts +2 -2
- package/dist/useTus/useTusStore.d.ts +2 -0
- package/dist/useTus/utils/createUpload.d.ts +3 -0
- package/dist/useTus/utils/startOrResumeUpload.d.ts +2 -0
- package/dist/useTus/utils/useAutoAbort.d.ts +2 -0
- package/dist/useTus/utils/useMergeTusOptions.d.ts +6 -0
- package/dist/useTusClient/index.d.ts +1 -0
- package/dist/useTusClient/useTusClient.d.ts +7 -0
- package/package.json +9 -9
- package/dist/TusClientProvider/TusController.d.ts +0 -4
- package/dist/core/constants.d.ts +0 -4
- package/dist/core/tusHandler.d.ts +0 -17
- package/dist/core/types.d.ts +0 -8
- package/dist/useTus/utils.d.ts +0 -16
- package/dist/utils/uid.d.ts +0 -1
package/README.md
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
## Features
|
|
16
16
|
- Resumable file uploads on react.
|
|
17
|
+
- Lightweight and simple interface hooks.
|
|
17
18
|
- Managing the [Upload](https://github.com/tus/tus-js-client/blob/master/docs/api.md#tusuploadfile-options) by using context.
|
|
18
|
-
- One dependency ([tus-js-client](https://github.com/tus/tus-js-client)).
|
|
19
19
|
- TypeScript support.
|
|
20
20
|
|
|
21
21
|
## Demo
|
|
@@ -25,25 +25,20 @@ You can try the [use-tus demo](https://kqito.github.io/use-tus/?path=/story/uset
|
|
|
25
25
|
## Installation
|
|
26
26
|
You can install the package from npm.
|
|
27
27
|
```sh
|
|
28
|
-
npm install use-tus
|
|
28
|
+
npm install use-tus tus-js-client
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
or
|
|
32
|
+
|
|
32
33
|
```sh
|
|
33
|
-
yarn add use-tus
|
|
34
|
+
yarn add use-tus tus-js-client
|
|
34
35
|
```
|
|
35
36
|
|
|
36
37
|
## Usage
|
|
37
38
|
We can use `useTus` as following.
|
|
38
39
|
|
|
39
40
|
```tsx
|
|
40
|
-
import { useTus
|
|
41
|
-
|
|
42
|
-
const App = () => (
|
|
43
|
-
<TusClientProvider>
|
|
44
|
-
<Uploader />
|
|
45
|
-
</TusClientProvider>
|
|
46
|
-
);
|
|
41
|
+
import { useTus } from 'use-tus'
|
|
47
42
|
|
|
48
43
|
const Uploader = () => {
|
|
49
44
|
const { upload, setUpload, isSuccess, error, remove } = useTus();
|
|
@@ -71,7 +66,7 @@ const Uploader = () => {
|
|
|
71
66
|
return;
|
|
72
67
|
}
|
|
73
68
|
|
|
74
|
-
// Start upload the file.
|
|
69
|
+
// Start to upload the file.
|
|
75
70
|
upload.start();
|
|
76
71
|
}, [upload]);
|
|
77
72
|
|
|
@@ -91,27 +86,79 @@ const Uploader = () => {
|
|
|
91
86
|
### `useTus` hooks
|
|
92
87
|
|
|
93
88
|
```tsx
|
|
94
|
-
const { upload, setUpload, isSuccess, isAborted, error, remove } = useTus({
|
|
89
|
+
const { upload, setUpload, isSuccess, isAborted, error, remove } = useTus({ autoAbort, autoStart, uploadOptions });
|
|
95
90
|
```
|
|
96
91
|
|
|
97
|
-
`useTus` is a hooks
|
|
92
|
+
`useTus` is a hooks that creates an object to perform Resumable file upload.
|
|
98
93
|
|
|
99
94
|
### Arguments
|
|
100
|
-
- `cacheKey` (type: `string | undefined`)
|
|
101
|
-
- Specify the key associated with the `Upload` if it's undefined, a random string will be specified.
|
|
102
|
-
|
|
103
95
|
- `autoAbort` (type: `boolean | undefined`) (default: true)
|
|
104
96
|
- Whether or not to automatically abort uploads when useTus hooks is unmounted.
|
|
105
97
|
|
|
106
98
|
- `autoStart` (type: `boolean | undefined`) (default: false)
|
|
107
99
|
- Whether or not to start upload the file after `setUpload` function.
|
|
108
100
|
|
|
101
|
+
- `uploadOptions` (type: `UploadOptions | undefined`) (default: undefined)
|
|
102
|
+
- Option to used by upload object that generated by that hooks.
|
|
103
|
+
- For detail type information of `UploadOptions`, please see [here](https://github.com/tus/tus-js-client/blob/master/lib/index.d.ts#L22).
|
|
104
|
+
|
|
105
|
+
### Returns
|
|
106
|
+
- `upload` (type: `tus.Upload | undefined`)
|
|
107
|
+
- Object to be used when performing Resumable file upload.
|
|
108
|
+
- This value is undefined unless the `setUpload` function called.
|
|
109
|
+
- For detail usage, please see [here](https://github.com/tus/tus-js-client#example)
|
|
110
|
+
|
|
111
|
+
- `setUpload` (type: `(file: tus.Upload['file'], options?: UploadOptions) => void`)
|
|
112
|
+
- Function to create an `Upload`.
|
|
113
|
+
- The property specified in `uploadOptions` will be overwritten if property of `options` are speicified.
|
|
114
|
+
|
|
115
|
+
- `isSuccess` (type: `boolean`)
|
|
116
|
+
- Whether the upload was successful or not.
|
|
117
|
+
|
|
118
|
+
- `isAborted` (type: `boolean`)
|
|
119
|
+
- Whether the upload was aborted or not.
|
|
120
|
+
|
|
121
|
+
- `error` (type: `Error | undefined`)
|
|
122
|
+
- Error when upload fails.
|
|
123
|
+
|
|
124
|
+
- `remove` (type: `() => void`)
|
|
125
|
+
- Function to reset states.
|
|
126
|
+
|
|
127
|
+
### `useTusStore` hooks
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
const { upload, setUpload, isSuccess, isAborted, error, remove } = useTusStore(cacheKey, { autoAbort, autoStart, uploadOptions });
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
`useTusStore` is a hooks that creates an object for resumable file upload and stores it in a context.
|
|
134
|
+
|
|
135
|
+
This hooks is useful when you want to handle uploads across pages or components.
|
|
136
|
+
|
|
137
|
+
**Note that using `useTusStore` hooks, the `TusClientProvider` must be specified as the parent or higher element.**
|
|
138
|
+
|
|
139
|
+
### Arguments
|
|
140
|
+
- `cacheKey` (type: `string`)
|
|
141
|
+
- Specify the key associated with the `Upload` object is created by `setUpload` function.
|
|
142
|
+
|
|
143
|
+
- `autoAbort` (type: `boolean | undefined`) (default: true)
|
|
144
|
+
- Whether or not to automatically abort uploads when useTusStore hooks is unmounted.
|
|
145
|
+
|
|
146
|
+
- `autoStart` (type: `boolean | undefined`) (default: false)
|
|
147
|
+
- Whether or not to start upload the file after `setUpload` function.
|
|
148
|
+
|
|
149
|
+
- `uploadOptions` (type: `UploadOptions | undefined`) (default: undefined)
|
|
150
|
+
- Option to used by upload object that generated by that hooks.
|
|
151
|
+
- For detail type information of `UploadOptions`, please see [here](https://github.com/tus/tus-js-client/blob/master/lib/index.d.ts#L22).
|
|
152
|
+
|
|
109
153
|
### Returns
|
|
110
154
|
- `upload` (type: `tus.Upload | undefined`)
|
|
111
|
-
-
|
|
155
|
+
- Object to be used when performing Resumable file upload.
|
|
156
|
+
- This value of the `Upload` associated with the cacheKey in the TusClientProvider. If not present, undefined.
|
|
157
|
+
- For detail usage, please see [here](https://github.com/tus/tus-js-client#example)
|
|
112
158
|
|
|
113
159
|
- `setUpload` (type: `(file: tus.Upload['file'], options?: tus.Upload['options']) => void`)
|
|
114
|
-
- Function to create an `Upload
|
|
160
|
+
- Function to create an `Upload`.
|
|
161
|
+
- The property specified in `uploadOptions` will be overwritten if property of `options` are speicified.
|
|
115
162
|
|
|
116
163
|
- `isSuccess` (type: `boolean`)
|
|
117
164
|
- Whether the upload was successful or not.
|
|
@@ -129,28 +176,38 @@ const { upload, setUpload, isSuccess, isAborted, error, remove } = useTus({ cach
|
|
|
129
176
|
|
|
130
177
|
```tsx
|
|
131
178
|
() => (
|
|
132
|
-
<TusClientProvider>
|
|
179
|
+
<TusClientProvider defaultOptions={defaultOptions}>
|
|
133
180
|
{children}
|
|
134
181
|
</TusClientProvider>
|
|
135
182
|
)
|
|
136
183
|
```
|
|
137
184
|
|
|
138
|
-
`TusClientProvider` is the provider that stores the `Upload` with `
|
|
139
|
-
|
|
140
|
-
**In order to use `useTus`, you need to set `TusClientProvider`.**
|
|
185
|
+
`TusClientProvider` is the provider that stores the `Upload` with `useTusStore` hooks.
|
|
141
186
|
|
|
142
187
|
### Props
|
|
143
|
-
- `
|
|
144
|
-
- A boolean indicating whether the current environment allows storing URLs enabling the corresponding upload to be resumed. [detail](https://github.com/tus/tus-js-client/blob/master/docs/api.md#tuscanstoreurls)
|
|
145
|
-
|
|
146
|
-
- `defaultOptions` (type: `(file: tus.Upload['file']) => tus.DefaltOptions | undefined`)
|
|
188
|
+
- `defaultOptions` (type: `(file: tus.Upload['file']) => UploadOptions | undefined`)
|
|
147
189
|
- An object containing the default options used when creating a new upload. [detail](https://github.com/tus/tus-js-client/blob/master/docs/api.md#tusdefaultoptions)
|
|
148
190
|
|
|
191
|
+
### `useTusClient`
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
const { state, removeUpload, reset } = useTusClient();
|
|
195
|
+
```
|
|
196
|
+
`useTusClient` is a hooks that can be used to retrieve and reset the state of a `TusClientProvider`.
|
|
197
|
+
|
|
198
|
+
### Returns
|
|
199
|
+
- `state` (type: `{ [cacheKey: string]: UploadState | undefined }`)
|
|
200
|
+
- Upload information associated with cacheKey
|
|
201
|
+
|
|
202
|
+
- `removeUpload` (type: `(cacheKey: string) => void`)
|
|
203
|
+
- Remove the upload instance associated with the specified cacheKey.
|
|
204
|
+
|
|
205
|
+
- `reset` (type: `() => void`)
|
|
206
|
+
- Initialize the value of TusClientProvider
|
|
207
|
+
|
|
149
208
|
## Examples
|
|
150
209
|
The following are some example of how to use `use-tus`.
|
|
151
210
|
|
|
152
|
-
Note that the `TusClientProvider` must be specified as the parent or higher element.
|
|
153
|
-
|
|
154
211
|
### Uploading a file
|
|
155
212
|
The setUpload and `upload.start` functions can be used to perform resumable file uploads.
|
|
156
213
|
|
|
@@ -272,7 +329,7 @@ const Uploader = () => {
|
|
|
272
329
|
You can specify default options in the `defaultOptions` props of the `TusClientProvider`.
|
|
273
330
|
|
|
274
331
|
```tsx
|
|
275
|
-
import {
|
|
332
|
+
import { useTusStore, DefaultOptions, TusClientProvider } from 'use-tus'
|
|
276
333
|
|
|
277
334
|
const defaultOptions: DefaultOptions = (contents) => {
|
|
278
335
|
const file = contents instanceof File ? contents : undefined;
|
|
@@ -295,7 +352,7 @@ const App = () => (
|
|
|
295
352
|
);
|
|
296
353
|
|
|
297
354
|
const Uploader = () => {
|
|
298
|
-
const { setUpload } =
|
|
355
|
+
const { setUpload } = useTusStore('cacheKey', { autoAtart: true });
|
|
299
356
|
|
|
300
357
|
const handleSetUpload = useCallback((event: ChangeEvent<HTMLInputElement>) => {
|
|
301
358
|
const file = event.target.files.item(0);
|
|
@@ -320,18 +377,18 @@ const Uploader = () => {
|
|
|
320
377
|
```
|
|
321
378
|
|
|
322
379
|
### Specify upload key
|
|
323
|
-
If you specify `cacheKey` as an argument to
|
|
380
|
+
If you specify `cacheKey` as an argument to useTusStore, you can get the `upload` associated with it. This is useful for cross-page file uploads.
|
|
324
381
|
|
|
325
382
|
```tsx
|
|
326
383
|
const SelectFileComponent = (file: File) => {
|
|
327
384
|
// Create upload accosiated with 'upload-thumbnail' key
|
|
328
|
-
const { setUpload } =
|
|
385
|
+
const { setUpload } = useTusStore('upload-thumbnail')
|
|
329
386
|
|
|
330
387
|
setUpload(file)
|
|
331
388
|
}
|
|
332
389
|
|
|
333
390
|
const UploadFileComponent = () => {
|
|
334
|
-
const { upload } =
|
|
391
|
+
const { upload } = useTusStore('upload-thumbnail')
|
|
335
392
|
|
|
336
393
|
upload.start()
|
|
337
394
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
export declare type TusClientProviderProps = Readonly<
|
|
4
|
-
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { DefaultOptions } from "./types";
|
|
3
|
+
export declare type TusClientProviderProps = Readonly<{
|
|
4
|
+
defaultOptions?: DefaultOptions;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const TusClientProvider: FC<TusClientProviderProps>;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { TusClientProvider } from
|
|
2
|
-
export type { TusClientProviderProps } from
|
|
1
|
+
export { TusClientProvider } from "./TusClientProvider";
|
|
2
|
+
export type { TusClientProviderProps } from "./TusClientProvider";
|
|
3
|
+
export type { DefaultOptions } from "./types";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Dispatch } from
|
|
2
|
-
import { TusClientActions } from
|
|
3
|
-
import { TusClientState } from
|
|
4
|
-
export declare const TusClientStateContext: import("react").Context<TusClientState | undefined>;
|
|
5
|
-
export declare const TusClientDispatchContext: import("react").Context<Dispatch<TusClientActions> | undefined>;
|
|
6
|
-
export declare const useTusClientState: () => TusClientState;
|
|
7
|
-
export declare const useTusClientDispatch: () => Dispatch<TusClientActions>;
|
|
1
|
+
import type { Dispatch } from "react";
|
|
2
|
+
import { TusClientActions } from "./tucClientActions";
|
|
3
|
+
import { TusClientState } from "./tusClientReducer";
|
|
4
|
+
export declare const TusClientStateContext: import("react").Context<TusClientState | undefined>;
|
|
5
|
+
export declare const TusClientDispatchContext: import("react").Context<Dispatch<TusClientActions> | undefined>;
|
|
6
|
+
export declare const useTusClientState: () => TusClientState;
|
|
7
|
+
export declare const useTusClientDispatch: () => Dispatch<TusClientActions>;
|
|
@@ -1,47 +1,49 @@
|
|
|
1
|
-
import type { Upload } from
|
|
2
|
-
import {
|
|
3
|
-
export declare type TusClientActions = ReturnType<typeof insertUploadInstance | typeof removeUploadInstance | typeof updateSuccessUpload | typeof updateErrorUpload | typeof updateIsAbortedUpload | typeof
|
|
4
|
-
export declare const insertUploadInstance: (cacheKey: string, upload: Upload) => {
|
|
5
|
-
readonly type: "INSERT_UPLOAD_INSTANCE";
|
|
6
|
-
readonly payload: {
|
|
7
|
-
readonly cacheKey: string;
|
|
8
|
-
readonly uploadState: {
|
|
9
|
-
readonly upload: Upload;
|
|
10
|
-
readonly isSuccess: false;
|
|
11
|
-
readonly isAborted: false;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export declare const updateSuccessUpload: (cacheKey: string) => {
|
|
16
|
-
readonly type: "UPDATE_SUCCESS_UPLOAD";
|
|
17
|
-
readonly payload: {
|
|
18
|
-
readonly cacheKey: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export declare const updateErrorUpload: (cacheKey: string, error?: Error | undefined) => {
|
|
22
|
-
readonly type: "UPDATE_ERROR_UPLOAD";
|
|
23
|
-
readonly payload: {
|
|
24
|
-
readonly cacheKey: string;
|
|
25
|
-
readonly error: Error | undefined;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
export declare const updateIsAbortedUpload: (cacheKey: string, isAborted: boolean) => {
|
|
29
|
-
readonly type: "UPDATE_IS_ABORTED_UPLOAD";
|
|
30
|
-
readonly payload: {
|
|
31
|
-
readonly cacheKey: string;
|
|
32
|
-
readonly isAborted: boolean;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
export declare const removeUploadInstance: (cacheKey: string) => {
|
|
36
|
-
readonly type: "REMOVE_UPLOAD_INSTANCE";
|
|
37
|
-
readonly payload: {
|
|
38
|
-
readonly cacheKey: string;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
export declare const
|
|
42
|
-
readonly type: "
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
1
|
+
import type { Upload } from "tus-js-client";
|
|
2
|
+
import { DefaultOptions } from "../types";
|
|
3
|
+
export declare type TusClientActions = ReturnType<typeof insertUploadInstance | typeof removeUploadInstance | typeof updateSuccessUpload | typeof updateErrorUpload | typeof updateIsAbortedUpload | typeof resetClient | typeof updateDefaultOptions>;
|
|
4
|
+
export declare const insertUploadInstance: (cacheKey: string, upload: Upload) => {
|
|
5
|
+
readonly type: "INSERT_UPLOAD_INSTANCE";
|
|
6
|
+
readonly payload: {
|
|
7
|
+
readonly cacheKey: string;
|
|
8
|
+
readonly uploadState: {
|
|
9
|
+
readonly upload: Upload;
|
|
10
|
+
readonly isSuccess: false;
|
|
11
|
+
readonly isAborted: false;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare const updateSuccessUpload: (cacheKey: string) => {
|
|
16
|
+
readonly type: "UPDATE_SUCCESS_UPLOAD";
|
|
17
|
+
readonly payload: {
|
|
18
|
+
readonly cacheKey: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare const updateErrorUpload: (cacheKey: string, error?: Error | undefined) => {
|
|
22
|
+
readonly type: "UPDATE_ERROR_UPLOAD";
|
|
23
|
+
readonly payload: {
|
|
24
|
+
readonly cacheKey: string;
|
|
25
|
+
readonly error: Error | undefined;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare const updateIsAbortedUpload: (cacheKey: string, isAborted: boolean) => {
|
|
29
|
+
readonly type: "UPDATE_IS_ABORTED_UPLOAD";
|
|
30
|
+
readonly payload: {
|
|
31
|
+
readonly cacheKey: string;
|
|
32
|
+
readonly isAborted: boolean;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export declare const removeUploadInstance: (cacheKey: string) => {
|
|
36
|
+
readonly type: "REMOVE_UPLOAD_INSTANCE";
|
|
37
|
+
readonly payload: {
|
|
38
|
+
readonly cacheKey: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export declare const resetClient: () => {
|
|
42
|
+
readonly type: "RESET_CLIENT";
|
|
43
|
+
};
|
|
44
|
+
export declare const updateDefaultOptions: (defaultOptions: DefaultOptions | undefined) => {
|
|
45
|
+
readonly type: "UPDATE_DEFAULT_OPTIONS";
|
|
46
|
+
readonly payload: {
|
|
47
|
+
readonly defaultOptions: DefaultOptions | undefined;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import type { Reducer } from
|
|
2
|
-
import type { Upload } from
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export declare type UploadState = {
|
|
6
|
-
upload: Upload | undefined;
|
|
7
|
-
isSuccess: boolean;
|
|
8
|
-
isAborted: boolean;
|
|
9
|
-
error?: Error;
|
|
10
|
-
};
|
|
11
|
-
export declare type TusClientState = {
|
|
12
|
-
uploads: {
|
|
13
|
-
[cacheKey: string]: UploadState | undefined;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
export declare const tusClientReducer: Reducer<TusClientState, TusClientActions>;
|
|
18
|
-
export declare const tusClientInitialState: TusClientState;
|
|
1
|
+
import type { Reducer } from "react";
|
|
2
|
+
import type { Upload } from "tus-js-client";
|
|
3
|
+
import { DefaultOptions } from "../types";
|
|
4
|
+
import { TusClientActions } from "./tucClientActions";
|
|
5
|
+
export declare type UploadState = {
|
|
6
|
+
upload: Upload | undefined;
|
|
7
|
+
isSuccess: boolean;
|
|
8
|
+
isAborted: boolean;
|
|
9
|
+
error?: Error;
|
|
10
|
+
};
|
|
11
|
+
export declare type TusClientState = {
|
|
12
|
+
uploads: {
|
|
13
|
+
[cacheKey: string]: UploadState | undefined;
|
|
14
|
+
};
|
|
15
|
+
defaultOptions: DefaultOptions | undefined;
|
|
16
|
+
};
|
|
17
|
+
export declare const tusClientReducer: Reducer<TusClientState, TusClientActions>;
|
|
18
|
+
export declare const tusClientInitialState: TusClientState;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
declare type BasicButtonProps = {
|
|
3
|
+
onClick: ComponentProps<"button">["onClick"];
|
|
4
|
+
title: string;
|
|
5
|
+
disabled?: ComponentProps<"button">["disabled"];
|
|
6
|
+
styleColor?: "primary" | "basic" | "error";
|
|
7
|
+
};
|
|
8
|
+
export declare const BasicButton: import("react").ForwardRefExoticComponent<BasicButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BasicButton } from "./BasicButton";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LoadingCircle } from "./LoadingCircle";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ProgressBar } from "./ProgressBar";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { UploadIcon } from "./UploadIcon";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TUS_DEMO_ENDPOINT: "https://tusd.tusdemo.net/files/";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getBlob: (str: string) => Blob;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
/// <reference types="webpack-env" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
export declare const createConsoleErrorMock: () => jest.SpyInstance<void, [message?: any, ...optionalParams: any[]]>;
|
|
5
|
+
export declare const insertEnvValue: (value: NodeJS.Process["env"]) => void;
|
|
6
|
+
export declare const startOrResumeUploadMock: jest.SpyInstance<void, [upload: import("tus-js-client").Upload]>;
|