@shipstatic/drop 0.1.12 → 0.1.13

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.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { useState, useRef, useMemo, useCallback } from 'react';
2
2
  import { formatFileSize as formatFileSize$1, getValidFiles, filterJunk, validateFiles } from '@shipstatic/ship';
3
- import { FileValidationStatus } from '@shipstatic/types';
4
3
 
5
4
  var __create = Object.create;
6
5
  var __defProp = Object.defineProperty;
@@ -11701,6 +11700,42 @@ var require_mime_db = __commonJS({
11701
11700
  }
11702
11701
  });
11703
11702
 
11703
+ // node_modules/.pnpm/@shipstatic+types@0.3.18/node_modules/@shipstatic/types/dist/index.js
11704
+ var ErrorType;
11705
+ (function(ErrorType2) {
11706
+ ErrorType2["Validation"] = "validation_failed";
11707
+ ErrorType2["NotFound"] = "not_found";
11708
+ ErrorType2["RateLimit"] = "rate_limit_exceeded";
11709
+ ErrorType2["Authentication"] = "authentication_failed";
11710
+ ErrorType2["Business"] = "business_logic_error";
11711
+ ErrorType2["Api"] = "internal_server_error";
11712
+ ErrorType2["Network"] = "network_error";
11713
+ ErrorType2["Cancelled"] = "operation_cancelled";
11714
+ ErrorType2["File"] = "file_error";
11715
+ ErrorType2["Config"] = "config_error";
11716
+ })(ErrorType || (ErrorType = {}));
11717
+ ({
11718
+ client: /* @__PURE__ */ new Set([ErrorType.Business, ErrorType.Config, ErrorType.File, ErrorType.Validation]),
11719
+ network: /* @__PURE__ */ new Set([ErrorType.Network]),
11720
+ auth: /* @__PURE__ */ new Set([ErrorType.Authentication])
11721
+ });
11722
+ var FileValidationStatus = {
11723
+ PENDING: "pending",
11724
+ PROCESSING_ERROR: "processing_error",
11725
+ EMPTY_FILE: "empty_file",
11726
+ VALIDATION_FAILED: "validation_failed",
11727
+ READY: "ready"
11728
+ };
11729
+
11730
+ // src/types.ts
11731
+ var FILE_STATUSES = {
11732
+ ...FileValidationStatus,
11733
+ PROCESSING: "processing",
11734
+ UPLOADING: "uploading",
11735
+ COMPLETE: "complete",
11736
+ ERROR: "error"
11737
+ };
11738
+
11704
11739
  // src/utils/zipExtractor.ts
11705
11740
  var import_jszip = __toESM(require_jszip_min());
11706
11741
 
@@ -11776,15 +11811,6 @@ function normalizePath(path) {
11776
11811
  function isZipFile(file) {
11777
11812
  return file.type === "application/zip" || file.type === "application/x-zip-compressed" || file.name.toLowerCase().endsWith(".zip");
11778
11813
  }
11779
- var FILE_STATUSES = {
11780
- ...FileValidationStatus,
11781
- PROCESSING: "processing",
11782
- UPLOADING: "uploading",
11783
- COMPLETE: "complete",
11784
- ERROR: "error"
11785
- };
11786
-
11787
- // src/utils/fileProcessing.ts
11788
11814
  var formatFileSize = formatFileSize$1;
11789
11815
  async function createProcessedFile(file, options) {
11790
11816
  const webkitPath = file.webkitRelativePath || "";
@@ -12026,7 +12052,17 @@ function useDrop(options) {
12026
12052
  e.preventDefault();
12027
12053
  setState((prev) => {
12028
12054
  if (prev.value !== "dragging") return prev;
12029
- const nextValue = prev.files.length > 0 ? prev.status?.title === "Ready" ? "ready" : "error" : "idle";
12055
+ if (prev.files.length === 0) {
12056
+ return { ...prev, value: "idle" };
12057
+ }
12058
+ const errorStatuses = [
12059
+ FILE_STATUSES.VALIDATION_FAILED,
12060
+ FILE_STATUSES.PROCESSING_ERROR,
12061
+ FILE_STATUSES.EMPTY_FILE,
12062
+ FILE_STATUSES.ERROR
12063
+ ];
12064
+ const hasErrors = prev.files.some((f) => errorStatuses.includes(f.status));
12065
+ const nextValue = hasErrors ? "error" : "ready";
12030
12066
  return { ...prev, value: nextValue };
12031
12067
  });
12032
12068
  }, []);