@shipstatic/drop 2.16.1-beta.6 → 2.16.1-beta.8
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 +1 -1
- package/dist/index.cjs +23 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -27
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -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);
|
|
@@ -815,34 +815,30 @@ 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
|
-
files.push(file);
|
|
818
|
+
const bytes = new Uint8Array(await zipFile.arrayBuffer());
|
|
819
|
+
const entries = await new Promise((resolve, reject) => {
|
|
820
|
+
unzip(
|
|
821
|
+
bytes,
|
|
822
|
+
(err2, data) => err2 ? reject(
|
|
823
|
+
new Error(`We couldn't open ${zipFile.name}. It may be damaged, or not a ZIP file.`)
|
|
824
|
+
) : resolve(data)
|
|
825
|
+
);
|
|
826
|
+
});
|
|
827
|
+
const files = [];
|
|
828
|
+
const errors = [];
|
|
829
|
+
for (const [path, data] of Object.entries(entries)) {
|
|
830
|
+
if (path.endsWith("/") && data.length === 0) continue;
|
|
831
|
+
const sanitizedPath = normalizePath(path);
|
|
832
|
+
if (!sanitizedPath) {
|
|
833
|
+
errors.push(`Skipped invalid path: ${path}`);
|
|
834
|
+
continue;
|
|
836
835
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
errors: [
|
|
842
|
-
`Failed to load ZIP file: ${error instanceof Error ? error.message : String(error)}`
|
|
843
|
-
]
|
|
844
|
-
};
|
|
836
|
+
const filename = sanitizedPath.split("/").pop() || sanitizedPath;
|
|
837
|
+
const file = new File([new Uint8Array(data)], filename);
|
|
838
|
+
setRelativePath(file, sanitizedPath);
|
|
839
|
+
files.push(file);
|
|
845
840
|
}
|
|
841
|
+
return { files, errors };
|
|
846
842
|
}
|
|
847
843
|
function normalizePath(path) {
|
|
848
844
|
const normalized = [];
|