@shipstatic/drop 0.2.8 → 0.2.10
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 +21 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -8
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -11700,7 +11700,7 @@ var require_mime_db = __commonJS({
|
|
|
11700
11700
|
}
|
|
11701
11701
|
});
|
|
11702
11702
|
|
|
11703
|
-
// node_modules/.pnpm/@shipstatic+types@0.4.
|
|
11703
|
+
// node_modules/.pnpm/@shipstatic+types@0.4.21/node_modules/@shipstatic/types/dist/index.js
|
|
11704
11704
|
var ErrorType;
|
|
11705
11705
|
(function(ErrorType2) {
|
|
11706
11706
|
ErrorType2["Validation"] = "validation_failed";
|
|
@@ -11815,7 +11815,7 @@ var formatFileSize = formatFileSize$1;
|
|
|
11815
11815
|
function createProcessedFile(file, options) {
|
|
11816
11816
|
const webkitPath = file.webkitRelativePath || "";
|
|
11817
11817
|
const path = options?.path || (webkitPath && webkitPath.trim() ? webkitPath : file.name);
|
|
11818
|
-
const type =
|
|
11818
|
+
const type = getMimeType(path);
|
|
11819
11819
|
return {
|
|
11820
11820
|
// ProcessedFile properties
|
|
11821
11821
|
// Note: md5 is intentionally undefined - Ship SDK will calculate it during deployment
|
|
@@ -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
|
});
|