use-tus 0.2.5 → 0.5.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.
Files changed (38) hide show
  1. package/README.md +201 -14
  2. package/dist/TusClientProvider/TusClientProvider.d.ts +4 -4
  3. package/dist/TusClientProvider/TusController.d.ts +4 -4
  4. package/dist/TusClientProvider/index.d.ts +2 -2
  5. package/dist/__stories__/Basic.stories.d.ts +5 -0
  6. package/dist/__stories__/CacheKey.stories.d.ts +5 -0
  7. package/dist/__stories__/DefaultOptions.stories.d.ts +5 -0
  8. package/dist/__stories__/components/BasicButton/BasicButton.d.ts +9 -0
  9. package/dist/__stories__/components/BasicButton/index.d.ts +1 -0
  10. package/dist/__stories__/components/LoadingCircle/LoadingCircle.d.ts +2 -0
  11. package/dist/__stories__/components/LoadingCircle/index.d.ts +1 -0
  12. package/dist/__stories__/components/ProgressBar/ProgressBar.d.ts +7 -0
  13. package/dist/__stories__/components/ProgressBar/index.d.ts +1 -0
  14. package/dist/__stories__/components/UploadIcon/UploadIcon.d.ts +2 -0
  15. package/dist/__stories__/components/UploadIcon/index.d.ts +1 -0
  16. package/dist/__stories__/constants.d.ts +1 -0
  17. package/dist/__tests__/TusClientProvider.test.d.ts +1 -0
  18. package/dist/__tests__/useTus.test.d.ts +1 -0
  19. package/dist/__tests__/utils/getBlob.d.ts +1 -0
  20. package/dist/__tests__/utils/mock.d.ts +5 -0
  21. package/dist/core/constants.d.ts +4 -4
  22. package/dist/core/contexts.d.ts +7 -7
  23. package/dist/core/tucClientActions.d.ts +50 -47
  24. package/dist/core/tusClientReducer.d.ts +18 -18
  25. package/dist/core/tusHandler.d.ts +17 -11
  26. package/dist/core/types.d.ts +8 -8
  27. package/dist/index.cjs.js +64 -1432
  28. package/dist/index.d.ts +4 -3
  29. package/dist/index.esm.js +51 -1416
  30. package/dist/index.js +385 -0
  31. package/dist/useTus/index.d.ts +2 -2
  32. package/dist/useTus/types.d.ts +15 -15
  33. package/dist/useTus/useTus.d.ts +2 -2
  34. package/dist/useTus/utils.d.ts +16 -16
  35. package/dist/useTusClient/index.d.ts +1 -0
  36. package/dist/useTusClient/useTusClient.d.ts +7 -0
  37. package/dist/utils/uid.d.ts +1 -1
  38. package/package.json +7 -7
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  </h3>
4
4
 
5
5
  <p align="center">
6
- React hooks for resumable file uploads using <a href="https://github.com/tus/tus-js-client">tus-js-client</a>.
6
+ React hooks for resumable file uploads using <a href="https://github.com/tus/tus-js-client">tus</a>.
7
7
  </p>
8
8
 
9
9
  <p align="center">
@@ -15,7 +15,6 @@
15
15
  ## Features
16
16
  - Resumable file uploads on react.
17
17
  - 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
18
  - TypeScript support.
20
19
 
21
20
  ## Demo
@@ -25,12 +24,12 @@ You can try the [use-tus demo](https://kqito.github.io/use-tus/?path=/story/uset
25
24
  ## Installation
26
25
  You can install the package from npm.
27
26
  ```sh
28
- npm install use-tus
27
+ npm install use-tus tus-js-client
29
28
  ```
30
29
 
31
30
  or
32
31
  ```sh
33
- yarn add use-tus
32
+ yarn add use-tus tus-js-client
34
33
  ```
35
34
 
36
35
  ## Usage
@@ -48,8 +47,7 @@ const App = () => (
48
47
  const Uploader = () => {
49
48
  const { upload, setUpload, isSuccess, error, remove } = useTus();
50
49
 
51
- const handleSetUpload = useCallback(
52
- (event) => {
50
+ const handleSetUpload = useCallback((event: ChangeEvent<HTMLInputElement>) => {
53
51
  const file = event.target.files.item(0);
54
52
 
55
53
  if (!file) {
@@ -91,7 +89,7 @@ const Uploader = () => {
91
89
  ## API
92
90
  ### `useTus` hooks
93
91
 
94
- ```js
92
+ ```tsx
95
93
  const { upload, setUpload, isSuccess, isAborted, error, remove } = useTus({ cacheKey, autoAbort, autoStart });
96
94
  ```
97
95
 
@@ -128,7 +126,7 @@ const { upload, setUpload, isSuccess, isAborted, error, remove } = useTus({ cach
128
126
 
129
127
  ### `TusClientProvider`
130
128
 
131
- ```js
129
+ ```tsx
132
130
  () => (
133
131
  <TusClientProvider>
134
132
  {children}
@@ -144,23 +142,212 @@ const { upload, setUpload, isSuccess, isAborted, error, remove } = useTus({ cach
144
142
  - `canStoreURLs` (type: `boolean | undefined`)
145
143
  - 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)
146
144
 
147
- - `defaultOptions` (type: `tus.DefaltOptions | undefined`)
145
+ - `defaultOptions` (type: `(file: tus.Upload['file']) => tus.DefaltOptions | undefined`)
148
146
  - 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)
149
147
 
148
+ ### `useTusClient`
149
+
150
+ ```tsx
151
+ const { state, removeUpload, reset } = useTusClient();
152
+ ```
153
+ `useTusClient` is a hooks that can be used to retrieve and reset the state of a `TusClientProvider`.
154
+
155
+ ### Returns
156
+ - `state` (type: `{ [cacheKey: string]: UploadState | undefined }`)
157
+ - Upload information associated with cacheKey
158
+
159
+ - `removeUpload` (type: `(cacheKey: string) => void`)
160
+ - Remove the upload instance associated with the specified cacheKey.
161
+
162
+ - `reset` (type: `() => void`)
163
+ - Initialize the value of TusClientProvider
164
+
150
165
  ## Examples
166
+ The following are some example of how to use `use-tus`.
167
+
168
+ Note that the `TusClientProvider` must be specified as the parent or higher element.
169
+
170
+ ### Uploading a file
171
+ The setUpload and `upload.start` functions can be used to perform resumable file uploads.
172
+
173
+ ```tsx
174
+ import { useTus } from 'use-tus'
175
+
176
+ const Uploader = () => {
177
+ const { upload, setUpload } = useTus();
178
+
179
+ const handleSetUpload = useCallback((event: ChangeEvent<HTMLInputElement>) => {
180
+ const file = event.target.files.item(0);
181
+
182
+ if (!file) {
183
+ return;
184
+ }
185
+
186
+ setUpload(file, {
187
+ endpoint: 'https://tusd.tusdemo.net/files/',
188
+ metadata: {
189
+ filename: file.name,
190
+ filetype: file.type,
191
+ },
192
+ });
193
+ },
194
+ [setUpload]
195
+ );
196
+
197
+ const handleStart = useCallback(() => {
198
+ if (!upload) {
199
+ return;
200
+ }
201
+
202
+ // Start upload the file.
203
+ upload.start();
204
+ }, [upload]);
205
+
206
+ return (
207
+ <div>
208
+ <input type="file" onChange={handleSetUpload} />
209
+ <button type="button" onClick={handleStart}>
210
+ Upload
211
+ </button>
212
+ </div>
213
+ );
214
+ };
215
+ ```
216
+
217
+ It is also possible to automatically upload files after setUpload by specifying the `autoStart` option.
218
+
219
+ ```tsx
220
+ import { useTus } from 'use-tus'
221
+
222
+ const Uploader = () => {
223
+ const { upload, setUpload } = useTus({ autoStart: true });
224
+
225
+ const handleSetUpload = useCallback((event: ChangeEvent<HTMLInputElement>) => {
226
+ const file = event.target.files.item(0);
227
+
228
+ if (!file) {
229
+ return;
230
+ }
231
+
232
+ setUpload(file, {
233
+ endpoint: 'https://tusd.tusdemo.net/files/',
234
+ metadata: {
235
+ filename: file.name,
236
+ filetype: file.type,
237
+ },
238
+ });
239
+ },
240
+ [setUpload]
241
+ );
242
+ return (
243
+ <input type="file" onChange={handleSetUpload} />
244
+ );
245
+ };
246
+ ```
247
+
248
+ ### Aborting a file upload
249
+ You can abort the upload by using the `upload.abort` function.
250
+
251
+ ```tsx
252
+ import { useTus } from 'use-tus'
253
+
254
+ const Aborter = () => {
255
+ const { upload } = useTus();
256
+
257
+ const handleAbort = useCallback(() => {
258
+ if (!upload) {
259
+ return;
260
+ }
261
+
262
+ upload.abort();
263
+ }, [upload]);
264
+
265
+ return (
266
+ <div>
267
+ <button type="button" onClick={handleAbort}>
268
+ Abort
269
+ </button>
270
+ </div>
271
+ );
272
+ };
273
+ ```
274
+
275
+ You can also specify the `autoAbort` option to automatically stop uploads when unmounting hooks.
276
+
277
+ ```tsx
278
+ import { useTus } from 'use-tus'
279
+
280
+ const Uploader = () => {
281
+ const { upload, setUpload } = useTus({ autoAbort: true });
282
+
283
+ // omitted...
284
+ };
285
+ ```
286
+
287
+ ## Default options of upload
288
+ You can specify default options in the `defaultOptions` props of the `TusClientProvider`.
289
+
290
+ ```tsx
291
+ import { useTus, DefaultOptions, TusClientProvider } from 'use-tus'
292
+
293
+ const defaultOptions: DefaultOptions = (contents) => {
294
+ const file = contents instanceof File ? contents : undefined;
295
+
296
+ return {
297
+ endpoint: 'https://tusd.tusdemo.net/files/',
298
+ metadata: file
299
+ ? {
300
+ filename: file.name,
301
+ filetype: file.type,
302
+ }
303
+ : undefined,
304
+ };
305
+ };
306
+
307
+ const App = () => (
308
+ <TusClientProvider defaultOptions={defaultOptions}>
309
+ <Uploader />
310
+ </TusClientProvider>
311
+ );
312
+
313
+ const Uploader = () => {
314
+ const { setUpload } = useTus({ autoAtart: true });
315
+
316
+ const handleSetUpload = useCallback((event: ChangeEvent<HTMLInputElement>) => {
317
+ const file = event.target.files.item(0);
318
+
319
+ if (!file) {
320
+ return;
321
+ }
322
+
323
+ // You no longer need to specify the options associated with upload.
324
+ // If specified, it will override defaultOptions.
325
+ setUpload(file);
326
+ },
327
+ [setUpload]
328
+ );
329
+
330
+ return (
331
+ <div>
332
+ <input type="file" onChange={handleSetUpload} />
333
+ </div>
334
+ );
335
+ };
336
+ ```
337
+
151
338
  ### Specify upload key
152
- If you specify `cacheKey` as an argument to useTus, you can get the `upload` associated with it. This is useful for resuming uploads, etc.
339
+ If you specify `cacheKey` as an argument to useTus, you can get the `upload` associated with it. This is useful for cross-page file uploads.
153
340
 
154
- ```js
155
- const SelectFileComponent = (file) => {
341
+ ```tsx
342
+ const SelectFileComponent = (file: File) => {
156
343
  // Create upload accosiated with 'upload-thumbnail' key
157
- const { setUpload } = useTus({cacheKey: 'upload-thumbnail'})
344
+ const { setUpload } = useTus({ cacheKey: 'upload-thumbnail' })
158
345
 
159
346
  setUpload(file)
160
347
  }
161
348
 
162
349
  const UploadFileComponent = () => {
163
- const { upload } = useTus({cacheKey: 'upload-thumbnail'})
350
+ const { upload } = useTus({ cacheKey: 'upload-thumbnail' })
164
351
 
165
352
  upload.start()
166
353
  }
@@ -1,4 +1,4 @@
1
- import type { FC } from 'react';
2
- import { TusConfigs } from '../core/tusHandler';
3
- export declare type TusClientProviderProps = Readonly<TusConfigs>;
4
- export declare const TusClientProvider: FC<TusClientProviderProps>;
1
+ import { FC } from 'react';
2
+ import { TusConfigs } from '../core/tusHandler';
3
+ export declare type TusClientProviderProps = Readonly<TusConfigs>;
4
+ export declare const TusClientProvider: FC<TusClientProviderProps>;
@@ -1,4 +1,4 @@
1
- import { FC } from 'react';
2
- import { TusConfigs } from '../core/tusHandler';
3
- export declare type TusControllerProps = Readonly<TusConfigs>;
4
- export declare const TusController: FC<TusControllerProps>;
1
+ import { FC } from 'react';
2
+ import { TusConfigs } from '../core/tusHandler';
3
+ export declare type TusControllerProps = Readonly<TusConfigs>;
4
+ export declare const TusController: FC<TusControllerProps>;
@@ -1,2 +1,2 @@
1
- export { TusClientProvider } from './TusClientProvider';
2
- export type { TusClientProviderProps } from './TusClientProvider';
1
+ export { TusClientProvider } from './TusClientProvider';
2
+ export type { TusClientProviderProps } from './TusClientProvider';
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { Meta } from '@storybook/react';
3
+ declare const _default: Meta<import("@storybook/react").Args>;
4
+ export default _default;
5
+ export declare const Basic: () => JSX.Element;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { Meta } from '@storybook/react';
3
+ declare const _default: Meta<import("@storybook/react").Args>;
4
+ export default _default;
5
+ export declare const CacheKey: () => JSX.Element;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { Meta } from '@storybook/react';
3
+ declare const _default: Meta<import("@storybook/react").Args>;
4
+ export default _default;
5
+ export declare const WithDefaultOptions: () => JSX.Element;
@@ -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,2 @@
1
+ import type { VFC } from 'react';
2
+ export declare const LoadingCircle: VFC;
@@ -0,0 +1 @@
1
+ export { LoadingCircle } from './LoadingCircle';
@@ -0,0 +1,7 @@
1
+ import { VFC } from 'react';
2
+ declare type ProgressBarProps = {
3
+ title?: string;
4
+ value?: number;
5
+ };
6
+ export declare const ProgressBar: VFC<ProgressBarProps>;
7
+ export {};
@@ -0,0 +1 @@
1
+ export { ProgressBar } from './ProgressBar';
@@ -0,0 +1,2 @@
1
+ import { VFC } from 'react';
2
+ export declare const UploadIcon: VFC;
@@ -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 declare const getBlob: (str: string) => Blob;
@@ -0,0 +1,5 @@
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;
@@ -1,4 +1,4 @@
1
- export declare const ERROR_MESSAGES: {
2
- tusClientHasNotFounded: string;
3
- tusIsNotSupported: string;
4
- };
1
+ export declare const ERROR_MESSAGES: {
2
+ tusClientHasNotFounded: string;
3
+ tusIsNotSupported: string;
4
+ };
@@ -1,7 +1,7 @@
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
+ 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,50 @@
1
- import type { Upload } from 'tus-js-client';
2
- import { TusConfigs } from './tusHandler';
3
- export declare type TusClientActions = ReturnType<typeof insertUploadInstance | typeof removeUploadInstance | typeof updateSuccessUpload | typeof updateErrorUpload | typeof updateIsAbortedUpload | typeof updateTusHandlerOptions>;
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 updateTusHandlerOptions: (payload: TusConfigs) => {
42
- readonly type: "UPDATE_TUS_HANDLER_OPTIONS";
43
- readonly payload: Partial<{
44
- canStoreURLs: boolean;
45
- defaultOptions: import("tus-js-client").UploadOptions;
46
- }>;
47
- };
1
+ import type { Upload } from 'tus-js-client';
2
+ import { TusConfigs } from './tusHandler';
3
+ export declare type TusClientActions = ReturnType<typeof insertUploadInstance | typeof removeUploadInstance | typeof resetClient | typeof updateSuccessUpload | typeof updateErrorUpload | typeof updateIsAbortedUpload | typeof updateTusHandlerOptions>;
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 updateTusHandlerOptions: (payload: TusConfigs) => {
45
+ readonly type: "UPDATE_TUS_HANDLER_OPTIONS";
46
+ readonly payload: Partial<{
47
+ canStoreURLs: boolean;
48
+ defaultOptions: import("./tusHandler").DefaultOptions;
49
+ }>;
50
+ };
@@ -1,18 +1,18 @@
1
- import type { Reducer } from 'react';
2
- import type { Upload } from 'tus-js-client';
3
- import { TusClientActions } from './tucClientActions';
4
- import { TusHandler } from './tusHandler';
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
- tusHandler: TusHandler;
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 { TusClientActions } from './tucClientActions';
4
+ import { TusHandler } from './tusHandler';
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
+ tusHandler: TusHandler;
16
+ };
17
+ export declare const tusClientReducer: Reducer<TusClientState, TusClientActions>;
18
+ export declare const tusClientInitialState: TusClientState;
@@ -1,11 +1,17 @@
1
- import * as tus from 'tus-js-client';
2
- export declare type Tus = typeof tus;
3
- export declare type TusConfigs = Partial<{
4
- canStoreURLs: boolean;
5
- defaultOptions: tus.UploadOptions;
6
- }>;
7
- export declare class TusHandler {
8
- private tus;
9
- constructor(tusConfigs?: TusConfigs);
10
- get getTus(): typeof tus;
11
- }
1
+ import * as tus from 'tus-js-client';
2
+ import { Upload } from 'tus-js-client';
3
+ export declare type DefaultOptions = (file: Upload['file']) => tus.UploadOptions;
4
+ export declare type TusConfigs = Partial<{
5
+ canStoreURLs: boolean;
6
+ defaultOptions: DefaultOptions;
7
+ }>;
8
+ export declare type Tus = Readonly<Omit<typeof tus, 'defaultOptions'> & Required<TusConfigs>>;
9
+ export declare const initialDefaultOptions: DefaultOptions;
10
+ export declare class TusHandler {
11
+ private tus;
12
+ constructor(tusConfigs?: TusConfigs);
13
+ get getTus(): Readonly<Omit<typeof tus, "defaultOptions"> & Required<Partial<{
14
+ canStoreURLs: boolean;
15
+ defaultOptions: DefaultOptions;
16
+ }>>>;
17
+ }
@@ -1,8 +1,8 @@
1
- import { Upload } from 'tus-js-client';
2
- export declare type BaseUseTusResult = {
3
- upload?: Upload;
4
- setUpload: (file: Upload['file'], options?: Upload['options']) => void;
5
- isSuccess: boolean;
6
- error?: Error;
7
- };
8
- export declare type BaseUseTusOptions = {};
1
+ import { Upload } from 'tus-js-client';
2
+ export declare type BaseUseTusResult = {
3
+ upload?: Upload;
4
+ setUpload: (file: Upload['file'], options?: Upload['options']) => void;
5
+ isSuccess: boolean;
6
+ error?: Error;
7
+ };
8
+ export declare type BaseUseTusOptions = {};