@shipstatic/drop 2.13.0-beta.5 → 2.13.0

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 CHANGED
@@ -275,7 +275,7 @@ vi.mock('@shipstatic/drop', () => ({ useDrop: mockUseDrop({ phase: 'ready' }) })
275
275
 
276
276
  - **`webkitRelativePath` is the handoff.** Drop writes each file's deploy path there, and the ShipStatic SDK reads it. Don't modify it in between.
277
277
  - **`stripCommonPrefix` mutates File objects.** It returns new `ProcessedFile`s but rewrites `webkitRelativePath` on the underlying `File` — deliberately, because that's what the SDK reads.
278
- - **A folder read only in part is refused.** If any file or folder in a drop cannot be read, the drop ends in the `error` phase under "Couldn't prepare the files", naming what could not be read. Nothing is deployed without it.
278
+ - **A drop read only in part is refused.** If any file, folder or dropped item cannot be read, the drop ends in the `error` phase under "Couldn't prepare the files", naming what could not be read. Nothing is deployed without it.
279
279
  - **No MD5 here.** Ship computes each file's MD5 for its manifest.
280
280
  - **`type` is the browser's report.** The platform derives `Content-Type` server-side from the path, so drop bundles no MIME database.
281
281
 
package/dist/index.cjs CHANGED
@@ -1096,6 +1096,7 @@ async function processFiles(input, { limits, onStatus }) {
1096
1096
  }
1097
1097
 
1098
1098
  // src/entries.ts
1099
+ var UNREADABLE_DROP = "We couldn't read everything you dropped. Make sure the files are on this computer, then try again.";
1099
1100
  function unreadable(path) {
1100
1101
  return `We couldn't read ${path}. Make sure it's on this computer, then try again.`;
1101
1102
  }
@@ -1248,27 +1249,29 @@ function useDrop({ ship }) {
1248
1249
  setState((prev) => prev.isDragging ? { ...prev, isDragging: false } : prev);
1249
1250
  const files = [];
1250
1251
  const directories = [];
1252
+ let unreadable2 = false;
1251
1253
  for (const item of Array.from(e.dataTransfer.items)) {
1252
1254
  if (item.kind !== "file") continue;
1255
+ let entry;
1253
1256
  try {
1254
- const entry = item.webkitGetAsEntry?.();
1255
- if (entry?.isDirectory) {
1256
- directories.push({ entry, path: entry.name });
1257
- } else {
1258
- const file = item.getAsFile();
1259
- if (file) {
1260
- setRelativePath(file, file.name);
1261
- files.push(file);
1262
- }
1263
- }
1264
- } catch (error) {
1265
- console.warn("Error processing drop item:", error);
1266
- const file = item.getAsFile();
1267
- if (file) files.push(file);
1257
+ entry = item.webkitGetAsEntry?.();
1258
+ } catch {
1259
+ }
1260
+ if (entry?.isDirectory) {
1261
+ directories.push({ entry, path: entry.name });
1262
+ continue;
1263
+ }
1264
+ const file = item.getAsFile();
1265
+ if (file) {
1266
+ setRelativePath(file, file.name);
1267
+ files.push(file);
1268
+ } else {
1269
+ unreadable2 = true;
1268
1270
  }
1269
1271
  }
1270
- if (directories.length === 0 && files.length === 0) return;
1272
+ if (directories.length === 0 && files.length === 0 && !unreadable2) return;
1271
1273
  await prepare(async () => {
1274
+ if (unreadable2) throw new Error(UNREADABLE_DROP);
1272
1275
  await Promise.all(directories.map((d) => traverseFileTree(d.entry, files, d.path)));
1273
1276
  return files;
1274
1277
  });