@shipstatic/drop 2.0.0-beta.1 → 2.0.0-beta.11

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",
@@ -19,6 +25,17 @@ var ErrorType = {
19
25
  Business: "business_logic_error",
20
26
  /** API server error (500). Generic server-side fault. */
21
27
  Api: "internal_server_error",
28
+ /**
29
+ * The platform is closed for maintenance (503). A deliberate operator
30
+ * state, not a fault — nothing errored; the API is refusing work on
31
+ * purpose, and deployed sites keep serving throughout.
32
+ *
33
+ * Distinct from `Api` at 503, which the platform already uses for a
34
+ * dependency that failed (moderation unavailable). A consumer has to tell
35
+ * "we closed the door" from "something broke": the two get opposite words
36
+ * and opposite retry behaviour.
37
+ */
38
+ Maintenance: "maintenance",
22
39
  /** Network/connection error. Client-side only — set by HTTP clients on fetch failure; never produced server-side. */
23
40
  Network: "network_error",
24
41
  /** Operation was cancelled. Client-side only — set on `AbortSignal` abort; never produced server-side. */
@@ -38,6 +55,90 @@ new Set(Object.values(ErrorType).filter((t) => !CLIENT_ONLY_ERROR_TYPES.has(t)))
38
55
  function isShipError(error) {
39
56
  return error !== null && typeof error === "object" && "name" in error && error.name === "ShipError" && "status" in error;
40
57
  }
58
+ var WEB_FILE_EXTENSIONS = [
59
+ // Markup & documents
60
+ "html",
61
+ "htm",
62
+ "xhtml",
63
+ "xml",
64
+ "txt",
65
+ "md",
66
+ "markdown",
67
+ "pdf",
68
+ "csv",
69
+ // Data & config
70
+ "json",
71
+ "jsonc",
72
+ "webmanifest",
73
+ "map",
74
+ "toml",
75
+ "yaml",
76
+ "yml",
77
+ "rss",
78
+ "atom",
79
+ // Styles
80
+ "css",
81
+ "scss",
82
+ "sass",
83
+ "less",
84
+ // Scripts & modules
85
+ "js",
86
+ "mjs",
87
+ "cjs",
88
+ "jsx",
89
+ "ts",
90
+ "tsx",
91
+ "wasm",
92
+ "vue",
93
+ "svelte",
94
+ // Images
95
+ "png",
96
+ "jpg",
97
+ "jpeg",
98
+ "gif",
99
+ "webp",
100
+ "avif",
101
+ "svg",
102
+ "ico",
103
+ "bmp",
104
+ "tif",
105
+ "tiff",
106
+ "heic",
107
+ "heif",
108
+ // Fonts
109
+ "woff",
110
+ "woff2",
111
+ "ttf",
112
+ "otf",
113
+ "eot",
114
+ // Audio
115
+ "mp3",
116
+ "wav",
117
+ "ogg",
118
+ "oga",
119
+ "opus",
120
+ "m4a",
121
+ "aac",
122
+ "flac",
123
+ "weba",
124
+ // Video
125
+ "mp4",
126
+ "webm",
127
+ "ogv",
128
+ "mov",
129
+ "m4v",
130
+ "avi",
131
+ // 3D models
132
+ "glb",
133
+ "gltf",
134
+ "usdz",
135
+ // Text tracks
136
+ "vtt",
137
+ "srt",
138
+ // Archive — a whole site in one file
139
+ "zip"
140
+ ];
141
+ var WEB_FILE_ACCEPT = WEB_FILE_EXTENSIONS.map((ext) => `.${ext}`).join(",");
41
142
  var UNBUILT_PROJECT_MARKERS = /* @__PURE__ */ new Set([
42
143
  "node_modules",
43
144
  "package.json"
@@ -946,7 +1047,8 @@ var initialState = {
946
1047
  function useDrop({ ship }) {
947
1048
  const [state, setState] = useState(initialState);
948
1049
  const isProcessingRef = useRef(false);
949
- const inputRef = useRef(null);
1050
+ const folderInputRef = useRef(null);
1051
+ const filesInputRef = useRef(null);
950
1052
  const isProcessing = state.phase === "processing";
951
1053
  const hasError = state.phase === "error";
952
1054
  const isInteractive = state.phase === "idle" || state.phase === "ready";
@@ -1040,8 +1142,15 @@ function useDrop({ ship }) {
1040
1142
  },
1041
1143
  [processFiles2]
1042
1144
  );
1043
- const open = useCallback(() => {
1044
- inputRef.current?.click();
1145
+ const open = useCallback((mode) => {
1146
+ const input = mode === "files" ? filesInputRef.current : folderInputRef.current;
1147
+ if (!input) {
1148
+ console.warn(
1149
+ `No ${mode === "files" ? "files" : "folder"} input is mounted. Spread getInputProps('${mode === "files" ? "files" : "folder"}') onto an <input> to open this picker.`
1150
+ );
1151
+ return;
1152
+ }
1153
+ input.click();
1045
1154
  }, []);
1046
1155
  const getDropzoneProps = useCallback(
1047
1156
  (options) => {
@@ -1050,18 +1159,20 @@ function useDrop({ ship }) {
1050
1159
  onDragOver: handleDragOver,
1051
1160
  onDragLeave: handleDragLeave,
1052
1161
  onDrop: handleDrop,
1053
- ...clickable && { onClick: open }
1162
+ // Wrapped rather than passed by reference: `open` takes a mode, and a
1163
+ // click handler would hand it a MouseEvent.
1164
+ ...clickable && { onClick: () => open() }
1054
1165
  };
1055
1166
  },
1056
1167
  [handleDragOver, handleDragLeave, handleDrop, open]
1057
1168
  );
1058
1169
  const getInputProps = useCallback(
1059
- () => ({
1060
- ref: inputRef,
1170
+ (mode) => ({
1171
+ ref: mode === "files" ? filesInputRef : folderInputRef,
1061
1172
  type: "file",
1062
1173
  style: { display: "none" },
1063
1174
  multiple: true,
1064
- webkitdirectory: "",
1175
+ ...mode === "files" ? { accept: WEB_FILE_ACCEPT } : { webkitdirectory: "" },
1065
1176
  onChange: handleInputChange
1066
1177
  }),
1067
1178
  [handleInputChange]