@dimah-s3/react 0.7.4 → 0.8.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 +2 -3
- package/dist/create-s3-client.d.ts +15 -14
- package/dist/create-s3-client.d.ts.map +1 -1
- package/dist/helpers/format-dimah-error.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +1 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/use-delete.d.ts +3 -3
- package/dist/hooks/use-delete.d.ts.map +1 -1
- package/dist/hooks/use-download.d.ts +48 -10
- package/dist/hooks/use-download.d.ts.map +1 -1
- package/dist/hooks/use-file-upload.d.ts +3 -2
- package/dist/hooks/use-file-upload.d.ts.map +1 -1
- package/dist/hooks/use-multi-file-upload.d.ts +3 -2
- package/dist/hooks/use-multi-file-upload.d.ts.map +1 -1
- package/dist/hooks/use-multi-upload.d.ts +4 -3
- package/dist/hooks/use-multi-upload.d.ts.map +1 -1
- package/dist/hooks/use-upload.d.ts +4 -3
- package/dist/hooks/use-upload.d.ts.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +191 -165
- package/dist/index.js.map +1 -1
- package/dist/s3-provider.d.ts +5 -10
- package/dist/s3-provider.d.ts.map +1 -1
- package/dist/translations/types.d.ts +5 -5
- package/dist/translations/types.d.ts.map +1 -1
- package/dist/types/error.d.ts +10 -12
- package/dist/types/error.d.ts.map +1 -1
- package/dist/types/multi-upload.d.ts +3 -2
- package/dist/types/multi-upload.d.ts.map +1 -1
- package/dist/upload/upload-file.d.ts.map +1 -1
- package/dist/upload/upload-files.d.ts +3 -3
- package/dist/upload/upload-files.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/helpers/format-dimah-error.test.d.ts +0 -2
- package/dist/helpers/format-dimah-error.test.d.ts.map +0 -1
- package/dist/helpers/helpers.test.d.ts +0 -2
- package/dist/helpers/helpers.test.d.ts.map +0 -1
- package/dist/hooks/use-fetch-download.d.ts +0 -33
- package/dist/hooks/use-fetch-download.d.ts.map +0 -1
package/dist/s3-provider.d.ts
CHANGED
|
@@ -3,8 +3,6 @@ import type { S3Api } from "@dimah-s3/core";
|
|
|
3
3
|
import type { Translations } from "./translations/types";
|
|
4
4
|
/**
|
|
5
5
|
* Internal context — use `S3Provider` to supply and `useApi` to consume.
|
|
6
|
-
* Exported so hooks can call `useContext(S3Context)` directly without throwing
|
|
7
|
-
* when `api` is passed explicitly.
|
|
8
6
|
*/
|
|
9
7
|
export declare const S3Context: import("react").Context<S3Api | null>;
|
|
10
8
|
export type S3ProviderProps<TApi extends S3Api = S3Api> = {
|
|
@@ -22,23 +20,20 @@ export type S3ProviderProps<TApi extends S3Api = S3Api> = {
|
|
|
22
20
|
* and UI. When `translations` is set, wraps children in Fuma
|
|
23
21
|
* `TranslationProvider`; otherwise English source keys are used as-is.
|
|
24
22
|
*
|
|
25
|
-
* Prefer {@link createS3Client} when using client plugins — it returns
|
|
26
|
-
* bound
|
|
23
|
+
* Prefer {@link createS3Client} when using client plugins — it returns the
|
|
24
|
+
* API object itself plus a bound `Provider` / typed `useApi()`.
|
|
27
25
|
*
|
|
28
26
|
* @example
|
|
29
27
|
* ```tsx
|
|
30
28
|
* import { createS3Client, type Translations } from "@dimah-s3/react";
|
|
31
29
|
*
|
|
32
|
-
* // lib/translations-de.ts
|
|
33
30
|
* const de = {
|
|
34
31
|
* "Upload failed(toast)": "Upload fehlgeschlagen",
|
|
35
32
|
* } satisfies Partial<Translations>;
|
|
36
33
|
*
|
|
37
|
-
* export const
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* return <S3Provider translations={de}>{children}</S3Provider>;
|
|
41
|
-
* }
|
|
34
|
+
* export const s3Client = createS3Client();
|
|
35
|
+
* export const S3Provider = s3Client.Provider;
|
|
36
|
+
* // <S3Provider translations={de}>{children}</S3Provider>
|
|
42
37
|
* ```
|
|
43
38
|
*/
|
|
44
39
|
export declare function S3Provider<TApi extends S3Api>({ api, translations, children, }: S3ProviderProps<TApi>): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3-provider.d.ts","sourceRoot":"","sources":["../src/s3-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD
|
|
1
|
+
{"version":3,"file":"s3-provider.d.ts","sourceRoot":"","sources":["../src/s3-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,SAAS,uCAAoC,CAAC;AAE3D,MAAM,MAAM,eAAe,CAAC,IAAI,SAAS,KAAK,GAAG,KAAK,IAAI;IACxD,GAAG,EAAE,IAAI,CAAC;IACV;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IACrC,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CAAC,IAAI,SAAS,KAAK,EAAE,EAC7C,GAAG,EACH,YAAY,EACZ,QAAQ,GACT,EAAE,eAAe,CAAC,IAAI,CAAC,+BAYvB;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,IAAI,SAAS,KAAK,GAAG,KAAK,KAAK,IAAI,CASzD"}
|
|
@@ -3,11 +3,12 @@ export type Translations = {
|
|
|
3
3
|
"Access denied(API error)": string;
|
|
4
4
|
"All {count} file(s) uploaded(status)": string;
|
|
5
5
|
"Are you sure you want to delete \"{name}\"? This action cannot be undone.(dialog description)": string;
|
|
6
|
-
"
|
|
6
|
+
"Bucket is not allowed(API error)": string;
|
|
7
7
|
"Cancel download(tooltip)": string;
|
|
8
8
|
"Cancel(dialog button)": string;
|
|
9
9
|
"Cancel(toast action)": string;
|
|
10
10
|
"Cancel(upload control)": string;
|
|
11
|
+
"Conflict(API error)": string;
|
|
11
12
|
"Could not reach storage ({code})(API error)": string;
|
|
12
13
|
"Delete failed(status)": string;
|
|
13
14
|
"Delete failed(toast)": string;
|
|
@@ -33,13 +34,12 @@ export type Translations = {
|
|
|
33
34
|
"File type \"{type}\" is not allowed(file validation)": string;
|
|
34
35
|
"Invalid request(API error)": string;
|
|
35
36
|
"Not found(API error)": string;
|
|
36
|
-
"Object key is
|
|
37
|
-
"Part number must be a positive integer(API error)": string;
|
|
37
|
+
"Object key is invalid(API error)": string;
|
|
38
38
|
"Pause(upload control)": string;
|
|
39
39
|
"Preparing…(upload status)": string;
|
|
40
40
|
"Something went wrong(API error)": string;
|
|
41
|
+
"Unauthorized(API error)": string;
|
|
41
42
|
"Unknown error(fallback)": string;
|
|
42
|
-
"Upload ID is required(API error)": string;
|
|
43
43
|
"Upload complete(toast)": string;
|
|
44
44
|
"Upload failed(status)": string;
|
|
45
45
|
"Upload failed(toast)": string;
|
|
@@ -51,7 +51,7 @@ export type Translations = {
|
|
|
51
51
|
"Validating…(upload status)": string;
|
|
52
52
|
"{count} file(s) uploaded(toast)": string;
|
|
53
53
|
"{done}/{total} files(upload progress)": string;
|
|
54
|
-
"{
|
|
54
|
+
"{feature} is disabled(API error)": string;
|
|
55
55
|
"{succeeded} succeeded, {failed} failed(toast)": string;
|
|
56
56
|
};
|
|
57
57
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/translations/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,4BAA4B,EAAE,MAAM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,CAAC;IAC3C,+BAA+B,EAAE,MAAM,CAAC;IACxC,sDAAsD,EAAE,MAAM,CAAC;IAC/D,4BAA4B,EAAE,MAAM,CAAC;IACrC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,kCAAkC,EAAE,MAAM,CAAC;IAC3C,uBAAuB,EAAE,MAAM,CAAC;IAChC,2BAA2B,EAAE,MAAM,CAAC;IACpC,iCAAiC,EAAE,MAAM,CAAC;IAC1C,yBAAyB,EAAE,MAAM,CAAC;IAClC,yBAAyB,EAAE,MAAM,CAAC;IAClC,wBAAwB,EAAE,MAAM,CAAC;IACjC,uBAAuB,EAAE,MAAM,CAAC;IAChC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,oCAAoC,EAAE,MAAM,CAAC;IAC7C,iCAAiC,EAAE,MAAM,CAAC;IAC1C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,4BAA4B,EAAE,MAAM,CAAC;IACrC,iCAAiC,EAAE,MAAM,CAAC;IAC1C,uCAAuC,EAAE,MAAM,CAAC;IAChD,kCAAkC,EAAE,MAAM,CAAC;IAC3C,+CAA+C,EAAE,MAAM,CAAC;CACzD,CAAC"}
|
package/dist/types/error.d.ts
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { DimahS3Error } from "@dimah-s3/core";
|
|
2
2
|
import type { UploadPhase } from "./upload";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Client-side upload failure (XHR to S3 / unexpected throw).
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* - `code` — machine-readable (e.g. `"HTTP_ERROR"`, `"NETWORK_ERROR"`)
|
|
9
|
-
* - `status` / `statusCode` — HTTP status when known
|
|
10
|
-
* - `phase` — upload phase in which the error occurred
|
|
6
|
+
* Protocol errors from `S3Api` stay {@link DimahS3Error} — do not wrap them
|
|
7
|
+
* or the stable `code` is lost for i18n.
|
|
11
8
|
*/
|
|
12
9
|
export declare class S3UploadError extends DimahS3Error {
|
|
13
|
-
readonly code: string;
|
|
14
10
|
readonly phase: UploadPhase | undefined;
|
|
15
11
|
constructor(message: string, code: string, status?: number, phase?: UploadPhase);
|
|
16
|
-
/** Alias for {@link DimahS3Error.status}. */
|
|
17
|
-
get statusCode(): number;
|
|
18
12
|
}
|
|
19
13
|
/**
|
|
20
|
-
* Normalize unknown throws
|
|
21
|
-
* Preserves AbortError
|
|
14
|
+
* Normalize unknown throws for the upload engine.
|
|
15
|
+
* Preserves AbortError and {@link DimahS3Error}; wraps everything else.
|
|
22
16
|
*/
|
|
23
|
-
export declare function toUploadError(err: unknown, phase?: UploadPhase):
|
|
17
|
+
export declare function toUploadError(err: unknown, phase?: UploadPhase): DimahS3Error;
|
|
18
|
+
/** Normalize unknown throws for hook `error` state. */
|
|
19
|
+
export declare function toHookError(err: unknown, fallback?: string): DimahS3Error;
|
|
20
|
+
/** Client-side block from a `before*` hook (`false` return). */
|
|
21
|
+
export declare function hookBlockedError(message: string): DimahS3Error;
|
|
24
22
|
//# sourceMappingURL=error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/types/error.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/types/error.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAGb,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;;;;GAKG;AACH,qBAAa,aAAc,SAAQ,YAAY;IAC7C,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;IAExC,YACE,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,SAAM,EACZ,KAAK,CAAC,EAAE,WAAW,EAKpB;CACF;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,YAAY,CAqB7E;AAED,uDAAuD;AACvD,wBAAgB,WAAW,CACzB,GAAG,EAAE,OAAO,EACZ,QAAQ,SAAmB,GAC1B,YAAY,CAId;AAED,gEAAgE;AAChE,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAE9D"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DimahS3Error } from "@dimah-s3/core";
|
|
1
2
|
import type { UploadProgress, UploadResult } from "./upload";
|
|
2
3
|
export type MultiUploadPhase = "idle" | "validating" | "uploading" | "success" | "error";
|
|
3
4
|
/** Per-file state in a multi-upload batch. */
|
|
@@ -17,7 +18,7 @@ export type MultiUploadFileState = {
|
|
|
17
18
|
previewUrl: string | null;
|
|
18
19
|
status: "pending" | "uploading" | "success" | "error";
|
|
19
20
|
progress: UploadProgress;
|
|
20
|
-
error:
|
|
21
|
+
error: DimahS3Error | null;
|
|
21
22
|
};
|
|
22
23
|
/** Lifecycle hooks for multi-file upload. */
|
|
23
24
|
export type MultiUploadHooks = {
|
|
@@ -25,7 +26,7 @@ export type MultiUploadHooks = {
|
|
|
25
26
|
onUploadStart?: (files: File[]) => void;
|
|
26
27
|
onFileProgress?: (file: File, progress: UploadProgress) => void;
|
|
27
28
|
onFileSuccess?: (file: File, result: UploadResult) => void;
|
|
28
|
-
onFileError?: (file: File, error:
|
|
29
|
+
onFileError?: (file: File, error: DimahS3Error) => void;
|
|
29
30
|
onProgress?: (progress: UploadProgress) => void;
|
|
30
31
|
onSuccess?: (results: UploadResult[]) => Promise<void> | void;
|
|
31
32
|
onError?: (error: unknown) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-upload.d.ts","sourceRoot":"","sources":["../../src/types/multi-upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,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,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,YAAiB,EACzB,SAAS,GAAE,qBAA0B,EACrC,MAAM,CAAC,EAAE,WAAW,EACpB,cAAc,CAAC,EAAE,oBAAoB,GACpC,OAAO,CAAC,YAAY,CAAC,CA+EvB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { UploadConfig, UploadProgress, UploadResult, UploadRequestOptions } from "../types";
|
|
2
|
-
import type { S3Api } from "@dimah-s3/core";
|
|
2
|
+
import type { DimahS3Error, S3Api } from "@dimah-s3/core";
|
|
3
3
|
export type FileItemStatus = "pending" | "uploading" | "success" | "error";
|
|
4
4
|
export type FileItem = {
|
|
5
5
|
id: string;
|
|
@@ -8,12 +8,12 @@ export type FileItem = {
|
|
|
8
8
|
status: FileItemStatus;
|
|
9
9
|
progress: UploadProgress;
|
|
10
10
|
result: UploadResult | null;
|
|
11
|
-
error:
|
|
11
|
+
error: DimahS3Error | null;
|
|
12
12
|
};
|
|
13
13
|
export type MultiUploadCallbacks = {
|
|
14
14
|
onFileProgress?: (id: string, progress: UploadProgress) => void;
|
|
15
15
|
onFileSuccess?: (id: string, result: UploadResult) => void;
|
|
16
|
-
onFileError?: (id: string, error:
|
|
16
|
+
onFileError?: (id: string, error: DimahS3Error) => void;
|
|
17
17
|
onTotalProgress?: (progress: UploadProgress) => void;
|
|
18
18
|
/** Called once after multipart init for a file (id → uploadId, server key). */
|
|
19
19
|
onMultipartInit?: (id: string, uploadId: string, key: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-files.d.ts","sourceRoot":"","sources":["../../src/upload/upload-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"upload-files.d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S,EAAE,MAAM,CAAA;CAAE,CAAC,EAC3D,MAAM,GAAE,YAAiB,EACzB,SAAS,GAAE,oBAAyB,EACpC,MAAM,CAAC,EAAE,WAAW,EACpB,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,oBAAoB,GACvD,OAAO,CAAC,QAAQ,EAAE,CAAC,CAgFrB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimah-s3/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Headless React hooks for presigned S3 and R2 file uploads, downloads, and deletes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"s3",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@fuma-translate/react": "^1.0.2",
|
|
42
|
-
"immer": "^11.1.
|
|
42
|
+
"immer": "^11.1.17",
|
|
43
43
|
"react-dropzone": "^20.1.0",
|
|
44
44
|
"zustand": "^5.0.15",
|
|
45
|
-
"@dimah-s3/core": "0.
|
|
45
|
+
"@dimah-s3/core": "0.8.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@fuma-translate/react": "^1.0.2",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
69
|
"compile:translations": "node ./scripts/compile-translations.mjs",
|
|
70
|
-
"build": "pnpm compile:translations && tsup --config tsup.config.ts && tsc --emitDeclarationOnly",
|
|
70
|
+
"build": "pnpm compile:translations && tsup --config tsup.config.ts && tsc --emitDeclarationOnly -p tsconfig.build.json",
|
|
71
71
|
"lint": "eslint",
|
|
72
72
|
"check-types": "pnpm compile:translations && tsc --noEmit",
|
|
73
73
|
"test": "vitest run"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"format-dimah-error.test.d.ts","sourceRoot":"","sources":["../../src/helpers/format-dimah-error.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.test.d.ts","sourceRoot":"","sources":["../../src/helpers/helpers.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { S3Api } from "@dimah-s3/core";
|
|
2
|
-
import type { FetchDownloadPhase, FetchDownloadHooks } from "../types/download";
|
|
3
|
-
import type { UploadProgress } from "../types/upload";
|
|
4
|
-
export type { FetchDownloadPhase, FetchDownloadProgress, FetchDownloadHooks, } from "../types/download";
|
|
5
|
-
/** Options for {@link useFetchDownload}. */
|
|
6
|
-
export type UseFetchDownloadOptions = FetchDownloadHooks & {
|
|
7
|
-
/** S3Api. Optional when an `<S3Provider>` is present in the tree. */
|
|
8
|
-
api?: S3Api;
|
|
9
|
-
/** Target bucket (overrides server default). */
|
|
10
|
-
bucket?: string;
|
|
11
|
-
};
|
|
12
|
-
export type UseFetchDownloadState = {
|
|
13
|
-
/** Current download phase. */
|
|
14
|
-
phase: FetchDownloadPhase;
|
|
15
|
-
/** Byte transfer progress. */
|
|
16
|
-
progress: UploadProgress;
|
|
17
|
-
/** Error message, or `null`. */
|
|
18
|
-
error: string | null;
|
|
19
|
-
/** Resolved download filename. */
|
|
20
|
-
fileName: string | null;
|
|
21
|
-
/** Total file size in bytes. */
|
|
22
|
-
fileSize: number | null;
|
|
23
|
-
};
|
|
24
|
-
export type UseFetchDownloadReturn = UseFetchDownloadState & {
|
|
25
|
-
/** Presign, fetch bytes, and save via the browser. */
|
|
26
|
-
download: (key: string, downloadName?: string) => Promise<void>;
|
|
27
|
-
/** Abort the active download. */
|
|
28
|
-
cancel: () => void;
|
|
29
|
-
/** Reset state to `idle`. */
|
|
30
|
-
reset: () => void;
|
|
31
|
-
};
|
|
32
|
-
export declare function useFetchDownload(options: UseFetchDownloadOptions): UseFetchDownloadReturn;
|
|
33
|
-
//# sourceMappingURL=use-fetch-download.d.ts.map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