@shipstatic/drop 0.3.0 → 0.3.1
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 +46 -5
- 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 +46 -5
- 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 {
|
|
@@ -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,18 @@ function useDrop(options) {
|
|
|
10109
10132
|
}));
|
|
10110
10133
|
const processedFiles = cleanFiles.map((file) => createProcessedFile(file));
|
|
10111
10134
|
const finalFiles = stripPrefix ? stripCommonPrefix(processedFiles) : processedFiles;
|
|
10135
|
+
if (needsBuild) {
|
|
10136
|
+
const filesWithStatus2 = finalFiles.map((f) => ({ ...f, status: "ready" }));
|
|
10137
|
+
setState({
|
|
10138
|
+
value: "ready",
|
|
10139
|
+
files: filesWithStatus2,
|
|
10140
|
+
sourceName: detectedSourceName,
|
|
10141
|
+
needsBuild: true,
|
|
10142
|
+
status: { title: "Ready", details: `${filesWithStatus2.length} file(s) ready \u2014 project will be built` }
|
|
10143
|
+
});
|
|
10144
|
+
onFilesReady?.(filesWithStatus2);
|
|
10145
|
+
return;
|
|
10146
|
+
}
|
|
10112
10147
|
const validatableFiles = finalFiles.map((f) => ({
|
|
10113
10148
|
name: f.path,
|
|
10114
10149
|
// Use full path to match server-side validation
|
|
@@ -10129,6 +10164,7 @@ function useDrop(options) {
|
|
|
10129
10164
|
value: "error",
|
|
10130
10165
|
files: filesWithStatus,
|
|
10131
10166
|
sourceName: detectedSourceName,
|
|
10167
|
+
needsBuild: false,
|
|
10132
10168
|
status: {
|
|
10133
10169
|
title: "Validation Failed",
|
|
10134
10170
|
details: `${validation.errors.length} file(s) failed validation`,
|
|
@@ -10150,6 +10186,7 @@ function useDrop(options) {
|
|
|
10150
10186
|
value: "ready",
|
|
10151
10187
|
files: filesWithStatus,
|
|
10152
10188
|
sourceName: detectedSourceName,
|
|
10189
|
+
needsBuild: false,
|
|
10153
10190
|
status: {
|
|
10154
10191
|
title: "Ready",
|
|
10155
10192
|
details,
|
|
@@ -10166,6 +10203,7 @@ function useDrop(options) {
|
|
|
10166
10203
|
value: "ready",
|
|
10167
10204
|
files: filesWithStatus,
|
|
10168
10205
|
sourceName: detectedSourceName,
|
|
10206
|
+
needsBuild: false,
|
|
10169
10207
|
status: {
|
|
10170
10208
|
title: "All files excluded",
|
|
10171
10209
|
details: `${validation.warnings.length} file(s) excluded (empty files cannot be deployed)`,
|
|
@@ -10183,6 +10221,7 @@ function useDrop(options) {
|
|
|
10183
10221
|
value: "error",
|
|
10184
10222
|
files: filesWithStatus,
|
|
10185
10223
|
sourceName: detectedSourceName,
|
|
10224
|
+
needsBuild: false,
|
|
10186
10225
|
status: { title: noValidError.error, details: noValidError.details }
|
|
10187
10226
|
});
|
|
10188
10227
|
onValidationError?.(noValidError);
|
|
@@ -10201,6 +10240,7 @@ function useDrop(options) {
|
|
|
10201
10240
|
value: "error",
|
|
10202
10241
|
files: [],
|
|
10203
10242
|
sourceName: detectedSourceName,
|
|
10243
|
+
needsBuild: false,
|
|
10204
10244
|
status: {
|
|
10205
10245
|
title: clientError.error,
|
|
10206
10246
|
details: clientError.details,
|
|
@@ -10324,6 +10364,7 @@ function useDrop(options) {
|
|
|
10324
10364
|
files: state.files,
|
|
10325
10365
|
sourceName: state.sourceName,
|
|
10326
10366
|
status: state.status,
|
|
10367
|
+
needsBuild: state.needsBuild,
|
|
10327
10368
|
// Primary API: Prop getters
|
|
10328
10369
|
getDropzoneProps,
|
|
10329
10370
|
getInputProps,
|