@shipstatic/drop 0.1.3 → 0.1.5
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/dist/index.cjs +23 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -18
- package/dist/index.d.ts +3 -18
- package/dist/index.js +25 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -11737,7 +11737,6 @@ async function extractZipToFiles(zipFile) {
|
|
|
11737
11737
|
errors.push(`Skipped invalid path: ${path}`);
|
|
11738
11738
|
continue;
|
|
11739
11739
|
}
|
|
11740
|
-
if (isJunkFile(sanitizedPath)) continue;
|
|
11741
11740
|
try {
|
|
11742
11741
|
const content = await entry.async("blob");
|
|
11743
11742
|
const mimeType = getMimeType(sanitizedPath);
|
|
@@ -11775,11 +11774,6 @@ function normalizePath(path) {
|
|
|
11775
11774
|
}
|
|
11776
11775
|
return normalized.join("/");
|
|
11777
11776
|
}
|
|
11778
|
-
function isJunkFile(path) {
|
|
11779
|
-
const basename = (path.split("/").pop() || "").toLowerCase();
|
|
11780
|
-
const junkFiles = [".ds_store", "thumbs.db", "desktop.ini", "._.ds_store"];
|
|
11781
|
-
return path.toLowerCase().startsWith("__macosx/") || junkFiles.includes(basename);
|
|
11782
|
-
}
|
|
11783
11777
|
function isZipFile(file) {
|
|
11784
11778
|
return file.type === "application/zip" || file.type === "application/x-zip-compressed" || file.name.toLowerCase().endsWith(".zip");
|
|
11785
11779
|
}
|
|
@@ -11848,6 +11842,7 @@ function useDrop(options) {
|
|
|
11848
11842
|
stripPrefix = true
|
|
11849
11843
|
} = options;
|
|
11850
11844
|
const [files, setFiles] = react.useState([]);
|
|
11845
|
+
const [sourceName, setSourceName] = react.useState("");
|
|
11851
11846
|
const [statusText, setStatusText] = react.useState("");
|
|
11852
11847
|
const [isProcessing, setIsProcessing] = react.useState(false);
|
|
11853
11848
|
const [validationError, setValidationError] = react.useState(null);
|
|
@@ -11867,6 +11862,18 @@ function useDrop(options) {
|
|
|
11867
11862
|
setValidationError(null);
|
|
11868
11863
|
setStatusText("Processing files...");
|
|
11869
11864
|
try {
|
|
11865
|
+
let detectedSourceName = "";
|
|
11866
|
+
if (newFiles.length === 1 && isZipFile(newFiles[0])) {
|
|
11867
|
+
detectedSourceName = newFiles[0].name.replace(/\.zip$/i, "");
|
|
11868
|
+
} else if (newFiles.length > 0) {
|
|
11869
|
+
const firstPath = newFiles[0].webkitRelativePath || "";
|
|
11870
|
+
if (firstPath && firstPath.includes("/")) {
|
|
11871
|
+
detectedSourceName = firstPath.split("/")[0];
|
|
11872
|
+
} else {
|
|
11873
|
+
detectedSourceName = newFiles[0].name;
|
|
11874
|
+
}
|
|
11875
|
+
}
|
|
11876
|
+
setSourceName(detectedSourceName);
|
|
11870
11877
|
const allFiles = [];
|
|
11871
11878
|
const shouldExtractZip = newFiles.length === 1 && isZipFile(newFiles[0]);
|
|
11872
11879
|
if (shouldExtractZip) {
|
|
@@ -11880,9 +11887,16 @@ function useDrop(options) {
|
|
|
11880
11887
|
} else {
|
|
11881
11888
|
allFiles.push(...newFiles);
|
|
11882
11889
|
}
|
|
11890
|
+
const getFilePath = (f) => {
|
|
11891
|
+
const webkitPath = f.webkitRelativePath;
|
|
11892
|
+
return webkitPath && webkitPath.trim() ? webkitPath : f.name;
|
|
11893
|
+
};
|
|
11894
|
+
const filePaths = allFiles.map(getFilePath);
|
|
11895
|
+
const validPaths = new Set(ship.filterJunk(filePaths));
|
|
11896
|
+
const cleanFiles = allFiles.filter((f) => validPaths.has(getFilePath(f)));
|
|
11883
11897
|
setStatusText("Processing files...");
|
|
11884
11898
|
const processedFiles = await Promise.all(
|
|
11885
|
-
|
|
11899
|
+
cleanFiles.map((file) => createProcessedFile(file))
|
|
11886
11900
|
);
|
|
11887
11901
|
const finalFiles = stripPrefix ? stripCommonPrefix(processedFiles) : processedFiles;
|
|
11888
11902
|
const config = await ship$1.getConfig();
|
|
@@ -11921,6 +11935,7 @@ function useDrop(options) {
|
|
|
11921
11935
|
}, [ship$1, onValidationError, onFilesReady, stripPrefix]);
|
|
11922
11936
|
const clearAll = react.useCallback(() => {
|
|
11923
11937
|
setFiles([]);
|
|
11938
|
+
setSourceName("");
|
|
11924
11939
|
setStatusText("");
|
|
11925
11940
|
setValidationError(null);
|
|
11926
11941
|
isProcessingRef.current = false;
|
|
@@ -11936,6 +11951,7 @@ function useDrop(options) {
|
|
|
11936
11951
|
}, []);
|
|
11937
11952
|
return {
|
|
11938
11953
|
files,
|
|
11954
|
+
sourceName,
|
|
11939
11955
|
statusText,
|
|
11940
11956
|
isProcessing,
|
|
11941
11957
|
validationError,
|
|
@@ -11974,7 +11990,6 @@ exports.createProcessedFile = createProcessedFile;
|
|
|
11974
11990
|
exports.extractZipToFiles = extractZipToFiles;
|
|
11975
11991
|
exports.formatFileSize = formatFileSize;
|
|
11976
11992
|
exports.getValidFiles = getValidFiles;
|
|
11977
|
-
exports.isJunkFile = isJunkFile;
|
|
11978
11993
|
exports.isZipFile = isZipFile;
|
|
11979
11994
|
exports.normalizePath = normalizePath;
|
|
11980
11995
|
exports.stripCommonPrefix = stripCommonPrefix;
|