@shipstatic/drop 0.2.7 → 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 +35 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +35 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11979,12 +11979,42 @@ function useDrop(options) {
|
|
|
11979
11979
|
}));
|
|
11980
11980
|
const processedFiles = cleanFiles.map((file) => createProcessedFile(file));
|
|
11981
11981
|
const finalFiles = stripPrefix ? stripCommonPrefix(processedFiles) : processedFiles;
|
|
11982
|
+
const filesForValidation = finalFiles.map((f) => {
|
|
11983
|
+
const isUnknownType = !f.file.type || f.file.type === "application/octet-stream";
|
|
11984
|
+
if (isUnknownType) {
|
|
11985
|
+
const textFile = new File([f.file], f.file.name, {
|
|
11986
|
+
type: "text/plain",
|
|
11987
|
+
lastModified: f.file.lastModified
|
|
11988
|
+
});
|
|
11989
|
+
if (f.file.webkitRelativePath) {
|
|
11990
|
+
Object.defineProperty(textFile, "webkitRelativePath", {
|
|
11991
|
+
value: f.file.webkitRelativePath,
|
|
11992
|
+
writable: false,
|
|
11993
|
+
configurable: true
|
|
11994
|
+
});
|
|
11995
|
+
}
|
|
11996
|
+
return { ...f, file: textFile };
|
|
11997
|
+
}
|
|
11998
|
+
return f;
|
|
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
|
+
}));
|
|
11982
12007
|
const config = await ship.getConfig();
|
|
11983
|
-
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
|
+
}));
|
|
11984
12014
|
if (validation.error) {
|
|
11985
12015
|
setState({
|
|
11986
12016
|
value: "error",
|
|
11987
|
-
files:
|
|
12017
|
+
files: filesWithStatus,
|
|
11988
12018
|
sourceName: detectedSourceName,
|
|
11989
12019
|
status: {
|
|
11990
12020
|
title: validation.error.error,
|
|
@@ -11996,11 +12026,11 @@ function useDrop(options) {
|
|
|
11996
12026
|
} else if (validation.validFiles.length > 0) {
|
|
11997
12027
|
setState({
|
|
11998
12028
|
value: "ready",
|
|
11999
|
-
files:
|
|
12029
|
+
files: filesWithStatus,
|
|
12000
12030
|
sourceName: detectedSourceName,
|
|
12001
12031
|
status: { title: "Ready", details: `${validation.validFiles.length} file(s) are ready.` }
|
|
12002
12032
|
});
|
|
12003
|
-
onFilesReady?.(validation.
|
|
12033
|
+
onFilesReady?.(filesWithStatus.filter((f, idx) => validation.files[idx]?.status === "ready"));
|
|
12004
12034
|
} else {
|
|
12005
12035
|
const noValidError = {
|
|
12006
12036
|
error: "No Valid Files",
|
|
@@ -12010,7 +12040,7 @@ function useDrop(options) {
|
|
|
12010
12040
|
};
|
|
12011
12041
|
setState({
|
|
12012
12042
|
value: "error",
|
|
12013
|
-
files:
|
|
12043
|
+
files: filesWithStatus,
|
|
12014
12044
|
sourceName: detectedSourceName,
|
|
12015
12045
|
status: { title: noValidError.error, details: noValidError.details }
|
|
12016
12046
|
});
|