@shipstatic/drop 2.0.0-beta.3 → 2.0.0-beta.7

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.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PlatformLimits } from '@shipstatic/types';
2
- import { P as ProcessedFile, D as DropStatus } from './useDrop-Bmjfjp_o.cjs';
3
- export { a as DropOptions, b as DropPhase, c as DropReturn, d as DropzonePropsOptions, u as useDrop } from './useDrop-Bmjfjp_o.cjs';
2
+ import { P as ProcessedFile, D as DropStatus } from './useDrop-C43AHhf8.cjs';
3
+ export { a as DropInputProps, b as DropOptions, c as DropPhase, d as DropReturn, e as DropzonePropsOptions, f as PickerMode, u as useDrop } from './useDrop-C43AHhf8.cjs';
4
4
  import '@shipstatic/ship';
5
5
 
6
6
  interface ProcessFilesOptions {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PlatformLimits } from '@shipstatic/types';
2
- import { P as ProcessedFile, D as DropStatus } from './useDrop-Bmjfjp_o.js';
3
- export { a as DropOptions, b as DropPhase, c as DropReturn, d as DropzonePropsOptions, u as useDrop } from './useDrop-Bmjfjp_o.js';
2
+ import { P as ProcessedFile, D as DropStatus } from './useDrop-C43AHhf8.js';
3
+ export { a as DropInputProps, b as DropOptions, c as DropPhase, d as DropReturn, e as DropzonePropsOptions, f as PickerMode, u as useDrop } from './useDrop-C43AHhf8.js';
4
4
  import '@shipstatic/ship';
5
5
 
6
6
  interface ProcessFilesOptions {
package/dist/index.js CHANGED
@@ -2,10 +2,16 @@ import { filterJunk, pluralize, validateFiles, optimizeDeployPaths } from '@ship
2
2
  import { useState, useRef, useMemo, useCallback } from 'react';
3
3
 
4
4
  // src/process.ts
5
-
6
- // node_modules/.pnpm/@shipstatic+types@2.2.1-beta.0/node_modules/@shipstatic/types/dist/index.js
7
5
  var ErrorType = {
8
- /** Validation failed (400). Input shape is wrong. */
6
+ /**
7
+ * Validation failed. Input shape is wrong.
8
+ *
9
+ * Carries 400 when an API judged it — including a client-side pre-check of a
10
+ * rule the server enforces too, which keeps the error identical wherever it
11
+ * was caught. **Statusless** when a client rejects something no API judges,
12
+ * such as a CLI's own command grammar: `status` is documented "(API
13
+ * contexts)" on `ErrorResponse`, so there is none to report.
14
+ */
9
15
  Validation: "validation_failed",
10
16
  /** Resource not found (404). */
11
17
  NotFound: "not_found",
@@ -38,6 +44,90 @@ new Set(Object.values(ErrorType).filter((t) => !CLIENT_ONLY_ERROR_TYPES.has(t)))
38
44
  function isShipError(error) {
39
45
  return error !== null && typeof error === "object" && "name" in error && error.name === "ShipError" && "status" in error;
40
46
  }
47
+ var WEB_FILE_EXTENSIONS = [
48
+ // Markup & documents
49
+ "html",
50
+ "htm",
51
+ "xhtml",
52
+ "xml",
53
+ "txt",
54
+ "md",
55
+ "markdown",
56
+ "pdf",
57
+ "csv",
58
+ // Data & config
59
+ "json",
60
+ "jsonc",
61
+ "webmanifest",
62
+ "map",
63
+ "toml",
64
+ "yaml",
65
+ "yml",
66
+ "rss",
67
+ "atom",
68
+ // Styles
69
+ "css",
70
+ "scss",
71
+ "sass",
72
+ "less",
73
+ // Scripts & modules
74
+ "js",
75
+ "mjs",
76
+ "cjs",
77
+ "jsx",
78
+ "ts",
79
+ "tsx",
80
+ "wasm",
81
+ "vue",
82
+ "svelte",
83
+ // Images
84
+ "png",
85
+ "jpg",
86
+ "jpeg",
87
+ "gif",
88
+ "webp",
89
+ "avif",
90
+ "svg",
91
+ "ico",
92
+ "bmp",
93
+ "tif",
94
+ "tiff",
95
+ "heic",
96
+ "heif",
97
+ // Fonts
98
+ "woff",
99
+ "woff2",
100
+ "ttf",
101
+ "otf",
102
+ "eot",
103
+ // Audio
104
+ "mp3",
105
+ "wav",
106
+ "ogg",
107
+ "oga",
108
+ "opus",
109
+ "m4a",
110
+ "aac",
111
+ "flac",
112
+ "weba",
113
+ // Video
114
+ "mp4",
115
+ "webm",
116
+ "ogv",
117
+ "mov",
118
+ "m4v",
119
+ "avi",
120
+ // 3D models
121
+ "glb",
122
+ "gltf",
123
+ "usdz",
124
+ // Text tracks
125
+ "vtt",
126
+ "srt",
127
+ // Archive — a whole site in one file
128
+ "zip"
129
+ ];
130
+ var WEB_FILE_ACCEPT = WEB_FILE_EXTENSIONS.map((ext) => `.${ext}`).join(",");
41
131
  var UNBUILT_PROJECT_MARKERS = /* @__PURE__ */ new Set([
42
132
  "node_modules",
43
133
  "package.json"
@@ -946,7 +1036,8 @@ var initialState = {
946
1036
  function useDrop({ ship }) {
947
1037
  const [state, setState] = useState(initialState);
948
1038
  const isProcessingRef = useRef(false);
949
- const inputRef = useRef(null);
1039
+ const folderInputRef = useRef(null);
1040
+ const filesInputRef = useRef(null);
950
1041
  const isProcessing = state.phase === "processing";
951
1042
  const hasError = state.phase === "error";
952
1043
  const isInteractive = state.phase === "idle" || state.phase === "ready";
@@ -1040,8 +1131,15 @@ function useDrop({ ship }) {
1040
1131
  },
1041
1132
  [processFiles2]
1042
1133
  );
1043
- const open = useCallback(() => {
1044
- inputRef.current?.click();
1134
+ const open = useCallback((mode) => {
1135
+ const input = mode === "files" ? filesInputRef.current : folderInputRef.current;
1136
+ if (!input) {
1137
+ console.warn(
1138
+ `No ${mode === "files" ? "files" : "folder"} input is mounted. Spread getInputProps('${mode === "files" ? "files" : "folder"}') onto an <input> to open this picker.`
1139
+ );
1140
+ return;
1141
+ }
1142
+ input.click();
1045
1143
  }, []);
1046
1144
  const getDropzoneProps = useCallback(
1047
1145
  (options) => {
@@ -1050,18 +1148,20 @@ function useDrop({ ship }) {
1050
1148
  onDragOver: handleDragOver,
1051
1149
  onDragLeave: handleDragLeave,
1052
1150
  onDrop: handleDrop,
1053
- ...clickable && { onClick: open }
1151
+ // Wrapped rather than passed by reference: `open` takes a mode, and a
1152
+ // click handler would hand it a MouseEvent.
1153
+ ...clickable && { onClick: () => open() }
1054
1154
  };
1055
1155
  },
1056
1156
  [handleDragOver, handleDragLeave, handleDrop, open]
1057
1157
  );
1058
1158
  const getInputProps = useCallback(
1059
- () => ({
1060
- ref: inputRef,
1159
+ (mode) => ({
1160
+ ref: mode === "files" ? filesInputRef : folderInputRef,
1061
1161
  type: "file",
1062
1162
  style: { display: "none" },
1063
1163
  multiple: true,
1064
- webkitdirectory: "",
1164
+ ...mode === "files" ? { accept: WEB_FILE_ACCEPT } : { webkitdirectory: "" },
1065
1165
  onChange: handleInputChange
1066
1166
  }),
1067
1167
  [handleInputChange]