@dimah-s3/react 1.0.1 → 1.1.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 +1 -0
- package/dist/api.d.ts +2 -2
- package/dist/create-s3-client.d.ts +1 -1
- package/dist/engine.d.ts +2 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +508 -0
- package/dist/engine.js.map +1 -0
- package/dist/helpers/format-dimah-error.d.ts.map +1 -1
- package/dist/helpers/index.d.ts +2 -0
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/load-route-catalog.d.ts +18 -0
- package/dist/helpers/load-route-catalog.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/use-delete.d.ts +7 -3
- package/dist/hooks/use-delete.d.ts.map +1 -1
- package/dist/hooks/use-download.d.ts +6 -4
- package/dist/hooks/use-download.d.ts.map +1 -1
- package/dist/hooks/use-file-upload.d.ts +4 -4
- package/dist/hooks/use-file-upload.d.ts.map +1 -1
- package/dist/hooks/use-multi-file-upload.d.ts +4 -4
- package/dist/hooks/use-multi-file-upload.d.ts.map +1 -1
- package/dist/hooks/use-multi-upload.d.ts +1 -3
- package/dist/hooks/use-multi-upload.d.ts.map +1 -1
- package/dist/hooks/use-object-url.d.ts +30 -0
- package/dist/hooks/use-object-url.d.ts.map +1 -0
- package/dist/hooks/use-route-upload-policy.d.ts +13 -0
- package/dist/hooks/use-route-upload-policy.d.ts.map +1 -0
- package/dist/hooks/use-upload.d.ts +4 -4
- package/dist/hooks/use-upload.d.ts.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +728 -304
- package/dist/index.js.map +1 -1
- package/dist/store/local-storage-store.d.ts +1 -1
- package/dist/store/memory-store.d.ts +1 -1
- package/dist/translations/types.d.ts +2 -3
- package/dist/translations/types.d.ts.map +1 -1
- package/dist/types/error.d.ts +1 -0
- package/dist/types/error.d.ts.map +1 -1
- package/dist/types/multi-upload.d.ts +2 -0
- package/dist/types/multi-upload.d.ts.map +1 -1
- package/dist/types/upload-store.d.ts +27 -13
- package/dist/types/upload-store.d.ts.map +1 -1
- package/dist/types/upload.d.ts +40 -26
- package/dist/types/upload.d.ts.map +1 -1
- package/dist/upload/index.d.ts +2 -0
- package/dist/upload/index.d.ts.map +1 -1
- package/dist/upload/multipart.d.ts +2 -2
- package/dist/upload/multipart.d.ts.map +1 -1
- package/dist/upload/presigned-http.d.ts +1 -1
- package/dist/upload/resume-key.d.ts +6 -0
- package/dist/upload/resume-key.d.ts.map +1 -0
- package/dist/upload/upload-file.d.ts +3 -3
- package/dist/upload/upload-file.d.ts.map +1 -1
- package/dist/upload/upload-files.d.ts +2 -4
- package/dist/upload/upload-files.d.ts.map +1 -1
- package/dist/upload/upload-part.d.ts +1 -1
- package/dist/upload/upload-part.d.ts.map +1 -1
- package/dist/upload/xhr-upload.d.ts.map +1 -1
- package/package.json +12 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { UploadStore } from "../types/upload-store";
|
|
2
2
|
/**
|
|
3
3
|
* Default `UploadStore` implementation backed by `localStorage`.
|
|
4
|
-
* Stores one pending upload per
|
|
4
|
+
* Stores one pending upload per resume identity (`route:name:size:mtime`).
|
|
5
5
|
*
|
|
6
6
|
* Falls back silently when `localStorage` is unavailable (SSR, private
|
|
7
7
|
* browsing with full quota, or environments without a `window` object).
|
|
@@ -8,7 +8,7 @@ import type { UploadStore } from "../types/upload-store";
|
|
|
8
8
|
* @example
|
|
9
9
|
* ```ts
|
|
10
10
|
* const store = createMemoryStore();
|
|
11
|
-
* useFileUpload({ api, uploadStore: store });
|
|
11
|
+
* useFileUpload({ api, route: "uploads", uploadStore: store });
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
14
|
export declare function createMemoryStore(): UploadStore;
|
|
@@ -3,7 +3,6 @@ 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
|
-
"Bucket is not allowed(API error)": string;
|
|
7
6
|
"Cancel download(tooltip)": string;
|
|
8
7
|
"Cancel(dialog button)": string;
|
|
9
8
|
"Cancel(toast action)": string;
|
|
@@ -31,9 +30,8 @@ export type Translations = {
|
|
|
31
30
|
"File not accepted(toast)": string;
|
|
32
31
|
"File not found(API error)": string;
|
|
33
32
|
"File size exceeds {size} limit(file validation)": string;
|
|
34
|
-
"File size is required(multipart)": string;
|
|
35
|
-
"File size is required(upload)": string;
|
|
36
33
|
"File type \"{type}\" is not allowed(file validation)": string;
|
|
34
|
+
"File type is not allowed(API error)": string;
|
|
37
35
|
"Finishing…(upload status)": string;
|
|
38
36
|
"Invalid request(API error)": string;
|
|
39
37
|
"Not found(API error)": string;
|
|
@@ -43,6 +41,7 @@ export type Translations = {
|
|
|
43
41
|
"Something went wrong(API error)": string;
|
|
44
42
|
"Unauthorized(API error)": string;
|
|
45
43
|
"Unknown error(fallback)": string;
|
|
44
|
+
"Unknown file route(API error)": string;
|
|
46
45
|
"Upload complete(toast)": string;
|
|
47
46
|
"Upload failed(status)": string;
|
|
48
47
|
"Upload failed(toast)": string;
|
|
@@ -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,CAAC;IACrC,0BAA0B,EAAE,MAAM,CAAC;IACnC,sCAAsC,EAAE,MAAM,CAAC;IAC/C,+FAA+F,EAAE,MAAM,CAAC;IACxG,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/translations/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,4BAA4B,EAAE,MAAM,CAAC;IACrC,0BAA0B,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AAC;IACpC,iCAAiC,EAAE,MAAM,CAAC;IAC1C,yBAAyB,EAAE,MAAM,CAAC;IAClC,yBAAyB,EAAE,MAAM,CAAC;IAClC,+BAA+B,EAAE,MAAM,CAAC;IACxC,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,qDAAqD,EAAE,MAAM,CAAC;IAC9D,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,sBAAsB,EAAE,MAAM,CAAC;IAC/B,+CAA+C,EAAE,MAAM,CAAC;CACzD,CAAC"}
|
package/dist/types/error.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare class S3UploadError extends DimahS3Error {
|
|
|
17
17
|
export declare function toUploadError(err: unknown, phase?: UploadPhase): DimahS3Error;
|
|
18
18
|
/** Normalize unknown throws for hook `error` state. */
|
|
19
19
|
export declare function toHookError(err: unknown, fallback?: string): DimahS3Error;
|
|
20
|
+
export declare function isAbortError(err: unknown): boolean;
|
|
20
21
|
/** Client-side block from a `before*` hook (`false` return). */
|
|
21
22
|
export declare function hookBlockedError(message: string): DimahS3Error;
|
|
22
23
|
//# sourceMappingURL=error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;;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E9D"}
|
|
@@ -8,6 +8,8 @@ export type MultiUploadFileState = UploadFileInfo & {
|
|
|
8
8
|
status: "pending" | "uploading" | "success" | "error";
|
|
9
9
|
progress: UploadProgress;
|
|
10
10
|
error: DimahS3Error | null;
|
|
11
|
+
/** Set after this file succeeds. */
|
|
12
|
+
result: UploadResult | null;
|
|
11
13
|
};
|
|
12
14
|
/** Lifecycle hooks for multi-file upload. */
|
|
13
15
|
export type MultiUploadHooks = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-upload.d.ts","sourceRoot":"","sources":["../../src/types/multi-upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7E,MAAM,MAAM,gBAAgB,GAC1B,MAAM,GAAG,YAAY,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;AAE5D,8CAA8C;AAC9C,MAAM,MAAM,oBAAoB,GAAG,cAAc,GAAG;IAClD,4CAA4C;IAC5C,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;IACtD,QAAQ,EAAE,cAAc,CAAC;IACzB,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"multi-upload.d.ts","sourceRoot":"","sources":["../../src/types/multi-upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7E,MAAM,MAAM,gBAAgB,GAC1B,MAAM,GAAG,YAAY,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;AAE5D,8CAA8C;AAC9C,MAAM,MAAM,oBAAoB,GAAG,cAAc,GAAG;IAClD,4CAA4C;IAC5C,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;IACtD,QAAQ,EAAE,cAAc,CAAC;IACzB,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IAC3B,oCAAoC;IACpC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF,6CAA6C;AAC7C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAC7D,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACxC,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;IAChE,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC3D,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACxD,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;IAChD,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC9D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC"}
|
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
* Minimal state that must be persisted to resume a multipart upload.
|
|
3
3
|
*/
|
|
4
4
|
export type StoredUpload = {
|
|
5
|
+
/**
|
|
6
|
+
* Client-side resume identity
|
|
7
|
+
* (`${route}:${file.name}:${file.size}:${file.lastModified}`).
|
|
8
|
+
*/
|
|
9
|
+
resumeKey: string;
|
|
5
10
|
/** S3 multipart `UploadId` returned by `CreateMultipartUpload`. */
|
|
6
11
|
uploadId: string;
|
|
7
|
-
/** S3 object key. */
|
|
12
|
+
/** Server-generated S3 object key. */
|
|
8
13
|
key: string;
|
|
9
14
|
/** Total file size in bytes — used to verify the same file is being resumed. */
|
|
10
15
|
fileSize: number;
|
|
11
|
-
/** Bucket override, if any. */
|
|
12
|
-
bucket?: string;
|
|
13
16
|
};
|
|
14
17
|
/**
|
|
15
18
|
* Storage backend for resumable multipart uploads.
|
|
@@ -18,29 +21,40 @@ export type StoredUpload = {
|
|
|
18
21
|
* (database, Redis, IndexedDB, etc.). The default implementation uses
|
|
19
22
|
* `localStorage` via `createLocalStorageStore()`.
|
|
20
23
|
*
|
|
24
|
+
* Lookup is by {@link StoredUpload.resumeKey}, not the S3 object key.
|
|
25
|
+
*
|
|
21
26
|
* @example
|
|
22
27
|
* ```ts
|
|
23
|
-
* // Custom database-backed store
|
|
24
28
|
* const dbStore: UploadStore = {
|
|
25
|
-
* async get(
|
|
26
|
-
* const row = await db.uploads.findFirst({ where: {
|
|
27
|
-
* return row
|
|
29
|
+
* async get(resumeKey, fileSize) {
|
|
30
|
+
* const row = await db.uploads.findFirst({ where: { resumeKey, fileSize } });
|
|
31
|
+
* return row
|
|
32
|
+
* ? {
|
|
33
|
+
* resumeKey,
|
|
34
|
+
* uploadId: row.uploadId,
|
|
35
|
+
* key: row.key,
|
|
36
|
+
* fileSize,
|
|
37
|
+
* }
|
|
38
|
+
* : null;
|
|
28
39
|
* },
|
|
29
40
|
* async set(upload) {
|
|
30
|
-
* await db.uploads.upsert({
|
|
41
|
+
* await db.uploads.upsert({
|
|
42
|
+
* where: { resumeKey: upload.resumeKey },
|
|
43
|
+
* data: upload,
|
|
44
|
+
* });
|
|
31
45
|
* },
|
|
32
|
-
* async delete(
|
|
33
|
-
* await db.uploads.deleteMany({ where: {
|
|
46
|
+
* async delete(resumeKey) {
|
|
47
|
+
* await db.uploads.deleteMany({ where: { resumeKey } });
|
|
34
48
|
* },
|
|
35
49
|
* };
|
|
36
50
|
* ```
|
|
37
51
|
*/
|
|
38
52
|
export type UploadStore = {
|
|
39
53
|
/**
|
|
40
|
-
* Look up a pending upload by
|
|
54
|
+
* Look up a pending upload by resume identity and file size.
|
|
41
55
|
* Returns `null` if no matching upload is found.
|
|
42
56
|
*/
|
|
43
|
-
get: (
|
|
57
|
+
get: (resumeKey: string, fileSize: number) => StoredUpload | null | Promise<StoredUpload | null>;
|
|
44
58
|
/**
|
|
45
59
|
* Persist a new upload state after `CreateMultipartUpload` succeeds.
|
|
46
60
|
* Called once per upload, before any parts are sent.
|
|
@@ -50,6 +64,6 @@ export type UploadStore = {
|
|
|
50
64
|
* Remove the upload state after the upload completes or is explicitly
|
|
51
65
|
* abandoned. Should be a no-op if the key is not found.
|
|
52
66
|
*/
|
|
53
|
-
delete: (
|
|
67
|
+
delete: (resumeKey: string) => void | Promise<void>;
|
|
54
68
|
};
|
|
55
69
|
//# sourceMappingURL=upload-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-store.d.ts","sourceRoot":"","sources":["../../src/types/upload-store.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC;IACjB,
|
|
1
|
+
{"version":3,"file":"upload-store.d.ts","sourceRoot":"","sources":["../../src/types/upload-store.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,gFAAgF;IAChF,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB;;;OAGG;IACH,GAAG,EAAE,CACH,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,KACb,YAAY,GAAG,IAAI,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAExD;;;OAGG;IACH,GAAG,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD;;;OAGG;IACH,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD,CAAC"}
|
package/dist/types/upload.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UploadPresignResponse } from "@dimah-s3/core";
|
|
1
|
+
import type { S3RouteName, UploadPresignResponse } from "@dimah-s3/core";
|
|
2
2
|
import type { UploadStore } from "./upload-store";
|
|
3
3
|
/** Result returned after a successful upload. */
|
|
4
4
|
export type UploadResult = {
|
|
@@ -6,6 +6,12 @@ export type UploadResult = {
|
|
|
6
6
|
key: string;
|
|
7
7
|
/** Object ETag from S3. */
|
|
8
8
|
eTag?: string;
|
|
9
|
+
/** Verified size from HeadObject / multipart complete. */
|
|
10
|
+
contentLength: number;
|
|
11
|
+
/** MIME type from HeadObject. */
|
|
12
|
+
contentType?: string;
|
|
13
|
+
/** Stored filename. */
|
|
14
|
+
fileName?: string;
|
|
9
15
|
};
|
|
10
16
|
/** Byte transfer progress for upload and fetch-download. */
|
|
11
17
|
export type UploadProgress = {
|
|
@@ -35,32 +41,30 @@ export type UploadFileInfo = {
|
|
|
35
41
|
};
|
|
36
42
|
/** Per-upload options passed to the presign API. */
|
|
37
43
|
export type UploadRequestOptions = {
|
|
38
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Client extras sent to the server `object` callback as `clientMetadata`.
|
|
46
|
+
* Not written to S3 unless the route copies them into `object().metadata`.
|
|
47
|
+
*/
|
|
39
48
|
metadata?: Record<string, string>;
|
|
40
|
-
/** Target bucket (overrides server default). */
|
|
41
|
-
bucket?: string;
|
|
42
49
|
/** Override auto-detected content type. */
|
|
43
50
|
contentType?: string;
|
|
44
|
-
/** Object ACL — defaults to `'private'`. */
|
|
45
|
-
acl?: "private" | "public-read";
|
|
46
51
|
/**
|
|
47
|
-
* Original file name
|
|
48
|
-
*
|
|
49
|
-
* Pass `null` to omit Content-Disposition entirely.
|
|
52
|
+
* Original file name sent on presign. Defaults to the browser's `file.name`.
|
|
53
|
+
* The protocol requires a non-empty name — it cannot be omitted.
|
|
50
54
|
*/
|
|
51
|
-
fileName?: string
|
|
55
|
+
fileName?: string;
|
|
52
56
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
57
|
+
* Unpadded base64 SHA-256. Sent when the route sets `upload.checksum`.
|
|
58
|
+
* The engine computes this when {@link FileUploadConfig.checksum} is true.
|
|
55
59
|
*/
|
|
56
|
-
|
|
60
|
+
checksum?: string;
|
|
57
61
|
};
|
|
58
62
|
/** Lifecycle hooks for single-file upload. */
|
|
59
63
|
export type UploadHooks = {
|
|
60
64
|
/** Runs before the upload starts. Return `false` to block it. */
|
|
61
65
|
beforeUpload?: (file: File) => Promise<boolean> | boolean;
|
|
62
66
|
/** Fires after validation passes and the upload begins. */
|
|
63
|
-
onUploadStart?: (file: File
|
|
67
|
+
onUploadStart?: (file: File) => void;
|
|
64
68
|
/** Fires continuously while bytes are transferred. */
|
|
65
69
|
onProgress?: (file: File, progress: UploadProgress) => void;
|
|
66
70
|
/** Fires after each part is successfully uploaded to S3 (multipart only). */
|
|
@@ -96,25 +100,35 @@ export type RetryConfig = {
|
|
|
96
100
|
/** Base delay in ms for exponential backoff. @default 1000 */
|
|
97
101
|
baseDelay?: number;
|
|
98
102
|
};
|
|
99
|
-
/**
|
|
100
|
-
export type
|
|
101
|
-
/**
|
|
103
|
+
/** Engine configuration for `useFileUpload` and `useMultiFileUpload`. */
|
|
104
|
+
export type FileUploadConfig = {
|
|
105
|
+
/**
|
|
106
|
+
* Named server route (`dimahS3({ routes })`). Required — the server
|
|
107
|
+
* generates the object key from this route's policy.
|
|
108
|
+
*/
|
|
109
|
+
route: S3RouteName;
|
|
110
|
+
/**
|
|
111
|
+
* Attempt multipart when the file is at least 50 MB. The server must
|
|
112
|
+
* enable `multipart` on the route or init returns `FEATURE_DISABLED`.
|
|
113
|
+
* The threshold is not configurable.
|
|
114
|
+
*/
|
|
102
115
|
multipart?: boolean;
|
|
103
116
|
/**
|
|
104
117
|
* HTML `accept` tokens: MIME types (`image/*`, `application/pdf`) and/or
|
|
105
|
-
* extensions (`.pdf`).
|
|
118
|
+
* extensions (`.pdf`). Client-side UX only — the server enforces
|
|
119
|
+
* route `fileTypes`. Omitted values are filled from `api.catalog()`.
|
|
106
120
|
*/
|
|
107
121
|
accept?: string[];
|
|
108
|
-
/**
|
|
122
|
+
/**
|
|
123
|
+
* Max file size in bytes. Client-side UX only — the server enforces
|
|
124
|
+
* route `maxFileSize`. Omitted values are filled from `api.catalog()`.
|
|
125
|
+
*/
|
|
109
126
|
maxFileSize?: number;
|
|
110
|
-
/** File size threshold in bytes above which multipart is used. */
|
|
111
|
-
multipartThreshold?: number;
|
|
112
127
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* @default 5 MB
|
|
128
|
+
* Compute and send a SHA-256 checksum on presign. Filled from
|
|
129
|
+
* `api.catalog()` when the route sets `upload.checksum`.
|
|
116
130
|
*/
|
|
117
|
-
|
|
131
|
+
checksum?: boolean;
|
|
118
132
|
/** Number of parts uploaded concurrently (multipart). */
|
|
119
133
|
concurrentParts?: number;
|
|
120
134
|
/** Retry configuration for failed network requests. */
|
|
@@ -129,7 +143,7 @@ export type UploadConfig = {
|
|
|
129
143
|
uploadStore?: UploadStore | false;
|
|
130
144
|
};
|
|
131
145
|
/** Extra engine configuration for multi-file uploads. */
|
|
132
|
-
export type
|
|
146
|
+
export type MultiFileUploadConfig = FileUploadConfig & {
|
|
133
147
|
/** Max number of files in a batch. */
|
|
134
148
|
maxFiles?: number;
|
|
135
149
|
/** Number of files uploaded concurrently. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/types/upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/types/upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,iDAAiD;AACjD,MAAM,MAAM,YAAY,GAAG;IACzB,qBAAqB;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,2BAA2B;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,aAAa,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uBAAuB;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,4DAA4D;AAC5D,MAAM,MAAM,cAAc,GAAG;IAC3B,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,SAAS,GACT,OAAO,CAAC;AAEZ,gEAAgE;AAChE,MAAM,MAAM,cAAc,GAAG;IAC3B,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAA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AG;IACrD,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6CAA6C;IAC7C,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC"}
|
package/dist/upload/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { uploadFile, type UploadEngineCallbacks } from "./upload-file";
|
|
2
2
|
export { uploadFiles, type FileItem, type FileItemStatus, type MultiUploadCallbacks, } from "./upload-files";
|
|
3
|
+
export { multipartResumeKey } from "./resume-key";
|
|
4
|
+
export { DEFAULT_MULTIPART_THRESHOLD } from "./constants";
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/upload/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EACL,WAAW,EACX,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,oBAAoB,GAC1B,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/upload/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EACL,WAAW,EACX,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,oBAAoB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UploadProgress, UploadRequestOptions, RetryConfig } from "../types";
|
|
1
|
+
import type { UploadProgress, UploadRequestOptions, RetryConfig, UploadResult } from "../types";
|
|
2
2
|
import type { S3Api } from "@dimah-s3/core";
|
|
3
3
|
import type { UploadStore } from "../types/upload-store";
|
|
4
|
-
export declare function uploadMultipart(api: S3Api, file: File,
|
|
4
|
+
export declare function uploadMultipart(api: S3Api, file: File, route: string, partSize: number, concurrentParts: number, onProgress?: (progress: UploadProgress) => void, signal?: AbortSignal, requestOptions?: UploadRequestOptions, retryConfig?: RetryConfig, uploadStore?: UploadStore | false, onPartUpload?: (partNumber: number, totalParts: number) => void, onMultipartInit?: (uploadId: string, key: string) => void): Promise<UploadResult>;
|
|
5
5
|
//# sourceMappingURL=multipart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multipart.d.ts","sourceRoot":"","sources":["../../src/upload/multipart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,WAAW,
|
|
1
|
+
{"version":3,"file":"multipart.d.ts","sourceRoot":"","sources":["../../src/upload/multipart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,YAAY,EACb,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAiBxD,wBAAsB,eAAe,CACnC,GAAG,EAAE,KAAK,EACV,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,EACvB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,EAC/C,MAAM,CAAC,EAAE,WAAW,EACpB,cAAc,CAAC,EAAE,oBAAoB,EACrC,WAAW,CAAC,EAAE,WAAW,EACzB,WAAW,CAAC,EAAE,WAAW,GAAG,KAAK,EACjC,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,EAC/D,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,GACxD,OAAO,CAAC,YAAY,CAAC,CAoLvB"}
|
|
@@ -10,7 +10,7 @@ export declare function uploadSimple(file: File, url: string, fields: Record<str
|
|
|
10
10
|
/**
|
|
11
11
|
* Uploads a file directly to S3 using a presigned PUT URL.
|
|
12
12
|
*
|
|
13
|
-
* Use this when the server is configured with `
|
|
13
|
+
* Use this when the server is configured with `method: "PUT"` — for
|
|
14
14
|
* example with Cloudflare R2 which does not support presigned POST.
|
|
15
15
|
*/
|
|
16
16
|
export declare function uploadPut(file: File, url: string, headers: Record<string, string>, onProgress?: (progress: UploadProgress) => void, signal?: AbortSignal): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resume-key.d.ts","sourceRoot":"","sources":["../../src/upload/resume-key.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAEpE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type
|
|
1
|
+
import type { FileUploadConfig, UploadProgress, UploadResult, UploadRequestOptions } from "../types";
|
|
2
|
+
import { type S3Api } from "@dimah-s3/core";
|
|
3
3
|
export type UploadEngineCallbacks = {
|
|
4
4
|
onProgress?: (progress: UploadProgress) => void;
|
|
5
5
|
/** Called when the upload transitions between internal phases. */
|
|
@@ -9,5 +9,5 @@ export type UploadEngineCallbacks = {
|
|
|
9
9
|
/** Called once after `CreateMultipartUpload` succeeds with the S3-assigned `uploadId` and final object `key`. */
|
|
10
10
|
onMultipartInit?: (uploadId: string, key: string) => void;
|
|
11
11
|
};
|
|
12
|
-
export declare function uploadFile(api: S3Api, file: File,
|
|
12
|
+
export declare function uploadFile(api: S3Api, file: File, config: FileUploadConfig, callbacks?: UploadEngineCallbacks, signal?: AbortSignal, requestOptions?: UploadRequestOptions): Promise<UploadResult>;
|
|
13
13
|
//# sourceMappingURL=upload-file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-file.d.ts","sourceRoot":"","sources":["../../src/upload/upload-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"upload-file.d.ts","sourceRoot":"","sources":["../../src/upload/upload-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,oBAAoB,EAGrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAgBxD,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;IAChD,kEAAkE;IAClE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,GAAG,WAAW,GAAG,YAAY,KAAK,IAAI,CAAC;IAC3E,4EAA4E;IAC5E,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAChE,iHAAiH;IACjH,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3D,CAAC;AAEF,wBAAsB,UAAU,CAC9B,GAAG,EAAE,KAAK,EACV,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,gBAAgB,EACxB,SAAS,GAAE,qBAA0B,EACrC,MAAM,CAAC,EAAE,WAAW,EACpB,cAAc,CAAC,EAAE,oBAAoB,GACpC,OAAO,CAAC,YAAY,CAAC,CAoGvB"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MultiFileUploadConfig, UploadProgress, UploadResult, UploadRequestOptions } from "../types";
|
|
2
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;
|
|
6
6
|
file: File;
|
|
7
|
-
objectKey: string;
|
|
8
7
|
status: FileItemStatus;
|
|
9
8
|
progress: UploadProgress;
|
|
10
9
|
result: UploadResult | null;
|
|
@@ -21,6 +20,5 @@ export type MultiUploadCallbacks = {
|
|
|
21
20
|
export declare function uploadFiles(api: S3Api, items: Array<{
|
|
22
21
|
id: string;
|
|
23
22
|
file: File;
|
|
24
|
-
|
|
25
|
-
}>, config?: MultiUploadConfig, callbacks?: MultiUploadCallbacks, signal?: AbortSignal, getRequestOptions?: (file: File) => UploadRequestOptions): Promise<FileItem[]>;
|
|
23
|
+
}>, config: MultiFileUploadConfig, callbacks?: MultiUploadCallbacks, signal?: AbortSignal, getRequestOptions?: (file: File) => UploadRequestOptions): Promise<FileItem[]>;
|
|
26
24
|
//# sourceMappingURL=upload-files.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-files.d.ts","sourceRoot":"","sources":["../../src/upload/upload-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"upload-files.d.ts","sourceRoot":"","sources":["../../src/upload/upload-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,oBAAoB,EACrB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAK1D,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;AAE3E,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,cAAc,CAAC;IACvB,QAAQ,EAAE,cAAc,CAAC;IACzB,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;IAChE,aAAa,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC3D,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACxD,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;IACrD,+EAA+E;IAC/E,eAAe,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACvE,CAAC;AAEF,wBAAsB,WAAW,CAC/B,GAAG,EAAE,KAAK,EACV,KAAK,EAAE,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,EACxC,MAAM,EAAE,qBAAqB,EAC7B,SAAS,GAAE,oBAAyB,EACpC,MAAM,CAAC,EAAE,WAAW,EACpB,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,oBAAoB,GACvD,OAAO,CAAC,QAAQ,EAAE,CAAC,CA2ErB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function uploadPart(blob: Blob,
|
|
1
|
+
export declare function uploadPart(blob: Blob, url: string, partLoaded: {
|
|
2
2
|
bytes: number;
|
|
3
3
|
}, reportProgress: () => void, signal?: AbortSignal): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=upload-part.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-part.d.ts","sourceRoot":"","sources":["../../src/upload/upload-part.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CACxB,IAAI,EAAE,IAAI,EACV,
|
|
1
|
+
{"version":3,"file":"upload-part.d.ts","sourceRoot":"","sources":["../../src/upload/upload-part.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CACxB,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,MAAM,EACX,UAAU,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EAC7B,cAAc,EAAE,MAAM,IAAI,EAC1B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC,CAef"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xhr-upload.d.ts","sourceRoot":"","sources":["../../src/upload/xhr-upload.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACtD,CAAC;AAEF,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"xhr-upload.d.ts","sourceRoot":"","sources":["../../src/upload/xhr-upload.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACtD,CAAC;AAEF,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwE1E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimah-s3/react",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Headless React hooks for presigned S3 file uploads, downloads, and deletes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"s3",
|
|
@@ -34,16 +34,20 @@
|
|
|
34
34
|
".": {
|
|
35
35
|
"types": "./dist/index.d.ts",
|
|
36
36
|
"default": "./dist/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./engine": {
|
|
39
|
+
"types": "./dist/engine.d.ts",
|
|
40
|
+
"default": "./dist/engine.js"
|
|
37
41
|
}
|
|
38
42
|
},
|
|
39
43
|
"files": [
|
|
40
44
|
"dist"
|
|
41
45
|
],
|
|
42
46
|
"dependencies": {
|
|
47
|
+
"@dimah-s3/core": "1.1.0",
|
|
43
48
|
"@fuma-translate/react": "^1.0.2",
|
|
44
49
|
"immer": "^11.1.18",
|
|
45
|
-
"react-dropzone": "^20.1.1"
|
|
46
|
-
"@dimah-s3/core": "1.0.1"
|
|
50
|
+
"react-dropzone": "^20.1.1"
|
|
47
51
|
},
|
|
48
52
|
"peerDependencies": {
|
|
49
53
|
"@fuma-translate/react": "^1.0.2",
|
|
@@ -51,8 +55,10 @@
|
|
|
51
55
|
},
|
|
52
56
|
"devDependencies": {
|
|
53
57
|
"@types/react": "^19.2.18",
|
|
54
|
-
"@types/react-dom": "^19.2.
|
|
55
|
-
"eslint": "
|
|
58
|
+
"@types/react-dom": "^19.2.5",
|
|
59
|
+
"@workspace/eslint-config": "0.0.1",
|
|
60
|
+
"@workspace/typescript-config": "0.0.1",
|
|
61
|
+
"eslint": "^10.9.1",
|
|
56
62
|
"fuma-translate": "^1.0.2",
|
|
57
63
|
"jsdom": "^30.0.1",
|
|
58
64
|
"react": "^19.2.8",
|
|
@@ -60,9 +66,7 @@
|
|
|
60
66
|
"tsc-alias": "^1.9.2",
|
|
61
67
|
"tsup": "^8.5.1",
|
|
62
68
|
"typescript": "7.0.2",
|
|
63
|
-
"vitest": "^4.1.11"
|
|
64
|
-
"@workspace/eslint-config": "0.0.1",
|
|
65
|
-
"@workspace/typescript-config": "0.0.1"
|
|
69
|
+
"vitest": "^4.1.11"
|
|
66
70
|
},
|
|
67
71
|
"publishConfig": {
|
|
68
72
|
"access": "public"
|