@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/README.md
CHANGED
|
@@ -85,9 +85,8 @@ function MyUploader() {
|
|
|
85
85
|
});
|
|
86
86
|
|
|
87
87
|
const handleUpload = async () => {
|
|
88
|
-
const validFiles = drop.getValidFiles();
|
|
89
88
|
// ProcessedFile extends StaticFile - no conversion needed!
|
|
90
|
-
await ship.deployments.create(validFiles.map(f => f.file));
|
|
89
|
+
await ship.deployments.create(drop.validFiles.map(f => f.file));
|
|
91
90
|
};
|
|
92
91
|
|
|
93
92
|
return (
|
|
@@ -126,7 +125,7 @@ function MyUploader() {
|
|
|
126
125
|
onClick={handleUpload}
|
|
127
126
|
disabled={drop.phase !== 'ready'}
|
|
128
127
|
>
|
|
129
|
-
Upload {drop.
|
|
128
|
+
Upload {drop.validFiles.length} files
|
|
130
129
|
</button>
|
|
131
130
|
</div>
|
|
132
131
|
);
|
|
@@ -277,7 +276,7 @@ interface DropReturn {
|
|
|
277
276
|
|
|
278
277
|
// Helpers
|
|
279
278
|
/** Get only valid files ready for upload */
|
|
280
|
-
|
|
279
|
+
validFiles: ProcessedFile[];
|
|
281
280
|
/** Update upload state for a specific file (status, progress, message) */
|
|
282
281
|
updateFileStatus: (fileId: string, state: {
|
|
283
282
|
status: FileStatus;
|
|
@@ -628,7 +627,7 @@ All errors are surfaced at the per-file level:
|
|
|
628
627
|
- Processing errors (e.g., ZIP extraction failures) are marked with `status: 'processing_error'`
|
|
629
628
|
- Validation failures are marked with `status: 'validation_failed'`
|
|
630
629
|
- The `statusMessage` always contains specific error details
|
|
631
|
-
- Failed files are excluded from `
|
|
630
|
+
- Failed files are excluded from `validFiles` and cannot be deployed
|
|
632
631
|
- No silent failures - all errors are visible to users
|
|
633
632
|
|
|
634
633
|
See the [Error Handling](#error-handling) section for examples of displaying per-file errors in your UI.
|
package/dist/index.cjs
CHANGED
|
@@ -11798,15 +11798,12 @@ async function createProcessedFile(file, options) {
|
|
|
11798
11798
|
const path = options?.path || (webkitPath && webkitPath.trim() ? webkitPath : file.name);
|
|
11799
11799
|
const type = file.type || getMimeType(path);
|
|
11800
11800
|
return {
|
|
11801
|
-
//
|
|
11801
|
+
// ProcessedFile properties
|
|
11802
11802
|
// Note: md5 is intentionally undefined - Ship SDK will calculate it during deployment
|
|
11803
|
-
content: file,
|
|
11804
|
-
path,
|
|
11805
|
-
size: file.size,
|
|
11806
|
-
// ProcessedFile-specific properties (UI functionality)
|
|
11807
11803
|
id: crypto.randomUUID(),
|
|
11808
11804
|
file,
|
|
11809
|
-
|
|
11805
|
+
path,
|
|
11806
|
+
size: file.size,
|
|
11810
11807
|
name: path.split("/").pop() || file.name,
|
|
11811
11808
|
type,
|
|
11812
11809
|
lastModified: file.lastModified,
|
|
@@ -11828,10 +11825,20 @@ function stripCommonPrefix(files) {
|
|
|
11828
11825
|
}
|
|
11829
11826
|
if (commonDepth === 0) return files;
|
|
11830
11827
|
const prefix = segments.slice(0, commonDepth).join("/") + "/";
|
|
11831
|
-
return files.map((f) =>
|
|
11832
|
-
|
|
11833
|
-
|
|
11834
|
-
|
|
11828
|
+
return files.map((f) => {
|
|
11829
|
+
const newPath = f.path.startsWith(prefix) ? f.path.slice(prefix.length) : f.path;
|
|
11830
|
+
if (f.file) {
|
|
11831
|
+
Object.defineProperty(f.file, "webkitRelativePath", {
|
|
11832
|
+
value: newPath,
|
|
11833
|
+
writable: false,
|
|
11834
|
+
configurable: true
|
|
11835
|
+
});
|
|
11836
|
+
}
|
|
11837
|
+
return {
|
|
11838
|
+
...f,
|
|
11839
|
+
path: newPath
|
|
11840
|
+
};
|
|
11841
|
+
});
|
|
11835
11842
|
}
|
|
11836
11843
|
async function traverseFileTree(entry, files, currentPath = "") {
|
|
11837
11844
|
try {
|
|
@@ -11842,7 +11849,8 @@ async function traverseFileTree(entry, files, currentPath = "") {
|
|
|
11842
11849
|
const relativePath = currentPath ? `${currentPath}/${file.name}` : file.name;
|
|
11843
11850
|
Object.defineProperty(file, "webkitRelativePath", {
|
|
11844
11851
|
value: relativePath,
|
|
11845
|
-
writable: false
|
|
11852
|
+
writable: false,
|
|
11853
|
+
configurable: true
|
|
11846
11854
|
});
|
|
11847
11855
|
files.push(file);
|
|
11848
11856
|
} else if (entry.isDirectory) {
|
|
@@ -12031,21 +12039,21 @@ function useDrop(options) {
|
|
|
12031
12039
|
e.preventDefault();
|
|
12032
12040
|
const items = Array.from(e.dataTransfer.items);
|
|
12033
12041
|
const files = [];
|
|
12034
|
-
|
|
12042
|
+
const entriesToTraverse = [];
|
|
12035
12043
|
for (const item of items) {
|
|
12036
12044
|
if (item.kind === "file") {
|
|
12037
12045
|
try {
|
|
12038
12046
|
const entry = item.webkitGetAsEntry?.();
|
|
12039
|
-
if (entry) {
|
|
12040
|
-
|
|
12041
|
-
await traverseFileTree(
|
|
12042
|
-
entry,
|
|
12043
|
-
files,
|
|
12044
|
-
entry.isDirectory ? entry.name : ""
|
|
12045
|
-
);
|
|
12047
|
+
if (entry && entry.isDirectory) {
|
|
12048
|
+
entriesToTraverse.push({ entry, path: entry.name });
|
|
12046
12049
|
} else {
|
|
12047
12050
|
const file = item.getAsFile();
|
|
12048
12051
|
if (file) {
|
|
12052
|
+
Object.defineProperty(file, "webkitRelativePath", {
|
|
12053
|
+
value: file.name,
|
|
12054
|
+
writable: false,
|
|
12055
|
+
configurable: true
|
|
12056
|
+
});
|
|
12049
12057
|
files.push(file);
|
|
12050
12058
|
}
|
|
12051
12059
|
}
|
|
@@ -12058,7 +12066,12 @@ function useDrop(options) {
|
|
|
12058
12066
|
}
|
|
12059
12067
|
}
|
|
12060
12068
|
}
|
|
12061
|
-
if (
|
|
12069
|
+
if (entriesToTraverse.length > 0) {
|
|
12070
|
+
await Promise.all(entriesToTraverse.map(
|
|
12071
|
+
(item) => traverseFileTree(item.entry, files, item.path)
|
|
12072
|
+
));
|
|
12073
|
+
}
|
|
12074
|
+
if (files.length === 0 && e.dataTransfer.files.length > 0) {
|
|
12062
12075
|
files.push(...Array.from(e.dataTransfer.files));
|
|
12063
12076
|
}
|
|
12064
12077
|
if (files.length > 0) {
|
|
@@ -12092,7 +12105,6 @@ function useDrop(options) {
|
|
|
12092
12105
|
}), [handleInputChange]);
|
|
12093
12106
|
return {
|
|
12094
12107
|
// State machine
|
|
12095
|
-
// state, // REMOVED
|
|
12096
12108
|
// Convenience getters (computed from state)
|
|
12097
12109
|
phase: state.value,
|
|
12098
12110
|
isProcessing,
|
|
@@ -12140,6 +12152,7 @@ exports.FILE_STATUSES = FILE_STATUSES;
|
|
|
12140
12152
|
exports.createProcessedFile = createProcessedFile;
|
|
12141
12153
|
exports.extractZipToFiles = extractZipToFiles;
|
|
12142
12154
|
exports.formatFileSize = formatFileSize;
|
|
12155
|
+
exports.getMimeType = getMimeType;
|
|
12143
12156
|
exports.isZipFile = isZipFile;
|
|
12144
12157
|
exports.normalizePath = normalizePath;
|
|
12145
12158
|
exports.stripCommonPrefix = stripCommonPrefix;
|