@shipstatic/drop 0.2.26 → 0.2.27

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