@shipstatic/drop 2.16.0 → 2.16.1-beta.10
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 +15 -10
- package/dist/index.cjs +32 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -33
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +1 -1
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pluralize, validateFiles, optimizeDeployPaths, sitePaths
|
|
1
|
+
import { pluralize, validateFiles, unreadable, optimizeDeployPaths, sitePaths } from '@shipstatic/ship';
|
|
2
2
|
import ignore from 'ignore';
|
|
3
3
|
import { useState, useRef, useMemo, useCallback } from 'react';
|
|
4
4
|
|
|
@@ -115,7 +115,7 @@ function setRelativePath(file, path) {
|
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
function filePath(file) {
|
|
118
|
-
return file.webkitRelativePath
|
|
118
|
+
return file.webkitRelativePath || file.name;
|
|
119
119
|
}
|
|
120
120
|
function createProcessedFile(file, options) {
|
|
121
121
|
const path = options?.path || filePath(file);
|
|
@@ -143,7 +143,7 @@ function siteFiles(files) {
|
|
|
143
143
|
}
|
|
144
144
|
function stripCommonPrefix(files) {
|
|
145
145
|
const paths = optimizeDeployPaths(files.map((f) => f.path));
|
|
146
|
-
return files.map((file, i) => published(file, paths[i]
|
|
146
|
+
return files.map((file, i) => published(file, paths[i]));
|
|
147
147
|
}
|
|
148
148
|
function applyStatus(files, status, statusMessage) {
|
|
149
149
|
return files.map((f) => ({
|
|
@@ -815,34 +815,34 @@ function unzip(data, opts, cb) {
|
|
|
815
815
|
|
|
816
816
|
// src/zip.ts
|
|
817
817
|
async function extractZipToFiles(zipFile) {
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
818
|
+
const bytes = new Uint8Array(
|
|
819
|
+
await zipFile.arrayBuffer().catch(() => {
|
|
820
|
+
throw new Error(unreadable(zipFile.name));
|
|
821
|
+
})
|
|
822
|
+
);
|
|
823
|
+
const entries = await new Promise((resolve, reject) => {
|
|
824
|
+
unzip(
|
|
825
|
+
bytes,
|
|
826
|
+
(err2, data) => err2 ? reject(
|
|
827
|
+
new Error(`We couldn't open ${zipFile.name}. It may be damaged, or not a ZIP file.`)
|
|
828
|
+
) : resolve(data)
|
|
829
|
+
);
|
|
830
|
+
});
|
|
831
|
+
const files = [];
|
|
832
|
+
const errors = [];
|
|
833
|
+
for (const [path, data] of Object.entries(entries)) {
|
|
834
|
+
if (path.endsWith("/") && data.length === 0) continue;
|
|
835
|
+
const sanitizedPath = normalizePath(path);
|
|
836
|
+
if (!sanitizedPath) {
|
|
837
|
+
errors.push(`Skipped invalid path: ${path}`);
|
|
838
|
+
continue;
|
|
836
839
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
errors: [
|
|
842
|
-
`Failed to load ZIP file: ${error instanceof Error ? error.message : String(error)}`
|
|
843
|
-
]
|
|
844
|
-
};
|
|
840
|
+
const filename = sanitizedPath.split("/").pop() || sanitizedPath;
|
|
841
|
+
const file = new File([new Uint8Array(data)], filename);
|
|
842
|
+
setRelativePath(file, sanitizedPath);
|
|
843
|
+
files.push(file);
|
|
845
844
|
}
|
|
845
|
+
return { files, errors };
|
|
846
846
|
}
|
|
847
847
|
function normalizePath(path) {
|
|
848
848
|
const normalized = [];
|
|
@@ -1101,7 +1101,7 @@ function useDrop({ ship }) {
|
|
|
1101
1101
|
setState((prev) => prev.isDragging ? { ...prev, isDragging: false } : prev);
|
|
1102
1102
|
const files = [];
|
|
1103
1103
|
const directories = [];
|
|
1104
|
-
let
|
|
1104
|
+
let unreadable3 = false;
|
|
1105
1105
|
for (const item of Array.from(e.dataTransfer.items)) {
|
|
1106
1106
|
if (item.kind !== "file") continue;
|
|
1107
1107
|
let entry;
|
|
@@ -1118,12 +1118,12 @@ function useDrop({ ship }) {
|
|
|
1118
1118
|
setRelativePath(file, file.name);
|
|
1119
1119
|
files.push(file);
|
|
1120
1120
|
} else {
|
|
1121
|
-
|
|
1121
|
+
unreadable3 = true;
|
|
1122
1122
|
}
|
|
1123
1123
|
}
|
|
1124
|
-
if (directories.length === 0 && files.length === 0 && !
|
|
1124
|
+
if (directories.length === 0 && files.length === 0 && !unreadable3) return;
|
|
1125
1125
|
await prepare(async () => {
|
|
1126
|
-
if (
|
|
1126
|
+
if (unreadable3) throw new Error(UNREADABLE_DROP);
|
|
1127
1127
|
await Promise.all(directories.map((d) => traverseFileTree(d.entry, files, d.path)));
|
|
1128
1128
|
return files;
|
|
1129
1129
|
});
|