@shipstatic/drop 0.3.0 → 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.cjs +77 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +77 -7
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +3 -1
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +2 -1
- package/dist/testing.d.ts +2 -1
- package/dist/testing.js +3 -1
- package/dist/testing.js.map +1 -1
- package/dist/{useDrop-CEMSBb-M.d.cts → useDrop-q3T3LVH0.d.cts} +3 -0
- package/dist/{useDrop-CEMSBb-M.d.ts → useDrop-q3T3LVH0.d.ts} +3 -0
- package/package.json +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as ProcessedFile } from './useDrop-
|
|
2
|
-
export { C as ClientError, D as DropOptions, a as DropReturn, b as DropState, c as DropStateValue, d as DropStatus, e as DropzonePropsOptions, F as FILE_STATUSES, f as FileStatus, g as FileWithPath, u as useDrop } from './useDrop-
|
|
1
|
+
import { P as ProcessedFile } from './useDrop-q3T3LVH0.cjs';
|
|
2
|
+
export { C as ClientError, D as DropOptions, a as DropReturn, b as DropState, c as DropStateValue, d as DropStatus, e as DropzonePropsOptions, F as FILE_STATUSES, f as FileStatus, g as FileWithPath, u as useDrop } from './useDrop-q3T3LVH0.cjs';
|
|
3
3
|
import { formatFileSize as formatFileSize$1 } from '@shipstatic/ship';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as ProcessedFile } from './useDrop-
|
|
2
|
-
export { C as ClientError, D as DropOptions, a as DropReturn, b as DropState, c as DropStateValue, d as DropStatus, e as DropzonePropsOptions, F as FILE_STATUSES, f as FileStatus, g as FileWithPath, u as useDrop } from './useDrop-
|
|
1
|
+
import { P as ProcessedFile } from './useDrop-q3T3LVH0.js';
|
|
2
|
+
export { C as ClientError, D as DropOptions, a as DropReturn, b as DropState, c as DropStateValue, d as DropStatus, e as DropzonePropsOptions, F as FILE_STATUSES, f as FileStatus, g as FileWithPath, u as useDrop } from './useDrop-q3T3LVH0.js';
|
|
3
3
|
import { formatFileSize as formatFileSize$1 } from '@shipstatic/ship';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.js
CHANGED
|
@@ -9382,7 +9382,7 @@ var require_mime_db = __commonJS({
|
|
|
9382
9382
|
}
|
|
9383
9383
|
});
|
|
9384
9384
|
|
|
9385
|
-
// node_modules/.pnpm/@shipstatic+types@0.7.
|
|
9385
|
+
// node_modules/.pnpm/@shipstatic+types@0.7.7/node_modules/@shipstatic/types/dist/index.js
|
|
9386
9386
|
var ErrorType;
|
|
9387
9387
|
(function(ErrorType2) {
|
|
9388
9388
|
ErrorType2["Validation"] = "validation_failed";
|
|
@@ -9404,6 +9404,14 @@ var ErrorType;
|
|
|
9404
9404
|
function isShipError(error) {
|
|
9405
9405
|
return error !== null && typeof error === "object" && "name" in error && error.name === "ShipError" && "status" in error;
|
|
9406
9406
|
}
|
|
9407
|
+
var UNBUILT_PROJECT_MARKERS = /* @__PURE__ */ new Set([
|
|
9408
|
+
"node_modules",
|
|
9409
|
+
"package.json"
|
|
9410
|
+
]);
|
|
9411
|
+
function hasUnbuiltMarker(filePath) {
|
|
9412
|
+
const segments = filePath.replace(/\\/g, "/").split("/").filter(Boolean);
|
|
9413
|
+
return segments.some((s) => UNBUILT_PROJECT_MARKERS.has(s));
|
|
9414
|
+
}
|
|
9407
9415
|
var FileValidationStatus = {
|
|
9408
9416
|
/** File is pending validation */
|
|
9409
9417
|
PENDING: "pending",
|
|
@@ -10021,6 +10029,9 @@ async function traverseFileTree(entry, files, currentPath = "") {
|
|
|
10021
10029
|
};
|
|
10022
10030
|
await readEntriesBatch();
|
|
10023
10031
|
for (const childEntry of allEntries) {
|
|
10032
|
+
if (childEntry.isDirectory && childEntry.name === "node_modules") {
|
|
10033
|
+
continue;
|
|
10034
|
+
}
|
|
10024
10035
|
const entryPath = childEntry.isDirectory ? currentPath ? `${currentPath}/${childEntry.name}` : childEntry.name : currentPath;
|
|
10025
10036
|
await traverseFileTree(childEntry, files, entryPath);
|
|
10026
10037
|
}
|
|
@@ -10033,7 +10044,8 @@ var initialState = {
|
|
|
10033
10044
|
value: "idle",
|
|
10034
10045
|
files: [],
|
|
10035
10046
|
sourceName: "",
|
|
10036
|
-
status: null
|
|
10047
|
+
status: null,
|
|
10048
|
+
needsBuild: false
|
|
10037
10049
|
};
|
|
10038
10050
|
function useDrop(options) {
|
|
10039
10051
|
const {
|
|
@@ -10049,7 +10061,7 @@ function useDrop(options) {
|
|
|
10049
10061
|
const isDragging = state.value === "dragging";
|
|
10050
10062
|
const isInteractive = state.value === "idle" || state.value === "dragging" || state.value === "ready";
|
|
10051
10063
|
const hasError = state.value === "error";
|
|
10052
|
-
const validFiles = useMemo(() => state.files.filter((f) => f.status ===
|
|
10064
|
+
const validFiles = useMemo(() => state.files.filter((f) => f.status === FILE_STATUSES.READY), [state.files]);
|
|
10053
10065
|
const getFilesForUpload = useCallback(() => {
|
|
10054
10066
|
return validFiles.map((f) => f.file);
|
|
10055
10067
|
}, [validFiles]);
|
|
@@ -10066,7 +10078,8 @@ function useDrop(options) {
|
|
|
10066
10078
|
value: "processing",
|
|
10067
10079
|
files: [],
|
|
10068
10080
|
sourceName: "",
|
|
10069
|
-
status: { title: "Processing...", details: "Validating and preparing files." }
|
|
10081
|
+
status: { title: "Processing...", details: "Validating and preparing files." },
|
|
10082
|
+
needsBuild: false
|
|
10070
10083
|
});
|
|
10071
10084
|
let detectedSourceName = "";
|
|
10072
10085
|
try {
|
|
@@ -10100,8 +10113,18 @@ function useDrop(options) {
|
|
|
10100
10113
|
const webkitPath = f.webkitRelativePath;
|
|
10101
10114
|
return webkitPath && webkitPath.trim() ? webkitPath : f.name;
|
|
10102
10115
|
};
|
|
10103
|
-
|
|
10104
|
-
const
|
|
10116
|
+
let filePaths = allFiles.map(getFilePath);
|
|
10117
|
+
const needsBuild = filePaths.some((p) => hasUnbuiltMarker(p));
|
|
10118
|
+
if (needsBuild) {
|
|
10119
|
+
const filtered = allFiles.filter((f) => {
|
|
10120
|
+
const segments = getFilePath(f).replace(/\\/g, "/").split("/");
|
|
10121
|
+
return !segments.includes("node_modules");
|
|
10122
|
+
});
|
|
10123
|
+
allFiles.length = 0;
|
|
10124
|
+
allFiles.push(...filtered);
|
|
10125
|
+
filePaths = allFiles.map(getFilePath);
|
|
10126
|
+
}
|
|
10127
|
+
const validPaths = new Set(filterJunk(filePaths, { allowUnbuilt: needsBuild }));
|
|
10105
10128
|
const cleanFiles = allFiles.filter((f) => validPaths.has(getFilePath(f)));
|
|
10106
10129
|
setState((prev) => ({
|
|
10107
10130
|
...prev,
|
|
@@ -10109,6 +10132,47 @@ function useDrop(options) {
|
|
|
10109
10132
|
}));
|
|
10110
10133
|
const processedFiles = cleanFiles.map((file) => createProcessedFile(file));
|
|
10111
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
|
+
}
|
|
10164
|
+
if (needsBuild) {
|
|
10165
|
+
const filesWithStatus2 = finalFiles.map((f) => ({ ...f, status: FILE_STATUSES.READY }));
|
|
10166
|
+
setState({
|
|
10167
|
+
value: "ready",
|
|
10168
|
+
files: filesWithStatus2,
|
|
10169
|
+
sourceName: detectedSourceName,
|
|
10170
|
+
needsBuild: true,
|
|
10171
|
+
status: { title: "Ready", details: `${filesWithStatus2.length} file(s) ready \u2014 project will be built` }
|
|
10172
|
+
});
|
|
10173
|
+
onFilesReady?.(filesWithStatus2);
|
|
10174
|
+
return;
|
|
10175
|
+
}
|
|
10112
10176
|
const validatableFiles = finalFiles.map((f) => ({
|
|
10113
10177
|
name: f.path,
|
|
10114
10178
|
// Use full path to match server-side validation
|
|
@@ -10129,6 +10193,7 @@ function useDrop(options) {
|
|
|
10129
10193
|
value: "error",
|
|
10130
10194
|
files: filesWithStatus,
|
|
10131
10195
|
sourceName: detectedSourceName,
|
|
10196
|
+
needsBuild: false,
|
|
10132
10197
|
status: {
|
|
10133
10198
|
title: "Validation Failed",
|
|
10134
10199
|
details: `${validation.errors.length} file(s) failed validation`,
|
|
@@ -10150,6 +10215,7 @@ function useDrop(options) {
|
|
|
10150
10215
|
value: "ready",
|
|
10151
10216
|
files: filesWithStatus,
|
|
10152
10217
|
sourceName: detectedSourceName,
|
|
10218
|
+
needsBuild: false,
|
|
10153
10219
|
status: {
|
|
10154
10220
|
title: "Ready",
|
|
10155
10221
|
details,
|
|
@@ -10157,7 +10223,7 @@ function useDrop(options) {
|
|
|
10157
10223
|
}
|
|
10158
10224
|
});
|
|
10159
10225
|
onFilesReady?.(filesWithStatus.filter(
|
|
10160
|
-
(f, idx) => validation.files[idx]?.status ===
|
|
10226
|
+
(f, idx) => validation.files[idx]?.status === FILE_STATUSES.READY
|
|
10161
10227
|
));
|
|
10162
10228
|
} else {
|
|
10163
10229
|
const hasOnlyWarnings = validation.errors.length === 0 && validation.warnings.length > 0;
|
|
@@ -10166,6 +10232,7 @@ function useDrop(options) {
|
|
|
10166
10232
|
value: "ready",
|
|
10167
10233
|
files: filesWithStatus,
|
|
10168
10234
|
sourceName: detectedSourceName,
|
|
10235
|
+
needsBuild: false,
|
|
10169
10236
|
status: {
|
|
10170
10237
|
title: "All files excluded",
|
|
10171
10238
|
details: `${validation.warnings.length} file(s) excluded (empty files cannot be deployed)`,
|
|
@@ -10183,6 +10250,7 @@ function useDrop(options) {
|
|
|
10183
10250
|
value: "error",
|
|
10184
10251
|
files: filesWithStatus,
|
|
10185
10252
|
sourceName: detectedSourceName,
|
|
10253
|
+
needsBuild: false,
|
|
10186
10254
|
status: { title: noValidError.error, details: noValidError.details }
|
|
10187
10255
|
});
|
|
10188
10256
|
onValidationError?.(noValidError);
|
|
@@ -10201,6 +10269,7 @@ function useDrop(options) {
|
|
|
10201
10269
|
value: "error",
|
|
10202
10270
|
files: [],
|
|
10203
10271
|
sourceName: detectedSourceName,
|
|
10272
|
+
needsBuild: false,
|
|
10204
10273
|
status: {
|
|
10205
10274
|
title: clientError.error,
|
|
10206
10275
|
details: clientError.details,
|
|
@@ -10324,6 +10393,7 @@ function useDrop(options) {
|
|
|
10324
10393
|
files: state.files,
|
|
10325
10394
|
sourceName: state.sourceName,
|
|
10326
10395
|
status: state.status,
|
|
10396
|
+
needsBuild: state.needsBuild,
|
|
10327
10397
|
// Primary API: Prop getters
|
|
10328
10398
|
getDropzoneProps,
|
|
10329
10399
|
getInputProps,
|