@aws-amplify/ui-react-storage 3.17.2 → 3.18.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/bin/copy-serviceworker.js +36 -0
- package/dist/browser.js +23 -23
- package/dist/{createStorageBrowser-CtfBkr62.js → createStorageBrowser-S_PgkSVv.js} +1123 -264
- package/dist/download-sw.js +70 -0
- package/dist/esm/components/StorageBrowser/actions/configs/defaults.mjs +3 -1
- package/dist/esm/components/StorageBrowser/actions/handlers/composedDownloadHandler.mjs +2 -2
- package/dist/esm/components/StorageBrowser/actions/handlers/download.mjs +1 -1
- package/dist/esm/components/StorageBrowser/actions/handlers/utils.mjs +23 -1
- package/dist/esm/components/StorageBrowser/actions/handlers/zipdownload.mjs +342 -118
- package/dist/esm/components/StorageBrowser/createStorageBrowser/StorageBrowserDefault.mjs +3 -1
- package/dist/esm/components/StorageBrowser/createStorageBrowser/createStorageBrowser.mjs +1 -1
- package/dist/esm/components/StorageBrowser/displayText/libraries/en/downloadView.mjs +4 -0
- package/dist/esm/components/StorageBrowser/service-worker/useServiceWorkerRegistration.mjs +25 -0
- package/dist/esm/components/StorageBrowser/useAction/useHandler.mjs +6 -2
- package/dist/esm/components/StorageBrowser/views/LocationActionView/DownloadView/DownloadViewProvider.mjs +60 -8
- package/dist/esm/components/StorageBrowser/views/LocationActionView/DownloadView/useDownloadView.mjs +376 -5
- package/dist/esm/components/StorageBrowser/views/LocationActionView/DownloadView/utils.mjs +172 -0
- package/dist/esm/components/StorageBrowser/views/context/actionViews.mjs +1 -0
- package/dist/esm/components/StorageBrowser/views/context/primaryViews.mjs +1 -1
- package/dist/esm/version.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/styles.css +144 -114
- package/dist/types/components/StorageBrowser/actions/handlers/download.d.ts +15 -0
- package/dist/types/components/StorageBrowser/actions/handlers/utils.d.ts +12 -0
- package/dist/types/components/StorageBrowser/actions/handlers/zipdownload.d.ts +2 -2
- package/dist/types/components/StorageBrowser/actions/index.d.ts +1 -1
- package/dist/types/components/StorageBrowser/displayText/types.d.ts +21 -0
- package/dist/types/components/StorageBrowser/service-worker/download-sw.d.ts +2 -0
- package/dist/types/components/StorageBrowser/service-worker/useServiceWorkerRegistration.d.ts +2 -0
- package/dist/types/components/StorageBrowser/useAction/types.d.ts +1 -0
- package/dist/types/components/StorageBrowser/views/LocationActionView/DownloadView/types.d.ts +40 -0
- package/dist/types/components/StorageBrowser/views/LocationActionView/DownloadView/utils.d.ts +99 -0
- package/dist/types/components/StorageBrowser/views/LocationActionView/index.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +12 -8
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { ActionInputConfig, DownloadHandlerData, LocationItemData } from '../../../actions';
|
|
2
|
+
/**
|
|
3
|
+
* Hard cap on the combined number of files a single download may contain,
|
|
4
|
+
* counted across every folder (and loose file) in the selection. Folder
|
|
5
|
+
* expansion stops paginating as soon as the running total would exceed this
|
|
6
|
+
* value and throws {@link FileLimitError}; the view then surfaces a blocked
|
|
7
|
+
* state instead of downloading a truncated set (silent truncation would be
|
|
8
|
+
* data loss). Mirrors the 5000 threshold DeleteView uses for its file count.
|
|
9
|
+
*/
|
|
10
|
+
export declare const LARGE_DOWNLOAD_FILE_COUNT = 5000;
|
|
11
|
+
/**
|
|
12
|
+
* Thrown by {@link expandFolderToFiles} when the combined expanded file count
|
|
13
|
+
* of the selection exceeds {@link LARGE_DOWNLOAD_FILE_COUNT}. Callers use it
|
|
14
|
+
* to distinguish the over-limit state from enumeration failures.
|
|
15
|
+
*/
|
|
16
|
+
export declare class FileLimitError extends Error {
|
|
17
|
+
constructor();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Mutable running total of files expanded so far across the ENTIRE selection.
|
|
21
|
+
* A single instance is shared by every `expandFolderToFiles` call in one
|
|
22
|
+
* enumeration run so the {@link LARGE_DOWNLOAD_FILE_COUNT} cap applies to the
|
|
23
|
+
* combined selection, not per folder.
|
|
24
|
+
*/
|
|
25
|
+
export interface FileCounter {
|
|
26
|
+
count: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Computes the base name for a multi-file zip archive from the flat list of
|
|
30
|
+
* file keys being zipped. Used for file-only, multi-item, and mixed
|
|
31
|
+
* selections; a selection of exactly one folder is named after that folder
|
|
32
|
+
* instead (see {@link resolveArchiveName}).
|
|
33
|
+
*
|
|
34
|
+
* Rule: the name is the last path segment of the LONGEST COMMON ANCESTOR
|
|
35
|
+
* DIRECTORY of all files. For each key the directory segments are
|
|
36
|
+
* `key.split('/')` without the final basename; the longest common prefix of
|
|
37
|
+
* those segment arrays is taken, and its last element is the name. When the
|
|
38
|
+
* common prefix is empty (root-level files or files with no shared ancestor)
|
|
39
|
+
* this falls back to `'download'`.
|
|
40
|
+
*
|
|
41
|
+
* Examples:
|
|
42
|
+
* - ['public/nested/one/pic.jpg', 'public/nested/two/pic.jpg'] -> 'nested'
|
|
43
|
+
* - ['public/nested/a.jpg', 'public/images/b.jpg', 'public/c.jpg'] -> 'public'
|
|
44
|
+
* - ['photos/a.jpg', 'photos/b.jpg'] -> 'photos'
|
|
45
|
+
* - ['a.jpg', 'b.jpg'] -> 'download'
|
|
46
|
+
* - ['public/x.jpg', 'other/y.jpg'] -> 'download'
|
|
47
|
+
* - [] -> 'download'
|
|
48
|
+
*
|
|
49
|
+
* Pure/synchronous; the base name only — the handler appends `.zip`.
|
|
50
|
+
*/
|
|
51
|
+
export declare const getArchiveName: (fileKeys: string[]) => string;
|
|
52
|
+
/**
|
|
53
|
+
* Resolves the zip archive base name for the current SELECTION.
|
|
54
|
+
*
|
|
55
|
+
* When the selection consists of exactly ONE FOLDER (no other items), the
|
|
56
|
+
* archive is named after that folder (basename of `folder.key`, trailing
|
|
57
|
+
* slash stripped): the download was initiated from that folder, so selecting
|
|
58
|
+
* `photos/` yields `photos.zip` even when every file lives in a deeper
|
|
59
|
+
* subfolder like `photos/vacation/`. Every other selection shape (file-only,
|
|
60
|
+
* multi-folder, mixed) falls back to the longest-common-ancestor rule of
|
|
61
|
+
* {@link getArchiveName}.
|
|
62
|
+
*/
|
|
63
|
+
export declare const resolveArchiveName: (dataItems: LocationItemData[], fileKeys: string[]) => string;
|
|
64
|
+
export interface ExpandFolderToFilesOptions {
|
|
65
|
+
/** S3 key of the folder to expand (ends in `'/'`). */
|
|
66
|
+
folderKey: string;
|
|
67
|
+
/** Storage action config. */
|
|
68
|
+
config: ActionInputConfig;
|
|
69
|
+
/**
|
|
70
|
+
* Current browse-location prefix `P`; each file's `relativePath` is
|
|
71
|
+
* computed as `key.slice(P.length)`.
|
|
72
|
+
*/
|
|
73
|
+
locationPrefix: string;
|
|
74
|
+
/**
|
|
75
|
+
* Optional abort signal; when aborted between pages the loop throws an
|
|
76
|
+
* `AbortError` and no items are returned.
|
|
77
|
+
*/
|
|
78
|
+
signal?: AbortSignal;
|
|
79
|
+
/**
|
|
80
|
+
* Shared running total of files expanded so far across the selection (see
|
|
81
|
+
* {@link FileCounter}). Callers expanding multiple folders MUST pass the
|
|
82
|
+
* same instance to every call so the cap applies to the combined selection.
|
|
83
|
+
* Defaults to a fresh counter (single-folder cap still enforced).
|
|
84
|
+
*/
|
|
85
|
+
fileCounter?: FileCounter;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Recursively expands a folder into the flat list of downloadable files it
|
|
89
|
+
* contains, preserving each file's folder-relative zip path.
|
|
90
|
+
*
|
|
91
|
+
* Clones the pagination loop from DeleteView's `countFilesInFolder`, but:
|
|
92
|
+
* - collects {@link DownloadHandlerData} items instead of counting,
|
|
93
|
+
* - stops paginating and throws {@link FileLimitError} once the shared
|
|
94
|
+
* `fileCounter` would exceed {@link LARGE_DOWNLOAD_FILE_COUNT} (the caller
|
|
95
|
+
* surfaces a blocked state; a truncated zip is never produced),
|
|
96
|
+
* - filters out directory markers (keys ending in `'/'`),
|
|
97
|
+
* - is cancellable via `signal`, checked between `list()` pages.
|
|
98
|
+
*/
|
|
99
|
+
export declare const expandFolderToFiles: ({ folderKey, config, locationPrefix, signal, fileCounter, }: ExpandFolderToFilesOptions) => Promise<DownloadHandlerData[]>;
|
|
@@ -4,7 +4,7 @@ export type { CreateFolderViewProps, CreateFolderViewType, CreateFolderViewState
|
|
|
4
4
|
export { CreateFolderView, useCreateFolderView } from './CreateFolderView';
|
|
5
5
|
export type { DeleteViewProps, DeleteViewType, DeleteViewState, } from './DeleteView';
|
|
6
6
|
export { DeleteView, useDeleteView } from './DeleteView';
|
|
7
|
-
export type { DownloadViewProps, DownloadViewType, DownloadViewState, } from './DownloadView';
|
|
7
|
+
export type { DownloadEnumerationStatus, DownloadViewProps, DownloadViewType, DownloadViewState, } from './DownloadView';
|
|
8
8
|
export { DownloadView, useDownloadView } from './DownloadView';
|
|
9
9
|
export { LocationActionView } from './LocationActionView';
|
|
10
10
|
export type { UploadViewProps, UploadViewType, UploadViewState, } from './UploadView';
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "3.
|
|
1
|
+
export declare const VERSION = "3.18.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/ui-react-storage",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.18.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/esm/index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
"./styles.css": "./dist/styles.css"
|
|
21
21
|
},
|
|
22
22
|
"types": "dist/types/index.d.ts",
|
|
23
|
+
"bin": {
|
|
24
|
+
"copy-serviceworker": "./bin/copy-serviceworker.js"
|
|
25
|
+
},
|
|
23
26
|
"license": "Apache-2.0",
|
|
24
27
|
"repository": {
|
|
25
28
|
"type": "git",
|
|
@@ -28,6 +31,7 @@
|
|
|
28
31
|
},
|
|
29
32
|
"files": [
|
|
30
33
|
"dist",
|
|
34
|
+
"bin",
|
|
31
35
|
"LICENSE",
|
|
32
36
|
"browser"
|
|
33
37
|
],
|
|
@@ -43,17 +47,17 @@
|
|
|
43
47
|
"size": "yarn size-limit",
|
|
44
48
|
"test": "jest",
|
|
45
49
|
"test:watch": "yarn test --watch",
|
|
46
|
-
"typecheck": "tsc --noEmit"
|
|
50
|
+
"typecheck": "tsc --noEmit && tsc --project tsconfig.sw.json --noEmit"
|
|
47
51
|
},
|
|
48
52
|
"dependencies": {
|
|
49
|
-
"@aws-amplify/ui": "6.15.
|
|
50
|
-
"@aws-amplify/ui-react": "6.15.
|
|
51
|
-
"@aws-amplify/ui-react-core": "3.6.
|
|
53
|
+
"@aws-amplify/ui": "6.15.5",
|
|
54
|
+
"@aws-amplify/ui-react": "6.15.5",
|
|
55
|
+
"@aws-amplify/ui-react-core": "3.6.5",
|
|
52
56
|
"tslib": "^2.5.2",
|
|
53
57
|
"@zip.js/zip.js": "^2.7.53"
|
|
54
58
|
},
|
|
55
59
|
"peerDependencies": {
|
|
56
|
-
"aws-amplify": "^6.
|
|
60
|
+
"aws-amplify": "^6.17.0",
|
|
57
61
|
"react": "^16.14 || ^17 || ^18 || ^19",
|
|
58
62
|
"react-dom": "^16.14 || ^17 || ^18 || ^19"
|
|
59
63
|
},
|
|
@@ -69,7 +73,7 @@
|
|
|
69
73
|
"name": "createStorageBrowser",
|
|
70
74
|
"path": "dist/esm/browser.mjs",
|
|
71
75
|
"import": "{ createStorageBrowser }",
|
|
72
|
-
"limit": "
|
|
76
|
+
"limit": "133 kB",
|
|
73
77
|
"ignore": [
|
|
74
78
|
"@aws-amplify/storage"
|
|
75
79
|
]
|
|
@@ -78,7 +82,7 @@
|
|
|
78
82
|
"name": "StorageBrowser",
|
|
79
83
|
"path": "dist/esm/index.mjs",
|
|
80
84
|
"import": "{ StorageBrowser }",
|
|
81
|
-
"limit": "
|
|
85
|
+
"limit": "157 kB"
|
|
82
86
|
},
|
|
83
87
|
{
|
|
84
88
|
"name": "FileUploader",
|