@shipstatic/drop 0.1.9 → 0.1.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 +4 -5
- package/dist/index.cjs +30 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -15
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -11826,10 +11826,20 @@ function stripCommonPrefix(files) {
|
|
|
11826
11826
|
}
|
|
11827
11827
|
if (commonDepth === 0) return files;
|
|
11828
11828
|
const prefix = segments.slice(0, commonDepth).join("/") + "/";
|
|
11829
|
-
return files.map((f) =>
|
|
11830
|
-
|
|
11831
|
-
|
|
11832
|
-
|
|
11829
|
+
return files.map((f) => {
|
|
11830
|
+
const newPath = f.path.startsWith(prefix) ? f.path.slice(prefix.length) : f.path;
|
|
11831
|
+
if (f.file) {
|
|
11832
|
+
Object.defineProperty(f.file, "webkitRelativePath", {
|
|
11833
|
+
value: newPath,
|
|
11834
|
+
writable: false,
|
|
11835
|
+
configurable: true
|
|
11836
|
+
});
|
|
11837
|
+
}
|
|
11838
|
+
return {
|
|
11839
|
+
...f,
|
|
11840
|
+
path: newPath
|
|
11841
|
+
};
|
|
11842
|
+
});
|
|
11833
11843
|
}
|
|
11834
11844
|
async function traverseFileTree(entry, files, currentPath = "") {
|
|
11835
11845
|
try {
|
|
@@ -11840,7 +11850,8 @@ async function traverseFileTree(entry, files, currentPath = "") {
|
|
|
11840
11850
|
const relativePath = currentPath ? `${currentPath}/${file.name}` : file.name;
|
|
11841
11851
|
Object.defineProperty(file, "webkitRelativePath", {
|
|
11842
11852
|
value: relativePath,
|
|
11843
|
-
writable: false
|
|
11853
|
+
writable: false,
|
|
11854
|
+
configurable: true
|
|
11844
11855
|
});
|
|
11845
11856
|
files.push(file);
|
|
11846
11857
|
} else if (entry.isDirectory) {
|
|
@@ -12029,21 +12040,21 @@ function useDrop(options) {
|
|
|
12029
12040
|
e.preventDefault();
|
|
12030
12041
|
const items = Array.from(e.dataTransfer.items);
|
|
12031
12042
|
const files = [];
|
|
12032
|
-
|
|
12043
|
+
const entriesToTraverse = [];
|
|
12033
12044
|
for (const item of items) {
|
|
12034
12045
|
if (item.kind === "file") {
|
|
12035
12046
|
try {
|
|
12036
12047
|
const entry = item.webkitGetAsEntry?.();
|
|
12037
|
-
if (entry) {
|
|
12038
|
-
|
|
12039
|
-
await traverseFileTree(
|
|
12040
|
-
entry,
|
|
12041
|
-
files,
|
|
12042
|
-
entry.isDirectory ? entry.name : ""
|
|
12043
|
-
);
|
|
12048
|
+
if (entry && entry.isDirectory) {
|
|
12049
|
+
entriesToTraverse.push({ entry, path: entry.name });
|
|
12044
12050
|
} else {
|
|
12045
12051
|
const file = item.getAsFile();
|
|
12046
12052
|
if (file) {
|
|
12053
|
+
Object.defineProperty(file, "webkitRelativePath", {
|
|
12054
|
+
value: file.name,
|
|
12055
|
+
writable: false,
|
|
12056
|
+
configurable: true
|
|
12057
|
+
});
|
|
12047
12058
|
files.push(file);
|
|
12048
12059
|
}
|
|
12049
12060
|
}
|
|
@@ -12056,7 +12067,12 @@ function useDrop(options) {
|
|
|
12056
12067
|
}
|
|
12057
12068
|
}
|
|
12058
12069
|
}
|
|
12059
|
-
if (
|
|
12070
|
+
if (entriesToTraverse.length > 0) {
|
|
12071
|
+
await Promise.all(entriesToTraverse.map(
|
|
12072
|
+
(item) => traverseFileTree(item.entry, files, item.path)
|
|
12073
|
+
));
|
|
12074
|
+
}
|
|
12075
|
+
if (files.length === 0 && e.dataTransfer.files.length > 0) {
|
|
12060
12076
|
files.push(...Array.from(e.dataTransfer.files));
|
|
12061
12077
|
}
|
|
12062
12078
|
if (files.length > 0) {
|
|
@@ -12090,7 +12106,6 @@ function useDrop(options) {
|
|
|
12090
12106
|
}), [handleInputChange]);
|
|
12091
12107
|
return {
|
|
12092
12108
|
// State machine
|
|
12093
|
-
// state, // REMOVED
|
|
12094
12109
|
// Convenience getters (computed from state)
|
|
12095
12110
|
phase: state.value,
|
|
12096
12111
|
isProcessing,
|