@shipstatic/drop 2.10.4-beta.7 → 2.10.4-beta.8
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/index.cjs +27 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1119,13 +1119,12 @@ function useDrop({ ship }) {
|
|
|
1119
1119
|
[state.files]
|
|
1120
1120
|
);
|
|
1121
1121
|
const getFilesForUpload = useCallback(() => validFiles.map((f) => f.file), [validFiles]);
|
|
1122
|
-
const
|
|
1123
|
-
async (
|
|
1122
|
+
const prepare = useCallback(
|
|
1123
|
+
async (collect) => {
|
|
1124
1124
|
if (runRef.current) {
|
|
1125
1125
|
console.warn("File processing already in progress. Ignoring duplicate call.");
|
|
1126
1126
|
return;
|
|
1127
1127
|
}
|
|
1128
|
-
if (!newFiles || newFiles.length === 0) return;
|
|
1129
1128
|
const run = new AbortController();
|
|
1130
1129
|
runRef.current = run;
|
|
1131
1130
|
setState({
|
|
@@ -1134,8 +1133,17 @@ function useDrop({ ship }) {
|
|
|
1134
1133
|
status: { title: "Processing...", details: "Validating and preparing files." }
|
|
1135
1134
|
});
|
|
1136
1135
|
try {
|
|
1137
|
-
const
|
|
1138
|
-
|
|
1136
|
+
const [files, limits] = await Promise.all([
|
|
1137
|
+
collect(),
|
|
1138
|
+
ship.getLimits({ signal: run.signal })
|
|
1139
|
+
]);
|
|
1140
|
+
if (run.signal.aborted) return;
|
|
1141
|
+
if (files.length === 0) {
|
|
1142
|
+
setState(initialState);
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1145
|
+
const outcome = await processFiles(files, {
|
|
1146
|
+
limits,
|
|
1139
1147
|
onStatus: (status) => {
|
|
1140
1148
|
if (!run.signal.aborted) setState((prev) => ({ ...prev, status }));
|
|
1141
1149
|
}
|
|
@@ -1165,6 +1173,13 @@ function useDrop({ ship }) {
|
|
|
1165
1173
|
},
|
|
1166
1174
|
[ship]
|
|
1167
1175
|
);
|
|
1176
|
+
const processFiles2 = useCallback(
|
|
1177
|
+
async (newFiles) => {
|
|
1178
|
+
if (!newFiles || newFiles.length === 0) return;
|
|
1179
|
+
await prepare(async () => newFiles);
|
|
1180
|
+
},
|
|
1181
|
+
[prepare]
|
|
1182
|
+
);
|
|
1168
1183
|
const reset = useCallback(() => {
|
|
1169
1184
|
runRef.current?.abort();
|
|
1170
1185
|
runRef.current = null;
|
|
@@ -1203,13 +1218,14 @@ function useDrop({ ship }) {
|
|
|
1203
1218
|
if (file) files.push(file);
|
|
1204
1219
|
}
|
|
1205
1220
|
}
|
|
1206
|
-
|
|
1207
|
-
if (
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1221
|
+
const plain = Array.from(e.dataTransfer.files);
|
|
1222
|
+
if (directories.length === 0 && files.length === 0 && plain.length === 0) return;
|
|
1223
|
+
await prepare(async () => {
|
|
1224
|
+
await Promise.all(directories.map((d) => traverseFileTree(d.entry, files, d.path)));
|
|
1225
|
+
return files.length > 0 ? files : plain;
|
|
1226
|
+
});
|
|
1211
1227
|
},
|
|
1212
|
-
[
|
|
1228
|
+
[prepare]
|
|
1213
1229
|
);
|
|
1214
1230
|
const handleInputChange = useCallback(
|
|
1215
1231
|
(e) => {
|