@shipstatic/drop 0.1.11 → 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/README.md +43 -41
- package/dist/index.cjs +49 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -11
- package/dist/index.d.ts +9 -11
- package/dist/index.js +49 -16
- package/dist/index.js.map +1 -1
- package/package.json +10 -8
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ValidationError } from '@shipstatic/types';
|
|
1
2
|
import { Ship, formatFileSize as formatFileSize$1 } from '@shipstatic/ship';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -5,28 +6,24 @@ import { Ship, formatFileSize as formatFileSize$1 } from '@shipstatic/ship';
|
|
|
5
6
|
* Imports types from @shipstatic/types (single source of truth)
|
|
6
7
|
* and defines drop-specific types
|
|
7
8
|
*/
|
|
9
|
+
|
|
8
10
|
declare const FILE_STATUSES: {
|
|
9
|
-
readonly PENDING: "pending";
|
|
10
11
|
readonly PROCESSING: "processing";
|
|
11
|
-
readonly VALIDATION_FAILED: "validation_failed";
|
|
12
|
-
readonly PROCESSING_ERROR: "processing_error";
|
|
13
|
-
readonly EMPTY_FILE: "empty_file";
|
|
14
|
-
readonly READY: "ready";
|
|
15
12
|
readonly UPLOADING: "uploading";
|
|
16
13
|
readonly COMPLETE: "complete";
|
|
17
14
|
readonly ERROR: "error";
|
|
15
|
+
readonly PENDING: "pending";
|
|
16
|
+
readonly PROCESSING_ERROR: "processing_error";
|
|
17
|
+
readonly EMPTY_FILE: "empty_file";
|
|
18
|
+
readonly VALIDATION_FAILED: "validation_failed";
|
|
19
|
+
readonly READY: "ready";
|
|
18
20
|
};
|
|
19
21
|
type FileStatus = (typeof FILE_STATUSES)[keyof typeof FILE_STATUSES];
|
|
20
22
|
/**
|
|
21
23
|
* Client-side error structure
|
|
22
24
|
* Matches ValidationError from @shipstatic/ship for consistency
|
|
23
25
|
*/
|
|
24
|
-
|
|
25
|
-
error: string;
|
|
26
|
-
details: string;
|
|
27
|
-
errors?: string[];
|
|
28
|
-
isClientError: true;
|
|
29
|
-
}
|
|
26
|
+
type ClientError = ValidationError;
|
|
30
27
|
/**
|
|
31
28
|
* Processed file entry ready for upload
|
|
32
29
|
* Contains both the File object and UI-specific metadata
|
|
@@ -103,6 +100,7 @@ interface DropReturn {
|
|
|
103
100
|
status: {
|
|
104
101
|
title: string;
|
|
105
102
|
details: string;
|
|
103
|
+
errors?: string[];
|
|
106
104
|
} | null;
|
|
107
105
|
/** Get props to spread on dropzone element (handles drag & drop) */
|
|
108
106
|
getDropzoneProps: () => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ValidationError } from '@shipstatic/types';
|
|
1
2
|
import { Ship, formatFileSize as formatFileSize$1 } from '@shipstatic/ship';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -5,28 +6,24 @@ import { Ship, formatFileSize as formatFileSize$1 } from '@shipstatic/ship';
|
|
|
5
6
|
* Imports types from @shipstatic/types (single source of truth)
|
|
6
7
|
* and defines drop-specific types
|
|
7
8
|
*/
|
|
9
|
+
|
|
8
10
|
declare const FILE_STATUSES: {
|
|
9
|
-
readonly PENDING: "pending";
|
|
10
11
|
readonly PROCESSING: "processing";
|
|
11
|
-
readonly VALIDATION_FAILED: "validation_failed";
|
|
12
|
-
readonly PROCESSING_ERROR: "processing_error";
|
|
13
|
-
readonly EMPTY_FILE: "empty_file";
|
|
14
|
-
readonly READY: "ready";
|
|
15
12
|
readonly UPLOADING: "uploading";
|
|
16
13
|
readonly COMPLETE: "complete";
|
|
17
14
|
readonly ERROR: "error";
|
|
15
|
+
readonly PENDING: "pending";
|
|
16
|
+
readonly PROCESSING_ERROR: "processing_error";
|
|
17
|
+
readonly EMPTY_FILE: "empty_file";
|
|
18
|
+
readonly VALIDATION_FAILED: "validation_failed";
|
|
19
|
+
readonly READY: "ready";
|
|
18
20
|
};
|
|
19
21
|
type FileStatus = (typeof FILE_STATUSES)[keyof typeof FILE_STATUSES];
|
|
20
22
|
/**
|
|
21
23
|
* Client-side error structure
|
|
22
24
|
* Matches ValidationError from @shipstatic/ship for consistency
|
|
23
25
|
*/
|
|
24
|
-
|
|
25
|
-
error: string;
|
|
26
|
-
details: string;
|
|
27
|
-
errors?: string[];
|
|
28
|
-
isClientError: true;
|
|
29
|
-
}
|
|
26
|
+
type ClientError = ValidationError;
|
|
30
27
|
/**
|
|
31
28
|
* Processed file entry ready for upload
|
|
32
29
|
* Contains both the File object and UI-specific metadata
|
|
@@ -103,6 +100,7 @@ interface DropReturn {
|
|
|
103
100
|
status: {
|
|
104
101
|
title: string;
|
|
105
102
|
details: string;
|
|
103
|
+
errors?: string[];
|
|
106
104
|
} | null;
|
|
107
105
|
/** Get props to spread on dropzone element (handles drag & drop) */
|
|
108
106
|
getDropzoneProps: () => {
|
package/dist/index.js
CHANGED
|
@@ -11700,6 +11700,42 @@ var require_mime_db = __commonJS({
|
|
|
11700
11700
|
}
|
|
11701
11701
|
});
|
|
11702
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
|
+
|
|
11703
11739
|
// src/utils/zipExtractor.ts
|
|
11704
11740
|
var import_jszip = __toESM(require_jszip_min());
|
|
11705
11741
|
|
|
@@ -11775,21 +11811,6 @@ function normalizePath(path) {
|
|
|
11775
11811
|
function isZipFile(file) {
|
|
11776
11812
|
return file.type === "application/zip" || file.type === "application/x-zip-compressed" || file.name.toLowerCase().endsWith(".zip");
|
|
11777
11813
|
}
|
|
11778
|
-
|
|
11779
|
-
// src/types.ts
|
|
11780
|
-
var FILE_STATUSES = {
|
|
11781
|
-
PENDING: "pending",
|
|
11782
|
-
PROCESSING: "processing",
|
|
11783
|
-
VALIDATION_FAILED: "validation_failed",
|
|
11784
|
-
PROCESSING_ERROR: "processing_error",
|
|
11785
|
-
EMPTY_FILE: "empty_file",
|
|
11786
|
-
READY: "ready",
|
|
11787
|
-
UPLOADING: "uploading",
|
|
11788
|
-
COMPLETE: "complete",
|
|
11789
|
-
ERROR: "error"
|
|
11790
|
-
};
|
|
11791
|
-
|
|
11792
|
-
// src/utils/fileProcessing.ts
|
|
11793
11814
|
var formatFileSize = formatFileSize$1;
|
|
11794
11815
|
async function createProcessedFile(file, options) {
|
|
11795
11816
|
const webkitPath = file.webkitRelativePath || "";
|
|
@@ -11978,6 +11999,7 @@ function useDrop(options) {
|
|
|
11978
11999
|
const noValidError = {
|
|
11979
12000
|
error: "No Valid Files",
|
|
11980
12001
|
details: "None of the provided files could be processed.",
|
|
12002
|
+
errors: [],
|
|
11981
12003
|
isClientError: true
|
|
11982
12004
|
};
|
|
11983
12005
|
setState({
|
|
@@ -11992,6 +12014,7 @@ function useDrop(options) {
|
|
|
11992
12014
|
const processingError = {
|
|
11993
12015
|
error: "Processing Failed",
|
|
11994
12016
|
details: `Failed to process files: ${error instanceof Error ? error.message : String(error)}`,
|
|
12017
|
+
errors: [],
|
|
11995
12018
|
isClientError: true
|
|
11996
12019
|
};
|
|
11997
12020
|
setState((prev) => ({
|
|
@@ -12029,7 +12052,17 @@ function useDrop(options) {
|
|
|
12029
12052
|
e.preventDefault();
|
|
12030
12053
|
setState((prev) => {
|
|
12031
12054
|
if (prev.value !== "dragging") return prev;
|
|
12032
|
-
|
|
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";
|
|
12033
12066
|
return { ...prev, value: nextValue };
|
|
12034
12067
|
});
|
|
12035
12068
|
}, []);
|