@shipstatic/drop 2.16.1-beta.8 → 2.16.1-beta.9

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
@@ -1,4 +1,4 @@
1
- import { pluralize, validateFiles, optimizeDeployPaths, sitePaths, unreadable } from '@shipstatic/ship';
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
 
@@ -815,7 +815,11 @@ function unzip(data, opts, cb) {
815
815
 
816
816
  // src/zip.ts
817
817
  async function extractZipToFiles(zipFile) {
818
- const bytes = new Uint8Array(await zipFile.arrayBuffer());
818
+ const bytes = new Uint8Array(
819
+ await zipFile.arrayBuffer().catch(() => {
820
+ throw new Error(unreadable(zipFile.name));
821
+ })
822
+ );
819
823
  const entries = await new Promise((resolve, reject) => {
820
824
  unzip(
821
825
  bytes,
@@ -1097,7 +1101,7 @@ function useDrop({ ship }) {
1097
1101
  setState((prev) => prev.isDragging ? { ...prev, isDragging: false } : prev);
1098
1102
  const files = [];
1099
1103
  const directories = [];
1100
- let unreadable2 = false;
1104
+ let unreadable3 = false;
1101
1105
  for (const item of Array.from(e.dataTransfer.items)) {
1102
1106
  if (item.kind !== "file") continue;
1103
1107
  let entry;
@@ -1114,12 +1118,12 @@ function useDrop({ ship }) {
1114
1118
  setRelativePath(file, file.name);
1115
1119
  files.push(file);
1116
1120
  } else {
1117
- unreadable2 = true;
1121
+ unreadable3 = true;
1118
1122
  }
1119
1123
  }
1120
- if (directories.length === 0 && files.length === 0 && !unreadable2) return;
1124
+ if (directories.length === 0 && files.length === 0 && !unreadable3) return;
1121
1125
  await prepare(async () => {
1122
- if (unreadable2) throw new Error(UNREADABLE_DROP);
1126
+ if (unreadable3) throw new Error(UNREADABLE_DROP);
1123
1127
  await Promise.all(directories.map((d) => traverseFileTree(d.entry, files, d.path)));
1124
1128
  return files;
1125
1129
  });