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