@shipstatic/drop 0.1.9 → 0.1.11
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 +4 -5
- package/dist/index.cjs +34 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -9
- package/dist/index.d.ts +18 -9
- package/dist/index.js +34 -22
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { StaticFile } from '@shipstatic/types';
|
|
2
1
|
import { Ship, formatFileSize as formatFileSize$1 } from '@shipstatic/ship';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
|
-
* Core types for @shipstatic/
|
|
4
|
+
* Core types for @shipstatic/drop
|
|
6
5
|
* Imports types from @shipstatic/types (single source of truth)
|
|
7
|
-
* and defines
|
|
6
|
+
* and defines drop-specific types
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
declare const FILE_STATUSES: {
|
|
11
9
|
readonly PENDING: "pending";
|
|
12
10
|
readonly PROCESSING: "processing";
|
|
@@ -31,14 +29,20 @@ interface ClientError {
|
|
|
31
29
|
}
|
|
32
30
|
/**
|
|
33
31
|
* Processed file entry ready for upload
|
|
34
|
-
*
|
|
35
|
-
*
|
|
32
|
+
* Contains both the File object and UI-specific metadata
|
|
33
|
+
* Use `file` property to access the underlying File for SDK operations
|
|
36
34
|
*/
|
|
37
|
-
interface ProcessedFile
|
|
35
|
+
interface ProcessedFile {
|
|
38
36
|
/** Unique identifier for React keys and tracking */
|
|
39
37
|
id: string;
|
|
40
|
-
/**
|
|
38
|
+
/** The File object - pass this to ship.deployments.create() */
|
|
41
39
|
file: File;
|
|
40
|
+
/** Relative path for deployment (e.g., "images/photo.jpg") */
|
|
41
|
+
path: string;
|
|
42
|
+
/** File size in bytes */
|
|
43
|
+
size: number;
|
|
44
|
+
/** MD5 hash (optional - Ship SDK calculates during deployment if not provided) */
|
|
45
|
+
md5?: string;
|
|
42
46
|
/** Filename without path */
|
|
43
47
|
name: string;
|
|
44
48
|
/** MIME type for UI icons/previews */
|
|
@@ -212,4 +216,9 @@ declare function normalizePath(path: string): string;
|
|
|
212
216
|
*/
|
|
213
217
|
declare function isZipFile(file: File): boolean;
|
|
214
218
|
|
|
215
|
-
|
|
219
|
+
/**
|
|
220
|
+
* Get MIME type from file path (browser-compatible, no Node.js dependencies)
|
|
221
|
+
*/
|
|
222
|
+
declare function getMimeType(path: string): string;
|
|
223
|
+
|
|
224
|
+
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,12 +1,10 @@
|
|
|
1
|
-
import { StaticFile } from '@shipstatic/types';
|
|
2
1
|
import { Ship, formatFileSize as formatFileSize$1 } from '@shipstatic/ship';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
|
-
* Core types for @shipstatic/
|
|
4
|
+
* Core types for @shipstatic/drop
|
|
6
5
|
* Imports types from @shipstatic/types (single source of truth)
|
|
7
|
-
* and defines
|
|
6
|
+
* and defines drop-specific types
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
declare const FILE_STATUSES: {
|
|
11
9
|
readonly PENDING: "pending";
|
|
12
10
|
readonly PROCESSING: "processing";
|
|
@@ -31,14 +29,20 @@ interface ClientError {
|
|
|
31
29
|
}
|
|
32
30
|
/**
|
|
33
31
|
* Processed file entry ready for upload
|
|
34
|
-
*
|
|
35
|
-
*
|
|
32
|
+
* Contains both the File object and UI-specific metadata
|
|
33
|
+
* Use `file` property to access the underlying File for SDK operations
|
|
36
34
|
*/
|
|
37
|
-
interface ProcessedFile
|
|
35
|
+
interface ProcessedFile {
|
|
38
36
|
/** Unique identifier for React keys and tracking */
|
|
39
37
|
id: string;
|
|
40
|
-
/**
|
|
38
|
+
/** The File object - pass this to ship.deployments.create() */
|
|
41
39
|
file: File;
|
|
40
|
+
/** Relative path for deployment (e.g., "images/photo.jpg") */
|
|
41
|
+
path: string;
|
|
42
|
+
/** File size in bytes */
|
|
43
|
+
size: number;
|
|
44
|
+
/** MD5 hash (optional - Ship SDK calculates during deployment if not provided) */
|
|
45
|
+
md5?: string;
|
|
42
46
|
/** Filename without path */
|
|
43
47
|
name: string;
|
|
44
48
|
/** MIME type for UI icons/previews */
|
|
@@ -212,4 +216,9 @@ declare function normalizePath(path: string): string;
|
|
|
212
216
|
*/
|
|
213
217
|
declare function isZipFile(file: File): boolean;
|
|
214
218
|
|
|
215
|
-
|
|
219
|
+
/**
|
|
220
|
+
* Get MIME type from file path (browser-compatible, no Node.js dependencies)
|
|
221
|
+
*/
|
|
222
|
+
declare function getMimeType(path: string): string;
|
|
223
|
+
|
|
224
|
+
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
|
@@ -11796,15 +11796,12 @@ async function createProcessedFile(file, options) {
|
|
|
11796
11796
|
const path = options?.path || (webkitPath && webkitPath.trim() ? webkitPath : file.name);
|
|
11797
11797
|
const type = file.type || getMimeType(path);
|
|
11798
11798
|
return {
|
|
11799
|
-
//
|
|
11799
|
+
// ProcessedFile properties
|
|
11800
11800
|
// 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
11801
|
id: crypto.randomUUID(),
|
|
11806
11802
|
file,
|
|
11807
|
-
|
|
11803
|
+
path,
|
|
11804
|
+
size: file.size,
|
|
11808
11805
|
name: path.split("/").pop() || file.name,
|
|
11809
11806
|
type,
|
|
11810
11807
|
lastModified: file.lastModified,
|
|
@@ -11826,10 +11823,20 @@ function stripCommonPrefix(files) {
|
|
|
11826
11823
|
}
|
|
11827
11824
|
if (commonDepth === 0) return files;
|
|
11828
11825
|
const prefix = segments.slice(0, commonDepth).join("/") + "/";
|
|
11829
|
-
return files.map((f) =>
|
|
11830
|
-
|
|
11831
|
-
|
|
11832
|
-
|
|
11826
|
+
return files.map((f) => {
|
|
11827
|
+
const newPath = f.path.startsWith(prefix) ? f.path.slice(prefix.length) : f.path;
|
|
11828
|
+
if (f.file) {
|
|
11829
|
+
Object.defineProperty(f.file, "webkitRelativePath", {
|
|
11830
|
+
value: newPath,
|
|
11831
|
+
writable: false,
|
|
11832
|
+
configurable: true
|
|
11833
|
+
});
|
|
11834
|
+
}
|
|
11835
|
+
return {
|
|
11836
|
+
...f,
|
|
11837
|
+
path: newPath
|
|
11838
|
+
};
|
|
11839
|
+
});
|
|
11833
11840
|
}
|
|
11834
11841
|
async function traverseFileTree(entry, files, currentPath = "") {
|
|
11835
11842
|
try {
|
|
@@ -11840,7 +11847,8 @@ async function traverseFileTree(entry, files, currentPath = "") {
|
|
|
11840
11847
|
const relativePath = currentPath ? `${currentPath}/${file.name}` : file.name;
|
|
11841
11848
|
Object.defineProperty(file, "webkitRelativePath", {
|
|
11842
11849
|
value: relativePath,
|
|
11843
|
-
writable: false
|
|
11850
|
+
writable: false,
|
|
11851
|
+
configurable: true
|
|
11844
11852
|
});
|
|
11845
11853
|
files.push(file);
|
|
11846
11854
|
} else if (entry.isDirectory) {
|
|
@@ -12029,21 +12037,21 @@ function useDrop(options) {
|
|
|
12029
12037
|
e.preventDefault();
|
|
12030
12038
|
const items = Array.from(e.dataTransfer.items);
|
|
12031
12039
|
const files = [];
|
|
12032
|
-
|
|
12040
|
+
const entriesToTraverse = [];
|
|
12033
12041
|
for (const item of items) {
|
|
12034
12042
|
if (item.kind === "file") {
|
|
12035
12043
|
try {
|
|
12036
12044
|
const entry = item.webkitGetAsEntry?.();
|
|
12037
|
-
if (entry) {
|
|
12038
|
-
|
|
12039
|
-
await traverseFileTree(
|
|
12040
|
-
entry,
|
|
12041
|
-
files,
|
|
12042
|
-
entry.isDirectory ? entry.name : ""
|
|
12043
|
-
);
|
|
12045
|
+
if (entry && entry.isDirectory) {
|
|
12046
|
+
entriesToTraverse.push({ entry, path: entry.name });
|
|
12044
12047
|
} else {
|
|
12045
12048
|
const file = item.getAsFile();
|
|
12046
12049
|
if (file) {
|
|
12050
|
+
Object.defineProperty(file, "webkitRelativePath", {
|
|
12051
|
+
value: file.name,
|
|
12052
|
+
writable: false,
|
|
12053
|
+
configurable: true
|
|
12054
|
+
});
|
|
12047
12055
|
files.push(file);
|
|
12048
12056
|
}
|
|
12049
12057
|
}
|
|
@@ -12056,7 +12064,12 @@ function useDrop(options) {
|
|
|
12056
12064
|
}
|
|
12057
12065
|
}
|
|
12058
12066
|
}
|
|
12059
|
-
if (
|
|
12067
|
+
if (entriesToTraverse.length > 0) {
|
|
12068
|
+
await Promise.all(entriesToTraverse.map(
|
|
12069
|
+
(item) => traverseFileTree(item.entry, files, item.path)
|
|
12070
|
+
));
|
|
12071
|
+
}
|
|
12072
|
+
if (files.length === 0 && e.dataTransfer.files.length > 0) {
|
|
12060
12073
|
files.push(...Array.from(e.dataTransfer.files));
|
|
12061
12074
|
}
|
|
12062
12075
|
if (files.length > 0) {
|
|
@@ -12090,7 +12103,6 @@ function useDrop(options) {
|
|
|
12090
12103
|
}), [handleInputChange]);
|
|
12091
12104
|
return {
|
|
12092
12105
|
// State machine
|
|
12093
|
-
// state, // REMOVED
|
|
12094
12106
|
// Convenience getters (computed from state)
|
|
12095
12107
|
phase: state.value,
|
|
12096
12108
|
isProcessing,
|
|
@@ -12134,6 +12146,6 @@ mime-db/index.js:
|
|
|
12134
12146
|
*)
|
|
12135
12147
|
*/
|
|
12136
12148
|
|
|
12137
|
-
export { FILE_STATUSES, createProcessedFile, extractZipToFiles, formatFileSize, isZipFile, normalizePath, stripCommonPrefix, traverseFileTree, useDrop };
|
|
12149
|
+
export { FILE_STATUSES, createProcessedFile, extractZipToFiles, formatFileSize, getMimeType, isZipFile, normalizePath, stripCommonPrefix, traverseFileTree, useDrop };
|
|
12138
12150
|
//# sourceMappingURL=index.js.map
|
|
12139
12151
|
//# sourceMappingURL=index.js.map
|