@shipstatic/drop 0.2.26 → 0.2.28
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 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -11
- 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.7.
|
|
11703
|
+
// node_modules/.pnpm/@shipstatic+types@0.7.5/node_modules/@shipstatic/types/dist/index.js
|
|
11704
11704
|
var ErrorType;
|
|
11705
11705
|
(function(ErrorType2) {
|
|
11706
11706
|
ErrorType2["Validation"] = "validation_failed";
|
|
@@ -11719,6 +11719,9 @@ var ErrorType;
|
|
|
11719
11719
|
network: /* @__PURE__ */ new Set([ErrorType.Network]),
|
|
11720
11720
|
auth: /* @__PURE__ */ new Set([ErrorType.Authentication])
|
|
11721
11721
|
});
|
|
11722
|
+
function isShipError(error) {
|
|
11723
|
+
return error !== null && typeof error === "object" && "name" in error && error.name === "ShipError" && "status" in error;
|
|
11724
|
+
}
|
|
11722
11725
|
var FileValidationStatus = {
|
|
11723
11726
|
/** File is pending validation */
|
|
11724
11727
|
PENDING: "pending",
|
|
@@ -11945,8 +11948,8 @@ function useDrop(options) {
|
|
|
11945
11948
|
sourceName: "",
|
|
11946
11949
|
status: { title: "Processing...", details: "Validating and preparing files." }
|
|
11947
11950
|
});
|
|
11951
|
+
let detectedSourceName = "";
|
|
11948
11952
|
try {
|
|
11949
|
-
let detectedSourceName = "";
|
|
11950
11953
|
if (newFiles.length === 1 && isZipFile(newFiles[0])) {
|
|
11951
11954
|
detectedSourceName = newFiles[0].name.replace(/\.zip$/i, "");
|
|
11952
11955
|
} else if (newFiles.length > 0) {
|
|
@@ -12067,18 +12070,25 @@ function useDrop(options) {
|
|
|
12067
12070
|
}
|
|
12068
12071
|
}
|
|
12069
12072
|
} catch (error) {
|
|
12070
|
-
const
|
|
12071
|
-
|
|
12072
|
-
|
|
12073
|
-
|
|
12073
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
12074
|
+
const isValidation = isShipError(error);
|
|
12075
|
+
const clientError = {
|
|
12076
|
+
error: isValidation ? "Validation Failed" : "Processing Failed",
|
|
12077
|
+
details: isValidation ? message : `Failed to process files: ${message}`,
|
|
12078
|
+
errors: isValidation ? [message] : [],
|
|
12074
12079
|
isClientError: true
|
|
12075
12080
|
};
|
|
12076
|
-
setState(
|
|
12077
|
-
...prev,
|
|
12081
|
+
setState({
|
|
12078
12082
|
value: "error",
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
|
|
12083
|
+
files: [],
|
|
12084
|
+
sourceName: detectedSourceName,
|
|
12085
|
+
status: {
|
|
12086
|
+
title: clientError.error,
|
|
12087
|
+
details: clientError.details,
|
|
12088
|
+
...clientError.errors.length > 0 && { errors: clientError.errors }
|
|
12089
|
+
}
|
|
12090
|
+
});
|
|
12091
|
+
onValidationError?.(clientError);
|
|
12082
12092
|
} finally {
|
|
12083
12093
|
isProcessingRef.current = false;
|
|
12084
12094
|
}
|