@shipstatic/drop 0.2.0 → 0.2.2
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 +64 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -167
- package/dist/index.d.ts +5 -167
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +149 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +100 -0
- package/dist/testing.d.ts +100 -0
- package/dist/testing.js +140 -0
- package/dist/testing.js.map +1 -0
- package/dist/useDrop-CRUVkVzW.d.cts +168 -0
- package/dist/useDrop-CRUVkVzW.d.ts +168 -0
- package/package.json +14 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,169 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Core types for @shipstatic/drop
|
|
6
|
-
* Imports types from @shipstatic/types (single source of truth)
|
|
7
|
-
* and defines drop-specific types
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Extended File interface with webkitRelativePath
|
|
12
|
-
* This property is set by browsers for folder uploads and drag-drop
|
|
13
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/File/webkitRelativePath
|
|
14
|
-
*/
|
|
15
|
-
interface FileWithPath extends File {
|
|
16
|
-
readonly webkitRelativePath: string;
|
|
17
|
-
}
|
|
18
|
-
declare const FILE_STATUSES: {
|
|
19
|
-
readonly PROCESSING: "processing";
|
|
20
|
-
readonly UPLOADING: "uploading";
|
|
21
|
-
readonly COMPLETE: "complete";
|
|
22
|
-
readonly ERROR: "error";
|
|
23
|
-
readonly PENDING: "pending";
|
|
24
|
-
readonly PROCESSING_ERROR: "processing_error";
|
|
25
|
-
readonly EMPTY_FILE: "empty_file";
|
|
26
|
-
readonly VALIDATION_FAILED: "validation_failed";
|
|
27
|
-
readonly READY: "ready";
|
|
28
|
-
};
|
|
29
|
-
type FileStatus = (typeof FILE_STATUSES)[keyof typeof FILE_STATUSES];
|
|
30
|
-
/**
|
|
31
|
-
* Client-side error structure
|
|
32
|
-
* Matches ValidationError from @shipstatic/ship for consistency
|
|
33
|
-
*/
|
|
34
|
-
type ClientError = ValidationError;
|
|
35
|
-
/**
|
|
36
|
-
* Processed file entry ready for upload
|
|
37
|
-
* Contains both the File object and UI-specific metadata
|
|
38
|
-
* Use `file` property to access the underlying File for SDK operations
|
|
39
|
-
*/
|
|
40
|
-
interface ProcessedFile {
|
|
41
|
-
/** Unique identifier for React keys and tracking */
|
|
42
|
-
id: string;
|
|
43
|
-
/** The File object - pass this to ship.deployments.create() */
|
|
44
|
-
file: File;
|
|
45
|
-
/** Relative path for deployment (e.g., "images/photo.jpg") */
|
|
46
|
-
path: string;
|
|
47
|
-
/** File size in bytes */
|
|
48
|
-
size: number;
|
|
49
|
-
/** MD5 hash (optional - Ship SDK calculates during deployment if not provided) */
|
|
50
|
-
md5?: string;
|
|
51
|
-
/** Filename without path */
|
|
52
|
-
name: string;
|
|
53
|
-
/** MIME type for UI icons/previews */
|
|
54
|
-
type: string;
|
|
55
|
-
/** Last modified timestamp */
|
|
56
|
-
lastModified: number;
|
|
57
|
-
/** Current processing/upload status */
|
|
58
|
-
status: FileStatus;
|
|
59
|
-
/** Human-readable status message for UI */
|
|
60
|
-
statusMessage?: string;
|
|
61
|
-
/** Upload progress (0-100) - only set during upload */
|
|
62
|
-
progress?: number;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* State machine values for the drop hook
|
|
66
|
-
*/
|
|
67
|
-
type DropStateValue = 'idle' | 'dragging' | 'processing' | 'ready' | 'error';
|
|
68
|
-
/**
|
|
69
|
-
* Status information with title and details
|
|
70
|
-
*/
|
|
71
|
-
interface DropStatus {
|
|
72
|
-
title: string;
|
|
73
|
-
details: string;
|
|
74
|
-
errors?: string[];
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* State machine state for the drop hook
|
|
78
|
-
*/
|
|
79
|
-
interface DropState {
|
|
80
|
-
value: DropStateValue;
|
|
81
|
-
files: ProcessedFile[];
|
|
82
|
-
sourceName: string;
|
|
83
|
-
status: DropStatus | null;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
interface DropOptions {
|
|
87
|
-
/** Ship SDK instance (required for validation) */
|
|
88
|
-
ship: Ship;
|
|
89
|
-
/** Callback when files are processed and ready */
|
|
90
|
-
onFilesReady?: (files: ProcessedFile[]) => void;
|
|
91
|
-
/** Callback when validation fails */
|
|
92
|
-
onValidationError?: (error: ClientError) => void;
|
|
93
|
-
/** Whether to strip common directory prefix from paths (default: true) */
|
|
94
|
-
stripPrefix?: boolean;
|
|
95
|
-
}
|
|
96
|
-
/** Options for getDropzoneProps() */
|
|
97
|
-
interface DropzonePropsOptions {
|
|
98
|
-
/** Whether clicking the dropzone opens the file picker (default: true) */
|
|
99
|
-
clickable?: boolean;
|
|
100
|
-
}
|
|
101
|
-
interface DropReturn {
|
|
102
|
-
/** Current phase of the state machine */
|
|
103
|
-
phase: DropStateValue;
|
|
104
|
-
/** Whether currently processing files (ZIP extraction, etc.) */
|
|
105
|
-
isProcessing: boolean;
|
|
106
|
-
/** Whether user is currently dragging over the dropzone */
|
|
107
|
-
isDragging: boolean;
|
|
108
|
-
/** Whether the dropzone is interactive (idle, dragging, or ready - not processing or error) */
|
|
109
|
-
isInteractive: boolean;
|
|
110
|
-
/** Whether an error occurred during processing */
|
|
111
|
-
hasError: boolean;
|
|
112
|
-
/** Flattened access to files */
|
|
113
|
-
files: ProcessedFile[];
|
|
114
|
-
/** Flattened access to source name */
|
|
115
|
-
sourceName: string;
|
|
116
|
-
/** Flattened access to status */
|
|
117
|
-
status: {
|
|
118
|
-
title: string;
|
|
119
|
-
details: string;
|
|
120
|
-
errors?: string[];
|
|
121
|
-
} | null;
|
|
122
|
-
/** Get props to spread on dropzone element (handles drag & drop, optionally click) */
|
|
123
|
-
getDropzoneProps: (options?: DropzonePropsOptions) => {
|
|
124
|
-
onDragOver: (e: React.DragEvent) => void;
|
|
125
|
-
onDragLeave: (e: React.DragEvent) => void;
|
|
126
|
-
onDrop: (e: React.DragEvent) => void;
|
|
127
|
-
onClick?: () => void;
|
|
128
|
-
};
|
|
129
|
-
/** Get props to spread on hidden file input element */
|
|
130
|
-
getInputProps: () => {
|
|
131
|
-
ref: React.RefObject<HTMLInputElement | null>;
|
|
132
|
-
type: 'file';
|
|
133
|
-
style: {
|
|
134
|
-
display: string;
|
|
135
|
-
};
|
|
136
|
-
multiple: boolean;
|
|
137
|
-
webkitdirectory: string;
|
|
138
|
-
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
139
|
-
};
|
|
140
|
-
/** Programmatically trigger file picker */
|
|
141
|
-
open: () => void;
|
|
142
|
-
/** Manually process files (for advanced usage) */
|
|
143
|
-
processFiles: (files: File[]) => Promise<void>;
|
|
144
|
-
/** Reset state and clear all files */
|
|
145
|
-
reset: () => void;
|
|
146
|
-
/** Get only valid files ready for upload */
|
|
147
|
-
validFiles: ProcessedFile[];
|
|
148
|
-
/** Get raw File objects ready for Ship SDK upload */
|
|
149
|
-
getFilesForUpload: () => File[];
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Headless drop hook for file upload workflows
|
|
153
|
-
*
|
|
154
|
-
* @example
|
|
155
|
-
* ```tsx
|
|
156
|
-
* const drop = useDrop({ ship });
|
|
157
|
-
*
|
|
158
|
-
* return (
|
|
159
|
-
* <div {...drop.getDropzoneProps()} style={{...}}>
|
|
160
|
-
* <input {...drop.getInputProps()} />
|
|
161
|
-
* {drop.isDragging ? "📂 Drop" : "📁 Click"}
|
|
162
|
-
* </div>
|
|
163
|
-
* );
|
|
164
|
-
* ```
|
|
165
|
-
*/
|
|
166
|
-
declare function useDrop(options: DropOptions): DropReturn;
|
|
1
|
+
import { P as ProcessedFile } from './useDrop-CRUVkVzW.cjs';
|
|
2
|
+
export { C as ClientError, D as DropOptions, a as DropReturn, b as DropState, c as DropStateValue, d as DropStatus, e as DropzonePropsOptions, F as FILE_STATUSES, f as FileStatus, g as FileWithPath, u as useDrop } from './useDrop-CRUVkVzW.cjs';
|
|
3
|
+
import { formatFileSize as formatFileSize$1 } from '@shipstatic/ship';
|
|
4
|
+
import '@shipstatic/types';
|
|
167
5
|
|
|
168
6
|
/**
|
|
169
7
|
* Unified file processing utilities
|
|
@@ -232,4 +70,4 @@ declare function isZipFile(file: File): boolean;
|
|
|
232
70
|
*/
|
|
233
71
|
declare function getMimeType(path: string): string;
|
|
234
72
|
|
|
235
|
-
export {
|
|
73
|
+
export { ProcessedFile, type ZipExtractionResult, createProcessedFile, extractZipToFiles, formatFileSize, getMimeType, isZipFile, normalizePath, stripCommonPrefix, traverseFileTree };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,169 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Core types for @shipstatic/drop
|
|
6
|
-
* Imports types from @shipstatic/types (single source of truth)
|
|
7
|
-
* and defines drop-specific types
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Extended File interface with webkitRelativePath
|
|
12
|
-
* This property is set by browsers for folder uploads and drag-drop
|
|
13
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/File/webkitRelativePath
|
|
14
|
-
*/
|
|
15
|
-
interface FileWithPath extends File {
|
|
16
|
-
readonly webkitRelativePath: string;
|
|
17
|
-
}
|
|
18
|
-
declare const FILE_STATUSES: {
|
|
19
|
-
readonly PROCESSING: "processing";
|
|
20
|
-
readonly UPLOADING: "uploading";
|
|
21
|
-
readonly COMPLETE: "complete";
|
|
22
|
-
readonly ERROR: "error";
|
|
23
|
-
readonly PENDING: "pending";
|
|
24
|
-
readonly PROCESSING_ERROR: "processing_error";
|
|
25
|
-
readonly EMPTY_FILE: "empty_file";
|
|
26
|
-
readonly VALIDATION_FAILED: "validation_failed";
|
|
27
|
-
readonly READY: "ready";
|
|
28
|
-
};
|
|
29
|
-
type FileStatus = (typeof FILE_STATUSES)[keyof typeof FILE_STATUSES];
|
|
30
|
-
/**
|
|
31
|
-
* Client-side error structure
|
|
32
|
-
* Matches ValidationError from @shipstatic/ship for consistency
|
|
33
|
-
*/
|
|
34
|
-
type ClientError = ValidationError;
|
|
35
|
-
/**
|
|
36
|
-
* Processed file entry ready for upload
|
|
37
|
-
* Contains both the File object and UI-specific metadata
|
|
38
|
-
* Use `file` property to access the underlying File for SDK operations
|
|
39
|
-
*/
|
|
40
|
-
interface ProcessedFile {
|
|
41
|
-
/** Unique identifier for React keys and tracking */
|
|
42
|
-
id: string;
|
|
43
|
-
/** The File object - pass this to ship.deployments.create() */
|
|
44
|
-
file: File;
|
|
45
|
-
/** Relative path for deployment (e.g., "images/photo.jpg") */
|
|
46
|
-
path: string;
|
|
47
|
-
/** File size in bytes */
|
|
48
|
-
size: number;
|
|
49
|
-
/** MD5 hash (optional - Ship SDK calculates during deployment if not provided) */
|
|
50
|
-
md5?: string;
|
|
51
|
-
/** Filename without path */
|
|
52
|
-
name: string;
|
|
53
|
-
/** MIME type for UI icons/previews */
|
|
54
|
-
type: string;
|
|
55
|
-
/** Last modified timestamp */
|
|
56
|
-
lastModified: number;
|
|
57
|
-
/** Current processing/upload status */
|
|
58
|
-
status: FileStatus;
|
|
59
|
-
/** Human-readable status message for UI */
|
|
60
|
-
statusMessage?: string;
|
|
61
|
-
/** Upload progress (0-100) - only set during upload */
|
|
62
|
-
progress?: number;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* State machine values for the drop hook
|
|
66
|
-
*/
|
|
67
|
-
type DropStateValue = 'idle' | 'dragging' | 'processing' | 'ready' | 'error';
|
|
68
|
-
/**
|
|
69
|
-
* Status information with title and details
|
|
70
|
-
*/
|
|
71
|
-
interface DropStatus {
|
|
72
|
-
title: string;
|
|
73
|
-
details: string;
|
|
74
|
-
errors?: string[];
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* State machine state for the drop hook
|
|
78
|
-
*/
|
|
79
|
-
interface DropState {
|
|
80
|
-
value: DropStateValue;
|
|
81
|
-
files: ProcessedFile[];
|
|
82
|
-
sourceName: string;
|
|
83
|
-
status: DropStatus | null;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
interface DropOptions {
|
|
87
|
-
/** Ship SDK instance (required for validation) */
|
|
88
|
-
ship: Ship;
|
|
89
|
-
/** Callback when files are processed and ready */
|
|
90
|
-
onFilesReady?: (files: ProcessedFile[]) => void;
|
|
91
|
-
/** Callback when validation fails */
|
|
92
|
-
onValidationError?: (error: ClientError) => void;
|
|
93
|
-
/** Whether to strip common directory prefix from paths (default: true) */
|
|
94
|
-
stripPrefix?: boolean;
|
|
95
|
-
}
|
|
96
|
-
/** Options for getDropzoneProps() */
|
|
97
|
-
interface DropzonePropsOptions {
|
|
98
|
-
/** Whether clicking the dropzone opens the file picker (default: true) */
|
|
99
|
-
clickable?: boolean;
|
|
100
|
-
}
|
|
101
|
-
interface DropReturn {
|
|
102
|
-
/** Current phase of the state machine */
|
|
103
|
-
phase: DropStateValue;
|
|
104
|
-
/** Whether currently processing files (ZIP extraction, etc.) */
|
|
105
|
-
isProcessing: boolean;
|
|
106
|
-
/** Whether user is currently dragging over the dropzone */
|
|
107
|
-
isDragging: boolean;
|
|
108
|
-
/** Whether the dropzone is interactive (idle, dragging, or ready - not processing or error) */
|
|
109
|
-
isInteractive: boolean;
|
|
110
|
-
/** Whether an error occurred during processing */
|
|
111
|
-
hasError: boolean;
|
|
112
|
-
/** Flattened access to files */
|
|
113
|
-
files: ProcessedFile[];
|
|
114
|
-
/** Flattened access to source name */
|
|
115
|
-
sourceName: string;
|
|
116
|
-
/** Flattened access to status */
|
|
117
|
-
status: {
|
|
118
|
-
title: string;
|
|
119
|
-
details: string;
|
|
120
|
-
errors?: string[];
|
|
121
|
-
} | null;
|
|
122
|
-
/** Get props to spread on dropzone element (handles drag & drop, optionally click) */
|
|
123
|
-
getDropzoneProps: (options?: DropzonePropsOptions) => {
|
|
124
|
-
onDragOver: (e: React.DragEvent) => void;
|
|
125
|
-
onDragLeave: (e: React.DragEvent) => void;
|
|
126
|
-
onDrop: (e: React.DragEvent) => void;
|
|
127
|
-
onClick?: () => void;
|
|
128
|
-
};
|
|
129
|
-
/** Get props to spread on hidden file input element */
|
|
130
|
-
getInputProps: () => {
|
|
131
|
-
ref: React.RefObject<HTMLInputElement | null>;
|
|
132
|
-
type: 'file';
|
|
133
|
-
style: {
|
|
134
|
-
display: string;
|
|
135
|
-
};
|
|
136
|
-
multiple: boolean;
|
|
137
|
-
webkitdirectory: string;
|
|
138
|
-
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
139
|
-
};
|
|
140
|
-
/** Programmatically trigger file picker */
|
|
141
|
-
open: () => void;
|
|
142
|
-
/** Manually process files (for advanced usage) */
|
|
143
|
-
processFiles: (files: File[]) => Promise<void>;
|
|
144
|
-
/** Reset state and clear all files */
|
|
145
|
-
reset: () => void;
|
|
146
|
-
/** Get only valid files ready for upload */
|
|
147
|
-
validFiles: ProcessedFile[];
|
|
148
|
-
/** Get raw File objects ready for Ship SDK upload */
|
|
149
|
-
getFilesForUpload: () => File[];
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Headless drop hook for file upload workflows
|
|
153
|
-
*
|
|
154
|
-
* @example
|
|
155
|
-
* ```tsx
|
|
156
|
-
* const drop = useDrop({ ship });
|
|
157
|
-
*
|
|
158
|
-
* return (
|
|
159
|
-
* <div {...drop.getDropzoneProps()} style={{...}}>
|
|
160
|
-
* <input {...drop.getInputProps()} />
|
|
161
|
-
* {drop.isDragging ? "📂 Drop" : "📁 Click"}
|
|
162
|
-
* </div>
|
|
163
|
-
* );
|
|
164
|
-
* ```
|
|
165
|
-
*/
|
|
166
|
-
declare function useDrop(options: DropOptions): DropReturn;
|
|
1
|
+
import { P as ProcessedFile } from './useDrop-CRUVkVzW.js';
|
|
2
|
+
export { C as ClientError, D as DropOptions, a as DropReturn, b as DropState, c as DropStateValue, d as DropStatus, e as DropzonePropsOptions, F as FILE_STATUSES, f as FileStatus, g as FileWithPath, u as useDrop } from './useDrop-CRUVkVzW.js';
|
|
3
|
+
import { formatFileSize as formatFileSize$1 } from '@shipstatic/ship';
|
|
4
|
+
import '@shipstatic/types';
|
|
167
5
|
|
|
168
6
|
/**
|
|
169
7
|
* Unified file processing utilities
|
|
@@ -232,4 +70,4 @@ declare function isZipFile(file: File): boolean;
|
|
|
232
70
|
*/
|
|
233
71
|
declare function getMimeType(path: string): string;
|
|
234
72
|
|
|
235
|
-
export {
|
|
73
|
+
export { ProcessedFile, type ZipExtractionResult, createProcessedFile, extractZipToFiles, formatFileSize, getMimeType, isZipFile, normalizePath, stripCommonPrefix, traverseFileTree };
|
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.4.
|
|
11703
|
+
// node_modules/.pnpm/@shipstatic+types@0.4.12/node_modules/@shipstatic/types/dist/index.js
|
|
11704
11704
|
var ErrorType;
|
|
11705
11705
|
(function(ErrorType2) {
|
|
11706
11706
|
ErrorType2["Validation"] = "validation_failed";
|