@netlify/spark-ui 1.27.3 → 1.27.5

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.
@@ -1,41 +1,44 @@
1
- const i = "https://api.netlify.com/api/v1";
2
- class n {
3
- constructor(e = i) {
4
- this.apiBase = e;
1
+ function r(s, t) {
2
+ return Object.assign(new Error(`${s} failed: ${t}`), { status: t });
3
+ }
4
+ const n = "https://api.netlify.com/api/v1";
5
+ class p {
6
+ constructor(t = n) {
7
+ this.apiBase = t;
5
8
  }
6
9
  async getToken() {
7
- const e = await fetch(`${this.apiBase}/drop/token`, { method: "POST" });
8
- if (!e.ok) throw new Error(`drop/token failed: ${e.status}`);
9
- return (await e.json()).token;
10
+ const t = await fetch(`${this.apiBase}/drop/token`, { method: "POST" });
11
+ if (!t.ok) throw r("drop/token", t.status);
12
+ return (await t.json()).token;
10
13
  }
11
- async createDeploy(e, o) {
12
- const t = await fetch(`${this.apiBase}/drop`, {
14
+ async createDeploy(t, o) {
15
+ const e = await fetch(`${this.apiBase}/drop`, {
13
16
  method: "POST",
14
17
  headers: { "Content-Type": "application/json" },
15
- body: JSON.stringify({ files: e, token: o })
18
+ body: JSON.stringify({ files: t, token: o })
16
19
  });
17
- if (!t.ok) throw new Error(`drop failed: ${t.status}`);
18
- return t.json();
20
+ if (!e.ok) throw r("drop", e.status);
21
+ return e.json();
19
22
  }
20
- async uploadFile(e, o, t, a) {
21
- const r = await fetch(`${this.apiBase}/deploys/${e}/files${o}`, {
23
+ async uploadFile(t, o, e, a) {
24
+ const i = await fetch(`${this.apiBase}/deploys/${t}/files${o}`, {
22
25
  method: "PUT",
23
26
  headers: { "Content-Type": "application/octet-stream", Authorization: `Bearer ${a}` },
24
- body: t
27
+ body: e
25
28
  });
26
- if (!r.ok) throw new Error(`upload ${o} failed: ${r.status}`);
29
+ if (!i.ok) throw r(`upload ${o}`, i.status);
27
30
  }
28
- async waitUntilReady(e, o) {
29
- for (let t = 0; t < 600; t++) {
30
- const a = await fetch(`${this.apiBase}/deploys/${e.deploy_id}`, {
31
+ async waitUntilReady(t, o) {
32
+ for (let e = 0; e < 600; e++) {
33
+ const a = await fetch(`${this.apiBase}/deploys/${t.deploy_id}`, {
31
34
  headers: { Authorization: `Bearer ${o}` }
32
35
  });
33
36
  if (a.ok && (await a.json()).state === "ready") return;
34
- await new Promise((r) => setTimeout(r, 1e3));
37
+ await new Promise((i) => setTimeout(i, 1e3));
35
38
  }
36
39
  throw new Error("Deploy did not become ready in time");
37
40
  }
38
41
  }
39
42
  export {
40
- n as AnonymousDropClient
43
+ p as AnonymousDropClient
41
44
  };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Turn a raw deploy failure into copy a non-technical user can act on.
3
+ * The original message is still tracked via analytics — this is only for display.
4
+ */
5
+ export declare function humanizeDropError(err: unknown): string;
@@ -0,0 +1,29 @@
1
+ function a(e) {
2
+ if (!(e instanceof Error)) return "Something went wrong. Please try again.";
3
+ if (e.message === "Deploy did not become ready in time")
4
+ return "Your site is taking longer than expected to go live. Please try again in a moment.";
5
+ if (e instanceof TypeError)
6
+ return "Couldn't connect to Netlify. Check your internet connection and try again.";
7
+ const t = "status" in e && typeof e.status == "number" ? e.status : void 0;
8
+ switch (t) {
9
+ case 429:
10
+ return "Too many attempts — please wait a moment and try again.";
11
+ case 413:
12
+ return "Your upload is too large to deploy this way.";
13
+ case 404:
14
+ return "We couldn't find that deploy. Please try again.";
15
+ case 401:
16
+ case 403:
17
+ return "That request wasn't allowed. Please try again.";
18
+ case 500:
19
+ case 502:
20
+ case 503:
21
+ case 504:
22
+ return "Netlify's servers are having trouble right now. Please try again shortly.";
23
+ default:
24
+ return t ? "Something went wrong talking to Netlify. Please try again." : "Something went wrong. Please try again.";
25
+ }
26
+ }
27
+ export {
28
+ a as humanizeDropError
29
+ };
@@ -3,3 +3,4 @@ export * from './digest';
3
3
  export * from './readFiles';
4
4
  export * from './client';
5
5
  export * from './deploy';
6
+ export * from './errors';
@@ -1,13 +1,16 @@
1
- import { getDigest as o } from "./digest.js";
2
- import { getSingleNonIndexHtmlFileName as l, hasMultipleHtmlFilesWithoutIndex as i, readDataTransfer as m, readFileList as n } from "./readFiles.js";
3
- import { AnonymousDropClient as p } from "./client.js";
4
- import { deployFiles as x } from "./deploy.js";
1
+ import { getDigest as r } from "./digest.js";
2
+ import { getSingleNonIndexHtmlFileName as n, hasMultipleHtmlFilesWithoutIndex as l, readDataTransfer as i, readFileList as m, renameSingleNonIndexHtmlToIndex as a } from "./readFiles.js";
3
+ import { AnonymousDropClient as x } from "./client.js";
4
+ import { deployFiles as s } from "./deploy.js";
5
+ import { humanizeDropError as g } from "./errors.js";
5
6
  export {
6
- p as AnonymousDropClient,
7
- x as deployFiles,
8
- o as getDigest,
9
- l as getSingleNonIndexHtmlFileName,
10
- i as hasMultipleHtmlFilesWithoutIndex,
11
- m as readDataTransfer,
12
- n as readFileList
7
+ x as AnonymousDropClient,
8
+ s as deployFiles,
9
+ r as getDigest,
10
+ n as getSingleNonIndexHtmlFileName,
11
+ l as hasMultipleHtmlFilesWithoutIndex,
12
+ g as humanizeDropError,
13
+ i as readDataTransfer,
14
+ m as readFileList,
15
+ a as renameSingleNonIndexHtmlToIndex
13
16
  };
@@ -11,3 +11,11 @@ export declare function readDataTransfer(dt: DataTransfer): Promise<ProcessedFil
11
11
  export declare function readFileList(files: FileList): Promise<ProcessedFile[]>;
12
12
  export declare function getSingleNonIndexHtmlFileName(files: ProcessedFile[]): string | null;
13
13
  export declare function hasMultipleHtmlFilesWithoutIndex(files: ProcessedFile[]): boolean;
14
+ /**
15
+ * When the set has no index.html but exactly one HTML file (a lone page
16
+ * alongside its assets, or a single dropped file), rename that file to
17
+ * index.html — keeping its directory — so it is served at the site root
18
+ * instead of 404ing. Content and sha are untouched. Any other set (already has
19
+ * an index, multiple HTML files, or no HTML) is returned unchanged.
20
+ */
21
+ export declare function renameSingleNonIndexHtmlToIndex(files: ProcessedFile[]): ProcessedFile[];
@@ -1,18 +1,18 @@
1
- import { g as F } from "../../../../chunks/_commonjsHelpers.C6fGbg64.js";
2
- var L = { exports: {} }, I = L.exports, M;
1
+ import { g as I } from "../../../../chunks/_commonjsHelpers.C6fGbg64.js";
2
+ var L = { exports: {} }, F = L.exports, M;
3
3
  function z() {
4
4
  return M || (M = 1, function(g, _) {
5
- (function(b, p) {
6
- g.exports = p();
7
- })(typeof self < "u" ? self : I, function() {
5
+ (function(m, h) {
6
+ g.exports = h();
7
+ })(typeof self < "u" ? self : F, function() {
8
8
  return (
9
9
  /******/
10
- function(x) {
11
- var b = {};
12
- function p(v) {
13
- if (b[v])
14
- return b[v].exports;
15
- var s = b[v] = {
10
+ function(y) {
11
+ var m = {};
12
+ function h(v) {
13
+ if (m[v])
14
+ return m[v].exports;
15
+ var s = m[v] = {
16
16
  /******/
17
17
  i: v,
18
18
  /******/
@@ -21,19 +21,19 @@ function z() {
21
21
  exports: {}
22
22
  /******/
23
23
  };
24
- return x[v].call(s.exports, s, s.exports, p), s.l = !0, s.exports;
24
+ return y[v].call(s.exports, s, s.exports, h), s.l = !0, s.exports;
25
25
  }
26
- return p.m = x, p.c = b, p.d = function(v, s, y) {
27
- p.o(v, s) || Object.defineProperty(v, s, {
26
+ return h.m = y, h.c = m, h.d = function(v, s, w) {
27
+ h.o(v, s) || Object.defineProperty(v, s, {
28
28
  /******/
29
29
  configurable: !1,
30
30
  /******/
31
31
  enumerable: !0,
32
32
  /******/
33
- get: y
33
+ get: w
34
34
  /******/
35
35
  });
36
- }, p.n = function(v) {
36
+ }, h.n = function(v) {
37
37
  var s = v && v.__esModule ? (
38
38
  /******/
39
39
  function() {
@@ -45,25 +45,25 @@ function z() {
45
45
  return v;
46
46
  }
47
47
  );
48
- return p.d(s, "a", s), s;
49
- }, p.o = function(v, s) {
48
+ return h.d(s, "a", s), s;
49
+ }, h.o = function(v, s) {
50
50
  return Object.prototype.hasOwnProperty.call(v, s);
51
- }, p.p = "", p(p.s = 3);
51
+ }, h.p = "", h(h.s = 3);
52
52
  }([
53
53
  /* 0 */
54
54
  /***/
55
- function(x, b, p) {
55
+ function(y, m, h) {
56
56
  function v(e, o) {
57
57
  if (!(e instanceof o))
58
58
  throw new TypeError("Cannot call a class as a function");
59
59
  }
60
- var s = p(5), y = p(1), u = y.toHex, f = y.ceilHeapSize, l = p(6), d = function(e) {
60
+ var s = h(5), w = h(1), u = w.toHex, f = w.ceilHeapSize, l = h(6), d = function(e) {
61
61
  for (e += 9; e % 64 > 0; e += 1)
62
62
  ;
63
63
  return e;
64
64
  }, i = function(e, o) {
65
- var n = new Uint8Array(e.buffer), h = o % 4, a = o - h;
66
- switch (h) {
65
+ var n = new Uint8Array(e.buffer), p = o % 4, a = o - p;
66
+ switch (p) {
67
67
  case 0:
68
68
  n[a + 3] = 0;
69
69
  case 1:
@@ -73,38 +73,38 @@ function z() {
73
73
  case 3:
74
74
  n[a + 0] = 0;
75
75
  }
76
- for (var w = (o >> 2) + 1; w < e.length; w++)
77
- e[w] = 0;
76
+ for (var x = (o >> 2) + 1; x < e.length; x++)
77
+ e[x] = 0;
78
78
  }, r = function(e, o, n) {
79
79
  e[o >> 2] |= 128 << 24 - (o % 4 << 3), e[((o >> 2) + 2 & -16) + 14] = n / (1 << 29) | 0, e[((o >> 2) + 2 & -16) + 15] = n << 3;
80
80
  }, t = function(e, o) {
81
- var n = new Int32Array(e, o + 320, 5), h = new Int32Array(5), a = new DataView(h.buffer);
82
- return a.setInt32(0, n[0], !1), a.setInt32(4, n[1], !1), a.setInt32(8, n[2], !1), a.setInt32(12, n[3], !1), a.setInt32(16, n[4], !1), h;
81
+ var n = new Int32Array(e, o + 320, 5), p = new Int32Array(5), a = new DataView(p.buffer);
82
+ return a.setInt32(0, n[0], !1), a.setInt32(4, n[1], !1), a.setInt32(8, n[2], !1), a.setInt32(12, n[3], !1), a.setInt32(16, n[4], !1), p;
83
83
  }, c = function() {
84
84
  function e(o) {
85
85
  if (v(this, e), o = o || 64 * 1024, o % 64 > 0)
86
86
  throw new Error("Chunk size must be a multiple of 128 bit");
87
87
  this._offset = 0, this._maxChunkLen = o, this._padMaxChunkLen = d(o), this._heap = new ArrayBuffer(f(this._padMaxChunkLen + 320 + 20)), this._h32 = new Int32Array(this._heap), this._h8 = new Int8Array(this._heap), this._core = new s({ Int32Array }, {}, this._heap);
88
88
  }
89
- return e.prototype._initState = function(n, h) {
89
+ return e.prototype._initState = function(n, p) {
90
90
  this._offset = 0;
91
- var a = new Int32Array(n, h + 320, 5);
91
+ var a = new Int32Array(n, p + 320, 5);
92
92
  a[0] = 1732584193, a[1] = -271733879, a[2] = -1732584194, a[3] = 271733878, a[4] = -1009589776;
93
- }, e.prototype._padChunk = function(n, h) {
94
- var a = d(n), w = new Int32Array(this._heap, 0, a >> 2);
95
- return i(w, n), r(w, n, h), a;
96
- }, e.prototype._write = function(n, h, a, w) {
97
- l(n, this._h8, this._h32, h, a, w || 0);
98
- }, e.prototype._coreCall = function(n, h, a, w, m) {
93
+ }, e.prototype._padChunk = function(n, p) {
94
+ var a = d(n), x = new Int32Array(this._heap, 0, a >> 2);
95
+ return i(x, n), r(x, n, p), a;
96
+ }, e.prototype._write = function(n, p, a, x) {
97
+ l(n, this._h8, this._h32, p, a, x || 0);
98
+ }, e.prototype._coreCall = function(n, p, a, x, b) {
99
99
  var C = a;
100
- this._write(n, h, a), m && (C = this._padChunk(a, w)), this._core.hash(C, this._padMaxChunkLen);
100
+ this._write(n, p, a), b && (C = this._padChunk(a, x)), this._core.hash(C, this._padMaxChunkLen);
101
101
  }, e.prototype.rawDigest = function(n) {
102
- var h = n.byteLength || n.length || n.size || 0;
102
+ var p = n.byteLength || n.length || n.size || 0;
103
103
  this._initState(this._heap, this._padMaxChunkLen);
104
- var a = 0, w = this._maxChunkLen;
105
- for (a = 0; h > a + w; a += w)
106
- this._coreCall(n, a, w, h, !1);
107
- return this._coreCall(n, a, h - a, h, !0), t(this._heap, this._padMaxChunkLen);
104
+ var a = 0, x = this._maxChunkLen;
105
+ for (a = 0; p > a + x; a += x)
106
+ this._coreCall(n, a, x, p, !1);
107
+ return this._coreCall(n, a, p - a, p, !0), t(this._heap, this._padMaxChunkLen);
108
108
  }, e.prototype.digest = function(n) {
109
109
  return u(this.rawDigest(n).buffer);
110
110
  }, e.prototype.digestFromString = function(n) {
@@ -116,75 +116,75 @@ function z() {
116
116
  }, e.prototype.resetState = function() {
117
117
  return this._initState(this._heap, this._padMaxChunkLen), this;
118
118
  }, e.prototype.append = function(n) {
119
- var h = 0, a = n.byteLength || n.length || n.size || 0, w = this._offset % this._maxChunkLen, m = void 0;
120
- for (this._offset += a; h < a; )
121
- m = Math.min(a - h, this._maxChunkLen - w), this._write(n, h, m, w), w += m, h += m, w === this._maxChunkLen && (this._core.hash(this._maxChunkLen, this._padMaxChunkLen), w = 0);
119
+ var p = 0, a = n.byteLength || n.length || n.size || 0, x = this._offset % this._maxChunkLen, b = void 0;
120
+ for (this._offset += a; p < a; )
121
+ b = Math.min(a - p, this._maxChunkLen - x), this._write(n, p, b, x), x += b, p += b, x === this._maxChunkLen && (this._core.hash(this._maxChunkLen, this._padMaxChunkLen), x = 0);
122
122
  return this;
123
123
  }, e.prototype.getState = function() {
124
- var n = this._offset % this._maxChunkLen, h = void 0;
124
+ var n = this._offset % this._maxChunkLen, p = void 0;
125
125
  if (n)
126
- h = this._heap.slice(0);
126
+ p = this._heap.slice(0);
127
127
  else {
128
128
  var a = new Int32Array(this._heap, this._padMaxChunkLen + 320, 5);
129
- h = a.buffer.slice(a.byteOffset, a.byteOffset + a.byteLength);
129
+ p = a.buffer.slice(a.byteOffset, a.byteOffset + a.byteLength);
130
130
  }
131
131
  return {
132
132
  offset: this._offset,
133
- heap: h
133
+ heap: p
134
134
  };
135
135
  }, e.prototype.setState = function(n) {
136
136
  if (this._offset = n.offset, n.heap.byteLength === 20) {
137
- var h = new Int32Array(this._heap, this._padMaxChunkLen + 320, 5);
138
- h.set(new Int32Array(n.heap));
137
+ var p = new Int32Array(this._heap, this._padMaxChunkLen + 320, 5);
138
+ p.set(new Int32Array(n.heap));
139
139
  } else
140
140
  this._h32.set(new Int32Array(n.heap));
141
141
  return this;
142
142
  }, e.prototype.rawEnd = function() {
143
- var n = this._offset, h = n % this._maxChunkLen, a = this._padChunk(h, n);
143
+ var n = this._offset, p = n % this._maxChunkLen, a = this._padChunk(p, n);
144
144
  this._core.hash(a, this._padMaxChunkLen);
145
- var w = t(this._heap, this._padMaxChunkLen);
146
- return this._initState(this._heap, this._padMaxChunkLen), w;
145
+ var x = t(this._heap, this._padMaxChunkLen);
146
+ return this._initState(this._heap, this._padMaxChunkLen), x;
147
147
  }, e.prototype.end = function() {
148
148
  return u(this.rawEnd().buffer);
149
149
  }, e;
150
150
  }();
151
- x.exports = c, x.exports._core = s;
151
+ y.exports = c, y.exports._core = s;
152
152
  },
153
153
  /* 1 */
154
154
  /***/
155
- function(x, b) {
156
- for (var p = new Array(256), v = 0; v < 256; v++)
157
- p[v] = (v < 16 ? "0" : "") + v.toString(16);
158
- x.exports.toHex = function(s) {
159
- for (var y = new Uint8Array(s), u = new Array(s.byteLength), f = 0; f < u.length; f++)
160
- u[f] = p[y[f]];
155
+ function(y, m) {
156
+ for (var h = new Array(256), v = 0; v < 256; v++)
157
+ h[v] = (v < 16 ? "0" : "") + v.toString(16);
158
+ y.exports.toHex = function(s) {
159
+ for (var w = new Uint8Array(s), u = new Array(s.byteLength), f = 0; f < u.length; f++)
160
+ u[f] = h[w[f]];
161
161
  return u.join("");
162
- }, x.exports.ceilHeapSize = function(s) {
163
- var y = 0;
162
+ }, y.exports.ceilHeapSize = function(s) {
163
+ var w = 0;
164
164
  if (s <= 65536) return 65536;
165
165
  if (s < 16777216)
166
- for (y = 1; y < s; y = y << 1)
166
+ for (w = 1; w < s; w = w << 1)
167
167
  ;
168
168
  else
169
- for (y = 16777216; y < s; y += 16777216)
169
+ for (w = 16777216; w < s; w += 16777216)
170
170
  ;
171
- return y;
172
- }, x.exports.isDedicatedWorkerScope = function(s) {
173
- var y = "WorkerGlobalScope" in s && s instanceof s.WorkerGlobalScope, u = "SharedWorkerGlobalScope" in s && s instanceof s.SharedWorkerGlobalScope, f = "ServiceWorkerGlobalScope" in s && s instanceof s.ServiceWorkerGlobalScope;
174
- return y && !u && !f;
171
+ return w;
172
+ }, y.exports.isDedicatedWorkerScope = function(s) {
173
+ var w = "WorkerGlobalScope" in s && s instanceof s.WorkerGlobalScope, u = "SharedWorkerGlobalScope" in s && s instanceof s.SharedWorkerGlobalScope, f = "ServiceWorkerGlobalScope" in s && s instanceof s.ServiceWorkerGlobalScope;
174
+ return w && !u && !f;
175
175
  };
176
176
  },
177
177
  /* 2 */
178
178
  /***/
179
- function(x, b, p) {
180
- x.exports = function() {
181
- var v = p(0), s = function(f, l, d) {
179
+ function(y, m, h) {
180
+ y.exports = function() {
181
+ var v = h(0), s = function(f, l, d) {
182
182
  try {
183
183
  return d(null, f.digest(l));
184
184
  } catch (i) {
185
185
  return d(i);
186
186
  }
187
- }, y = function(f, l, d, i, r) {
187
+ }, w = function(f, l, d, i, r) {
188
188
  var t = new self.FileReader();
189
189
  t.onloadend = function() {
190
190
  if (t.error)
@@ -197,7 +197,7 @@ function z() {
197
197
  r(o);
198
198
  return;
199
199
  }
200
- l < i.size ? y(f, l, d, i, r) : r(null, f.end());
200
+ l < i.size ? w(f, l, d, i, r) : r(null, f.end());
201
201
  }, t.readAsArrayBuffer(i.slice(l, l + d));
202
202
  }, u = !0;
203
203
  return self.onmessage = function(f) {
@@ -209,7 +209,7 @@ function z() {
209
209
  var c = function(e, o) {
210
210
  e ? self.postMessage({ id: i, error: e.name }) : self.postMessage({ id: i, hash: o });
211
211
  };
212
- l && s(t, l, c), d && y(t, 0, r, d, c);
212
+ l && s(t, l, c), d && w(t, 0, r, d, c);
213
213
  }
214
214
  }
215
215
  }, function() {
@@ -219,8 +219,8 @@ function z() {
219
219
  },
220
220
  /* 3 */
221
221
  /***/
222
- function(x, b, p) {
223
- var v = p(4), s = p(0), y = p(7), u = p(2), f = p(1), l = f.isDedicatedWorkerScope, d = typeof self < "u" && l(self);
222
+ function(y, m, h) {
223
+ var v = h(4), s = h(0), w = h(7), u = h(2), f = h(1), l = f.isDedicatedWorkerScope, d = typeof self < "u" && l(self);
224
224
  s.disableWorkerBehaviour = d ? u() : function() {
225
225
  }, s.createWorker = function() {
226
226
  var i = v(
@@ -230,11 +230,11 @@ function z() {
230
230
  return i.terminate = function() {
231
231
  URL.revokeObjectURL(i.objectURL), r.call(i);
232
232
  }, i;
233
- }, s.createHash = y, x.exports = s;
233
+ }, s.createHash = w, y.exports = s;
234
234
  },
235
235
  /* 4 */
236
236
  /***/
237
- function(x, b, p) {
237
+ function(y, m, h) {
238
238
  function v(i) {
239
239
  var r = {};
240
240
  function t(e) {
@@ -286,7 +286,7 @@ function z() {
286
286
  var c = t(t.s = ENTRY_MODULE);
287
287
  return c.default || c;
288
288
  }
289
- var s = "[\\.|\\-|\\+|\\w|/|@]+", y = "\\((/\\*.*?\\*/)?s?.*?(" + s + ").*?\\)";
289
+ var s = "[\\.|\\-|\\+|\\w|/|@]+", w = "\\((/\\*.*?\\*/)?s?.*?(" + s + ").*?\\)";
290
290
  function u(i) {
291
291
  return (i + "").replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&");
292
292
  }
@@ -295,10 +295,10 @@ function z() {
295
295
  c[t] = [];
296
296
  var e = r.toString(), o = e.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);
297
297
  if (!o) return c;
298
- for (var n = o[1], h = new RegExp("(\\\\n|\\W)" + u(n) + y, "g"), a; a = h.exec(e); )
298
+ for (var n = o[1], p = new RegExp("(\\\\n|\\W)" + u(n) + w, "g"), a; a = p.exec(e); )
299
299
  a[3] !== "dll-reference" && c[t].push(a[3]);
300
- for (h = new RegExp("\\(" + u(n) + '\\("(dll-reference\\s(' + s + '))"\\)\\)' + y, "g"); a = h.exec(e); )
301
- i[a[2]] || (c[t].push(a[1]), i[a[2]] = p(a[1]).m), c[a[2]] = c[a[2]] || [], c[a[2]].push(a[4]);
300
+ for (p = new RegExp("\\(" + u(n) + '\\("(dll-reference\\s(' + s + '))"\\)\\)' + w, "g"); a = p.exec(e); )
301
+ i[a[2]] || (c[t].push(a[1]), i[a[2]] = h(a[1]).m), c[a[2]] = c[a[2]] || [], c[a[2]].push(a[4]);
302
302
  return c;
303
303
  }
304
304
  function l(i) {
@@ -316,69 +316,69 @@ function z() {
316
316
  main: {}
317
317
  }; l(t); )
318
318
  for (var o = Object.keys(t), n = 0; n < o.length; n++) {
319
- var h = o[n], a = t[h], w = a.pop();
320
- if (e[h] = e[h] || {}, !(e[h][w] || !i[h][w])) {
321
- e[h][w] = !0, c[h] = c[h] || [], c[h].push(w);
322
- for (var m = f(i, i[h][w], h), C = Object.keys(m), S = 0; S < C.length; S++)
323
- t[C[S]] = t[C[S]] || [], t[C[S]] = t[C[S]].concat(m[C[S]]);
319
+ var p = o[n], a = t[p], x = a.pop();
320
+ if (e[p] = e[p] || {}, !(e[p][x] || !i[p][x])) {
321
+ e[p][x] = !0, c[p] = c[p] || [], c[p].push(x);
322
+ for (var b = f(i, i[p][x], p), C = Object.keys(b), S = 0; S < C.length; S++)
323
+ t[C[S]] = t[C[S]] || [], t[C[S]] = t[C[S]].concat(b[C[S]]);
324
324
  }
325
325
  }
326
326
  return c;
327
327
  }
328
- x.exports = function(i, r) {
328
+ y.exports = function(i, r) {
329
329
  r = r || {};
330
330
  var t = {
331
- main: p.m
331
+ main: h.m
332
332
  }, c = r.all ? { main: Object.keys(t) } : d(t, i), e = "";
333
- Object.keys(c).filter(function(w) {
334
- return w !== "main";
335
- }).forEach(function(w) {
336
- for (var m = 0; c[w][m]; )
337
- m++;
338
- c[w].push(m), t[w][m] = "(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })", e = e + "var " + w + " = (" + v.toString().replace("ENTRY_MODULE", JSON.stringify(m)) + ")({" + c[w].map(function(C) {
339
- return "" + JSON.stringify(C) + ": " + t[w][C].toString();
333
+ Object.keys(c).filter(function(x) {
334
+ return x !== "main";
335
+ }).forEach(function(x) {
336
+ for (var b = 0; c[x][b]; )
337
+ b++;
338
+ c[x].push(b), t[x][b] = "(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })", e = e + "var " + x + " = (" + v.toString().replace("ENTRY_MODULE", JSON.stringify(b)) + ")({" + c[x].map(function(C) {
339
+ return "" + JSON.stringify(C) + ": " + t[x][C].toString();
340
340
  }).join(",") + `});
341
341
  `;
342
- }), e = e + "(" + v.toString().replace("ENTRY_MODULE", JSON.stringify(i)) + ")({" + c.main.map(function(w) {
343
- return "" + JSON.stringify(w) + ": " + t.main[w].toString();
342
+ }), e = e + "(" + v.toString().replace("ENTRY_MODULE", JSON.stringify(i)) + ")({" + c.main.map(function(x) {
343
+ return "" + JSON.stringify(x) + ": " + t.main[x].toString();
344
344
  }).join(",") + "})(self);";
345
345
  var o = new window.Blob([e], { type: "text/javascript" });
346
346
  if (r.bare)
347
347
  return o;
348
- var n = window.URL || window.webkitURL || window.mozURL || window.msURL, h = n.createObjectURL(o), a = new window.Worker(h);
349
- return a.objectURL = h, a;
348
+ var n = window.URL || window.webkitURL || window.mozURL || window.msURL, p = n.createObjectURL(o), a = new window.Worker(p);
349
+ return a.objectURL = p, a;
350
350
  };
351
351
  },
352
352
  /* 5 */
353
353
  /***/
354
- function(x, b) {
355
- x.exports = function(v, s, y) {
356
- var u = new v.Int32Array(y);
354
+ function(y, m) {
355
+ y.exports = function(v, s, w) {
356
+ var u = new v.Int32Array(w);
357
357
  function f(l, d) {
358
358
  l = l | 0, d = d | 0;
359
- var i = 0, r = 0, t = 0, c = 0, e = 0, o = 0, n = 0, h = 0, a = 0, w = 0, m = 0, C = 0, S = 0, A = 0;
360
- for (t = u[d + 320 >> 2] | 0, e = u[d + 324 >> 2] | 0, n = u[d + 328 >> 2] | 0, a = u[d + 332 >> 2] | 0, m = u[d + 336 >> 2] | 0, i = 0; (i | 0) < (l | 0); i = i + 64 | 0) {
361
- for (c = t, o = e, h = n, w = a, C = m, r = 0; (r | 0) < 64; r = r + 4 | 0)
362
- A = u[i + r >> 2] | 0, S = ((t << 5 | t >>> 27) + (e & n | ~e & a) | 0) + ((A + m | 0) + 1518500249 | 0) | 0, m = a, a = n, n = e << 30 | e >>> 2, e = t, t = S, u[l + r >> 2] = A;
359
+ var i = 0, r = 0, t = 0, c = 0, e = 0, o = 0, n = 0, p = 0, a = 0, x = 0, b = 0, C = 0, S = 0, A = 0;
360
+ for (t = u[d + 320 >> 2] | 0, e = u[d + 324 >> 2] | 0, n = u[d + 328 >> 2] | 0, a = u[d + 332 >> 2] | 0, b = u[d + 336 >> 2] | 0, i = 0; (i | 0) < (l | 0); i = i + 64 | 0) {
361
+ for (c = t, o = e, p = n, x = a, C = b, r = 0; (r | 0) < 64; r = r + 4 | 0)
362
+ A = u[i + r >> 2] | 0, S = ((t << 5 | t >>> 27) + (e & n | ~e & a) | 0) + ((A + b | 0) + 1518500249 | 0) | 0, b = a, a = n, n = e << 30 | e >>> 2, e = t, t = S, u[l + r >> 2] = A;
363
363
  for (r = l + 64 | 0; (r | 0) < (l + 80 | 0); r = r + 4 | 0)
364
- A = (u[r - 12 >> 2] ^ u[r - 32 >> 2] ^ u[r - 56 >> 2] ^ u[r - 64 >> 2]) << 1 | (u[r - 12 >> 2] ^ u[r - 32 >> 2] ^ u[r - 56 >> 2] ^ u[r - 64 >> 2]) >>> 31, S = ((t << 5 | t >>> 27) + (e & n | ~e & a) | 0) + ((A + m | 0) + 1518500249 | 0) | 0, m = a, a = n, n = e << 30 | e >>> 2, e = t, t = S, u[r >> 2] = A;
364
+ A = (u[r - 12 >> 2] ^ u[r - 32 >> 2] ^ u[r - 56 >> 2] ^ u[r - 64 >> 2]) << 1 | (u[r - 12 >> 2] ^ u[r - 32 >> 2] ^ u[r - 56 >> 2] ^ u[r - 64 >> 2]) >>> 31, S = ((t << 5 | t >>> 27) + (e & n | ~e & a) | 0) + ((A + b | 0) + 1518500249 | 0) | 0, b = a, a = n, n = e << 30 | e >>> 2, e = t, t = S, u[r >> 2] = A;
365
365
  for (r = l + 80 | 0; (r | 0) < (l + 160 | 0); r = r + 4 | 0)
366
- A = (u[r - 12 >> 2] ^ u[r - 32 >> 2] ^ u[r - 56 >> 2] ^ u[r - 64 >> 2]) << 1 | (u[r - 12 >> 2] ^ u[r - 32 >> 2] ^ u[r - 56 >> 2] ^ u[r - 64 >> 2]) >>> 31, S = ((t << 5 | t >>> 27) + (e ^ n ^ a) | 0) + ((A + m | 0) + 1859775393 | 0) | 0, m = a, a = n, n = e << 30 | e >>> 2, e = t, t = S, u[r >> 2] = A;
366
+ A = (u[r - 12 >> 2] ^ u[r - 32 >> 2] ^ u[r - 56 >> 2] ^ u[r - 64 >> 2]) << 1 | (u[r - 12 >> 2] ^ u[r - 32 >> 2] ^ u[r - 56 >> 2] ^ u[r - 64 >> 2]) >>> 31, S = ((t << 5 | t >>> 27) + (e ^ n ^ a) | 0) + ((A + b | 0) + 1859775393 | 0) | 0, b = a, a = n, n = e << 30 | e >>> 2, e = t, t = S, u[r >> 2] = A;
367
367
  for (r = l + 160 | 0; (r | 0) < (l + 240 | 0); r = r + 4 | 0)
368
- A = (u[r - 12 >> 2] ^ u[r - 32 >> 2] ^ u[r - 56 >> 2] ^ u[r - 64 >> 2]) << 1 | (u[r - 12 >> 2] ^ u[r - 32 >> 2] ^ u[r - 56 >> 2] ^ u[r - 64 >> 2]) >>> 31, S = ((t << 5 | t >>> 27) + (e & n | e & a | n & a) | 0) + ((A + m | 0) - 1894007588 | 0) | 0, m = a, a = n, n = e << 30 | e >>> 2, e = t, t = S, u[r >> 2] = A;
368
+ A = (u[r - 12 >> 2] ^ u[r - 32 >> 2] ^ u[r - 56 >> 2] ^ u[r - 64 >> 2]) << 1 | (u[r - 12 >> 2] ^ u[r - 32 >> 2] ^ u[r - 56 >> 2] ^ u[r - 64 >> 2]) >>> 31, S = ((t << 5 | t >>> 27) + (e & n | e & a | n & a) | 0) + ((A + b | 0) - 1894007588 | 0) | 0, b = a, a = n, n = e << 30 | e >>> 2, e = t, t = S, u[r >> 2] = A;
369
369
  for (r = l + 240 | 0; (r | 0) < (l + 320 | 0); r = r + 4 | 0)
370
- A = (u[r - 12 >> 2] ^ u[r - 32 >> 2] ^ u[r - 56 >> 2] ^ u[r - 64 >> 2]) << 1 | (u[r - 12 >> 2] ^ u[r - 32 >> 2] ^ u[r - 56 >> 2] ^ u[r - 64 >> 2]) >>> 31, S = ((t << 5 | t >>> 27) + (e ^ n ^ a) | 0) + ((A + m | 0) - 899497514 | 0) | 0, m = a, a = n, n = e << 30 | e >>> 2, e = t, t = S, u[r >> 2] = A;
371
- t = t + c | 0, e = e + o | 0, n = n + h | 0, a = a + w | 0, m = m + C | 0;
370
+ A = (u[r - 12 >> 2] ^ u[r - 32 >> 2] ^ u[r - 56 >> 2] ^ u[r - 64 >> 2]) << 1 | (u[r - 12 >> 2] ^ u[r - 32 >> 2] ^ u[r - 56 >> 2] ^ u[r - 64 >> 2]) >>> 31, S = ((t << 5 | t >>> 27) + (e ^ n ^ a) | 0) + ((A + b | 0) - 899497514 | 0) | 0, b = a, a = n, n = e << 30 | e >>> 2, e = t, t = S, u[r >> 2] = A;
371
+ t = t + c | 0, e = e + o | 0, n = n + p | 0, a = a + x | 0, b = b + C | 0;
372
372
  }
373
- u[d + 320 >> 2] = t, u[d + 324 >> 2] = e, u[d + 328 >> 2] = n, u[d + 332 >> 2] = a, u[d + 336 >> 2] = m;
373
+ u[d + 320 >> 2] = t, u[d + 324 >> 2] = e, u[d + 328 >> 2] = n, u[d + 332 >> 2] = a, u[d + 336 >> 2] = b;
374
374
  }
375
375
  return { hash: f };
376
376
  };
377
377
  },
378
378
  /* 6 */
379
379
  /***/
380
- function(x, b) {
381
- var p = this, v = void 0;
380
+ function(y, m) {
381
+ var h = this, v = void 0;
382
382
  typeof self < "u" && typeof self.FileReaderSync < "u" && (v = new self.FileReaderSync());
383
383
  var s = function(f, l, d, i, r, t) {
384
384
  var c = void 0, e = t % 4, o = (r + e) % 4, n = r - o;
@@ -404,7 +404,7 @@ function z() {
404
404
  l[t + n + 3 | 0] = f.charCodeAt(i + n);
405
405
  }
406
406
  }
407
- }, y = function(f, l, d, i, r, t) {
407
+ }, w = function(f, l, d, i, r, t) {
408
408
  var c = void 0, e = t % 4, o = (r + e) % 4, n = r - o;
409
409
  switch (e) {
410
410
  case 0:
@@ -429,39 +429,39 @@ function z() {
429
429
  }
430
430
  }
431
431
  }, u = function(f, l, d, i, r, t) {
432
- var c = void 0, e = t % 4, o = (r + e) % 4, n = r - o, h = new Uint8Array(v.readAsArrayBuffer(f.slice(i, i + r)));
432
+ var c = void 0, e = t % 4, o = (r + e) % 4, n = r - o, p = new Uint8Array(v.readAsArrayBuffer(f.slice(i, i + r)));
433
433
  switch (e) {
434
434
  case 0:
435
- l[t] = h[3];
435
+ l[t] = p[3];
436
436
  case 1:
437
- l[t + 1 - (e << 1) | 0] = h[2];
437
+ l[t + 1 - (e << 1) | 0] = p[2];
438
438
  case 2:
439
- l[t + 2 - (e << 1) | 0] = h[1];
439
+ l[t + 2 - (e << 1) | 0] = p[1];
440
440
  case 3:
441
- l[t + 3 - (e << 1) | 0] = h[0];
441
+ l[t + 3 - (e << 1) | 0] = p[0];
442
442
  }
443
443
  if (!(r < o + (4 - e))) {
444
444
  for (c = 4 - e; c < n; c = c + 4 | 0)
445
- d[t + c >> 2 | 0] = h[c] << 24 | h[c + 1] << 16 | h[c + 2] << 8 | h[c + 3];
445
+ d[t + c >> 2 | 0] = p[c] << 24 | p[c + 1] << 16 | p[c + 2] << 8 | p[c + 3];
446
446
  switch (o) {
447
447
  case 3:
448
- l[t + n + 1 | 0] = h[n + 2];
448
+ l[t + n + 1 | 0] = p[n + 2];
449
449
  case 2:
450
- l[t + n + 2 | 0] = h[n + 1];
450
+ l[t + n + 2 | 0] = p[n + 1];
451
451
  case 1:
452
- l[t + n + 3 | 0] = h[n];
452
+ l[t + n + 3 | 0] = p[n];
453
453
  }
454
454
  }
455
455
  };
456
- x.exports = function(f, l, d, i, r, t) {
456
+ y.exports = function(f, l, d, i, r, t) {
457
457
  if (typeof f == "string")
458
458
  return s(f, l, d, i, r, t);
459
- if (f instanceof Array || p && p.Buffer && p.Buffer.isBuffer(f))
460
- return y(f, l, d, i, r, t);
459
+ if (f instanceof Array || h && h.Buffer && h.Buffer.isBuffer(f))
460
+ return w(f, l, d, i, r, t);
461
461
  if (f instanceof ArrayBuffer)
462
- return y(new Uint8Array(f), l, d, i, r, t);
462
+ return w(new Uint8Array(f), l, d, i, r, t);
463
463
  if (f.buffer instanceof ArrayBuffer)
464
- return y(new Uint8Array(f.buffer, f.byteOffset, f.byteLength), l, d, i, r, t);
464
+ return w(new Uint8Array(f.buffer, f.byteOffset, f.byteLength), l, d, i, r, t);
465
465
  if (f instanceof Blob)
466
466
  return u(f, l, d, i, r, t);
467
467
  throw new Error("Unsupported data type.");
@@ -469,7 +469,7 @@ function z() {
469
469
  },
470
470
  /* 7 */
471
471
  /***/
472
- function(x, b, p) {
472
+ function(y, m, h) {
473
473
  var v = /* @__PURE__ */ function() {
474
474
  function d(i, r) {
475
475
  for (var t = 0; t < r.length; t++) {
@@ -485,9 +485,9 @@ function z() {
485
485
  if (!(d instanceof i))
486
486
  throw new TypeError("Cannot call a class as a function");
487
487
  }
488
- var y = p(0), u = p(1), f = u.toHex, l = function() {
488
+ var w = h(0), u = h(1), f = u.toHex, l = function() {
489
489
  function d() {
490
- s(this, d), this._rusha = new y(), this._rusha.resetState();
490
+ s(this, d), this._rusha = new w(), this._rusha.resetState();
491
491
  }
492
492
  return d.prototype.update = function(r) {
493
493
  return this._rusha.append(r), this;
@@ -508,7 +508,7 @@ function z() {
508
508
  }
509
509
  }]), d;
510
510
  }();
511
- x.exports = function() {
511
+ y.exports = function() {
512
512
  return new l();
513
513
  };
514
514
  }
@@ -519,43 +519,43 @@ function z() {
519
519
  }(L)), L.exports;
520
520
  }
521
521
  var P = z();
522
- const G = /* @__PURE__ */ F(P), J = new G(), R = (g) => g.startsWith(".") || g === "__MACOSX" || g === "node_modules", $ = (g) => g.split("/").some((_) => _ && R(_)), k = (g) => g.startsWith("/") ? g : `/${g}`;
523
- function O(g, _, x) {
522
+ const G = /* @__PURE__ */ I(P), J = new G(), R = (g) => g.startsWith(".") || g === "__MACOSX" || g === "node_modules", $ = (g) => g.split("/").some((_) => _ && R(_)), k = (g) => g.startsWith("/") ? g : `/${g}`;
523
+ function O(g, _, y) {
524
524
  return {
525
525
  path: k(g),
526
526
  size: _.byteLength,
527
527
  sha: J.digest(_),
528
528
  content: _,
529
- name: x
529
+ name: y
530
530
  };
531
531
  }
532
532
  async function D(g) {
533
- const _ = await new Promise((b, p) => g.file(b, p)), x = await _.arrayBuffer();
534
- return O(g.fullPath, x, _.name);
533
+ const _ = await new Promise((m, h) => g.file(m, h)), y = await _.arrayBuffer();
534
+ return O(g.fullPath, y, _.name);
535
535
  }
536
536
  async function B(g) {
537
- const _ = g.createReader(), x = [];
537
+ const _ = g.createReader(), y = [];
538
538
  for (; ; ) {
539
- const b = await new Promise((p, v) => _.readEntries(p, v));
540
- if (!b.length) break;
541
- for (const p of b)
542
- R(p.name) || x.push(...p.isDirectory ? await B(p) : [await D(p)]);
539
+ const m = await new Promise((h, v) => _.readEntries(h, v));
540
+ if (!m.length) break;
541
+ for (const h of m)
542
+ R(h.name) || y.push(...h.isDirectory ? await B(h) : [await D(h)]);
543
543
  }
544
- return x;
544
+ return y;
545
545
  }
546
- async function V(g) {
547
- var p;
548
- const _ = (p = g.files) == null ? void 0 : p[0];
546
+ async function Z(g) {
547
+ var h;
548
+ const _ = (h = g.files) == null ? void 0 : h[0];
549
549
  if (g.files.length === 1 && _ && /\.zip$/i.test(_.name))
550
550
  return U(_);
551
- const b = Array.from(g.items ?? []).map((v) => {
551
+ const m = Array.from(g.items ?? []).map((v) => {
552
552
  var s;
553
553
  return (s = v.webkitGetAsEntry) == null ? void 0 : s.call(v);
554
554
  }).filter(Boolean);
555
- if (b.length) {
555
+ if (m.length) {
556
556
  const v = await Promise.all(
557
- b.map(
558
- (s) => R(s.name) ? [] : s.isDirectory ? B(s) : D(s).then((y) => [y])
557
+ m.map(
558
+ (s) => R(s.name) ? [] : s.isDirectory ? B(s) : D(s).then((w) => [w])
559
559
  )
560
560
  );
561
561
  return E(v.flat());
@@ -566,53 +566,62 @@ async function Y(g) {
566
566
  const _ = Array.from(g);
567
567
  if (_.length === 1 && /\.zip$/i.test(_[0].name))
568
568
  return U(_[0]);
569
- const x = [];
570
- for (const b of _) {
571
- const p = b.webkitRelativePath || b.name;
572
- x.push(O(p, await b.arrayBuffer(), b.name));
569
+ const y = [];
570
+ for (const m of _) {
571
+ const h = m.webkitRelativePath || m.name;
572
+ y.push(O(h, await m.arrayBuffer(), m.name));
573
573
  }
574
- return E(x);
574
+ return E(y);
575
575
  }
576
576
  async function U(g) {
577
- const { unzip: _ } = await import("../../../../chunks/browser.D58rdxmc.js"), x = new Uint8Array(await g.arrayBuffer()), b = await new Promise(
578
- (v, s) => _(x, (y, u) => y ? s(y) : v(u))
579
- ), p = [];
580
- for (const [v, s] of Object.entries(b)) {
577
+ const { unzip: _ } = await import("../../../../chunks/browser.D58rdxmc.js"), y = new Uint8Array(await g.arrayBuffer()), m = await new Promise(
578
+ (v, s) => _(y, (w, u) => w ? s(w) : v(u))
579
+ ), h = [];
580
+ for (const [v, s] of Object.entries(m)) {
581
581
  if (v.endsWith("/") || $(v)) continue;
582
- const y = s.buffer.slice(
582
+ const w = s.buffer.slice(
583
583
  s.byteOffset,
584
584
  s.byteOffset + s.byteLength
585
585
  );
586
- p.push(O(v, y, v.split("/").pop()));
586
+ h.push(O(v, w, v.split("/").pop()));
587
587
  }
588
- return E(p);
588
+ return E(h);
589
589
  }
590
590
  function E(g) {
591
591
  if (!g.length) return g;
592
- const _ = (p) => k(p).split("/").slice(1);
593
- let x = _(g[0].path).slice(0, -1);
594
- for (const p of g) {
595
- const v = _(p.path);
592
+ const _ = (h) => k(h).split("/").slice(1);
593
+ let y = _(g[0].path).slice(0, -1);
594
+ for (const h of g) {
595
+ const v = _(h.path);
596
596
  let s = 0;
597
- for (; s < x.length && s < v.length - 1 && x[s] === v[s]; ) s++;
598
- x = x.slice(0, s);
597
+ for (; s < y.length && s < v.length - 1 && y[s] === v[s]; ) s++;
598
+ y = y.slice(0, s);
599
599
  }
600
- if (!x.length) return g;
601
- const b = "/" + x.join("/");
602
- return g.map((p) => ({ ...p, path: k(p.path.slice(b.length)) }));
600
+ if (!y.length) return g;
601
+ const m = "/" + y.join("/");
602
+ return g.map((h) => ({ ...h, path: k(h.path.slice(m.length)) }));
603
603
  }
604
604
  const W = (g) => g.filter((_) => /\.html?$/i.test(_.name)), j = (g) => g.some((_) => /^index\.html?$/i.test(_.name));
605
- function Z(g) {
605
+ function Q(g) {
606
606
  const _ = W(g);
607
607
  return j(_) ? null : _.length === 1 ? _[0].name : null;
608
608
  }
609
- function X(g) {
609
+ function N(g) {
610
610
  const _ = W(g);
611
611
  return _.length > 1 && !j(_);
612
612
  }
613
+ function X(g) {
614
+ const _ = Q(g);
615
+ return _ ? g.map((y) => {
616
+ if (y.name !== _) return y;
617
+ const m = y.path.lastIndexOf("/"), h = m === -1 ? "" : y.path.slice(0, m);
618
+ return { ...y, name: "index.html", path: k(`${h}/index.html`) };
619
+ }) : g;
620
+ }
613
621
  export {
614
- Z as getSingleNonIndexHtmlFileName,
615
- X as hasMultipleHtmlFilesWithoutIndex,
616
- V as readDataTransfer,
617
- Y as readFileList
622
+ Q as getSingleNonIndexHtmlFileName,
623
+ N as hasMultipleHtmlFilesWithoutIndex,
624
+ Z as readDataTransfer,
625
+ Y as readFileList,
626
+ X as renameSingleNonIndexHtmlToIndex
618
627
  };
@@ -1,67 +1,71 @@
1
- import { d as m, A as x } from "../../../chunks/hooks.module.DRcxknIz.js";
2
- import { getSingleNonIndexHtmlFileName as S, hasMultipleHtmlFilesWithoutIndex as b } from "./drop-core/readFiles.js";
3
- import { AnonymousDropClient as I } from "./drop-core/client.js";
4
- import { deployFiles as z } from "./drop-core/deploy.js";
5
- function F(n) {
6
- switch (n.phase) {
1
+ import { d as p, A as I } from "../../../chunks/hooks.module.DRcxknIz.js";
2
+ import { renameSingleNonIndexHtmlToIndex as S, getSingleNonIndexHtmlFileName as b, hasMultipleHtmlFilesWithoutIndex as z } from "./drop-core/readFiles.js";
3
+ import { AnonymousDropClient as F } from "./drop-core/client.js";
4
+ import { deployFiles as H } from "./drop-core/deploy.js";
5
+ import { humanizeDropError as E } from "./drop-core/errors.js";
6
+ function W(e) {
7
+ switch (e.phase) {
7
8
  case "creating":
8
9
  return { kind: "creating" };
9
10
  case "uploading":
10
- return { kind: "uploading", uploaded: n.uploaded ?? 0, total: n.total ?? 0 };
11
+ return { kind: "uploading", uploaded: e.uploaded ?? 0, total: e.total ?? 0 };
11
12
  case "processing":
12
13
  case "ready":
13
14
  return { kind: "processing" };
14
15
  }
15
16
  }
16
- function H(n) {
17
- const i = S(n);
18
- return i ? `No index.html found — "${i}" won’t be served at the site root.` : b(n) ? "No index.html found — your site may not have a landing page." : null;
17
+ function $(e) {
18
+ const d = b(e);
19
+ return d ? `No index.html found — "${d}" won’t be served at the site root.` : z(e) ? "No index.html found — your site may not have a landing page." : null;
19
20
  }
20
- function C({
21
- apiBase: n,
22
- client: i,
23
- claimUrl: g,
24
- onDeploy: d,
25
- track: s
21
+ function P({
22
+ apiBase: e,
23
+ client: d,
24
+ claimUrl: f,
25
+ onDeploy: l,
26
+ track: a
26
27
  }) {
27
- const [a, t] = m({ kind: "idle" }), [f, l] = m(null), h = x(i ?? new I(n)).current, k = a.kind !== "idle" && a.kind !== "error";
28
- async function y(w, r) {
29
- l(null), t({ kind: "reading" });
30
- const p = (e, u) => {
31
- t({ kind: "error", message: e }), s("dropzone_deploy_failed", { method: r, reason: e, ...u });
28
+ const [u, t] = p({ kind: "idle" }), [g, c] = p(null), h = I(d ?? new F(e)).current, y = u.kind !== "idle" && u.kind !== "error";
29
+ async function k(N, s) {
30
+ c(null), t({ kind: "reading" });
31
+ const m = (n, i, o) => {
32
+ t({ kind: "error", message: n }), a("dropzone_deploy_failed", { method: s, reason: i, ...o });
33
+ }, x = (n, i) => {
34
+ const o = n instanceof Error ? n.message : String(n);
35
+ m(E(n), o, i);
32
36
  };
33
37
  try {
34
- const e = await w();
35
- if (!e.length) {
36
- p("No files found to deploy.", { file_count: 0 });
38
+ const n = S(await N());
39
+ if (!n.length) {
40
+ m("No files found to deploy.", "No files found to deploy.", { file_count: 0 });
37
41
  return;
38
42
  }
39
- r === "drag" && s("dropzone_files_dropped", { method: r, file_count: e.length }), l(H(e));
43
+ s === "drag" && a("dropzone_files_dropped", { method: s, file_count: n.length }), c($(n));
40
44
  const {
41
- url: u,
42
- token: c,
43
- deploy: o
44
- } = await z(h, e, {
45
- onProgress: (N) => t(F(N))
45
+ url: i,
46
+ token: o,
47
+ deploy: r
48
+ } = await H(h, n, {
49
+ onProgress: (w) => t(W(w))
46
50
  });
47
51
  try {
48
- localStorage.setItem("drop-token", c), localStorage.setItem("dropSiteName", o.subdomain);
52
+ localStorage.setItem("drop-token", o), localStorage.setItem("dropSiteName", r.subdomain);
49
53
  } catch {
50
54
  }
51
- t({ kind: "redirecting" }), s("dropzone_deploy_succeeded", {
52
- method: r,
53
- site_name: o.subdomain,
54
- file_count: e.length
55
- }), d == null || d({ url: u, token: c, siteName: o.subdomain, siteId: o.id }), window.location.assign(`${g(o.subdomain)}#drop_token=${c}`);
56
- } catch (e) {
57
- p(e instanceof Error ? e.message : String(e));
55
+ t({ kind: "redirecting" }), a("dropzone_deploy_succeeded", {
56
+ method: s,
57
+ site_name: r.subdomain,
58
+ file_count: n.length
59
+ }), l == null || l({ url: i, token: o, siteName: r.subdomain, siteId: r.id }), window.location.assign(`${f(r.subdomain)}#drop_token=${o}`);
60
+ } catch (n) {
61
+ x(n);
58
62
  }
59
63
  }
60
64
  function _() {
61
- l(null), t({ kind: "idle" });
65
+ c(null), t({ kind: "idle" });
62
66
  }
63
- return { status: a, warning: f, busy: k, deploy: y, reset: _ };
67
+ return { status: u, warning: g, busy: y, deploy: k, reset: _ };
64
68
  }
65
69
  export {
66
- C as useDropDeploy
70
+ P as useDropDeploy
67
71
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@netlify/spark-ui",
3
3
  "description": "Assets, design tokens, components, and utilities",
4
- "version": "1.27.3",
4
+ "version": "1.27.5",
5
5
  "type": "module",
6
6
  "main": "dist/components/preact/index.js",
7
7
  "types": "dist/components/preact/index.d.ts",
@@ -1,5 +1,10 @@
1
1
  import type { DropResponse, Digest } from './types';
2
2
 
3
+ /** A normal Error with the response's HTTP status attached, so callers can branch on it directly. */
4
+ function apiError(action: string, status: number): Error & { status: number } {
5
+ return Object.assign(new Error(`${action} failed: ${status}`), { status });
6
+ }
7
+
3
8
  export interface DropClient {
4
9
  getToken(): Promise<string>;
5
10
  createDeploy(digest: Digest, token: string): Promise<DropResponse>;
@@ -18,7 +23,7 @@ export class AnonymousDropClient implements DropClient {
18
23
 
19
24
  async getToken(): Promise<string> {
20
25
  const res = await fetch(`${this.apiBase}/drop/token`, { method: 'POST' });
21
- if (!res.ok) throw new Error(`drop/token failed: ${res.status}`);
26
+ if (!res.ok) throw apiError('drop/token', res.status);
22
27
  return (await res.json()).token;
23
28
  }
24
29
 
@@ -28,7 +33,7 @@ export class AnonymousDropClient implements DropClient {
28
33
  headers: { 'Content-Type': 'application/json' },
29
34
  body: JSON.stringify({ files, token }),
30
35
  });
31
- if (!res.ok) throw new Error(`drop failed: ${res.status}`);
36
+ if (!res.ok) throw apiError('drop', res.status);
32
37
  return res.json();
33
38
  }
34
39
 
@@ -44,7 +49,7 @@ export class AnonymousDropClient implements DropClient {
44
49
  headers: { 'Content-Type': 'application/octet-stream', Authorization: `Bearer ${token}` },
45
50
  body: content,
46
51
  });
47
- if (!res.ok) throw new Error(`upload ${path} failed: ${res.status}`);
52
+ if (!res.ok) throw apiError(`upload ${path}`, res.status);
48
53
  }
49
54
 
50
55
  async waitUntilReady(deploy: DropResponse, token: string): Promise<void> {
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Turn a raw deploy failure into copy a non-technical user can act on.
3
+ * The original message is still tracked via analytics — this is only for display.
4
+ */
5
+ export function humanizeDropError(err: unknown): string {
6
+ if (!(err instanceof Error)) return 'Something went wrong. Please try again.';
7
+
8
+ if (err.message === 'Deploy did not become ready in time') {
9
+ return 'Your site is taking longer than expected to go live. Please try again in a moment.';
10
+ }
11
+ // fetch() rejects with a TypeError when the network is unreachable (offline, DNS, CORS, etc).
12
+ if (err instanceof TypeError) {
13
+ return "Couldn't connect to Netlify. Check your internet connection and try again.";
14
+ }
15
+
16
+ // client.ts attaches `.status` to API failures — see apiError().
17
+ const status = 'status' in err && typeof err.status === 'number' ? err.status : undefined;
18
+
19
+ switch (status) {
20
+ case 429:
21
+ return 'Too many attempts — please wait a moment and try again.';
22
+ case 413:
23
+ return 'Your upload is too large to deploy this way.';
24
+ case 404:
25
+ return "We couldn't find that deploy. Please try again.";
26
+ case 401:
27
+ case 403:
28
+ return "That request wasn't allowed. Please try again.";
29
+ case 500:
30
+ case 502:
31
+ case 503:
32
+ case 504:
33
+ return "Netlify's servers are having trouble right now. Please try again shortly.";
34
+ default:
35
+ return status
36
+ ? 'Something went wrong talking to Netlify. Please try again.'
37
+ : 'Something went wrong. Please try again.';
38
+ }
39
+ }
@@ -3,3 +3,4 @@ export * from './digest';
3
3
  export * from './readFiles';
4
4
  export * from './client';
5
5
  export * from './deploy';
6
+ export * from './errors';
@@ -146,3 +146,21 @@ export function hasMultipleHtmlFilesWithoutIndex(files: ProcessedFile[]): boolea
146
146
  const html = htmlFiles(files);
147
147
  return html.length > 1 && !hasIndex(html);
148
148
  }
149
+
150
+ /**
151
+ * When the set has no index.html but exactly one HTML file (a lone page
152
+ * alongside its assets, or a single dropped file), rename that file to
153
+ * index.html — keeping its directory — so it is served at the site root
154
+ * instead of 404ing. Content and sha are untouched. Any other set (already has
155
+ * an index, multiple HTML files, or no HTML) is returned unchanged.
156
+ */
157
+ export function renameSingleNonIndexHtmlToIndex(files: ProcessedFile[]): ProcessedFile[] {
158
+ const name = getSingleNonIndexHtmlFileName(files);
159
+ if (!name) return files;
160
+ return files.map(f => {
161
+ if (f.name !== name) return f;
162
+ const slash = f.path.lastIndexOf('/');
163
+ const dir = slash === -1 ? '' : f.path.slice(0, slash);
164
+ return { ...f, name: 'index.html', path: slashPrefix(`${dir}/index.html`) };
165
+ });
166
+ }
@@ -4,6 +4,8 @@ import {
4
4
  deployFiles,
5
5
  getSingleNonIndexHtmlFileName,
6
6
  hasMultipleHtmlFilesWithoutIndex,
7
+ humanizeDropError,
8
+ renameSingleNonIndexHtmlToIndex,
7
9
  type DeployProgress,
8
10
  type DropClient,
9
11
  type ProcessedFile,
@@ -92,15 +94,26 @@ export function useDropDeploy({
92
94
  // read/deploy throw) reports uniformly — the mirror of the
93
95
  // `dropzone_deploy_succeeded` event on the happy path. `file_count` is only
94
96
  // included where the file set is known (it isn't if `read()` itself threw).
95
- const fail = (message: string, extra?: Record<string, unknown>) => {
97
+ // `reason` goes to analytics as-is (raw, e.g. "drop failed: 429"); `message`
98
+ // is what the user sees, which for a caught error is humanized separately.
99
+ const fail = (message: string, reason: string, extra?: Record<string, unknown>) => {
96
100
  setStatus({ kind: 'error', message });
97
- track('dropzone_deploy_failed', { method: source, reason: message, ...extra });
101
+ track('dropzone_deploy_failed', { method: source, reason, ...extra });
102
+ };
103
+
104
+ const failFromError = (err: unknown, extra?: Record<string, unknown>) => {
105
+ const reason = err instanceof Error ? err.message : String(err);
106
+ fail(humanizeDropError(err), reason, extra);
98
107
  };
99
108
 
100
109
  try {
101
- const files = await read();
110
+ // Auto-rename a lone non-index HTML file to index.html so it is served at
111
+ // the site root. Detection (getSingleNonIndexHtmlFileName) sits on the
112
+ // read side; recompute the warning on the renamed set so the fixable
113
+ // single-file case no longer warns and only the multi-HTML case does.
114
+ const files = renameSingleNonIndexHtmlToIndex(await read());
102
115
  if (!files.length) {
103
- fail('No files found to deploy.', { file_count: 0 });
116
+ fail('No files found to deploy.', 'No files found to deploy.', { file_count: 0 });
104
117
  return;
105
118
  }
106
119
 
@@ -147,7 +160,7 @@ export function useDropDeploy({
147
160
  // `#drop_token=` and persists it for the claim + post-signup steps.
148
161
  window.location.assign(`${claimUrl(result.subdomain)}#drop_token=${token}`);
149
162
  } catch (err) {
150
- fail(err instanceof Error ? err.message : String(err));
163
+ failFromError(err);
151
164
  }
152
165
  }
153
166