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