@shipstatic/drop 0.3.1 → 0.3.2

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
@@ -10061,7 +10061,7 @@ function useDrop(options) {
10061
10061
  const isDragging = state.value === "dragging";
10062
10062
  const isInteractive = state.value === "idle" || state.value === "dragging" || state.value === "ready";
10063
10063
  const hasError = state.value === "error";
10064
- const validFiles = useMemo(() => state.files.filter((f) => f.status === "ready"), [state.files]);
10064
+ const validFiles = useMemo(() => state.files.filter((f) => f.status === FILE_STATUSES.READY), [state.files]);
10065
10065
  const getFilesForUpload = useCallback(() => {
10066
10066
  return validFiles.map((f) => f.file);
10067
10067
  }, [validFiles]);
@@ -10132,8 +10132,37 @@ function useDrop(options) {
10132
10132
  }));
10133
10133
  const processedFiles = cleanFiles.map((file) => createProcessedFile(file));
10134
10134
  const finalFiles = stripPrefix ? stripCommonPrefix(processedFiles) : processedFiles;
10135
+ if (finalFiles.length > 0) {
10136
+ const hasIndexHtml = needsBuild ? finalFiles.some((f) => f.path === "index.html" || f.path.endsWith("/index.html")) : finalFiles.some((f) => f.path === "index.html");
10137
+ if (!hasIndexHtml) {
10138
+ const message = needsBuild ? "No index.html found \u2014 every web project needs an index.html entry point" : "No index.html at root \u2014 the entry point must be in the top-level directory";
10139
+ const filesWithStatus2 = finalFiles.map((f) => ({
10140
+ ...f,
10141
+ status: FILE_STATUSES.VALIDATION_FAILED,
10142
+ statusMessage: message
10143
+ }));
10144
+ setState({
10145
+ value: "error",
10146
+ files: filesWithStatus2,
10147
+ sourceName: detectedSourceName,
10148
+ needsBuild,
10149
+ status: {
10150
+ title: "Validation Failed",
10151
+ details: message,
10152
+ errors: [message]
10153
+ }
10154
+ });
10155
+ onValidationError?.({
10156
+ error: "Validation Failed",
10157
+ details: message,
10158
+ errors: [message],
10159
+ isClientError: true
10160
+ });
10161
+ return;
10162
+ }
10163
+ }
10135
10164
  if (needsBuild) {
10136
- const filesWithStatus2 = finalFiles.map((f) => ({ ...f, status: "ready" }));
10165
+ const filesWithStatus2 = finalFiles.map((f) => ({ ...f, status: FILE_STATUSES.READY }));
10137
10166
  setState({
10138
10167
  value: "ready",
10139
10168
  files: filesWithStatus2,
@@ -10194,7 +10223,7 @@ function useDrop(options) {
10194
10223
  }
10195
10224
  });
10196
10225
  onFilesReady?.(filesWithStatus.filter(
10197
- (f, idx) => validation.files[idx]?.status === "ready"
10226
+ (f, idx) => validation.files[idx]?.status === FILE_STATUSES.READY
10198
10227
  ));
10199
10228
  } else {
10200
10229
  const hasOnlyWarnings = validation.errors.length === 0 && validation.warnings.length > 0;