@shipstatic/drop 0.1.10 → 0.1.12
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 +1 -0
- package/dist/index.cjs +8 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -19
- package/dist/index.d.ts +26 -19
- package/dist/index.js +8 -14
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.cts
CHANGED
|
@@ -1,44 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ValidationError } from '@shipstatic/types';
|
|
2
2
|
import { Ship, formatFileSize as formatFileSize$1 } from '@shipstatic/ship';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Core types for @shipstatic/
|
|
5
|
+
* Core types for @shipstatic/drop
|
|
6
6
|
* Imports types from @shipstatic/types (single source of truth)
|
|
7
|
-
* and defines
|
|
7
|
+
* and defines drop-specific types
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
declare const FILE_STATUSES: {
|
|
11
|
-
readonly PENDING: "pending";
|
|
12
11
|
readonly PROCESSING: "processing";
|
|
13
|
-
readonly VALIDATION_FAILED: "validation_failed";
|
|
14
|
-
readonly PROCESSING_ERROR: "processing_error";
|
|
15
|
-
readonly EMPTY_FILE: "empty_file";
|
|
16
|
-
readonly READY: "ready";
|
|
17
12
|
readonly UPLOADING: "uploading";
|
|
18
13
|
readonly COMPLETE: "complete";
|
|
19
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";
|
|
20
20
|
};
|
|
21
21
|
type FileStatus = (typeof FILE_STATUSES)[keyof typeof FILE_STATUSES];
|
|
22
22
|
/**
|
|
23
23
|
* Client-side error structure
|
|
24
24
|
* Matches ValidationError from @shipstatic/ship for consistency
|
|
25
25
|
*/
|
|
26
|
-
|
|
27
|
-
error: string;
|
|
28
|
-
details: string;
|
|
29
|
-
errors?: string[];
|
|
30
|
-
isClientError: true;
|
|
31
|
-
}
|
|
26
|
+
type ClientError = ValidationError;
|
|
32
27
|
/**
|
|
33
28
|
* Processed file entry ready for upload
|
|
34
|
-
*
|
|
35
|
-
*
|
|
29
|
+
* Contains both the File object and UI-specific metadata
|
|
30
|
+
* Use `file` property to access the underlying File for SDK operations
|
|
36
31
|
*/
|
|
37
|
-
interface ProcessedFile
|
|
32
|
+
interface ProcessedFile {
|
|
38
33
|
/** Unique identifier for React keys and tracking */
|
|
39
34
|
id: string;
|
|
40
|
-
/**
|
|
35
|
+
/** The File object - pass this to ship.deployments.create() */
|
|
41
36
|
file: File;
|
|
37
|
+
/** Relative path for deployment (e.g., "images/photo.jpg") */
|
|
38
|
+
path: string;
|
|
39
|
+
/** File size in bytes */
|
|
40
|
+
size: number;
|
|
41
|
+
/** MD5 hash (optional - Ship SDK calculates during deployment if not provided) */
|
|
42
|
+
md5?: string;
|
|
42
43
|
/** Filename without path */
|
|
43
44
|
name: string;
|
|
44
45
|
/** MIME type for UI icons/previews */
|
|
@@ -99,6 +100,7 @@ interface DropReturn {
|
|
|
99
100
|
status: {
|
|
100
101
|
title: string;
|
|
101
102
|
details: string;
|
|
103
|
+
errors?: string[];
|
|
102
104
|
} | null;
|
|
103
105
|
/** Get props to spread on dropzone element (handles drag & drop) */
|
|
104
106
|
getDropzoneProps: () => {
|
|
@@ -212,4 +214,9 @@ declare function normalizePath(path: string): string;
|
|
|
212
214
|
*/
|
|
213
215
|
declare function isZipFile(file: File): boolean;
|
|
214
216
|
|
|
215
|
-
|
|
217
|
+
/**
|
|
218
|
+
* Get MIME type from file path (browser-compatible, no Node.js dependencies)
|
|
219
|
+
*/
|
|
220
|
+
declare function getMimeType(path: string): string;
|
|
221
|
+
|
|
222
|
+
export { type ClientError, type DropOptions, type DropReturn, type DropState, type DropStateValue, type DropStatus, FILE_STATUSES, type FileStatus, type ProcessedFile, type ZipExtractionResult, createProcessedFile, extractZipToFiles, formatFileSize, getMimeType, isZipFile, normalizePath, stripCommonPrefix, traverseFileTree, useDrop };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,44 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ValidationError } from '@shipstatic/types';
|
|
2
2
|
import { Ship, formatFileSize as formatFileSize$1 } from '@shipstatic/ship';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Core types for @shipstatic/
|
|
5
|
+
* Core types for @shipstatic/drop
|
|
6
6
|
* Imports types from @shipstatic/types (single source of truth)
|
|
7
|
-
* and defines
|
|
7
|
+
* and defines drop-specific types
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
declare const FILE_STATUSES: {
|
|
11
|
-
readonly PENDING: "pending";
|
|
12
11
|
readonly PROCESSING: "processing";
|
|
13
|
-
readonly VALIDATION_FAILED: "validation_failed";
|
|
14
|
-
readonly PROCESSING_ERROR: "processing_error";
|
|
15
|
-
readonly EMPTY_FILE: "empty_file";
|
|
16
|
-
readonly READY: "ready";
|
|
17
12
|
readonly UPLOADING: "uploading";
|
|
18
13
|
readonly COMPLETE: "complete";
|
|
19
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";
|
|
20
20
|
};
|
|
21
21
|
type FileStatus = (typeof FILE_STATUSES)[keyof typeof FILE_STATUSES];
|
|
22
22
|
/**
|
|
23
23
|
* Client-side error structure
|
|
24
24
|
* Matches ValidationError from @shipstatic/ship for consistency
|
|
25
25
|
*/
|
|
26
|
-
|
|
27
|
-
error: string;
|
|
28
|
-
details: string;
|
|
29
|
-
errors?: string[];
|
|
30
|
-
isClientError: true;
|
|
31
|
-
}
|
|
26
|
+
type ClientError = ValidationError;
|
|
32
27
|
/**
|
|
33
28
|
* Processed file entry ready for upload
|
|
34
|
-
*
|
|
35
|
-
*
|
|
29
|
+
* Contains both the File object and UI-specific metadata
|
|
30
|
+
* Use `file` property to access the underlying File for SDK operations
|
|
36
31
|
*/
|
|
37
|
-
interface ProcessedFile
|
|
32
|
+
interface ProcessedFile {
|
|
38
33
|
/** Unique identifier for React keys and tracking */
|
|
39
34
|
id: string;
|
|
40
|
-
/**
|
|
35
|
+
/** The File object - pass this to ship.deployments.create() */
|
|
41
36
|
file: File;
|
|
37
|
+
/** Relative path for deployment (e.g., "images/photo.jpg") */
|
|
38
|
+
path: string;
|
|
39
|
+
/** File size in bytes */
|
|
40
|
+
size: number;
|
|
41
|
+
/** MD5 hash (optional - Ship SDK calculates during deployment if not provided) */
|
|
42
|
+
md5?: string;
|
|
42
43
|
/** Filename without path */
|
|
43
44
|
name: string;
|
|
44
45
|
/** MIME type for UI icons/previews */
|
|
@@ -99,6 +100,7 @@ interface DropReturn {
|
|
|
99
100
|
status: {
|
|
100
101
|
title: string;
|
|
101
102
|
details: string;
|
|
103
|
+
errors?: string[];
|
|
102
104
|
} | null;
|
|
103
105
|
/** Get props to spread on dropzone element (handles drag & drop) */
|
|
104
106
|
getDropzoneProps: () => {
|
|
@@ -212,4 +214,9 @@ declare function normalizePath(path: string): string;
|
|
|
212
214
|
*/
|
|
213
215
|
declare function isZipFile(file: File): boolean;
|
|
214
216
|
|
|
215
|
-
|
|
217
|
+
/**
|
|
218
|
+
* Get MIME type from file path (browser-compatible, no Node.js dependencies)
|
|
219
|
+
*/
|
|
220
|
+
declare function getMimeType(path: string): string;
|
|
221
|
+
|
|
222
|
+
export { type ClientError, type DropOptions, type DropReturn, type DropState, type DropStateValue, type DropStatus, FILE_STATUSES, type FileStatus, type ProcessedFile, type ZipExtractionResult, createProcessedFile, extractZipToFiles, formatFileSize, getMimeType, isZipFile, normalizePath, stripCommonPrefix, traverseFileTree, useDrop };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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';
|
|
3
4
|
|
|
4
5
|
var __create = Object.create;
|
|
5
6
|
var __defProp = Object.defineProperty;
|
|
@@ -11775,15 +11776,9 @@ function normalizePath(path) {
|
|
|
11775
11776
|
function isZipFile(file) {
|
|
11776
11777
|
return file.type === "application/zip" || file.type === "application/x-zip-compressed" || file.name.toLowerCase().endsWith(".zip");
|
|
11777
11778
|
}
|
|
11778
|
-
|
|
11779
|
-
// src/types.ts
|
|
11780
11779
|
var FILE_STATUSES = {
|
|
11781
|
-
|
|
11780
|
+
...FileValidationStatus,
|
|
11782
11781
|
PROCESSING: "processing",
|
|
11783
|
-
VALIDATION_FAILED: "validation_failed",
|
|
11784
|
-
PROCESSING_ERROR: "processing_error",
|
|
11785
|
-
EMPTY_FILE: "empty_file",
|
|
11786
|
-
READY: "ready",
|
|
11787
11782
|
UPLOADING: "uploading",
|
|
11788
11783
|
COMPLETE: "complete",
|
|
11789
11784
|
ERROR: "error"
|
|
@@ -11796,15 +11791,12 @@ async function createProcessedFile(file, options) {
|
|
|
11796
11791
|
const path = options?.path || (webkitPath && webkitPath.trim() ? webkitPath : file.name);
|
|
11797
11792
|
const type = file.type || getMimeType(path);
|
|
11798
11793
|
return {
|
|
11799
|
-
//
|
|
11794
|
+
// ProcessedFile properties
|
|
11800
11795
|
// Note: md5 is intentionally undefined - Ship SDK will calculate it during deployment
|
|
11801
|
-
content: file,
|
|
11802
|
-
path,
|
|
11803
|
-
size: file.size,
|
|
11804
|
-
// ProcessedFile-specific properties (UI functionality)
|
|
11805
11796
|
id: crypto.randomUUID(),
|
|
11806
11797
|
file,
|
|
11807
|
-
|
|
11798
|
+
path,
|
|
11799
|
+
size: file.size,
|
|
11808
11800
|
name: path.split("/").pop() || file.name,
|
|
11809
11801
|
type,
|
|
11810
11802
|
lastModified: file.lastModified,
|
|
@@ -11981,6 +11973,7 @@ function useDrop(options) {
|
|
|
11981
11973
|
const noValidError = {
|
|
11982
11974
|
error: "No Valid Files",
|
|
11983
11975
|
details: "None of the provided files could be processed.",
|
|
11976
|
+
errors: [],
|
|
11984
11977
|
isClientError: true
|
|
11985
11978
|
};
|
|
11986
11979
|
setState({
|
|
@@ -11995,6 +11988,7 @@ function useDrop(options) {
|
|
|
11995
11988
|
const processingError = {
|
|
11996
11989
|
error: "Processing Failed",
|
|
11997
11990
|
details: `Failed to process files: ${error instanceof Error ? error.message : String(error)}`,
|
|
11991
|
+
errors: [],
|
|
11998
11992
|
isClientError: true
|
|
11999
11993
|
};
|
|
12000
11994
|
setState((prev) => ({
|
|
@@ -12149,6 +12143,6 @@ mime-db/index.js:
|
|
|
12149
12143
|
*)
|
|
12150
12144
|
*/
|
|
12151
12145
|
|
|
12152
|
-
export { FILE_STATUSES, createProcessedFile, extractZipToFiles, formatFileSize, isZipFile, normalizePath, stripCommonPrefix, traverseFileTree, useDrop };
|
|
12146
|
+
export { FILE_STATUSES, createProcessedFile, extractZipToFiles, formatFileSize, getMimeType, isZipFile, normalizePath, stripCommonPrefix, traverseFileTree, useDrop };
|
|
12153
12147
|
//# sourceMappingURL=index.js.map
|
|
12154
12148
|
//# sourceMappingURL=index.js.map
|