@aws-amplify/ui-react-storage 3.10.1 → 3.10.2
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/dist/browser.js +1 -1
- package/dist/{createStorageBrowser-BfRLqdUj.js → createStorageBrowser-Cbdy8OAN.js} +26 -17
- package/dist/esm/components/StorageBrowser/tasks/useProcessTasks.mjs +20 -11
- package/dist/esm/components/StorageBrowser/useAction/useHandler.mjs +5 -5
- package/dist/esm/version.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/types/components/StorageBrowser/tasks/types.d.ts +10 -3
- package/dist/types/components/StorageBrowser/tasks/useProcessTasks.d.ts +2 -2
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
package/dist/browser.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var internals = require('@aws-amplify/storage/internals');
|
|
6
6
|
require('@aws-amplify/ui');
|
|
7
|
-
var createStorageBrowser = require('./createStorageBrowser-
|
|
7
|
+
var createStorageBrowser = require('./createStorageBrowser-Cbdy8OAN.js');
|
|
8
8
|
require('aws-amplify/storage');
|
|
9
9
|
require('react');
|
|
10
10
|
require('@aws-amplify/ui-react');
|
|
@@ -32,7 +32,7 @@ function _interopNamespace(e) {
|
|
|
32
32
|
|
|
33
33
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
34
34
|
|
|
35
|
-
const VERSION = '3.10.
|
|
35
|
+
const VERSION = '3.10.2';
|
|
36
36
|
|
|
37
37
|
const toAccessGrantPermission = (permission) => {
|
|
38
38
|
let result = '';
|
|
@@ -1923,9 +1923,9 @@ const QUEUED_TASK_BASE = {
|
|
|
1923
1923
|
progress: undefined,
|
|
1924
1924
|
status: 'QUEUED',
|
|
1925
1925
|
};
|
|
1926
|
-
const
|
|
1926
|
+
const isSingleTaskInput = (input) => !!input.data;
|
|
1927
1927
|
function useProcessTasks(handler, options) {
|
|
1928
|
-
const {
|
|
1928
|
+
const { items, ...callbacks } = options ?? {};
|
|
1929
1929
|
const callbacksRef = React__namespace["default"].useRef(callbacks);
|
|
1930
1930
|
if (callbacks) {
|
|
1931
1931
|
callbacksRef.current = callbacks;
|
|
@@ -1996,13 +1996,13 @@ function useProcessTasks(handler, options) {
|
|
|
1996
1996
|
});
|
|
1997
1997
|
flush();
|
|
1998
1998
|
}, [createTask, flush, updateTask, items, refreshTaskData]);
|
|
1999
|
-
const
|
|
2000
|
-
const
|
|
2001
|
-
if (
|
|
1999
|
+
const processTask = (_input) => {
|
|
2000
|
+
const isSingleTask = isSingleTaskInput(_input);
|
|
2001
|
+
if (isSingleTask) {
|
|
2002
2002
|
createTask(_input.data);
|
|
2003
2003
|
flush();
|
|
2004
2004
|
}
|
|
2005
|
-
const { data } =
|
|
2005
|
+
const { data } = isSingleTask
|
|
2006
2006
|
? _input
|
|
2007
2007
|
: [...tasksRef.current.values()].find(({ status }) => status === 'QUEUED') ?? {};
|
|
2008
2008
|
if (!data)
|
|
@@ -2047,10 +2047,10 @@ function useProcessTasks(handler, options) {
|
|
|
2047
2047
|
const task = getTask();
|
|
2048
2048
|
if (task && ui.isFunction(onTaskComplete))
|
|
2049
2049
|
onTaskComplete(task);
|
|
2050
|
-
// ignore process next task for single
|
|
2051
|
-
if (
|
|
2050
|
+
// ignore process next task for single task
|
|
2051
|
+
if (isSingleTask)
|
|
2052
2052
|
return;
|
|
2053
|
-
|
|
2053
|
+
processTask(_input);
|
|
2054
2054
|
});
|
|
2055
2055
|
updateTask(data.id, { cancel, status: 'PENDING' });
|
|
2056
2056
|
};
|
|
@@ -2062,13 +2062,22 @@ function useProcessTasks(handler, options) {
|
|
|
2062
2062
|
if (isProcessing) {
|
|
2063
2063
|
return;
|
|
2064
2064
|
}
|
|
2065
|
+
// if single task, run `processTask` once
|
|
2066
|
+
if (isSingleTaskInput(input)) {
|
|
2067
|
+
processTask(input);
|
|
2068
|
+
return;
|
|
2069
|
+
}
|
|
2070
|
+
const { concurrency, ...options } = input.options ?? {};
|
|
2071
|
+
// reconstruct `input` without `concurrency`
|
|
2072
|
+
const _input = { ...input, options };
|
|
2073
|
+
// for batch tasks, if no `concurrency` process tasks individually
|
|
2065
2074
|
if (!concurrency) {
|
|
2066
|
-
|
|
2075
|
+
processTask(_input);
|
|
2067
2076
|
return;
|
|
2068
2077
|
}
|
|
2069
2078
|
let count = 0;
|
|
2070
2079
|
while (count < concurrency) {
|
|
2071
|
-
|
|
2080
|
+
processTask(_input);
|
|
2072
2081
|
count++;
|
|
2073
2082
|
}
|
|
2074
2083
|
};
|
|
@@ -2084,10 +2093,7 @@ function useProcessTasks(handler, options) {
|
|
|
2084
2093
|
const isOptionsWithItems = (options) => !!options?.items;
|
|
2085
2094
|
const isHandleTaskInput = (value) => !!value?.data;
|
|
2086
2095
|
function useHandler(handler, options) {
|
|
2087
|
-
const [state, handleProcessing] = useProcessTasks(handler,
|
|
2088
|
-
...options,
|
|
2089
|
-
concurrency: DEFAULT_ACTION_CONCURRENCY,
|
|
2090
|
-
});
|
|
2096
|
+
const [state, handleProcessing] = useProcessTasks(handler, options);
|
|
2091
2097
|
const getConfig = useGetActionInput();
|
|
2092
2098
|
const { reset, isProcessing, tasks, ...rest } = state;
|
|
2093
2099
|
const handleDispatch = React__namespace["default"].useCallback((input) => {
|
|
@@ -2098,7 +2104,10 @@ function useHandler(handler, options) {
|
|
|
2098
2104
|
reset();
|
|
2099
2105
|
handleProcessing({
|
|
2100
2106
|
config,
|
|
2101
|
-
...(hasData
|
|
2107
|
+
...(hasData
|
|
2108
|
+
? { data: input.data }
|
|
2109
|
+
: // if no `data` provided, provide `concurrency` to `options`
|
|
2110
|
+
{ options: { concurrency: DEFAULT_ACTION_CONCURRENCY } }),
|
|
2102
2111
|
});
|
|
2103
2112
|
}, [getConfig, handleProcessing, reset]);
|
|
2104
2113
|
if (isOptionsWithItems(options)) {
|
|
@@ -8,9 +8,9 @@ const QUEUED_TASK_BASE = {
|
|
|
8
8
|
progress: undefined,
|
|
9
9
|
status: 'QUEUED',
|
|
10
10
|
};
|
|
11
|
-
const
|
|
11
|
+
const isSingleTaskInput = (input) => !!input.data;
|
|
12
12
|
function useProcessTasks(handler, options) {
|
|
13
|
-
const {
|
|
13
|
+
const { items, ...callbacks } = options ?? {};
|
|
14
14
|
const callbacksRef = React__default.useRef(callbacks);
|
|
15
15
|
if (callbacks) {
|
|
16
16
|
callbacksRef.current = callbacks;
|
|
@@ -81,13 +81,13 @@ function useProcessTasks(handler, options) {
|
|
|
81
81
|
});
|
|
82
82
|
flush();
|
|
83
83
|
}, [createTask, flush, updateTask, items, refreshTaskData]);
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
84
|
+
const processTask = (_input) => {
|
|
85
|
+
const isSingleTask = isSingleTaskInput(_input);
|
|
86
|
+
if (isSingleTask) {
|
|
87
87
|
createTask(_input.data);
|
|
88
88
|
flush();
|
|
89
89
|
}
|
|
90
|
-
const { data } =
|
|
90
|
+
const { data } = isSingleTask
|
|
91
91
|
? _input
|
|
92
92
|
: [...tasksRef.current.values()].find(({ status }) => status === 'QUEUED') ?? {};
|
|
93
93
|
if (!data)
|
|
@@ -132,10 +132,10 @@ function useProcessTasks(handler, options) {
|
|
|
132
132
|
const task = getTask();
|
|
133
133
|
if (task && isFunction(onTaskComplete))
|
|
134
134
|
onTaskComplete(task);
|
|
135
|
-
// ignore process next task for single
|
|
136
|
-
if (
|
|
135
|
+
// ignore process next task for single task
|
|
136
|
+
if (isSingleTask)
|
|
137
137
|
return;
|
|
138
|
-
|
|
138
|
+
processTask(_input);
|
|
139
139
|
});
|
|
140
140
|
updateTask(data.id, { cancel, status: 'PENDING' });
|
|
141
141
|
};
|
|
@@ -147,13 +147,22 @@ function useProcessTasks(handler, options) {
|
|
|
147
147
|
if (isProcessing) {
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
150
|
+
// if single task, run `processTask` once
|
|
151
|
+
if (isSingleTaskInput(input)) {
|
|
152
|
+
processTask(input);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const { concurrency, ...options } = input.options ?? {};
|
|
156
|
+
// reconstruct `input` without `concurrency`
|
|
157
|
+
const _input = { ...input, options };
|
|
158
|
+
// for batch tasks, if no `concurrency` process tasks individually
|
|
150
159
|
if (!concurrency) {
|
|
151
|
-
|
|
160
|
+
processTask(_input);
|
|
152
161
|
return;
|
|
153
162
|
}
|
|
154
163
|
let count = 0;
|
|
155
164
|
while (count < concurrency) {
|
|
156
|
-
|
|
165
|
+
processTask(_input);
|
|
157
166
|
count++;
|
|
158
167
|
}
|
|
159
168
|
};
|
|
@@ -9,10 +9,7 @@ import { useProcessTasks } from '../tasks/useProcessTasks.mjs';
|
|
|
9
9
|
const isOptionsWithItems = (options) => !!options?.items;
|
|
10
10
|
const isHandleTaskInput = (value) => !!value?.data;
|
|
11
11
|
function useHandler(handler, options) {
|
|
12
|
-
const [state, handleProcessing] = useProcessTasks(handler,
|
|
13
|
-
...options,
|
|
14
|
-
concurrency: DEFAULT_ACTION_CONCURRENCY,
|
|
15
|
-
});
|
|
12
|
+
const [state, handleProcessing] = useProcessTasks(handler, options);
|
|
16
13
|
const getConfig = useGetActionInput();
|
|
17
14
|
const { reset, isProcessing, tasks, ...rest } = state;
|
|
18
15
|
const handleDispatch = React__default.useCallback((input) => {
|
|
@@ -23,7 +20,10 @@ function useHandler(handler, options) {
|
|
|
23
20
|
reset();
|
|
24
21
|
handleProcessing({
|
|
25
22
|
config,
|
|
26
|
-
...(hasData
|
|
23
|
+
...(hasData
|
|
24
|
+
? { data: input.data }
|
|
25
|
+
: // if no `data` provided, provide `concurrency` to `options`
|
|
26
|
+
{ options: { concurrency: DEFAULT_ACTION_CONCURRENCY } }),
|
|
27
27
|
});
|
|
28
28
|
}, [getConfig, handleProcessing, reset]);
|
|
29
29
|
if (isOptionsWithItems(options)) {
|
package/dist/esm/version.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var uiReactCore = require('@aws-amplify/ui-react-core');
|
|
|
9
9
|
var auth = require('aws-amplify/auth');
|
|
10
10
|
var storage = require('aws-amplify/storage');
|
|
11
11
|
var internal = require('@aws-amplify/ui-react/internal');
|
|
12
|
-
var createStorageBrowser = require('./createStorageBrowser-
|
|
12
|
+
var createStorageBrowser = require('./createStorageBrowser-Cbdy8OAN.js');
|
|
13
13
|
require('@aws-amplify/storage/internals');
|
|
14
14
|
require('aws-amplify');
|
|
15
15
|
require('aws-amplify/utils');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TaskHandlerInput, TaskData, TaskResult, TaskResultStatus } from '../actions';
|
|
1
|
+
import { TaskHandlerInput, TaskData, TaskResult, TaskResultStatus, TaskHandlerOptions } from '../actions';
|
|
2
2
|
/**
|
|
3
3
|
* extends {@link TaskResultStatus} to include `QUEUED` and `PENDING` statuses
|
|
4
4
|
* used in task processing
|
|
@@ -9,7 +9,6 @@ export type TaskStatus = TaskResultStatus | 'QUEUED' | 'PENDING';
|
|
|
9
9
|
*/
|
|
10
10
|
export type StatusCounts = Record<TaskStatus | 'TOTAL', number>;
|
|
11
11
|
export interface ProcessTasksOptions<TTask extends Task, TItems = []> {
|
|
12
|
-
concurrency?: number;
|
|
13
12
|
items?: TItems;
|
|
14
13
|
onTaskCancel?: (task: TTask) => void;
|
|
15
14
|
onTaskComplete?: (task: TTask) => void;
|
|
@@ -48,4 +47,12 @@ export type UseProcessTasksState<TTask, TInput> = [
|
|
|
48
47
|
TasksState<TTask>,
|
|
49
48
|
HandleProcessTasks<TInput>
|
|
50
49
|
];
|
|
51
|
-
|
|
50
|
+
interface HandleTasksOptions extends TaskHandlerOptions {
|
|
51
|
+
concurrency?: number;
|
|
52
|
+
}
|
|
53
|
+
export interface HandleBatchTasksInput<TData extends TaskData> extends Omit<TaskHandlerInput<TData, HandleTasksOptions>, 'data'> {
|
|
54
|
+
}
|
|
55
|
+
export interface HandleSingleTaskInput<TData extends TaskData> extends TaskHandlerInput<TData> {
|
|
56
|
+
}
|
|
57
|
+
export type InferHandleTasksInput<TItems, TData extends TaskData> = TItems extends NonNullable<TItems> ? HandleBatchTasksInput<TData> : HandleSingleTaskInput<TData>;
|
|
58
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ActionHandler } from '../actions';
|
|
2
|
-
import { InferHandleTasksInput, Task, ProcessTasksOptions, UseProcessTasksState } from './types';
|
|
1
|
+
import type { ActionHandler } from '../actions';
|
|
2
|
+
import type { InferHandleTasksInput, Task, ProcessTasksOptions, UseProcessTasksState } from './types';
|
|
3
3
|
export declare function useProcessTasks<TData, TValue, TTask extends Task<TData, TValue>, TInput extends InferHandleTasksInput<TItems, TTask['data']>, TItems extends TTask['data'][] | undefined = undefined>(handler: ActionHandler<TData, TValue>, options?: ProcessTasksOptions<TTask, TItems>): UseProcessTasksState<TTask, TInput>;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "3.10.
|
|
1
|
+
export declare const VERSION = "3.10.2";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/ui-react-storage",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/esm/index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"name": "createStorageBrowser",
|
|
67
67
|
"path": "dist/esm/browser.mjs",
|
|
68
68
|
"import": "{ createStorageBrowser }",
|
|
69
|
-
"limit": "64.
|
|
69
|
+
"limit": "64.19 kB",
|
|
70
70
|
"ignore": [
|
|
71
71
|
"@aws-amplify/storage"
|
|
72
72
|
]
|