@shipstatic/drop 0.2.8 → 0.2.9
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 +19 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -11982,7 +11982,8 @@ function useDrop(options) {
|
|
|
11982
11982
|
const processedFiles = cleanFiles.map((file) => createProcessedFile(file));
|
|
11983
11983
|
const finalFiles = stripPrefix ? stripCommonPrefix(processedFiles) : processedFiles;
|
|
11984
11984
|
const filesForValidation = finalFiles.map((f) => {
|
|
11985
|
-
|
|
11985
|
+
const isUnknownType = !f.file.type || f.file.type === "application/octet-stream";
|
|
11986
|
+
if (isUnknownType) {
|
|
11986
11987
|
const textFile = new File([f.file], f.file.name, {
|
|
11987
11988
|
type: "text/plain",
|
|
11988
11989
|
lastModified: f.file.lastModified
|
|
@@ -11998,12 +11999,24 @@ function useDrop(options) {
|
|
|
11998
11999
|
}
|
|
11999
12000
|
return f;
|
|
12000
12001
|
});
|
|
12002
|
+
const validatableFiles = filesForValidation.map((f) => ({
|
|
12003
|
+
name: f.file.name,
|
|
12004
|
+
type: f.file.type,
|
|
12005
|
+
size: f.file.size,
|
|
12006
|
+
status: f.status,
|
|
12007
|
+
statusMessage: f.statusMessage
|
|
12008
|
+
}));
|
|
12001
12009
|
const config = await ship$1.getConfig();
|
|
12002
|
-
const validation = ship.validateFiles(
|
|
12010
|
+
const validation = ship.validateFiles(validatableFiles, config);
|
|
12011
|
+
const filesWithStatus = filesForValidation.map((processedFile, idx) => ({
|
|
12012
|
+
...processedFile,
|
|
12013
|
+
status: validation.files[idx]?.status || processedFile.status,
|
|
12014
|
+
statusMessage: validation.files[idx]?.statusMessage || processedFile.statusMessage
|
|
12015
|
+
}));
|
|
12003
12016
|
if (validation.error) {
|
|
12004
12017
|
setState({
|
|
12005
12018
|
value: "error",
|
|
12006
|
-
files:
|
|
12019
|
+
files: filesWithStatus,
|
|
12007
12020
|
sourceName: detectedSourceName,
|
|
12008
12021
|
status: {
|
|
12009
12022
|
title: validation.error.error,
|
|
@@ -12015,11 +12028,11 @@ function useDrop(options) {
|
|
|
12015
12028
|
} else if (validation.validFiles.length > 0) {
|
|
12016
12029
|
setState({
|
|
12017
12030
|
value: "ready",
|
|
12018
|
-
files:
|
|
12031
|
+
files: filesWithStatus,
|
|
12019
12032
|
sourceName: detectedSourceName,
|
|
12020
12033
|
status: { title: "Ready", details: `${validation.validFiles.length} file(s) are ready.` }
|
|
12021
12034
|
});
|
|
12022
|
-
onFilesReady?.(validation.
|
|
12035
|
+
onFilesReady?.(filesWithStatus.filter((f, idx) => validation.files[idx]?.status === "ready"));
|
|
12023
12036
|
} else {
|
|
12024
12037
|
const noValidError = {
|
|
12025
12038
|
error: "No Valid Files",
|
|
@@ -12029,7 +12042,7 @@ function useDrop(options) {
|
|
|
12029
12042
|
};
|
|
12030
12043
|
setState({
|
|
12031
12044
|
value: "error",
|
|
12032
|
-
files:
|
|
12045
|
+
files: filesWithStatus,
|
|
12033
12046
|
sourceName: detectedSourceName,
|
|
12034
12047
|
status: { title: noValidError.error, details: noValidError.details }
|
|
12035
12048
|
});
|