@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/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?.trim() || file.name;
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
- try {
819
- const bytes = new Uint8Array(await zipFile.arrayBuffer());
820
- const entries = await new Promise((resolve, reject) => {
821
- unzip(bytes, (err2, data) => err2 ? reject(err2) : resolve(data));
822
- });
823
- const files = [];
824
- const errors = [];
825
- for (const [path, data] of Object.entries(entries)) {
826
- if (path.endsWith("/") && data.length === 0) continue;
827
- const sanitizedPath = normalizePath(path);
828
- if (!sanitizedPath) {
829
- errors.push(`Skipped invalid path: ${path}`);
830
- continue;
831
- }
832
- const filename = sanitizedPath.split("/").pop() || sanitizedPath;
833
- const file = new File([new Uint8Array(data)], filename);
834
- setRelativePath(file, sanitizedPath);
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
- return { files, errors };
838
- } catch (error) {
839
- return {
840
- files: [],
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 = [];